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 into for-davem

Conflicts:
include/net/bluetooth/bluetooth.h

+9029 -6464
+3
arch/alpha/include/asm/socket.h
··· 69 69 70 70 #define SO_RXQ_OVFL 40 71 71 72 + #define SO_WIFI_STATUS 41 73 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 74 + 72 75 /* O_NONBLOCK clashes with the bits used for socket types. Therefore we 73 76 * have to define SOCK_NONBLOCK to a different value here. 74 77 */
+3
arch/arm/include/asm/socket.h
··· 62 62 63 63 #define SO_RXQ_OVFL 40 64 64 65 + #define SO_WIFI_STATUS 41 66 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 67 + 65 68 #endif /* _ASM_SOCKET_H */
+3
arch/avr32/include/asm/socket.h
··· 62 62 63 63 #define SO_RXQ_OVFL 40 64 64 65 + #define SO_WIFI_STATUS 41 66 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 67 + 65 68 #endif /* __ASM_AVR32_SOCKET_H */
+3
arch/cris/include/asm/socket.h
··· 64 64 65 65 #define SO_RXQ_OVFL 40 66 66 67 + #define SO_WIFI_STATUS 41 68 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 69 + 67 70 #endif /* _ASM_SOCKET_H */ 68 71 69 72
+3
arch/frv/include/asm/socket.h
··· 62 62 63 63 #define SO_RXQ_OVFL 40 64 64 65 + #define SO_WIFI_STATUS 41 66 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 67 + 65 68 #endif /* _ASM_SOCKET_H */ 66 69
+3
arch/h8300/include/asm/socket.h
··· 62 62 63 63 #define SO_RXQ_OVFL 40 64 64 65 + #define SO_WIFI_STATUS 41 66 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 67 + 65 68 #endif /* _ASM_SOCKET_H */
+3
arch/ia64/include/asm/socket.h
··· 71 71 72 72 #define SO_RXQ_OVFL 40 73 73 74 + #define SO_WIFI_STATUS 41 75 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 76 + 74 77 #endif /* _ASM_IA64_SOCKET_H */
+3
arch/m32r/include/asm/socket.h
··· 62 62 63 63 #define SO_RXQ_OVFL 40 64 64 65 + #define SO_WIFI_STATUS 41 66 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 67 + 65 68 #endif /* _ASM_M32R_SOCKET_H */
+3
arch/m68k/include/asm/socket.h
··· 62 62 63 63 #define SO_RXQ_OVFL 40 64 64 65 + #define SO_WIFI_STATUS 41 66 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 67 + 65 68 #endif /* _ASM_SOCKET_H */
+3
arch/mips/include/asm/socket.h
··· 82 82 83 83 #define SO_RXQ_OVFL 40 84 84 85 + #define SO_WIFI_STATUS 41 86 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 87 + 85 88 #ifdef __KERNEL__ 86 89 87 90 /** sock_type - Socket types
+3
arch/mn10300/include/asm/socket.h
··· 62 62 63 63 #define SO_RXQ_OVFL 40 64 64 65 + #define SO_WIFI_STATUS 41 66 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 67 + 65 68 #endif /* _ASM_SOCKET_H */
+3
arch/parisc/include/asm/socket.h
··· 61 61 62 62 #define SO_RXQ_OVFL 0x4021 63 63 64 + #define SO_WIFI_STATUS 0x4022 65 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 66 + 64 67 /* O_NONBLOCK clashes with the bits used for socket types. Therefore we 65 68 * have to define SOCK_NONBLOCK to a different value here. 66 69 */
+3
arch/powerpc/include/asm/socket.h
··· 69 69 70 70 #define SO_RXQ_OVFL 40 71 71 72 + #define SO_WIFI_STATUS 41 73 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 74 + 72 75 #endif /* _ASM_POWERPC_SOCKET_H */
+3
arch/s390/include/asm/socket.h
··· 70 70 71 71 #define SO_RXQ_OVFL 40 72 72 73 + #define SO_WIFI_STATUS 41 74 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 75 + 73 76 #endif /* _ASM_SOCKET_H */
+3
arch/sparc/include/asm/socket.h
··· 58 58 59 59 #define SO_RXQ_OVFL 0x0024 60 60 61 + #define SO_WIFI_STATUS 0x0025 62 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 63 + 61 64 /* Security levels - as per NRL IPv6 - don't actually do anything */ 62 65 #define SO_SECURITY_AUTHENTICATION 0x5001 63 66 #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
+3
arch/xtensa/include/asm/socket.h
··· 73 73 74 74 #define SO_RXQ_OVFL 40 75 75 76 + #define SO_WIFI_STATUS 41 77 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 78 + 76 79 #endif /* _XTENSA_SOCKET_H */
+11 -4
drivers/bluetooth/ath3k.c
··· 30 30 #include <net/bluetooth/bluetooth.h> 31 31 32 32 #define VERSION "1.0" 33 + #define ATH3K_FIRMWARE "ath3k-1.fw" 33 34 34 35 #define ATH3K_DNLOAD 0x01 35 36 #define ATH3K_GETSTATE 0x05 ··· 401 400 return 0; 402 401 } 403 402 404 - if (request_firmware(&firmware, "ath3k-1.fw", &udev->dev) < 0) { 405 - BT_ERR("Error loading firmware"); 406 - return -EIO; 403 + ret = request_firmware(&firmware, ATH3K_FIRMWARE, &udev->dev); 404 + if (ret < 0) { 405 + if (ret == -ENOENT) 406 + BT_ERR("Firmware file \"%s\" not found", 407 + ATH3K_FIRMWARE); 408 + else 409 + BT_ERR("Firmware file \"%s\" request failed (err=%d)", 410 + ATH3K_FIRMWARE, ret); 411 + return ret; 407 412 } 408 413 409 414 ret = ath3k_load_firmware(udev, firmware); ··· 448 441 MODULE_DESCRIPTION("Atheros AR30xx firmware driver"); 449 442 MODULE_VERSION(VERSION); 450 443 MODULE_LICENSE("GPL"); 451 - MODULE_FIRMWARE("ath3k-1.fw"); 444 + MODULE_FIRMWARE(ATH3K_FIRMWARE);
+1 -3
drivers/bluetooth/bfusb.c
··· 751 751 752 752 bfusb_close(hdev); 753 753 754 - if (hci_unregister_dev(hdev) < 0) 755 - BT_ERR("Can't unregister HCI device %s", hdev->name); 756 - 754 + hci_unregister_dev(hdev); 757 755 hci_free_dev(hdev); 758 756 } 759 757
+1 -3
drivers/bluetooth/bluecard_cs.c
··· 844 844 /* Turn FPGA off */ 845 845 outb(0x80, iobase + 0x30); 846 846 847 - if (hci_unregister_dev(hdev) < 0) 848 - BT_ERR("Can't unregister HCI device %s", hdev->name); 849 - 847 + hci_unregister_dev(hdev); 850 848 hci_free_dev(hdev); 851 849 852 850 return 0;
+1 -3
drivers/bluetooth/bt3c_cs.c
··· 636 636 637 637 bt3c_hci_close(hdev); 638 638 639 - if (hci_unregister_dev(hdev) < 0) 640 - BT_ERR("Can't unregister HCI device %s", hdev->name); 641 - 639 + hci_unregister_dev(hdev); 642 640 hci_free_dev(hdev); 643 641 644 642 return 0;
+1 -3
drivers/bluetooth/btuart_cs.c
··· 565 565 566 566 spin_unlock_irqrestore(&(info->lock), flags); 567 567 568 - if (hci_unregister_dev(hdev) < 0) 569 - BT_ERR("Can't unregister HCI device %s", hdev->name); 570 - 568 + hci_unregister_dev(hdev); 571 569 hci_free_dev(hdev); 572 570 573 571 return 0;
+15 -4
drivers/bluetooth/btusb.c
··· 100 100 /* Canyon CN-BTU1 with HID interfaces */ 101 101 { USB_DEVICE(0x0c10, 0x0000) }, 102 102 103 + /* Broadcom BCM20702A0 */ 104 + { USB_DEVICE(0x413c, 0x8197) }, 105 + 103 106 { } /* Terminating entry */ 104 107 }; 105 108 ··· 315 312 316 313 err = usb_submit_urb(urb, mem_flags); 317 314 if (err < 0) { 318 - BT_ERR("%s urb %p submission failed (%d)", 315 + if (err != -EPERM && err != -ENODEV) 316 + BT_ERR("%s urb %p submission failed (%d)", 319 317 hdev->name, urb, -err); 320 318 usb_unanchor_urb(urb); 321 319 } ··· 401 397 402 398 err = usb_submit_urb(urb, mem_flags); 403 399 if (err < 0) { 404 - BT_ERR("%s urb %p submission failed (%d)", 400 + if (err != -EPERM && err != -ENODEV) 401 + BT_ERR("%s urb %p submission failed (%d)", 405 402 hdev->name, urb, -err); 406 403 usb_unanchor_urb(urb); 407 404 } ··· 525 520 526 521 err = usb_submit_urb(urb, mem_flags); 527 522 if (err < 0) { 528 - BT_ERR("%s urb %p submission failed (%d)", 523 + if (err != -EPERM && err != -ENODEV) 524 + BT_ERR("%s urb %p submission failed (%d)", 529 525 hdev->name, urb, -err); 530 526 usb_unanchor_urb(urb); 531 527 } ··· 730 724 usb_fill_bulk_urb(urb, data->udev, pipe, 731 725 skb->data, skb->len, btusb_tx_complete, skb); 732 726 727 + if (skb->priority >= HCI_PRIO_MAX - 1) 728 + urb->transfer_flags = URB_ISO_ASAP; 729 + 733 730 hdev->stat.acl_tx++; 734 731 break; 735 732 ··· 776 767 777 768 err = usb_submit_urb(urb, GFP_ATOMIC); 778 769 if (err < 0) { 779 - BT_ERR("%s urb %p submission failed", hdev->name, urb); 770 + if (err != -EPERM && err != -ENODEV) 771 + BT_ERR("%s urb %p submission failed (%d)", 772 + hdev->name, urb, -err); 780 773 kfree(urb->setup_packet); 781 774 usb_unanchor_urb(urb); 782 775 } else {
+1 -3
drivers/bluetooth/dtl1_cs.c
··· 551 551 552 552 spin_unlock_irqrestore(&(info->lock), flags); 553 553 554 - if (hci_unregister_dev(hdev) < 0) 555 - BT_ERR("Can't unregister HCI device %s", hdev->name); 556 - 554 + hci_unregister_dev(hdev); 557 555 hci_free_dev(hdev); 558 556 559 557 return 0;
+1 -4
drivers/bluetooth/hci_vhci.c
··· 264 264 struct vhci_data *data = file->private_data; 265 265 struct hci_dev *hdev = data->hdev; 266 266 267 - if (hci_unregister_dev(hdev) < 0) { 268 - BT_ERR("Can't unregister HCI device %s", hdev->name); 269 - } 270 - 267 + hci_unregister_dev(hdev); 271 268 hci_free_dev(hdev); 272 269 273 270 file->private_data = NULL;
+3 -3
drivers/net/wireless/Makefile
··· 58 58 obj-$(CONFIG_IWM) += iwmc3200wifi/ 59 59 60 60 obj-$(CONFIG_MWIFIEX) += mwifiex/ 61 - obj-$(CONFIG_BRCMFMAC) += brcm80211/ 62 - obj-$(CONFIG_BRCMUMAC) += brcm80211/ 63 - obj-$(CONFIG_BRCMSMAC) += brcm80211/ 61 + 62 + obj-$(CONFIG_BRCMFMAC) += brcm80211/ 63 + obj-$(CONFIG_BRCMSMAC) += brcm80211/
+1
drivers/net/wireless/ath/ath.h
··· 239 239 ATH_DBG_BTCOEX = 0x00002000, 240 240 ATH_DBG_WMI = 0x00004000, 241 241 ATH_DBG_BSTUCK = 0x00008000, 242 + ATH_DBG_MCI = 0x00010000, 242 243 ATH_DBG_ANY = 0xffffffff 243 244 }; 244 245
+2 -1
drivers/net/wireless/ath/ath6kl/cfg80211.c
··· 1734 1734 struct ieee80211_channel *chan, bool offchan, 1735 1735 enum nl80211_channel_type channel_type, 1736 1736 bool channel_type_valid, unsigned int wait, 1737 - const u8 *buf, size_t len, bool no_cck, u64 *cookie) 1737 + const u8 *buf, size_t len, bool no_cck, 1738 + bool dont_wait_for_ack, u64 *cookie) 1738 1739 { 1739 1740 struct ath6kl *ar = ath6kl_priv(dev); 1740 1741 u32 id;
+2 -1
drivers/net/wireless/ath/ath6kl/init.c
··· 1548 1548 ar->conf_flags = ATH6KL_CONF_IGNORE_ERP_BARKER | 1549 1549 ATH6KL_CONF_ENABLE_11N | ATH6KL_CONF_ENABLE_TX_BURST; 1550 1550 1551 - ar->wdev->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM; 1551 + ar->wdev->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | 1552 + WIPHY_FLAG_HAVE_AP_SME; 1552 1553 1553 1554 status = ath6kl_target_config_wlan_params(ar); 1554 1555 if (!status)
+1
drivers/net/wireless/ath/ath9k/Kconfig
··· 25 25 26 26 config ATH9K_PCI 27 27 bool "Atheros ath9k PCI/PCIe bus support" 28 + default y 28 29 depends on ATH9K && PCI 29 30 ---help--- 30 31 This option enables the PCI bus support in ath9k.
+1
drivers/net/wireless/ath/ath9k/Makefile
··· 4 4 main.o \ 5 5 recv.o \ 6 6 xmit.o \ 7 + mci.o \ 7 8 8 9 ath9k-$(CONFIG_ATH9K_RATE_CONTROL) += rc.o 9 10 ath9k-$(CONFIG_ATH9K_PCI) += pci.o
+75 -65
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
··· 121 121 * if the register is per chain 122 122 */ 123 123 .noiseFloorThreshCh = {-1, 0, 0}, 124 - .ob = {1, 1, 1},/* 3 chain */ 125 - .db_stage2 = {1, 1, 1}, /* 3 chain */ 126 - .db_stage3 = {0, 0, 0}, 127 - .db_stage4 = {0, 0, 0}, 124 + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 125 + .quick_drop = 0, 128 126 .xpaBiasLvl = 0, 129 127 .txFrameToDataStart = 0x0e, 130 128 .txFrameToPaOn = 0x0e, ··· 142 144 }, 143 145 .base_ext1 = { 144 146 .ant_div_control = 0, 145 - .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 147 + .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 146 148 }, 147 149 .calFreqPier2G = { 148 150 FREQ2FBIN(2412, 1), ··· 321 323 .spurChans = {0, 0, 0, 0, 0}, 322 324 /* noiseFloorThreshCh Check if the register is per chain */ 323 325 .noiseFloorThreshCh = {-1, 0, 0}, 324 - .ob = {3, 3, 3}, /* 3 chain */ 325 - .db_stage2 = {3, 3, 3}, /* 3 chain */ 326 - .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ 327 - .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ 326 + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 327 + .quick_drop = 0, 328 328 .xpaBiasLvl = 0, 329 329 .txFrameToDataStart = 0x0e, 330 330 .txFrameToPaOn = 0x0e, ··· 694 698 * if the register is per chain 695 699 */ 696 700 .noiseFloorThreshCh = {-1, 0, 0}, 697 - .ob = {1, 1, 1},/* 3 chain */ 698 - .db_stage2 = {1, 1, 1}, /* 3 chain */ 699 - .db_stage3 = {0, 0, 0}, 700 - .db_stage4 = {0, 0, 0}, 701 + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 702 + .quick_drop = 0, 701 703 .xpaBiasLvl = 0, 702 704 .txFrameToDataStart = 0x0e, 703 705 .txFrameToPaOn = 0x0e, ··· 715 721 }, 716 722 .base_ext1 = { 717 723 .ant_div_control = 0, 718 - .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 724 + .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 719 725 }, 720 726 .calFreqPier2G = { 721 727 FREQ2FBIN(2412, 1), ··· 894 900 .spurChans = {FREQ2FBIN(5500, 0), 0, 0, 0, 0}, 895 901 /* noiseFloorThreshCh Check if the register is per chain */ 896 902 .noiseFloorThreshCh = {-1, 0, 0}, 897 - .ob = {3, 3, 3}, /* 3 chain */ 898 - .db_stage2 = {3, 3, 3}, /* 3 chain */ 899 - .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ 900 - .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ 903 + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 904 + .quick_drop = 0, 901 905 .xpaBiasLvl = 0xf, 902 906 .txFrameToDataStart = 0x0e, 903 907 .txFrameToPaOn = 0x0e, ··· 1268 1276 * if the register is per chain 1269 1277 */ 1270 1278 .noiseFloorThreshCh = {-1, 0, 0}, 1271 - .ob = {1, 1, 1},/* 3 chain */ 1272 - .db_stage2 = {1, 1, 1}, /* 3 chain */ 1273 - .db_stage3 = {0, 0, 0}, 1274 - .db_stage4 = {0, 0, 0}, 1279 + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1280 + .quick_drop = 0, 1275 1281 .xpaBiasLvl = 0, 1276 1282 .txFrameToDataStart = 0x0e, 1277 1283 .txFrameToPaOn = 0x0e, ··· 1281 1291 .txEndToRxOn = 0x2, 1282 1292 .txFrameToXpaOn = 0xe, 1283 1293 .thresh62 = 28, 1284 - .papdRateMaskHt20 = LE32(0x80c080), 1285 - .papdRateMaskHt40 = LE32(0x80c080), 1294 + .papdRateMaskHt20 = LE32(0x0c80c080), 1295 + .papdRateMaskHt40 = LE32(0x0080c080), 1286 1296 .futureModal = { 1287 1297 0, 0, 0, 0, 0, 0, 0, 0, 1288 1298 }, 1289 1299 }, 1290 1300 .base_ext1 = { 1291 1301 .ant_div_control = 0, 1292 - .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 1302 + .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 1293 1303 }, 1294 1304 .calFreqPier2G = { 1295 1305 FREQ2FBIN(2412, 1), 1296 1306 FREQ2FBIN(2437, 1), 1297 - FREQ2FBIN(2472, 1), 1307 + FREQ2FBIN(2462, 1), 1298 1308 }, 1299 1309 /* ar9300_cal_data_per_freq_op_loop 2g */ 1300 1310 .calPierData2G = { ··· 1304 1314 }, 1305 1315 .calTarget_freqbin_Cck = { 1306 1316 FREQ2FBIN(2412, 1), 1307 - FREQ2FBIN(2484, 1), 1317 + FREQ2FBIN(2472, 1), 1308 1318 }, 1309 1319 .calTarget_freqbin_2G = { 1310 1320 FREQ2FBIN(2412, 1), ··· 1468 1478 .spurChans = {0, 0, 0, 0, 0}, 1469 1479 /* noiseFloorThreshCh Check if the register is per chain */ 1470 1480 .noiseFloorThreshCh = {-1, 0, 0}, 1471 - .ob = {3, 3, 3}, /* 3 chain */ 1472 - .db_stage2 = {3, 3, 3}, /* 3 chain */ 1473 - .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ 1474 - .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ 1481 + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1482 + .quick_drop = 0, 1475 1483 .xpaBiasLvl = 0, 1476 1484 .txFrameToDataStart = 0x0e, 1477 1485 .txFrameToPaOn = 0x0e, ··· 1503 1515 FREQ2FBIN(5500, 0), 1504 1516 FREQ2FBIN(5600, 0), 1505 1517 FREQ2FBIN(5700, 0), 1506 - FREQ2FBIN(5825, 0) 1518 + FREQ2FBIN(5785, 0) 1507 1519 }, 1508 1520 .calPierData5G = { 1509 1521 { ··· 1842 1854 * if the register is per chain 1843 1855 */ 1844 1856 .noiseFloorThreshCh = {-1, 0, 0}, 1845 - .ob = {1, 1, 1},/* 3 chain */ 1846 - .db_stage2 = {1, 1, 1}, /* 3 chain */ 1847 - .db_stage3 = {0, 0, 0}, 1848 - .db_stage4 = {0, 0, 0}, 1857 + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1858 + .quick_drop = 0, 1849 1859 .xpaBiasLvl = 0, 1850 1860 .txFrameToDataStart = 0x0e, 1851 1861 .txFrameToPaOn = 0x0e, ··· 1863 1877 }, 1864 1878 .base_ext1 = { 1865 1879 .ant_div_control = 0, 1866 - .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 1880 + .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 1867 1881 }, 1868 1882 .calFreqPier2G = { 1869 1883 FREQ2FBIN(2412, 1), ··· 2042 2056 .spurChans = {0, 0, 0, 0, 0}, 2043 2057 /* noiseFloorThreshch check if the register is per chain */ 2044 2058 .noiseFloorThreshCh = {-1, 0, 0}, 2045 - .ob = {3, 3, 3}, /* 3 chain */ 2046 - .db_stage2 = {3, 3, 3}, /* 3 chain */ 2047 - .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ 2048 - .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ 2059 + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 2060 + .quick_drop = 0, 2049 2061 .xpaBiasLvl = 0, 2050 2062 .txFrameToDataStart = 0x0e, 2051 2063 .txFrameToPaOn = 0x0e, ··· 2415 2431 * if the register is per chain 2416 2432 */ 2417 2433 .noiseFloorThreshCh = {-1, 0, 0}, 2418 - .ob = {1, 1, 1},/* 3 chain */ 2419 - .db_stage2 = {1, 1, 1}, /* 3 chain */ 2420 - .db_stage3 = {0, 0, 0}, 2421 - .db_stage4 = {0, 0, 0}, 2434 + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 2435 + .quick_drop = 0, 2422 2436 .xpaBiasLvl = 0, 2423 2437 .txFrameToDataStart = 0x0e, 2424 2438 .txFrameToPaOn = 0x0e, ··· 2436 2454 }, 2437 2455 .base_ext1 = { 2438 2456 .ant_div_control = 0, 2439 - .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 2457 + .future = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} 2440 2458 }, 2441 2459 .calFreqPier2G = { 2442 2460 FREQ2FBIN(2412, 1), 2443 2461 FREQ2FBIN(2437, 1), 2444 - FREQ2FBIN(2472, 1), 2462 + FREQ2FBIN(2462, 1), 2445 2463 }, 2446 2464 /* ar9300_cal_data_per_freq_op_loop 2g */ 2447 2465 .calPierData2G = { ··· 2615 2633 .spurChans = {0, 0, 0, 0, 0}, 2616 2634 /* noiseFloorThreshCh Check if the register is per chain */ 2617 2635 .noiseFloorThreshCh = {-1, 0, 0}, 2618 - .ob = {3, 3, 3}, /* 3 chain */ 2619 - .db_stage2 = {3, 3, 3}, /* 3 chain */ 2620 - .db_stage3 = {3, 3, 3}, /* doesn't exist for 2G */ 2621 - .db_stage4 = {3, 3, 3}, /* don't exist for 2G */ 2636 + .reserved = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 2637 + .quick_drop = 0, 2622 2638 .xpaBiasLvl = 0, 2623 2639 .txFrameToDataStart = 0x0e, 2624 2640 .txFrameToPaOn = 0x0e, ··· 2643 2663 .xatten1MarginHigh = {0, 0, 0} 2644 2664 }, 2645 2665 .calFreqPier5G = { 2646 - FREQ2FBIN(5180, 0), 2666 + FREQ2FBIN(5160, 0), 2647 2667 FREQ2FBIN(5220, 0), 2648 2668 FREQ2FBIN(5320, 0), 2649 2669 FREQ2FBIN(5400, 0), ··· 3003 3023 return eep->modalHeader5G.antennaGain; 3004 3024 case EEP_ANTENNA_GAIN_2G: 3005 3025 return eep->modalHeader2G.antennaGain; 3026 + case EEP_QUICK_DROP: 3027 + return pBase->miscConfiguration & BIT(1); 3006 3028 default: 3007 3029 return 0; 3008 3030 } ··· 3410 3428 PR_EEP("Chain0 NF Threshold", modal_hdr->noiseFloorThreshCh[0]); 3411 3429 PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]); 3412 3430 PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]); 3431 + PR_EEP("Quick Drop", modal_hdr->quick_drop); 3432 + PR_EEP("txEndToXpaOff", modal_hdr->txEndToXpaOff); 3413 3433 PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl); 3414 3434 PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart); 3415 3435 PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn); 3416 3436 PR_EEP("txFrameToXpaOn", modal_hdr->txFrameToXpaOn); 3417 3437 PR_EEP("txClip", modal_hdr->txClip); 3418 3438 PR_EEP("ADC Desired size", modal_hdr->adcDesiredSize); 3419 - PR_EEP("Chain0 ob", modal_hdr->ob[0]); 3420 - PR_EEP("Chain1 ob", modal_hdr->ob[1]); 3421 - PR_EEP("Chain2 ob", modal_hdr->ob[2]); 3422 - 3423 - PR_EEP("Chain0 db_stage2", modal_hdr->db_stage2[0]); 3424 - PR_EEP("Chain1 db_stage2", modal_hdr->db_stage2[1]); 3425 - PR_EEP("Chain2 db_stage2", modal_hdr->db_stage2[2]); 3426 - PR_EEP("Chain0 db_stage3", modal_hdr->db_stage3[0]); 3427 - PR_EEP("Chain1 db_stage3", modal_hdr->db_stage3[1]); 3428 - PR_EEP("Chain2 db_stage3", modal_hdr->db_stage3[2]); 3429 - PR_EEP("Chain0 db_stage4", modal_hdr->db_stage4[0]); 3430 - PR_EEP("Chain1 db_stage4", modal_hdr->db_stage4[1]); 3431 - PR_EEP("Chain2 db_stage4", modal_hdr->db_stage4[2]); 3432 3439 3433 3440 return len; 3434 3441 } ··· 3474 3503 PR_EEP("Internal regulator", !!(pBase->featureEnable & BIT(4))); 3475 3504 PR_EEP("Enable Paprd", !!(pBase->featureEnable & BIT(5))); 3476 3505 PR_EEP("Driver Strength", !!(pBase->miscConfiguration & BIT(0))); 3506 + PR_EEP("Quick Drop", !!(pBase->miscConfiguration & BIT(1))); 3477 3507 PR_EEP("Chain mask Reduce", (pBase->miscConfiguration >> 0x3) & 0x1); 3478 3508 PR_EEP("Write enable Gpio", pBase->eepromWriteEnableGpio); 3479 3509 PR_EEP("WLAN Disable Gpio", pBase->wlanDisableGpio); ··· 3937 3965 } 3938 3966 } 3939 3967 3968 + static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq) 3969 + { 3970 + struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3971 + int quick_drop = ath9k_hw_ar9300_get_eeprom(ah, EEP_QUICK_DROP); 3972 + s32 t[3], f[3] = {5180, 5500, 5785}; 3973 + 3974 + if (!quick_drop) 3975 + return; 3976 + 3977 + if (freq < 4000) 3978 + quick_drop = eep->modalHeader2G.quick_drop; 3979 + else { 3980 + t[0] = eep->base_ext1.quick_drop_low; 3981 + t[1] = eep->modalHeader5G.quick_drop; 3982 + t[2] = eep->base_ext1.quick_drop_high; 3983 + quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3); 3984 + } 3985 + REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop); 3986 + } 3987 + 3988 + static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, u16 freq) 3989 + { 3990 + struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 3991 + u32 value; 3992 + 3993 + value = (freq < 4000) ? eep->modalHeader2G.txEndToXpaOff : 3994 + eep->modalHeader5G.txEndToXpaOff; 3995 + 3996 + REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL, 3997 + AR_PHY_XPA_TIMING_CTL_TX_END_XPAB_OFF, value); 3998 + REG_RMW_FIELD(ah, AR_PHY_XPA_TIMING_CTL, 3999 + AR_PHY_XPA_TIMING_CTL_TX_END_XPAA_OFF, value); 4000 + } 4001 + 3940 4002 static void ath9k_hw_ar9300_set_board_values(struct ath_hw *ah, 3941 4003 struct ath9k_channel *chan) 3942 4004 { ··· 3978 3972 ar9003_hw_ant_ctrl_apply(ah, IS_CHAN_2GHZ(chan)); 3979 3973 ar9003_hw_drive_strength_apply(ah); 3980 3974 ar9003_hw_atten_apply(ah, chan); 3975 + ar9003_hw_quick_drop_apply(ah, chan->channel); 3981 3976 if (!AR_SREV_9330(ah) && !AR_SREV_9340(ah)) 3982 3977 ar9003_hw_internal_regulator_apply(ah); 3983 3978 if (AR_SREV_9485(ah) || AR_SREV_9330(ah) || AR_SREV_9340(ah)) 3984 3979 ar9003_hw_apply_tuning_caps(ah); 3980 + ar9003_hw_txend_to_xpa_off_apply(ah, chan->channel); 3985 3981 } 3986 3982 3987 3983 static void ath9k_hw_ar9300_set_addac(struct ath_hw *ah, ··· 5058 5050 if (targetPowerValT2[i] > regulatory->max_power_level) 5059 5051 regulatory->max_power_level = targetPowerValT2[i]; 5060 5052 } 5053 + 5054 + ath9k_hw_update_regulatory_maxpower(ah); 5061 5055 5062 5056 if (test) 5063 5057 return;
+5 -5
drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
··· 216 216 u8 spurChans[AR_EEPROM_MODAL_SPURS]; 217 217 /* 3 Check if the register is per chain */ 218 218 int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS]; 219 - u8 ob[AR9300_MAX_CHAINS]; 220 - u8 db_stage2[AR9300_MAX_CHAINS]; 221 - u8 db_stage3[AR9300_MAX_CHAINS]; 222 - u8 db_stage4[AR9300_MAX_CHAINS]; 219 + u8 reserved[11]; 220 + int8_t quick_drop; 223 221 u8 xpaBiasLvl; 224 222 u8 txFrameToDataStart; 225 223 u8 txFrameToPaOn; ··· 267 269 268 270 struct ar9300_BaseExtension_1 { 269 271 u8 ant_div_control; 270 - u8 future[13]; 272 + u8 future[11]; 273 + int8_t quick_drop_low; 274 + int8_t quick_drop_high; 271 275 } __packed; 272 276 273 277 struct ar9300_BaseExtension_2 {
+3 -1
drivers/net/wireless/ath/ath9k/ar9003_phy.c
··· 199 199 synth_freq = chan->channel; 200 200 } 201 201 } else { 202 - range = 10; 202 + range = AR_SREV_9462(ah) ? 5 : 10; 203 203 max_spur_cnts = 4; 204 204 synth_freq = chan->channel; 205 205 } 206 206 207 207 for (i = 0; i < max_spur_cnts; i++) { 208 + if (AR_SREV_9462(ah) && (i == 0 || i == 3)) 209 + continue; 208 210 negative = 0; 209 211 if (AR_SREV_9485(ah) || AR_SREV_9340(ah) || AR_SREV_9330(ah)) 210 212 cur_bb_spur = FBIN2FREQ(spur_fbin_ptr[i],
+2
drivers/net/wireless/ath/ath9k/ar9003_phy.h
··· 389 389 #define AR_PHY_DAG_CTRLCCK_RSSI_THR_S 10 390 390 391 391 #define AR_PHY_RIFS_INIT_DELAY 0x3ff0000 392 + #define AR_PHY_AGC_QUICK_DROP 0x03c00000 393 + #define AR_PHY_AGC_QUICK_DROP_S 22 392 394 #define AR_PHY_AGC_COARSE_LOW 0x00007F80 393 395 #define AR_PHY_AGC_COARSE_LOW_S 7 394 396 #define AR_PHY_AGC_COARSE_HIGH 0x003F8000
+13 -13
drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h
··· 43 43 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 44 44 {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011}, 45 45 {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e}, 46 - {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0}, 47 - {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881}, 46 + {0x00009824, 0x5ac640de, 0x5ac640d0, 0x5ac640d0, 0x5ac640de}, 47 + {0x00009828, 0x0796be89, 0x0696b081, 0x0696b881, 0x0796be89}, 48 48 {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4}, 49 49 {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c}, 50 50 {0x00009c00, 0x000000c4, 0x000000c4, 0x000000c4, 0x000000c4}, 51 51 {0x00009e00, 0x0372111a, 0x0372111a, 0x037216a0, 0x037216a0}, 52 52 {0x00009e04, 0x001c2020, 0x001c2020, 0x001c2020, 0x001c2020}, 53 53 {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2}, 54 - {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec84d2e}, 55 - {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3039605e, 0x33795d5e}, 54 + {0x00009e10, 0x92c88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x92c84d2e}, 55 + {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3379605e, 0x33795d5e}, 56 56 {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 57 57 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, 58 58 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, ··· 688 688 static const u32 ar9462_2p0_radio_postamble_sys3ant[][5] = { 689 689 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 690 690 {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24645808, 0x24645808}, 691 - {0x00016140, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, 692 - {0x00016540, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, 691 + {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, 692 + {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, 693 693 }; 694 694 695 695 static const u32 ar9462_2p0_baseband_postamble_emulation[][5] = { ··· 717 717 static const u32 ar9462_2p0_radio_postamble_sys2ant[][5] = { 718 718 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 719 719 {0x000160ac, 0xa4646c08, 0xa4646c08, 0x24645808, 0x24645808}, 720 - {0x00016140, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, 721 - {0x00016540, 0x10804008, 0x10804008, 0x90804008, 0x90804008}, 720 + {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, 721 + {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008}, 722 722 }; 723 723 724 724 static const u32 ar9462_common_wo_xlna_rx_gain_table_2p0[][2] = { ··· 1059 1059 1060 1060 static const u32 ar9462_2p0_soc_postamble[][5] = { 1061 1061 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 1062 - {0x00007010, 0x00002233, 0x00002233, 0x00002233, 0x00002233}, 1062 + {0x00007010, 0x00000033, 0x00000033, 0x00000033, 0x00000033}, 1063 1063 }; 1064 1064 1065 1065 static const u32 ar9462_2p0_baseband_core[][2] = { ··· 1257 1257 {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660}, 1258 1258 {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861}, 1259 1259 {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81}, 1260 - {0x0000a54c, 0x59025eb2, 0x59025eb2, 0x42001a83, 0x42001a83}, 1261 - {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84}, 1260 + {0x0000a54c, 0x59025eb6, 0x59025eb6, 0x42001a83, 0x42001a83}, 1261 + {0x0000a550, 0x5d025ef6, 0x5d025ef6, 0x44001c84, 0x44001c84}, 1262 1262 {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3}, 1263 1263 {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, 1264 1264 {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9}, ··· 1850 1850 {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660}, 1851 1851 {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861}, 1852 1852 {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81}, 1853 - {0x0000a54c, 0x59025eb2, 0x59025eb2, 0x42001a83, 0x42001a83}, 1854 - {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84}, 1853 + {0x0000a54c, 0x59025eb6, 0x59025eb6, 0x42001a83, 0x42001a83}, 1854 + {0x0000a550, 0x5d025ef6, 0x5d025ef6, 0x44001c84, 0x44001c84}, 1855 1855 {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3}, 1856 1856 {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5}, 1857 1857 {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9},
+4
drivers/net/wireless/ath/ath9k/ath9k.h
··· 25 25 26 26 #include "debug.h" 27 27 #include "common.h" 28 + #include "mci.h" 28 29 29 30 /* 30 31 * Header for the ath9k.ko driver core *only* -- hw code nor any other driver ··· 253 252 #ifdef CONFIG_ATH9K_DEBUGFS 254 253 struct list_head list; /* for sc->nodes */ 255 254 struct ieee80211_sta *sta; /* station struct we're part of */ 255 + struct ieee80211_vif *vif; /* interface with which we're associated */ 256 256 #endif 257 257 struct ath_atx_tid tid[WME_NUM_TID]; 258 258 struct ath_atx_ac ac[WME_NUM_AC]; ··· 445 443 u32 btcoex_no_stomp; /* in usec */ 446 444 u32 btcoex_period; /* in usec */ 447 445 u32 btscan_no_stomp; /* in usec */ 446 + u32 duty_cycle; 448 447 struct ath_gen_timer *no_stomp_timer; /* Timer for no BT stomping */ 448 + struct ath_mci_profile mci; 449 449 }; 450 450 451 451 int ath_init_btcoex_timer(struct ath_softc *sc);
+9 -4
drivers/net/wireless/ath/ath9k/debug.c
··· 709 709 710 710 len += snprintf(buf + len, size - len, 711 711 "Stations:\n" 712 - " tid: addr sched paused buf_q-empty an ac\n" 712 + " tid: addr sched paused buf_q-empty an ac baw\n" 713 713 " ac: addr sched tid_q-empty txq\n"); 714 714 715 715 spin_lock(&sc->nodes_lock); 716 716 list_for_each_entry(an, &sc->nodes, list) { 717 + unsigned short ma = an->maxampdu; 718 + if (ma == 0) 719 + ma = 65535; /* see ath_lookup_rate */ 717 720 len += snprintf(buf + len, size - len, 718 - "%pM\n", an->sta->addr); 721 + "iface: %pM sta: %pM max-ampdu: %hu mpdu-density: %uus\n", 722 + an->vif->addr, an->sta->addr, ma, 723 + (unsigned int)(an->mpdudensity)); 719 724 if (len >= size) 720 725 goto done; 721 726 722 727 for (q = 0; q < WME_NUM_TID; q++) { 723 728 struct ath_atx_tid *tid = &(an->tid[q]); 724 729 len += snprintf(buf + len, size - len, 725 - " tid: %p %s %s %i %p %p\n", 730 + " tid: %p %s %s %i %p %p %hu\n", 726 731 tid, tid->sched ? "sched" : "idle", 727 732 tid->paused ? "paused" : "running", 728 733 skb_queue_empty(&tid->buf_q), 729 - tid->an, tid->ac); 734 + tid->an, tid->ac, tid->baw_size); 730 735 if (len >= size) 731 736 goto done; 732 737 }
+2 -1
drivers/net/wireless/ath/ath9k/eeprom.h
··· 249 249 EEP_ANT_DIV_CTL1, 250 250 EEP_CHAIN_MASK_REDUCE, 251 251 EEP_ANTENNA_GAIN_2G, 252 - EEP_ANTENNA_GAIN_5G 252 + EEP_ANTENNA_GAIN_5G, 253 + EEP_QUICK_DROP 253 254 }; 254 255 255 256 enum ar5416_rates {
+4 -3
drivers/net/wireless/ath/ath9k/gpio.c
··· 189 189 bool is_btscan; 190 190 191 191 ath9k_ps_wakeup(sc); 192 - ath_detect_bt_priority(sc); 193 - 192 + if (!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) 193 + ath_detect_bt_priority(sc); 194 194 is_btscan = sc->sc_flags & SC_OP_BT_SCAN; 195 195 196 196 spin_lock_bh(&btcoex->btcoex_lock); ··· 212 212 } 213 213 214 214 ath9k_ps_restore(sc); 215 + timer_period = btcoex->btcoex_period / 1000; 215 216 mod_timer(&btcoex->period_timer, jiffies + 216 - msecs_to_jiffies(ATH_BTCOEX_DEF_BT_PERIOD)); 217 + msecs_to_jiffies(timer_period)); 217 218 } 218 219 219 220 /*
+2 -2
drivers/net/wireless/ath/ath9k/hw.c
··· 2335 2335 ah->enabled_cals |= TX_IQ_ON_AGC_CAL; 2336 2336 } 2337 2337 if (AR_SREV_9462(ah)) 2338 - pCap->hw_caps |= ATH9K_HW_CAP_RTT; 2338 + pCap->hw_caps |= ATH9K_HW_CAP_RTT | ATH9K_HW_CAP_MCI; 2339 2339 2340 2340 return 0; 2341 2341 } ··· 2583 2583 struct ath9k_channel *chan = ah->curchan; 2584 2584 struct ieee80211_channel *channel = chan->chan; 2585 2585 2586 - reg->power_limit = min_t(int, limit, MAX_RATE_POWER); 2586 + reg->power_limit = min_t(u32, limit, MAX_RATE_POWER); 2587 2587 if (test) 2588 2588 channel->max_power = MAX_RATE_POWER / 2; 2589 2589
+11
drivers/net/wireless/ath/ath9k/hw.h
··· 203 203 ATH9K_HW_CAP_5GHZ = BIT(14), 204 204 ATH9K_HW_CAP_APM = BIT(15), 205 205 ATH9K_HW_CAP_RTT = BIT(16), 206 + ATH9K_HW_CAP_MCI = BIT(17), 206 207 }; 207 208 208 209 struct ath9k_hw_capabilities { ··· 418 417 ATH9K_RX_QUEUE_HP, 419 418 ATH9K_RX_QUEUE_LP, 420 419 ATH9K_RX_QUEUE_MAX, 420 + }; 421 + 422 + enum ath_mci_gpm_coex_profile_type { 423 + MCI_GPM_COEX_PROFILE_UNKNOWN, 424 + MCI_GPM_COEX_PROFILE_RFCOMM, 425 + MCI_GPM_COEX_PROFILE_A2DP, 426 + MCI_GPM_COEX_PROFILE_HID, 427 + MCI_GPM_COEX_PROFILE_BNEP, 428 + MCI_GPM_COEX_PROFILE_VOICE, 429 + MCI_GPM_COEX_PROFILE_MAX 421 430 }; 422 431 423 432 struct ath9k_beacon_state {
+3
drivers/net/wireless/ath/ath9k/init.c
··· 424 424 txq = sc->tx.txq_map[WME_AC_BE]; 425 425 ath9k_hw_init_btcoex_hw(sc->sc_ah, txq->axq_qnum); 426 426 sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; 427 + sc->btcoex.duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE; 428 + INIT_LIST_HEAD(&sc->btcoex.mci.info); 427 429 break; 428 430 default: 429 431 WARN_ON(1); ··· 697 695 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 698 696 699 697 hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN; 698 + hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; 700 699 701 700 hw->queues = 4; 702 701 hw->max_rates = 4;
+8 -4
drivers/net/wireless/ath/ath9k/main.c
··· 630 630 } 631 631 } 632 632 633 - static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta) 633 + static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta, 634 + struct ieee80211_vif *vif) 634 635 { 635 636 struct ath_node *an; 636 637 an = (struct ath_node *)sta->drv_priv; ··· 641 640 list_add(&an->list, &sc->nodes); 642 641 spin_unlock(&sc->nodes_lock); 643 642 an->sta = sta; 643 + an->vif = vif; 644 644 #endif 645 645 if (sc->sc_flags & SC_OP_TXAGGR) { 646 646 ath_tx_node_init(sc, an); ··· 1135 1133 1136 1134 if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) && 1137 1135 !ah->btcoex_hw.enabled) { 1138 - ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, 1139 - AR_STOMP_LOW_WLAN_WGHT); 1136 + if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI)) 1137 + ath9k_hw_btcoex_set_weight(ah, AR_BT_COEX_WGHT, 1138 + AR_STOMP_LOW_WLAN_WGHT); 1140 1139 ath9k_hw_btcoex_enable(ah); 1141 1140 1142 1141 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) ··· 1240 1237 ath9k_hw_btcoex_disable(ah); 1241 1238 if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) 1242 1239 ath9k_btcoex_timer_pause(sc); 1240 + ath_mci_flush_profile(&sc->btcoex.mci); 1243 1241 } 1244 1242 1245 1243 spin_lock_bh(&sc->sc_pcu_lock); ··· 1802 1798 struct ath_node *an = (struct ath_node *) sta->drv_priv; 1803 1799 struct ieee80211_key_conf ps_key = { }; 1804 1800 1805 - ath_node_attach(sc, sta); 1801 + ath_node_attach(sc, sta, vif); 1806 1802 1807 1803 if (vif->type != NL80211_IFTYPE_AP && 1808 1804 vif->type != NL80211_IFTYPE_AP_VLAN)
+254
drivers/net/wireless/ath/ath9k/mci.c
··· 1 + /* 2 + * Copyright (c) 2010-2011 Atheros Communications Inc. 3 + * 4 + * Permission to use, copy, modify, and/or distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + 17 + #include "ath9k.h" 18 + #include "mci.h" 19 + 20 + u8 ath_mci_duty_cycle[] = { 0, 50, 60, 70, 80, 85, 90, 95, 98 }; 21 + 22 + static struct ath_mci_profile_info* 23 + ath_mci_find_profile(struct ath_mci_profile *mci, 24 + struct ath_mci_profile_info *info) 25 + { 26 + struct ath_mci_profile_info *entry; 27 + 28 + list_for_each_entry(entry, &mci->info, list) { 29 + if (entry->conn_handle == info->conn_handle) 30 + break; 31 + } 32 + return entry; 33 + } 34 + 35 + static bool ath_mci_add_profile(struct ath_common *common, 36 + struct ath_mci_profile *mci, 37 + struct ath_mci_profile_info *info) 38 + { 39 + struct ath_mci_profile_info *entry; 40 + 41 + if ((mci->num_sco == ATH_MCI_MAX_SCO_PROFILE) && 42 + (info->type == MCI_GPM_COEX_PROFILE_VOICE)) { 43 + ath_dbg(common, ATH_DBG_MCI, 44 + "Too many SCO profile, failed to add new profile\n"); 45 + return false; 46 + } 47 + 48 + if (((NUM_PROF(mci) - mci->num_sco) == ATH_MCI_MAX_ACL_PROFILE) && 49 + (info->type != MCI_GPM_COEX_PROFILE_VOICE)) { 50 + ath_dbg(common, ATH_DBG_MCI, 51 + "Too many ACL profile, failed to add new profile\n"); 52 + return false; 53 + } 54 + 55 + entry = ath_mci_find_profile(mci, info); 56 + 57 + if (entry) 58 + memcpy(entry, info, 10); 59 + else { 60 + entry = kzalloc(sizeof(*entry), GFP_KERNEL); 61 + if (!entry) 62 + return false; 63 + 64 + memcpy(entry, info, 10); 65 + INC_PROF(mci, info); 66 + list_add_tail(&info->list, &mci->info); 67 + } 68 + return true; 69 + } 70 + 71 + static void ath_mci_del_profile(struct ath_common *common, 72 + struct ath_mci_profile *mci, 73 + struct ath_mci_profile_info *info) 74 + { 75 + struct ath_mci_profile_info *entry; 76 + 77 + entry = ath_mci_find_profile(mci, info); 78 + 79 + if (!entry) { 80 + ath_dbg(common, ATH_DBG_MCI, 81 + "Profile to be deleted not found\n"); 82 + return; 83 + } 84 + DEC_PROF(mci, entry); 85 + list_del(&entry->list); 86 + kfree(entry); 87 + } 88 + 89 + void ath_mci_flush_profile(struct ath_mci_profile *mci) 90 + { 91 + struct ath_mci_profile_info *info, *tinfo; 92 + 93 + list_for_each_entry_safe(info, tinfo, &mci->info, list) { 94 + list_del(&info->list); 95 + DEC_PROF(mci, info); 96 + kfree(info); 97 + } 98 + mci->aggr_limit = 0; 99 + } 100 + 101 + static void ath_mci_adjust_aggr_limit(struct ath_btcoex *btcoex) 102 + { 103 + struct ath_mci_profile *mci = &btcoex->mci; 104 + u32 wlan_airtime = btcoex->btcoex_period * 105 + (100 - btcoex->duty_cycle) / 100; 106 + 107 + /* 108 + * Scale: wlan_airtime is in ms, aggr_limit is in 0.25 ms. 109 + * When wlan_airtime is less than 4ms, aggregation limit has to be 110 + * adjusted half of wlan_airtime to ensure that the aggregation can fit 111 + * without collision with BT traffic. 112 + */ 113 + if ((wlan_airtime <= 4) && 114 + (!mci->aggr_limit || (mci->aggr_limit > (2 * wlan_airtime)))) 115 + mci->aggr_limit = 2 * wlan_airtime; 116 + } 117 + 118 + static void ath_mci_update_scheme(struct ath_softc *sc) 119 + { 120 + struct ath_common *common = ath9k_hw_common(sc->sc_ah); 121 + struct ath_btcoex *btcoex = &sc->btcoex; 122 + struct ath_mci_profile *mci = &btcoex->mci; 123 + struct ath_mci_profile_info *info; 124 + u32 num_profile = NUM_PROF(mci); 125 + 126 + if (num_profile == 1) { 127 + info = list_first_entry(&mci->info, 128 + struct ath_mci_profile_info, 129 + list); 130 + if (mci->num_sco && info->T == 12) { 131 + mci->aggr_limit = 8; 132 + ath_dbg(common, ATH_DBG_MCI, 133 + "Single SCO, aggregation limit 2 ms\n"); 134 + } else if ((info->type == MCI_GPM_COEX_PROFILE_BNEP) && 135 + !info->master) { 136 + btcoex->btcoex_period = 60; 137 + ath_dbg(common, ATH_DBG_MCI, 138 + "Single slave PAN/FTP, bt period 60 ms\n"); 139 + } else if ((info->type == MCI_GPM_COEX_PROFILE_HID) && 140 + (info->T > 0 && info->T < 50) && 141 + (info->A > 1 || info->W > 1)) { 142 + btcoex->duty_cycle = 30; 143 + mci->aggr_limit = 8; 144 + ath_dbg(common, ATH_DBG_MCI, 145 + "Multiple attempt/timeout single HID " 146 + "aggregation limit 2 ms dutycycle 30%%\n"); 147 + } 148 + } else if ((num_profile == 2) && (mci->num_hid == 2)) { 149 + btcoex->duty_cycle = 30; 150 + mci->aggr_limit = 8; 151 + ath_dbg(common, ATH_DBG_MCI, 152 + "Two HIDs aggregation limit 2 ms dutycycle 30%%\n"); 153 + } else if (num_profile > 3) { 154 + mci->aggr_limit = 6; 155 + ath_dbg(common, ATH_DBG_MCI, 156 + "Three or more profiles aggregation limit 1.5 ms\n"); 157 + } 158 + 159 + if (IS_CHAN_2GHZ(sc->sc_ah->curchan)) { 160 + if (IS_CHAN_HT(sc->sc_ah->curchan)) 161 + ath_mci_adjust_aggr_limit(btcoex); 162 + else 163 + btcoex->btcoex_period >>= 1; 164 + } 165 + 166 + ath9k_hw_btcoex_disable(sc->sc_ah); 167 + ath9k_btcoex_timer_pause(sc); 168 + 169 + if (IS_CHAN_5GHZ(sc->sc_ah->curchan)) 170 + return; 171 + 172 + btcoex->duty_cycle += (mci->num_bdr ? ATH_MCI_MAX_DUTY_CYCLE : 0); 173 + if (btcoex->duty_cycle > ATH_MCI_MAX_DUTY_CYCLE) 174 + btcoex->duty_cycle = ATH_MCI_MAX_DUTY_CYCLE; 175 + 176 + btcoex->btcoex_period *= 1000; 177 + btcoex->btcoex_no_stomp = btcoex->btcoex_period * 178 + (100 - btcoex->duty_cycle) / 100; 179 + 180 + ath9k_hw_btcoex_enable(sc->sc_ah); 181 + ath9k_btcoex_timer_resume(sc); 182 + } 183 + 184 + void ath_mci_process_profile(struct ath_softc *sc, 185 + struct ath_mci_profile_info *info) 186 + { 187 + struct ath_common *common = ath9k_hw_common(sc->sc_ah); 188 + struct ath_btcoex *btcoex = &sc->btcoex; 189 + struct ath_mci_profile *mci = &btcoex->mci; 190 + 191 + if (info->start) { 192 + if (!ath_mci_add_profile(common, mci, info)) 193 + return; 194 + } else 195 + ath_mci_del_profile(common, mci, info); 196 + 197 + btcoex->btcoex_period = ATH_MCI_DEF_BT_PERIOD; 198 + mci->aggr_limit = mci->num_sco ? 6 : 0; 199 + if (NUM_PROF(mci)) { 200 + btcoex->bt_stomp_type = ATH_BTCOEX_STOMP_LOW; 201 + btcoex->duty_cycle = ath_mci_duty_cycle[NUM_PROF(mci)]; 202 + } else { 203 + btcoex->bt_stomp_type = mci->num_mgmt ? ATH_BTCOEX_STOMP_ALL : 204 + ATH_BTCOEX_STOMP_LOW; 205 + btcoex->duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE; 206 + } 207 + 208 + ath_mci_update_scheme(sc); 209 + } 210 + 211 + void ath_mci_process_status(struct ath_softc *sc, 212 + struct ath_mci_profile_status *status) 213 + { 214 + struct ath_common *common = ath9k_hw_common(sc->sc_ah); 215 + struct ath_btcoex *btcoex = &sc->btcoex; 216 + struct ath_mci_profile *mci = &btcoex->mci; 217 + struct ath_mci_profile_info info; 218 + int i = 0, old_num_mgmt = mci->num_mgmt; 219 + 220 + /* Link status type are not handled */ 221 + if (status->is_link) { 222 + ath_dbg(common, ATH_DBG_MCI, 223 + "Skip link type status update\n"); 224 + return; 225 + } 226 + 227 + memset(&info, 0, sizeof(struct ath_mci_profile_info)); 228 + 229 + info.conn_handle = status->conn_handle; 230 + if (ath_mci_find_profile(mci, &info)) { 231 + ath_dbg(common, ATH_DBG_MCI, 232 + "Skip non link state update for existing profile %d\n", 233 + status->conn_handle); 234 + return; 235 + } 236 + if (status->conn_handle >= ATH_MCI_MAX_PROFILE) { 237 + ath_dbg(common, ATH_DBG_MCI, 238 + "Ignore too many non-link update\n"); 239 + return; 240 + } 241 + if (status->is_critical) 242 + __set_bit(status->conn_handle, mci->status); 243 + else 244 + __clear_bit(status->conn_handle, mci->status); 245 + 246 + mci->num_mgmt = 0; 247 + do { 248 + if (test_bit(i, mci->status)) 249 + mci->num_mgmt++; 250 + } while (++i < ATH_MCI_MAX_PROFILE); 251 + 252 + if (old_num_mgmt != mci->num_mgmt) 253 + ath_mci_update_scheme(sc); 254 + }
+118
drivers/net/wireless/ath/ath9k/mci.h
··· 1 + /* 2 + * Copyright (c) 2010-2011 Atheros Communications Inc. 3 + * 4 + * Permission to use, copy, modify, and/or distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + 17 + #ifndef MCI_H 18 + #define MCI_H 19 + 20 + #define ATH_MCI_DEF_BT_PERIOD 40 21 + #define ATH_MCI_BDR_DUTY_CYCLE 20 22 + #define ATH_MCI_MAX_DUTY_CYCLE 90 23 + 24 + #define ATH_MCI_DEF_AGGR_LIMIT 6 /* in 0.24 ms */ 25 + #define ATH_MCI_MAX_ACL_PROFILE 7 26 + #define ATH_MCI_MAX_SCO_PROFILE 1 27 + #define ATH_MCI_MAX_PROFILE (ATH_MCI_MAX_ACL_PROFILE +\ 28 + ATH_MCI_MAX_SCO_PROFILE) 29 + 30 + #define INC_PROF(_mci, _info) do { \ 31 + switch (_info->type) { \ 32 + case MCI_GPM_COEX_PROFILE_RFCOMM:\ 33 + _mci->num_other_acl++; \ 34 + break; \ 35 + case MCI_GPM_COEX_PROFILE_A2DP: \ 36 + _mci->num_a2dp++; \ 37 + if (!_info->edr) \ 38 + _mci->num_bdr++; \ 39 + break; \ 40 + case MCI_GPM_COEX_PROFILE_HID: \ 41 + _mci->num_hid++; \ 42 + break; \ 43 + case MCI_GPM_COEX_PROFILE_BNEP: \ 44 + _mci->num_pan++; \ 45 + break; \ 46 + case MCI_GPM_COEX_PROFILE_VOICE: \ 47 + _mci->num_sco++; \ 48 + break; \ 49 + default: \ 50 + break; \ 51 + } \ 52 + } while (0) 53 + 54 + #define DEC_PROF(_mci, _info) do { \ 55 + switch (_info->type) { \ 56 + case MCI_GPM_COEX_PROFILE_RFCOMM:\ 57 + _mci->num_other_acl--; \ 58 + break; \ 59 + case MCI_GPM_COEX_PROFILE_A2DP: \ 60 + _mci->num_a2dp--; \ 61 + if (!_info->edr) \ 62 + _mci->num_bdr--; \ 63 + break; \ 64 + case MCI_GPM_COEX_PROFILE_HID: \ 65 + _mci->num_hid--; \ 66 + break; \ 67 + case MCI_GPM_COEX_PROFILE_BNEP: \ 68 + _mci->num_pan--; \ 69 + break; \ 70 + case MCI_GPM_COEX_PROFILE_VOICE: \ 71 + _mci->num_sco--; \ 72 + break; \ 73 + default: \ 74 + break; \ 75 + } \ 76 + } while (0) 77 + 78 + #define NUM_PROF(_mci) (_mci->num_other_acl + _mci->num_a2dp + \ 79 + _mci->num_hid + _mci->num_pan + _mci->num_sco) 80 + 81 + struct ath_mci_profile_info { 82 + u8 type; 83 + u8 conn_handle; 84 + bool start; 85 + bool master; 86 + bool edr; 87 + u8 voice_type; 88 + u16 T; /* Voice: Tvoice, HID: Tsniff, in slots */ 89 + u8 W; /* Voice: Wvoice, HID: Sniff timeout, in slots */ 90 + u8 A; /* HID: Sniff attempt, in slots */ 91 + struct list_head list; 92 + }; 93 + 94 + struct ath_mci_profile_status { 95 + bool is_critical; 96 + bool is_link; 97 + u8 conn_handle; 98 + }; 99 + 100 + struct ath_mci_profile { 101 + struct list_head info; 102 + DECLARE_BITMAP(status, ATH_MCI_MAX_PROFILE); 103 + u16 aggr_limit; 104 + u8 num_mgmt; 105 + u8 num_sco; 106 + u8 num_a2dp; 107 + u8 num_hid; 108 + u8 num_pan; 109 + u8 num_other_acl; 110 + u8 num_bdr; 111 + }; 112 + 113 + void ath_mci_flush_profile(struct ath_mci_profile *mci); 114 + void ath_mci_process_profile(struct ath_softc *sc, 115 + struct ath_mci_profile_info *info); 116 + void ath_mci_process_status(struct ath_softc *sc, 117 + struct ath_mci_profile_status *status); 118 + #endif
+4 -1
drivers/net/wireless/ath/ath9k/xmit.c
··· 601 601 struct sk_buff *skb; 602 602 struct ieee80211_tx_info *tx_info; 603 603 struct ieee80211_tx_rate *rates; 604 + struct ath_mci_profile *mci = &sc->btcoex.mci; 604 605 u32 max_4ms_framelen, frmlen; 605 606 u16 aggr_limit, legacy = 0; 606 607 int i; ··· 646 645 if (tx_info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE || legacy) 647 646 return 0; 648 647 649 - if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED) 648 + if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) && mci->aggr_limit) 649 + aggr_limit = (max_4ms_framelen * mci->aggr_limit) >> 4; 650 + else if (sc->sc_flags & SC_OP_BT_PRIORITY_DETECTED) 650 651 aggr_limit = min((max_4ms_framelen * 3) / 8, 651 652 (u32)ATH_AMPDU_LIMIT_MAX); 652 653 else
+2
drivers/net/wireless/ath/regd.c
··· 254 254 int r; 255 255 256 256 sband = wiphy->bands[IEEE80211_BAND_2GHZ]; 257 + if (!sband) 258 + return; 257 259 258 260 /* 259 261 * If no country IE has been received always enable active scan
+13 -2
drivers/net/wireless/b43/xmit.c
··· 175 175 } 176 176 } 177 177 178 + /* TODO: verify if needed for SSLPN or LCN */ 178 179 static u16 b43_generate_tx_phy_ctl1(struct b43_wldev *dev, u8 bitrate) 179 180 { 180 181 const struct b43_phy *phy = &dev->phy; ··· 257 256 unsigned int plcp_fragment_len; 258 257 u32 mac_ctl = 0; 259 258 u16 phy_ctl = 0; 259 + bool fill_phy_ctl1 = (phy->type == B43_PHYTYPE_LP || 260 + phy->type == B43_PHYTYPE_N || 261 + phy->type == B43_PHYTYPE_HT); 260 262 u8 extra_ft = 0; 261 263 struct ieee80211_rate *txrate; 262 264 struct ieee80211_tx_rate *rates; ··· 535 531 extra_ft |= B43_TXH_EFT_RTSFB_CCK; 536 532 537 533 if (rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS && 538 - phy->type == B43_PHYTYPE_N) { 534 + fill_phy_ctl1) { 539 535 txhdr->phy_ctl1_rts = cpu_to_le16( 540 536 b43_generate_tx_phy_ctl1(dev, rts_rate)); 541 537 txhdr->phy_ctl1_rts_fb = cpu_to_le16( ··· 556 552 break; 557 553 } 558 554 559 - if (phy->type == B43_PHYTYPE_N) { 555 + if (fill_phy_ctl1) { 560 556 txhdr->phy_ctl1 = 561 557 cpu_to_le16(b43_generate_tx_phy_ctl1(dev, rate)); 562 558 txhdr->phy_ctl1_fb = ··· 740 736 741 737 /* Link quality statistics */ 742 738 switch (chanstat & B43_RX_CHAN_PHYTYPE) { 739 + case B43_PHYTYPE_HT: 740 + /* TODO: is max the right choice? */ 741 + status.signal = max_t(__s8, 742 + max(rxhdr->phy_ht_power0, rxhdr->phy_ht_power1), 743 + rxhdr->phy_ht_power2); 744 + break; 743 745 case B43_PHYTYPE_N: 746 + /* Broadcom has code for min and avg, but always uses max */ 744 747 if (rxhdr->power0 == 16 || rxhdr->power0 == 32) 745 748 status.signal = max(rxhdr->power1, rxhdr->power2); 746 749 else
+15 -1
drivers/net/wireless/b43/xmit.h
··· 249 249 } __packed; 250 250 } __packed; 251 251 union { 252 + /* HT-PHY */ 253 + struct { 254 + PAD_BYTES(1); 255 + __s8 phy_ht_power0; 256 + } __packed; 257 + 252 258 /* RSSI for N-PHYs */ 253 259 struct { 254 260 __s8 power2; ··· 263 257 264 258 __le16 phy_status2; /* PHY RX Status 2 */ 265 259 } __packed; 266 - __le16 phy_status3; /* PHY RX Status 3 */ 260 + union { 261 + /* HT-PHY */ 262 + struct { 263 + __s8 phy_ht_power1; 264 + __s8 phy_ht_power2; 265 + } __packed; 266 + 267 + __le16 phy_status3; /* PHY RX Status 3 */ 268 + } __packed; 267 269 union { 268 270 /* Tested with 598.314, 644.1001 and 666.2 */ 269 271 struct {
+2 -1
drivers/net/wireless/brcm80211/brcmfmac/Makefile
··· 26 26 dhd_sdio.o \ 27 27 dhd_linux.o \ 28 28 bcmsdh.o \ 29 - bcmsdh_sdmmc.o 29 + bcmsdh_sdmmc.o \ 30 + sdio_chip.o 30 31 31 32 obj-$(CONFIG_BRCMFMAC) += brcmfmac.o 32 33 brcmfmac-objs += $(DHDOFILES)
-7
drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h
··· 18 18 #define _bcmchip_h_ 19 19 20 20 /* bcm4329 */ 21 - /* SDIO device core, ID 0x829 */ 22 - #define BCM4329_CORE_BUS_BASE 0x18011000 23 - /* internal memory core, ID 0x80e */ 24 - #define BCM4329_CORE_SOCRAM_BASE 0x18003000 25 - /* ARM Cortex M3 core, ID 0x82a */ 26 - #define BCM4329_CORE_ARM_BASE 0x18002000 27 - #define BCM4329_RAMSIZE 0x48000 28 21 /* firmware name */ 29 22 #define BCM4329_FW_NAME "brcm/bcm4329-fullmac-4.bin" 30 23 #define BCM4329_NV_NAME "brcm/bcm4329-fullmac-4.txt"
+5 -13
drivers/net/wireless/brcm80211/brcmfmac/dhd.h
··· 87 87 #define TOE_TX_CSUM_OL 0x00000001 88 88 #define TOE_RX_CSUM_OL 0x00000002 89 89 90 - #define BRCMF_BSS_INFO_VERSION 108 /* current ver of brcmf_bss_info struct */ 90 + #define BRCMF_BSS_INFO_VERSION 108 /* curr ver of brcmf_bss_info_le struct */ 91 91 92 92 /* size of brcmf_scan_params not including variable length array */ 93 93 #define BRCMF_SCAN_PARAMS_FIXED_SIZE 64 ··· 122 122 123 123 /* For supporting multiple interfaces */ 124 124 #define BRCMF_MAX_IFS 16 125 - #define BRCMF_DEL_IF -0xe 126 - #define BRCMF_BAD_IF -0xf 127 125 128 126 #define DOT11_BSSTYPE_ANY 2 129 127 #define DOT11_MAX_DEFAULT_KEYS 4 ··· 363 365 * Applications MUST CHECK ie_offset field and length field to access IEs and 364 366 * next bss_info structure in a vector (in struct brcmf_scan_results) 365 367 */ 366 - struct brcmf_bss_info { 368 + struct brcmf_bss_info_le { 367 369 __le32 version; /* version field */ 368 370 __le32 length; /* byte length of data in this record, 369 371 * starting at version and including IEs ··· 464 466 u32 buflen; 465 467 u32 version; 466 468 u32 count; 467 - struct brcmf_bss_info bss_info[1]; 469 + struct brcmf_bss_info_le bss_info_le[]; 468 470 }; 469 471 470 472 struct brcmf_scan_results_le { 471 473 __le32 buflen; 472 474 __le32 version; 473 475 __le32 count; 474 - struct brcmf_bss_info bss_info[1]; 475 476 }; 476 477 477 478 /* used for association with a specific BSSID and chanspec list */ ··· 490 493 struct brcmf_assoc_params_le params_le; 491 494 }; 492 495 493 - /* size of brcmf_scan_results not including variable length array */ 494 - #define BRCMF_SCAN_RESULTS_FIXED_SIZE \ 495 - (sizeof(struct brcmf_scan_results) - sizeof(struct brcmf_bss_info)) 496 - 497 496 /* incremental scan results struct */ 498 497 struct brcmf_iscan_results { 499 498 union { ··· 504 511 505 512 /* size of brcmf_iscan_results not including variable length array */ 506 513 #define BRCMF_ISCAN_RESULTS_FIXED_SIZE \ 507 - (BRCMF_SCAN_RESULTS_FIXED_SIZE + \ 514 + (sizeof(struct brcmf_scan_results) + \ 508 515 offsetof(struct brcmf_iscan_results, results)) 509 516 510 517 struct brcmf_wsec_key { ··· 727 734 extern void brcmf_c_init(void); 728 735 729 736 extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, 730 - struct net_device *ndev, char *name, u8 *mac_addr, 731 - u32 flags, u8 bssidx); 737 + char *name, u8 *mac_addr); 732 738 extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); 733 739 734 740 /* Send packet to dongle via data channel */
+2 -3
drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c
··· 488 488 489 489 if (ifevent->ifidx > 0 && ifevent->ifidx < BRCMF_MAX_IFS) { 490 490 if (ifevent->action == BRCMF_E_IF_ADD) 491 - brcmf_add_if(drvr_priv, ifevent->ifidx, NULL, 491 + brcmf_add_if(drvr_priv, ifevent->ifidx, 492 492 event->ifname, 493 - pvt_data->eth.h_dest, 494 - ifevent->flags, ifevent->bssidx); 493 + pvt_data->eth.h_dest); 495 494 else 496 495 brcmf_del_if(drvr_priv, ifevent->ifidx); 497 496 } else {
+104 -197
drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c
··· 58 58 struct net_device *ndev; 59 59 struct net_device_stats stats; 60 60 int idx; /* iface idx in dongle */ 61 - int state; /* interface state */ 62 61 u8 mac_addr[ETH_ALEN]; /* assigned MAC address */ 63 62 }; 64 63 ··· 78 79 79 80 /* Error bits */ 80 81 module_param(brcmf_msg_level, int, 0); 81 - 82 - 83 - static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *ndev) 84 - { 85 - int i = 0; 86 - 87 - while (i < BRCMF_MAX_IFS) { 88 - if (drvr_priv->iflist[i] && drvr_priv->iflist[i]->ndev == ndev) 89 - return i; 90 - i++; 91 - } 92 - 93 - return BRCMF_BAD_IF; 94 - } 95 82 96 83 int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name) 97 84 { ··· 270 285 271 286 static int brcmf_netdev_set_mac_address(struct net_device *ndev, void *addr) 272 287 { 273 - struct brcmf_info *drvr_priv = *(struct brcmf_info **) 274 - netdev_priv(ndev); 288 + struct brcmf_if *ifp = netdev_priv(ndev); 289 + struct brcmf_info *drvr_priv = ifp->info; 275 290 struct sockaddr *sa = (struct sockaddr *)addr; 276 - int ifidx; 277 - 278 - ifidx = brcmf_net2idx(drvr_priv, ndev); 279 - if (ifidx == BRCMF_BAD_IF) 280 - return -1; 281 291 282 292 memcpy(&drvr_priv->macvalue, sa->sa_data, ETH_ALEN); 283 293 schedule_work(&drvr_priv->setmacaddr_work); ··· 281 301 282 302 static void brcmf_netdev_set_multicast_list(struct net_device *ndev) 283 303 { 284 - struct brcmf_info *drvr_priv = *(struct brcmf_info **) 285 - netdev_priv(ndev); 286 - int ifidx; 287 - 288 - ifidx = brcmf_net2idx(drvr_priv, ndev); 289 - if (ifidx == BRCMF_BAD_IF) 290 - return; 304 + struct brcmf_if *ifp = netdev_priv(ndev); 305 + struct brcmf_info *drvr_priv = ifp->info; 291 306 292 307 schedule_work(&drvr_priv->multicast_work); 293 308 } ··· 316 341 static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) 317 342 { 318 343 int ret; 319 - struct brcmf_info *drvr_priv = *(struct brcmf_info **) 320 - netdev_priv(ndev); 321 - int ifidx; 344 + struct brcmf_if *ifp = netdev_priv(ndev); 345 + struct brcmf_info *drvr_priv = ifp->info; 322 346 323 347 brcmf_dbg(TRACE, "Enter\n"); 324 348 ··· 329 355 return -ENODEV; 330 356 } 331 357 332 - ifidx = brcmf_net2idx(drvr_priv, ndev); 333 - if (ifidx == BRCMF_BAD_IF) { 334 - brcmf_dbg(ERROR, "bad ifidx %d\n", ifidx); 358 + if (!drvr_priv->iflist[ifp->idx]) { 359 + brcmf_dbg(ERROR, "bad ifidx %d\n", ifp->idx); 335 360 netif_stop_queue(ndev); 336 361 return -ENODEV; 337 362 } ··· 340 367 struct sk_buff *skb2; 341 368 342 369 brcmf_dbg(INFO, "%s: insufficient headroom\n", 343 - brcmf_ifname(&drvr_priv->pub, ifidx)); 370 + brcmf_ifname(&drvr_priv->pub, ifp->idx)); 344 371 drvr_priv->pub.tx_realloc++; 345 372 skb2 = skb_realloc_headroom(skb, drvr_priv->pub.hdrlen); 346 373 dev_kfree_skb(skb); 347 374 skb = skb2; 348 375 if (skb == NULL) { 349 376 brcmf_dbg(ERROR, "%s: skb_realloc_headroom failed\n", 350 - brcmf_ifname(&drvr_priv->pub, ifidx)); 377 + brcmf_ifname(&drvr_priv->pub, ifp->idx)); 351 378 ret = -ENOMEM; 352 379 goto done; 353 380 } 354 381 } 355 382 356 - ret = brcmf_sendpkt(&drvr_priv->pub, ifidx, skb); 383 + ret = brcmf_sendpkt(&drvr_priv->pub, ifp->idx, skb); 357 384 358 385 done: 359 386 if (ret) ··· 455 482 skb_mac_header(skb), 456 483 &event, &data); 457 484 458 - if (drvr_priv->iflist[ifidx] && 459 - !drvr_priv->iflist[ifidx]->state) 485 + if (drvr_priv->iflist[ifidx]) { 460 486 ifp = drvr_priv->iflist[ifidx]; 461 - 462 - if (ifp->ndev) 463 487 ifp->ndev->last_rx = jiffies; 488 + } 464 489 465 490 drvr->dstats.rx_bytes += skb->len; 466 491 drvr->rx_packets++; /* Local count */ ··· 495 524 496 525 static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *ndev) 497 526 { 498 - struct brcmf_info *drvr_priv = *(struct brcmf_info **) 499 - netdev_priv(ndev); 500 - struct brcmf_if *ifp; 501 - int ifidx; 527 + struct brcmf_if *ifp = netdev_priv(ndev); 528 + struct brcmf_info *drvr_priv = ifp->info; 502 529 503 530 brcmf_dbg(TRACE, "Enter\n"); 504 - 505 - ifidx = brcmf_net2idx(drvr_priv, ndev); 506 - if (ifidx == BRCMF_BAD_IF) 507 - return NULL; 508 - 509 - ifp = drvr_priv->iflist[ifidx]; 510 531 511 532 if (drvr_priv->pub.up) 512 533 /* Use the protocol to get dongle stats */ ··· 600 637 static void brcmf_ethtool_get_drvinfo(struct net_device *ndev, 601 638 struct ethtool_drvinfo *info) 602 639 { 603 - struct brcmf_info *drvr_priv = *(struct brcmf_info **) 604 - netdev_priv(ndev); 640 + struct brcmf_if *ifp = netdev_priv(ndev); 641 + struct brcmf_info *drvr_priv = ifp->info; 605 642 606 643 sprintf(info->driver, KBUILD_MODNAME); 607 644 sprintf(info->version, "%lu", drvr_priv->pub.drv_version); ··· 728 765 static int brcmf_netdev_ioctl_entry(struct net_device *ndev, struct ifreq *ifr, 729 766 int cmd) 730 767 { 731 - struct brcmf_info *drvr_priv = *(struct brcmf_info **) 732 - netdev_priv(ndev); 733 - int ifidx; 768 + struct brcmf_if *ifp = netdev_priv(ndev); 769 + struct brcmf_info *drvr_priv = ifp->info; 734 770 735 - ifidx = brcmf_net2idx(drvr_priv, ndev); 736 - brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifidx, cmd); 771 + brcmf_dbg(TRACE, "ifidx %d, cmd 0x%04x\n", ifp->idx, cmd); 737 772 738 - if (ifidx == BRCMF_BAD_IF) 773 + if (!drvr_priv->iflist[ifp->idx]) 739 774 return -1; 740 775 741 776 if (cmd == SIOCETHTOOL) ··· 749 788 s32 err = 0; 750 789 int buflen = 0; 751 790 bool is_set_key_cmd; 752 - struct brcmf_info *drvr_priv = *(struct brcmf_info **) 753 - netdev_priv(ndev); 754 - int ifidx; 791 + struct brcmf_if *ifp = netdev_priv(ndev); 792 + struct brcmf_info *drvr_priv = ifp->info; 755 793 756 794 memset(&dcmd, 0, sizeof(dcmd)); 757 795 dcmd.cmd = cmd; 758 796 dcmd.buf = arg; 759 797 dcmd.len = len; 760 - 761 - ifidx = brcmf_net2idx(drvr_priv, ndev); 762 798 763 799 if (dcmd.buf != NULL) 764 800 buflen = min_t(uint, dcmd.len, BRCMF_DCMD_MAXLEN); ··· 784 826 if (is_set_key_cmd) 785 827 brcmf_netdev_wait_pend8021x(ndev); 786 828 787 - err = brcmf_proto_dcmd(&drvr_priv->pub, ifidx, &dcmd, buflen); 829 + err = brcmf_proto_dcmd(&drvr_priv->pub, ifp->idx, &dcmd, buflen); 788 830 789 831 done: 790 832 if (err > 0) ··· 795 837 796 838 static int brcmf_netdev_stop(struct net_device *ndev) 797 839 { 798 - struct brcmf_pub *drvr = *(struct brcmf_pub **) netdev_priv(ndev); 840 + struct brcmf_if *ifp = netdev_priv(ndev); 841 + struct brcmf_pub *drvr = &ifp->info->pub; 799 842 800 843 brcmf_dbg(TRACE, "Enter\n"); 801 844 brcmf_cfg80211_down(drvr->config); ··· 812 853 813 854 static int brcmf_netdev_open(struct net_device *ndev) 814 855 { 815 - struct brcmf_info *drvr_priv = *(struct brcmf_info **) 816 - netdev_priv(ndev); 856 + struct brcmf_if *ifp = netdev_priv(ndev); 857 + struct brcmf_info *drvr_priv = ifp->info; 817 858 u32 toe_ol; 818 - int ifidx = brcmf_net2idx(drvr_priv, ndev); 819 859 s32 ret = 0; 820 860 821 - brcmf_dbg(TRACE, "ifidx %d\n", ifidx); 861 + brcmf_dbg(TRACE, "ifidx %d\n", ifp->idx); 822 862 823 - if (ifidx == 0) { /* do it only for primary eth0 */ 824 - 863 + if (ifp->idx == 0) { /* do it only for primary eth0 */ 825 864 /* try to bring up bus */ 826 865 ret = brcmf_bus_start(&drvr_priv->pub); 827 866 if (ret != 0) { ··· 831 874 memcpy(ndev->dev_addr, drvr_priv->pub.mac, ETH_ALEN); 832 875 833 876 /* Get current TOE mode from dongle */ 834 - if (brcmf_toe_get(drvr_priv, ifidx, &toe_ol) >= 0 877 + if (brcmf_toe_get(drvr_priv, ifp->idx, &toe_ol) >= 0 835 878 && (toe_ol & TOE_TX_CSUM_OL) != 0) 836 - drvr_priv->iflist[ifidx]->ndev->features |= 879 + drvr_priv->iflist[ifp->idx]->ndev->features |= 837 880 NETIF_F_IP_CSUM; 838 881 else 839 - drvr_priv->iflist[ifidx]->ndev->features &= 882 + drvr_priv->iflist[ifp->idx]->ndev->features &= 840 883 ~NETIF_F_IP_CSUM; 841 884 } 842 885 /* Allow transmit calls */ ··· 850 893 return ret; 851 894 } 852 895 896 + static const struct net_device_ops brcmf_netdev_ops_pri = { 897 + .ndo_open = brcmf_netdev_open, 898 + .ndo_stop = brcmf_netdev_stop, 899 + .ndo_get_stats = brcmf_netdev_get_stats, 900 + .ndo_do_ioctl = brcmf_netdev_ioctl_entry, 901 + .ndo_start_xmit = brcmf_netdev_start_xmit, 902 + .ndo_set_mac_address = brcmf_netdev_set_mac_address, 903 + .ndo_set_rx_mode = brcmf_netdev_set_multicast_list 904 + }; 905 + 853 906 int 854 - brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, struct net_device *ndev, 855 - char *name, u8 *mac_addr, u32 flags, u8 bssidx) 907 + brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, char *name, u8 *mac_addr) 856 908 { 857 909 struct brcmf_if *ifp; 858 - int ret = 0, err = 0; 910 + struct net_device *ndev; 859 911 860 - brcmf_dbg(TRACE, "idx %d, handle->%p\n", ifidx, ndev); 912 + brcmf_dbg(TRACE, "idx %d\n", ifidx); 861 913 862 914 ifp = drvr_priv->iflist[ifidx]; 863 - if (!ifp) { 864 - ifp = kmalloc(sizeof(struct brcmf_if), GFP_ATOMIC); 865 - if (!ifp) 866 - return -ENOMEM; 915 + /* 916 + * Delete the existing interface before overwriting it 917 + * in case we missed the BRCMF_E_IF_DEL event. 918 + */ 919 + if (ifp) { 920 + brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", 921 + ifp->ndev->name); 922 + netif_stop_queue(ifp->ndev); 923 + unregister_netdev(ifp->ndev); 924 + free_netdev(ifp->ndev); 925 + drvr_priv->iflist[ifidx] = NULL; 867 926 } 868 927 869 - memset(ifp, 0, sizeof(struct brcmf_if)); 928 + /* Allocate netdev, including space for private structure */ 929 + ndev = alloc_netdev(sizeof(struct brcmf_if), name, ether_setup); 930 + if (!ndev) { 931 + brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); 932 + return -ENOMEM; 933 + } 934 + 935 + ifp = netdev_priv(ndev); 936 + ifp->ndev = ndev; 870 937 ifp->info = drvr_priv; 871 938 drvr_priv->iflist[ifidx] = ifp; 939 + ifp->idx = ifidx; 872 940 if (mac_addr != NULL) 873 941 memcpy(&ifp->mac_addr, mac_addr, ETH_ALEN); 874 942 875 - if (ndev == NULL) { 876 - ifp->state = BRCMF_E_IF_ADD; 877 - ifp->idx = ifidx; 878 - /* 879 - * Delete the existing interface before overwriting it 880 - * in case we missed the BRCMF_E_IF_DEL event. 881 - */ 882 - if (ifp->ndev != NULL) { 883 - brcmf_dbg(ERROR, "ERROR: netdev:%s already exists, try free & unregister\n", 884 - ifp->ndev->name); 885 - netif_stop_queue(ifp->ndev); 886 - unregister_netdev(ifp->ndev); 887 - free_netdev(ifp->ndev); 888 - } 943 + if (brcmf_net_attach(&drvr_priv->pub, ifp->idx)) { 944 + brcmf_dbg(ERROR, "brcmf_net_attach failed"); 945 + free_netdev(ifp->ndev); 946 + drvr_priv->iflist[ifidx] = NULL; 947 + return -EOPNOTSUPP; 948 + } 889 949 890 - /* Allocate netdev, including space for private structure */ 891 - ifp->ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", 892 - ether_setup); 893 - if (!ifp->ndev) { 894 - brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); 895 - ret = -ENOMEM; 896 - } 897 - 898 - if (ret == 0) { 899 - memcpy(netdev_priv(ifp->ndev), &drvr_priv, 900 - sizeof(drvr_priv)); 901 - err = brcmf_net_attach(&drvr_priv->pub, ifp->idx); 902 - if (err != 0) { 903 - brcmf_dbg(ERROR, "brcmf_net_attach failed, err %d\n", 904 - err); 905 - ret = -EOPNOTSUPP; 906 - } else { 907 - brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", 908 - current->pid, ifp->ndev->name); 909 - ifp->state = 0; 910 - } 911 - } 912 - 913 - if (ret < 0) { 914 - if (ifp->ndev) 915 - free_netdev(ifp->ndev); 916 - 917 - drvr_priv->iflist[ifp->idx] = NULL; 918 - kfree(ifp); 919 - } 920 - } else 921 - ifp->ndev = ndev; 950 + brcmf_dbg(TRACE, " ==== pid:%x, net_device for if:%s created ===\n", 951 + current->pid, ifp->ndev->name); 922 952 923 953 return 0; 924 954 } ··· 921 977 brcmf_dbg(ERROR, "Null interface\n"); 922 978 return; 923 979 } 980 + if (ifp->ndev) { 981 + if (ifidx == 0) { 982 + if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { 983 + rtnl_lock(); 984 + brcmf_netdev_stop(ifp->ndev); 985 + rtnl_unlock(); 986 + } 987 + } else { 988 + netif_stop_queue(ifp->ndev); 989 + } 924 990 925 - ifp->state = BRCMF_E_IF_DEL; 926 - ifp->idx = ifidx; 927 - if (ifp->ndev != NULL) { 928 - netif_stop_queue(ifp->ndev); 929 991 unregister_netdev(ifp->ndev); 930 - free_netdev(ifp->ndev); 931 992 drvr_priv->iflist[ifidx] = NULL; 932 - kfree(ifp); 993 + if (ifidx == 0) 994 + brcmf_cfg80211_detach(drvr_priv->pub.config); 995 + free_netdev(ifp->ndev); 933 996 } 934 997 } 935 998 936 999 struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) 937 1000 { 938 1001 struct brcmf_info *drvr_priv = NULL; 939 - struct net_device *ndev; 940 1002 941 1003 brcmf_dbg(TRACE, "Enter\n"); 942 - 943 - /* Allocate netdev, including space for private structure */ 944 - ndev = alloc_netdev(sizeof(drvr_priv), "wlan%d", ether_setup); 945 - if (!ndev) { 946 - brcmf_dbg(ERROR, "OOM - alloc_netdev\n"); 947 - goto fail; 948 - } 949 1004 950 1005 /* Allocate primary brcmf_info */ 951 1006 drvr_priv = kzalloc(sizeof(struct brcmf_info), GFP_ATOMIC); 952 1007 if (!drvr_priv) 953 1008 goto fail; 954 1009 955 - /* 956 - * Save the brcmf_info into the priv 957 - */ 958 - memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); 959 - 960 - if (brcmf_add_if(drvr_priv, 0, ndev, ndev->name, NULL, 0, 0) == 961 - BRCMF_BAD_IF) 962 - goto fail; 963 - 964 - ndev->netdev_ops = NULL; 965 1010 mutex_init(&drvr_priv->proto_block); 966 1011 967 1012 /* Link to info module */ ··· 966 1033 goto fail; 967 1034 } 968 1035 969 - /* Attach and link in the cfg80211 */ 970 - drvr_priv->pub.config = 971 - brcmf_cfg80211_attach(ndev, 972 - brcmf_bus_get_device(bus), 973 - &drvr_priv->pub); 974 - if (drvr_priv->pub.config == NULL) { 975 - brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); 976 - goto fail; 977 - } 978 - 979 1036 INIT_WORK(&drvr_priv->setmacaddr_work, _brcmf_set_mac_address); 980 1037 INIT_WORK(&drvr_priv->multicast_work, _brcmf_set_multicast_list); 981 - 982 - /* 983 - * Save the brcmf_info into the priv 984 - */ 985 - memcpy(netdev_priv(ndev), &drvr_priv, sizeof(drvr_priv)); 986 1038 987 1039 return &drvr_priv->pub; 988 1040 989 1041 fail: 990 - if (ndev) 991 - free_netdev(ndev); 992 1042 if (drvr_priv) 993 1043 brcmf_detach(&drvr_priv->pub); 994 1044 ··· 1039 1123 return 0; 1040 1124 } 1041 1125 1042 - static struct net_device_ops brcmf_netdev_ops_pri = { 1043 - .ndo_open = brcmf_netdev_open, 1044 - .ndo_stop = brcmf_netdev_stop, 1045 - .ndo_get_stats = brcmf_netdev_get_stats, 1046 - .ndo_do_ioctl = brcmf_netdev_ioctl_entry, 1047 - .ndo_start_xmit = brcmf_netdev_start_xmit, 1048 - .ndo_set_mac_address = brcmf_netdev_set_mac_address, 1049 - .ndo_set_rx_mode = brcmf_netdev_set_multicast_list 1050 - }; 1051 - 1052 1126 int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) 1053 1127 { 1054 1128 struct brcmf_info *drvr_priv = drvr->info; ··· 1074 1168 drvr_priv->pub.hdrlen; 1075 1169 1076 1170 memcpy(ndev->dev_addr, temp_addr, ETH_ALEN); 1171 + 1172 + /* attach to cfg80211 for primary interface */ 1173 + if (!ifidx) { 1174 + drvr->config = 1175 + brcmf_cfg80211_attach(ndev, 1176 + brcmf_bus_get_device(drvr->bus), 1177 + drvr); 1178 + if (drvr->config == NULL) { 1179 + brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); 1180 + goto fail; 1181 + } 1182 + } 1077 1183 1078 1184 if (register_netdev(ndev) != 0) { 1079 1185 brcmf_dbg(ERROR, "couldn't register the net device\n"); ··· 1128 1210 if (drvr) { 1129 1211 drvr_priv = drvr->info; 1130 1212 if (drvr_priv) { 1131 - struct brcmf_if *ifp; 1132 1213 int i; 1133 1214 1134 - for (i = 1; i < BRCMF_MAX_IFS; i++) 1215 + /* make sure primary interface removed last */ 1216 + for (i = BRCMF_MAX_IFS-1; i > -1; i--) 1135 1217 if (drvr_priv->iflist[i]) 1136 1218 brcmf_del_if(drvr_priv, i); 1137 - 1138 - ifp = drvr_priv->iflist[0]; 1139 - if (ifp->ndev->netdev_ops == &brcmf_netdev_ops_pri) { 1140 - rtnl_lock(); 1141 - brcmf_netdev_stop(ifp->ndev); 1142 - rtnl_unlock(); 1143 - unregister_netdev(ifp->ndev); 1144 - } 1145 1219 1146 1220 cancel_work_sync(&drvr_priv->setmacaddr_work); 1147 1221 cancel_work_sync(&drvr_priv->multicast_work); ··· 1143 1233 if (drvr->prot) 1144 1234 brcmf_proto_detach(drvr); 1145 1235 1146 - brcmf_cfg80211_detach(drvr->config); 1147 - 1148 - free_netdev(ifp->ndev); 1149 - kfree(ifp); 1150 1236 kfree(drvr_priv); 1151 1237 } 1152 1238 } ··· 1208 1302 1209 1303 int brcmf_netdev_wait_pend8021x(struct net_device *ndev) 1210 1304 { 1211 - struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(ndev); 1305 + struct brcmf_if *ifp = netdev_priv(ndev); 1306 + struct brcmf_info *drvr_priv = ifp->info; 1212 1307 int timeout = 10 * HZ / 1000; 1213 1308 int ntimes = MAX_WAIT_FOR_8021X_TX; 1214 1309 int pend = brcmf_get_pend_8021x_cnt(drvr_priv);
+94 -615
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
··· 28 28 #include <linux/semaphore.h> 29 29 #include <linux/firmware.h> 30 30 #include <linux/module.h> 31 + #include <linux/bcma/bcma.h> 31 32 #include <asm/unaligned.h> 32 33 #include <defs.h> 33 34 #include <brcmu_wifi.h> ··· 36 35 #include <brcm_hw_ids.h> 37 36 #include <soc.h> 38 37 #include "sdio_host.h" 38 + #include "sdio_chip.h" 39 39 40 40 #define DCMD_RESP_TIMEOUT 2000 /* In milli second */ 41 41 ··· 135 133 #define SBSDIO_DEVCTL_RST_BPRESET 0x10 136 134 /* Force no backplane reset */ 137 135 #define SBSDIO_DEVCTL_RST_NOBPRESET 0x20 138 - 139 - /* SBSDIO_FUNC1_CHIPCLKCSR */ 140 - 141 - /* Force ALP request to backplane */ 142 - #define SBSDIO_FORCE_ALP 0x01 143 - /* Force HT request to backplane */ 144 - #define SBSDIO_FORCE_HT 0x02 145 - /* Force ILP request to backplane */ 146 - #define SBSDIO_FORCE_ILP 0x04 147 - /* Make ALP ready (power up xtal) */ 148 - #define SBSDIO_ALP_AVAIL_REQ 0x08 149 - /* Make HT ready (power up PLL) */ 150 - #define SBSDIO_HT_AVAIL_REQ 0x10 151 - /* Squelch clock requests from HW */ 152 - #define SBSDIO_FORCE_HW_CLKREQ_OFF 0x20 153 - /* Status: ALP is ready */ 154 - #define SBSDIO_ALP_AVAIL 0x40 155 - /* Status: HT is ready */ 156 - #define SBSDIO_HT_AVAIL 0x80 157 - 158 - #define SBSDIO_AVBITS (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL) 159 - #define SBSDIO_ALPAV(regval) ((regval) & SBSDIO_AVBITS) 160 - #define SBSDIO_HTAV(regval) (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS) 161 - #define SBSDIO_ALPONLY(regval) (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval)) 162 - 163 - #define SBSDIO_CLKAV(regval, alponly) \ 164 - (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) 165 136 166 137 /* direct(mapped) cis space */ 167 138 ··· 310 335 /* Flags for SDH calls */ 311 336 #define F2SYNC (SDIO_REQ_4BYTE | SDIO_REQ_FIXED) 312 337 313 - /* sbimstate */ 314 - #define SBIM_IBE 0x20000 /* inbanderror */ 315 - #define SBIM_TO 0x40000 /* timeout */ 316 - #define SBIM_BY 0x01800000 /* busy (sonics >= 2.3) */ 317 - #define SBIM_RJ 0x02000000 /* reject (sonics >= 2.3) */ 318 - 319 - /* sbtmstatelow */ 320 - 321 - /* reset */ 322 - #define SBTML_RESET 0x0001 323 - /* reject field */ 324 - #define SBTML_REJ_MASK 0x0006 325 - /* reject */ 326 - #define SBTML_REJ 0x0002 327 - /* temporary reject, for error recovery */ 328 - #define SBTML_TMPREJ 0x0004 329 - 330 - /* Shift to locate the SI control flags in sbtml */ 331 - #define SBTML_SICF_SHIFT 16 332 - 333 - /* sbtmstatehigh */ 334 - #define SBTMH_SERR 0x0001 /* serror */ 335 - #define SBTMH_INT 0x0002 /* interrupt */ 336 - #define SBTMH_BUSY 0x0004 /* busy */ 337 - #define SBTMH_TO 0x0020 /* timeout (sonics >= 2.3) */ 338 - 339 - /* Shift to locate the SI status flags in sbtmh */ 340 - #define SBTMH_SISF_SHIFT 16 341 - 342 - /* sbidlow */ 343 - #define SBIDL_INIT 0x80 /* initiator */ 344 - 345 - /* sbidhigh */ 346 - #define SBIDH_RC_MASK 0x000f /* revision code */ 347 - #define SBIDH_RCE_MASK 0x7000 /* revision code extension field */ 348 - #define SBIDH_RCE_SHIFT 8 349 - #define SBCOREREV(sbidh) \ 350 - ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | \ 351 - ((sbidh) & SBIDH_RC_MASK)) 352 - #define SBIDH_CC_MASK 0x8ff0 /* core code */ 353 - #define SBIDH_CC_SHIFT 4 354 - #define SBIDH_VC_MASK 0xffff0000 /* vendor code */ 355 - #define SBIDH_VC_SHIFT 16 356 - 357 338 /* 358 339 * Conversion of 802.1D priority to precedence level 359 340 */ ··· 318 387 return (prio == PRIO_8021D_NONE || prio == PRIO_8021D_BE) ? 319 388 (prio^2) : prio; 320 389 } 321 - 322 - /* 323 - * Core reg address translation. 324 - * Both macro's returns a 32 bits byte address on the backplane bus. 325 - */ 326 - #define CORE_CC_REG(base, field) \ 327 - (base + offsetof(struct chipcregs, field)) 328 - #define CORE_BUS_REG(base, field) \ 329 - (base + offsetof(struct sdpcmd_regs, field)) 330 - #define CORE_SB(base, field) \ 331 - (base + SBCONFIGOFF + offsetof(struct sbconfig, field)) 332 390 333 391 /* core registers */ 334 392 struct sdpcmd_regs { ··· 444 524 445 525 446 526 /* misc chip info needed by some of the routines */ 447 - struct chip_info { 448 - u32 chip; 449 - u32 chiprev; 450 - u32 cccorebase; 451 - u32 ccrev; 452 - u32 cccaps; 453 - u32 buscorebase; /* 32 bits backplane bus address */ 454 - u32 buscorerev; 455 - u32 buscoretype; 456 - u32 ramcorebase; 457 - u32 armcorebase; 458 - u32 pmurev; 459 - u32 ramsize; 460 - }; 461 - 462 527 /* Private data for SDIO bus interaction */ 463 528 struct brcmf_bus { 464 529 struct brcmf_pub *drvr; ··· 479 574 uint txminmax; 480 575 481 576 struct sk_buff *glomd; /* Packet containing glomming descriptor */ 482 - struct sk_buff *glom; /* Packet chain for glommed superframe */ 577 + struct sk_buff_head glom; /* Packet list for glommed superframe */ 483 578 uint glomerr; /* Glom packet read errors */ 484 579 485 580 u8 *rxbuf; /* Buffer for receiving control packets */ ··· 568 663 u32 fw_ptr; 569 664 }; 570 665 571 - struct sbconfig { 572 - u32 PAD[2]; 573 - u32 sbipsflag; /* initiator port ocp slave flag */ 574 - u32 PAD[3]; 575 - u32 sbtpsflag; /* target port ocp slave flag */ 576 - u32 PAD[11]; 577 - u32 sbtmerrloga; /* (sonics >= 2.3) */ 578 - u32 PAD; 579 - u32 sbtmerrlog; /* (sonics >= 2.3) */ 580 - u32 PAD[3]; 581 - u32 sbadmatch3; /* address match3 */ 582 - u32 PAD; 583 - u32 sbadmatch2; /* address match2 */ 584 - u32 PAD; 585 - u32 sbadmatch1; /* address match1 */ 586 - u32 PAD[7]; 587 - u32 sbimstate; /* initiator agent state */ 588 - u32 sbintvec; /* interrupt mask */ 589 - u32 sbtmstatelow; /* target state */ 590 - u32 sbtmstatehigh; /* target state */ 591 - u32 sbbwa0; /* bandwidth allocation table0 */ 592 - u32 PAD; 593 - u32 sbimconfiglow; /* initiator configuration */ 594 - u32 sbimconfighigh; /* initiator configuration */ 595 - u32 sbadmatch0; /* address match0 */ 596 - u32 PAD; 597 - u32 sbtmconfiglow; /* target configuration */ 598 - u32 sbtmconfighigh; /* target configuration */ 599 - u32 sbbconfig; /* broadcast configuration */ 600 - u32 PAD; 601 - u32 sbbstate; /* broadcast state */ 602 - u32 PAD[3]; 603 - u32 sbactcnfg; /* activate configuration */ 604 - u32 PAD[3]; 605 - u32 sbflagst; /* current sbflags */ 606 - u32 PAD[3]; 607 - u32 sbidlow; /* identification */ 608 - u32 sbidhigh; /* identification */ 609 - }; 610 - 611 666 /* clkstate */ 612 667 #define CLK_NONE 0 613 668 #define CLK_SDONLY 1 ··· 615 750 static void 616 751 r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) 617 752 { 753 + u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); 618 754 *retryvar = 0; 619 755 do { 620 756 *regvar = brcmf_sdcard_reg_read(bus->sdiodev, 621 - bus->ci->buscorebase + reg_offset, sizeof(u32)); 757 + bus->ci->c_inf[idx].base + reg_offset, 758 + sizeof(u32)); 622 759 } while (brcmf_sdcard_regfail(bus->sdiodev) && 623 760 (++(*retryvar) <= retry_limit)); 624 761 if (*retryvar) { ··· 635 768 static void 636 769 w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) 637 770 { 771 + u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); 638 772 *retryvar = 0; 639 773 do { 640 774 brcmf_sdcard_reg_write(bus->sdiodev, 641 - bus->ci->buscorebase + reg_offset, 775 + bus->ci->c_inf[idx].base + reg_offset, 642 776 sizeof(u32), regval); 643 777 } while (brcmf_sdcard_regfail(bus->sdiodev) && 644 778 (++(*retryvar) <= retry_limit)); ··· 680 812 clkreq = 681 813 bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ; 682 814 683 - if ((bus->ci->chip == BCM4329_CHIP_ID) 684 - && (bus->ci->chiprev == 0)) 685 - clkreq |= SBSDIO_FORCE_ALP; 686 - 687 815 brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, 688 816 SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); 689 817 if (err) { 690 818 brcmf_dbg(ERROR, "HT Avail request error: %d\n", err); 691 819 return -EBADE; 692 - } 693 - 694 - if (pendok && ((bus->ci->buscoretype == PCMCIA_CORE_ID) 695 - && (bus->ci->buscorerev == 9))) { 696 - u32 dummy, retries; 697 - r_sdreg32(bus, &dummy, 698 - offsetof(struct sdpcmd_regs, clockctlstatus), 699 - &retries); 700 820 } 701 821 702 822 /* Check current status */ ··· 890 1034 SBSDIO_FORCE_HW_CLKREQ_OFF, NULL); 891 1035 892 1036 /* Isolate the bus */ 893 - if (bus->ci->chip != BCM4329_CHIP_ID) { 894 - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, 895 - SBSDIO_DEVICE_CTL, 896 - SBSDIO_DEVCTL_PADS_ISO, NULL); 897 - } 1037 + brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, 1038 + SBSDIO_DEVICE_CTL, 1039 + SBSDIO_DEVCTL_PADS_ISO, NULL); 898 1040 899 1041 /* Change state */ 900 1042 bus->sleeping = true; ··· 902 1048 903 1049 brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, 904 1050 SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); 905 - 906 - /* Force pad isolation off if possible 907 - (in case power never toggled) */ 908 - if ((bus->ci->buscoretype == PCMCIA_CORE_ID) 909 - && (bus->ci->buscorerev >= 10)) 910 - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, 911 - SBSDIO_DEVICE_CTL, 0, NULL); 912 1051 913 1052 /* Make sure the controller has the bus up */ 914 1053 brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); ··· 1069 1222 bus->drvr->busstate = BRCMF_BUS_DOWN; 1070 1223 } 1071 1224 1225 + /* copy a buffer into a pkt buffer chain */ 1226 + static uint brcmf_sdbrcm_glom_from_buf(struct brcmf_bus *bus, uint len) 1227 + { 1228 + uint n, ret = 0; 1229 + struct sk_buff *p; 1230 + u8 *buf; 1231 + 1232 + buf = bus->dataptr; 1233 + 1234 + /* copy the data */ 1235 + skb_queue_walk(&bus->glom, p) { 1236 + n = min_t(uint, p->len, len); 1237 + memcpy(p->data, buf, n); 1238 + buf += n; 1239 + len -= n; 1240 + ret += n; 1241 + if (!len) 1242 + break; 1243 + } 1244 + 1245 + return ret; 1246 + } 1247 + 1248 + /* return total length of buffer chain */ 1249 + static uint brcmf_sdbrcm_glom_len(struct brcmf_bus *bus) 1250 + { 1251 + struct sk_buff *p; 1252 + uint total; 1253 + 1254 + total = 0; 1255 + skb_queue_walk(&bus->glom, p) 1256 + total += p->len; 1257 + return total; 1258 + } 1259 + 1260 + static void brcmf_sdbrcm_free_glom(struct brcmf_bus *bus) 1261 + { 1262 + struct sk_buff *cur, *next; 1263 + 1264 + skb_queue_walk_safe(&bus->glom, cur, next) { 1265 + skb_unlink(cur, &bus->glom); 1266 + brcmu_pkt_buf_free_skb(cur); 1267 + } 1268 + } 1269 + 1072 1270 static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) 1073 1271 { 1074 1272 u16 dlen, totlen; ··· 1132 1240 /* If packets, issue read(s) and send up packet chain */ 1133 1241 /* Return sequence numbers consumed? */ 1134 1242 1135 - brcmf_dbg(TRACE, "start: glomd %p glom %p\n", bus->glomd, bus->glom); 1243 + brcmf_dbg(TRACE, "start: glomd %p glom %p\n", 1244 + bus->glomd, skb_peek(&bus->glom)); 1136 1245 1137 1246 /* If there's a descriptor, generate the packet chain */ 1138 1247 if (bus->glomd) { ··· 1180 1287 num, sublen); 1181 1288 break; 1182 1289 } 1183 - if (!pfirst) { 1184 - pfirst = plast = pnext; 1185 - } else { 1186 - plast->next = pnext; 1187 - plast = pnext; 1188 - } 1290 + skb_queue_tail(&bus->glom, pnext); 1189 1291 1190 1292 /* Adhere to start alignment requirements */ 1191 1293 pkt_align(pnext, sublen, BRCMF_SDALIGN); ··· 1196 1308 brcmf_dbg(GLOM, "glomdesc mismatch: nextlen %d glomdesc %d rxseq %d\n", 1197 1309 bus->nextlen, totlen, rxseq); 1198 1310 } 1199 - bus->glom = pfirst; 1200 1311 pfirst = pnext = NULL; 1201 1312 } else { 1202 - if (pfirst) 1203 - brcmu_pkt_buf_free_skb(pfirst); 1204 - bus->glom = NULL; 1313 + brcmf_sdbrcm_free_glom(bus); 1205 1314 num = 0; 1206 1315 } 1207 1316 ··· 1210 1325 1211 1326 /* Ok -- either we just generated a packet chain, 1212 1327 or had one from before */ 1213 - if (bus->glom) { 1328 + if (!skb_queue_empty(&bus->glom)) { 1214 1329 if (BRCMF_GLOM_ON()) { 1215 1330 brcmf_dbg(GLOM, "try superframe read, packet chain:\n"); 1216 - for (pnext = bus->glom; pnext; pnext = pnext->next) { 1331 + skb_queue_walk(&bus->glom, pnext) { 1217 1332 brcmf_dbg(GLOM, " %p: %p len 0x%04x (%d)\n", 1218 1333 pnext, (u8 *) (pnext->data), 1219 1334 pnext->len, pnext->len); 1220 1335 } 1221 1336 } 1222 1337 1223 - pfirst = bus->glom; 1224 - dlen = (u16) brcmu_pkttotlen(pfirst); 1338 + pfirst = skb_peek(&bus->glom); 1339 + dlen = (u16) brcmf_sdbrcm_glom_len(bus); 1225 1340 1226 1341 /* Do an SDIO read for the superframe. Configurable iovar to 1227 1342 * read directly into the chained packet, or allocate a large ··· 1239 1354 SDIO_FUNC_2, 1240 1355 F2SYNC, bus->dataptr, dlen, 1241 1356 NULL); 1242 - sublen = (u16) brcmu_pktfrombuf(pfirst, 0, dlen, 1243 - bus->dataptr); 1357 + sublen = (u16) brcmf_sdbrcm_glom_from_buf(bus, dlen); 1244 1358 if (sublen != dlen) { 1245 1359 brcmf_dbg(ERROR, "FAILED TO COPY, dlen %d sublen %d\n", 1246 1360 dlen, sublen); ··· 1264 1380 } else { 1265 1381 bus->glomerr = 0; 1266 1382 brcmf_sdbrcm_rxfail(bus, true, false); 1267 - brcmu_pkt_buf_free_skb(bus->glom); 1268 1383 bus->rxglomfail++; 1269 - bus->glom = NULL; 1384 + brcmf_sdbrcm_free_glom(bus); 1270 1385 } 1271 1386 return 0; 1272 1387 } ··· 1386 1503 } else { 1387 1504 bus->glomerr = 0; 1388 1505 brcmf_sdbrcm_rxfail(bus, true, false); 1389 - brcmu_pkt_buf_free_skb(bus->glom); 1390 1506 bus->rxglomfail++; 1391 - bus->glom = NULL; 1507 + brcmf_sdbrcm_free_glom(bus); 1392 1508 } 1393 1509 bus->nextlen = 0; 1394 1510 return 0; ··· 1395 1513 1396 1514 /* Basic SD framing looks ok - process each packet (header) */ 1397 1515 save_pfirst = pfirst; 1398 - bus->glom = NULL; 1399 1516 plast = NULL; 1400 1517 1401 1518 for (num = 0; pfirst; rxseq++, pfirst = pnext) { ··· 1731 1850 rxseq++, rxleft--) { 1732 1851 1733 1852 /* Handle glomming separately */ 1734 - if (bus->glom || bus->glomd) { 1853 + if (bus->glomd || !skb_queue_empty(&bus->glom)) { 1735 1854 u8 cnt; 1736 1855 brcmf_dbg(GLOM, "calling rxglom: glomd %p, glom %p\n", 1737 - bus->glomd, bus->glom); 1856 + bus->glomd, skb_peek(&bus->glom)); 1738 1857 cnt = brcmf_sdbrcm_rxglom(bus, rxseq); 1739 1858 brcmf_dbg(GLOM, "rxglom returned %d\n", cnt); 1740 1859 rxseq += cnt - 1; ··· 3091 3210 return bcmerror; 3092 3211 } 3093 3212 3094 - static void 3095 - brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_dev *sdiodev, u32 corebase) 3096 - { 3097 - u32 regdata; 3098 - 3099 - regdata = brcmf_sdcard_reg_read(sdiodev, 3100 - CORE_SB(corebase, sbtmstatelow), 4); 3101 - if (regdata & SBTML_RESET) 3102 - return; 3103 - 3104 - regdata = brcmf_sdcard_reg_read(sdiodev, 3105 - CORE_SB(corebase, sbtmstatelow), 4); 3106 - if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) { 3107 - /* 3108 - * set target reject and spin until busy is clear 3109 - * (preserve core-specific bits) 3110 - */ 3111 - regdata = brcmf_sdcard_reg_read(sdiodev, 3112 - CORE_SB(corebase, sbtmstatelow), 4); 3113 - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 3114 - 4, regdata | SBTML_REJ); 3115 - 3116 - regdata = brcmf_sdcard_reg_read(sdiodev, 3117 - CORE_SB(corebase, sbtmstatelow), 4); 3118 - udelay(1); 3119 - SPINWAIT((brcmf_sdcard_reg_read(sdiodev, 3120 - CORE_SB(corebase, sbtmstatehigh), 4) & 3121 - SBTMH_BUSY), 100000); 3122 - 3123 - regdata = brcmf_sdcard_reg_read(sdiodev, 3124 - CORE_SB(corebase, sbtmstatehigh), 4); 3125 - if (regdata & SBTMH_BUSY) 3126 - brcmf_dbg(ERROR, "ARM core still busy\n"); 3127 - 3128 - regdata = brcmf_sdcard_reg_read(sdiodev, 3129 - CORE_SB(corebase, sbidlow), 4); 3130 - if (regdata & SBIDL_INIT) { 3131 - regdata = brcmf_sdcard_reg_read(sdiodev, 3132 - CORE_SB(corebase, sbimstate), 4) | 3133 - SBIM_RJ; 3134 - brcmf_sdcard_reg_write(sdiodev, 3135 - CORE_SB(corebase, sbimstate), 4, 3136 - regdata); 3137 - regdata = brcmf_sdcard_reg_read(sdiodev, 3138 - CORE_SB(corebase, sbimstate), 4); 3139 - udelay(1); 3140 - SPINWAIT((brcmf_sdcard_reg_read(sdiodev, 3141 - CORE_SB(corebase, sbimstate), 4) & 3142 - SBIM_BY), 100000); 3143 - } 3144 - 3145 - /* set reset and reject while enabling the clocks */ 3146 - brcmf_sdcard_reg_write(sdiodev, 3147 - CORE_SB(corebase, sbtmstatelow), 4, 3148 - (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | 3149 - SBTML_REJ | SBTML_RESET)); 3150 - regdata = brcmf_sdcard_reg_read(sdiodev, 3151 - CORE_SB(corebase, sbtmstatelow), 4); 3152 - udelay(10); 3153 - 3154 - /* clear the initiator reject bit */ 3155 - regdata = brcmf_sdcard_reg_read(sdiodev, 3156 - CORE_SB(corebase, sbidlow), 4); 3157 - if (regdata & SBIDL_INIT) { 3158 - regdata = brcmf_sdcard_reg_read(sdiodev, 3159 - CORE_SB(corebase, sbimstate), 4) & 3160 - ~SBIM_RJ; 3161 - brcmf_sdcard_reg_write(sdiodev, 3162 - CORE_SB(corebase, sbimstate), 4, 3163 - regdata); 3164 - } 3165 - } 3166 - 3167 - /* leave reset and reject asserted */ 3168 - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, 3169 - (SBTML_REJ | SBTML_RESET)); 3170 - udelay(1); 3171 - } 3172 - 3173 - static void 3174 - brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_dev *sdiodev, u32 corebase) 3175 - { 3176 - u32 regdata; 3177 - 3178 - /* 3179 - * Must do the disable sequence first to work for 3180 - * arbitrary current core state. 3181 - */ 3182 - brcmf_sdbrcm_chip_disablecore(sdiodev, corebase); 3183 - 3184 - /* 3185 - * Now do the initialization sequence. 3186 - * set reset while enabling the clock and 3187 - * forcing them on throughout the core 3188 - */ 3189 - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, 3190 - ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | 3191 - SBTML_RESET); 3192 - udelay(1); 3193 - 3194 - regdata = brcmf_sdcard_reg_read(sdiodev, 3195 - CORE_SB(corebase, sbtmstatehigh), 4); 3196 - if (regdata & SBTMH_SERR) 3197 - brcmf_sdcard_reg_write(sdiodev, 3198 - CORE_SB(corebase, sbtmstatehigh), 4, 0); 3199 - 3200 - regdata = brcmf_sdcard_reg_read(sdiodev, 3201 - CORE_SB(corebase, sbimstate), 4); 3202 - if (regdata & (SBIM_IBE | SBIM_TO)) 3203 - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbimstate), 4, 3204 - regdata & ~(SBIM_IBE | SBIM_TO)); 3205 - 3206 - /* clear reset and allow it to propagate throughout the core */ 3207 - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, 3208 - (SICF_FGC << SBTML_SICF_SHIFT) | 3209 - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); 3210 - udelay(1); 3211 - 3212 - /* leave clock enabled */ 3213 - brcmf_sdcard_reg_write(sdiodev, CORE_SB(corebase, sbtmstatelow), 4, 3214 - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); 3215 - udelay(1); 3216 - } 3217 - 3218 3213 static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) 3219 3214 { 3220 3215 uint retries; 3221 - u32 regdata; 3222 3216 int bcmerror = 0; 3217 + struct chip_info *ci = bus->ci; 3223 3218 3224 3219 /* To enter download state, disable ARM and reset SOCRAM. 3225 3220 * To exit download state, simply reset ARM (default is RAM boot). ··· 3103 3346 if (enter) { 3104 3347 bus->alp_only = true; 3105 3348 3106 - brcmf_sdbrcm_chip_disablecore(bus->sdiodev, 3107 - bus->ci->armcorebase); 3349 + ci->coredisable(bus->sdiodev, ci, BCMA_CORE_ARM_CM3); 3108 3350 3109 - brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->ramcorebase); 3351 + ci->resetcore(bus->sdiodev, ci, BCMA_CORE_INTERNAL_MEM); 3110 3352 3111 3353 /* Clear the top bit of memory */ 3112 3354 if (bus->ramsize) { ··· 3114 3358 (u8 *)&zeros, 4); 3115 3359 } 3116 3360 } else { 3117 - regdata = brcmf_sdcard_reg_read(bus->sdiodev, 3118 - CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4); 3119 - regdata &= (SBTML_RESET | SBTML_REJ_MASK | 3120 - (SICF_CLOCK_EN << SBTML_SICF_SHIFT)); 3121 - if ((SICF_CLOCK_EN << SBTML_SICF_SHIFT) != regdata) { 3361 + if (!ci->iscoreup(bus->sdiodev, ci, BCMA_CORE_INTERNAL_MEM)) { 3122 3362 brcmf_dbg(ERROR, "SOCRAM core is down after reset?\n"); 3123 3363 bcmerror = -EBADE; 3124 3364 goto fail; ··· 3129 3377 w_sdreg32(bus, 0xFFFFFFFF, 3130 3378 offsetof(struct sdpcmd_regs, intstatus), &retries); 3131 3379 3132 - brcmf_sdbrcm_chip_resetcore(bus->sdiodev, bus->ci->armcorebase); 3380 + ci->resetcore(bus->sdiodev, ci, BCMA_CORE_ARM_CM3); 3133 3381 3134 3382 /* Allow HT Clock now that the ARM is running. */ 3135 3383 bus->alp_only = false; ··· 3413 3661 /* Clear any held glomming stuff */ 3414 3662 if (bus->glomd) 3415 3663 brcmu_pkt_buf_free_skb(bus->glomd); 3416 - 3417 - if (bus->glom) 3418 - brcmu_pkt_buf_free_skb(bus->glom); 3419 - 3420 - bus->glom = bus->glomd = NULL; 3664 + brcmf_sdbrcm_free_glom(bus); 3421 3665 3422 3666 /* Clear rx control and wake any waiters */ 3423 3667 bus->rxlen = 0; ··· 3698 3950 return false; 3699 3951 } 3700 3952 3701 - /* SDIO Pad drive strength to select value mappings */ 3702 - struct sdiod_drive_str { 3703 - u8 strength; /* Pad Drive Strength in mA */ 3704 - u8 sel; /* Chip-specific select value */ 3705 - }; 3706 - 3707 - /* SDIO Drive Strength to sel value table for PMU Rev 1 */ 3708 - static const struct sdiod_drive_str sdiod_drive_strength_tab1[] = { 3709 - { 3710 - 4, 0x2}, { 3711 - 2, 0x3}, { 3712 - 1, 0x0}, { 3713 - 0, 0x0} 3714 - }; 3715 - 3716 - /* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */ 3717 - static const struct sdiod_drive_str sdiod_drive_strength_tab2[] = { 3718 - { 3719 - 12, 0x7}, { 3720 - 10, 0x6}, { 3721 - 8, 0x5}, { 3722 - 6, 0x4}, { 3723 - 4, 0x2}, { 3724 - 2, 0x1}, { 3725 - 0, 0x0} 3726 - }; 3727 - 3728 - /* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */ 3729 - static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { 3730 - { 3731 - 32, 0x7}, { 3732 - 26, 0x6}, { 3733 - 22, 0x5}, { 3734 - 16, 0x4}, { 3735 - 12, 0x3}, { 3736 - 8, 0x2}, { 3737 - 4, 0x1}, { 3738 - 0, 0x0} 3739 - }; 3740 - 3741 - #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) 3742 - 3743 - static char *brcmf_chipname(uint chipid, char *buf, uint len) 3744 - { 3745 - const char *fmt; 3746 - 3747 - fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x"; 3748 - snprintf(buf, len, fmt, chipid); 3749 - return buf; 3750 - } 3751 - 3752 - static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, 3753 - u32 drivestrength) { 3754 - struct sdiod_drive_str *str_tab = NULL; 3755 - u32 str_mask = 0; 3756 - u32 str_shift = 0; 3757 - char chn[8]; 3758 - 3759 - if (!(bus->ci->cccaps & CC_CAP_PMU)) 3760 - return; 3761 - 3762 - switch (SDIOD_DRVSTR_KEY(bus->ci->chip, bus->ci->pmurev)) { 3763 - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1): 3764 - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab1; 3765 - str_mask = 0x30000000; 3766 - str_shift = 28; 3767 - break; 3768 - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2): 3769 - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3): 3770 - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab2; 3771 - str_mask = 0x00003800; 3772 - str_shift = 11; 3773 - break; 3774 - case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8): 3775 - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab3; 3776 - str_mask = 0x00003800; 3777 - str_shift = 11; 3778 - break; 3779 - default: 3780 - brcmf_dbg(ERROR, "No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", 3781 - brcmf_chipname(bus->ci->chip, chn, 8), 3782 - bus->ci->chiprev, bus->ci->pmurev); 3783 - break; 3784 - } 3785 - 3786 - if (str_tab != NULL) { 3787 - u32 drivestrength_sel = 0; 3788 - u32 cc_data_temp; 3789 - int i; 3790 - 3791 - for (i = 0; str_tab[i].strength != 0; i++) { 3792 - if (drivestrength >= str_tab[i].strength) { 3793 - drivestrength_sel = str_tab[i].sel; 3794 - break; 3795 - } 3796 - } 3797 - 3798 - brcmf_sdcard_reg_write(bus->sdiodev, 3799 - CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 3800 - 4, 1); 3801 - cc_data_temp = brcmf_sdcard_reg_read(bus->sdiodev, 3802 - CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4); 3803 - cc_data_temp &= ~str_mask; 3804 - drivestrength_sel <<= str_shift; 3805 - cc_data_temp |= drivestrength_sel; 3806 - brcmf_sdcard_reg_write(bus->sdiodev, 3807 - CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 3808 - 4, cc_data_temp); 3809 - 3810 - brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n", 3811 - drivestrength, cc_data_temp); 3812 - } 3813 - } 3814 - 3815 - static int 3816 - brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, 3817 - struct chip_info *ci, u32 regs) 3818 - { 3819 - u32 regdata; 3820 - 3821 - /* 3822 - * Get CC core rev 3823 - * Chipid is assume to be at offset 0 from regs arg 3824 - * For different chiptypes or old sdio hosts w/o chipcommon, 3825 - * other ways of recognition should be added here. 3826 - */ 3827 - ci->cccorebase = regs; 3828 - regdata = brcmf_sdcard_reg_read(sdiodev, 3829 - CORE_CC_REG(ci->cccorebase, chipid), 4); 3830 - ci->chip = regdata & CID_ID_MASK; 3831 - ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; 3832 - 3833 - brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); 3834 - 3835 - /* Address of cores for new chips should be added here */ 3836 - switch (ci->chip) { 3837 - case BCM4329_CHIP_ID: 3838 - ci->buscorebase = BCM4329_CORE_BUS_BASE; 3839 - ci->ramcorebase = BCM4329_CORE_SOCRAM_BASE; 3840 - ci->armcorebase = BCM4329_CORE_ARM_BASE; 3841 - ci->ramsize = BCM4329_RAMSIZE; 3842 - break; 3843 - default: 3844 - brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); 3845 - return -ENODEV; 3846 - } 3847 - 3848 - regdata = brcmf_sdcard_reg_read(sdiodev, 3849 - CORE_SB(ci->cccorebase, sbidhigh), 4); 3850 - ci->ccrev = SBCOREREV(regdata); 3851 - 3852 - regdata = brcmf_sdcard_reg_read(sdiodev, 3853 - CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); 3854 - ci->pmurev = regdata & PCAP_REV_MASK; 3855 - 3856 - regdata = brcmf_sdcard_reg_read(sdiodev, 3857 - CORE_SB(ci->buscorebase, sbidhigh), 4); 3858 - ci->buscorerev = SBCOREREV(regdata); 3859 - ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; 3860 - 3861 - brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", 3862 - ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); 3863 - 3864 - /* get chipcommon capabilites */ 3865 - ci->cccaps = brcmf_sdcard_reg_read(sdiodev, 3866 - CORE_CC_REG(ci->cccorebase, capabilities), 4); 3867 - 3868 - return 0; 3869 - } 3870 - 3871 - static int 3872 - brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) 3873 - { 3874 - struct chip_info *ci; 3875 - int err; 3876 - u8 clkval, clkset; 3877 - 3878 - brcmf_dbg(TRACE, "Enter\n"); 3879 - 3880 - /* alloc chip_info_t */ 3881 - ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); 3882 - if (NULL == ci) 3883 - return -ENOMEM; 3884 - 3885 - /* bus/core/clk setup for register access */ 3886 - /* Try forcing SDIO core to do ALPAvail request only */ 3887 - clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; 3888 - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, 3889 - SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); 3890 - if (err) { 3891 - brcmf_dbg(ERROR, "error writing for HT off\n"); 3892 - goto fail; 3893 - } 3894 - 3895 - /* If register supported, wait for ALPAvail and then force ALP */ 3896 - /* This may take up to 15 milliseconds */ 3897 - clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, 3898 - SBSDIO_FUNC1_CHIPCLKCSR, NULL); 3899 - if ((clkval & ~SBSDIO_AVBITS) == clkset) { 3900 - SPINWAIT(((clkval = 3901 - brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, 3902 - SBSDIO_FUNC1_CHIPCLKCSR, 3903 - NULL)), 3904 - !SBSDIO_ALPAV(clkval)), 3905 - PMU_MAX_TRANSITION_DLY); 3906 - if (!SBSDIO_ALPAV(clkval)) { 3907 - brcmf_dbg(ERROR, "timeout on ALPAV wait, clkval 0x%02x\n", 3908 - clkval); 3909 - err = -EBUSY; 3910 - goto fail; 3911 - } 3912 - clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | 3913 - SBSDIO_FORCE_ALP; 3914 - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, 3915 - SBSDIO_FUNC1_CHIPCLKCSR, 3916 - clkset, &err); 3917 - udelay(65); 3918 - } else { 3919 - brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n", 3920 - clkset, clkval); 3921 - err = -EACCES; 3922 - goto fail; 3923 - } 3924 - 3925 - /* Also, disable the extra SDIO pull-ups */ 3926 - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, 3927 - SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); 3928 - 3929 - err = brcmf_sdbrcm_chip_recognition(bus->sdiodev, ci, regs); 3930 - if (err) 3931 - goto fail; 3932 - 3933 - /* 3934 - * Make sure any on-chip ARM is off (in case strapping is wrong), 3935 - * or downloaded code was already running. 3936 - */ 3937 - brcmf_sdbrcm_chip_disablecore(bus->sdiodev, ci->armcorebase); 3938 - 3939 - brcmf_sdcard_reg_write(bus->sdiodev, 3940 - CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); 3941 - brcmf_sdcard_reg_write(bus->sdiodev, 3942 - CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); 3943 - 3944 - /* Disable F2 to clear any intermediate frame state on the dongle */ 3945 - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, 3946 - SDIO_FUNC_ENABLE_1, NULL); 3947 - 3948 - /* WAR: cmd52 backplane read so core HW will drop ALPReq */ 3949 - clkval = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, 3950 - 0, NULL); 3951 - 3952 - /* Done with backplane-dependent accesses, can drop clock... */ 3953 - brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, 3954 - SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); 3955 - 3956 - bus->ci = ci; 3957 - return 0; 3958 - fail: 3959 - bus->ci = NULL; 3960 - kfree(ci); 3961 - return err; 3962 - } 3963 - 3964 3953 static bool 3965 3954 brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) 3966 3955 { ··· 3705 4220 int err = 0; 3706 4221 int reg_addr; 3707 4222 u32 reg_val; 4223 + u8 idx; 3708 4224 3709 4225 bus->alp_only = true; 3710 4226 ··· 3720 4234 #endif /* BCMDBG */ 3721 4235 3722 4236 /* 3723 - * Force PLL off until brcmf_sdbrcm_chip_attach() 4237 + * Force PLL off until brcmf_sdio_chip_attach() 3724 4238 * programs PLL control regs 3725 4239 */ 3726 4240 ··· 3738 4252 goto fail; 3739 4253 } 3740 4254 3741 - if (brcmf_sdbrcm_chip_attach(bus, regsva)) { 3742 - brcmf_dbg(ERROR, "brcmf_sdbrcm_chip_attach failed!\n"); 4255 + if (brcmf_sdio_chip_attach(bus->sdiodev, &bus->ci, regsva)) { 4256 + brcmf_dbg(ERROR, "brcmf_sdio_chip_attach failed!\n"); 3743 4257 goto fail; 3744 4258 } 3745 4259 ··· 3748 4262 goto fail; 3749 4263 } 3750 4264 3751 - brcmf_sdbrcm_sdiod_drive_strength_init(bus, SDIO_DRIVE_STRENGTH); 4265 + brcmf_sdio_chip_drivestrengthinit(bus->sdiodev, bus->ci, 4266 + SDIO_DRIVE_STRENGTH); 3752 4267 3753 - /* Get info on the ARM and SOCRAM cores... */ 3754 - brcmf_sdcard_reg_read(bus->sdiodev, 3755 - CORE_SB(bus->ci->armcorebase, sbidhigh), 4); 4268 + /* Get info on the SOCRAM cores... */ 3756 4269 bus->ramsize = bus->ci->ramsize; 3757 4270 if (!(bus->ramsize)) { 3758 4271 brcmf_dbg(ERROR, "failed to find SOCRAM memory!\n"); ··· 3759 4274 } 3760 4275 3761 4276 /* Set core control so an SDIO reset does a backplane reset */ 3762 - reg_addr = bus->ci->buscorebase + 4277 + idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); 4278 + reg_addr = bus->ci->c_inf[idx].base + 3763 4279 offsetof(struct sdpcmd_regs, corecontrol); 3764 4280 reg_val = brcmf_sdcard_reg_read(bus->sdiodev, reg_addr, sizeof(u32)); 3765 4281 brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, sizeof(u32), ··· 3850 4364 } 3851 4365 } 3852 4366 3853 - static void 3854 - brcmf_sdbrcm_chip_detach(struct brcmf_bus *bus) 3855 - { 3856 - brcmf_dbg(TRACE, "Enter\n"); 3857 - 3858 - kfree(bus->ci); 3859 - bus->ci = NULL; 3860 - } 3861 - 3862 4367 static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) 3863 4368 { 3864 4369 brcmf_dbg(TRACE, "Enter\n"); ··· 3857 4380 if (bus->ci) { 3858 4381 brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); 3859 4382 brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); 3860 - brcmf_sdbrcm_chip_detach(bus); 4383 + brcmf_sdio_chip_detach(&bus->ci); 3861 4384 if (bus->vars && bus->varsz) 3862 4385 kfree(bus->vars); 3863 4386 bus->vars = NULL; ··· 3917 4440 3918 4441 bus->sdiodev = sdiodev; 3919 4442 sdiodev->bus = bus; 4443 + skb_queue_head_init(&bus->glom); 3920 4444 bus->txbound = BRCMF_TXBOUND; 3921 4445 bus->rxbound = BRCMF_RXBOUND; 3922 4446 bus->txminmax = BRCMF_TXMINMAX; ··· 3999 4521 goto fail; 4000 4522 } 4001 4523 } 4002 - /* Ok, have the per-port tell the stack we're open for business */ 4003 - if (brcmf_net_attach(bus->drvr, 0) != 0) { 4004 - brcmf_dbg(ERROR, "Net attach failed!!\n"); 4524 + 4525 + /* add interface and open for business */ 4526 + if (brcmf_add_if((struct brcmf_info *)bus->drvr, 0, "wlan%d", NULL)) { 4527 + brcmf_dbg(ERROR, "Add primary net device interface failed!!\n"); 4005 4528 goto fail; 4006 4529 } 4007 4530 ··· 4033 4554 void 4034 4555 brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) 4035 4556 { 4036 - /* don't start the wd until fw is loaded */ 4037 - if (bus->drvr->busstate == BRCMF_BUS_DOWN) 4038 - return; 4039 - 4040 4557 /* Totally stop the timer */ 4041 4558 if (!wdtick && bus->wd_timer_valid == true) { 4042 4559 del_timer_sync(&bus->timer); ··· 4040 4565 bus->save_ms = wdtick; 4041 4566 return; 4042 4567 } 4568 + 4569 + /* don't start the wd until fw is loaded */ 4570 + if (bus->drvr->busstate == BRCMF_BUS_DOWN) 4571 + return; 4043 4572 4044 4573 if (wdtick) { 4045 4574 if (bus->save_ms != BRCMF_WD_POLL_MS) {
+622
drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c
··· 1 + /* 2 + * Copyright (c) 2011 Broadcom Corporation 3 + * 4 + * Permission to use, copy, modify, and/or distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11 + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13 + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + /* ***** SDIO interface chip backplane handle functions ***** */ 17 + 18 + #include <linux/types.h> 19 + #include <linux/netdevice.h> 20 + #include <linux/mmc/card.h> 21 + #include <linux/ssb/ssb_regs.h> 22 + #include <linux/bcma/bcma.h> 23 + 24 + #include <chipcommon.h> 25 + #include <brcm_hw_ids.h> 26 + #include <brcmu_wifi.h> 27 + #include <brcmu_utils.h> 28 + #include <soc.h> 29 + #include "dhd.h" 30 + #include "dhd_dbg.h" 31 + #include "sdio_host.h" 32 + #include "sdio_chip.h" 33 + 34 + /* chip core base & ramsize */ 35 + /* bcm4329 */ 36 + /* SDIO device core, ID 0x829 */ 37 + #define BCM4329_CORE_BUS_BASE 0x18011000 38 + /* internal memory core, ID 0x80e */ 39 + #define BCM4329_CORE_SOCRAM_BASE 0x18003000 40 + /* ARM Cortex M3 core, ID 0x82a */ 41 + #define BCM4329_CORE_ARM_BASE 0x18002000 42 + #define BCM4329_RAMSIZE 0x48000 43 + 44 + #define SBCOREREV(sbidh) \ 45 + ((((sbidh) & SSB_IDHIGH_RCHI) >> SSB_IDHIGH_RCHI_SHIFT) | \ 46 + ((sbidh) & SSB_IDHIGH_RCLO)) 47 + 48 + /* SOC Interconnect types (aka chip types) */ 49 + #define SOCI_SB 0 50 + #define SOCI_AI 1 51 + 52 + /* EROM CompIdentB */ 53 + #define CIB_REV_MASK 0xff000000 54 + #define CIB_REV_SHIFT 24 55 + 56 + #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu)) 57 + /* SDIO Pad drive strength to select value mappings */ 58 + struct sdiod_drive_str { 59 + u8 strength; /* Pad Drive Strength in mA */ 60 + u8 sel; /* Chip-specific select value */ 61 + }; 62 + /* SDIO Drive Strength to sel value table for PMU Rev 1 */ 63 + static const struct sdiod_drive_str sdiod_drive_strength_tab1[] = { 64 + { 65 + 4, 0x2}, { 66 + 2, 0x3}, { 67 + 1, 0x0}, { 68 + 0, 0x0} 69 + }; 70 + /* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */ 71 + static const struct sdiod_drive_str sdiod_drive_strength_tab2[] = { 72 + { 73 + 12, 0x7}, { 74 + 10, 0x6}, { 75 + 8, 0x5}, { 76 + 6, 0x4}, { 77 + 4, 0x2}, { 78 + 2, 0x1}, { 79 + 0, 0x0} 80 + }; 81 + /* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */ 82 + static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { 83 + { 84 + 32, 0x7}, { 85 + 26, 0x6}, { 86 + 22, 0x5}, { 87 + 16, 0x4}, { 88 + 12, 0x3}, { 89 + 8, 0x2}, { 90 + 4, 0x1}, { 91 + 0, 0x0} 92 + }; 93 + 94 + u8 95 + brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid) 96 + { 97 + u8 idx; 98 + 99 + for (idx = 0; idx < BRCMF_MAX_CORENUM; idx++) 100 + if (coreid == ci->c_inf[idx].id) 101 + return idx; 102 + 103 + return BRCMF_MAX_CORENUM; 104 + } 105 + 106 + static u32 107 + brcmf_sdio_sb_corerev(struct brcmf_sdio_dev *sdiodev, 108 + struct chip_info *ci, u16 coreid) 109 + { 110 + u32 regdata; 111 + u8 idx; 112 + 113 + idx = brcmf_sdio_chip_getinfidx(ci, coreid); 114 + 115 + regdata = brcmf_sdcard_reg_read(sdiodev, 116 + CORE_SB(ci->c_inf[idx].base, sbidhigh), 4); 117 + return SBCOREREV(regdata); 118 + } 119 + 120 + static u32 121 + brcmf_sdio_ai_corerev(struct brcmf_sdio_dev *sdiodev, 122 + struct chip_info *ci, u16 coreid) 123 + { 124 + u8 idx; 125 + 126 + idx = brcmf_sdio_chip_getinfidx(ci, coreid); 127 + 128 + return (ci->c_inf[idx].cib & CIB_REV_MASK) >> CIB_REV_SHIFT; 129 + } 130 + 131 + static bool 132 + brcmf_sdio_sb_iscoreup(struct brcmf_sdio_dev *sdiodev, 133 + struct chip_info *ci, u16 coreid) 134 + { 135 + u32 regdata; 136 + u8 idx; 137 + 138 + idx = brcmf_sdio_chip_getinfidx(ci, coreid); 139 + 140 + regdata = brcmf_sdcard_reg_read(sdiodev, 141 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); 142 + regdata &= (SSB_TMSLOW_RESET | SSB_TMSLOW_REJECT | 143 + SSB_IMSTATE_REJECT | SSB_TMSLOW_CLOCK); 144 + return (SSB_TMSLOW_CLOCK == regdata); 145 + } 146 + 147 + static bool 148 + brcmf_sdio_ai_iscoreup(struct brcmf_sdio_dev *sdiodev, 149 + struct chip_info *ci, u16 coreid) 150 + { 151 + u32 regdata; 152 + u8 idx; 153 + bool ret; 154 + 155 + idx = brcmf_sdio_chip_getinfidx(ci, coreid); 156 + 157 + regdata = brcmf_sdcard_reg_read(sdiodev, 158 + ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); 159 + ret = (regdata & (BCMA_IOCTL_FGC | BCMA_IOCTL_CLK)) == BCMA_IOCTL_CLK; 160 + 161 + regdata = brcmf_sdcard_reg_read(sdiodev, 162 + ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, 163 + 4); 164 + ret = ret && ((regdata & BCMA_RESET_CTL_RESET) == 0); 165 + 166 + return ret; 167 + } 168 + 169 + static void 170 + brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev, 171 + struct chip_info *ci, u16 coreid) 172 + { 173 + u32 regdata; 174 + u8 idx; 175 + 176 + idx = brcmf_sdio_chip_getinfidx(ci, coreid); 177 + 178 + regdata = brcmf_sdcard_reg_read(sdiodev, 179 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); 180 + if (regdata & SSB_TMSLOW_RESET) 181 + return; 182 + 183 + regdata = brcmf_sdcard_reg_read(sdiodev, 184 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); 185 + if ((regdata & SSB_TMSLOW_CLOCK) != 0) { 186 + /* 187 + * set target reject and spin until busy is clear 188 + * (preserve core-specific bits) 189 + */ 190 + regdata = brcmf_sdcard_reg_read(sdiodev, 191 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); 192 + brcmf_sdcard_reg_write(sdiodev, 193 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 194 + 4, regdata | SSB_TMSLOW_REJECT); 195 + 196 + regdata = brcmf_sdcard_reg_read(sdiodev, 197 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); 198 + udelay(1); 199 + SPINWAIT((brcmf_sdcard_reg_read(sdiodev, 200 + CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4) & 201 + SSB_TMSHIGH_BUSY), 100000); 202 + 203 + regdata = brcmf_sdcard_reg_read(sdiodev, 204 + CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4); 205 + if (regdata & SSB_TMSHIGH_BUSY) 206 + brcmf_dbg(ERROR, "core state still busy\n"); 207 + 208 + regdata = brcmf_sdcard_reg_read(sdiodev, 209 + CORE_SB(ci->c_inf[idx].base, sbidlow), 4); 210 + if (regdata & SSB_IDLOW_INITIATOR) { 211 + regdata = brcmf_sdcard_reg_read(sdiodev, 212 + CORE_SB(ci->c_inf[idx].base, sbimstate), 4) | 213 + SSB_IMSTATE_REJECT; 214 + brcmf_sdcard_reg_write(sdiodev, 215 + CORE_SB(ci->c_inf[idx].base, sbimstate), 4, 216 + regdata); 217 + regdata = brcmf_sdcard_reg_read(sdiodev, 218 + CORE_SB(ci->c_inf[idx].base, sbimstate), 4); 219 + udelay(1); 220 + SPINWAIT((brcmf_sdcard_reg_read(sdiodev, 221 + CORE_SB(ci->c_inf[idx].base, sbimstate), 4) & 222 + SSB_IMSTATE_BUSY), 100000); 223 + } 224 + 225 + /* set reset and reject while enabling the clocks */ 226 + brcmf_sdcard_reg_write(sdiodev, 227 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, 228 + (SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | 229 + SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET)); 230 + regdata = brcmf_sdcard_reg_read(sdiodev, 231 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); 232 + udelay(10); 233 + 234 + /* clear the initiator reject bit */ 235 + regdata = brcmf_sdcard_reg_read(sdiodev, 236 + CORE_SB(ci->c_inf[idx].base, sbidlow), 4); 237 + if (regdata & SSB_IDLOW_INITIATOR) { 238 + regdata = brcmf_sdcard_reg_read(sdiodev, 239 + CORE_SB(ci->c_inf[idx].base, sbimstate), 4) & 240 + ~SSB_IMSTATE_REJECT; 241 + brcmf_sdcard_reg_write(sdiodev, 242 + CORE_SB(ci->c_inf[idx].base, sbimstate), 4, 243 + regdata); 244 + } 245 + } 246 + 247 + /* leave reset and reject asserted */ 248 + brcmf_sdcard_reg_write(sdiodev, 249 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, 250 + (SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET)); 251 + udelay(1); 252 + } 253 + 254 + static void 255 + brcmf_sdio_ai_coredisable(struct brcmf_sdio_dev *sdiodev, 256 + struct chip_info *ci, u16 coreid) 257 + { 258 + u8 idx; 259 + u32 regdata; 260 + 261 + idx = brcmf_sdio_chip_getinfidx(ci, coreid); 262 + 263 + /* if core is already in reset, just return */ 264 + regdata = brcmf_sdcard_reg_read(sdiodev, 265 + ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, 266 + 4); 267 + if ((regdata & BCMA_RESET_CTL_RESET) != 0) 268 + return; 269 + 270 + brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 271 + 4, 0); 272 + regdata = brcmf_sdcard_reg_read(sdiodev, 273 + ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); 274 + udelay(10); 275 + 276 + brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, 277 + 4, BCMA_RESET_CTL_RESET); 278 + udelay(1); 279 + } 280 + 281 + static void 282 + brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev, 283 + struct chip_info *ci, u16 coreid) 284 + { 285 + u32 regdata; 286 + u8 idx; 287 + 288 + idx = brcmf_sdio_chip_getinfidx(ci, coreid); 289 + 290 + /* 291 + * Must do the disable sequence first to work for 292 + * arbitrary current core state. 293 + */ 294 + brcmf_sdio_sb_coredisable(sdiodev, ci, coreid); 295 + 296 + /* 297 + * Now do the initialization sequence. 298 + * set reset while enabling the clock and 299 + * forcing them on throughout the core 300 + */ 301 + brcmf_sdcard_reg_write(sdiodev, 302 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, 303 + SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET); 304 + regdata = brcmf_sdcard_reg_read(sdiodev, 305 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); 306 + udelay(1); 307 + 308 + /* clear any serror */ 309 + regdata = brcmf_sdcard_reg_read(sdiodev, 310 + CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4); 311 + if (regdata & SSB_TMSHIGH_SERR) 312 + brcmf_sdcard_reg_write(sdiodev, 313 + CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4, 0); 314 + 315 + regdata = brcmf_sdcard_reg_read(sdiodev, 316 + CORE_SB(ci->c_inf[idx].base, sbimstate), 4); 317 + if (regdata & (SSB_IMSTATE_IBE | SSB_IMSTATE_TO)) 318 + brcmf_sdcard_reg_write(sdiodev, 319 + CORE_SB(ci->c_inf[idx].base, sbimstate), 4, 320 + regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO)); 321 + 322 + /* clear reset and allow it to propagate throughout the core */ 323 + brcmf_sdcard_reg_write(sdiodev, 324 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4, 325 + SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK); 326 + regdata = brcmf_sdcard_reg_read(sdiodev, 327 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); 328 + udelay(1); 329 + 330 + /* leave clock enabled */ 331 + brcmf_sdcard_reg_write(sdiodev, 332 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 333 + 4, SSB_TMSLOW_CLOCK); 334 + regdata = brcmf_sdcard_reg_read(sdiodev, 335 + CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4); 336 + udelay(1); 337 + } 338 + 339 + static void 340 + brcmf_sdio_ai_resetcore(struct brcmf_sdio_dev *sdiodev, 341 + struct chip_info *ci, u16 coreid) 342 + { 343 + u8 idx; 344 + u32 regdata; 345 + 346 + idx = brcmf_sdio_chip_getinfidx(ci, coreid); 347 + 348 + /* must disable first to work for arbitrary current core state */ 349 + brcmf_sdio_ai_coredisable(sdiodev, ci, coreid); 350 + 351 + /* now do initialization sequence */ 352 + brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 353 + 4, BCMA_IOCTL_FGC | BCMA_IOCTL_CLK); 354 + regdata = brcmf_sdcard_reg_read(sdiodev, 355 + ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); 356 + brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL, 357 + 4, 0); 358 + udelay(1); 359 + 360 + brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 361 + 4, BCMA_IOCTL_CLK); 362 + regdata = brcmf_sdcard_reg_read(sdiodev, 363 + ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4); 364 + udelay(1); 365 + } 366 + 367 + static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, 368 + struct chip_info *ci, u32 regs) 369 + { 370 + u32 regdata; 371 + 372 + /* 373 + * Get CC core rev 374 + * Chipid is assume to be at offset 0 from regs arg 375 + * For different chiptypes or old sdio hosts w/o chipcommon, 376 + * other ways of recognition should be added here. 377 + */ 378 + ci->c_inf[0].id = BCMA_CORE_CHIPCOMMON; 379 + ci->c_inf[0].base = regs; 380 + regdata = brcmf_sdcard_reg_read(sdiodev, 381 + CORE_CC_REG(ci->c_inf[0].base, chipid), 4); 382 + ci->chip = regdata & CID_ID_MASK; 383 + ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; 384 + ci->socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT; 385 + 386 + brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); 387 + 388 + /* Address of cores for new chips should be added here */ 389 + switch (ci->chip) { 390 + case BCM4329_CHIP_ID: 391 + ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; 392 + ci->c_inf[1].base = BCM4329_CORE_BUS_BASE; 393 + ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; 394 + ci->c_inf[2].base = BCM4329_CORE_SOCRAM_BASE; 395 + ci->c_inf[3].id = BCMA_CORE_ARM_CM3; 396 + ci->c_inf[3].base = BCM4329_CORE_ARM_BASE; 397 + ci->ramsize = BCM4329_RAMSIZE; 398 + break; 399 + default: 400 + brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); 401 + return -ENODEV; 402 + } 403 + 404 + switch (ci->socitype) { 405 + case SOCI_SB: 406 + ci->iscoreup = brcmf_sdio_sb_iscoreup; 407 + ci->corerev = brcmf_sdio_sb_corerev; 408 + ci->coredisable = brcmf_sdio_sb_coredisable; 409 + ci->resetcore = brcmf_sdio_sb_resetcore; 410 + break; 411 + case SOCI_AI: 412 + ci->iscoreup = brcmf_sdio_ai_iscoreup; 413 + ci->corerev = brcmf_sdio_ai_corerev; 414 + ci->coredisable = brcmf_sdio_ai_coredisable; 415 + ci->resetcore = brcmf_sdio_ai_resetcore; 416 + break; 417 + default: 418 + brcmf_dbg(ERROR, "socitype %u not supported\n", ci->socitype); 419 + return -ENODEV; 420 + } 421 + 422 + return 0; 423 + } 424 + 425 + static int 426 + brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev) 427 + { 428 + int err = 0; 429 + u8 clkval, clkset; 430 + 431 + /* Try forcing SDIO core to do ALPAvail request only */ 432 + clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; 433 + brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, 434 + SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); 435 + if (err) { 436 + brcmf_dbg(ERROR, "error writing for HT off\n"); 437 + return err; 438 + } 439 + 440 + /* If register supported, wait for ALPAvail and then force ALP */ 441 + /* This may take up to 15 milliseconds */ 442 + clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1, 443 + SBSDIO_FUNC1_CHIPCLKCSR, NULL); 444 + 445 + if ((clkval & ~SBSDIO_AVBITS) != clkset) { 446 + brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n", 447 + clkset, clkval); 448 + return -EACCES; 449 + } 450 + 451 + SPINWAIT(((clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1, 452 + SBSDIO_FUNC1_CHIPCLKCSR, NULL)), 453 + !SBSDIO_ALPAV(clkval)), 454 + PMU_MAX_TRANSITION_DLY); 455 + if (!SBSDIO_ALPAV(clkval)) { 456 + brcmf_dbg(ERROR, "timeout on ALPAV wait, clkval 0x%02x\n", 457 + clkval); 458 + return -EBUSY; 459 + } 460 + 461 + clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_FORCE_ALP; 462 + brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, 463 + SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err); 464 + udelay(65); 465 + 466 + /* Also, disable the extra SDIO pull-ups */ 467 + brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, 468 + SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); 469 + 470 + return 0; 471 + } 472 + 473 + static void 474 + brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev, 475 + struct chip_info *ci) 476 + { 477 + /* get chipcommon rev */ 478 + ci->c_inf[0].rev = ci->corerev(sdiodev, ci, ci->c_inf[0].id); 479 + 480 + /* get chipcommon capabilites */ 481 + ci->c_inf[0].caps = 482 + brcmf_sdcard_reg_read(sdiodev, 483 + CORE_CC_REG(ci->c_inf[0].base, capabilities), 4); 484 + 485 + /* get pmu caps & rev */ 486 + if (ci->c_inf[0].caps & CC_CAP_PMU) { 487 + ci->pmucaps = brcmf_sdcard_reg_read(sdiodev, 488 + CORE_CC_REG(ci->c_inf[0].base, pmucapabilities), 4); 489 + ci->pmurev = ci->pmucaps & PCAP_REV_MASK; 490 + } 491 + 492 + ci->c_inf[1].rev = ci->corerev(sdiodev, ci, ci->c_inf[1].id); 493 + 494 + brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", 495 + ci->c_inf[0].rev, ci->pmurev, 496 + ci->c_inf[1].rev, ci->c_inf[1].id); 497 + 498 + /* 499 + * Make sure any on-chip ARM is off (in case strapping is wrong), 500 + * or downloaded code was already running. 501 + */ 502 + ci->coredisable(sdiodev, ci, BCMA_CORE_ARM_CM3); 503 + } 504 + 505 + int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, 506 + struct chip_info **ci_ptr, u32 regs) 507 + { 508 + int ret; 509 + struct chip_info *ci; 510 + 511 + brcmf_dbg(TRACE, "Enter\n"); 512 + 513 + /* alloc chip_info_t */ 514 + ci = kzalloc(sizeof(struct chip_info), GFP_ATOMIC); 515 + if (!ci) 516 + return -ENOMEM; 517 + 518 + ret = brcmf_sdio_chip_buscoreprep(sdiodev); 519 + if (ret != 0) 520 + goto err; 521 + 522 + ret = brcmf_sdio_chip_recognition(sdiodev, ci, regs); 523 + if (ret != 0) 524 + goto err; 525 + 526 + brcmf_sdio_chip_buscoresetup(sdiodev, ci); 527 + 528 + brcmf_sdcard_reg_write(sdiodev, 529 + CORE_CC_REG(ci->c_inf[0].base, gpiopullup), 4, 0); 530 + brcmf_sdcard_reg_write(sdiodev, 531 + CORE_CC_REG(ci->c_inf[0].base, gpiopulldown), 4, 0); 532 + 533 + *ci_ptr = ci; 534 + return 0; 535 + 536 + err: 537 + kfree(ci); 538 + return ret; 539 + } 540 + 541 + void 542 + brcmf_sdio_chip_detach(struct chip_info **ci_ptr) 543 + { 544 + brcmf_dbg(TRACE, "Enter\n"); 545 + 546 + kfree(*ci_ptr); 547 + *ci_ptr = NULL; 548 + } 549 + 550 + static char *brcmf_sdio_chip_name(uint chipid, char *buf, uint len) 551 + { 552 + const char *fmt; 553 + 554 + fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x"; 555 + snprintf(buf, len, fmt, chipid); 556 + return buf; 557 + } 558 + 559 + void 560 + brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, 561 + struct chip_info *ci, u32 drivestrength) 562 + { 563 + struct sdiod_drive_str *str_tab = NULL; 564 + u32 str_mask = 0; 565 + u32 str_shift = 0; 566 + char chn[8]; 567 + 568 + if (!(ci->c_inf[0].caps & CC_CAP_PMU)) 569 + return; 570 + 571 + switch (SDIOD_DRVSTR_KEY(ci->chip, ci->pmurev)) { 572 + case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1): 573 + str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab1; 574 + str_mask = 0x30000000; 575 + str_shift = 28; 576 + break; 577 + case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2): 578 + case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3): 579 + str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab2; 580 + str_mask = 0x00003800; 581 + str_shift = 11; 582 + break; 583 + case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8): 584 + str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab3; 585 + str_mask = 0x00003800; 586 + str_shift = 11; 587 + break; 588 + default: 589 + brcmf_dbg(ERROR, "No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", 590 + brcmf_sdio_chip_name(ci->chip, chn, 8), 591 + ci->chiprev, ci->pmurev); 592 + break; 593 + } 594 + 595 + if (str_tab != NULL) { 596 + u32 drivestrength_sel = 0; 597 + u32 cc_data_temp; 598 + int i; 599 + 600 + for (i = 0; str_tab[i].strength != 0; i++) { 601 + if (drivestrength >= str_tab[i].strength) { 602 + drivestrength_sel = str_tab[i].sel; 603 + break; 604 + } 605 + } 606 + 607 + brcmf_sdcard_reg_write(sdiodev, 608 + CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), 609 + 4, 1); 610 + cc_data_temp = brcmf_sdcard_reg_read(sdiodev, 611 + CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), 4); 612 + cc_data_temp &= ~str_mask; 613 + drivestrength_sel <<= str_shift; 614 + cc_data_temp |= drivestrength_sel; 615 + brcmf_sdcard_reg_write(sdiodev, 616 + CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), 617 + 4, cc_data_temp); 618 + 619 + brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n", 620 + drivestrength, cc_data_temp); 621 + } 622 + }
+136
drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.h
··· 1 + /* 2 + * Copyright (c) 2011 Broadcom Corporation 3 + * 4 + * Permission to use, copy, modify, and/or distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11 + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13 + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + 17 + #ifndef _BRCMFMAC_SDIO_CHIP_H_ 18 + #define _BRCMFMAC_SDIO_CHIP_H_ 19 + 20 + /* 21 + * Core reg address translation. 22 + * Both macro's returns a 32 bits byte address on the backplane bus. 23 + */ 24 + #define CORE_CC_REG(base, field) \ 25 + (base + offsetof(struct chipcregs, field)) 26 + #define CORE_BUS_REG(base, field) \ 27 + (base + offsetof(struct sdpcmd_regs, field)) 28 + #define CORE_SB(base, field) \ 29 + (base + SBCONFIGOFF + offsetof(struct sbconfig, field)) 30 + 31 + /* SDIO function 1 register CHIPCLKCSR */ 32 + /* Force ALP request to backplane */ 33 + #define SBSDIO_FORCE_ALP 0x01 34 + /* Force HT request to backplane */ 35 + #define SBSDIO_FORCE_HT 0x02 36 + /* Force ILP request to backplane */ 37 + #define SBSDIO_FORCE_ILP 0x04 38 + /* Make ALP ready (power up xtal) */ 39 + #define SBSDIO_ALP_AVAIL_REQ 0x08 40 + /* Make HT ready (power up PLL) */ 41 + #define SBSDIO_HT_AVAIL_REQ 0x10 42 + /* Squelch clock requests from HW */ 43 + #define SBSDIO_FORCE_HW_CLKREQ_OFF 0x20 44 + /* Status: ALP is ready */ 45 + #define SBSDIO_ALP_AVAIL 0x40 46 + /* Status: HT is ready */ 47 + #define SBSDIO_HT_AVAIL 0x80 48 + #define SBSDIO_AVBITS (SBSDIO_HT_AVAIL | SBSDIO_ALP_AVAIL) 49 + #define SBSDIO_ALPAV(regval) ((regval) & SBSDIO_AVBITS) 50 + #define SBSDIO_HTAV(regval) (((regval) & SBSDIO_AVBITS) == SBSDIO_AVBITS) 51 + #define SBSDIO_ALPONLY(regval) (SBSDIO_ALPAV(regval) && !SBSDIO_HTAV(regval)) 52 + #define SBSDIO_CLKAV(regval, alponly) \ 53 + (SBSDIO_ALPAV(regval) && (alponly ? 1 : SBSDIO_HTAV(regval))) 54 + 55 + #define BRCMF_MAX_CORENUM 6 56 + 57 + struct chip_core_info { 58 + u16 id; 59 + u16 rev; 60 + u32 base; 61 + u32 wrapbase; 62 + u32 caps; 63 + u32 cib; 64 + }; 65 + 66 + struct chip_info { 67 + u32 chip; 68 + u32 chiprev; 69 + u32 socitype; 70 + /* core info */ 71 + /* always put chipcommon core at 0, bus core at 1 */ 72 + struct chip_core_info c_inf[BRCMF_MAX_CORENUM]; 73 + u32 pmurev; 74 + u32 pmucaps; 75 + u32 ramsize; 76 + 77 + bool (*iscoreup)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, 78 + u16 coreid); 79 + u32 (*corerev)(struct brcmf_sdio_dev *sdiodev, struct chip_info *ci, 80 + u16 coreid); 81 + void (*coredisable)(struct brcmf_sdio_dev *sdiodev, 82 + struct chip_info *ci, u16 coreid); 83 + void (*resetcore)(struct brcmf_sdio_dev *sdiodev, 84 + struct chip_info *ci, u16 coreid); 85 + }; 86 + 87 + struct sbconfig { 88 + u32 PAD[2]; 89 + u32 sbipsflag; /* initiator port ocp slave flag */ 90 + u32 PAD[3]; 91 + u32 sbtpsflag; /* target port ocp slave flag */ 92 + u32 PAD[11]; 93 + u32 sbtmerrloga; /* (sonics >= 2.3) */ 94 + u32 PAD; 95 + u32 sbtmerrlog; /* (sonics >= 2.3) */ 96 + u32 PAD[3]; 97 + u32 sbadmatch3; /* address match3 */ 98 + u32 PAD; 99 + u32 sbadmatch2; /* address match2 */ 100 + u32 PAD; 101 + u32 sbadmatch1; /* address match1 */ 102 + u32 PAD[7]; 103 + u32 sbimstate; /* initiator agent state */ 104 + u32 sbintvec; /* interrupt mask */ 105 + u32 sbtmstatelow; /* target state */ 106 + u32 sbtmstatehigh; /* target state */ 107 + u32 sbbwa0; /* bandwidth allocation table0 */ 108 + u32 PAD; 109 + u32 sbimconfiglow; /* initiator configuration */ 110 + u32 sbimconfighigh; /* initiator configuration */ 111 + u32 sbadmatch0; /* address match0 */ 112 + u32 PAD; 113 + u32 sbtmconfiglow; /* target configuration */ 114 + u32 sbtmconfighigh; /* target configuration */ 115 + u32 sbbconfig; /* broadcast configuration */ 116 + u32 PAD; 117 + u32 sbbstate; /* broadcast state */ 118 + u32 PAD[3]; 119 + u32 sbactcnfg; /* activate configuration */ 120 + u32 PAD[3]; 121 + u32 sbflagst; /* current sbflags */ 122 + u32 PAD[3]; 123 + u32 sbidlow; /* identification */ 124 + u32 sbidhigh; /* identification */ 125 + }; 126 + 127 + extern int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, 128 + struct chip_info **ci_ptr, u32 regs); 129 + extern void brcmf_sdio_chip_detach(struct chip_info **ci_ptr); 130 + extern void brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, 131 + struct chip_info *ci, 132 + u32 drivestrength); 133 + extern u8 brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid); 134 + 135 + 136 + #endif /* _BRCMFMAC_SDIO_CHIP_H_ */
+29 -12
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
··· 1997 1997 } 1998 1998 1999 1999 static s32 brcmf_inform_single_bss(struct brcmf_cfg80211_priv *cfg_priv, 2000 - struct brcmf_bss_info *bi) 2000 + struct brcmf_bss_info_le *bi) 2001 2001 { 2002 2002 struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); 2003 2003 struct ieee80211_channel *notify_channel; ··· 2049 2049 notify_timestamp, notify_capability, notify_interval, notify_ie, 2050 2050 notify_ielen, notify_signal, GFP_KERNEL); 2051 2051 2052 - if (!bss) { 2053 - WL_ERR("cfg80211_inform_bss_frame error\n"); 2054 - return -EINVAL; 2055 - } 2052 + if (!bss) 2053 + return -ENOMEM; 2054 + 2055 + cfg80211_put_bss(bss); 2056 2056 2057 2057 return err; 2058 + } 2059 + 2060 + static struct brcmf_bss_info_le * 2061 + next_bss_le(struct brcmf_scan_results *list, struct brcmf_bss_info_le *bss) 2062 + { 2063 + if (bss == NULL) 2064 + return list->bss_info_le; 2065 + return (struct brcmf_bss_info_le *)((unsigned long)bss + 2066 + le32_to_cpu(bss->length)); 2058 2067 } 2059 2068 2060 2069 static s32 brcmf_inform_bss(struct brcmf_cfg80211_priv *cfg_priv) 2061 2070 { 2062 2071 struct brcmf_scan_results *bss_list; 2063 - struct brcmf_bss_info *bi = NULL; /* must be initialized */ 2072 + struct brcmf_bss_info_le *bi = NULL; /* must be initialized */ 2064 2073 s32 err = 0; 2065 2074 int i; 2066 2075 ··· 2081 2072 } 2082 2073 WL_SCAN("scanned AP count (%d)\n", bss_list->count); 2083 2074 for (i = 0; i < bss_list->count && i < WL_AP_MAX; i++) { 2084 - bi = next_bss(bss_list, bi); 2075 + bi = next_bss_le(bss_list, bi); 2085 2076 err = brcmf_inform_single_bss(cfg_priv, bi); 2086 2077 if (err) 2087 2078 break; ··· 2094 2085 { 2095 2086 struct wiphy *wiphy = cfg_to_wiphy(cfg_priv); 2096 2087 struct ieee80211_channel *notify_channel; 2097 - struct brcmf_bss_info *bi = NULL; 2088 + struct brcmf_bss_info_le *bi = NULL; 2098 2089 struct ieee80211_supported_band *band; 2090 + struct cfg80211_bss *bss; 2099 2091 u8 *buf = NULL; 2100 2092 s32 err = 0; 2101 2093 u16 channel; ··· 2124 2114 goto CleanUp; 2125 2115 } 2126 2116 2127 - bi = (struct brcmf_bss_info *)(buf + 4); 2117 + bi = (struct brcmf_bss_info_le *)(buf + 4); 2128 2118 2129 2119 channel = bi->ctl_ch ? bi->ctl_ch : 2130 2120 CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec)); ··· 2150 2140 WL_CONN("signal: %d\n", notify_signal); 2151 2141 WL_CONN("notify_timestamp: %#018llx\n", notify_timestamp); 2152 2142 2153 - cfg80211_inform_bss(wiphy, notify_channel, bssid, 2143 + bss = cfg80211_inform_bss(wiphy, notify_channel, bssid, 2154 2144 notify_timestamp, notify_capability, notify_interval, 2155 2145 notify_ie, notify_ielen, notify_signal, GFP_KERNEL); 2146 + 2147 + if (!bss) { 2148 + err = -ENOMEM; 2149 + goto CleanUp; 2150 + } 2151 + 2152 + cfg80211_put_bss(bss); 2156 2153 2157 2154 CleanUp: 2158 2155 ··· 2205 2188 2206 2189 static s32 brcmf_update_bss_info(struct brcmf_cfg80211_priv *cfg_priv) 2207 2190 { 2208 - struct brcmf_bss_info *bi; 2191 + struct brcmf_bss_info_le *bi; 2209 2192 struct brcmf_ssid *ssid; 2210 2193 struct brcmf_tlv *tim; 2211 2194 u16 beacon_interval; ··· 2228 2211 goto update_bss_info_out; 2229 2212 } 2230 2213 2231 - bi = (struct brcmf_bss_info *)(cfg_priv->extra_buf + 4); 2214 + bi = (struct brcmf_bss_info_le *)(cfg_priv->extra_buf + 4); 2232 2215 err = brcmf_inform_single_bss(cfg_priv, bi); 2233 2216 if (err) 2234 2217 goto update_bss_info_out;
-9
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h
··· 352 352 return &cfg->conn_info; 353 353 } 354 354 355 - static inline struct brcmf_bss_info *next_bss(struct brcmf_scan_results *list, 356 - struct brcmf_bss_info *bss) 357 - { 358 - return bss = bss ? 359 - (struct brcmf_bss_info *)((unsigned long)bss + 360 - le32_to_cpu(bss->length)) : 361 - list->bss_info; 362 - } 363 - 364 355 extern struct brcmf_cfg80211_dev *brcmf_cfg80211_attach(struct net_device *ndev, 365 356 struct device *busdev, 366 357 void *data);
-76
drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
··· 38 38 /* PCIE Client Mode sb2pcitranslation2 (2 ZettaBytes), high 32 bits */ 39 39 #define SI_PCIE_DMA_H32 0x80000000 40 40 41 - /* core codes */ 42 - #define NODEV_CORE_ID 0x700 /* Invalid coreid */ 43 - #define CC_CORE_ID 0x800 /* chipcommon core */ 44 - #define ILINE20_CORE_ID 0x801 /* iline20 core */ 45 - #define SRAM_CORE_ID 0x802 /* sram core */ 46 - #define SDRAM_CORE_ID 0x803 /* sdram core */ 47 - #define PCI_CORE_ID 0x804 /* pci core */ 48 - #define MIPS_CORE_ID 0x805 /* mips core */ 49 - #define ENET_CORE_ID 0x806 /* enet mac core */ 50 - #define CODEC_CORE_ID 0x807 /* v90 codec core */ 51 - #define USB_CORE_ID 0x808 /* usb 1.1 host/device core */ 52 - #define ADSL_CORE_ID 0x809 /* ADSL core */ 53 - #define ILINE100_CORE_ID 0x80a /* iline100 core */ 54 - #define IPSEC_CORE_ID 0x80b /* ipsec core */ 55 - #define UTOPIA_CORE_ID 0x80c /* utopia core */ 56 - #define PCMCIA_CORE_ID 0x80d /* pcmcia core */ 57 - #define SOCRAM_CORE_ID 0x80e /* internal memory core */ 58 - #define MEMC_CORE_ID 0x80f /* memc sdram core */ 59 - #define OFDM_CORE_ID 0x810 /* OFDM phy core */ 60 - #define EXTIF_CORE_ID 0x811 /* external interface core */ 61 - #define D11_CORE_ID 0x812 /* 802.11 MAC core */ 62 - #define APHY_CORE_ID 0x813 /* 802.11a phy core */ 63 - #define BPHY_CORE_ID 0x814 /* 802.11b phy core */ 64 - #define GPHY_CORE_ID 0x815 /* 802.11g phy core */ 65 - #define MIPS33_CORE_ID 0x816 /* mips3302 core */ 66 - #define USB11H_CORE_ID 0x817 /* usb 1.1 host core */ 67 - #define USB11D_CORE_ID 0x818 /* usb 1.1 device core */ 68 - #define USB20H_CORE_ID 0x819 /* usb 2.0 host core */ 69 - #define USB20D_CORE_ID 0x81a /* usb 2.0 device core */ 70 - #define SDIOH_CORE_ID 0x81b /* sdio host core */ 71 - #define ROBO_CORE_ID 0x81c /* roboswitch core */ 72 - #define ATA100_CORE_ID 0x81d /* parallel ATA core */ 73 - #define SATAXOR_CORE_ID 0x81e /* serial ATA & XOR DMA core */ 74 - #define GIGETH_CORE_ID 0x81f /* gigabit ethernet core */ 75 - #define PCIE_CORE_ID 0x820 /* pci express core */ 76 - #define NPHY_CORE_ID 0x821 /* 802.11n 2x2 phy core */ 77 - #define SRAMC_CORE_ID 0x822 /* SRAM controller core */ 78 - #define MINIMAC_CORE_ID 0x823 /* MINI MAC/phy core */ 79 - #define ARM11_CORE_ID 0x824 /* ARM 1176 core */ 80 - #define ARM7S_CORE_ID 0x825 /* ARM7tdmi-s core */ 81 - #define LPPHY_CORE_ID 0x826 /* 802.11a/b/g phy core */ 82 - #define PMU_CORE_ID 0x827 /* PMU core */ 83 - #define SSNPHY_CORE_ID 0x828 /* 802.11n single-stream phy core */ 84 - #define SDIOD_CORE_ID 0x829 /* SDIO device core */ 85 - #define ARMCM3_CORE_ID 0x82a /* ARM Cortex M3 core */ 86 - #define HTPHY_CORE_ID 0x82b /* 802.11n 4x4 phy core */ 87 - #define MIPS74K_CORE_ID 0x82c /* mips 74k core */ 88 - #define GMAC_CORE_ID 0x82d /* Gigabit MAC core */ 89 - #define DMEMC_CORE_ID 0x82e /* DDR1/2 memory controller core */ 90 - #define PCIERC_CORE_ID 0x82f /* PCIE Root Complex core */ 91 - #define OCP_CORE_ID 0x830 /* OCP2OCP bridge core */ 92 - #define SC_CORE_ID 0x831 /* shared common core */ 93 - #define AHB_CORE_ID 0x832 /* OCP2AHB bridge core */ 94 - #define SPIH_CORE_ID 0x833 /* SPI host core */ 95 - #define I2S_CORE_ID 0x834 /* I2S core */ 96 - #define DMEMS_CORE_ID 0x835 /* SDR/DDR1 memory controller core */ 97 - #define DEF_SHIM_COMP 0x837 /* SHIM component in ubus/6362 */ 98 - #define OOB_ROUTER_CORE_ID 0x367 /* OOB router core ID */ 99 - #define DEF_AI_COMP 0xfff /* Default component, in ai chips it 100 - * maps all unused address ranges 101 - */ 102 - 103 41 /* chipcommon being the first core: */ 104 42 #define SI_CC_IDX 0 105 43 106 44 /* SOC Interconnect types (aka chip types) */ 107 45 #define SOCI_AI 1 108 - 109 - /* Common core control flags */ 110 - #define SICF_BIST_EN 0x8000 111 - #define SICF_PME_EN 0x4000 112 - #define SICF_CORE_BITS 0x3ffc 113 - #define SICF_FGC 0x0002 114 - #define SICF_CLOCK_EN 0x0001 115 - 116 - /* Common core status flags */ 117 - #define SISF_BIST_DONE 0x8000 118 - #define SISF_BIST_ERROR 0x4000 119 - #define SISF_GATED_CLK 0x2000 120 - #define SISF_DMA64 0x1000 121 - #define SISF_CORE_BITS 0x0fff 122 46 123 47 /* A register that is common to all cores to 124 48 * communicate w/PMU regarding clock control.
+2 -4
drivers/net/wireless/brcm80211/brcmsmac/ampdu.c
··· 649 649 len = roundup(len, 4); 650 650 ampdu_len += (len + (ndelim + 1) * AMPDU_DELIMITER_LEN); 651 651 652 - dma_len += (u16) brcmu_pkttotlen(p); 652 + dma_len += (u16) p->len; 653 653 654 654 BCMMSG(wlc->wiphy, "wl%d: ampdu_len %d" 655 655 " seg_cnt %d null delim %d\n", ··· 741 741 if (p) { 742 742 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && 743 743 ((u8) (p->priority) == tid)) { 744 - 745 - plen = brcmu_pkttotlen(p) + 746 - AMPDU_MAX_MPDU_OVERHEAD; 744 + plen = p->len + AMPDU_MAX_MPDU_OVERHEAD; 747 745 plen = max(scb_ampdu->min_len, plen); 748 746 749 747 if ((plen + ampdu_len) > max_ampdu_bytes) {
-118
drivers/net/wireless/brcm80211/brcmsmac/channel.c
··· 1153 1153 &txpwr); 1154 1154 } 1155 1155 1156 - #ifdef POWER_DBG 1157 - static void wlc_phy_txpower_limits_dump(struct txpwr_limits *txpwr) 1158 - { 1159 - int i; 1160 - char buf[80]; 1161 - char fraction[4][4] = { " ", ".25", ".5 ", ".75" }; 1162 - 1163 - sprintf(buf, "CCK "); 1164 - for (i = 0; i < BRCMS_NUM_RATES_CCK; i++) 1165 - sprintf(buf[strlen(buf)], " %2d%s", 1166 - txpwr->cck[i] / BRCMS_TXPWR_DB_FACTOR, 1167 - fraction[txpwr->cck[i] % BRCMS_TXPWR_DB_FACTOR]); 1168 - printk(KERN_DEBUG "%s\n", buf); 1169 - 1170 - sprintf(buf, "20 MHz OFDM SISO "); 1171 - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) 1172 - sprintf(buf[strlen(buf)], " %2d%s", 1173 - txpwr->ofdm[i] / BRCMS_TXPWR_DB_FACTOR, 1174 - fraction[txpwr->ofdm[i] % BRCMS_TXPWR_DB_FACTOR]); 1175 - printk(KERN_DEBUG "%s\n", buf); 1176 - 1177 - sprintf(buf, "20 MHz OFDM CDD "); 1178 - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) 1179 - sprintf(buf[strlen(buf)], " %2d%s", 1180 - txpwr->ofdm_cdd[i] / BRCMS_TXPWR_DB_FACTOR, 1181 - fraction[txpwr->ofdm_cdd[i] % BRCMS_TXPWR_DB_FACTOR]); 1182 - printk(KERN_DEBUG "%s\n", buf); 1183 - 1184 - sprintf(buf, "40 MHz OFDM SISO "); 1185 - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) 1186 - sprintf(buf[strlen(buf)], " %2d%s", 1187 - txpwr->ofdm_40_siso[i] / BRCMS_TXPWR_DB_FACTOR, 1188 - fraction[txpwr->ofdm_40_siso[i] % 1189 - BRCMS_TXPWR_DB_FACTOR]); 1190 - printk(KERN_DEBUG "%s\n", buf); 1191 - 1192 - sprintf(buf, "40 MHz OFDM CDD "); 1193 - for (i = 0; i < BRCMS_NUM_RATES_OFDM; i++) 1194 - sprintf(buf[strlen(buf)], " %2d%s", 1195 - txpwr->ofdm_40_cdd[i] / BRCMS_TXPWR_DB_FACTOR, 1196 - fraction[txpwr->ofdm_40_cdd[i] % 1197 - BRCMS_TXPWR_DB_FACTOR]); 1198 - printk(KERN_DEBUG "%s\n", buf); 1199 - 1200 - sprintf(buf, "20 MHz MCS0-7 SISO "); 1201 - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) 1202 - sprintf(buf[strlen(buf)], " %2d%s", 1203 - txpwr->mcs_20_siso[i] / BRCMS_TXPWR_DB_FACTOR, 1204 - fraction[txpwr->mcs_20_siso[i] % 1205 - BRCMS_TXPWR_DB_FACTOR]); 1206 - printk(KERN_DEBUG "%s\n", buf); 1207 - 1208 - sprintf(buf, "20 MHz MCS0-7 CDD "); 1209 - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) 1210 - sprintf(buf[strlen(buf)], " %2d%s", 1211 - txpwr->mcs_20_cdd[i] / BRCMS_TXPWR_DB_FACTOR, 1212 - fraction[txpwr->mcs_20_cdd[i] % 1213 - BRCMS_TXPWR_DB_FACTOR]); 1214 - printk(KERN_DEBUG "%s\n", buf); 1215 - 1216 - sprintf(buf, "20 MHz MCS0-7 STBC "); 1217 - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) 1218 - sprintf(buf[strlen(buf)], " %2d%s", 1219 - txpwr->mcs_20_stbc[i] / BRCMS_TXPWR_DB_FACTOR, 1220 - fraction[txpwr->mcs_20_stbc[i] % 1221 - BRCMS_TXPWR_DB_FACTOR]); 1222 - printk(KERN_DEBUG "%s\n", buf); 1223 - 1224 - sprintf(buf, "20 MHz MCS8-15 SDM "); 1225 - for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) 1226 - sprintf(buf[strlen(buf)], " %2d%s", 1227 - txpwr->mcs_20_mimo[i] / BRCMS_TXPWR_DB_FACTOR, 1228 - fraction[txpwr->mcs_20_mimo[i] % 1229 - BRCMS_TXPWR_DB_FACTOR]); 1230 - printk(KERN_DEBUG "%s\n", buf); 1231 - 1232 - sprintf(buf, "40 MHz MCS0-7 SISO "); 1233 - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) 1234 - sprintf(buf[strlen(buf)], " %2d%s", 1235 - txpwr->mcs_40_siso[i] / BRCMS_TXPWR_DB_FACTOR, 1236 - fraction[txpwr->mcs_40_siso[i] % 1237 - BRCMS_TXPWR_DB_FACTOR]); 1238 - printk(KERN_DEBUG "%s\n", buf); 1239 - 1240 - sprintf(buf, "40 MHz MCS0-7 CDD "); 1241 - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) 1242 - sprintf(buf[strlen(buf)], " %2d%s", 1243 - txpwr->mcs_40_cdd[i] / BRCMS_TXPWR_DB_FACTOR, 1244 - fraction[txpwr->mcs_40_cdd[i] % 1245 - BRCMS_TXPWR_DB_FACTOR]); 1246 - printk(KERN_DEBUG "%s\n", buf); 1247 - 1248 - sprintf(buf, "40 MHz MCS0-7 STBC "); 1249 - for (i = 0; i < BRCMS_NUM_RATES_MCS_1_STREAM; i++) 1250 - sprintf(buf[strlen(buf)], " %2d%s", 1251 - txpwr->mcs_40_stbc[i] / BRCMS_TXPWR_DB_FACTOR, 1252 - fraction[txpwr->mcs_40_stbc[i] % 1253 - BRCMS_TXPWR_DB_FACTOR]); 1254 - printk(KERN_DEBUG "%s\n", buf); 1255 - 1256 - sprintf(buf, "40 MHz MCS8-15 SDM "); 1257 - for (i = 0; i < BRCMS_NUM_RATES_MCS_2_STREAM; i++) 1258 - sprintf(buf[strlen(buf)], " %2d%s", 1259 - txpwr->mcs_40_mimo[i] / BRCMS_TXPWR_DB_FACTOR, 1260 - fraction[txpwr->mcs_40_mimo[i] % 1261 - BRCMS_TXPWR_DB_FACTOR]); 1262 - } 1263 - printk(KERN_DEBUG "%s\n", buf); 1264 - 1265 - printk(KERN_DEBUG "MCS32 %2d%s\n", 1266 - txpwr->mcs32 / BRCMS_TXPWR_DB_FACTOR, 1267 - fraction[txpwr->mcs32 % BRCMS_TXPWR_DB_FACTOR]); 1268 - } 1269 - #endif /* POWER_DBG */ 1270 - 1271 1156 void 1272 1157 brcms_c_channel_reg_limits(struct brcms_cm_info *wlc_cm, u16 chanspec, 1273 1158 struct txpwr_limits *txpwr) ··· 1363 1478 txpwr->mcs_40_stbc[i] = txpwr->mcs_40_cdd[i]; 1364 1479 } 1365 1480 1366 - #ifdef POWER_DBG 1367 - wlc_phy_txpower_limits_dump(txpwr); 1368 - #endif 1369 1481 return; 1370 1482 } 1371 1483
+26 -18
drivers/net/wireless/brcm80211/brcmsmac/dma.c
··· 14 14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 15 */ 16 16 #include <linux/slab.h> 17 - #include <linux/skbuff.h> 18 17 #include <linux/delay.h> 19 18 #include <linux/pci.h> 20 19 ··· 21 22 #include <aiutils.h> 22 23 #include "types.h" 23 24 #include "dma.h" 25 + #include "soc.h" 24 26 25 27 /* 26 28 * DMA hardware requires each descriptor ring to be 8kB aligned, and fit within ··· 358 358 359 359 static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) 360 360 { 361 - uint dmactrlflags = di->dma.dmactrlflags; 361 + uint dmactrlflags; 362 362 363 363 if (di == NULL) { 364 - DMA_ERROR(("%s: _dma_ctrlflags: NULL dma handle\n", di->name)); 364 + DMA_ERROR(("_dma_ctrlflags: NULL dma handle\n")); 365 365 return 0; 366 366 } 367 367 368 + dmactrlflags = di->dma.dmactrlflags; 368 369 dmactrlflags &= ~mask; 369 370 dmactrlflags |= flags; 370 371 ··· 901 900 902 901 /* 903 902 * !! rx entry routine 904 - * returns a pointer to the next frame received, or NULL if there are no more 903 + * returns the number packages in the next frame, or 0 if there are no more 905 904 * if DMA_CTRL_RXMULTI is defined, DMA scattering(multiple buffers) is 906 905 * supported with pkts chain 907 906 * otherwise, it's treated as giant pkt and will be tossed. ··· 909 908 * buffer data. After it reaches the max size of buffer, the data continues 910 909 * in next DMA descriptor buffer WITHOUT DMA header 911 910 */ 912 - struct sk_buff *dma_rx(struct dma_pub *pub) 911 + int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list) 913 912 { 914 913 struct dma_info *di = (struct dma_info *)pub; 915 - struct sk_buff *p, *head, *tail; 914 + struct sk_buff_head dma_frames; 915 + struct sk_buff *p, *next; 916 916 uint len; 917 917 uint pkt_len; 918 918 int resid = 0; 919 + int pktcnt = 1; 919 920 921 + skb_queue_head_init(&dma_frames); 920 922 next_frame: 921 - head = _dma_getnextrxp(di, false); 922 - if (head == NULL) 923 - return NULL; 923 + p = _dma_getnextrxp(di, false); 924 + if (p == NULL) 925 + return 0; 924 926 925 - len = le16_to_cpu(*(__le16 *) (head->data)); 927 + len = le16_to_cpu(*(__le16 *) (p->data)); 926 928 DMA_TRACE(("%s: dma_rx len %d\n", di->name, len)); 927 - dma_spin_for_len(len, head); 929 + dma_spin_for_len(len, p); 928 930 929 931 /* set actual length */ 930 932 pkt_len = min((di->rxoffset + len), di->rxbufsize); 931 - __skb_trim(head, pkt_len); 933 + __skb_trim(p, pkt_len); 934 + skb_queue_tail(&dma_frames, p); 932 935 resid = len - (di->rxbufsize - di->rxoffset); 933 936 934 937 /* check for single or multi-buffer rx */ 935 938 if (resid > 0) { 936 - tail = head; 937 939 while ((resid > 0) && (p = _dma_getnextrxp(di, false))) { 938 - tail->next = p; 939 940 pkt_len = min_t(uint, resid, di->rxbufsize); 940 941 __skb_trim(p, pkt_len); 941 - 942 - tail = p; 942 + skb_queue_tail(&dma_frames, p); 943 943 resid -= di->rxbufsize; 944 + pktcnt++; 944 945 } 945 946 946 947 #ifdef BCMDBG ··· 961 958 if ((di->dma.dmactrlflags & DMA_CTRL_RXMULTI) == 0) { 962 959 DMA_ERROR(("%s: dma_rx: bad frame length (%d)\n", 963 960 di->name, len)); 964 - brcmu_pkt_buf_free_skb(head); 961 + skb_queue_walk_safe(&dma_frames, p, next) { 962 + skb_unlink(p, &dma_frames); 963 + brcmu_pkt_buf_free_skb(p); 964 + } 965 965 di->dma.rxgiants++; 966 + pktcnt = 1; 966 967 goto next_frame; 967 968 } 968 969 } 969 970 970 - return head; 971 + skb_queue_splice_tail(&dma_frames, skb_list); 972 + return pktcnt; 971 973 } 972 974 973 975 static bool dma64_rxidle(struct dma_info *di)
+2 -1
drivers/net/wireless/brcm80211/brcmsmac/dma.h
··· 18 18 #define _BRCM_DMA_H_ 19 19 20 20 #include <linux/delay.h> 21 + #include <linux/skbuff.h> 21 22 #include "types.h" /* forward structure declarations */ 22 23 23 24 /* map/unmap direction */ ··· 81 80 uint nrxpost, uint rxoffset, uint *msg_level); 82 81 83 82 void dma_rxinit(struct dma_pub *pub); 84 - struct sk_buff *dma_rx(struct dma_pub *pub); 83 + int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list); 85 84 bool dma_rxfill(struct dma_pub *pub); 86 85 bool dma_rxreset(struct dma_pub *pub); 87 86 bool dma_txreset(struct dma_pub *pub);
+58 -69
drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
··· 216 216 .ht_cap = { 217 217 /* from include/linux/ieee80211.h */ 218 218 .cap = IEEE80211_HT_CAP_GRN_FLD | 219 - IEEE80211_HT_CAP_SGI_20 | 220 - IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, 219 + IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40, 221 220 .ht_supported = true, 222 221 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, 223 222 .ampdu_density = AMPDU_DEF_MPDU_DENSITY, ··· 237 238 BRCMS_LEGACY_5G_RATE_OFFSET, 238 239 .ht_cap = { 239 240 .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | 240 - IEEE80211_HT_CAP_SGI_40 | 241 - IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ 241 + IEEE80211_HT_CAP_SGI_40, 242 242 .ht_supported = true, 243 243 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, 244 244 .ampdu_density = AMPDU_DEF_MPDU_DENSITY, ··· 285 287 { 286 288 struct brcms_info *wl = hw->priv; 287 289 bool blocked; 290 + int err; 288 291 289 292 ieee80211_wake_queues(hw); 290 293 spin_lock_bh(&wl->lock); ··· 294 295 if (!blocked) 295 296 wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); 296 297 297 - return 0; 298 - } 299 - 300 - static void brcms_ops_stop(struct ieee80211_hw *hw) 301 - { 302 - ieee80211_stop_queues(hw); 303 - } 304 - 305 - static int 306 - brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 307 - { 308 - struct brcms_info *wl; 309 - int err; 310 - 311 - /* Just STA for now */ 312 - if (vif->type != NL80211_IFTYPE_AP && 313 - vif->type != NL80211_IFTYPE_MESH_POINT && 314 - vif->type != NL80211_IFTYPE_STATION && 315 - vif->type != NL80211_IFTYPE_WDS && 316 - vif->type != NL80211_IFTYPE_ADHOC) { 317 - wiphy_err(hw->wiphy, "%s: Attempt to add type %d, only" 318 - " STA for now\n", __func__, vif->type); 319 - return -EOPNOTSUPP; 320 - } 321 - 322 - wl = hw->priv; 323 298 spin_lock_bh(&wl->lock); 299 + /* avoid acknowledging frames before a non-monitor device is added */ 300 + wl->mute_tx = true; 301 + 324 302 if (!wl->pub->up) 325 303 err = brcms_up(wl); 326 304 else ··· 307 331 if (err != 0) 308 332 wiphy_err(hw->wiphy, "%s: brcms_up() returned %d\n", __func__, 309 333 err); 310 - 311 334 return err; 312 335 } 313 336 314 - static void 315 - brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 337 + static void brcms_ops_stop(struct ieee80211_hw *hw) 316 338 { 317 - struct brcms_info *wl; 339 + struct brcms_info *wl = hw->priv; 340 + int status; 318 341 319 - wl = hw->priv; 342 + ieee80211_stop_queues(hw); 343 + 344 + if (wl->wlc == NULL) 345 + return; 346 + 347 + spin_lock_bh(&wl->lock); 348 + status = brcms_c_chipmatch(wl->wlc->hw->vendorid, 349 + wl->wlc->hw->deviceid); 350 + spin_unlock_bh(&wl->lock); 351 + if (!status) { 352 + wiphy_err(wl->wiphy, 353 + "wl: brcms_ops_stop: chipmatch failed\n"); 354 + return; 355 + } 320 356 321 357 /* put driver in down state */ 322 358 spin_lock_bh(&wl->lock); 323 359 brcms_down(wl); 324 360 spin_unlock_bh(&wl->lock); 361 + } 362 + 363 + static int 364 + brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 365 + { 366 + struct brcms_info *wl = hw->priv; 367 + 368 + /* Just STA for now */ 369 + if (vif->type != NL80211_IFTYPE_STATION) { 370 + wiphy_err(hw->wiphy, "%s: Attempt to add type %d, only" 371 + " STA for now\n", __func__, vif->type); 372 + return -EOPNOTSUPP; 373 + } 374 + 375 + wl->mute_tx = false; 376 + brcms_c_mute(wl->wlc, false); 377 + 378 + return 0; 379 + } 380 + 381 + static void 382 + brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) 383 + { 325 384 } 326 385 327 386 static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) ··· 620 609 wl->pub->global_ampdu->scb = scb; 621 610 wl->pub->global_ampdu->max_pdu = 16; 622 611 623 - sta->ht_cap.ht_supported = true; 624 - sta->ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; 625 - sta->ht_cap.ampdu_density = AMPDU_DEF_MPDU_DENSITY; 626 - sta->ht_cap.cap = IEEE80211_HT_CAP_GRN_FLD | 627 - IEEE80211_HT_CAP_SGI_20 | 628 - IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT; 629 - 630 612 /* 631 613 * minstrel_ht initiates addBA on our behalf by calling 632 614 * ieee80211_start_tx_ba_session() ··· 881 877 } 882 878 883 879 /* 884 - * called from both kernel as from this kernel module. 880 + * called from both kernel as from this kernel module (error flow on attach) 885 881 * precondition: perimeter lock is not acquired. 886 882 */ 887 883 static void brcms_remove(struct pci_dev *pdev) 888 884 { 889 - struct brcms_info *wl; 890 - struct ieee80211_hw *hw; 891 - int status; 885 + struct ieee80211_hw *hw = pci_get_drvdata(pdev); 886 + struct brcms_info *wl = hw->priv; 892 887 893 - hw = pci_get_drvdata(pdev); 894 - wl = hw->priv; 895 - if (!wl) { 896 - pr_err("wl: brcms_remove: pci_get_drvdata failed\n"); 897 - return; 898 - } 899 - 900 - spin_lock_bh(&wl->lock); 901 - status = brcms_c_chipmatch(pdev->vendor, pdev->device); 902 - spin_unlock_bh(&wl->lock); 903 - if (!status) { 904 - wiphy_err(wl->wiphy, "wl: brcms_remove: chipmatch " 905 - "failed\n"); 906 - return; 907 - } 908 888 if (wl->wlc) { 909 889 wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false); 910 890 wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); 911 891 ieee80211_unregister_hw(hw); 912 - spin_lock_bh(&wl->lock); 913 - brcms_down(wl); 914 - spin_unlock_bh(&wl->lock); 915 892 } 916 893 pci_disable_device(pdev); 917 894 ··· 1065 1080 wl->pub = brcms_c_pub(wl->wlc); 1066 1081 1067 1082 wl->pub->ieee_hw = hw; 1068 - 1069 - /* disable mpc */ 1070 - brcms_c_set_radio_mpc(wl->wlc, false); 1071 1083 1072 1084 /* register our interrupt handler */ 1073 1085 if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { ··· 1301 1319 { 1302 1320 BCMMSG(wl->pub->ieee_hw->wiphy, "wl%d\n", wl->pub->unit); 1303 1321 brcms_reset(wl); 1304 - 1305 - brcms_c_init(wl->wlc); 1322 + brcms_c_init(wl->wlc, wl->mute_tx); 1306 1323 } 1307 1324 1308 1325 /* ··· 1316 1335 wl->resched = 0; 1317 1336 1318 1337 return 0; 1338 + } 1339 + 1340 + void brcms_fatal_error(struct brcms_info *wl) 1341 + { 1342 + wiphy_err(wl->wlc->wiphy, "wl%d: fatal error, reinitializing\n", 1343 + wl->wlc->pub->unit); 1344 + brcms_reset(wl); 1345 + ieee80211_restart_hw(wl->pub->ieee_hw); 1319 1346 } 1320 1347 1321 1348 /*
+2
drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
··· 80 80 struct brcms_firmware fw; 81 81 struct wiphy *wiphy; 82 82 struct brcms_ucode ucode; 83 + bool mute_tx; 83 84 }; 84 85 85 86 /* misc callbacks */ ··· 105 104 extern void brcms_msleep(struct brcms_info *wl, uint ms); 106 105 extern void brcms_dpc(unsigned long data); 107 106 extern void brcms_timer(struct brcms_timer *t); 107 + extern void brcms_fatal_error(struct brcms_info *wl); 108 108 109 109 #endif /* _BRCM_MAC80211_IF_H_ */
+224 -451
drivers/net/wireless/brcm80211/brcmsmac/main.c
··· 30 30 #include "mac80211_if.h" 31 31 #include "ucode_loader.h" 32 32 #include "main.h" 33 + #include "soc.h" 33 34 34 35 /* 35 36 * Indication for txflowcontrol that all priority bits in 36 37 * TXQ_STOP_FOR_PRIOFC_MASK are to be considered. 37 38 */ 38 - #define ALLPRIO -1 39 - 40 - /* 41 - * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. 42 - */ 43 - #define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) 39 + #define ALLPRIO -1 44 40 45 41 /* watchdog timer, in unit of ms */ 46 - #define TIMER_INTERVAL_WATCHDOG 1000 42 + #define TIMER_INTERVAL_WATCHDOG 1000 47 43 /* radio monitor timer, in unit of ms */ 48 - #define TIMER_INTERVAL_RADIOCHK 800 49 - 50 - /* Max MPC timeout, in unit of watchdog */ 51 - #ifndef BRCMS_MPC_MAX_DELAYCNT 52 - #define BRCMS_MPC_MAX_DELAYCNT 10 53 - #endif 54 - 55 - /* Min MPC timeout, in unit of watchdog */ 56 - #define BRCMS_MPC_MIN_DELAYCNT 1 57 - #define BRCMS_MPC_THRESHOLD 3 /* MPC count threshold level */ 44 + #define TIMER_INTERVAL_RADIOCHK 800 58 45 59 46 /* beacon interval, in unit of 1024TU */ 60 - #define BEACON_INTERVAL_DEFAULT 100 61 - /* DTIM interval, in unit of beacon interval */ 62 - #define DTIM_INTERVAL_DEFAULT 3 63 - 64 - /* Scale down delays to accommodate QT slow speed */ 65 - /* beacon interval, in unit of 1024TU */ 66 - #define BEACON_INTERVAL_DEF_QT 20 67 - /* DTIM interval, in unit of beacon interval */ 68 - #define DTIM_INTERVAL_DEF_QT 1 69 - 70 - #define TBTT_ALIGN_LEEWAY_US 100 /* min leeway before first TBTT in us */ 47 + #define BEACON_INTERVAL_DEFAULT 100 71 48 72 49 /* n-mode support capability */ 73 50 /* 2x2 includes both 1x1 & 2x2 devices ··· 55 78 #define WL_11N_3x3 3 56 79 #define WL_11N_4x4 4 57 80 58 - /* define 11n feature disable flags */ 59 - #define WLFEATURE_DISABLE_11N 0x00000001 60 - #define WLFEATURE_DISABLE_11N_STBC_TX 0x00000002 61 - #define WLFEATURE_DISABLE_11N_STBC_RX 0x00000004 62 - #define WLFEATURE_DISABLE_11N_SGI_TX 0x00000008 63 - #define WLFEATURE_DISABLE_11N_SGI_RX 0x00000010 64 - #define WLFEATURE_DISABLE_11N_AMPDU_TX 0x00000020 65 - #define WLFEATURE_DISABLE_11N_AMPDU_RX 0x00000040 66 - #define WLFEATURE_DISABLE_11N_GF 0x00000080 81 + #define EDCF_ACI_MASK 0x60 82 + #define EDCF_ACI_SHIFT 5 83 + #define EDCF_ECWMIN_MASK 0x0f 84 + #define EDCF_ECWMAX_SHIFT 4 85 + #define EDCF_AIFSN_MASK 0x0f 86 + #define EDCF_AIFSN_MAX 15 87 + #define EDCF_ECWMAX_MASK 0xf0 67 88 68 - #define EDCF_ACI_MASK 0x60 69 - #define EDCF_ACI_SHIFT 5 70 - #define EDCF_ECWMIN_MASK 0x0f 71 - #define EDCF_ECWMAX_SHIFT 4 72 - #define EDCF_AIFSN_MASK 0x0f 73 - #define EDCF_AIFSN_MAX 15 74 - #define EDCF_ECWMAX_MASK 0xf0 89 + #define EDCF_AC_BE_TXOP_STA 0x0000 90 + #define EDCF_AC_BK_TXOP_STA 0x0000 91 + #define EDCF_AC_VO_ACI_STA 0x62 92 + #define EDCF_AC_VO_ECW_STA 0x32 93 + #define EDCF_AC_VI_ACI_STA 0x42 94 + #define EDCF_AC_VI_ECW_STA 0x43 95 + #define EDCF_AC_BK_ECW_STA 0xA4 96 + #define EDCF_AC_VI_TXOP_STA 0x005e 97 + #define EDCF_AC_VO_TXOP_STA 0x002f 98 + #define EDCF_AC_BE_ACI_STA 0x03 99 + #define EDCF_AC_BE_ECW_STA 0xA4 100 + #define EDCF_AC_BK_ACI_STA 0x27 101 + #define EDCF_AC_VO_TXOP_AP 0x002f 75 102 76 - #define EDCF_AC_BE_TXOP_STA 0x0000 77 - #define EDCF_AC_BK_TXOP_STA 0x0000 78 - #define EDCF_AC_VO_ACI_STA 0x62 79 - #define EDCF_AC_VO_ECW_STA 0x32 80 - #define EDCF_AC_VI_ACI_STA 0x42 81 - #define EDCF_AC_VI_ECW_STA 0x43 82 - #define EDCF_AC_BK_ECW_STA 0xA4 83 - #define EDCF_AC_VI_TXOP_STA 0x005e 84 - #define EDCF_AC_VO_TXOP_STA 0x002f 85 - #define EDCF_AC_BE_ACI_STA 0x03 86 - #define EDCF_AC_BE_ECW_STA 0xA4 87 - #define EDCF_AC_BK_ACI_STA 0x27 88 - #define EDCF_AC_VO_TXOP_AP 0x002f 103 + #define EDCF_TXOP2USEC(txop) ((txop) << 5) 104 + #define EDCF_ECW2CW(exp) ((1 << (exp)) - 1) 89 105 90 - #define EDCF_TXOP2USEC(txop) ((txop) << 5) 91 - #define EDCF_ECW2CW(exp) ((1 << (exp)) - 1) 106 + #define APHY_SYMBOL_TIME 4 107 + #define APHY_PREAMBLE_TIME 16 108 + #define APHY_SIGNAL_TIME 4 109 + #define APHY_SIFS_TIME 16 110 + #define APHY_SERVICE_NBITS 16 111 + #define APHY_TAIL_NBITS 6 112 + #define BPHY_SIFS_TIME 10 113 + #define BPHY_PLCP_SHORT_TIME 96 92 114 93 - #define APHY_SYMBOL_TIME 4 94 - #define APHY_PREAMBLE_TIME 16 95 - #define APHY_SIGNAL_TIME 4 96 - #define APHY_SIFS_TIME 16 97 - #define APHY_SERVICE_NBITS 16 98 - #define APHY_TAIL_NBITS 6 99 - #define BPHY_SIFS_TIME 10 100 - #define BPHY_PLCP_SHORT_TIME 96 101 - 102 - #define PREN_PREAMBLE 24 103 - #define PREN_MM_EXT 12 104 - #define PREN_PREAMBLE_EXT 4 115 + #define PREN_PREAMBLE 24 116 + #define PREN_MM_EXT 12 117 + #define PREN_PREAMBLE_EXT 4 105 118 106 119 #define DOT11_MAC_HDR_LEN 24 107 - #define DOT11_ACK_LEN 10 108 - #define DOT11_BA_LEN 4 120 + #define DOT11_ACK_LEN 10 121 + #define DOT11_BA_LEN 4 109 122 #define DOT11_OFDM_SIGNAL_EXTENSION 6 110 123 #define DOT11_MIN_FRAG_LEN 256 111 - #define DOT11_RTS_LEN 16 112 - #define DOT11_CTS_LEN 10 124 + #define DOT11_RTS_LEN 16 125 + #define DOT11_CTS_LEN 10 113 126 #define DOT11_BA_BITMAP_LEN 128 114 127 #define DOT11_MIN_BEACON_PERIOD 1 115 128 #define DOT11_MAX_BEACON_PERIOD 0xFFFF 116 - #define DOT11_MAXNUMFRAGS 16 129 + #define DOT11_MAXNUMFRAGS 16 117 130 #define DOT11_MAX_FRAG_LEN 2346 118 131 119 - #define BPHY_PLCP_TIME 192 120 - #define RIFS_11N_TIME 2 132 + #define BPHY_PLCP_TIME 192 133 + #define RIFS_11N_TIME 2 121 134 122 - #define WME_VER 1 123 - #define WME_SUBTYPE_PARAM_IE 1 124 - #define WME_TYPE 2 125 - #define WME_OUI "\x00\x50\xf2" 126 - 127 - #define AC_BE 0 128 - #define AC_BK 1 129 - #define AC_VI 2 130 - #define AC_VO 3 131 - 132 - #define BCN_TMPL_LEN 512 /* length of the BCN template area */ 135 + /* length of the BCN template area */ 136 + #define BCN_TMPL_LEN 512 133 137 134 138 /* brcms_bss_info flag bit values */ 135 - #define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */ 139 + #define BRCMS_BSS_HT 0x0020 /* BSS is HT (MIMO) capable */ 136 140 137 - /* Flags used in brcms_c_txq_info.stopped */ 138 - /* per prio flow control bits */ 139 - #define TXQ_STOP_FOR_PRIOFC_MASK 0x000000FF 140 - /* stop txq enqueue for packet drain */ 141 - #define TXQ_STOP_FOR_PKT_DRAIN 0x00000100 142 - /* stop txq enqueue for ampdu flow control */ 143 - #define TXQ_STOP_FOR_AMPDU_FLOW_CNTRL 0x00000200 144 - 145 - #define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ 146 - 147 - /* Find basic rate for a given rate */ 148 - static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) 149 - { 150 - if (is_mcs_rate(rspec)) 151 - return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] 152 - .leg_ofdm]; 153 - return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; 154 - } 155 - 156 - static u16 frametype(u32 rspec, u8 mimoframe) 157 - { 158 - if (is_mcs_rate(rspec)) 159 - return mimoframe; 160 - return is_cck_rate(rspec) ? FT_CCK : FT_OFDM; 161 - } 141 + /* chip rx buffer offset */ 142 + #define BRCMS_HWRXOFF 38 162 143 163 144 /* rfdisable delay timer 500 ms, runs of ALP clock */ 164 - #define RFDISABLE_DEFAULT 10000000 145 + #define RFDISABLE_DEFAULT 10000000 165 146 166 147 #define BRCMS_TEMPSENSE_PERIOD 10 /* 10 second timeout */ 167 148 ··· 129 194 * These constants are used ONLY by wlc_prio2prec_map. Do not use them 130 195 * elsewhere. 131 196 */ 132 - #define _BRCMS_PREC_NONE 0 /* None = - */ 133 - #define _BRCMS_PREC_BK 2 /* BK - Background */ 134 - #define _BRCMS_PREC_BE 4 /* BE - Best-effort */ 135 - #define _BRCMS_PREC_EE 6 /* EE - Excellent-effort */ 136 - #define _BRCMS_PREC_CL 8 /* CL - Controlled Load */ 137 - #define _BRCMS_PREC_VI 10 /* Vi - Video */ 138 - #define _BRCMS_PREC_VO 12 /* Vo - Voice */ 139 - #define _BRCMS_PREC_NC 14 /* NC - Network Control */ 197 + #define _BRCMS_PREC_NONE 0 /* None = - */ 198 + #define _BRCMS_PREC_BK 2 /* BK - Background */ 199 + #define _BRCMS_PREC_BE 4 /* BE - Best-effort */ 200 + #define _BRCMS_PREC_EE 6 /* EE - Excellent-effort */ 201 + #define _BRCMS_PREC_CL 8 /* CL - Controlled Load */ 202 + #define _BRCMS_PREC_VI 10 /* Vi - Video */ 203 + #define _BRCMS_PREC_VO 12 /* Vo - Voice */ 204 + #define _BRCMS_PREC_NC 14 /* NC - Network Control */ 140 205 141 - /* The BSS is generating beacons in HW */ 142 - #define BRCMS_BSSCFG_HW_BCN 0x20 206 + /* synthpu_dly times in us */ 207 + #define SYNTHPU_DLY_APHY_US 3700 208 + #define SYNTHPU_DLY_BPHY_US 1050 209 + #define SYNTHPU_DLY_NPHY_US 2048 210 + #define SYNTHPU_DLY_LPPHY_US 300 143 211 144 - #define SYNTHPU_DLY_APHY_US 3700 /* a phy synthpu_dly time in us */ 145 - #define SYNTHPU_DLY_BPHY_US 1050 /* b/g phy synthpu_dly time in us */ 146 - #define SYNTHPU_DLY_NPHY_US 2048 /* n phy REV3 synthpu_dly time in us */ 147 - #define SYNTHPU_DLY_LPPHY_US 300 /* lpphy synthpu_dly time in us */ 148 - 149 - #define SYNTHPU_DLY_PHY_US_QT 100 /* QT synthpu_dly time in us */ 150 - 151 - #define ANTCNT 10 /* vanilla M_MAX_ANTCNT value */ 212 + #define ANTCNT 10 /* vanilla M_MAX_ANTCNT val */ 152 213 153 214 /* Per-AC retry limit register definitions; uses defs.h bitfield macros */ 154 - #define EDCF_SHORT_S 0 155 - #define EDCF_SFB_S 4 156 - #define EDCF_LONG_S 8 157 - #define EDCF_LFB_S 12 158 - #define EDCF_SHORT_M BITFIELD_MASK(4) 159 - #define EDCF_SFB_M BITFIELD_MASK(4) 160 - #define EDCF_LONG_M BITFIELD_MASK(4) 161 - #define EDCF_LFB_M BITFIELD_MASK(4) 215 + #define EDCF_SHORT_S 0 216 + #define EDCF_SFB_S 4 217 + #define EDCF_LONG_S 8 218 + #define EDCF_LFB_S 12 219 + #define EDCF_SHORT_M BITFIELD_MASK(4) 220 + #define EDCF_SFB_M BITFIELD_MASK(4) 221 + #define EDCF_LONG_M BITFIELD_MASK(4) 222 + #define EDCF_LFB_M BITFIELD_MASK(4) 162 223 163 - #define RETRY_SHORT_DEF 7 /* Default Short retry Limit */ 164 - #define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */ 165 - #define RETRY_LONG_DEF 4 /* Default Long retry count */ 166 - #define RETRY_SHORT_FB 3 /* Short count for fallback rate */ 167 - #define RETRY_LONG_FB 2 /* Long count for fallback rate */ 224 + #define RETRY_SHORT_DEF 7 /* Default Short retry Limit */ 225 + #define RETRY_SHORT_MAX 255 /* Maximum Short retry Limit */ 226 + #define RETRY_LONG_DEF 4 /* Default Long retry count */ 227 + #define RETRY_SHORT_FB 3 /* Short count for fb rate */ 228 + #define RETRY_LONG_FB 2 /* Long count for fb rate */ 168 229 169 - #define APHY_CWMIN 15 170 - #define PHY_CWMAX 1023 230 + #define APHY_CWMIN 15 231 + #define PHY_CWMAX 1023 171 232 172 - #define EDCF_AIFSN_MIN 1 233 + #define EDCF_AIFSN_MIN 1 173 234 174 - #define FRAGNUM_MASK 0xF 235 + #define FRAGNUM_MASK 0xF 175 236 176 - #define APHY_SLOT_TIME 9 177 - #define BPHY_SLOT_TIME 20 237 + #define APHY_SLOT_TIME 9 238 + #define BPHY_SLOT_TIME 20 178 239 179 - #define WL_SPURAVOID_OFF 0 180 - #define WL_SPURAVOID_ON1 1 181 - #define WL_SPURAVOID_ON2 2 240 + #define WL_SPURAVOID_OFF 0 241 + #define WL_SPURAVOID_ON1 1 242 + #define WL_SPURAVOID_ON2 2 182 243 183 244 /* invalid core flags, use the saved coreflags */ 184 - #define BRCMS_USE_COREFLAGS 0xffffffff 245 + #define BRCMS_USE_COREFLAGS 0xffffffff 185 246 186 247 /* values for PLCPHdr_override */ 187 - #define BRCMS_PLCP_AUTO -1 188 - #define BRCMS_PLCP_SHORT 0 189 - #define BRCMS_PLCP_LONG 1 248 + #define BRCMS_PLCP_AUTO -1 249 + #define BRCMS_PLCP_SHORT 0 250 + #define BRCMS_PLCP_LONG 1 190 251 191 252 /* values for g_protection_override and n_protection_override */ 192 253 #define BRCMS_PROTECTION_AUTO -1 193 254 #define BRCMS_PROTECTION_OFF 0 194 255 #define BRCMS_PROTECTION_ON 1 195 256 #define BRCMS_PROTECTION_MMHDR_ONLY 2 196 - #define BRCMS_PROTECTION_CTS_ONLY 3 257 + #define BRCMS_PROTECTION_CTS_ONLY 3 197 258 198 259 /* values for g_protection_control and n_protection_control */ 199 - #define BRCMS_PROTECTION_CTL_OFF 0 260 + #define BRCMS_PROTECTION_CTL_OFF 0 200 261 #define BRCMS_PROTECTION_CTL_LOCAL 1 201 262 #define BRCMS_PROTECTION_CTL_OVERLAP 2 202 263 203 264 /* values for n_protection */ 204 265 #define BRCMS_N_PROTECTION_OFF 0 205 266 #define BRCMS_N_PROTECTION_OPTIONAL 1 206 - #define BRCMS_N_PROTECTION_20IN40 2 267 + #define BRCMS_N_PROTECTION_20IN40 2 207 268 #define BRCMS_N_PROTECTION_MIXEDMODE 3 208 269 209 270 /* values for band specific 40MHz capabilities */ 210 - #define BRCMS_N_BW_20ALL 0 211 - #define BRCMS_N_BW_40ALL 1 212 - #define BRCMS_N_BW_20IN2G_40IN5G 2 271 + #define BRCMS_N_BW_20ALL 0 272 + #define BRCMS_N_BW_40ALL 1 273 + #define BRCMS_N_BW_20IN2G_40IN5G 2 213 274 214 275 /* bitflags for SGI support (sgi_rx iovar) */ 215 276 #define BRCMS_N_SGI_20 0x01 ··· 213 282 214 283 /* defines used by the nrate iovar */ 215 284 /* MSC in use,indicates b0-6 holds an mcs */ 216 - #define NRATE_MCS_INUSE 0x00000080 285 + #define NRATE_MCS_INUSE 0x00000080 217 286 /* rate/mcs value */ 218 - #define NRATE_RATE_MASK 0x0000007f 287 + #define NRATE_RATE_MASK 0x0000007f 219 288 /* stf mode mask: siso, cdd, stbc, sdm */ 220 - #define NRATE_STF_MASK 0x0000ff00 289 + #define NRATE_STF_MASK 0x0000ff00 221 290 /* stf mode shift */ 222 - #define NRATE_STF_SHIFT 8 223 - /* bit indicates override both rate & mode */ 224 - #define NRATE_OVERRIDE 0x80000000 291 + #define NRATE_STF_SHIFT 8 225 292 /* bit indicate to override mcs only */ 226 - #define NRATE_OVERRIDE_MCS_ONLY 0x40000000 227 - #define NRATE_SGI_MASK 0x00800000 /* sgi mode */ 228 - #define NRATE_SGI_SHIFT 23 /* sgi mode */ 229 - #define NRATE_LDPC_CODING 0x00400000 /* bit indicates adv coding in use */ 230 - #define NRATE_LDPC_SHIFT 22 /* ldpc shift */ 293 + #define NRATE_OVERRIDE_MCS_ONLY 0x40000000 294 + #define NRATE_SGI_MASK 0x00800000 /* sgi mode */ 295 + #define NRATE_SGI_SHIFT 23 /* sgi mode */ 296 + #define NRATE_LDPC_CODING 0x00400000 /* adv coding in use */ 297 + #define NRATE_LDPC_SHIFT 22 /* ldpc shift */ 231 298 232 - #define NRATE_STF_SISO 0 /* stf mode SISO */ 233 - #define NRATE_STF_CDD 1 /* stf mode CDD */ 234 - #define NRATE_STF_STBC 2 /* stf mode STBC */ 235 - #define NRATE_STF_SDM 3 /* stf mode SDM */ 299 + #define NRATE_STF_SISO 0 /* stf mode SISO */ 300 + #define NRATE_STF_CDD 1 /* stf mode CDD */ 301 + #define NRATE_STF_STBC 2 /* stf mode STBC */ 302 + #define NRATE_STF_SDM 3 /* stf mode SDM */ 236 303 237 - #define MAX_DMA_SEGS 4 304 + #define MAX_DMA_SEGS 4 238 305 239 306 /* Max # of entries in Tx FIFO based on 4kb page size */ 240 - #define NTXD 256 307 + #define NTXD 256 241 308 /* Max # of entries in Rx FIFO based on 4kb page size */ 242 - #define NRXD 256 309 + #define NRXD 256 243 310 244 311 /* try to keep this # rbufs posted to the chip */ 245 - #define NRXBUFPOST 32 312 + #define NRXBUFPOST 32 246 313 247 314 /* data msg txq hiwat mark */ 248 - #define BRCMS_DATAHIWAT 50 315 + #define BRCMS_DATAHIWAT 50 249 316 250 - /* bounded rx loops */ 251 - #define RXBND 8 /* max # frames to process in brcms_c_recv() */ 252 - #define TXSBND 8 /* max # tx status to process in wlc_txstatus() */ 253 - 254 - /* 255 - * 32 SSID chars, max of 4 chars for each SSID char "\xFF", plus NULL. 256 - */ 257 - #define SSID_FMT_BUF_LEN ((4 * IEEE80211_MAX_SSID_LEN) + 1) 317 + /* max # frames to process in brcms_c_recv() */ 318 + #define RXBND 8 319 + /* max # tx status to process in wlc_txstatus() */ 320 + #define TXSBND 8 258 321 259 322 /* brcmu_format_flags() bit description structure */ 260 323 struct brcms_c_bit_desc { ··· 300 375 #endif /* BCMDBG */ 301 376 302 377 /* TX FIFO number to WME/802.1E Access Category */ 303 - static const u8 wme_fifo2ac[] = { AC_BK, AC_BE, AC_VI, AC_VO, AC_BE, AC_BE }; 378 + static const u8 wme_fifo2ac[] = { 379 + IEEE80211_AC_BK, 380 + IEEE80211_AC_BE, 381 + IEEE80211_AC_VI, 382 + IEEE80211_AC_VO, 383 + IEEE80211_AC_BE, 384 + IEEE80211_AC_BE 385 + }; 304 386 305 - /* WME/802.1E Access Category to TX FIFO number */ 306 - static const u8 wme_ac2fifo[] = { 1, 0, 2, 3 }; 387 + /* ieee80211 Access Category to TX FIFO number */ 388 + static const u8 wme_ac2fifo[] = { 389 + TX_AC_VO_FIFO, 390 + TX_AC_VI_FIFO, 391 + TX_AC_BE_FIFO, 392 + TX_AC_BK_FIFO 393 + }; 307 394 308 395 /* 802.1D Priority to precedence queue mapping */ 309 396 const u8 wlc_prio2prec_map[] = { ··· 342 405 {9, 58, 22, 14, 14, 5}, 343 406 }; 344 407 345 - static const u8 acbitmap2maxprio[] = { 346 - PRIO_8021D_BE, PRIO_8021D_BE, PRIO_8021D_BK, PRIO_8021D_BK, 347 - PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, PRIO_8021D_VI, 348 - PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, 349 - PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO, PRIO_8021D_VO 350 - }; 351 - 352 408 #ifdef BCMDBG 353 409 static const char * const fifo_names[] = { 354 410 "AC_BK", "AC_BE", "AC_VI", "AC_VO", "BCMC", "ATIM" }; ··· 353 423 /* pointer to most recently allocated wl/wlc */ 354 424 static struct brcms_c_info *wlc_info_dbg = (struct brcms_c_info *) (NULL); 355 425 #endif 426 + 427 + /* Find basic rate for a given rate */ 428 + static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) 429 + { 430 + if (is_mcs_rate(rspec)) 431 + return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] 432 + .leg_ofdm]; 433 + return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; 434 + } 435 + 436 + static u16 frametype(u32 rspec, u8 mimoframe) 437 + { 438 + if (is_mcs_rate(rspec)) 439 + return mimoframe; 440 + return is_cck_rate(rspec) ? FT_CCK : FT_OFDM; 441 + } 356 442 357 443 /* currently the best mechanism for determining SIFS is the band in use */ 358 444 static u16 get_sifs(struct brcms_band *band) ··· 414 468 return BRCMS_20_MHZ; 415 469 416 470 return BRCMS_10_MHZ; 417 - } 418 - 419 - /* 420 - * return true if Minimum Power Consumption should 421 - * be entered, false otherwise 422 - */ 423 - static bool brcms_c_is_non_delay_mpc(struct brcms_c_info *wlc) 424 - { 425 - return false; 426 - } 427 - 428 - static bool brcms_c_ismpc(struct brcms_c_info *wlc) 429 - { 430 - return (wlc->mpc_delay_off == 0) && (brcms_c_is_non_delay_mpc(wlc)); 431 471 } 432 472 433 473 static void brcms_c_bsscfg_mfree(struct brcms_bss_cfg *cfg) ··· 601 669 * calculate frame duration of a given rate and length, return 602 670 * time in usec unit 603 671 */ 604 - uint 605 - brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, 606 - u8 preamble_type, uint mac_len) 672 + static uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, 673 + u8 preamble_type, uint mac_len) 607 674 { 608 675 uint nsyms, dur = 0, Ndps, kNdps; 609 676 uint rate = rspec2rate(ratespec); ··· 900 969 lfbl, /* Long Frame Rate Fallback Limit */ 901 970 fbl; 902 971 903 - if (queue < AC_COUNT) { 972 + if (queue < IEEE80211_NUM_ACS) { 904 973 sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], 905 974 EDCF_SFB); 906 975 lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], ··· 949 1018 tx_info->flags |= IEEE80211_TX_STAT_ACK; 950 1019 } 951 1020 952 - totlen = brcmu_pkttotlen(p); 1021 + totlen = p->len; 953 1022 free_pdu = true; 954 1023 955 1024 brcms_c_txfifo_complete(wlc, queue, 1); ··· 2283 2352 wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); 2284 2353 } 2285 2354 2286 - static void brcms_c_fatal_error(struct brcms_c_info *wlc) 2287 - { 2288 - wiphy_err(wlc->wiphy, "wl%d: fatal error, reinitializing\n", 2289 - wlc->pub->unit); 2290 - brcms_init(wlc->wl); 2291 - } 2292 - 2293 2355 static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) 2294 2356 { 2295 2357 bool fatal = false; ··· 2338 2414 } 2339 2415 2340 2416 if (fatal) { 2341 - brcms_c_fatal_error(wlc_hw->wlc); /* big hammer */ 2417 + brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ 2342 2418 break; 2343 2419 } else 2344 2420 W_REG(&regs->intctrlregs[idx].intstatus, ··· 2403 2479 W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); 2404 2480 } 2405 2481 2482 + /* assumes that the d11 MAC is enabled */ 2406 2483 static void brcms_b_tx_fifo_suspend(struct brcms_hardware *wlc_hw, 2407 2484 uint tx_fifo) 2408 2485 { ··· 2460 2535 } 2461 2536 } 2462 2537 2463 - static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) 2538 + /* precondition: requires the mac core to be enabled */ 2539 + static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool mute_tx) 2464 2540 { 2465 2541 static const u8 null_ether_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; 2466 2542 2467 - if (on) { 2543 + if (mute_tx) { 2468 2544 /* suspend tx fifos */ 2469 2545 brcms_b_tx_fifo_suspend(wlc_hw, TX_DATA_FIFO); 2470 2546 brcms_b_tx_fifo_suspend(wlc_hw, TX_CTL_FIFO); ··· 2487 2561 wlc_hw->etheraddr); 2488 2562 } 2489 2563 2490 - wlc_phy_mute_upd(wlc_hw->band->pi, on, flags); 2564 + wlc_phy_mute_upd(wlc_hw->band->pi, mute_tx, 0); 2491 2565 2492 - if (on) 2566 + if (mute_tx) 2493 2567 brcms_c_ucode_mute_override_set(wlc_hw); 2494 2568 else 2495 2569 brcms_c_ucode_mute_override_clear(wlc_hw); 2570 + } 2571 + 2572 + void 2573 + brcms_c_mute(struct brcms_c_info *wlc, bool mute_tx) 2574 + { 2575 + brcms_b_mute(wlc->hw, mute_tx); 2496 2576 } 2497 2577 2498 2578 /* ··· 3369 3437 } 3370 3438 3371 3439 void 3372 - static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec, 3373 - bool mute) { 3440 + static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec) { 3374 3441 u32 macintmask; 3375 3442 bool fastclk; 3376 3443 struct brcms_c_info *wlc = wlc_hw->wlc; ··· 3393 3462 3394 3463 /* core-specific initialization */ 3395 3464 brcms_b_coreinit(wlc); 3396 - 3397 - /* suspend the tx fifos and mute the phy for preism cac time */ 3398 - if (mute) 3399 - brcms_b_mute(wlc_hw, ON, PHY_MUTE_FOR_PREISM); 3400 3465 3401 3466 /* band-specific inits */ 3402 3467 brcms_b_bsinit(wlc, chanspec); ··· 3583 3656 brcms_c_set_phy_chanspec(wlc, chanspec); 3584 3657 } 3585 3658 3586 - static void brcms_c_mac_bcn_promisc(struct brcms_c_info *wlc) 3659 + /* 3660 + * Set or clear maccontrol bits MCTL_PROMISC, MCTL_BCNS_PROMISC and 3661 + * MCTL_KEEPCONTROL 3662 + */ 3663 + static void brcms_c_mac_promisc(struct brcms_c_info *wlc) 3587 3664 { 3665 + u32 promisc_bits = 0; 3666 + 3588 3667 if (wlc->bcnmisc_monitor) 3589 - brcms_b_mctrl(wlc->hw, MCTL_BCNS_PROMISC, MCTL_BCNS_PROMISC); 3590 - else 3591 - brcms_b_mctrl(wlc->hw, MCTL_BCNS_PROMISC, 0); 3668 + promisc_bits |= MCTL_BCNS_PROMISC; 3669 + 3670 + if (wlc->monitor) 3671 + promisc_bits |= 3672 + MCTL_PROMISC | MCTL_BCNS_PROMISC | MCTL_KEEPCONTROL; 3673 + 3674 + brcms_b_mctrl(wlc->hw, 3675 + MCTL_PROMISC | MCTL_BCNS_PROMISC | MCTL_KEEPCONTROL, 3676 + promisc_bits); 3592 3677 } 3593 3678 3594 3679 void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, bool promisc) 3595 3680 { 3596 3681 wlc->bcnmisc_monitor = promisc; 3597 - brcms_c_mac_bcn_promisc(wlc); 3598 - } 3599 - 3600 - /* set or clear maccontrol bits MCTL_PROMISC and MCTL_KEEPCONTROL */ 3601 - static void brcms_c_mac_promisc(struct brcms_c_info *wlc) 3602 - { 3603 - u32 promisc_bits = 0; 3604 - 3605 - /* 3606 - * promiscuous mode just sets MCTL_PROMISC 3607 - * Note: APs get all BSS traffic without the need to set 3608 - * the MCTL_PROMISC bit since all BSS data traffic is 3609 - * directed at the AP 3610 - */ 3611 - if (wlc->pub->promisc) 3612 - promisc_bits |= MCTL_PROMISC; 3613 - 3614 - /* monitor mode needs both MCTL_PROMISC and MCTL_KEEPCONTROL 3615 - * Note: monitor mode also needs MCTL_BCNS_PROMISC, but that is 3616 - * handled in brcms_c_mac_bcn_promisc() 3617 - */ 3618 - if (wlc->monitor) 3619 - promisc_bits |= MCTL_PROMISC | MCTL_KEEPCONTROL; 3620 - 3621 - brcms_b_mctrl(wlc->hw, MCTL_PROMISC | MCTL_KEEPCONTROL, promisc_bits); 3682 + brcms_c_mac_promisc(wlc); 3622 3683 } 3623 3684 3624 3685 /* ··· 3638 3723 } 3639 3724 3640 3725 /* update the various promisc bits */ 3641 - brcms_c_mac_bcn_promisc(wlc); 3642 3726 brcms_c_mac_promisc(wlc); 3643 3727 } 3644 3728 ··· 3893 3979 3894 3980 void 3895 3981 brcms_b_set_chanspec(struct brcms_hardware *wlc_hw, u16 chanspec, 3896 - bool mute, struct txpwr_limits *txpwr) 3982 + bool mute_tx, struct txpwr_limits *txpwr) 3897 3983 { 3898 3984 uint bandunit; 3899 3985 ··· 3919 4005 } 3920 4006 } 3921 4007 3922 - wlc_phy_initcal_enable(wlc_hw->band->pi, !mute); 4008 + wlc_phy_initcal_enable(wlc_hw->band->pi, !mute_tx); 3923 4009 3924 4010 if (!wlc_hw->up) { 3925 4011 if (wlc_hw->clk) ··· 3931 4017 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); 3932 4018 3933 4019 /* Update muting of the channel */ 3934 - brcms_b_mute(wlc_hw, mute, 0); 4020 + brcms_b_mute(wlc_hw, mute_tx); 3935 4021 } 3936 4022 } 3937 4023 ··· 4119 4205 EDCF_TXOP2USEC(acp_shm.txop); 4120 4206 acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); 4121 4207 4122 - if (aci == AC_VI && acp_shm.txop == 0 4208 + if (aci == IEEE80211_AC_VI && acp_shm.txop == 0 4123 4209 && acp_shm.aifs < EDCF_AIFSN_MAX) 4124 4210 acp_shm.aifs++; 4125 4211 ··· 4156 4242 } 4157 4243 } 4158 4244 4159 - void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) 4245 + static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) 4160 4246 { 4161 4247 u16 aci; 4162 4248 int i_ac; ··· 4169 4255 }; /* ucode needs these parameters during its initialization */ 4170 4256 const struct edcf_acparam *edcf_acp = &default_edcf_acparams[0]; 4171 4257 4172 - for (i_ac = 0; i_ac < AC_COUNT; i_ac++, edcf_acp++) { 4258 + for (i_ac = 0; i_ac < IEEE80211_NUM_ACS; i_ac++, edcf_acp++) { 4173 4259 /* find out which ac this set of params applies to */ 4174 4260 aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT; 4175 4261 ··· 4191 4277 } 4192 4278 } 4193 4279 4194 - /* maintain LED behavior in down state */ 4195 - static void brcms_c_down_led_upd(struct brcms_c_info *wlc) 4196 - { 4197 - /* 4198 - * maintain LEDs while in down state, turn on sbclk if 4199 - * not available yet. Turn on sbclk if necessary 4200 - */ 4201 - brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_FLIP); 4202 - brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_FLIP); 4203 - } 4204 - 4205 4280 static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) 4206 4281 { 4207 4282 /* Don't start the timer if HWRADIO feature is disabled */ ··· 4200 4297 wlc->radio_monitor = true; 4201 4298 brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_RADIO_MON); 4202 4299 brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); 4203 - } 4204 - 4205 - static void brcms_c_radio_disable(struct brcms_c_info *wlc) 4206 - { 4207 - if (!wlc->pub->up) { 4208 - brcms_c_down_led_upd(wlc); 4209 - return; 4210 - } 4211 - 4212 - brcms_c_radio_monitor_start(wlc); 4213 - brcms_down(wlc->wl); 4214 - } 4215 - 4216 - static void brcms_c_radio_enable(struct brcms_c_info *wlc) 4217 - { 4218 - if (wlc->pub->up) 4219 - return; 4220 - 4221 - if (brcms_deviceremoved(wlc)) 4222 - return; 4223 - 4224 - brcms_up(wlc->wl); 4225 4300 } 4226 4301 4227 4302 static bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) ··· 4224 4343 mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); 4225 4344 } 4226 4345 4227 - /* 4228 - * centralized radio disable/enable function, 4229 - * invoke radio enable/disable after updating hwradio status 4230 - */ 4231 - static void brcms_c_radio_upd(struct brcms_c_info *wlc) 4232 - { 4233 - if (wlc->pub->radio_disabled) 4234 - brcms_c_radio_disable(wlc); 4235 - else 4236 - brcms_c_radio_enable(wlc); 4237 - } 4238 - 4239 4346 /* update hwradio status and return it */ 4240 4347 bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) 4241 4348 { ··· 4245 4376 return; 4246 4377 } 4247 4378 4248 - /* cap mpc off count */ 4249 - if (wlc->mpc_offcnt < BRCMS_MPC_MAX_DELAYCNT) 4250 - wlc->mpc_offcnt++; 4251 - 4252 4379 brcms_c_radio_hwdisable_upd(wlc); 4253 - brcms_c_radio_upd(wlc); 4254 4380 } 4255 4381 4256 4382 /* common low-level watchdog code */ ··· 4271 4407 wlc_phy_watchdog(wlc_hw->band->pi); 4272 4408 } 4273 4409 4274 - static void brcms_c_radio_mpc_upd(struct brcms_c_info *wlc) 4275 - { 4276 - bool mpc_radio, radio_state; 4277 - 4278 - /* 4279 - * Clear the WL_RADIO_MPC_DISABLE bit when mpc feature is disabled 4280 - * in case the WL_RADIO_MPC_DISABLE bit was set. Stop the radio 4281 - * monitor also when WL_RADIO_MPC_DISABLE is the only reason that 4282 - * the radio is going down. 4283 - */ 4284 - if (!wlc->mpc) { 4285 - if (!wlc->pub->radio_disabled) 4286 - return; 4287 - mboolclr(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); 4288 - brcms_c_radio_upd(wlc); 4289 - if (!wlc->pub->radio_disabled) 4290 - brcms_c_radio_monitor_stop(wlc); 4291 - return; 4292 - } 4293 - 4294 - /* 4295 - * sync ismpc logic with WL_RADIO_MPC_DISABLE bit in 4296 - * wlc->pub->radio_disabled to go ON, always call radio_upd 4297 - * synchronously to go OFF, postpone radio_upd to later when 4298 - * context is safe(e.g. watchdog) 4299 - */ 4300 - radio_state = 4301 - (mboolisset(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE) ? OFF : 4302 - ON); 4303 - mpc_radio = (brcms_c_ismpc(wlc) == true) ? OFF : ON; 4304 - 4305 - if (radio_state == ON && mpc_radio == OFF) 4306 - wlc->mpc_delay_off = wlc->mpc_dlycnt; 4307 - else if (radio_state == OFF && mpc_radio == ON) { 4308 - mboolclr(wlc->pub->radio_disabled, WL_RADIO_MPC_DISABLE); 4309 - brcms_c_radio_upd(wlc); 4310 - if (wlc->mpc_offcnt < BRCMS_MPC_THRESHOLD) 4311 - wlc->mpc_dlycnt = BRCMS_MPC_MAX_DELAYCNT; 4312 - else 4313 - wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; 4314 - } 4315 - /* 4316 - * Below logic is meant to capture the transition from mpc off 4317 - * to mpc on for reasons other than wlc->mpc_delay_off keeping 4318 - * the mpc off. In that case reset wlc->mpc_delay_off to 4319 - * wlc->mpc_dlycnt, so that we restart the countdown of mpc_delay_off 4320 - */ 4321 - if ((wlc->prev_non_delay_mpc == false) && 4322 - (brcms_c_is_non_delay_mpc(wlc) == true) && wlc->mpc_delay_off) 4323 - wlc->mpc_delay_off = wlc->mpc_dlycnt; 4324 - 4325 - wlc->prev_non_delay_mpc = brcms_c_is_non_delay_mpc(wlc); 4326 - } 4327 - 4328 4410 /* common watchdog code */ 4329 4411 static void brcms_c_watchdog(void *arg) 4330 4412 { ··· 4291 4481 /* increment second count */ 4292 4482 wlc->pub->now++; 4293 4483 4294 - /* delay radio disable */ 4295 - if (wlc->mpc_delay_off) { 4296 - if (--wlc->mpc_delay_off == 0) { 4297 - mboolset(wlc->pub->radio_disabled, 4298 - WL_RADIO_MPC_DISABLE); 4299 - if (wlc->mpc && brcms_c_ismpc(wlc)) 4300 - wlc->mpc_offcnt = 0; 4301 - } 4302 - } 4303 - 4304 - /* mpc sync */ 4305 - brcms_c_radio_mpc_upd(wlc); 4306 - /* radio sync: sw/hw/mpc --> radio_disable/radio_enable */ 4307 4484 brcms_c_radio_hwdisable_upd(wlc); 4308 - brcms_c_radio_upd(wlc); 4309 4485 /* if radio is disable, driver may be down, quit here */ 4310 4486 if (wlc->pub->radio_disabled) 4311 4487 return; ··· 4395 4599 /* WME QoS mode is Auto by default */ 4396 4600 wlc->pub->_ampdu = AMPDU_AGG_HOST; 4397 4601 wlc->pub->bcmerror = 0; 4398 - 4399 - /* initialize mpc delay */ 4400 - wlc->mpc_delay_off = wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; 4401 4602 } 4402 4603 4403 4604 static uint brcms_c_attach_module(struct brcms_c_info *wlc) ··· 5052 5259 { 5053 5260 /* STA-BSS; short capable */ 5054 5261 wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; 5055 - 5056 - /* fixup mpc */ 5057 - wlc->mpc = true; 5058 5262 } 5059 5263 5060 5264 /* Initialize just the hardware when coming out of POR or S3/S5 system states */ ··· 5166 5376 if (!wlc->clk) 5167 5377 return; 5168 5378 5169 - for (ac = 0; ac < AC_COUNT; ac++) 5379 + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) 5170 5380 brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), 5171 5381 wlc->wme_retries[ac]); 5172 5382 } ··· 5365 5575 if (!wlc->pub->up) 5366 5576 return callbacks; 5367 5577 5368 - /* in between, mpc could try to bring down again.. */ 5369 5578 wlc->going_down = true; 5370 5579 5371 5580 callbacks += brcms_b_bmac_down_prep(wlc->hw); ··· 5641 5852 5642 5853 brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); 5643 5854 5644 - for (ac = 0; ac < AC_COUNT; ac++) { 5855 + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 5645 5856 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], 5646 5857 EDCF_SHORT, wlc->SRL); 5647 5858 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], ··· 5892 6103 5893 6104 u8 *rtsph = txh->RTSPhyHeader; 5894 6105 struct ieee80211_rts rts = txh->rts_frame; 5895 - char hexbuf[256]; 5896 6106 5897 6107 /* add plcp header along with txh descriptor */ 5898 6108 printk(KERN_DEBUG "Raw TxDesc + plcp header:\n"); ··· 5912 6124 printk(KERN_DEBUG "XtraFrameTypes: %04x ", xtraft); 5913 6125 printk(KERN_DEBUG "\n"); 5914 6126 5915 - brcmu_format_hex(hexbuf, iv, sizeof(txh->IV)); 5916 - printk(KERN_DEBUG "SecIV: %s\n", hexbuf); 5917 - brcmu_format_hex(hexbuf, ra, sizeof(txh->TxFrameRA)); 5918 - printk(KERN_DEBUG "RA: %s\n", hexbuf); 6127 + print_hex_dump_bytes("SecIV:", DUMP_PREFIX_OFFSET, iv, sizeof(txh->IV)); 6128 + print_hex_dump_bytes("RA:", DUMP_PREFIX_OFFSET, 6129 + ra, sizeof(txh->TxFrameRA)); 5919 6130 5920 6131 printk(KERN_DEBUG "Fb FES Time: %04x ", tfestfb); 5921 - brcmu_format_hex(hexbuf, rtspfb, sizeof(txh->RTSPLCPFallback)); 5922 - printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf); 6132 + print_hex_dump_bytes("Fb RTS PLCP:", DUMP_PREFIX_OFFSET, 6133 + rtspfb, sizeof(txh->RTSPLCPFallback)); 5923 6134 printk(KERN_DEBUG "RTS DUR: %04x ", rtsdfb); 5924 - brcmu_format_hex(hexbuf, fragpfb, sizeof(txh->FragPLCPFallback)); 5925 - printk(KERN_DEBUG "PLCP: %s ", hexbuf); 6135 + print_hex_dump_bytes("PLCP:", DUMP_PREFIX_OFFSET, 6136 + fragpfb, sizeof(txh->FragPLCPFallback)); 5926 6137 printk(KERN_DEBUG "DUR: %04x", fragdfb); 5927 6138 printk(KERN_DEBUG "\n"); 5928 6139 ··· 5936 6149 printk(KERN_DEBUG "MaxAggbyte_fb: %04x\n", mabyte_f); 5937 6150 printk(KERN_DEBUG "MinByte: %04x\n", mmbyte); 5938 6151 5939 - brcmu_format_hex(hexbuf, rtsph, sizeof(txh->RTSPhyHeader)); 5940 - printk(KERN_DEBUG "RTS PLCP: %s ", hexbuf); 5941 - brcmu_format_hex(hexbuf, (u8 *) &rts, sizeof(txh->rts_frame)); 5942 - printk(KERN_DEBUG "RTS Frame: %s", hexbuf); 6152 + print_hex_dump_bytes("RTS PLCP:", DUMP_PREFIX_OFFSET, 6153 + rtsph, sizeof(txh->RTSPhyHeader)); 6154 + print_hex_dump_bytes("RTS Frame:", DUMP_PREFIX_OFFSET, 6155 + (u8 *)&rts, sizeof(txh->rts_frame)); 5943 6156 printk(KERN_DEBUG "\n"); 5944 6157 } 5945 6158 #endif /* defined(BCMDBG) */ 5946 6159 5947 6160 #if defined(BCMDBG) 5948 - int 6161 + static int 5949 6162 brcms_c_format_flags(const struct brcms_c_bit_desc *bd, u32 flags, char *buf, 5950 - int len) 6163 + int len) 5951 6164 { 5952 6165 int i; 5953 6166 char *p = buf; ··· 6703 6916 qos = ieee80211_is_data_qos(h->frame_control); 6704 6917 6705 6918 /* compute length of frame in bytes for use in PLCP computations */ 6706 - len = brcmu_pkttotlen(p); 6919 + len = p->len; 6707 6920 phylen = len + FCS_LEN; 6708 6921 6709 6922 /* Get tx_info */ ··· 8040 8253 return (int)(qdbm / BRCMS_TXPWR_DB_FACTOR); 8041 8254 } 8042 8255 8043 - void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc) 8044 - { 8045 - wlc->mpc = mpc; 8046 - brcms_c_radio_mpc_upd(wlc); 8047 - } 8048 - 8049 8256 /* Process received frames */ 8050 8257 /* 8051 8258 * Return true if more frames need to be processed. false otherwise. ··· 8109 8328 brcms_b_recv(struct brcms_hardware *wlc_hw, uint fifo, bool bound) 8110 8329 { 8111 8330 struct sk_buff *p; 8112 - struct sk_buff *head = NULL; 8113 - struct sk_buff *tail = NULL; 8331 + struct sk_buff *next = NULL; 8332 + struct sk_buff_head recv_frames; 8333 + 8114 8334 uint n = 0; 8115 8335 uint bound_limit = bound ? RXBND : -1; 8116 8336 8117 8337 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); 8118 - /* gather received frames */ 8119 - while ((p = dma_rx(wlc_hw->di[fifo]))) { 8338 + skb_queue_head_init(&recv_frames); 8120 8339 8121 - if (!tail) 8122 - head = tail = p; 8123 - else { 8124 - tail->prev = p; 8125 - tail = p; 8126 - } 8340 + /* gather received frames */ 8341 + while (dma_rx(wlc_hw->di[fifo], &recv_frames)) { 8127 8342 8128 8343 /* !give others some time to run! */ 8129 8344 if (++n >= bound_limit) ··· 8130 8353 dma_rxfill(wlc_hw->di[fifo]); 8131 8354 8132 8355 /* process each frame */ 8133 - while ((p = head) != NULL) { 8356 + skb_queue_walk_safe(&recv_frames, p, next) { 8134 8357 struct d11rxhdr_le *rxh_le; 8135 8358 struct d11rxhdr *rxh; 8136 - head = head->prev; 8137 - p->prev = NULL; 8138 8359 8360 + skb_unlink(p, &recv_frames); 8139 8361 rxh_le = (struct d11rxhdr_le *)p->data; 8140 8362 rxh = (struct d11rxhdr *)p->data; 8141 8363 ··· 8224 8448 printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n", 8225 8449 __func__, wlc_hw->sih->chip, 8226 8450 wlc_hw->sih->chiprev); 8227 - /* big hammer */ 8228 - brcms_init(wlc->wl); 8451 + brcms_fatal_error(wlc_hw->wlc->wl); 8229 8452 } 8230 8453 8231 8454 /* gptimer timeout */ ··· 8245 8470 return wlc->macintstatus != 0; 8246 8471 8247 8472 fatal: 8248 - brcms_init(wlc->wl); 8473 + brcms_fatal_error(wlc_hw->wlc->wl); 8249 8474 return wlc->macintstatus != 0; 8250 8475 } 8251 8476 8252 - void brcms_c_init(struct brcms_c_info *wlc) 8477 + void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) 8253 8478 { 8254 8479 struct d11regs __iomem *regs; 8255 8480 u16 chanspec; 8256 - bool mute = false; 8257 8481 8258 8482 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); 8259 8483 ··· 8268 8494 else 8269 8495 chanspec = brcms_c_init_chanspec(wlc); 8270 8496 8271 - brcms_b_init(wlc->hw, chanspec, mute); 8497 + brcms_b_init(wlc->hw, chanspec); 8272 8498 8273 8499 /* update beacon listen interval */ 8274 8500 brcms_c_bcn_li_upd(wlc); ··· 8334 8560 /* ..now really unleash hell (allow the MAC out of suspend) */ 8335 8561 brcms_c_enable_mac(wlc); 8336 8562 8563 + /* suspend the tx fifos and mute the phy for preism cac time */ 8564 + if (mute_tx) 8565 + brcms_b_mute(wlc->hw, true); 8566 + 8337 8567 /* clear tx flow control */ 8338 8568 brcms_c_txflowcontrol_reset(wlc); 8339 8569 8340 8570 /* enable the RF Disable Delay timer */ 8341 8571 W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); 8342 - 8343 - /* initialize mpc delay */ 8344 - wlc->mpc_delay_off = wlc->mpc_dlycnt = BRCMS_MPC_MIN_DELAYCNT; 8345 8572 8346 8573 /* 8347 8574 * Initialize WME parameters; if they haven't been set by some other ··· 8352 8577 /* Uninitialized; read from HW */ 8353 8578 int ac; 8354 8579 8355 - for (ac = 0; ac < AC_COUNT; ac++) 8580 + for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) 8356 8581 wlc->wme_retries[ac] = 8357 8582 brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); 8358 8583 } ··· 8529 8754 brcms_c_ht_update_sgi_rx(wlc, 0); 8530 8755 } 8531 8756 8532 - /* initialize radio_mpc_disable according to wlc->mpc */ 8533 - brcms_c_radio_mpc_upd(wlc); 8534 8757 brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); 8535 8758 8536 8759 if (perr)
+3 -16
drivers/net/wireless/brcm80211/brcmsmac/main.h
··· 44 44 /* transmit buffer max headroom for protocol headers */ 45 45 #define TXOFF (D11_TXH_LEN + D11_PHY_HDR_LEN) 46 46 47 - #define AC_COUNT 4 48 - 49 47 /* Macros for doing definition and get/set of bitfields 50 48 * Usage example, e.g. a three-bit field (bits 4-6): 51 49 * #define <NAME>_M BITFIELD_MASK(3) ··· 425 427 * bandinit_pending: track band init in auto band. 426 428 * radio_monitor: radio timer is running. 427 429 * going_down: down path intermediate variable. 428 - * mpc: enable minimum power consumption. 429 - * mpc_dlycnt: # of watchdog cnt before turn disable radio. 430 - * mpc_offcnt: # of watchdog cnt that radio is disabled. 431 - * mpc_delay_off: delay radio disable by # of watchdog cnt. 432 - * prev_non_delay_mpc: prev state brcms_c_is_non_delay_mpc. 433 430 * wdtimer: timer for watchdog routine. 434 431 * radio_timer: timer for hw radio button monitor routine. 435 432 * monitor: monitor (MPDU sniffing) mode. ··· 434 441 * bcn_li_dtim: beacon listen interval in # dtims. 435 442 * WDarmed: watchdog timer is armed. 436 443 * WDlast: last time wlc_watchdog() was called. 437 - * edcf_txop[AC_COUNT]: current txop for each ac. 444 + * edcf_txop[IEEE80211_NUM_ACS]: current txop for each ac. 438 445 * wme_retries: per-AC retry limits. 439 446 * tx_prec_map: Precedence map based on HW FIFO space. 440 447 * fifo2prec_map[NFIFO]: pointer to fifo2_prec map based on WME. ··· 515 522 bool radio_monitor; 516 523 bool going_down; 517 524 518 - bool mpc; 519 - u8 mpc_dlycnt; 520 - u8 mpc_offcnt; 521 - u8 mpc_delay_off; 522 - u8 prev_non_delay_mpc; 523 - 524 525 struct brcms_timer *wdtimer; 525 526 struct brcms_timer *radio_timer; 526 527 ··· 533 546 u32 WDlast; 534 547 535 548 /* WME */ 536 - u16 edcf_txop[AC_COUNT]; 549 + u16 edcf_txop[IEEE80211_NUM_ACS]; 537 550 538 - u16 wme_retries[AC_COUNT]; 551 + u16 wme_retries[IEEE80211_NUM_ACS]; 539 552 u16 tx_prec_map; 540 553 u16 fifo2prec_map[NFIFO]; 541 554
+1 -9
drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c
··· 112 112 {216, 50800} 113 113 }; 114 114 115 - const u8 ofdm_rate_lookup[] = { 115 + static const u8 ofdm_rate_lookup[] = { 116 116 117 117 BRCM_RATE_48M, 118 118 BRCM_RATE_24M, ··· 190 190 data = R_REG(&pi->regs->radioregdata); 191 191 } else { 192 192 W_REG_FLUSH(&pi->regs->phy4waddr, addr); 193 - 194 - #ifdef __ARM_ARCH_4T__ 195 - __asm__(" .align 4 "); 196 - __asm__(" nop "); 197 193 data = R_REG(&pi->regs->phy4wdatalo); 198 - #else 199 - data = R_REG(&pi->regs->phy4wdatalo); 200 - #endif 201 - 202 194 } 203 195 pi->phy_wreg = 0; 204 196
-5
drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h
··· 774 774 s16 nphy_noise_win[PHY_CORE_MAX][PHY_NOISE_WINDOW_SZ]; 775 775 u8 nphy_noise_index; 776 776 777 - u8 nphy_txpid2g[PHY_CORE_NUM_2]; 778 - u8 nphy_txpid5g[PHY_CORE_NUM_2]; 779 - u8 nphy_txpid5gl[PHY_CORE_NUM_2]; 780 - u8 nphy_txpid5gh[PHY_CORE_NUM_2]; 781 - 782 777 bool nphy_gain_boost; 783 778 bool nphy_elna_gain_config; 784 779 u16 old_bphy_test;
+3 -35
drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c
··· 29 29 #include "phy_radio.h" 30 30 #include "phyreg_n.h" 31 31 #include "phytbl_n.h" 32 + #include "soc.h" 32 33 33 34 #define READ_RADIO_REG2(pi, radio_type, jspace, core, reg_name) \ 34 35 read_radio_reg(pi, radio_type##_##jspace##_##reg_name | \ ··· 14418 14417 switch (band_num) { 14419 14418 case 0: 14420 14419 14421 - pi->nphy_txpid2g[PHY_CORE_0] = 14422 - (u8) wlapi_getintvar(shim, 14423 - BRCMS_SROM_TXPID2GA0); 14424 - pi->nphy_txpid2g[PHY_CORE_1] = 14425 - (u8) wlapi_getintvar(shim, 14426 - BRCMS_SROM_TXPID2GA1); 14427 14420 pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g = 14428 14421 (s8) wlapi_getintvar(shim, 14429 14422 BRCMS_SROM_MAXP2GA0); ··· 14481 14486 break; 14482 14487 case 1: 14483 14488 14484 - pi->nphy_txpid5g[PHY_CORE_0] = 14485 - (u8) wlapi_getintvar(shim, 14486 - BRCMS_SROM_TXPID5GA0); 14487 - pi->nphy_txpid5g[PHY_CORE_1] = 14488 - (u8) wlapi_getintvar(shim, 14489 - BRCMS_SROM_TXPID5GA1); 14490 14489 pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm = 14491 14490 (s8) wlapi_getintvar(shim, BRCMS_SROM_MAXP5GA0); 14492 14491 pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm = ··· 14540 14551 break; 14541 14552 case 2: 14542 14553 14543 - pi->nphy_txpid5gl[0] = 14544 - (u8) wlapi_getintvar(shim, 14545 - BRCMS_SROM_TXPID5GLA0); 14546 - pi->nphy_txpid5gl[1] = 14547 - (u8) wlapi_getintvar(shim, 14548 - BRCMS_SROM_TXPID5GLA1); 14549 14554 pi->nphy_pwrctrl_info[0].max_pwr_5gl = 14550 14555 (s8) wlapi_getintvar(shim, 14551 14556 BRCMS_SROM_MAXP5GLA0); ··· 14598 14615 break; 14599 14616 case 3: 14600 14617 14601 - pi->nphy_txpid5gh[0] = 14602 - (u8) wlapi_getintvar(shim, 14603 - BRCMS_SROM_TXPID5GHA0); 14604 - pi->nphy_txpid5gh[1] = 14605 - (u8) wlapi_getintvar(shim, 14606 - BRCMS_SROM_TXPID5GHA1); 14607 14618 pi->nphy_pwrctrl_info[0].max_pwr_5gh = 14608 14619 (s8) wlapi_getintvar(shim, 14609 14620 BRCMS_SROM_MAXP5GHA0); ··· 27971 27994 chan_freq_range = wlc_phy_get_chan_freq_range_nphy(pi, 0); 27972 27995 switch (chan_freq_range) { 27973 27996 case WL_CHAN_FREQ_RANGE_2G: 27974 - txpi[0] = pi->nphy_txpid2g[0]; 27975 - txpi[1] = pi->nphy_txpid2g[1]; 27976 - break; 27977 27997 case WL_CHAN_FREQ_RANGE_5GL: 27978 - txpi[0] = pi->nphy_txpid5gl[0]; 27979 - txpi[1] = pi->nphy_txpid5gl[1]; 27980 - break; 27981 27998 case WL_CHAN_FREQ_RANGE_5GM: 27982 - txpi[0] = pi->nphy_txpid5g[0]; 27983 - txpi[1] = pi->nphy_txpid5g[1]; 27984 - break; 27985 27999 case WL_CHAN_FREQ_RANGE_5GH: 27986 - txpi[0] = pi->nphy_txpid5gh[0]; 27987 - txpi[1] = pi->nphy_txpid5gh[1]; 28000 + txpi[0] = 0; 28001 + txpi[1] = 0; 27988 28002 break; 27989 28003 default: 27990 28004 txpi[0] = txpi[1] = 91;
+1
drivers/net/wireless/brcm80211/brcmsmac/pmu.c
··· 23 23 #include "pub.h" 24 24 #include "aiutils.h" 25 25 #include "pmu.h" 26 + #include "soc.h" 26 27 27 28 /* 28 29 * external LPO crystal frequency
+2 -36
drivers/net/wireless/brcm80211/brcmsmac/pub.h
··· 170 170 BRCMS_SROM_TSSIPOS2G, 171 171 BRCMS_SROM_TSSIPOS5G, 172 172 BRCMS_SROM_TXCHAIN, 173 - BRCMS_SROM_TXPID2GA0, 174 - BRCMS_SROM_TXPID2GA1, 175 - BRCMS_SROM_TXPID2GA2, 176 - BRCMS_SROM_TXPID2GA3, 177 - BRCMS_SROM_TXPID5GA0, 178 - BRCMS_SROM_TXPID5GA1, 179 - BRCMS_SROM_TXPID5GA2, 180 - BRCMS_SROM_TXPID5GA3, 181 - BRCMS_SROM_TXPID5GHA0, 182 - BRCMS_SROM_TXPID5GHA1, 183 - BRCMS_SROM_TXPID5GHA2, 184 - BRCMS_SROM_TXPID5GHA3, 185 - BRCMS_SROM_TXPID5GLA0, 186 - BRCMS_SROM_TXPID5GLA1, 187 - BRCMS_SROM_TXPID5GLA2, 188 - BRCMS_SROM_TXPID5GLA3, 189 173 /* 190 174 * per-path identifiers (see srom.c) 191 175 */ ··· 209 225 BRCMS_SROM_PA2GW2A1, 210 226 BRCMS_SROM_PA2GW2A2, 211 227 BRCMS_SROM_PA2GW2A3, 212 - BRCMS_SROM_PA2GW3A0, 213 - BRCMS_SROM_PA2GW3A1, 214 - BRCMS_SROM_PA2GW3A2, 215 - BRCMS_SROM_PA2GW3A3, 216 228 BRCMS_SROM_PA5GHW0A0, 217 229 BRCMS_SROM_PA5GHW0A1, 218 230 BRCMS_SROM_PA5GHW0A2, ··· 221 241 BRCMS_SROM_PA5GHW2A1, 222 242 BRCMS_SROM_PA5GHW2A2, 223 243 BRCMS_SROM_PA5GHW2A3, 224 - BRCMS_SROM_PA5GHW3A0, 225 - BRCMS_SROM_PA5GHW3A1, 226 - BRCMS_SROM_PA5GHW3A2, 227 - BRCMS_SROM_PA5GHW3A3, 228 244 BRCMS_SROM_PA5GLW0A0, 229 245 BRCMS_SROM_PA5GLW0A1, 230 246 BRCMS_SROM_PA5GLW0A2, ··· 233 257 BRCMS_SROM_PA5GLW2A1, 234 258 BRCMS_SROM_PA5GLW2A2, 235 259 BRCMS_SROM_PA5GLW2A3, 236 - BRCMS_SROM_PA5GLW3A0, 237 - BRCMS_SROM_PA5GLW3A1, 238 - BRCMS_SROM_PA5GLW3A2, 239 - BRCMS_SROM_PA5GLW3A3, 240 260 BRCMS_SROM_PA5GW0A0, 241 261 BRCMS_SROM_PA5GW0A1, 242 262 BRCMS_SROM_PA5GW0A2, ··· 245 273 BRCMS_SROM_PA5GW2A1, 246 274 BRCMS_SROM_PA5GW2A2, 247 275 BRCMS_SROM_PA5GW2A3, 248 - BRCMS_SROM_PA5GW3A0, 249 - BRCMS_SROM_PA5GW3A1, 250 - BRCMS_SROM_PA5GW3A2, 251 - BRCMS_SROM_PA5GW3A3, 252 276 }; 253 277 254 278 #define BRCMS_NUMRATES 16 /* max # of rates in a rateset */ 255 - #define D11_PHY_HDR_LEN 6 /* Phy header length - 6 bytes */ 256 279 257 280 /* phy types */ 258 281 #define PHY_TYPE_A 0 /* Phy type A */ ··· 381 414 uint _nbands; /* # bands supported */ 382 415 uint now; /* # elapsed seconds */ 383 416 384 - bool promisc; /* promiscuous destination address */ 385 417 bool delayed_down; /* down delayed */ 386 418 bool associated; /* true:part of [I]BSS, false: not */ 387 419 /* (union of stas_associated, aps_associated) */ ··· 538 572 extern uint brcms_c_down(struct brcms_c_info *wlc); 539 573 540 574 extern bool brcms_c_chipmatch(u16 vendor, u16 device); 541 - extern void brcms_c_init(struct brcms_c_info *wlc); 575 + extern void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx); 542 576 extern void brcms_c_reset(struct brcms_c_info *wlc); 543 577 544 578 extern void brcms_c_intrson(struct brcms_c_info *wlc); ··· 594 628 u8 interval); 595 629 extern int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr); 596 630 extern int brcms_c_get_tx_power(struct brcms_c_info *wlc); 597 - extern void brcms_c_set_radio_mpc(struct brcms_c_info *wlc, bool mpc); 598 631 extern bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc); 632 + extern void brcms_c_mute(struct brcms_c_info *wlc, bool on); 599 633 600 634 #endif /* _BRCM_PUB_H_ */
+2 -3
drivers/net/wireless/brcm80211/brcmsmac/rate.h
··· 19 19 20 20 #include "types.h" 21 21 #include "d11.h" 22 + #include "phy_hal.h" 22 23 23 24 extern const u8 rate_info[]; 24 25 extern const struct brcms_c_rateset cck_ofdm_mimo_rates; ··· 199 198 200 199 /* Convert encoded rate value in plcp header to numerical rates in 500 KHz 201 200 * increments */ 202 - extern const u8 ofdm_rate_lookup[]; 203 - 204 201 static inline u8 ofdm_phy2mac_rate(u8 rlpt) 205 202 { 206 - return ofdm_rate_lookup[rlpt & 0x7]; 203 + return wlc_phy_get_ofdm_rate_lookup()[rlpt & 0x7]; 207 204 } 208 205 209 206 static inline u8 cck_phy2mac_rate(u8 signal)
+77 -394
drivers/net/wireless/brcm80211/brcmsmac/srom.c
··· 28 28 #include "aiutils.h" 29 29 #include "otp.h" 30 30 #include "srom.h" 31 + #include "soc.h" 31 32 32 33 /* 33 34 * SROM CRC8 polynomial value: ··· 63 62 #define SROM_MACHI_ET1 42 64 63 #define SROM_MACMID_ET1 43 65 64 #define SROM_MACLO_ET1 44 66 - #define SROM3_MACHI 37 67 - #define SROM3_MACMID 38 68 - #define SROM3_MACLO 39 69 65 70 66 #define SROM_BXARSSI2G 40 71 67 #define SROM_BXARSSI5G 41 ··· 99 101 100 102 #define SROM_BFL 57 101 103 #define SROM_BFL2 28 102 - #define SROM3_BFL2 61 103 104 104 105 #define SROM_AG10 58 105 106 ··· 106 109 107 110 #define SROM_OPO 60 108 111 109 - #define SROM3_LEDDC 62 110 - 111 112 #define SROM_CRCREV 63 112 - 113 - /* SROM Rev 4: Reallocate the software part of the srom to accommodate 114 - * MIMO features. It assumes up to two PCIE functions and 440 bytes 115 - * of usable srom i.e. the usable storage in chips with OTP that 116 - * implements hardware redundancy. 117 - */ 118 113 119 114 #define SROM4_WORDS 220 120 115 121 - #define SROM4_SIGN 32 122 - #define SROM4_SIGNATURE 0x5372 123 - 124 - #define SROM4_BREV 33 125 - 126 - #define SROM4_BFL0 34 127 - #define SROM4_BFL1 35 128 - #define SROM4_BFL2 36 129 - #define SROM4_BFL3 37 130 - #define SROM5_BFL0 37 131 - #define SROM5_BFL1 38 132 - #define SROM5_BFL2 39 133 - #define SROM5_BFL3 40 134 - 135 - #define SROM4_MACHI 38 136 - #define SROM4_MACMID 39 137 - #define SROM4_MACLO 40 138 - #define SROM5_MACHI 41 139 - #define SROM5_MACMID 42 140 - #define SROM5_MACLO 43 141 - 142 - #define SROM4_CCODE 41 143 - #define SROM4_REGREV 42 144 - #define SROM5_CCODE 34 145 - #define SROM5_REGREV 35 146 - 147 - #define SROM4_LEDBH10 43 148 - #define SROM4_LEDBH32 44 149 - #define SROM5_LEDBH10 59 150 - #define SROM5_LEDBH32 60 151 - 152 - #define SROM4_LEDDC 45 153 - #define SROM5_LEDDC 45 154 - 155 - #define SROM4_AA 46 156 - 157 - #define SROM4_AG10 47 158 - #define SROM4_AG32 48 159 - 160 - #define SROM4_TXPID2G 49 161 - #define SROM4_TXPID5G 51 162 - #define SROM4_TXPID5GL 53 163 - #define SROM4_TXPID5GH 55 164 - 165 - #define SROM4_TXRXC 61 166 116 #define SROM4_TXCHAIN_MASK 0x000f 167 - #define SROM4_TXCHAIN_SHIFT 0 168 117 #define SROM4_RXCHAIN_MASK 0x00f0 169 - #define SROM4_RXCHAIN_SHIFT 4 170 118 #define SROM4_SWITCH_MASK 0xff00 171 - #define SROM4_SWITCH_SHIFT 8 172 119 173 120 /* Per-path fields */ 174 121 #define MAX_PATH_SROM 4 175 - #define SROM4_PATH0 64 176 - #define SROM4_PATH1 87 177 - #define SROM4_PATH2 110 178 - #define SROM4_PATH3 133 179 - 180 - #define SROM4_2G_ITT_MAXP 0 181 - #define SROM4_2G_PA 1 182 - #define SROM4_5G_ITT_MAXP 5 183 - #define SROM4_5GLH_MAXP 6 184 - #define SROM4_5G_PA 7 185 - #define SROM4_5GL_PA 11 186 - #define SROM4_5GH_PA 15 187 - 188 - /* All the miriad power offsets */ 189 - #define SROM4_2G_CCKPO 156 190 - #define SROM4_2G_OFDMPO 157 191 - #define SROM4_5G_OFDMPO 159 192 - #define SROM4_5GL_OFDMPO 161 193 - #define SROM4_5GH_OFDMPO 163 194 - #define SROM4_2G_MCSPO 165 195 - #define SROM4_5G_MCSPO 173 196 - #define SROM4_5GL_MCSPO 181 197 - #define SROM4_5GH_MCSPO 189 198 - #define SROM4_CDDPO 197 199 - #define SROM4_STBCPO 198 200 - #define SROM4_BW40PO 199 201 - #define SROM4_BWDUPPO 200 202 122 203 123 #define SROM4_CRCREV 219 204 124 ··· 338 424 static const struct brcms_sromvar pci_sromvars[] = { 339 425 {BRCMS_SROM_DEVID, 0xffffff00, SRFL_PRHEX | SRFL_NOVAR, PCI_F0DEVID, 340 426 0xffff}, 341 - {BRCMS_SROM_BOARDREV, 0x0000000e, SRFL_PRHEX, SROM_AABREV, 342 - SROM_BR_MASK}, 343 - {BRCMS_SROM_BOARDREV, 0x000000f0, SRFL_PRHEX, SROM4_BREV, 0xffff}, 344 427 {BRCMS_SROM_BOARDREV, 0xffffff00, SRFL_PRHEX, SROM8_BREV, 0xffff}, 345 - {BRCMS_SROM_BOARDFLAGS, 0x00000002, SRFL_PRHEX, SROM_BFL, 0xffff}, 346 - {BRCMS_SROM_BOARDFLAGS, 0x00000004, SRFL_PRHEX | SRFL_MORE, SROM_BFL, 347 - 0xffff}, 348 - {BRCMS_SROM_CONT, 0, 0, SROM_BFL2, 0xffff}, 349 - {BRCMS_SROM_BOARDFLAGS, 0x00000008, SRFL_PRHEX | SRFL_MORE, SROM_BFL, 350 - 0xffff}, 351 - {BRCMS_SROM_CONT, 0, 0, SROM3_BFL2, 0xffff}, 352 - {BRCMS_SROM_BOARDFLAGS, 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL0, 353 - 0xffff}, 354 - {BRCMS_SROM_CONT, 0, 0, SROM4_BFL1, 0xffff}, 355 - {BRCMS_SROM_BOARDFLAGS, 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL0, 356 - 0xffff}, 357 - {BRCMS_SROM_CONT, 0, 0, SROM5_BFL1, 0xffff}, 358 428 {BRCMS_SROM_BOARDFLAGS, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL0, 359 429 0xffff}, 360 430 {BRCMS_SROM_CONT, 0, 0, SROM8_BFL1, 0xffff}, 361 - {BRCMS_SROM_BOARDFLAGS2, 0x00000010, SRFL_PRHEX | SRFL_MORE, SROM4_BFL2, 362 - 0xffff}, 363 - {BRCMS_SROM_CONT, 0, 0, SROM4_BFL3, 0xffff}, 364 - {BRCMS_SROM_BOARDFLAGS2, 0x000000e0, SRFL_PRHEX | SRFL_MORE, SROM5_BFL2, 365 - 0xffff}, 366 - {BRCMS_SROM_CONT, 0, 0, SROM5_BFL3, 0xffff}, 367 431 {BRCMS_SROM_BOARDFLAGS2, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL2, 368 432 0xffff}, 369 433 {BRCMS_SROM_CONT, 0, 0, SROM8_BFL3, 0xffff}, 370 434 {BRCMS_SROM_BOARDTYPE, 0xfffffffc, SRFL_PRHEX, SROM_SSID, 0xffff}, 371 - {BRCMS_SROM_BOARDNUM, 0x00000006, 0, SROM_MACLO_IL0, 0xffff}, 372 - {BRCMS_SROM_BOARDNUM, 0x00000008, 0, SROM3_MACLO, 0xffff}, 373 - {BRCMS_SROM_BOARDNUM, 0x00000010, 0, SROM4_MACLO, 0xffff}, 374 - {BRCMS_SROM_BOARDNUM, 0x000000e0, 0, SROM5_MACLO, 0xffff}, 375 435 {BRCMS_SROM_BOARDNUM, 0xffffff00, 0, SROM8_MACLO, 0xffff}, 376 - {BRCMS_SROM_CC, 0x00000002, 0, SROM_AABREV, SROM_CC_MASK}, 377 - {BRCMS_SROM_REGREV, 0x00000008, 0, SROM_OPO, 0xff00}, 378 - {BRCMS_SROM_REGREV, 0x00000010, 0, SROM4_REGREV, 0x00ff}, 379 - {BRCMS_SROM_REGREV, 0x000000e0, 0, SROM5_REGREV, 0x00ff}, 380 436 {BRCMS_SROM_REGREV, 0xffffff00, 0, SROM8_REGREV, 0x00ff}, 381 - {BRCMS_SROM_LEDBH0, 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0x00ff}, 382 - {BRCMS_SROM_LEDBH1, 0x0000000e, SRFL_NOFFS, SROM_LEDBH10, 0xff00}, 383 - {BRCMS_SROM_LEDBH2, 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0x00ff}, 384 - {BRCMS_SROM_LEDBH3, 0x0000000e, SRFL_NOFFS, SROM_LEDBH32, 0xff00}, 385 - {BRCMS_SROM_LEDBH0, 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0x00ff}, 386 - {BRCMS_SROM_LEDBH1, 0x00000010, SRFL_NOFFS, SROM4_LEDBH10, 0xff00}, 387 - {BRCMS_SROM_LEDBH2, 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0x00ff}, 388 - {BRCMS_SROM_LEDBH3, 0x00000010, SRFL_NOFFS, SROM4_LEDBH32, 0xff00}, 389 - {BRCMS_SROM_LEDBH0, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0x00ff}, 390 - {BRCMS_SROM_LEDBH1, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH10, 0xff00}, 391 - {BRCMS_SROM_LEDBH2, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0x00ff}, 392 - {BRCMS_SROM_LEDBH3, 0x000000e0, SRFL_NOFFS, SROM5_LEDBH32, 0xff00}, 393 437 {BRCMS_SROM_LEDBH0, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0x00ff}, 394 438 {BRCMS_SROM_LEDBH1, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0xff00}, 395 439 {BRCMS_SROM_LEDBH2, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0x00ff}, 396 440 {BRCMS_SROM_LEDBH3, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0xff00}, 397 - {BRCMS_SROM_PA0B0, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB0, 0xffff}, 398 - {BRCMS_SROM_PA0B1, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB1, 0xffff}, 399 - {BRCMS_SROM_PA0B2, 0x0000000e, SRFL_PRHEX, SROM_WL0PAB2, 0xffff}, 400 - {BRCMS_SROM_PA0ITSSIT, 0x0000000e, 0, SROM_ITT, 0x00ff}, 401 - {BRCMS_SROM_PA0MAXPWR, 0x0000000e, 0, SROM_WL10MAXP, 0x00ff}, 402 441 {BRCMS_SROM_PA0B0, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB0, 0xffff}, 403 442 {BRCMS_SROM_PA0B1, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB1, 0xffff}, 404 443 {BRCMS_SROM_PA0B2, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB2, 0xffff}, 405 444 {BRCMS_SROM_PA0ITSSIT, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0xff00}, 406 445 {BRCMS_SROM_PA0MAXPWR, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0x00ff}, 407 - {BRCMS_SROM_OPO, 0x0000000c, 0, SROM_OPO, 0x00ff}, 408 446 {BRCMS_SROM_OPO, 0xffffff00, 0, SROM8_2G_OFDMPO, 0x00ff}, 409 - {BRCMS_SROM_AA2G, 0x0000000e, 0, SROM_AABREV, SROM_AA0_MASK}, 410 - {BRCMS_SROM_AA2G, 0x000000f0, 0, SROM4_AA, 0x00ff}, 411 447 {BRCMS_SROM_AA2G, 0xffffff00, 0, SROM8_AA, 0x00ff}, 412 - {BRCMS_SROM_AA5G, 0x0000000e, 0, SROM_AABREV, SROM_AA1_MASK}, 413 - {BRCMS_SROM_AA5G, 0x000000f0, 0, SROM4_AA, 0xff00}, 414 448 {BRCMS_SROM_AA5G, 0xffffff00, 0, SROM8_AA, 0xff00}, 415 - {BRCMS_SROM_AG0, 0x0000000e, 0, SROM_AG10, 0x00ff}, 416 - {BRCMS_SROM_AG1, 0x0000000e, 0, SROM_AG10, 0xff00}, 417 - {BRCMS_SROM_AG0, 0x000000f0, 0, SROM4_AG10, 0x00ff}, 418 - {BRCMS_SROM_AG1, 0x000000f0, 0, SROM4_AG10, 0xff00}, 419 - {BRCMS_SROM_AG2, 0x000000f0, 0, SROM4_AG32, 0x00ff}, 420 - {BRCMS_SROM_AG3, 0x000000f0, 0, SROM4_AG32, 0xff00}, 421 449 {BRCMS_SROM_AG0, 0xffffff00, 0, SROM8_AG10, 0x00ff}, 422 450 {BRCMS_SROM_AG1, 0xffffff00, 0, SROM8_AG10, 0xff00}, 423 451 {BRCMS_SROM_AG2, 0xffffff00, 0, SROM8_AG32, 0x00ff}, 424 452 {BRCMS_SROM_AG3, 0xffffff00, 0, SROM8_AG32, 0xff00}, 425 - {BRCMS_SROM_PA1B0, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB0, 0xffff}, 426 - {BRCMS_SROM_PA1B1, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB1, 0xffff}, 427 - {BRCMS_SROM_PA1B2, 0x0000000e, SRFL_PRHEX, SROM_WL1PAB2, 0xffff}, 428 - {BRCMS_SROM_PA1LOB0, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB0, 0xffff}, 429 - {BRCMS_SROM_PA1LOB1, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB1, 0xffff}, 430 - {BRCMS_SROM_PA1LOB2, 0x0000000c, SRFL_PRHEX, SROM_WL1LPAB2, 0xffff}, 431 - {BRCMS_SROM_PA1HIB0, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB0, 0xffff}, 432 - {BRCMS_SROM_PA1HIB1, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB1, 0xffff}, 433 - {BRCMS_SROM_PA1HIB2, 0x0000000c, SRFL_PRHEX, SROM_WL1HPAB2, 0xffff}, 434 - {BRCMS_SROM_PA1ITSSIT, 0x0000000e, 0, SROM_ITT, 0xff00}, 435 - {BRCMS_SROM_PA1MAXPWR, 0x0000000e, 0, SROM_WL10MAXP, 0xff00}, 436 - {BRCMS_SROM_PA1LOMAXPWR, 0x0000000c, 0, SROM_WL1LHMAXP, 0xff00}, 437 - {BRCMS_SROM_PA1HIMAXPWR, 0x0000000c, 0, SROM_WL1LHMAXP, 0x00ff}, 438 453 {BRCMS_SROM_PA1B0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0, 0xffff}, 439 454 {BRCMS_SROM_PA1B1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1, 0xffff}, 440 455 {BRCMS_SROM_PA1B2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2, 0xffff}, ··· 377 534 {BRCMS_SROM_PA1MAXPWR, 0xffffff00, 0, SROM8_W1_ITTMAXP, 0x00ff}, 378 535 {BRCMS_SROM_PA1LOMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0xff00}, 379 536 {BRCMS_SROM_PA1HIMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0x00ff}, 380 - {BRCMS_SROM_BXA2G, 0x00000008, 0, SROM_BXARSSI2G, 0x1800}, 381 - {BRCMS_SROM_RSSISAV2G, 0x00000008, 0, SROM_BXARSSI2G, 0x0700}, 382 - {BRCMS_SROM_RSSISMC2G, 0x00000008, 0, SROM_BXARSSI2G, 0x00f0}, 383 - {BRCMS_SROM_RSSISMF2G, 0x00000008, 0, SROM_BXARSSI2G, 0x000f}, 384 537 {BRCMS_SROM_BXA2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x1800}, 385 538 {BRCMS_SROM_RSSISAV2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x0700}, 386 539 {BRCMS_SROM_RSSISMC2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x00f0}, 387 540 {BRCMS_SROM_RSSISMF2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x000f}, 388 - {BRCMS_SROM_BXA5G, 0x00000008, 0, SROM_BXARSSI5G, 0x1800}, 389 - {BRCMS_SROM_RSSISAV5G, 0x00000008, 0, SROM_BXARSSI5G, 0x0700}, 390 - {BRCMS_SROM_RSSISMC5G, 0x00000008, 0, SROM_BXARSSI5G, 0x00f0}, 391 - {BRCMS_SROM_RSSISMF5G, 0x00000008, 0, SROM_BXARSSI5G, 0x000f}, 392 541 {BRCMS_SROM_BXA5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x1800}, 393 542 {BRCMS_SROM_RSSISAV5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x0700}, 394 543 {BRCMS_SROM_RSSISMC5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x00f0}, 395 544 {BRCMS_SROM_RSSISMF5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x000f}, 396 - {BRCMS_SROM_TRI2G, 0x00000008, 0, SROM_TRI52G, 0x00ff}, 397 - {BRCMS_SROM_TRI5G, 0x00000008, 0, SROM_TRI52G, 0xff00}, 398 - {BRCMS_SROM_TRI5GL, 0x00000008, 0, SROM_TRI5GHL, 0x00ff}, 399 - {BRCMS_SROM_TRI5GH, 0x00000008, 0, SROM_TRI5GHL, 0xff00}, 400 545 {BRCMS_SROM_TRI2G, 0xffffff00, 0, SROM8_TRI52G, 0x00ff}, 401 546 {BRCMS_SROM_TRI5G, 0xffffff00, 0, SROM8_TRI52G, 0xff00}, 402 547 {BRCMS_SROM_TRI5GL, 0xffffff00, 0, SROM8_TRI5GHL, 0x00ff}, 403 548 {BRCMS_SROM_TRI5GH, 0xffffff00, 0, SROM8_TRI5GHL, 0xff00}, 404 - {BRCMS_SROM_RXPO2G, 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0x00ff}, 405 - {BRCMS_SROM_RXPO5G, 0x00000008, SRFL_PRSIGN, SROM_RXPO52G, 0xff00}, 406 549 {BRCMS_SROM_RXPO2G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0x00ff}, 407 550 {BRCMS_SROM_RXPO5G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0xff00}, 408 - {BRCMS_SROM_TXCHAIN, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, 409 - SROM4_TXCHAIN_MASK}, 410 - {BRCMS_SROM_RXCHAIN, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, 411 - SROM4_RXCHAIN_MASK}, 412 - {BRCMS_SROM_ANTSWITCH, 0x000000f0, SRFL_NOFFS, SROM4_TXRXC, 413 - SROM4_SWITCH_MASK}, 414 551 {BRCMS_SROM_TXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, 415 552 SROM4_TXCHAIN_MASK}, 416 553 {BRCMS_SROM_RXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC, ··· 417 594 SROM8_FEM_ANTSWLUT_MASK}, 418 595 {BRCMS_SROM_TEMPTHRESH, 0xffffff00, 0, SROM8_THERMAL, 0xff00}, 419 596 {BRCMS_SROM_TEMPOFFSET, 0xffffff00, 0, SROM8_THERMAL, 0x00ff}, 420 - {BRCMS_SROM_TXPID2GA0, 0x000000f0, 0, SROM4_TXPID2G, 0x00ff}, 421 - {BRCMS_SROM_TXPID2GA1, 0x000000f0, 0, SROM4_TXPID2G, 0xff00}, 422 - {BRCMS_SROM_TXPID2GA2, 0x000000f0, 0, SROM4_TXPID2G + 1, 0x00ff}, 423 - {BRCMS_SROM_TXPID2GA3, 0x000000f0, 0, SROM4_TXPID2G + 1, 0xff00}, 424 - {BRCMS_SROM_TXPID5GA0, 0x000000f0, 0, SROM4_TXPID5G, 0x00ff}, 425 - {BRCMS_SROM_TXPID5GA1, 0x000000f0, 0, SROM4_TXPID5G, 0xff00}, 426 - {BRCMS_SROM_TXPID5GA2, 0x000000f0, 0, SROM4_TXPID5G + 1, 0x00ff}, 427 - {BRCMS_SROM_TXPID5GA3, 0x000000f0, 0, SROM4_TXPID5G + 1, 0xff00}, 428 - {BRCMS_SROM_TXPID5GLA0, 0x000000f0, 0, SROM4_TXPID5GL, 0x00ff}, 429 - {BRCMS_SROM_TXPID5GLA1, 0x000000f0, 0, SROM4_TXPID5GL, 0xff00}, 430 - {BRCMS_SROM_TXPID5GLA2, 0x000000f0, 0, SROM4_TXPID5GL + 1, 0x00ff}, 431 - {BRCMS_SROM_TXPID5GLA3, 0x000000f0, 0, SROM4_TXPID5GL + 1, 0xff00}, 432 - {BRCMS_SROM_TXPID5GHA0, 0x000000f0, 0, SROM4_TXPID5GH, 0x00ff}, 433 - {BRCMS_SROM_TXPID5GHA1, 0x000000f0, 0, SROM4_TXPID5GH, 0xff00}, 434 - {BRCMS_SROM_TXPID5GHA2, 0x000000f0, 0, SROM4_TXPID5GH + 1, 0x00ff}, 435 - {BRCMS_SROM_TXPID5GHA3, 0x000000f0, 0, SROM4_TXPID5GH + 1, 0xff00}, 436 597 437 - {BRCMS_SROM_CCODE, 0x0000000f, SRFL_CCODE, SROM_CCODE, 0xffff}, 438 - {BRCMS_SROM_CCODE, 0x00000010, SRFL_CCODE, SROM4_CCODE, 0xffff}, 439 - {BRCMS_SROM_CCODE, 0x000000e0, SRFL_CCODE, SROM5_CCODE, 0xffff}, 440 598 {BRCMS_SROM_CCODE, 0xffffff00, SRFL_CCODE, SROM8_CCODE, 0xffff}, 441 599 {BRCMS_SROM_MACADDR, 0xffffff00, SRFL_ETHADDR, SROM8_MACHI, 0xffff}, 442 - {BRCMS_SROM_MACADDR, 0x000000e0, SRFL_ETHADDR, SROM5_MACHI, 0xffff}, 443 - {BRCMS_SROM_MACADDR, 0x00000010, SRFL_ETHADDR, SROM4_MACHI, 0xffff}, 444 - {BRCMS_SROM_MACADDR, 0x00000008, SRFL_ETHADDR, SROM3_MACHI, 0xffff}, 445 - {BRCMS_SROM_IL0MACADDR, 0x00000007, SRFL_ETHADDR, SROM_MACHI_IL0, 446 - 0xffff}, 447 - {BRCMS_SROM_ET1MACADDR, 0x00000007, SRFL_ETHADDR, SROM_MACHI_ET1, 448 - 0xffff}, 449 600 {BRCMS_SROM_LEDDC, 0xffffff00, SRFL_NOFFS | SRFL_LEDDC, SROM8_LEDDC, 450 - 0xffff}, 451 - {BRCMS_SROM_LEDDC, 0x000000e0, SRFL_NOFFS | SRFL_LEDDC, SROM5_LEDDC, 452 - 0xffff}, 453 - {BRCMS_SROM_LEDDC, 0x00000010, SRFL_NOFFS | SRFL_LEDDC, SROM4_LEDDC, 454 - 0xffff}, 455 - {BRCMS_SROM_LEDDC, 0x00000008, SRFL_NOFFS | SRFL_LEDDC, SROM3_LEDDC, 456 601 0xffff}, 457 602 {BRCMS_SROM_RAWTEMPSENSE, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS, 458 603 0x01ff}, ··· 441 650 {BRCMS_SROM_PHYCAL_TEMPDELTA, 0xffffff00, 0, SROM8_PHYCAL_TEMPDELTA, 442 651 0x00ff}, 443 652 444 - {BRCMS_SROM_CCK2GPO, 0x000000f0, 0, SROM4_2G_CCKPO, 0xffff}, 445 653 {BRCMS_SROM_CCK2GPO, 0x00000100, 0, SROM8_2G_CCKPO, 0xffff}, 446 - {BRCMS_SROM_OFDM2GPO, 0x000000f0, SRFL_MORE, SROM4_2G_OFDMPO, 0xffff}, 447 - {BRCMS_SROM_CONT, 0, 0, SROM4_2G_OFDMPO + 1, 0xffff}, 448 - {BRCMS_SROM_OFDM5GPO, 0x000000f0, SRFL_MORE, SROM4_5G_OFDMPO, 0xffff}, 449 - {BRCMS_SROM_CONT, 0, 0, SROM4_5G_OFDMPO + 1, 0xffff}, 450 - {BRCMS_SROM_OFDM5GLPO, 0x000000f0, SRFL_MORE, SROM4_5GL_OFDMPO, 0xffff}, 451 - {BRCMS_SROM_CONT, 0, 0, SROM4_5GL_OFDMPO + 1, 0xffff}, 452 - {BRCMS_SROM_OFDM5GHPO, 0x000000f0, SRFL_MORE, SROM4_5GH_OFDMPO, 0xffff}, 453 - {BRCMS_SROM_CONT, 0, 0, SROM4_5GH_OFDMPO + 1, 0xffff}, 454 654 {BRCMS_SROM_OFDM2GPO, 0x00000100, SRFL_MORE, SROM8_2G_OFDMPO, 0xffff}, 455 655 {BRCMS_SROM_CONT, 0, 0, SROM8_2G_OFDMPO + 1, 0xffff}, 456 656 {BRCMS_SROM_OFDM5GPO, 0x00000100, SRFL_MORE, SROM8_5G_OFDMPO, 0xffff}, ··· 450 668 {BRCMS_SROM_CONT, 0, 0, SROM8_5GL_OFDMPO + 1, 0xffff}, 451 669 {BRCMS_SROM_OFDM5GHPO, 0x00000100, SRFL_MORE, SROM8_5GH_OFDMPO, 0xffff}, 452 670 {BRCMS_SROM_CONT, 0, 0, SROM8_5GH_OFDMPO + 1, 0xffff}, 453 - {BRCMS_SROM_MCS2GPO0, 0x000000f0, 0, SROM4_2G_MCSPO, 0xffff}, 454 - {BRCMS_SROM_MCS2GPO1, 0x000000f0, 0, SROM4_2G_MCSPO + 1, 0xffff}, 455 - {BRCMS_SROM_MCS2GPO2, 0x000000f0, 0, SROM4_2G_MCSPO + 2, 0xffff}, 456 - {BRCMS_SROM_MCS2GPO3, 0x000000f0, 0, SROM4_2G_MCSPO + 3, 0xffff}, 457 - {BRCMS_SROM_MCS2GPO4, 0x000000f0, 0, SROM4_2G_MCSPO + 4, 0xffff}, 458 - {BRCMS_SROM_MCS2GPO5, 0x000000f0, 0, SROM4_2G_MCSPO + 5, 0xffff}, 459 - {BRCMS_SROM_MCS2GPO6, 0x000000f0, 0, SROM4_2G_MCSPO + 6, 0xffff}, 460 - {BRCMS_SROM_MCS2GPO7, 0x000000f0, 0, SROM4_2G_MCSPO + 7, 0xffff}, 461 - {BRCMS_SROM_MCS5GPO0, 0x000000f0, 0, SROM4_5G_MCSPO, 0xffff}, 462 - {BRCMS_SROM_MCS5GPO1, 0x000000f0, 0, SROM4_5G_MCSPO + 1, 0xffff}, 463 - {BRCMS_SROM_MCS5GPO2, 0x000000f0, 0, SROM4_5G_MCSPO + 2, 0xffff}, 464 - {BRCMS_SROM_MCS5GPO3, 0x000000f0, 0, SROM4_5G_MCSPO + 3, 0xffff}, 465 - {BRCMS_SROM_MCS5GPO4, 0x000000f0, 0, SROM4_5G_MCSPO + 4, 0xffff}, 466 - {BRCMS_SROM_MCS5GPO5, 0x000000f0, 0, SROM4_5G_MCSPO + 5, 0xffff}, 467 - {BRCMS_SROM_MCS5GPO6, 0x000000f0, 0, SROM4_5G_MCSPO + 6, 0xffff}, 468 - {BRCMS_SROM_MCS5GPO7, 0x000000f0, 0, SROM4_5G_MCSPO + 7, 0xffff}, 469 - {BRCMS_SROM_MCS5GLPO0, 0x000000f0, 0, SROM4_5GL_MCSPO, 0xffff}, 470 - {BRCMS_SROM_MCS5GLPO1, 0x000000f0, 0, SROM4_5GL_MCSPO + 1, 0xffff}, 471 - {BRCMS_SROM_MCS5GLPO2, 0x000000f0, 0, SROM4_5GL_MCSPO + 2, 0xffff}, 472 - {BRCMS_SROM_MCS5GLPO3, 0x000000f0, 0, SROM4_5GL_MCSPO + 3, 0xffff}, 473 - {BRCMS_SROM_MCS5GLPO4, 0x000000f0, 0, SROM4_5GL_MCSPO + 4, 0xffff}, 474 - {BRCMS_SROM_MCS5GLPO5, 0x000000f0, 0, SROM4_5GL_MCSPO + 5, 0xffff}, 475 - {BRCMS_SROM_MCS5GLPO6, 0x000000f0, 0, SROM4_5GL_MCSPO + 6, 0xffff}, 476 - {BRCMS_SROM_MCS5GLPO7, 0x000000f0, 0, SROM4_5GL_MCSPO + 7, 0xffff}, 477 - {BRCMS_SROM_MCS5GHPO0, 0x000000f0, 0, SROM4_5GH_MCSPO, 0xffff}, 478 - {BRCMS_SROM_MCS5GHPO1, 0x000000f0, 0, SROM4_5GH_MCSPO + 1, 0xffff}, 479 - {BRCMS_SROM_MCS5GHPO2, 0x000000f0, 0, SROM4_5GH_MCSPO + 2, 0xffff}, 480 - {BRCMS_SROM_MCS5GHPO3, 0x000000f0, 0, SROM4_5GH_MCSPO + 3, 0xffff}, 481 - {BRCMS_SROM_MCS5GHPO4, 0x000000f0, 0, SROM4_5GH_MCSPO + 4, 0xffff}, 482 - {BRCMS_SROM_MCS5GHPO5, 0x000000f0, 0, SROM4_5GH_MCSPO + 5, 0xffff}, 483 - {BRCMS_SROM_MCS5GHPO6, 0x000000f0, 0, SROM4_5GH_MCSPO + 6, 0xffff}, 484 - {BRCMS_SROM_MCS5GHPO7, 0x000000f0, 0, SROM4_5GH_MCSPO + 7, 0xffff}, 485 671 {BRCMS_SROM_MCS2GPO0, 0x00000100, 0, SROM8_2G_MCSPO, 0xffff}, 486 672 {BRCMS_SROM_MCS2GPO1, 0x00000100, 0, SROM8_2G_MCSPO + 1, 0xffff}, 487 673 {BRCMS_SROM_MCS2GPO2, 0x00000100, 0, SROM8_2G_MCSPO + 2, 0xffff}, ··· 482 732 {BRCMS_SROM_MCS5GHPO5, 0x00000100, 0, SROM8_5GH_MCSPO + 5, 0xffff}, 483 733 {BRCMS_SROM_MCS5GHPO6, 0x00000100, 0, SROM8_5GH_MCSPO + 6, 0xffff}, 484 734 {BRCMS_SROM_MCS5GHPO7, 0x00000100, 0, SROM8_5GH_MCSPO + 7, 0xffff}, 485 - {BRCMS_SROM_CDDPO, 0x000000f0, 0, SROM4_CDDPO, 0xffff}, 486 - {BRCMS_SROM_STBCPO, 0x000000f0, 0, SROM4_STBCPO, 0xffff}, 487 - {BRCMS_SROM_BW40PO, 0x000000f0, 0, SROM4_BW40PO, 0xffff}, 488 - {BRCMS_SROM_BWDUPPO, 0x000000f0, 0, SROM4_BWDUPPO, 0xffff}, 489 735 {BRCMS_SROM_CDDPO, 0x00000100, 0, SROM8_CDDPO, 0xffff}, 490 736 {BRCMS_SROM_STBCPO, 0x00000100, 0, SROM8_STBCPO, 0xffff}, 491 737 {BRCMS_SROM_BW40PO, 0x00000100, 0, SROM8_BW40PO, 0xffff}, ··· 557 811 }; 558 812 559 813 static const struct brcms_sromvar perpath_pci_sromvars[] = { 560 - {BRCMS_SROM_MAXP2GA0, 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0x00ff}, 561 - {BRCMS_SROM_ITT2GA0, 0x000000f0, 0, SROM4_2G_ITT_MAXP, 0xff00}, 562 - {BRCMS_SROM_ITT5GA0, 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0xff00}, 563 - {BRCMS_SROM_PA2GW0A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA, 0xffff}, 564 - {BRCMS_SROM_PA2GW1A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 1, 0xffff}, 565 - {BRCMS_SROM_PA2GW2A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 2, 0xffff}, 566 - {BRCMS_SROM_PA2GW3A0, 0x000000f0, SRFL_PRHEX, SROM4_2G_PA + 3, 0xffff}, 567 - {BRCMS_SROM_MAXP5GA0, 0x000000f0, 0, SROM4_5G_ITT_MAXP, 0x00ff}, 568 - {BRCMS_SROM_MAXP5GHA0, 0x000000f0, 0, SROM4_5GLH_MAXP, 0x00ff}, 569 - {BRCMS_SROM_MAXP5GLA0, 0x000000f0, 0, SROM4_5GLH_MAXP, 0xff00}, 570 - {BRCMS_SROM_PA5GW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA, 0xffff}, 571 - {BRCMS_SROM_PA5GW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 1, 0xffff}, 572 - {BRCMS_SROM_PA5GW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 2, 0xffff}, 573 - {BRCMS_SROM_PA5GW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5G_PA + 3, 0xffff}, 574 - {BRCMS_SROM_PA5GLW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA, 0xffff}, 575 - {BRCMS_SROM_PA5GLW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 1, 576 - 0xffff}, 577 - {BRCMS_SROM_PA5GLW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 2, 578 - 0xffff}, 579 - {BRCMS_SROM_PA5GLW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5GL_PA + 3, 580 - 0xffff}, 581 - {BRCMS_SROM_PA5GHW0A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA, 0xffff}, 582 - {BRCMS_SROM_PA5GHW1A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 1, 583 - 0xffff}, 584 - {BRCMS_SROM_PA5GHW2A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 2, 585 - 0xffff}, 586 - {BRCMS_SROM_PA5GHW3A0, 0x000000f0, SRFL_PRHEX, SROM4_5GH_PA + 3, 587 - 0xffff}, 588 814 {BRCMS_SROM_MAXP2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0x00ff}, 589 815 {BRCMS_SROM_ITT2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0xff00}, 590 816 {BRCMS_SROM_ITT5GA0, 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0xff00}, ··· 586 868 * shared between devices. */ 587 869 static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; 588 870 589 - static u16 __iomem * 871 + static u8 __iomem * 590 872 srom_window_address(struct si_pub *sih, u8 __iomem *curmap) 591 873 { 592 874 if (sih->ccrev < 32) 593 - return (u16 __iomem *)(curmap + PCI_BAR0_SPROM_OFFSET); 875 + return curmap + PCI_BAR0_SPROM_OFFSET; 594 876 if (sih->cccaps & CC_CAP_SROM) 595 - return (u16 __iomem *) 596 - (curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP); 877 + return curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP; 597 878 598 879 return NULL; 599 880 } 600 - 601 - /* Parse SROM and create name=value pairs. 'srom' points to 602 - * the SROM word array. 'off' specifies the offset of the 603 - * first word 'srom' points to, which should be either 0 or 604 - * SROM3_SWRG_OFF (full SROM or software region). 605 - */ 606 881 607 882 static uint mask_shift(u16 mask) 608 883 { ··· 617 906 return 0; 618 907 } 619 908 620 - static inline void ltoh16_buf(u16 *buf, unsigned int size) 909 + static inline void le16_to_cpu_buf(u16 *buf, uint nwords) 621 910 { 622 - size /= 2; 623 - while (size--) 624 - *(buf + size) = le16_to_cpu(*(__le16 *)(buf + size)); 911 + while (nwords--) 912 + *(buf + nwords) = le16_to_cpu(*(__le16 *)(buf + nwords)); 625 913 } 626 914 627 - static inline void htol16_buf(u16 *buf, unsigned int size) 915 + static inline void cpu_to_le16_buf(u16 *buf, uint nwords) 628 916 { 629 - size /= 2; 630 - while (size--) 631 - *(__le16 *)(buf + size) = cpu_to_le16(*(buf + size)); 917 + while (nwords--) 918 + *(__le16 *)(buf + nwords) = cpu_to_le16(*(buf + nwords)); 632 919 } 633 920 634 921 /* ··· 638 929 struct brcms_srom_list_head *entry; 639 930 enum brcms_srom_id id; 640 931 u16 w; 641 - u32 val; 932 + u32 val = 0; 642 933 const struct brcms_sromvar *srv; 643 934 uint width; 644 935 uint flags; 645 936 u32 sr = (1 << sromrev); 937 + uint p; 938 + uint pb = SROM8_PATH0; 939 + const uint psz = SROM8_PATH1 - SROM8_PATH0; 646 940 647 941 /* first store the srom revision */ 648 942 entry = kzalloc(sizeof(struct brcms_srom_list_head), GFP_KERNEL); ··· 743 1031 list_add(&entry->var_list, var_list); 744 1032 } 745 1033 746 - if (sromrev >= 4) { 747 - /* Do per-path variables */ 748 - uint p, pb, psz; 1034 + for (p = 0; p < MAX_PATH_SROM; p++) { 1035 + for (srv = perpath_pci_sromvars; 1036 + srv->varid != BRCMS_SROM_NULL; srv++) { 1037 + if ((srv->revmask & sr) == 0) 1038 + continue; 749 1039 750 - if (sromrev >= 8) { 751 - pb = SROM8_PATH0; 752 - psz = SROM8_PATH1 - SROM8_PATH0; 753 - } else { 754 - pb = SROM4_PATH0; 755 - psz = SROM4_PATH1 - SROM4_PATH0; 1040 + if (srv->flags & SRFL_NOVAR) 1041 + continue; 1042 + 1043 + w = srom[pb + srv->off]; 1044 + val = (w & srv->mask) >> mask_shift(srv->mask); 1045 + width = mask_width(srv->mask); 1046 + 1047 + /* Cheating: no per-path var is more than 1048 + * 1 word */ 1049 + if ((srv->flags & SRFL_NOFFS) 1050 + && ((int)val == (1 << width) - 1)) 1051 + continue; 1052 + 1053 + entry = 1054 + kzalloc(sizeof(struct brcms_srom_list_head), 1055 + GFP_KERNEL); 1056 + entry->varid = srv->varid+p; 1057 + entry->var_type = BRCMS_SROM_UNUMBER; 1058 + entry->uval = val; 1059 + list_add(&entry->var_list, var_list); 756 1060 } 757 - 758 - for (p = 0; p < MAX_PATH_SROM; p++) { 759 - for (srv = perpath_pci_sromvars; 760 - srv->varid != BRCMS_SROM_NULL; srv++) { 761 - if ((srv->revmask & sr) == 0) 762 - continue; 763 - 764 - if (srv->flags & SRFL_NOVAR) 765 - continue; 766 - 767 - w = srom[pb + srv->off]; 768 - val = (w & srv->mask) >> mask_shift(srv->mask); 769 - width = mask_width(srv->mask); 770 - 771 - /* Cheating: no per-path var is more than 772 - * 1 word */ 773 - if ((srv->flags & SRFL_NOFFS) 774 - && ((int)val == (1 << width) - 1)) 775 - continue; 776 - 777 - entry = 778 - kzalloc(sizeof(struct brcms_srom_list_head), 779 - GFP_KERNEL); 780 - entry->varid = srv->varid+p; 781 - entry->var_type = BRCMS_SROM_UNUMBER; 782 - entry->uval = val; 783 - list_add(&entry->var_list, var_list); 784 - } 785 - pb += psz; 786 - } 1061 + pb += psz; 787 1062 } 788 1063 } 789 1064 ··· 779 1080 * Return 0 on success, nonzero on error. 780 1081 */ 781 1082 static int 782 - sprom_read_pci(struct si_pub *sih, u16 __iomem *sprom, uint wordoff, 1083 + sprom_read_pci(struct si_pub *sih, u8 __iomem *sprom, uint wordoff, 783 1084 u16 *buf, uint nwords, bool check_crc) 784 1085 { 785 1086 int err = 0; 786 1087 uint i; 1088 + u8 *bbuf = (u8 *)buf; /* byte buffer */ 1089 + uint nbytes = nwords << 1; 787 1090 788 - /* read the sprom */ 789 - for (i = 0; i < nwords; i++) 790 - buf[i] = R_REG(&sprom[wordoff + i]); 1091 + /* read the sprom in bytes */ 1092 + for (i = 0; i < nbytes; i++) 1093 + bbuf[i] = readb(sprom+i); 791 1094 792 - if (check_crc) { 1095 + if (buf[0] == 0xffff) 1096 + /* 1097 + * The hardware thinks that an srom that starts with 1098 + * 0xffff is blank, regardless of the rest of the 1099 + * content, so declare it bad. 1100 + */ 1101 + return -ENODATA; 793 1102 794 - if (buf[0] == 0xffff) 795 - /* 796 - * The hardware thinks that an srom that starts with 797 - * 0xffff is blank, regardless of the rest of the 798 - * content, so declare it bad. 799 - */ 800 - return -ENODATA; 801 - 802 - /* fixup the endianness so crc8 will pass */ 803 - htol16_buf(buf, nwords * 2); 804 - if (crc8(brcms_srom_crc8_table, (u8 *) buf, nwords * 2, 805 - CRC8_INIT_VALUE) != 806 - CRC8_GOOD_VALUE(brcms_srom_crc8_table)) 807 - /* DBG only pci always read srom4 first, then srom8/9 */ 808 - err = -EIO; 809 - 1103 + if (check_crc && 1104 + crc8(brcms_srom_crc8_table, bbuf, nbytes, CRC8_INIT_VALUE) != 1105 + CRC8_GOOD_VALUE(brcms_srom_crc8_table)) 1106 + err = -EIO; 1107 + else 810 1108 /* now correct the endianness of the byte array */ 811 - ltoh16_buf(buf, nwords * 2); 812 - } 1109 + le16_to_cpu_buf(buf, nwords); 1110 + 813 1111 return err; 814 1112 } 815 1113 816 - static int otp_read_pci(struct si_pub *sih, u16 *buf, uint bufsz) 1114 + static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords) 817 1115 { 818 1116 u8 *otp; 819 1117 uint sz = OTP_SZ_MAX / 2; /* size in words */ ··· 822 1126 823 1127 err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz); 824 1128 825 - memcpy(buf, otp, bufsz); 1129 + sz = min_t(uint, sz, nwords); 1130 + memcpy(buf, otp, sz * 2); 826 1131 827 1132 kfree(otp); 828 1133 ··· 836 1139 return -ENODATA; 837 1140 838 1141 /* fixup the endianness so crc8 will pass */ 839 - htol16_buf(buf, bufsz); 840 - if (crc8(brcms_srom_crc8_table, (u8 *) buf, SROM4_WORDS * 2, 1142 + cpu_to_le16_buf(buf, sz); 1143 + if (crc8(brcms_srom_crc8_table, (u8 *) buf, sz * 2, 841 1144 CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table)) 842 1145 err = -EIO; 843 - 844 - /* now correct the endianness of the byte array */ 845 - ltoh16_buf(buf, bufsz); 1146 + else 1147 + /* now correct the endianness of the byte array */ 1148 + le16_to_cpu_buf(buf, sz); 846 1149 847 1150 return err; 848 1151 } ··· 854 1157 static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) 855 1158 { 856 1159 u16 *srom; 857 - u16 __iomem *sromwindow; 1160 + u8 __iomem *sromwindow; 858 1161 u8 sromrev = 0; 859 1162 u32 sr; 860 1163 int err = 0; ··· 870 1173 871 1174 crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY); 872 1175 if (ai_is_sprom_available(sih)) { 873 - err = sprom_read_pci(sih, sromwindow, 0, srom, SROM_WORDS, 874 - true); 1176 + err = sprom_read_pci(sih, sromwindow, 0, srom, 1177 + SROM4_WORDS, true); 875 1178 876 - if ((srom[SROM4_SIGN] == SROM4_SIGNATURE) || 877 - (((sih->buscoretype == PCIE_CORE_ID) 878 - && (sih->buscorerev >= 6)) 879 - || ((sih->buscoretype == PCI_CORE_ID) 880 - && (sih->buscorerev >= 0xe)))) { 881 - /* sromrev >= 4, read more */ 882 - err = sprom_read_pci(sih, sromwindow, 0, srom, 883 - SROM4_WORDS, true); 884 - sromrev = srom[SROM4_CRCREV] & 0xff; 885 - } else if (err == 0) { 886 - /* srom is good and is rev < 4 */ 1179 + if (err == 0) 1180 + /* srom read and passed crc */ 887 1181 /* top word of sprom contains version and crc8 */ 888 - sromrev = srom[SROM_CRCREV] & 0xff; 889 - /* bcm4401 sroms misprogrammed */ 890 - if (sromrev == 0x10) 891 - sromrev = 1; 892 - } 1182 + sromrev = srom[SROM4_CRCREV] & 0xff; 893 1183 } else { 894 1184 /* Use OTP if SPROM not available */ 895 - err = otp_read_pci(sih, srom, SROM_MAX); 1185 + err = otp_read_pci(sih, srom, SROM4_WORDS); 896 1186 if (err == 0) 897 1187 /* OTP only contain SROM rev8/rev9 for now */ 898 1188 sromrev = srom[SROM4_CRCREV] & 0xff; ··· 892 1208 sr = 1 << sromrev; 893 1209 894 1210 /* 895 - * srom version check: Current valid versions: 1, 2, 3, 4, 5, 8, 896 - * 9 1211 + * srom version check: Current valid versions: 8, 9 897 1212 */ 898 - if ((sr & 0x33e) == 0) { 1213 + if ((sr & 0x300) == 0) { 899 1214 err = -EINVAL; 900 1215 goto errout; 901 1216 }
-5
drivers/net/wireless/brcm80211/brcmsmac/srom.h
··· 26 26 extern int srom_read(struct si_pub *sih, uint bus, void *curmap, 27 27 uint byteoff, uint nbytes, u16 *buf, bool check_crc); 28 28 29 - /* parse standard PCMCIA cis, normally used by SB/PCMCIA/SDIO/SPI/OTP 30 - * and extract from it into name=value pairs 31 - */ 32 - extern int srom_parsecis(u8 **pcis, uint ciscnt, 33 - char **vars, uint *count); 34 29 #endif /* _BRCM_SROM_H_ */
+44 -174
drivers/net/wireless/brcm80211/brcmutil/utils.c
··· 16 16 17 17 #include <linux/netdevice.h> 18 18 #include <linux/module.h> 19 + 19 20 #include <brcmu_utils.h> 20 21 21 22 MODULE_AUTHOR("Broadcom Corporation"); ··· 41 40 /* Free the driver packet. Free the tag if present */ 42 41 void brcmu_pkt_buf_free_skb(struct sk_buff *skb) 43 42 { 44 - struct sk_buff *nskb; 45 - int nest = 0; 46 - 47 - /* perversion: we use skb->next to chain multi-skb packets */ 48 - while (skb) { 49 - nskb = skb->next; 50 - skb->next = NULL; 51 - 52 - if (skb->destructor) 53 - /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if 54 - * destructor exists 55 - */ 56 - dev_kfree_skb_any(skb); 57 - else 58 - /* can free immediately (even in_irq()) if destructor 59 - * does not exist 60 - */ 61 - dev_kfree_skb(skb); 62 - 63 - nest++; 64 - skb = nskb; 65 - } 43 + WARN_ON(skb->next); 44 + if (skb->destructor) 45 + /* cannot kfree_skb() on hard IRQ (net/core/skbuff.c) if 46 + * destructor exists 47 + */ 48 + dev_kfree_skb_any(skb); 49 + else 50 + /* can free immediately (even in_irq()) if destructor 51 + * does not exist 52 + */ 53 + dev_kfree_skb(skb); 66 54 } 67 55 EXPORT_SYMBOL(brcmu_pkt_buf_free_skb); 68 - 69 - 70 - /* copy a buffer into a pkt buffer chain */ 71 - uint brcmu_pktfrombuf(struct sk_buff *p, uint offset, int len, 72 - unsigned char *buf) 73 - { 74 - uint n, ret = 0; 75 - 76 - /* skip 'offset' bytes */ 77 - for (; p && offset; p = p->next) { 78 - if (offset < (uint) (p->len)) 79 - break; 80 - offset -= p->len; 81 - } 82 - 83 - if (!p) 84 - return 0; 85 - 86 - /* copy the data */ 87 - for (; p && len; p = p->next) { 88 - n = min((uint) (p->len) - offset, (uint) len); 89 - memcpy(p->data + offset, buf, n); 90 - buf += n; 91 - len -= n; 92 - ret += n; 93 - offset = 0; 94 - } 95 - 96 - return ret; 97 - } 98 - EXPORT_SYMBOL(brcmu_pktfrombuf); 99 - 100 - /* return total length of buffer chain */ 101 - uint brcmu_pkttotlen(struct sk_buff *p) 102 - { 103 - uint total; 104 - 105 - total = 0; 106 - for (; p; p = p->next) 107 - total += p->len; 108 - return total; 109 - } 110 - EXPORT_SYMBOL(brcmu_pkttotlen); 111 56 112 57 /* 113 58 * osl multiple-precedence packet queue ··· 62 115 struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, 63 116 struct sk_buff *p) 64 117 { 65 - struct pktq_prec *q; 118 + struct sk_buff_head *q; 66 119 67 120 if (pktq_full(pq) || pktq_pfull(pq, prec)) 68 121 return NULL; 69 122 70 - q = &pq->q[prec]; 71 - 72 - if (q->head) 73 - q->tail->prev = p; 74 - else 75 - q->head = p; 76 - 77 - q->tail = p; 78 - q->len++; 79 - 123 + q = &pq->q[prec].skblist; 124 + skb_queue_tail(q, p); 80 125 pq->len++; 81 126 82 127 if (pq->hi_prec < prec) ··· 81 142 struct sk_buff *brcmu_pktq_penq_head(struct pktq *pq, int prec, 82 143 struct sk_buff *p) 83 144 { 84 - struct pktq_prec *q; 145 + struct sk_buff_head *q; 85 146 86 147 if (pktq_full(pq) || pktq_pfull(pq, prec)) 87 148 return NULL; 88 149 89 - q = &pq->q[prec]; 90 - 91 - if (q->head == NULL) 92 - q->tail = p; 93 - 94 - p->prev = q->head; 95 - q->head = p; 96 - q->len++; 97 - 150 + q = &pq->q[prec].skblist; 151 + skb_queue_head(q, p); 98 152 pq->len++; 99 153 100 154 if (pq->hi_prec < prec) ··· 99 167 100 168 struct sk_buff *brcmu_pktq_pdeq(struct pktq *pq, int prec) 101 169 { 102 - struct pktq_prec *q; 170 + struct sk_buff_head *q; 103 171 struct sk_buff *p; 104 172 105 - q = &pq->q[prec]; 106 - 107 - p = q->head; 173 + q = &pq->q[prec].skblist; 174 + p = skb_dequeue(q); 108 175 if (p == NULL) 109 176 return NULL; 110 177 111 - q->head = p->prev; 112 - if (q->head == NULL) 113 - q->tail = NULL; 114 - 115 - q->len--; 116 - 117 178 pq->len--; 118 - 119 - p->prev = NULL; 120 - 121 179 return p; 122 180 } 123 181 EXPORT_SYMBOL(brcmu_pktq_pdeq); 124 182 125 183 struct sk_buff *brcmu_pktq_pdeq_tail(struct pktq *pq, int prec) 126 184 { 127 - struct pktq_prec *q; 128 - struct sk_buff *p, *prev; 185 + struct sk_buff_head *q; 186 + struct sk_buff *p; 129 187 130 - q = &pq->q[prec]; 131 - 132 - p = q->head; 188 + q = &pq->q[prec].skblist; 189 + p = skb_dequeue_tail(q); 133 190 if (p == NULL) 134 191 return NULL; 135 192 136 - for (prev = NULL; p != q->tail; p = p->prev) 137 - prev = p; 138 - 139 - if (prev) 140 - prev->prev = NULL; 141 - else 142 - q->head = NULL; 143 - 144 - q->tail = prev; 145 - q->len--; 146 - 147 193 pq->len--; 148 - 149 194 return p; 150 195 } 151 196 EXPORT_SYMBOL(brcmu_pktq_pdeq_tail); ··· 131 222 brcmu_pktq_pflush(struct pktq *pq, int prec, bool dir, 132 223 bool (*fn)(struct sk_buff *, void *), void *arg) 133 224 { 134 - struct pktq_prec *q; 135 - struct sk_buff *p, *prev = NULL; 225 + struct sk_buff_head *q; 226 + struct sk_buff *p, *next; 136 227 137 - q = &pq->q[prec]; 138 - p = q->head; 139 - while (p) { 228 + q = &pq->q[prec].skblist; 229 + skb_queue_walk_safe(q, p, next) { 140 230 if (fn == NULL || (*fn) (p, arg)) { 141 - bool head = (p == q->head); 142 - if (head) 143 - q->head = p->prev; 144 - else 145 - prev->prev = p->prev; 146 - p->prev = NULL; 231 + skb_unlink(p, q); 147 232 brcmu_pkt_buf_free_skb(p); 148 - q->len--; 149 233 pq->len--; 150 - p = (head ? q->head : prev->prev); 151 - } else { 152 - prev = p; 153 - p = p->prev; 154 234 } 155 235 } 156 - 157 - if (q->head == NULL) 158 - q->tail = NULL; 159 236 } 160 237 EXPORT_SYMBOL(brcmu_pktq_pflush); 161 238 ··· 166 271 167 272 pq->max = (u16) max_len; 168 273 169 - for (prec = 0; prec < num_prec; prec++) 274 + for (prec = 0; prec < num_prec; prec++) { 170 275 pq->q[prec].max = pq->max; 276 + skb_queue_head_init(&pq->q[prec].skblist); 277 + } 171 278 } 172 279 EXPORT_SYMBOL(brcmu_pktq_init); 173 280 ··· 181 284 return NULL; 182 285 183 286 for (prec = 0; prec < pq->hi_prec; prec++) 184 - if (pq->q[prec].head) 287 + if (!skb_queue_empty(&pq->q[prec].skblist)) 185 288 break; 186 289 187 290 if (prec_out) 188 291 *prec_out = prec; 189 292 190 - return pq->q[prec].tail; 293 + return skb_peek_tail(&pq->q[prec].skblist); 191 294 } 192 295 EXPORT_SYMBOL(brcmu_pktq_peek_tail); 193 296 ··· 200 303 201 304 for (prec = 0; prec <= pq->hi_prec; prec++) 202 305 if (prec_bmp & (1 << prec)) 203 - len += pq->q[prec].len; 306 + len += pq->q[prec].skblist.qlen; 204 307 205 308 return len; 206 309 } ··· 210 313 struct sk_buff *brcmu_pktq_mdeq(struct pktq *pq, uint prec_bmp, 211 314 int *prec_out) 212 315 { 213 - struct pktq_prec *q; 316 + struct sk_buff_head *q; 214 317 struct sk_buff *p; 215 318 int prec; 216 319 217 320 if (pq->len == 0) 218 321 return NULL; 219 322 220 - while ((prec = pq->hi_prec) > 0 && pq->q[prec].head == NULL) 323 + while ((prec = pq->hi_prec) > 0 && 324 + skb_queue_empty(&pq->q[prec].skblist)) 221 325 pq->hi_prec--; 222 326 223 - while ((prec_bmp & (1 << prec)) == 0 || pq->q[prec].head == NULL) 327 + while ((prec_bmp & (1 << prec)) == 0 || 328 + skb_queue_empty(&pq->q[prec].skblist)) 224 329 if (prec-- == 0) 225 330 return NULL; 226 331 227 - q = &pq->q[prec]; 228 - 229 - p = q->head; 332 + q = &pq->q[prec].skblist; 333 + p = skb_dequeue(q); 230 334 if (p == NULL) 231 335 return NULL; 232 336 233 - q->head = p->prev; 234 - if (q->head == NULL) 235 - q->tail = NULL; 236 - 237 - q->len--; 337 + pq->len--; 238 338 239 339 if (prec_out) 240 340 *prec_out = prec; 241 - 242 - pq->len--; 243 - 244 - p->prev = NULL; 245 341 246 342 return p; 247 343 } ··· 253 363 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, p->data, p->len); 254 364 } 255 365 EXPORT_SYMBOL(brcmu_prpkt); 256 - #endif /* defined(BCMDBG) */ 257 - 258 - #if defined(BCMDBG) 259 - /* 260 - * print bytes formatted as hex to a string. return the resulting 261 - * string length 262 - */ 263 - int brcmu_format_hex(char *str, const void *bytes, int len) 264 - { 265 - int i; 266 - char *p = str; 267 - const u8 *src = (const u8 *)bytes; 268 - 269 - for (i = 0; i < len; i++) { 270 - p += snprintf(p, 3, "%02X", *src); 271 - src++; 272 - } 273 - return (int)(p - str); 274 - } 275 - EXPORT_SYMBOL(brcmu_format_hex); 276 366 #endif /* defined(BCMDBG) */
+10 -20
drivers/net/wireless/brcm80211/include/brcmu_utils.h
··· 65 65 #define ETHER_ADDR_STR_LEN 18 66 66 67 67 struct pktq_prec { 68 - struct sk_buff *head; /* first packet to dequeue */ 69 - struct sk_buff *tail; /* last packet to dequeue */ 70 - u16 len; /* number of queued packets */ 68 + struct sk_buff_head skblist; 71 69 u16 max; /* maximum number of queued packets */ 72 70 }; 73 71 ··· 86 88 87 89 static inline int pktq_plen(struct pktq *pq, int prec) 88 90 { 89 - return pq->q[prec].len; 91 + return pq->q[prec].skblist.qlen; 90 92 } 91 93 92 94 static inline int pktq_pavail(struct pktq *pq, int prec) 93 95 { 94 - return pq->q[prec].max - pq->q[prec].len; 96 + return pq->q[prec].max - pq->q[prec].skblist.qlen; 95 97 } 96 98 97 99 static inline bool pktq_pfull(struct pktq *pq, int prec) 98 100 { 99 - return pq->q[prec].len >= pq->q[prec].max; 101 + return pq->q[prec].skblist.qlen >= pq->q[prec].max; 100 102 } 101 103 102 104 static inline bool pktq_pempty(struct pktq *pq, int prec) 103 105 { 104 - return pq->q[prec].len == 0; 106 + return skb_queue_empty(&pq->q[prec].skblist); 105 107 } 106 108 107 109 static inline struct sk_buff *pktq_ppeek(struct pktq *pq, int prec) 108 110 { 109 - return pq->q[prec].head; 111 + return skb_peek(&pq->q[prec].skblist); 110 112 } 111 113 112 114 static inline struct sk_buff *pktq_ppeek_tail(struct pktq *pq, int prec) 113 115 { 114 - return pq->q[prec].tail; 116 + return skb_peek_tail(&pq->q[prec].skblist); 115 117 } 116 118 117 119 extern struct sk_buff *brcmu_pktq_penq(struct pktq *pq, int prec, ··· 170 172 bool (*fn)(struct sk_buff *, void *), void *arg); 171 173 172 174 /* externs */ 173 - /* packet */ 174 - extern uint brcmu_pktfrombuf(struct sk_buff *p, 175 - uint offset, int len, unsigned char *buf); 176 - extern uint brcmu_pkttotlen(struct sk_buff *p); 177 - 178 175 /* ip address */ 179 176 struct ipv4_addr; 180 177 178 + 179 + /* externs */ 180 + /* format/print */ 181 181 #ifdef BCMDBG 182 182 extern void brcmu_prpkt(const char *msg, struct sk_buff *p0); 183 183 #else 184 184 #define brcmu_prpkt(a, b) 185 185 #endif /* BCMDBG */ 186 - 187 - /* externs */ 188 - /* format/print */ 189 - #if defined(BCMDBG) 190 - extern int brcmu_format_hex(char *str, const void *bytes, int len); 191 - #endif 192 186 193 187 #endif /* _BRCMU_UTILS_H_ */
-1
drivers/net/wireless/brcm80211/include/defs.h
··· 62 62 63 63 #define WL_RADIO_SW_DISABLE (1<<0) 64 64 #define WL_RADIO_HW_DISABLE (1<<1) 65 - #define WL_RADIO_MPC_DISABLE (1<<2) 66 65 /* some countries don't support any channel */ 67 66 #define WL_RADIO_COUNTRY_DISABLE (1<<3) 68 67
+10 -2
drivers/net/wireless/brcm80211/include/soc.h
··· 77 77 #define DMEMS_CORE_ID 0x835 /* SDR/DDR1 memory controller core */ 78 78 #define DEF_SHIM_COMP 0x837 /* SHIM component in ubus/6362 */ 79 79 #define OOB_ROUTER_CORE_ID 0x367 /* OOB router core ID */ 80 - /* Default component, in ai chips it maps all unused address ranges */ 81 - #define DEF_AI_COMP 0xfff 80 + #define DEF_AI_COMP 0xfff /* Default component, in ai chips it 81 + * maps all unused address ranges 82 + */ 82 83 83 84 /* Common core control flags */ 84 85 #define SICF_BIST_EN 0x8000 ··· 87 86 #define SICF_CORE_BITS 0x3ffc 88 87 #define SICF_FGC 0x0002 89 88 #define SICF_CLOCK_EN 0x0001 89 + 90 + /* Common core status flags */ 91 + #define SISF_BIST_DONE 0x8000 92 + #define SISF_BIST_ERROR 0x4000 93 + #define SISF_GATED_CLK 0x2000 94 + #define SISF_DMA64 0x1000 95 + #define SISF_CORE_BITS 0x0fff 90 96 91 97 #endif /* _BRCM_SOC_H */
+8
drivers/net/wireless/ipw2x00/ipw2200.c
··· 131 131 #define ipw2200_bg_rates (ipw2200_rates + 0) 132 132 #define ipw2200_num_bg_rates 12 133 133 134 + /* Ugly macro to convert literal channel numbers into their mhz equivalents 135 + * There are certianly some conditions that will break this (like feeding it '30') 136 + * but they shouldn't arise since nothing talks on channel 30. */ 137 + #define ieee80211chan2mhz(x) \ 138 + (((x) <= 14) ? \ 139 + (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ 140 + ((x) + 1000) * 5) 141 + 134 142 #ifdef CONFIG_IPW2200_QOS 135 143 static int qos_enable = 0; 136 144 static int qos_burst_enable = 0;
-8
drivers/net/wireless/ipw2x00/libipw.h
··· 66 66 do { if (libipw_debug_level & (level)) \ 67 67 printk(KERN_DEBUG "libipw: %c %s " fmt, \ 68 68 in_interrupt() ? 'I' : 'U', __func__ , ## args); } while (0) 69 - static inline bool libipw_ratelimit_debug(u32 level) 70 - { 71 - return (libipw_debug_level & level) && net_ratelimit(); 72 - } 73 69 #else 74 70 #define LIBIPW_DEBUG(level, fmt, args...) do {} while (0) 75 - static inline bool libipw_ratelimit_debug(u32 level) 76 - { 77 - return false; 78 - } 79 71 #endif /* CONFIG_LIBIPW_DEBUG */ 80 72 81 73 /*
+1 -1
drivers/net/wireless/iwlwifi/Makefile
··· 1 1 # WIFI 2 2 obj-$(CONFIG_IWLWIFI) += iwlwifi.o 3 - iwlwifi-objs := iwl-agn.o iwl-agn-rs.o 3 + iwlwifi-objs := iwl-agn.o iwl-agn-rs.o iwl-mac80211.o 4 4 iwlwifi-objs += iwl-agn-ucode.o iwl-agn-tx.o 5 5 iwlwifi-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o 6 6 iwlwifi-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-rx.o
-20
drivers/net/wireless/iwlwifi/iwl-2000.c
··· 270 270 .ht_params = &iwl2000_ht_params, 271 271 }; 272 272 273 - struct iwl_cfg iwl2000_2bg_cfg = { 274 - .name = "2000 Series 2x2 BG", 275 - IWL_DEVICE_2000, 276 - }; 277 - 278 273 struct iwl_cfg iwl2000_2bgn_d_cfg = { 279 274 .name = "2000D Series 2x2 BGN", 280 275 IWL_DEVICE_2000, ··· 299 304 .ht_params = &iwl2000_ht_params, 300 305 }; 301 306 302 - struct iwl_cfg iwl2030_2bg_cfg = { 303 - .name = "2000 Series 2x2 BG/BT", 304 - IWL_DEVICE_2030, 305 - }; 306 - 307 307 #define IWL_DEVICE_105 \ 308 308 .fw_name_pre = IWL105_FW_PRE, \ 309 309 .ucode_api_max = IWL105_UCODE_API_MAX, \ ··· 315 325 .adv_pm = true, \ 316 326 .rx_with_siso_diversity = true, \ 317 327 .iq_invert = true \ 318 - 319 - struct iwl_cfg iwl105_bg_cfg = { 320 - .name = "105 Series 1x1 BG", 321 - IWL_DEVICE_105, 322 - }; 323 328 324 329 struct iwl_cfg iwl105_bgn_cfg = { 325 330 .name = "105 Series 1x1 BGN", ··· 345 360 .adv_pm = true, \ 346 361 .rx_with_siso_diversity = true, \ 347 362 .iq_invert = true \ 348 - 349 - struct iwl_cfg iwl135_bg_cfg = { 350 - .name = "135 Series 1x1 BG/BT", 351 - IWL_DEVICE_135, 352 - }; 353 363 354 364 struct iwl_cfg iwl135_bgn_cfg = { 355 365 .name = "135 Series 1x1 BGN/BT",
-10
drivers/net/wireless/iwlwifi/iwl-6000.c
··· 439 439 .ht_params = &iwl6000_ht_params, 440 440 }; 441 441 442 - struct iwl_cfg iwl6035_2abg_cfg = { 443 - .name = "6035 Series 2x2 ABG/BT", 444 - IWL_DEVICE_6030, 445 - }; 446 - 447 - struct iwl_cfg iwl6035_2bg_cfg = { 448 - .name = "6035 Series 2x2 BG/BT", 449 - IWL_DEVICE_6030, 450 - }; 451 - 452 442 struct iwl_cfg iwl1030_bgn_cfg = { 453 443 .name = "Intel(R) Centrino(R) Wireless-N 1030 BGN", 454 444 IWL_DEVICE_6030,
+358
drivers/net/wireless/iwlwifi/iwl-agn-lib.c
··· 827 827 case IEEE80211_SMPS_STATIC: 828 828 case IEEE80211_SMPS_DYNAMIC: 829 829 return IWL_NUM_IDLE_CHAINS_SINGLE; 830 + case IEEE80211_SMPS_AUTOMATIC: 830 831 case IEEE80211_SMPS_OFF: 831 832 return active_cnt; 832 833 default: ··· 984 983 list_del(&wait_entry->list); 985 984 spin_unlock_bh(&priv->notif_wait_lock); 986 985 } 986 + 987 + #ifdef CONFIG_PM_SLEEP 988 + static void iwlagn_convert_p1k(u16 *p1k, __le16 *out) 989 + { 990 + int i; 991 + 992 + for (i = 0; i < IWLAGN_P1K_SIZE; i++) 993 + out[i] = cpu_to_le16(p1k[i]); 994 + } 995 + 996 + struct wowlan_key_data { 997 + struct iwl_rxon_context *ctx; 998 + struct iwlagn_wowlan_rsc_tsc_params_cmd *rsc_tsc; 999 + struct iwlagn_wowlan_tkip_params_cmd *tkip; 1000 + const u8 *bssid; 1001 + bool error, use_rsc_tsc, use_tkip; 1002 + }; 1003 + 1004 + 1005 + static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, 1006 + struct ieee80211_vif *vif, 1007 + struct ieee80211_sta *sta, 1008 + struct ieee80211_key_conf *key, 1009 + void *_data) 1010 + { 1011 + struct iwl_priv *priv = hw->priv; 1012 + struct wowlan_key_data *data = _data; 1013 + struct iwl_rxon_context *ctx = data->ctx; 1014 + struct aes_sc *aes_sc, *aes_tx_sc = NULL; 1015 + struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL; 1016 + struct iwlagn_p1k_cache *rx_p1ks; 1017 + u8 *rx_mic_key; 1018 + struct ieee80211_key_seq seq; 1019 + u32 cur_rx_iv32 = 0; 1020 + u16 p1k[IWLAGN_P1K_SIZE]; 1021 + int ret, i; 1022 + 1023 + mutex_lock(&priv->shrd->mutex); 1024 + 1025 + if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || 1026 + key->cipher == WLAN_CIPHER_SUITE_WEP104) && 1027 + !sta && !ctx->key_mapping_keys) 1028 + ret = iwl_set_default_wep_key(priv, ctx, key); 1029 + else 1030 + ret = iwl_set_dynamic_key(priv, ctx, key, sta); 1031 + 1032 + if (ret) { 1033 + IWL_ERR(priv, "Error setting key during suspend!\n"); 1034 + data->error = true; 1035 + } 1036 + 1037 + switch (key->cipher) { 1038 + case WLAN_CIPHER_SUITE_TKIP: 1039 + if (sta) { 1040 + tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc; 1041 + tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc; 1042 + 1043 + rx_p1ks = data->tkip->rx_uni; 1044 + 1045 + ieee80211_get_key_tx_seq(key, &seq); 1046 + tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16); 1047 + tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32); 1048 + 1049 + ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k); 1050 + iwlagn_convert_p1k(p1k, data->tkip->tx.p1k); 1051 + 1052 + memcpy(data->tkip->mic_keys.tx, 1053 + &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], 1054 + IWLAGN_MIC_KEY_SIZE); 1055 + 1056 + rx_mic_key = data->tkip->mic_keys.rx_unicast; 1057 + } else { 1058 + tkip_sc = 1059 + data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc; 1060 + rx_p1ks = data->tkip->rx_multi; 1061 + rx_mic_key = data->tkip->mic_keys.rx_mcast; 1062 + } 1063 + 1064 + /* 1065 + * For non-QoS this relies on the fact that both the uCode and 1066 + * mac80211 use TID 0 (as they need to to avoid replay attacks) 1067 + * for checking the IV in the frames. 1068 + */ 1069 + for (i = 0; i < IWLAGN_NUM_RSC; i++) { 1070 + ieee80211_get_key_rx_seq(key, i, &seq); 1071 + tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16); 1072 + tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32); 1073 + /* wrapping isn't allowed, AP must rekey */ 1074 + if (seq.tkip.iv32 > cur_rx_iv32) 1075 + cur_rx_iv32 = seq.tkip.iv32; 1076 + } 1077 + 1078 + ieee80211_get_tkip_rx_p1k(key, data->bssid, cur_rx_iv32, p1k); 1079 + iwlagn_convert_p1k(p1k, rx_p1ks[0].p1k); 1080 + ieee80211_get_tkip_rx_p1k(key, data->bssid, 1081 + cur_rx_iv32 + 1, p1k); 1082 + iwlagn_convert_p1k(p1k, rx_p1ks[1].p1k); 1083 + 1084 + memcpy(rx_mic_key, 1085 + &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], 1086 + IWLAGN_MIC_KEY_SIZE); 1087 + 1088 + data->use_tkip = true; 1089 + data->use_rsc_tsc = true; 1090 + break; 1091 + case WLAN_CIPHER_SUITE_CCMP: 1092 + if (sta) { 1093 + u8 *pn = seq.ccmp.pn; 1094 + 1095 + aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; 1096 + aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; 1097 + 1098 + ieee80211_get_key_tx_seq(key, &seq); 1099 + aes_tx_sc->pn = cpu_to_le64( 1100 + (u64)pn[5] | 1101 + ((u64)pn[4] << 8) | 1102 + ((u64)pn[3] << 16) | 1103 + ((u64)pn[2] << 24) | 1104 + ((u64)pn[1] << 32) | 1105 + ((u64)pn[0] << 40)); 1106 + } else 1107 + aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; 1108 + 1109 + /* 1110 + * For non-QoS this relies on the fact that both the uCode and 1111 + * mac80211 use TID 0 for checking the IV in the frames. 1112 + */ 1113 + for (i = 0; i < IWLAGN_NUM_RSC; i++) { 1114 + u8 *pn = seq.ccmp.pn; 1115 + 1116 + ieee80211_get_key_rx_seq(key, i, &seq); 1117 + aes_sc->pn = cpu_to_le64( 1118 + (u64)pn[5] | 1119 + ((u64)pn[4] << 8) | 1120 + ((u64)pn[3] << 16) | 1121 + ((u64)pn[2] << 24) | 1122 + ((u64)pn[1] << 32) | 1123 + ((u64)pn[0] << 40)); 1124 + } 1125 + data->use_rsc_tsc = true; 1126 + break; 1127 + } 1128 + 1129 + mutex_unlock(&priv->shrd->mutex); 1130 + } 1131 + 1132 + int iwlagn_send_patterns(struct iwl_priv *priv, 1133 + struct cfg80211_wowlan *wowlan) 1134 + { 1135 + struct iwlagn_wowlan_patterns_cmd *pattern_cmd; 1136 + struct iwl_host_cmd cmd = { 1137 + .id = REPLY_WOWLAN_PATTERNS, 1138 + .dataflags[0] = IWL_HCMD_DFL_NOCOPY, 1139 + .flags = CMD_SYNC, 1140 + }; 1141 + int i, err; 1142 + 1143 + if (!wowlan->n_patterns) 1144 + return 0; 1145 + 1146 + cmd.len[0] = sizeof(*pattern_cmd) + 1147 + wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern); 1148 + 1149 + pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL); 1150 + if (!pattern_cmd) 1151 + return -ENOMEM; 1152 + 1153 + pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns); 1154 + 1155 + for (i = 0; i < wowlan->n_patterns; i++) { 1156 + int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); 1157 + 1158 + memcpy(&pattern_cmd->patterns[i].mask, 1159 + wowlan->patterns[i].mask, mask_len); 1160 + memcpy(&pattern_cmd->patterns[i].pattern, 1161 + wowlan->patterns[i].pattern, 1162 + wowlan->patterns[i].pattern_len); 1163 + pattern_cmd->patterns[i].mask_size = mask_len; 1164 + pattern_cmd->patterns[i].pattern_size = 1165 + wowlan->patterns[i].pattern_len; 1166 + } 1167 + 1168 + cmd.data[0] = pattern_cmd; 1169 + err = iwl_trans_send_cmd(trans(priv), &cmd); 1170 + kfree(pattern_cmd); 1171 + return err; 1172 + } 1173 + 1174 + int iwlagn_suspend(struct iwl_priv *priv, 1175 + struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) 1176 + { 1177 + struct iwlagn_wowlan_wakeup_filter_cmd wakeup_filter_cmd; 1178 + struct iwl_rxon_cmd rxon; 1179 + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 1180 + struct iwlagn_wowlan_kek_kck_material_cmd kek_kck_cmd; 1181 + struct iwlagn_wowlan_tkip_params_cmd tkip_cmd = {}; 1182 + struct iwlagn_d3_config_cmd d3_cfg_cmd = {}; 1183 + struct wowlan_key_data key_data = { 1184 + .ctx = ctx, 1185 + .bssid = ctx->active.bssid_addr, 1186 + .use_rsc_tsc = false, 1187 + .tkip = &tkip_cmd, 1188 + .use_tkip = false, 1189 + }; 1190 + int ret, i; 1191 + u16 seq; 1192 + 1193 + key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL); 1194 + if (!key_data.rsc_tsc) 1195 + return -ENOMEM; 1196 + 1197 + memset(&wakeup_filter_cmd, 0, sizeof(wakeup_filter_cmd)); 1198 + 1199 + /* 1200 + * We know the last used seqno, and the uCode expects to know that 1201 + * one, it will increment before TX. 1202 + */ 1203 + seq = le16_to_cpu(priv->last_seq_ctl) & IEEE80211_SCTL_SEQ; 1204 + wakeup_filter_cmd.non_qos_seq = cpu_to_le16(seq); 1205 + 1206 + /* 1207 + * For QoS counters, we store the one to use next, so subtract 0x10 1208 + * since the uCode will add 0x10 before using the value. 1209 + */ 1210 + for (i = 0; i < 8; i++) { 1211 + seq = priv->shrd->tid_data[IWL_AP_ID][i].seq_number; 1212 + seq -= 0x10; 1213 + wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq); 1214 + } 1215 + 1216 + if (wowlan->disconnect) 1217 + wakeup_filter_cmd.enabled |= 1218 + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_BEACON_MISS | 1219 + IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE); 1220 + if (wowlan->magic_pkt) 1221 + wakeup_filter_cmd.enabled |= 1222 + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET); 1223 + if (wowlan->gtk_rekey_failure) 1224 + wakeup_filter_cmd.enabled |= 1225 + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL); 1226 + if (wowlan->eap_identity_req) 1227 + wakeup_filter_cmd.enabled |= 1228 + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ); 1229 + if (wowlan->four_way_handshake) 1230 + wakeup_filter_cmd.enabled |= 1231 + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE); 1232 + if (wowlan->n_patterns) 1233 + wakeup_filter_cmd.enabled |= 1234 + cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH); 1235 + 1236 + if (wowlan->rfkill_release) 1237 + d3_cfg_cmd.wakeup_flags |= 1238 + cpu_to_le32(IWLAGN_D3_WAKEUP_RFKILL); 1239 + 1240 + iwl_scan_cancel_timeout(priv, 200); 1241 + 1242 + memcpy(&rxon, &ctx->active, sizeof(rxon)); 1243 + 1244 + iwl_trans_stop_device(trans(priv)); 1245 + 1246 + priv->shrd->wowlan = true; 1247 + 1248 + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); 1249 + if (ret) 1250 + goto out; 1251 + 1252 + /* now configure WoWLAN ucode */ 1253 + ret = iwl_alive_start(priv); 1254 + if (ret) 1255 + goto out; 1256 + 1257 + memcpy(&ctx->staging, &rxon, sizeof(rxon)); 1258 + ret = iwlagn_commit_rxon(priv, ctx); 1259 + if (ret) 1260 + goto out; 1261 + 1262 + ret = iwl_power_update_mode(priv, true); 1263 + if (ret) 1264 + goto out; 1265 + 1266 + if (!iwlagn_mod_params.sw_crypto) { 1267 + /* mark all keys clear */ 1268 + priv->ucode_key_table = 0; 1269 + ctx->key_mapping_keys = 0; 1270 + 1271 + /* 1272 + * This needs to be unlocked due to lock ordering 1273 + * constraints. Since we're in the suspend path 1274 + * that isn't really a problem though. 1275 + */ 1276 + mutex_unlock(&priv->shrd->mutex); 1277 + ieee80211_iter_keys(priv->hw, ctx->vif, 1278 + iwlagn_wowlan_program_keys, 1279 + &key_data); 1280 + mutex_lock(&priv->shrd->mutex); 1281 + if (key_data.error) { 1282 + ret = -EIO; 1283 + goto out; 1284 + } 1285 + 1286 + if (key_data.use_rsc_tsc) { 1287 + struct iwl_host_cmd rsc_tsc_cmd = { 1288 + .id = REPLY_WOWLAN_TSC_RSC_PARAMS, 1289 + .flags = CMD_SYNC, 1290 + .data[0] = key_data.rsc_tsc, 1291 + .dataflags[0] = IWL_HCMD_DFL_NOCOPY, 1292 + .len[0] = sizeof(key_data.rsc_tsc), 1293 + }; 1294 + 1295 + ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd); 1296 + if (ret) 1297 + goto out; 1298 + } 1299 + 1300 + if (key_data.use_tkip) { 1301 + ret = iwl_trans_send_cmd_pdu(trans(priv), 1302 + REPLY_WOWLAN_TKIP_PARAMS, 1303 + CMD_SYNC, sizeof(tkip_cmd), 1304 + &tkip_cmd); 1305 + if (ret) 1306 + goto out; 1307 + } 1308 + 1309 + if (priv->have_rekey_data) { 1310 + memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd)); 1311 + memcpy(kek_kck_cmd.kck, priv->kck, NL80211_KCK_LEN); 1312 + kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN); 1313 + memcpy(kek_kck_cmd.kek, priv->kek, NL80211_KEK_LEN); 1314 + kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN); 1315 + kek_kck_cmd.replay_ctr = priv->replay_ctr; 1316 + 1317 + ret = iwl_trans_send_cmd_pdu(trans(priv), 1318 + REPLY_WOWLAN_KEK_KCK_MATERIAL, 1319 + CMD_SYNC, sizeof(kek_kck_cmd), 1320 + &kek_kck_cmd); 1321 + if (ret) 1322 + goto out; 1323 + } 1324 + } 1325 + 1326 + ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_D3_CONFIG, CMD_SYNC, 1327 + sizeof(d3_cfg_cmd), &d3_cfg_cmd); 1328 + if (ret) 1329 + goto out; 1330 + 1331 + ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER, 1332 + CMD_SYNC, sizeof(wakeup_filter_cmd), 1333 + &wakeup_filter_cmd); 1334 + if (ret) 1335 + goto out; 1336 + 1337 + ret = iwlagn_send_patterns(priv, wowlan); 1338 + out: 1339 + kfree(key_data.rsc_tsc); 1340 + return ret; 1341 + } 1342 + #endif
+2 -6
drivers/net/wireless/iwlwifi/iwl-agn-rs.c
··· 1458 1458 break; 1459 1459 case IWL_BT_COEX_TRAFFIC_LOAD_LOW: 1460 1460 /* avoid antenna B unless MIMO */ 1461 - valid_tx_ant = 1462 - first_antenna(hw_params(priv).valid_tx_ant); 1463 1461 if (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2) 1464 - tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; 1462 + tbl->action = IWL_LEGACY_SWITCH_SISO; 1465 1463 break; 1466 1464 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: 1467 1465 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS: ··· 1634 1636 break; 1635 1637 case IWL_BT_COEX_TRAFFIC_LOAD_LOW: 1636 1638 /* avoid antenna B unless MIMO */ 1637 - valid_tx_ant = 1638 - first_antenna(hw_params(priv).valid_tx_ant); 1639 1639 if (tbl->action == IWL_SISO_SWITCH_ANTENNA2) 1640 - tbl->action = IWL_SISO_SWITCH_ANTENNA1; 1640 + tbl->action = IWL_SISO_SWITCH_MIMO2_AB; 1641 1641 break; 1642 1642 case IWL_BT_COEX_TRAFFIC_LOAD_HIGH: 1643 1643 case IWL_BT_COEX_TRAFFIC_LOAD_CONTINUOUS:
+48 -1
drivers/net/wireless/iwlwifi/iwl-agn-rx.c
··· 800 800 ctx->active.bssid_addr)) 801 801 continue; 802 802 ctx->last_tx_rejected = false; 803 - iwl_trans_wake_any_queue(trans(priv), ctx->ctxid); 803 + iwl_trans_wake_any_queue(trans(priv), ctx->ctxid, 804 + "channel got active"); 804 805 } 805 806 } 806 807 ··· 1033 1032 return 0; 1034 1033 } 1035 1034 1035 + static int iwlagn_rx_noa_notification(struct iwl_priv *priv, 1036 + struct iwl_rx_mem_buffer *rxb, 1037 + struct iwl_device_cmd *cmd) 1038 + { 1039 + struct iwl_wipan_noa_data *new_data, *old_data; 1040 + struct iwl_rx_packet *pkt = rxb_addr(rxb); 1041 + struct iwl_wipan_noa_notification *noa_notif = (void *)pkt->u.raw; 1042 + 1043 + /* no condition -- we're in softirq */ 1044 + old_data = rcu_dereference_protected(priv->noa_data, true); 1045 + 1046 + if (noa_notif->noa_active) { 1047 + u32 len = le16_to_cpu(noa_notif->noa_attribute.length); 1048 + u32 copylen = len; 1049 + 1050 + /* EID, len, OUI, subtype */ 1051 + len += 1 + 1 + 3 + 1; 1052 + /* P2P id, P2P length */ 1053 + len += 1 + 2; 1054 + copylen += 1 + 2; 1055 + 1056 + new_data = kmalloc(sizeof(*new_data) + len, GFP_ATOMIC); 1057 + if (new_data) { 1058 + new_data->length = len; 1059 + new_data->data[0] = WLAN_EID_VENDOR_SPECIFIC; 1060 + new_data->data[1] = len - 2; /* not counting EID, len */ 1061 + new_data->data[2] = (WLAN_OUI_WFA >> 16) & 0xff; 1062 + new_data->data[3] = (WLAN_OUI_WFA >> 8) & 0xff; 1063 + new_data->data[4] = (WLAN_OUI_WFA >> 0) & 0xff; 1064 + new_data->data[5] = WLAN_OUI_TYPE_WFA_P2P; 1065 + memcpy(&new_data->data[6], &noa_notif->noa_attribute, 1066 + copylen); 1067 + } 1068 + } else 1069 + new_data = NULL; 1070 + 1071 + rcu_assign_pointer(priv->noa_data, new_data); 1072 + 1073 + if (old_data) 1074 + kfree_rcu(old_data, rcu_head); 1075 + 1076 + return 0; 1077 + } 1078 + 1036 1079 /** 1037 1080 * iwl_setup_rx_handlers - Initialize Rx handler callbacks 1038 1081 * ··· 1099 1054 iwlagn_rx_pm_debug_statistics_notif; 1100 1055 handlers[BEACON_NOTIFICATION] = iwlagn_rx_beacon_notif; 1101 1056 handlers[REPLY_ADD_STA] = iwl_add_sta_callback; 1057 + 1058 + handlers[REPLY_WIPAN_NOA_NOTIFICATION] = iwlagn_rx_noa_notification; 1102 1059 1103 1060 /* 1104 1061 * The same handler is used for both the REPLY to a discrete
+9 -4
drivers/net/wireless/iwlwifi/iwl-agn-rxon.c
··· 45 45 send->filter_flags = old_filter; 46 46 47 47 if (ret) 48 - IWL_ERR(priv, "Error clearing ASSOC_MSK on BSS (%d)\n", ret); 48 + IWL_DEBUG_QUIET_RFKILL(priv, 49 + "Error clearing ASSOC_MSK on BSS (%d)\n", ret); 49 50 50 51 return ret; 51 52 } ··· 117 116 if (ctx->ht.enabled) 118 117 ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; 119 118 120 - IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", 119 + IWL_DEBUG_INFO(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", 121 120 ctx->qos_data.qos_active, 122 121 ctx->qos_data.def_qos_parm.qos_flags); 123 122 ··· 125 124 sizeof(struct iwl_qosparam_cmd), 126 125 &ctx->qos_data.def_qos_parm); 127 126 if (ret) 128 - IWL_ERR(priv, "Failed to update QoS\n"); 127 + IWL_DEBUG_QUIET_RFKILL(priv, "Failed to update QoS\n"); 129 128 } 130 129 131 130 static int iwlagn_update_beacon(struct iwl_priv *priv, ··· 542 541 543 542 mutex_lock(&priv->shrd->mutex); 544 543 544 + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) 545 + goto out; 546 + 545 547 if (unlikely(test_bit(STATUS_SCANNING, &priv->shrd->status))) { 546 548 IWL_DEBUG_MAC80211(priv, "leave - scanning\n"); 547 549 goto out; ··· 844 840 if (ctx->last_tx_rejected) { 845 841 ctx->last_tx_rejected = false; 846 842 iwl_trans_wake_any_queue(trans(priv), 847 - ctx->ctxid); 843 + ctx->ctxid, 844 + "Disassoc: flush queue"); 848 845 } 849 846 ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; 850 847
+7 -71
drivers/net/wireless/iwlwifi/iwl-agn-sta.c
··· 647 647 int ret; 648 648 struct iwl_addsta_cmd sta_cmd; 649 649 struct iwl_link_quality_cmd lq; 650 - bool active; 650 + bool active, have_lq = false; 651 651 652 652 spin_lock_irqsave(&priv->shrd->sta_lock, flags); 653 653 if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { ··· 657 657 658 658 memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(sta_cmd)); 659 659 sta_cmd.mode = 0; 660 - memcpy(&lq, priv->stations[sta_id].lq, sizeof(lq)); 660 + if (priv->stations[sta_id].lq) { 661 + memcpy(&lq, priv->stations[sta_id].lq, sizeof(lq)); 662 + have_lq = true; 663 + } 661 664 662 665 active = priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE; 663 666 priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; ··· 682 679 if (ret) 683 680 IWL_ERR(priv, "failed to re-add STA %pM (%d)\n", 684 681 priv->stations[sta_id].sta.sta.addr, ret); 685 - iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); 682 + if (have_lq) 683 + iwl_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); 686 684 } 687 685 688 686 int iwl_get_free_ucode_key_offset(struct iwl_priv *priv) ··· 829 825 return ret; 830 826 } 831 827 832 - int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, 833 - struct ieee80211_vif *vif, 834 - struct ieee80211_sta *sta) 835 - { 836 - struct iwl_priv *priv = hw->priv; 837 - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; 838 - int ret; 839 - 840 - IWL_DEBUG_MAC80211(priv, "enter: received request to remove " 841 - "station %pM\n", sta->addr); 842 - mutex_lock(&priv->shrd->mutex); 843 - IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", 844 - sta->addr); 845 - ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); 846 - if (ret) 847 - IWL_ERR(priv, "Error removing station %pM\n", 848 - sta->addr); 849 - mutex_unlock(&priv->shrd->mutex); 850 - IWL_DEBUG_MAC80211(priv, "leave\n"); 851 - 852 - return ret; 853 - } 854 828 855 829 void iwl_sta_fill_lq(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 856 830 u8 sta_id, struct iwl_link_quality_cmd *link_cmd) ··· 1446 1464 return iwl_send_add_sta(priv, &sta_cmd, CMD_SYNC); 1447 1465 } 1448 1466 1449 - static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id) 1450 - { 1451 - unsigned long flags; 1452 1467 1453 - spin_lock_irqsave(&priv->shrd->sta_lock, flags); 1454 - priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK; 1455 - priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; 1456 - priv->stations[sta_id].sta.sta.modify_mask = 0; 1457 - priv->stations[sta_id].sta.sleep_tx_count = 0; 1458 - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; 1459 - iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); 1460 - spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); 1461 - 1462 - } 1463 1468 1464 1469 void iwl_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) 1465 1470 { ··· 1462 1493 iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); 1463 1494 spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); 1464 1495 1465 - } 1466 - 1467 - void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, 1468 - struct ieee80211_vif *vif, 1469 - enum sta_notify_cmd cmd, 1470 - struct ieee80211_sta *sta) 1471 - { 1472 - struct iwl_priv *priv = hw->priv; 1473 - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; 1474 - int sta_id; 1475 - 1476 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1477 - 1478 - switch (cmd) { 1479 - case STA_NOTIFY_SLEEP: 1480 - WARN_ON(!sta_priv->client); 1481 - sta_priv->asleep = true; 1482 - if (atomic_read(&sta_priv->pending_frames) > 0) 1483 - ieee80211_sta_block_awake(hw, sta, true); 1484 - break; 1485 - case STA_NOTIFY_AWAKE: 1486 - WARN_ON(!sta_priv->client); 1487 - if (!sta_priv->asleep) 1488 - break; 1489 - sta_priv->asleep = false; 1490 - sta_id = iwl_sta_id(sta); 1491 - if (sta_id != IWL_INVALID_STATION) 1492 - iwl_sta_modify_ps_wake(priv, sta_id); 1493 - break; 1494 - default: 1495 - break; 1496 - } 1497 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1498 1496 }
+15 -1
drivers/net/wireless/iwlwifi/iwl-agn-tx.c
··· 283 283 IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); 284 284 #endif 285 285 286 + if (unlikely(ieee80211_is_probe_resp(fc))) { 287 + struct iwl_wipan_noa_data *noa_data = 288 + rcu_dereference(priv->noa_data); 289 + 290 + if (noa_data && 291 + pskb_expand_head(skb, 0, noa_data->length, 292 + GFP_ATOMIC) == 0) { 293 + memcpy(skb_put(skb, noa_data->length), 294 + noa_data->data, noa_data->length); 295 + hdr = (struct ieee80211_hdr *)skb->data; 296 + } 297 + } 298 + 286 299 hdr_len = ieee80211_hdrlen(fc); 287 300 288 301 /* For management frames use broadcast id to do not break aggregation */ ··· 813 800 iwl_is_associated_ctx(ctx) && ctx->vif && 814 801 ctx->vif->type == NL80211_IFTYPE_STATION) { 815 802 ctx->last_tx_rejected = true; 816 - iwl_trans_stop_queue(trans(priv), txq_id); 803 + iwl_trans_stop_queue(trans(priv), txq_id, 804 + "Tx on passive channel"); 817 805 818 806 IWL_DEBUG_TX_REPLY(priv, 819 807 "TXQ %d status %s (0x%08x) "
+116 -38
drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
··· 31 31 #include <linux/module.h> 32 32 #include <linux/init.h> 33 33 #include <linux/sched.h> 34 + #include <linux/dma-mapping.h> 34 35 35 36 #include "iwl-dev.h" 36 37 #include "iwl-core.h" ··· 73 72 {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS} 74 73 }; 75 74 75 + /****************************************************************************** 76 + * 77 + * uCode download functions 78 + * 79 + ******************************************************************************/ 80 + 81 + static void iwl_free_fw_desc(struct iwl_bus *bus, struct fw_desc *desc) 82 + { 83 + if (desc->v_addr) 84 + dma_free_coherent(bus->dev, desc->len, 85 + desc->v_addr, desc->p_addr); 86 + desc->v_addr = NULL; 87 + desc->len = 0; 88 + } 89 + 90 + static void iwl_free_fw_img(struct iwl_bus *bus, struct fw_img *img) 91 + { 92 + iwl_free_fw_desc(bus, &img->code); 93 + iwl_free_fw_desc(bus, &img->data); 94 + } 95 + 96 + void iwl_dealloc_ucode(struct iwl_trans *trans) 97 + { 98 + iwl_free_fw_img(bus(trans), &trans->ucode_rt); 99 + iwl_free_fw_img(bus(trans), &trans->ucode_init); 100 + iwl_free_fw_img(bus(trans), &trans->ucode_wowlan); 101 + } 102 + 103 + int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, 104 + const void *data, size_t len) 105 + { 106 + if (!len) { 107 + desc->v_addr = NULL; 108 + return -EINVAL; 109 + } 110 + 111 + desc->v_addr = dma_alloc_coherent(bus->dev, len, 112 + &desc->p_addr, GFP_KERNEL); 113 + if (!desc->v_addr) 114 + return -ENOMEM; 115 + 116 + desc->len = len; 117 + memcpy(desc->v_addr, data, len); 118 + return 0; 119 + } 120 + 76 121 /* 77 122 * ucode 78 123 */ 79 - static int iwlagn_load_section(struct iwl_priv *priv, const char *name, 124 + static int iwlagn_load_section(struct iwl_trans *trans, const char *name, 80 125 struct fw_desc *image, u32 dst_addr) 81 126 { 127 + struct iwl_bus *bus = bus(trans); 82 128 dma_addr_t phy_addr = image->p_addr; 83 129 u32 byte_cnt = image->len; 84 130 int ret; 85 131 86 - priv->ucode_write_complete = 0; 132 + trans->ucode_write_complete = 0; 87 133 88 - iwl_write_direct32(bus(priv), 134 + iwl_write_direct32(bus, 89 135 FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), 90 136 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); 91 137 92 - iwl_write_direct32(bus(priv), 138 + iwl_write_direct32(bus, 93 139 FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); 94 140 95 - iwl_write_direct32(bus(priv), 141 + iwl_write_direct32(bus, 96 142 FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), 97 143 phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); 98 144 99 - iwl_write_direct32(bus(priv), 145 + iwl_write_direct32(bus, 100 146 FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), 101 147 (iwl_get_dma_hi_addr(phy_addr) 102 148 << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt); 103 149 104 - iwl_write_direct32(bus(priv), 150 + iwl_write_direct32(bus, 105 151 FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), 106 152 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | 107 153 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX | 108 154 FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID); 109 155 110 - iwl_write_direct32(bus(priv), 156 + iwl_write_direct32(bus, 111 157 FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), 112 158 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | 113 159 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | 114 160 FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); 115 161 116 - IWL_DEBUG_FW(priv, "%s uCode section being loaded...\n", name); 117 - ret = wait_event_timeout(priv->shrd->wait_command_queue, 118 - priv->ucode_write_complete, 5 * HZ); 162 + IWL_DEBUG_FW(bus, "%s uCode section being loaded...\n", name); 163 + ret = wait_event_timeout(trans->shrd->wait_command_queue, 164 + trans->ucode_write_complete, 5 * HZ); 119 165 if (!ret) { 120 - IWL_ERR(priv, "Could not load the %s uCode section\n", 166 + IWL_ERR(trans, "Could not load the %s uCode section\n", 121 167 name); 122 168 return -ETIMEDOUT; 123 169 } ··· 172 124 return 0; 173 125 } 174 126 175 - static int iwlagn_load_given_ucode(struct iwl_priv *priv, 176 - struct fw_img *image) 127 + static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, 128 + enum iwl_ucode_type ucode_type) 129 + { 130 + switch (ucode_type) { 131 + case IWL_UCODE_INIT: 132 + return &trans->ucode_init; 133 + case IWL_UCODE_WOWLAN: 134 + return &trans->ucode_wowlan; 135 + case IWL_UCODE_REGULAR: 136 + return &trans->ucode_rt; 137 + case IWL_UCODE_NONE: 138 + break; 139 + } 140 + return NULL; 141 + } 142 + 143 + static int iwlagn_load_given_ucode(struct iwl_trans *trans, 144 + enum iwl_ucode_type ucode_type) 177 145 { 178 146 int ret = 0; 147 + struct fw_img *image = iwl_get_ucode_image(trans, ucode_type); 179 148 180 - ret = iwlagn_load_section(priv, "INST", &image->code, 149 + 150 + if (!image) { 151 + IWL_ERR(trans, "Invalid ucode requested (%d)\n", 152 + ucode_type); 153 + return -EINVAL; 154 + } 155 + 156 + ret = iwlagn_load_section(trans, "INST", &image->code, 181 157 IWLAGN_RTC_INST_LOWER_BOUND); 182 158 if (ret) 183 159 return ret; 184 160 185 - return iwlagn_load_section(priv, "DATA", &image->data, 161 + return iwlagn_load_section(trans, "DATA", &image->data, 186 162 IWLAGN_RTC_DATA_LOWER_BOUND); 187 163 } 188 164 ··· 490 418 * using sample data 100 bytes apart. If these sample points are good, 491 419 * it's a pretty good bet that everything between them is good, too. 492 420 */ 493 - static int iwl_verify_inst_sparse(struct iwl_priv *priv, 421 + static int iwl_verify_inst_sparse(struct iwl_bus *bus, 494 422 struct fw_desc *fw_desc) 495 423 { 496 424 __le32 *image = (__le32 *)fw_desc->v_addr; ··· 498 426 u32 val; 499 427 u32 i; 500 428 501 - IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); 429 + IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); 502 430 503 431 for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { 504 432 /* read data comes through single port, auto-incr addr */ 505 433 /* NOTE: Use the debugless read so we don't flood kernel log 506 434 * if IWL_DL_IO is set */ 507 - iwl_write_direct32(bus(priv), HBUS_TARG_MEM_RADDR, 435 + iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, 508 436 i + IWLAGN_RTC_INST_LOWER_BOUND); 509 - val = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); 437 + val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); 510 438 if (val != le32_to_cpu(*image)) 511 439 return -EIO; 512 440 } ··· 514 442 return 0; 515 443 } 516 444 517 - static void iwl_print_mismatch_inst(struct iwl_priv *priv, 445 + static void iwl_print_mismatch_inst(struct iwl_bus *bus, 518 446 struct fw_desc *fw_desc) 519 447 { 520 448 __le32 *image = (__le32 *)fw_desc->v_addr; ··· 523 451 u32 offs; 524 452 int errors = 0; 525 453 526 - IWL_DEBUG_FW(priv, "ucode inst image size is %u\n", len); 454 + IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); 527 455 528 - iwl_write_direct32(bus(priv), HBUS_TARG_MEM_RADDR, 456 + iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, 529 457 IWLAGN_RTC_INST_LOWER_BOUND); 530 458 531 459 for (offs = 0; 532 460 offs < len && errors < 20; 533 461 offs += sizeof(u32), image++) { 534 462 /* read data comes through single port, auto-incr addr */ 535 - val = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); 463 + val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); 536 464 if (val != le32_to_cpu(*image)) { 537 - IWL_ERR(priv, "uCode INST section at " 465 + IWL_ERR(bus, "uCode INST section at " 538 466 "offset 0x%x, is 0x%x, s/b 0x%x\n", 539 467 offs, val, le32_to_cpu(*image)); 540 468 errors++; ··· 546 474 * iwl_verify_ucode - determine which instruction image is in SRAM, 547 475 * and verify its contents 548 476 */ 549 - static int iwl_verify_ucode(struct iwl_priv *priv, struct fw_img *img) 477 + static int iwl_verify_ucode(struct iwl_trans *trans, 478 + enum iwl_ucode_type ucode_type) 550 479 { 551 - if (!iwl_verify_inst_sparse(priv, &img->code)) { 552 - IWL_DEBUG_FW(priv, "uCode is good in inst SRAM\n"); 480 + struct fw_img *img = iwl_get_ucode_image(trans, ucode_type); 481 + 482 + if (!img) { 483 + IWL_ERR(trans, "Invalid ucode requested (%d)\n", ucode_type); 484 + return -EINVAL; 485 + } 486 + 487 + if (!iwl_verify_inst_sparse(bus(trans), &img->code)) { 488 + IWL_DEBUG_FW(trans, "uCode is good in inst SRAM\n"); 553 489 return 0; 554 490 } 555 491 556 - IWL_ERR(priv, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); 492 + IWL_ERR(trans, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); 557 493 558 - iwl_print_mismatch_inst(priv, &img->code); 494 + iwl_print_mismatch_inst(bus(trans), &img->code); 559 495 return -EIO; 560 496 } 561 497 ··· 599 519 #define UCODE_CALIB_TIMEOUT (2*HZ) 600 520 601 521 int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, 602 - struct fw_img *image, 603 - enum iwlagn_ucode_type ucode_type) 522 + enum iwl_ucode_type ucode_type) 604 523 { 605 524 struct iwl_notification_wait alive_wait; 606 525 struct iwlagn_alive_data alive_data; 607 526 int ret; 608 - enum iwlagn_ucode_type old_type; 527 + enum iwl_ucode_type old_type; 609 528 610 529 ret = iwl_trans_start_device(trans(priv)); 611 530 if (ret) ··· 616 537 old_type = priv->ucode_type; 617 538 priv->ucode_type = ucode_type; 618 539 619 - ret = iwlagn_load_given_ucode(priv, image); 540 + ret = iwlagn_load_given_ucode(trans(priv), ucode_type); 620 541 if (ret) { 621 542 priv->ucode_type = old_type; 622 543 iwlagn_remove_notification(priv, &alive_wait); ··· 647 568 * skip it for WoWLAN. 648 569 */ 649 570 if (ucode_type != IWL_UCODE_WOWLAN) { 650 - ret = iwl_verify_ucode(priv, image); 571 + ret = iwl_verify_ucode(trans(priv), ucode_type); 651 572 if (ret) { 652 573 priv->ucode_type = old_type; 653 574 return ret; ··· 676 597 lockdep_assert_held(&priv->shrd->mutex); 677 598 678 599 /* No init ucode required? Curious, but maybe ok */ 679 - if (!priv->ucode_init.code.len) 600 + if (!trans(priv)->ucode_init.code.len) 680 601 return 0; 681 602 682 603 if (priv->ucode_type != IWL_UCODE_NONE) ··· 687 608 NULL, NULL); 688 609 689 610 /* Will also start the device */ 690 - ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_init, 691 - IWL_UCODE_INIT); 611 + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); 692 612 if (ret) 693 613 goto error; 694 614
+16 -1527
drivers/net/wireless/iwlwifi/iwl-agn.c
··· 30 30 #include <linux/module.h> 31 31 #include <linux/init.h> 32 32 #include <linux/slab.h> 33 - #include <linux/dma-mapping.h> 34 33 #include <linux/delay.h> 35 34 #include <linux/sched.h> 36 35 #include <linux/skbuff.h> ··· 451 452 iwlagn_dev_txfifo_flush(priv, IWL_DROP_ALL); 452 453 } 453 454 454 - /****************************************************************************** 455 - * 456 - * uCode download functions 457 - * 458 - ******************************************************************************/ 459 - 460 - static void iwl_free_fw_desc(struct iwl_priv *priv, struct fw_desc *desc) 461 - { 462 - if (desc->v_addr) 463 - dma_free_coherent(bus(priv)->dev, desc->len, 464 - desc->v_addr, desc->p_addr); 465 - desc->v_addr = NULL; 466 - desc->len = 0; 467 - } 468 - 469 - static void iwl_free_fw_img(struct iwl_priv *priv, struct fw_img *img) 470 - { 471 - iwl_free_fw_desc(priv, &img->code); 472 - iwl_free_fw_desc(priv, &img->data); 473 - } 474 - 475 - static void iwl_dealloc_ucode(struct iwl_priv *priv) 476 - { 477 - iwl_free_fw_img(priv, &priv->ucode_rt); 478 - iwl_free_fw_img(priv, &priv->ucode_init); 479 - iwl_free_fw_img(priv, &priv->ucode_wowlan); 480 - } 481 - 482 - static int iwl_alloc_fw_desc(struct iwl_priv *priv, struct fw_desc *desc, 483 - const void *data, size_t len) 484 - { 485 - if (!len) { 486 - desc->v_addr = NULL; 487 - return -EINVAL; 488 - } 489 - 490 - desc->v_addr = dma_alloc_coherent(bus(priv)->dev, len, 491 - &desc->p_addr, GFP_KERNEL); 492 - if (!desc->v_addr) 493 - return -ENOMEM; 494 - 495 - desc->len = len; 496 - memcpy(desc->v_addr, data, len); 497 - return 0; 498 - } 499 - 500 455 static void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) 501 456 { 502 457 int i; ··· 508 555 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); 509 556 } 510 557 511 - 512 - struct iwlagn_ucode_capabilities { 513 - u32 max_probe_length; 514 - u32 standard_phy_calibration_size; 515 - u32 flags; 516 - }; 517 - 518 558 static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); 519 - static int iwlagn_mac_setup_register(struct iwl_priv *priv, 520 - struct iwlagn_ucode_capabilities *capa); 521 559 522 560 #define UCODE_EXPERIMENTAL_INDEX 100 523 561 #define UCODE_EXPERIMENTAL_TAG "exp" ··· 984 1040 /* Runtime instructions and 2 copies of data: 985 1041 * 1) unmodified from disk 986 1042 * 2) backup cache for save/restore during power-downs */ 987 - if (iwl_alloc_fw_desc(priv, &priv->ucode_rt.code, 1043 + if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_rt.code, 988 1044 pieces.inst, pieces.inst_size)) 989 1045 goto err_pci_alloc; 990 - if (iwl_alloc_fw_desc(priv, &priv->ucode_rt.data, 1046 + if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_rt.data, 991 1047 pieces.data, pieces.data_size)) 992 1048 goto err_pci_alloc; 993 1049 994 1050 /* Initialization instructions and data */ 995 1051 if (pieces.init_size && pieces.init_data_size) { 996 - if (iwl_alloc_fw_desc(priv, &priv->ucode_init.code, 1052 + if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_init.code, 997 1053 pieces.init, pieces.init_size)) 998 1054 goto err_pci_alloc; 999 - if (iwl_alloc_fw_desc(priv, &priv->ucode_init.data, 1055 + if (iwl_alloc_fw_desc(bus(priv), &trans(priv)->ucode_init.data, 1000 1056 pieces.init_data, pieces.init_data_size)) 1001 1057 goto err_pci_alloc; 1002 1058 } 1003 1059 1004 1060 /* WoWLAN instructions and data */ 1005 1061 if (pieces.wowlan_inst_size && pieces.wowlan_data_size) { 1006 - if (iwl_alloc_fw_desc(priv, &priv->ucode_wowlan.code, 1062 + if (iwl_alloc_fw_desc(bus(priv), 1063 + &trans(priv)->ucode_wowlan.code, 1007 1064 pieces.wowlan_inst, 1008 1065 pieces.wowlan_inst_size)) 1009 1066 goto err_pci_alloc; 1010 - if (iwl_alloc_fw_desc(priv, &priv->ucode_wowlan.data, 1067 + if (iwl_alloc_fw_desc(bus(priv), 1068 + &trans(priv)->ucode_wowlan.data, 1011 1069 pieces.wowlan_data, 1012 1070 pieces.wowlan_data_size)) 1013 1071 goto err_pci_alloc; ··· 1102 1156 1103 1157 err_pci_alloc: 1104 1158 IWL_ERR(priv, "failed to allocate pci memory\n"); 1105 - iwl_dealloc_ucode(priv); 1159 + iwl_dealloc_ucode(trans(priv)); 1106 1160 out_unbind: 1107 1161 complete(&priv->firmware_loading_complete); 1108 1162 device_release_driver(bus(priv)->dev); ··· 1298 1352 1299 1353 static void iwl_cancel_deferred_work(struct iwl_priv *priv); 1300 1354 1301 - static void __iwl_down(struct iwl_priv *priv) 1355 + void __iwl_down(struct iwl_priv *priv) 1302 1356 { 1303 1357 int exit_pending; 1304 1358 ··· 1361 1415 priv->beacon_skb = NULL; 1362 1416 } 1363 1417 1364 - static void iwl_down(struct iwl_priv *priv) 1418 + void iwl_down(struct iwl_priv *priv) 1365 1419 { 1366 1420 mutex_lock(&priv->shrd->mutex); 1367 1421 __iwl_down(priv); ··· 1369 1423 1370 1424 iwl_cancel_deferred_work(priv); 1371 1425 } 1372 - 1373 - #define MAX_HW_RESTARTS 5 1374 - 1375 - static int __iwl_up(struct iwl_priv *priv) 1376 - { 1377 - struct iwl_rxon_context *ctx; 1378 - int ret; 1379 - 1380 - lockdep_assert_held(&priv->shrd->mutex); 1381 - 1382 - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { 1383 - IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); 1384 - return -EIO; 1385 - } 1386 - 1387 - for_each_context(priv, ctx) { 1388 - ret = iwlagn_alloc_bcast_station(priv, ctx); 1389 - if (ret) { 1390 - iwl_dealloc_bcast_stations(priv); 1391 - return ret; 1392 - } 1393 - } 1394 - 1395 - ret = iwlagn_run_init_ucode(priv); 1396 - if (ret) { 1397 - IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret); 1398 - goto error; 1399 - } 1400 - 1401 - ret = iwlagn_load_ucode_wait_alive(priv, 1402 - &priv->ucode_rt, 1403 - IWL_UCODE_REGULAR); 1404 - if (ret) { 1405 - IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); 1406 - goto error; 1407 - } 1408 - 1409 - ret = iwl_alive_start(priv); 1410 - if (ret) 1411 - goto error; 1412 - return 0; 1413 - 1414 - error: 1415 - set_bit(STATUS_EXIT_PENDING, &priv->shrd->status); 1416 - __iwl_down(priv); 1417 - clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status); 1418 - 1419 - IWL_ERR(priv, "Unable to initialize device.\n"); 1420 - return ret; 1421 - } 1422 - 1423 1426 1424 1427 /***************************************************************************** 1425 1428 * ··· 1397 1502 mutex_unlock(&priv->shrd->mutex); 1398 1503 } 1399 1504 1400 - static void iwlagn_prepare_restart(struct iwl_priv *priv) 1505 + void iwlagn_prepare_restart(struct iwl_priv *priv) 1401 1506 { 1402 1507 struct iwl_rxon_context *ctx; 1403 1508 bool bt_full_concurrent; ··· 1454 1559 } 1455 1560 } 1456 1561 1457 - /***************************************************************************** 1458 - * 1459 - * mac80211 entry point functions 1460 - * 1461 - *****************************************************************************/ 1462 1562 1463 - static const struct ieee80211_iface_limit iwlagn_sta_ap_limits[] = { 1464 - { 1465 - .max = 1, 1466 - .types = BIT(NL80211_IFTYPE_STATION), 1467 - }, 1468 - { 1469 - .max = 1, 1470 - .types = BIT(NL80211_IFTYPE_AP), 1471 - }, 1472 - }; 1473 1563 1474 - static const struct ieee80211_iface_limit iwlagn_2sta_limits[] = { 1475 - { 1476 - .max = 2, 1477 - .types = BIT(NL80211_IFTYPE_STATION), 1478 - }, 1479 - }; 1480 - 1481 - static const struct ieee80211_iface_limit iwlagn_p2p_sta_go_limits[] = { 1482 - { 1483 - .max = 1, 1484 - .types = BIT(NL80211_IFTYPE_STATION), 1485 - }, 1486 - { 1487 - .max = 1, 1488 - .types = BIT(NL80211_IFTYPE_P2P_GO) | 1489 - BIT(NL80211_IFTYPE_AP), 1490 - }, 1491 - }; 1492 - 1493 - static const struct ieee80211_iface_limit iwlagn_p2p_2sta_limits[] = { 1494 - { 1495 - .max = 2, 1496 - .types = BIT(NL80211_IFTYPE_STATION), 1497 - }, 1498 - { 1499 - .max = 1, 1500 - .types = BIT(NL80211_IFTYPE_P2P_CLIENT), 1501 - }, 1502 - }; 1503 - 1504 - static const struct ieee80211_iface_combination 1505 - iwlagn_iface_combinations_dualmode[] = { 1506 - { .num_different_channels = 1, 1507 - .max_interfaces = 2, 1508 - .beacon_int_infra_match = true, 1509 - .limits = iwlagn_sta_ap_limits, 1510 - .n_limits = ARRAY_SIZE(iwlagn_sta_ap_limits), 1511 - }, 1512 - { .num_different_channels = 1, 1513 - .max_interfaces = 2, 1514 - .limits = iwlagn_2sta_limits, 1515 - .n_limits = ARRAY_SIZE(iwlagn_2sta_limits), 1516 - }, 1517 - }; 1518 - 1519 - static const struct ieee80211_iface_combination 1520 - iwlagn_iface_combinations_p2p[] = { 1521 - { .num_different_channels = 1, 1522 - .max_interfaces = 2, 1523 - .beacon_int_infra_match = true, 1524 - .limits = iwlagn_p2p_sta_go_limits, 1525 - .n_limits = ARRAY_SIZE(iwlagn_p2p_sta_go_limits), 1526 - }, 1527 - { .num_different_channels = 1, 1528 - .max_interfaces = 2, 1529 - .limits = iwlagn_p2p_2sta_limits, 1530 - .n_limits = ARRAY_SIZE(iwlagn_p2p_2sta_limits), 1531 - }, 1532 - }; 1533 - 1534 - /* 1535 - * Not a mac80211 entry point function, but it fits in with all the 1536 - * other mac80211 functions grouped here. 1537 - */ 1538 - static int iwlagn_mac_setup_register(struct iwl_priv *priv, 1539 - struct iwlagn_ucode_capabilities *capa) 1540 - { 1541 - int ret; 1542 - struct ieee80211_hw *hw = priv->hw; 1543 - struct iwl_rxon_context *ctx; 1544 - 1545 - hw->rate_control_algorithm = "iwl-agn-rs"; 1546 - 1547 - /* Tell mac80211 our characteristics */ 1548 - hw->flags = IEEE80211_HW_SIGNAL_DBM | 1549 - IEEE80211_HW_AMPDU_AGGREGATION | 1550 - IEEE80211_HW_NEED_DTIM_PERIOD | 1551 - IEEE80211_HW_SPECTRUM_MGMT | 1552 - IEEE80211_HW_REPORTS_TX_ACK_STATUS; 1553 - 1554 - /* 1555 - * Including the following line will crash some AP's. This 1556 - * workaround removes the stimulus which causes the crash until 1557 - * the AP software can be fixed. 1558 - hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF; 1559 - */ 1560 - 1561 - hw->flags |= IEEE80211_HW_SUPPORTS_PS | 1562 - IEEE80211_HW_SUPPORTS_DYNAMIC_PS; 1563 - 1564 - if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) 1565 - hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | 1566 - IEEE80211_HW_SUPPORTS_STATIC_SMPS; 1567 - 1568 - if (capa->flags & IWL_UCODE_TLV_FLAGS_MFP) 1569 - hw->flags |= IEEE80211_HW_MFP_CAPABLE; 1570 - 1571 - hw->sta_data_size = sizeof(struct iwl_station_priv); 1572 - hw->vif_data_size = sizeof(struct iwl_vif_priv); 1573 - 1574 - for_each_context(priv, ctx) { 1575 - hw->wiphy->interface_modes |= ctx->interface_modes; 1576 - hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; 1577 - } 1578 - 1579 - BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); 1580 - 1581 - if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) { 1582 - hw->wiphy->iface_combinations = iwlagn_iface_combinations_p2p; 1583 - hw->wiphy->n_iface_combinations = 1584 - ARRAY_SIZE(iwlagn_iface_combinations_p2p); 1585 - } else if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { 1586 - hw->wiphy->iface_combinations = iwlagn_iface_combinations_dualmode; 1587 - hw->wiphy->n_iface_combinations = 1588 - ARRAY_SIZE(iwlagn_iface_combinations_dualmode); 1589 - } 1590 - 1591 - hw->wiphy->max_remain_on_channel_duration = 1000; 1592 - 1593 - hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | 1594 - WIPHY_FLAG_DISABLE_BEACON_HINTS | 1595 - WIPHY_FLAG_IBSS_RSN; 1596 - 1597 - if (priv->ucode_wowlan.code.len && device_can_wakeup(bus(priv)->dev)) { 1598 - hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | 1599 - WIPHY_WOWLAN_DISCONNECT | 1600 - WIPHY_WOWLAN_EAP_IDENTITY_REQ | 1601 - WIPHY_WOWLAN_RFKILL_RELEASE; 1602 - if (!iwlagn_mod_params.sw_crypto) 1603 - hw->wiphy->wowlan.flags |= 1604 - WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | 1605 - WIPHY_WOWLAN_GTK_REKEY_FAILURE; 1606 - 1607 - hw->wiphy->wowlan.n_patterns = IWLAGN_WOWLAN_MAX_PATTERNS; 1608 - hw->wiphy->wowlan.pattern_min_len = 1609 - IWLAGN_WOWLAN_MIN_PATTERN_LEN; 1610 - hw->wiphy->wowlan.pattern_max_len = 1611 - IWLAGN_WOWLAN_MAX_PATTERN_LEN; 1612 - } 1613 - 1614 - if (iwlagn_mod_params.power_save) 1615 - hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; 1616 - else 1617 - hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 1618 - 1619 - hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; 1620 - /* we create the 802.11 header and a zero-length SSID element */ 1621 - hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2; 1622 - 1623 - /* Default value; 4 EDCA QOS priorities */ 1624 - hw->queues = 4; 1625 - 1626 - hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; 1627 - 1628 - if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) 1629 - priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = 1630 - &priv->bands[IEEE80211_BAND_2GHZ]; 1631 - if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) 1632 - priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = 1633 - &priv->bands[IEEE80211_BAND_5GHZ]; 1634 - 1635 - iwl_leds_init(priv); 1636 - 1637 - ret = ieee80211_register_hw(priv->hw); 1638 - if (ret) { 1639 - IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); 1640 - return ret; 1641 - } 1642 - priv->mac80211_registered = 1; 1643 - 1644 - return 0; 1645 - } 1646 - 1647 - 1648 - static int iwlagn_mac_start(struct ieee80211_hw *hw) 1649 - { 1650 - struct iwl_priv *priv = hw->priv; 1651 - int ret; 1652 - 1653 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1654 - 1655 - /* we should be verifying the device is ready to be opened */ 1656 - mutex_lock(&priv->shrd->mutex); 1657 - ret = __iwl_up(priv); 1658 - mutex_unlock(&priv->shrd->mutex); 1659 - if (ret) 1660 - return ret; 1661 - 1662 - IWL_DEBUG_INFO(priv, "Start UP work done.\n"); 1663 - 1664 - /* Now we should be done, and the READY bit should be set. */ 1665 - if (WARN_ON(!test_bit(STATUS_READY, &priv->shrd->status))) 1666 - ret = -EIO; 1667 - 1668 - iwlagn_led_enable(priv); 1669 - 1670 - priv->is_open = 1; 1671 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1672 - return 0; 1673 - } 1674 - 1675 - static void iwlagn_mac_stop(struct ieee80211_hw *hw) 1676 - { 1677 - struct iwl_priv *priv = hw->priv; 1678 - 1679 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1680 - 1681 - if (!priv->is_open) 1682 - return; 1683 - 1684 - priv->is_open = 0; 1685 - 1686 - iwl_down(priv); 1687 - 1688 - flush_workqueue(priv->shrd->workqueue); 1689 - 1690 - /* User space software may expect getting rfkill changes 1691 - * even if interface is down */ 1692 - iwl_write32(bus(priv), CSR_INT, 0xFFFFFFFF); 1693 - iwl_enable_rfkill_int(priv); 1694 - 1695 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1696 - } 1697 - 1698 - #ifdef CONFIG_PM_SLEEP 1699 - static int iwlagn_send_patterns(struct iwl_priv *priv, 1700 - struct cfg80211_wowlan *wowlan) 1701 - { 1702 - struct iwlagn_wowlan_patterns_cmd *pattern_cmd; 1703 - struct iwl_host_cmd cmd = { 1704 - .id = REPLY_WOWLAN_PATTERNS, 1705 - .dataflags[0] = IWL_HCMD_DFL_NOCOPY, 1706 - .flags = CMD_SYNC, 1707 - }; 1708 - int i, err; 1709 - 1710 - if (!wowlan->n_patterns) 1711 - return 0; 1712 - 1713 - cmd.len[0] = sizeof(*pattern_cmd) + 1714 - wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern); 1715 - 1716 - pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL); 1717 - if (!pattern_cmd) 1718 - return -ENOMEM; 1719 - 1720 - pattern_cmd->n_patterns = cpu_to_le32(wowlan->n_patterns); 1721 - 1722 - for (i = 0; i < wowlan->n_patterns; i++) { 1723 - int mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8); 1724 - 1725 - memcpy(&pattern_cmd->patterns[i].mask, 1726 - wowlan->patterns[i].mask, mask_len); 1727 - memcpy(&pattern_cmd->patterns[i].pattern, 1728 - wowlan->patterns[i].pattern, 1729 - wowlan->patterns[i].pattern_len); 1730 - pattern_cmd->patterns[i].mask_size = mask_len; 1731 - pattern_cmd->patterns[i].pattern_size = 1732 - wowlan->patterns[i].pattern_len; 1733 - } 1734 - 1735 - cmd.data[0] = pattern_cmd; 1736 - err = iwl_trans_send_cmd(trans(priv), &cmd); 1737 - kfree(pattern_cmd); 1738 - return err; 1739 - } 1740 - #endif 1741 - 1742 - static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, 1743 - struct ieee80211_vif *vif, 1744 - struct cfg80211_gtk_rekey_data *data) 1745 - { 1746 - struct iwl_priv *priv = hw->priv; 1747 - 1748 - if (iwlagn_mod_params.sw_crypto) 1749 - return; 1750 - 1751 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1752 - mutex_lock(&priv->shrd->mutex); 1753 - 1754 - if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif) 1755 - goto out; 1756 - 1757 - memcpy(priv->kek, data->kek, NL80211_KEK_LEN); 1758 - memcpy(priv->kck, data->kck, NL80211_KCK_LEN); 1759 - priv->replay_ctr = cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr)); 1760 - priv->have_rekey_data = true; 1761 - 1762 - out: 1763 - mutex_unlock(&priv->shrd->mutex); 1764 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1765 - } 1766 - 1767 - struct wowlan_key_data { 1768 - struct iwl_rxon_context *ctx; 1769 - struct iwlagn_wowlan_rsc_tsc_params_cmd *rsc_tsc; 1770 - struct iwlagn_wowlan_tkip_params_cmd *tkip; 1771 - const u8 *bssid; 1772 - bool error, use_rsc_tsc, use_tkip; 1773 - }; 1774 - 1775 - #ifdef CONFIG_PM_SLEEP 1776 - static void iwlagn_convert_p1k(u16 *p1k, __le16 *out) 1777 - { 1778 - int i; 1779 - 1780 - for (i = 0; i < IWLAGN_P1K_SIZE; i++) 1781 - out[i] = cpu_to_le16(p1k[i]); 1782 - } 1783 - 1784 - static void iwlagn_wowlan_program_keys(struct ieee80211_hw *hw, 1785 - struct ieee80211_vif *vif, 1786 - struct ieee80211_sta *sta, 1787 - struct ieee80211_key_conf *key, 1788 - void *_data) 1789 - { 1790 - struct iwl_priv *priv = hw->priv; 1791 - struct wowlan_key_data *data = _data; 1792 - struct iwl_rxon_context *ctx = data->ctx; 1793 - struct aes_sc *aes_sc, *aes_tx_sc = NULL; 1794 - struct tkip_sc *tkip_sc, *tkip_tx_sc = NULL; 1795 - struct iwlagn_p1k_cache *rx_p1ks; 1796 - u8 *rx_mic_key; 1797 - struct ieee80211_key_seq seq; 1798 - u32 cur_rx_iv32 = 0; 1799 - u16 p1k[IWLAGN_P1K_SIZE]; 1800 - int ret, i; 1801 - 1802 - mutex_lock(&priv->shrd->mutex); 1803 - 1804 - if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || 1805 - key->cipher == WLAN_CIPHER_SUITE_WEP104) && 1806 - !sta && !ctx->key_mapping_keys) 1807 - ret = iwl_set_default_wep_key(priv, ctx, key); 1808 - else 1809 - ret = iwl_set_dynamic_key(priv, ctx, key, sta); 1810 - 1811 - if (ret) { 1812 - IWL_ERR(priv, "Error setting key during suspend!\n"); 1813 - data->error = true; 1814 - } 1815 - 1816 - switch (key->cipher) { 1817 - case WLAN_CIPHER_SUITE_TKIP: 1818 - if (sta) { 1819 - tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.unicast_rsc; 1820 - tkip_tx_sc = &data->rsc_tsc->all_tsc_rsc.tkip.tsc; 1821 - 1822 - rx_p1ks = data->tkip->rx_uni; 1823 - 1824 - ieee80211_get_key_tx_seq(key, &seq); 1825 - tkip_tx_sc->iv16 = cpu_to_le16(seq.tkip.iv16); 1826 - tkip_tx_sc->iv32 = cpu_to_le32(seq.tkip.iv32); 1827 - 1828 - ieee80211_get_tkip_p1k_iv(key, seq.tkip.iv32, p1k); 1829 - iwlagn_convert_p1k(p1k, data->tkip->tx.p1k); 1830 - 1831 - memcpy(data->tkip->mic_keys.tx, 1832 - &key->key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY], 1833 - IWLAGN_MIC_KEY_SIZE); 1834 - 1835 - rx_mic_key = data->tkip->mic_keys.rx_unicast; 1836 - } else { 1837 - tkip_sc = data->rsc_tsc->all_tsc_rsc.tkip.multicast_rsc; 1838 - rx_p1ks = data->tkip->rx_multi; 1839 - rx_mic_key = data->tkip->mic_keys.rx_mcast; 1840 - } 1841 - 1842 - /* 1843 - * For non-QoS this relies on the fact that both the uCode and 1844 - * mac80211 use TID 0 (as they need to to avoid replay attacks) 1845 - * for checking the IV in the frames. 1846 - */ 1847 - for (i = 0; i < IWLAGN_NUM_RSC; i++) { 1848 - ieee80211_get_key_rx_seq(key, i, &seq); 1849 - tkip_sc[i].iv16 = cpu_to_le16(seq.tkip.iv16); 1850 - tkip_sc[i].iv32 = cpu_to_le32(seq.tkip.iv32); 1851 - /* wrapping isn't allowed, AP must rekey */ 1852 - if (seq.tkip.iv32 > cur_rx_iv32) 1853 - cur_rx_iv32 = seq.tkip.iv32; 1854 - } 1855 - 1856 - ieee80211_get_tkip_rx_p1k(key, data->bssid, cur_rx_iv32, p1k); 1857 - iwlagn_convert_p1k(p1k, rx_p1ks[0].p1k); 1858 - ieee80211_get_tkip_rx_p1k(key, data->bssid, 1859 - cur_rx_iv32 + 1, p1k); 1860 - iwlagn_convert_p1k(p1k, rx_p1ks[1].p1k); 1861 - 1862 - memcpy(rx_mic_key, 1863 - &key->key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY], 1864 - IWLAGN_MIC_KEY_SIZE); 1865 - 1866 - data->use_tkip = true; 1867 - data->use_rsc_tsc = true; 1868 - break; 1869 - case WLAN_CIPHER_SUITE_CCMP: 1870 - if (sta) { 1871 - u8 *pn = seq.ccmp.pn; 1872 - 1873 - aes_sc = data->rsc_tsc->all_tsc_rsc.aes.unicast_rsc; 1874 - aes_tx_sc = &data->rsc_tsc->all_tsc_rsc.aes.tsc; 1875 - 1876 - ieee80211_get_key_tx_seq(key, &seq); 1877 - aes_tx_sc->pn = cpu_to_le64( 1878 - (u64)pn[5] | 1879 - ((u64)pn[4] << 8) | 1880 - ((u64)pn[3] << 16) | 1881 - ((u64)pn[2] << 24) | 1882 - ((u64)pn[1] << 32) | 1883 - ((u64)pn[0] << 40)); 1884 - } else 1885 - aes_sc = data->rsc_tsc->all_tsc_rsc.aes.multicast_rsc; 1886 - 1887 - /* 1888 - * For non-QoS this relies on the fact that both the uCode and 1889 - * mac80211 use TID 0 for checking the IV in the frames. 1890 - */ 1891 - for (i = 0; i < IWLAGN_NUM_RSC; i++) { 1892 - u8 *pn = seq.ccmp.pn; 1893 - 1894 - ieee80211_get_key_rx_seq(key, i, &seq); 1895 - aes_sc->pn = cpu_to_le64( 1896 - (u64)pn[5] | 1897 - ((u64)pn[4] << 8) | 1898 - ((u64)pn[3] << 16) | 1899 - ((u64)pn[2] << 24) | 1900 - ((u64)pn[1] << 32) | 1901 - ((u64)pn[0] << 40)); 1902 - } 1903 - data->use_rsc_tsc = true; 1904 - break; 1905 - } 1906 - 1907 - mutex_unlock(&priv->shrd->mutex); 1908 - } 1909 - 1910 - static int iwlagn_mac_suspend(struct ieee80211_hw *hw, 1911 - struct cfg80211_wowlan *wowlan) 1912 - { 1913 - struct iwl_priv *priv = hw->priv; 1914 - struct iwlagn_wowlan_wakeup_filter_cmd wakeup_filter_cmd; 1915 - struct iwl_rxon_cmd rxon; 1916 - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 1917 - struct iwlagn_wowlan_kek_kck_material_cmd kek_kck_cmd; 1918 - struct iwlagn_wowlan_tkip_params_cmd tkip_cmd = {}; 1919 - struct wowlan_key_data key_data = { 1920 - .ctx = ctx, 1921 - .bssid = ctx->active.bssid_addr, 1922 - .use_rsc_tsc = false, 1923 - .tkip = &tkip_cmd, 1924 - .use_tkip = false, 1925 - }; 1926 - int ret, i; 1927 - u16 seq; 1928 - 1929 - if (WARN_ON(!wowlan)) 1930 - return -EINVAL; 1931 - 1932 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1933 - mutex_lock(&priv->shrd->mutex); 1934 - 1935 - /* Don't attempt WoWLAN when not associated, tear down instead. */ 1936 - if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION || 1937 - !iwl_is_associated_ctx(ctx)) { 1938 - ret = 1; 1939 - goto out; 1940 - } 1941 - 1942 - key_data.rsc_tsc = kzalloc(sizeof(*key_data.rsc_tsc), GFP_KERNEL); 1943 - if (!key_data.rsc_tsc) { 1944 - ret = -ENOMEM; 1945 - goto out; 1946 - } 1947 - 1948 - memset(&wakeup_filter_cmd, 0, sizeof(wakeup_filter_cmd)); 1949 - 1950 - /* 1951 - * We know the last used seqno, and the uCode expects to know that 1952 - * one, it will increment before TX. 1953 - */ 1954 - seq = le16_to_cpu(priv->last_seq_ctl) & IEEE80211_SCTL_SEQ; 1955 - wakeup_filter_cmd.non_qos_seq = cpu_to_le16(seq); 1956 - 1957 - /* 1958 - * For QoS counters, we store the one to use next, so subtract 0x10 1959 - * since the uCode will add 0x10 before using the value. 1960 - */ 1961 - for (i = 0; i < 8; i++) { 1962 - seq = priv->shrd->tid_data[IWL_AP_ID][i].seq_number; 1963 - seq -= 0x10; 1964 - wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq); 1965 - } 1966 - 1967 - if (wowlan->disconnect) 1968 - wakeup_filter_cmd.enabled |= 1969 - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_BEACON_MISS | 1970 - IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE); 1971 - if (wowlan->magic_pkt) 1972 - wakeup_filter_cmd.enabled |= 1973 - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_MAGIC_PACKET); 1974 - if (wowlan->gtk_rekey_failure) 1975 - wakeup_filter_cmd.enabled |= 1976 - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL); 1977 - if (wowlan->eap_identity_req) 1978 - wakeup_filter_cmd.enabled |= 1979 - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ); 1980 - if (wowlan->four_way_handshake) 1981 - wakeup_filter_cmd.enabled |= 1982 - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE); 1983 - if (wowlan->rfkill_release) 1984 - wakeup_filter_cmd.enabled |= 1985 - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_RFKILL); 1986 - if (wowlan->n_patterns) 1987 - wakeup_filter_cmd.enabled |= 1988 - cpu_to_le32(IWLAGN_WOWLAN_WAKEUP_PATTERN_MATCH); 1989 - 1990 - iwl_scan_cancel_timeout(priv, 200); 1991 - 1992 - memcpy(&rxon, &ctx->active, sizeof(rxon)); 1993 - 1994 - iwl_trans_stop_device(trans(priv)); 1995 - 1996 - priv->shrd->wowlan = true; 1997 - 1998 - ret = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_wowlan, 1999 - IWL_UCODE_WOWLAN); 2000 - if (ret) 2001 - goto error; 2002 - 2003 - /* now configure WoWLAN ucode */ 2004 - ret = iwl_alive_start(priv); 2005 - if (ret) 2006 - goto error; 2007 - 2008 - memcpy(&ctx->staging, &rxon, sizeof(rxon)); 2009 - ret = iwlagn_commit_rxon(priv, ctx); 2010 - if (ret) 2011 - goto error; 2012 - 2013 - ret = iwl_power_update_mode(priv, true); 2014 - if (ret) 2015 - goto error; 2016 - 2017 - if (!iwlagn_mod_params.sw_crypto) { 2018 - /* mark all keys clear */ 2019 - priv->ucode_key_table = 0; 2020 - ctx->key_mapping_keys = 0; 2021 - 2022 - /* 2023 - * This needs to be unlocked due to lock ordering 2024 - * constraints. Since we're in the suspend path 2025 - * that isn't really a problem though. 2026 - */ 2027 - mutex_unlock(&priv->shrd->mutex); 2028 - ieee80211_iter_keys(priv->hw, ctx->vif, 2029 - iwlagn_wowlan_program_keys, 2030 - &key_data); 2031 - mutex_lock(&priv->shrd->mutex); 2032 - if (key_data.error) { 2033 - ret = -EIO; 2034 - goto error; 2035 - } 2036 - 2037 - if (key_data.use_rsc_tsc) { 2038 - struct iwl_host_cmd rsc_tsc_cmd = { 2039 - .id = REPLY_WOWLAN_TSC_RSC_PARAMS, 2040 - .flags = CMD_SYNC, 2041 - .data[0] = key_data.rsc_tsc, 2042 - .dataflags[0] = IWL_HCMD_DFL_NOCOPY, 2043 - .len[0] = sizeof(*key_data.rsc_tsc), 2044 - }; 2045 - 2046 - ret = iwl_trans_send_cmd(trans(priv), &rsc_tsc_cmd); 2047 - if (ret) 2048 - goto error; 2049 - } 2050 - 2051 - if (key_data.use_tkip) { 2052 - ret = iwl_trans_send_cmd_pdu(trans(priv), 2053 - REPLY_WOWLAN_TKIP_PARAMS, 2054 - CMD_SYNC, sizeof(tkip_cmd), 2055 - &tkip_cmd); 2056 - if (ret) 2057 - goto error; 2058 - } 2059 - 2060 - if (priv->have_rekey_data) { 2061 - memset(&kek_kck_cmd, 0, sizeof(kek_kck_cmd)); 2062 - memcpy(kek_kck_cmd.kck, priv->kck, NL80211_KCK_LEN); 2063 - kek_kck_cmd.kck_len = cpu_to_le16(NL80211_KCK_LEN); 2064 - memcpy(kek_kck_cmd.kek, priv->kek, NL80211_KEK_LEN); 2065 - kek_kck_cmd.kek_len = cpu_to_le16(NL80211_KEK_LEN); 2066 - kek_kck_cmd.replay_ctr = priv->replay_ctr; 2067 - 2068 - ret = iwl_trans_send_cmd_pdu(trans(priv), 2069 - REPLY_WOWLAN_KEK_KCK_MATERIAL, 2070 - CMD_SYNC, sizeof(kek_kck_cmd), 2071 - &kek_kck_cmd); 2072 - if (ret) 2073 - goto error; 2074 - } 2075 - } 2076 - 2077 - ret = iwl_trans_send_cmd_pdu(trans(priv), REPLY_WOWLAN_WAKEUP_FILTER, 2078 - CMD_SYNC, sizeof(wakeup_filter_cmd), 2079 - &wakeup_filter_cmd); 2080 - if (ret) 2081 - goto error; 2082 - 2083 - ret = iwlagn_send_patterns(priv, wowlan); 2084 - if (ret) 2085 - goto error; 2086 - 2087 - device_set_wakeup_enable(bus(priv)->dev, true); 2088 - 2089 - /* Now let the ucode operate on its own */ 2090 - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET, 2091 - CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); 2092 - 2093 - goto out; 2094 - 2095 - error: 2096 - priv->shrd->wowlan = false; 2097 - iwlagn_prepare_restart(priv); 2098 - ieee80211_restart_hw(priv->hw); 2099 - out: 2100 - mutex_unlock(&priv->shrd->mutex); 2101 - kfree(key_data.rsc_tsc); 2102 - IWL_DEBUG_MAC80211(priv, "leave\n"); 2103 - 2104 - return ret; 2105 - } 2106 - 2107 - static int iwlagn_mac_resume(struct ieee80211_hw *hw) 2108 - { 2109 - struct iwl_priv *priv = hw->priv; 2110 - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 2111 - struct ieee80211_vif *vif; 2112 - unsigned long flags; 2113 - u32 base, status = 0xffffffff; 2114 - int ret = -EIO; 2115 - 2116 - IWL_DEBUG_MAC80211(priv, "enter\n"); 2117 - mutex_lock(&priv->shrd->mutex); 2118 - 2119 - iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, 2120 - CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); 2121 - 2122 - base = priv->device_pointers.error_event_table; 2123 - if (iwlagn_hw_valid_rtc_data_addr(base)) { 2124 - spin_lock_irqsave(&bus(priv)->reg_lock, flags); 2125 - ret = iwl_grab_nic_access_silent(bus(priv)); 2126 - if (ret == 0) { 2127 - iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, base); 2128 - status = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); 2129 - iwl_release_nic_access(bus(priv)); 2130 - } 2131 - spin_unlock_irqrestore(&bus(priv)->reg_lock, flags); 2132 - 2133 - #ifdef CONFIG_IWLWIFI_DEBUGFS 2134 - if (ret == 0) { 2135 - if (!priv->wowlan_sram) 2136 - priv->wowlan_sram = 2137 - kzalloc(priv->ucode_wowlan.data.len, 2138 - GFP_KERNEL); 2139 - 2140 - if (priv->wowlan_sram) 2141 - _iwl_read_targ_mem_words( 2142 - bus(priv), 0x800000, priv->wowlan_sram, 2143 - priv->ucode_wowlan.data.len / 4); 2144 - } 2145 - #endif 2146 - } 2147 - 2148 - /* we'll clear ctx->vif during iwlagn_prepare_restart() */ 2149 - vif = ctx->vif; 2150 - 2151 - priv->shrd->wowlan = false; 2152 - 2153 - device_set_wakeup_enable(bus(priv)->dev, false); 2154 - 2155 - iwlagn_prepare_restart(priv); 2156 - 2157 - memset((void *)&ctx->active, 0, sizeof(ctx->active)); 2158 - iwl_connection_init_rx_config(priv, ctx); 2159 - iwlagn_set_rxon_chain(priv, ctx); 2160 - 2161 - mutex_unlock(&priv->shrd->mutex); 2162 - IWL_DEBUG_MAC80211(priv, "leave\n"); 2163 - 2164 - ieee80211_resume_disconnect(vif); 2165 - 2166 - return 1; 2167 - } 2168 - #endif 2169 - 2170 - static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 2171 - { 2172 - struct iwl_priv *priv = hw->priv; 2173 - 2174 - IWL_DEBUG_MACDUMP(priv, "enter\n"); 2175 - 2176 - IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 2177 - ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); 2178 - 2179 - if (iwlagn_tx_skb(priv, skb)) 2180 - dev_kfree_skb_any(skb); 2181 - 2182 - IWL_DEBUG_MACDUMP(priv, "leave\n"); 2183 - } 2184 - 2185 - static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, 2186 - struct ieee80211_vif *vif, 2187 - struct ieee80211_key_conf *keyconf, 2188 - struct ieee80211_sta *sta, 2189 - u32 iv32, u16 *phase1key) 2190 - { 2191 - struct iwl_priv *priv = hw->priv; 2192 - 2193 - iwl_update_tkip_key(priv, vif, keyconf, sta, iv32, phase1key); 2194 - } 2195 - 2196 - static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 2197 - struct ieee80211_vif *vif, 2198 - struct ieee80211_sta *sta, 2199 - struct ieee80211_key_conf *key) 2200 - { 2201 - struct iwl_priv *priv = hw->priv; 2202 - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 2203 - struct iwl_rxon_context *ctx = vif_priv->ctx; 2204 - int ret; 2205 - bool is_default_wep_key = false; 2206 - 2207 - IWL_DEBUG_MAC80211(priv, "enter\n"); 2208 - 2209 - if (iwlagn_mod_params.sw_crypto) { 2210 - IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); 2211 - return -EOPNOTSUPP; 2212 - } 2213 - 2214 - /* 2215 - * We could program these keys into the hardware as well, but we 2216 - * don't expect much multicast traffic in IBSS and having keys 2217 - * for more stations is probably more useful. 2218 - * 2219 - * Mark key TX-only and return 0. 2220 - */ 2221 - if (vif->type == NL80211_IFTYPE_ADHOC && 2222 - !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { 2223 - key->hw_key_idx = WEP_INVALID_OFFSET; 2224 - return 0; 2225 - } 2226 - 2227 - /* If they key was TX-only, accept deletion */ 2228 - if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET) 2229 - return 0; 2230 - 2231 - mutex_lock(&priv->shrd->mutex); 2232 - iwl_scan_cancel_timeout(priv, 100); 2233 - 2234 - BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT); 2235 - 2236 - /* 2237 - * If we are getting WEP group key and we didn't receive any key mapping 2238 - * so far, we are in legacy wep mode (group key only), otherwise we are 2239 - * in 1X mode. 2240 - * In legacy wep mode, we use another host command to the uCode. 2241 - */ 2242 - if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || 2243 - key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { 2244 - if (cmd == SET_KEY) 2245 - is_default_wep_key = !ctx->key_mapping_keys; 2246 - else 2247 - is_default_wep_key = 2248 - key->hw_key_idx == IWLAGN_HW_KEY_DEFAULT; 2249 - } 2250 - 2251 - 2252 - switch (cmd) { 2253 - case SET_KEY: 2254 - if (is_default_wep_key) { 2255 - ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key); 2256 - break; 2257 - } 2258 - ret = iwl_set_dynamic_key(priv, vif_priv->ctx, key, sta); 2259 - if (ret) { 2260 - /* 2261 - * can't add key for RX, but we don't need it 2262 - * in the device for TX so still return 0 2263 - */ 2264 - ret = 0; 2265 - key->hw_key_idx = WEP_INVALID_OFFSET; 2266 - } 2267 - 2268 - IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); 2269 - break; 2270 - case DISABLE_KEY: 2271 - if (is_default_wep_key) 2272 - ret = iwl_remove_default_wep_key(priv, ctx, key); 2273 - else 2274 - ret = iwl_remove_dynamic_key(priv, ctx, key, sta); 2275 - 2276 - IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); 2277 - break; 2278 - default: 2279 - ret = -EINVAL; 2280 - } 2281 - 2282 - mutex_unlock(&priv->shrd->mutex); 2283 - IWL_DEBUG_MAC80211(priv, "leave\n"); 2284 - 2285 - return ret; 2286 - } 2287 - 2288 - static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, 2289 - struct ieee80211_vif *vif, 2290 - enum ieee80211_ampdu_mlme_action action, 2291 - struct ieee80211_sta *sta, u16 tid, u16 *ssn, 2292 - u8 buf_size) 2293 - { 2294 - struct iwl_priv *priv = hw->priv; 2295 - int ret = -EINVAL; 2296 - struct iwl_station_priv *sta_priv = (void *) sta->drv_priv; 2297 - struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); 2298 - 2299 - IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", 2300 - sta->addr, tid); 2301 - 2302 - if (!(priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE)) 2303 - return -EACCES; 2304 - 2305 - IWL_DEBUG_MAC80211(priv, "enter\n"); 2306 - mutex_lock(&priv->shrd->mutex); 2307 - 2308 - switch (action) { 2309 - case IEEE80211_AMPDU_RX_START: 2310 - IWL_DEBUG_HT(priv, "start Rx\n"); 2311 - ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn); 2312 - break; 2313 - case IEEE80211_AMPDU_RX_STOP: 2314 - IWL_DEBUG_HT(priv, "stop Rx\n"); 2315 - ret = iwl_sta_rx_agg_stop(priv, sta, tid); 2316 - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) 2317 - ret = 0; 2318 - break; 2319 - case IEEE80211_AMPDU_TX_START: 2320 - IWL_DEBUG_HT(priv, "start Tx\n"); 2321 - ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); 2322 - break; 2323 - case IEEE80211_AMPDU_TX_STOP: 2324 - IWL_DEBUG_HT(priv, "stop Tx\n"); 2325 - ret = iwlagn_tx_agg_stop(priv, vif, sta, tid); 2326 - if ((ret == 0) && (priv->agg_tids_count > 0)) { 2327 - priv->agg_tids_count--; 2328 - IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", 2329 - priv->agg_tids_count); 2330 - } 2331 - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) 2332 - ret = 0; 2333 - if (!priv->agg_tids_count && priv->cfg->ht_params && 2334 - priv->cfg->ht_params->use_rts_for_aggregation) { 2335 - /* 2336 - * switch off RTS/CTS if it was previously enabled 2337 - */ 2338 - sta_priv->lq_sta.lq.general_params.flags &= 2339 - ~LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; 2340 - iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), 2341 - &sta_priv->lq_sta.lq, CMD_ASYNC, false); 2342 - } 2343 - break; 2344 - case IEEE80211_AMPDU_TX_OPERATIONAL: 2345 - buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF); 2346 - 2347 - iwl_trans_tx_agg_setup(trans(priv), ctx->ctxid, iwl_sta_id(sta), 2348 - tid, buf_size); 2349 - 2350 - /* 2351 - * If the limit is 0, then it wasn't initialised yet, 2352 - * use the default. We can do that since we take the 2353 - * minimum below, and we don't want to go above our 2354 - * default due to hardware restrictions. 2355 - */ 2356 - if (sta_priv->max_agg_bufsize == 0) 2357 - sta_priv->max_agg_bufsize = 2358 - LINK_QUAL_AGG_FRAME_LIMIT_DEF; 2359 - 2360 - /* 2361 - * Even though in theory the peer could have different 2362 - * aggregation reorder buffer sizes for different sessions, 2363 - * our ucode doesn't allow for that and has a global limit 2364 - * for each station. Therefore, use the minimum of all the 2365 - * aggregation sessions and our default value. 2366 - */ 2367 - sta_priv->max_agg_bufsize = 2368 - min(sta_priv->max_agg_bufsize, buf_size); 2369 - 2370 - if (priv->cfg->ht_params && 2371 - priv->cfg->ht_params->use_rts_for_aggregation) { 2372 - /* 2373 - * switch to RTS/CTS if it is the prefer protection 2374 - * method for HT traffic 2375 - */ 2376 - 2377 - sta_priv->lq_sta.lq.general_params.flags |= 2378 - LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; 2379 - } 2380 - priv->agg_tids_count++; 2381 - IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", 2382 - priv->agg_tids_count); 2383 - 2384 - sta_priv->lq_sta.lq.agg_params.agg_frame_cnt_limit = 2385 - sta_priv->max_agg_bufsize; 2386 - 2387 - iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), 2388 - &sta_priv->lq_sta.lq, CMD_ASYNC, false); 2389 - 2390 - IWL_INFO(priv, "Tx aggregation enabled on ra = %pM tid = %d\n", 2391 - sta->addr, tid); 2392 - ret = 0; 2393 - break; 2394 - } 2395 - mutex_unlock(&priv->shrd->mutex); 2396 - IWL_DEBUG_MAC80211(priv, "leave\n"); 2397 - return ret; 2398 - } 2399 - 2400 - static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, 2401 - struct ieee80211_vif *vif, 2402 - struct ieee80211_sta *sta) 2403 - { 2404 - struct iwl_priv *priv = hw->priv; 2405 - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; 2406 - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 2407 - bool is_ap = vif->type == NL80211_IFTYPE_STATION; 2408 - int ret = 0; 2409 - u8 sta_id; 2410 - 2411 - IWL_DEBUG_MAC80211(priv, "received request to add station %pM\n", 2412 - sta->addr); 2413 - mutex_lock(&priv->shrd->mutex); 2414 - IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", 2415 - sta->addr); 2416 - sta_priv->sta_id = IWL_INVALID_STATION; 2417 - 2418 - atomic_set(&sta_priv->pending_frames, 0); 2419 - if (vif->type == NL80211_IFTYPE_AP) 2420 - sta_priv->client = true; 2421 - 2422 - ret = iwl_add_station_common(priv, vif_priv->ctx, sta->addr, 2423 - is_ap, sta, &sta_id); 2424 - if (ret) { 2425 - IWL_ERR(priv, "Unable to add station %pM (%d)\n", 2426 - sta->addr, ret); 2427 - /* Should we return success if return code is EEXIST ? */ 2428 - goto out; 2429 - } 2430 - 2431 - sta_priv->sta_id = sta_id; 2432 - 2433 - /* Initialize rate scaling */ 2434 - IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", 2435 - sta->addr); 2436 - iwl_rs_rate_init(priv, sta, sta_id); 2437 - out: 2438 - mutex_unlock(&priv->shrd->mutex); 2439 - IWL_DEBUG_MAC80211(priv, "leave\n"); 2440 - 2441 - return ret; 2442 - } 2443 - 2444 - static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, 2445 - struct ieee80211_channel_switch *ch_switch) 2446 - { 2447 - struct iwl_priv *priv = hw->priv; 2448 - const struct iwl_channel_info *ch_info; 2449 - struct ieee80211_conf *conf = &hw->conf; 2450 - struct ieee80211_channel *channel = ch_switch->channel; 2451 - struct iwl_ht_config *ht_conf = &priv->current_ht_config; 2452 - /* 2453 - * MULTI-FIXME 2454 - * When we add support for multiple interfaces, we need to 2455 - * revisit this. The channel switch command in the device 2456 - * only affects the BSS context, but what does that really 2457 - * mean? And what if we get a CSA on the second interface? 2458 - * This needs a lot of work. 2459 - */ 2460 - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 2461 - u16 ch; 2462 - 2463 - IWL_DEBUG_MAC80211(priv, "enter\n"); 2464 - 2465 - mutex_lock(&priv->shrd->mutex); 2466 - 2467 - if (iwl_is_rfkill(priv->shrd)) 2468 - goto out; 2469 - 2470 - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) || 2471 - test_bit(STATUS_SCANNING, &priv->shrd->status) || 2472 - test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status)) 2473 - goto out; 2474 - 2475 - if (!iwl_is_associated_ctx(ctx)) 2476 - goto out; 2477 - 2478 - if (!priv->cfg->lib->set_channel_switch) 2479 - goto out; 2480 - 2481 - ch = channel->hw_value; 2482 - if (le16_to_cpu(ctx->active.channel) == ch) 2483 - goto out; 2484 - 2485 - ch_info = iwl_get_channel_info(priv, channel->band, ch); 2486 - if (!is_channel_valid(ch_info)) { 2487 - IWL_DEBUG_MAC80211(priv, "invalid channel\n"); 2488 - goto out; 2489 - } 2490 - 2491 - spin_lock_irq(&priv->shrd->lock); 2492 - 2493 - priv->current_ht_config.smps = conf->smps_mode; 2494 - 2495 - /* Configure HT40 channels */ 2496 - ctx->ht.enabled = conf_is_ht(conf); 2497 - if (ctx->ht.enabled) { 2498 - if (conf_is_ht40_minus(conf)) { 2499 - ctx->ht.extension_chan_offset = 2500 - IEEE80211_HT_PARAM_CHA_SEC_BELOW; 2501 - ctx->ht.is_40mhz = true; 2502 - } else if (conf_is_ht40_plus(conf)) { 2503 - ctx->ht.extension_chan_offset = 2504 - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; 2505 - ctx->ht.is_40mhz = true; 2506 - } else { 2507 - ctx->ht.extension_chan_offset = 2508 - IEEE80211_HT_PARAM_CHA_SEC_NONE; 2509 - ctx->ht.is_40mhz = false; 2510 - } 2511 - } else 2512 - ctx->ht.is_40mhz = false; 2513 - 2514 - if ((le16_to_cpu(ctx->staging.channel) != ch)) 2515 - ctx->staging.flags = 0; 2516 - 2517 - iwl_set_rxon_channel(priv, channel, ctx); 2518 - iwl_set_rxon_ht(priv, ht_conf); 2519 - iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif); 2520 - 2521 - spin_unlock_irq(&priv->shrd->lock); 2522 - 2523 - iwl_set_rate(priv); 2524 - /* 2525 - * at this point, staging_rxon has the 2526 - * configuration for channel switch 2527 - */ 2528 - set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); 2529 - priv->switch_channel = cpu_to_le16(ch); 2530 - if (priv->cfg->lib->set_channel_switch(priv, ch_switch)) { 2531 - clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); 2532 - priv->switch_channel = 0; 2533 - ieee80211_chswitch_done(ctx->vif, false); 2534 - } 2535 - 2536 - out: 2537 - mutex_unlock(&priv->shrd->mutex); 2538 - IWL_DEBUG_MAC80211(priv, "leave\n"); 2539 - } 2540 - 2541 - static void iwlagn_configure_filter(struct ieee80211_hw *hw, 2542 - unsigned int changed_flags, 2543 - unsigned int *total_flags, 2544 - u64 multicast) 2545 - { 2546 - struct iwl_priv *priv = hw->priv; 2547 - __le32 filter_or = 0, filter_nand = 0; 2548 - struct iwl_rxon_context *ctx; 2549 - 2550 - #define CHK(test, flag) do { \ 2551 - if (*total_flags & (test)) \ 2552 - filter_or |= (flag); \ 2553 - else \ 2554 - filter_nand |= (flag); \ 2555 - } while (0) 2556 - 2557 - IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", 2558 - changed_flags, *total_flags); 2559 - 2560 - CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); 2561 - /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ 2562 - CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); 2563 - CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); 2564 - 2565 - #undef CHK 2566 - 2567 - mutex_lock(&priv->shrd->mutex); 2568 - 2569 - for_each_context(priv, ctx) { 2570 - ctx->staging.filter_flags &= ~filter_nand; 2571 - ctx->staging.filter_flags |= filter_or; 2572 - 2573 - /* 2574 - * Not committing directly because hardware can perform a scan, 2575 - * but we'll eventually commit the filter flags change anyway. 2576 - */ 2577 - } 2578 - 2579 - mutex_unlock(&priv->shrd->mutex); 2580 - 2581 - /* 2582 - * Receiving all multicast frames is always enabled by the 2583 - * default flags setup in iwl_connection_init_rx_config() 2584 - * since we currently do not support programming multicast 2585 - * filters into the device. 2586 - */ 2587 - *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | 2588 - FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; 2589 - } 2590 - 2591 - static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) 2592 - { 2593 - struct iwl_priv *priv = hw->priv; 2594 - 2595 - mutex_lock(&priv->shrd->mutex); 2596 - IWL_DEBUG_MAC80211(priv, "enter\n"); 2597 - 2598 - if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { 2599 - IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n"); 2600 - goto done; 2601 - } 2602 - if (iwl_is_rfkill(priv->shrd)) { 2603 - IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n"); 2604 - goto done; 2605 - } 2606 - 2607 - /* 2608 - * mac80211 will not push any more frames for transmit 2609 - * until the flush is completed 2610 - */ 2611 - if (drop) { 2612 - IWL_DEBUG_MAC80211(priv, "send flush command\n"); 2613 - if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) { 2614 - IWL_ERR(priv, "flush request fail\n"); 2615 - goto done; 2616 - } 2617 - } 2618 - IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); 2619 - iwl_trans_wait_tx_queue_empty(trans(priv)); 2620 - done: 2621 - mutex_unlock(&priv->shrd->mutex); 2622 - IWL_DEBUG_MAC80211(priv, "leave\n"); 2623 - } 2624 1564 2625 1565 void iwlagn_disable_roc(struct iwl_priv *priv) 2626 1566 { ··· 1487 2757 mutex_lock(&priv->shrd->mutex); 1488 2758 iwlagn_disable_roc(priv); 1489 2759 mutex_unlock(&priv->shrd->mutex); 1490 - } 1491 - 1492 - static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, 1493 - struct ieee80211_channel *channel, 1494 - enum nl80211_channel_type channel_type, 1495 - int duration) 1496 - { 1497 - struct iwl_priv *priv = hw->priv; 1498 - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; 1499 - int err = 0; 1500 - 1501 - if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) 1502 - return -EOPNOTSUPP; 1503 - 1504 - if (!(ctx->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT))) 1505 - return -EOPNOTSUPP; 1506 - 1507 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1508 - mutex_lock(&priv->shrd->mutex); 1509 - 1510 - if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { 1511 - err = -EBUSY; 1512 - goto out; 1513 - } 1514 - 1515 - priv->hw_roc_channel = channel; 1516 - priv->hw_roc_chantype = channel_type; 1517 - priv->hw_roc_duration = duration; 1518 - priv->hw_roc_start_notified = false; 1519 - cancel_delayed_work(&priv->hw_roc_disable_work); 1520 - 1521 - if (!ctx->is_active) { 1522 - ctx->is_active = true; 1523 - ctx->staging.dev_type = RXON_DEV_TYPE_P2P; 1524 - memcpy(ctx->staging.node_addr, 1525 - priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, 1526 - ETH_ALEN); 1527 - memcpy(ctx->staging.bssid_addr, 1528 - priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, 1529 - ETH_ALEN); 1530 - err = iwlagn_commit_rxon(priv, ctx); 1531 - if (err) 1532 - goto out; 1533 - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK | 1534 - RXON_FILTER_PROMISC_MSK | 1535 - RXON_FILTER_CTL2HOST_MSK; 1536 - 1537 - err = iwlagn_commit_rxon(priv, ctx); 1538 - if (err) { 1539 - iwlagn_disable_roc(priv); 1540 - goto out; 1541 - } 1542 - priv->hw_roc_setup = true; 1543 - } 1544 - 1545 - err = iwl_scan_initiate(priv, ctx->vif, IWL_SCAN_ROC, channel->band); 1546 - if (err) 1547 - iwlagn_disable_roc(priv); 1548 - 1549 - out: 1550 - mutex_unlock(&priv->shrd->mutex); 1551 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1552 - 1553 - return err; 1554 - } 1555 - 1556 - static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) 1557 - { 1558 - struct iwl_priv *priv = hw->priv; 1559 - 1560 - if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) 1561 - return -EOPNOTSUPP; 1562 - 1563 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1564 - mutex_lock(&priv->shrd->mutex); 1565 - iwl_scan_cancel_timeout(priv, priv->hw_roc_duration); 1566 - iwlagn_disable_roc(priv); 1567 - mutex_unlock(&priv->shrd->mutex); 1568 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1569 - 1570 - return 0; 1571 - } 1572 - 1573 - static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw, 1574 - struct ieee80211_vif *vif, 1575 - const u8 *bssid, 1576 - enum ieee80211_tx_sync_type type) 1577 - { 1578 - struct iwl_priv *priv = hw->priv; 1579 - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 1580 - struct iwl_rxon_context *ctx = vif_priv->ctx; 1581 - int ret; 1582 - u8 sta_id; 1583 - 1584 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1585 - mutex_lock(&priv->shrd->mutex); 1586 - 1587 - if (iwl_is_associated_ctx(ctx)) { 1588 - ret = 0; 1589 - goto out; 1590 - } 1591 - 1592 - if (ctx->preauth_bssid || test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { 1593 - ret = -EBUSY; 1594 - goto out; 1595 - } 1596 - 1597 - ret = iwl_add_station_common(priv, ctx, bssid, true, NULL, &sta_id); 1598 - if (ret) 1599 - goto out; 1600 - 1601 - if (WARN_ON(sta_id != ctx->ap_sta_id)) { 1602 - ret = -EIO; 1603 - goto out_remove_sta; 1604 - } 1605 - 1606 - memcpy(ctx->bssid, bssid, ETH_ALEN); 1607 - ctx->preauth_bssid = true; 1608 - 1609 - ret = iwlagn_commit_rxon(priv, ctx); 1610 - 1611 - if (ret == 0) 1612 - goto out; 1613 - 1614 - out_remove_sta: 1615 - iwl_remove_station(priv, sta_id, bssid); 1616 - out: 1617 - mutex_unlock(&priv->shrd->mutex); 1618 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1619 - 1620 - return ret; 1621 - } 1622 - 1623 - static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw, 1624 - struct ieee80211_vif *vif, 1625 - const u8 *bssid, 1626 - enum ieee80211_tx_sync_type type) 1627 - { 1628 - struct iwl_priv *priv = hw->priv; 1629 - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 1630 - struct iwl_rxon_context *ctx = vif_priv->ctx; 1631 - 1632 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1633 - mutex_lock(&priv->shrd->mutex); 1634 - 1635 - if (iwl_is_associated_ctx(ctx)) 1636 - goto out; 1637 - 1638 - iwl_remove_station(priv, ctx->ap_sta_id, bssid); 1639 - ctx->preauth_bssid = false; 1640 - /* no need to commit */ 1641 - out: 1642 - mutex_unlock(&priv->shrd->mutex); 1643 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1644 2760 } 1645 2761 1646 2762 /***************************************************************************** ··· 1638 3062 kmem_cache_destroy(priv->tx_cmd_pool); 1639 3063 kfree(priv->scan_cmd); 1640 3064 kfree(priv->beacon_cmd); 3065 + kfree(rcu_dereference_raw(priv->noa_data)); 1641 3066 #ifdef CONFIG_IWLWIFI_DEBUGFS 1642 3067 kfree(priv->wowlan_sram); 1643 3068 #endif 1644 3069 } 1645 3070 1646 - static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, 1647 - enum ieee80211_rssi_event rssi_event) 1648 - { 1649 - struct iwl_priv *priv = hw->priv; 1650 3071 1651 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1652 - mutex_lock(&priv->shrd->mutex); 1653 - 1654 - if (priv->cfg->bt_params && 1655 - priv->cfg->bt_params->advanced_bt_coexist) { 1656 - if (rssi_event == RSSI_EVENT_LOW) 1657 - priv->bt_enable_pspoll = true; 1658 - else if (rssi_event == RSSI_EVENT_HIGH) 1659 - priv->bt_enable_pspoll = false; 1660 - 1661 - iwlagn_send_advance_bt_config(priv); 1662 - } else { 1663 - IWL_DEBUG_MAC80211(priv, "Advanced BT coex disabled," 1664 - "ignoring RSSI callback\n"); 1665 - } 1666 - 1667 - mutex_unlock(&priv->shrd->mutex); 1668 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1669 - } 1670 - 1671 - static int iwlagn_mac_set_tim(struct ieee80211_hw *hw, 1672 - struct ieee80211_sta *sta, bool set) 1673 - { 1674 - struct iwl_priv *priv = hw->priv; 1675 - 1676 - queue_work(priv->shrd->workqueue, &priv->beacon_update); 1677 - 1678 - return 0; 1679 - } 1680 - 1681 - struct ieee80211_ops iwlagn_hw_ops = { 1682 - .tx = iwlagn_mac_tx, 1683 - .start = iwlagn_mac_start, 1684 - .stop = iwlagn_mac_stop, 1685 - #ifdef CONFIG_PM_SLEEP 1686 - .suspend = iwlagn_mac_suspend, 1687 - .resume = iwlagn_mac_resume, 1688 - #endif 1689 - .add_interface = iwlagn_mac_add_interface, 1690 - .remove_interface = iwlagn_mac_remove_interface, 1691 - .change_interface = iwlagn_mac_change_interface, 1692 - .config = iwlagn_mac_config, 1693 - .configure_filter = iwlagn_configure_filter, 1694 - .set_key = iwlagn_mac_set_key, 1695 - .update_tkip_key = iwlagn_mac_update_tkip_key, 1696 - .set_rekey_data = iwlagn_mac_set_rekey_data, 1697 - .conf_tx = iwlagn_mac_conf_tx, 1698 - .bss_info_changed = iwlagn_bss_info_changed, 1699 - .ampdu_action = iwlagn_mac_ampdu_action, 1700 - .hw_scan = iwlagn_mac_hw_scan, 1701 - .sta_notify = iwlagn_mac_sta_notify, 1702 - .sta_add = iwlagn_mac_sta_add, 1703 - .sta_remove = iwlagn_mac_sta_remove, 1704 - .channel_switch = iwlagn_mac_channel_switch, 1705 - .flush = iwlagn_mac_flush, 1706 - .tx_last_beacon = iwlagn_mac_tx_last_beacon, 1707 - .remain_on_channel = iwlagn_mac_remain_on_channel, 1708 - .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel, 1709 - .rssi_callback = iwlagn_mac_rssi_callback, 1710 - CFG80211_TESTMODE_CMD(iwlagn_mac_testmode_cmd) 1711 - CFG80211_TESTMODE_DUMP(iwlagn_mac_testmode_dump) 1712 - .tx_sync = iwlagn_mac_tx_sync, 1713 - .finish_tx_sync = iwlagn_mac_finish_tx_sync, 1714 - .set_tim = iwlagn_mac_set_tim, 1715 - }; 1716 3072 1717 3073 static u32 iwl_hw_detect(struct iwl_priv *priv) 1718 3074 { ··· 1678 3170 return priv->cfg->lib->set_hw_params(priv); 1679 3171 } 1680 3172 1681 - /* This function both allocates and initializes hw and priv. */ 1682 - static struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg) 1683 - { 1684 - struct iwl_priv *priv; 1685 - /* mac80211 allocates memory for this device instance, including 1686 - * space for this driver's private structure */ 1687 - struct ieee80211_hw *hw; 1688 3173 1689 - hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwlagn_hw_ops); 1690 - if (hw == NULL) { 1691 - pr_err("%s: Can not allocate network device\n", 1692 - cfg->name); 1693 - goto out; 1694 - } 1695 - 1696 - priv = hw->priv; 1697 - priv->hw = hw; 1698 - 1699 - out: 1700 - return hw; 1701 - } 1702 3174 1703 3175 int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, 1704 3176 struct iwl_cfg *cfg) ··· 1692 3204 /************************ 1693 3205 * 1. Allocating HW data 1694 3206 ************************/ 1695 - hw = iwl_alloc_all(cfg); 3207 + hw = iwl_alloc_all(); 1696 3208 if (!hw) { 3209 + pr_err("%s: Cannot allocate network device\n", cfg->name); 1697 3210 err = -ENOMEM; 1698 3211 goto out; 1699 3212 } ··· 1886 3397 /*This will stop the queues, move the device to low power state */ 1887 3398 iwl_trans_stop_device(trans(priv)); 1888 3399 1889 - iwl_dealloc_ucode(priv); 3400 + iwl_dealloc_ucode(trans(priv)); 1890 3401 1891 3402 iwl_eeprom_free(priv); 1892 3403
+22 -9
drivers/net/wireless/iwlwifi/iwl-agn.h
··· 65 65 66 66 #include "iwl-dev.h" 67 67 68 + struct iwlagn_ucode_capabilities { 69 + u32 max_probe_length; 70 + u32 standard_phy_calibration_size; 71 + u32 flags; 72 + }; 73 + 68 74 extern struct ieee80211_ops iwlagn_hw_ops; 69 75 70 76 int iwl_reset_ict(struct iwl_trans *trans); ··· 82 76 hdr->groups_num = 1; 83 77 hdr->data_valid = 1; 84 78 } 79 + 80 + void __iwl_down(struct iwl_priv *priv); 81 + void iwl_down(struct iwl_priv *priv); 82 + void iwlagn_prepare_restart(struct iwl_priv *priv); 83 + 84 + /* MAC80211 */ 85 + struct ieee80211_hw *iwl_alloc_all(void); 86 + int iwlagn_mac_setup_register(struct iwl_priv *priv, 87 + struct iwlagn_ucode_capabilities *capa); 85 88 86 89 /* RXON */ 87 90 int iwlagn_set_pan_params(struct iwl_priv *priv); ··· 110 95 void iwlagn_send_prio_tbl(struct iwl_priv *priv); 111 96 int iwlagn_run_init_ucode(struct iwl_priv *priv); 112 97 int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, 113 - struct fw_img *image, 114 - enum iwlagn_ucode_type ucode_type); 98 + enum iwl_ucode_type ucode_type); 115 99 116 100 /* lib */ 117 101 int iwlagn_send_tx_power(struct iwl_priv *priv); ··· 119 105 int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control); 120 106 void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control); 121 107 int iwlagn_send_beacon_cmd(struct iwl_priv *priv); 108 + #ifdef CONFIG_PM_SLEEP 109 + int iwlagn_send_patterns(struct iwl_priv *priv, 110 + struct cfg80211_wowlan *wowlan); 111 + int iwlagn_suspend(struct iwl_priv *priv, 112 + struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); 113 + #endif 122 114 123 115 /* rx */ 124 116 int iwlagn_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); ··· 216 196 struct ieee80211_sta *sta, u8 *sta_id_r); 217 197 int iwl_remove_station(struct iwl_priv *priv, const u8 sta_id, 218 198 const u8 *addr); 219 - int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, 220 - struct ieee80211_sta *sta); 221 - 222 199 u8 iwl_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 223 200 const u8 *addr, bool is_ap, struct ieee80211_sta *sta); 224 201 ··· 333 316 int iwl_update_bcast_station(struct iwl_priv *priv, 334 317 struct iwl_rxon_context *ctx); 335 318 int iwl_update_bcast_stations(struct iwl_priv *priv); 336 - void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, 337 - struct ieee80211_vif *vif, 338 - enum sta_notify_cmd cmd, 339 - struct ieee80211_sta *sta); 340 319 341 320 /* rate */ 342 321 static inline u32 iwl_ant_idx_to_flags(u8 ant_idx)
-6
drivers/net/wireless/iwlwifi/iwl-cfg.h
··· 101 101 extern struct iwl_cfg iwl130_bgn_cfg; 102 102 extern struct iwl_cfg iwl130_bg_cfg; 103 103 extern struct iwl_cfg iwl2000_2bgn_cfg; 104 - extern struct iwl_cfg iwl2000_2bg_cfg; 105 104 extern struct iwl_cfg iwl2000_2bgn_d_cfg; 106 105 extern struct iwl_cfg iwl2030_2bgn_cfg; 107 - extern struct iwl_cfg iwl2030_2bg_cfg; 108 106 extern struct iwl_cfg iwl6035_2agn_cfg; 109 - extern struct iwl_cfg iwl6035_2abg_cfg; 110 - extern struct iwl_cfg iwl6035_2bg_cfg; 111 - extern struct iwl_cfg iwl105_bg_cfg; 112 107 extern struct iwl_cfg iwl105_bgn_cfg; 113 108 extern struct iwl_cfg iwl105_bgn_d_cfg; 114 - extern struct iwl_cfg iwl135_bg_cfg; 115 109 extern struct iwl_cfg iwl135_bgn_cfg; 116 110 117 111 #endif /* __iwl_pci_h__ */
+19 -8
drivers/net/wireless/iwlwifi/iwl-commands.h
··· 198 198 REPLY_WOWLAN_TKIP_PARAMS = 0xe3, 199 199 REPLY_WOWLAN_KEK_KCK_MATERIAL = 0xe4, 200 200 REPLY_WOWLAN_GET_STATUS = 0xe5, 201 + REPLY_D3_CONFIG = 0xd3, 201 202 202 203 REPLY_MAX = 0xff 203 204 }; ··· 3802 3801 } __attribute__((packed)); 3803 3802 3804 3803 /* 3804 + * REPLY_D3_CONFIG 3805 + */ 3806 + enum iwlagn_d3_wakeup_filters { 3807 + IWLAGN_D3_WAKEUP_RFKILL = BIT(0), 3808 + IWLAGN_D3_WAKEUP_SYSASSERT = BIT(1), 3809 + }; 3810 + 3811 + struct iwlagn_d3_config_cmd { 3812 + __le32 min_sleep_time; 3813 + __le32 wakeup_flags; 3814 + } __packed; 3815 + 3816 + /* 3805 3817 * REPLY_WOWLAN_PATTERNS 3806 3818 */ 3807 3819 #define IWLAGN_WOWLAN_MIN_PATTERN_LEN 16 ··· 3844 3830 IWLAGN_WOWLAN_WAKEUP_BEACON_MISS = BIT(2), 3845 3831 IWLAGN_WOWLAN_WAKEUP_LINK_CHANGE = BIT(3), 3846 3832 IWLAGN_WOWLAN_WAKEUP_GTK_REKEY_FAIL = BIT(4), 3847 - IWLAGN_WOWLAN_WAKEUP_RFKILL = BIT(5), 3848 - IWLAGN_WOWLAN_WAKEUP_UCODE_ERROR = BIT(6), 3849 - IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ = BIT(7), 3850 - IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE = BIT(8), 3851 - IWLAGN_WOWLAN_WAKEUP_ALWAYS = BIT(9), 3852 - IWLAGN_WOWLAN_WAKEUP_ENABLE_NET_DETECT = BIT(10), 3833 + IWLAGN_WOWLAN_WAKEUP_EAP_IDENT_REQ = BIT(5), 3834 + IWLAGN_WOWLAN_WAKEUP_4WAY_HANDSHAKE = BIT(6), 3835 + IWLAGN_WOWLAN_WAKEUP_ALWAYS = BIT(7), 3836 + IWLAGN_WOWLAN_WAKEUP_ENABLE_NET_DETECT = BIT(8), 3853 3837 }; 3854 3838 3855 3839 struct iwlagn_wowlan_wakeup_filter_cmd { 3856 3840 __le32 enabled; 3857 3841 __le16 non_qos_seq; 3858 - u8 min_sleep_seconds; 3859 - u8 reserved; 3842 + __le16 reserved; 3860 3843 __le16 qos_seq[8]; 3861 3844 }; 3862 3845
+1 -306
drivers/net/wireless/iwlwifi/iwl-core.c
··· 1120 1120 &statistics_cmd); 1121 1121 } 1122 1122 1123 - int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, 1124 - struct ieee80211_vif *vif, u16 queue, 1125 - const struct ieee80211_tx_queue_params *params) 1126 - { 1127 - struct iwl_priv *priv = hw->priv; 1128 - struct iwl_rxon_context *ctx; 1129 - unsigned long flags; 1130 - int q; 1131 1123 1132 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1133 1124 1134 - if (!iwl_is_ready_rf(priv->shrd)) { 1135 - IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); 1136 - return -EIO; 1137 - } 1138 - 1139 - if (queue >= AC_NUM) { 1140 - IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); 1141 - return 0; 1142 - } 1143 - 1144 - q = AC_NUM - 1 - queue; 1145 - 1146 - spin_lock_irqsave(&priv->shrd->lock, flags); 1147 - 1148 - /* 1149 - * MULTI-FIXME 1150 - * This may need to be done per interface in nl80211/cfg80211/mac80211. 1151 - */ 1152 - for_each_context(priv, ctx) { 1153 - ctx->qos_data.def_qos_parm.ac[q].cw_min = 1154 - cpu_to_le16(params->cw_min); 1155 - ctx->qos_data.def_qos_parm.ac[q].cw_max = 1156 - cpu_to_le16(params->cw_max); 1157 - ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; 1158 - ctx->qos_data.def_qos_parm.ac[q].edca_txop = 1159 - cpu_to_le16((params->txop * 32)); 1160 - 1161 - ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; 1162 - } 1163 - 1164 - spin_unlock_irqrestore(&priv->shrd->lock, flags); 1165 - 1166 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1167 - return 0; 1168 - } 1169 - 1170 - int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw) 1171 - { 1172 - struct iwl_priv *priv = hw->priv; 1173 - 1174 - return priv->ibss_manager == IWL_IBSS_MANAGER; 1175 - } 1176 - 1177 - static int iwl_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx) 1178 - { 1179 - iwl_connection_init_rx_config(priv, ctx); 1180 - 1181 - iwlagn_set_rxon_chain(priv, ctx); 1182 - 1183 - return iwlagn_commit_rxon(priv, ctx); 1184 - } 1185 - 1186 - static int iwl_setup_interface(struct iwl_priv *priv, 1187 - struct iwl_rxon_context *ctx) 1188 - { 1189 - struct ieee80211_vif *vif = ctx->vif; 1190 - int err; 1191 - 1192 - lockdep_assert_held(&priv->shrd->mutex); 1193 - 1194 - /* 1195 - * This variable will be correct only when there's just 1196 - * a single context, but all code using it is for hardware 1197 - * that supports only one context. 1198 - */ 1199 - priv->iw_mode = vif->type; 1200 - 1201 - ctx->is_active = true; 1202 - 1203 - err = iwl_set_mode(priv, ctx); 1204 - if (err) { 1205 - if (!ctx->always_active) 1206 - ctx->is_active = false; 1207 - return err; 1208 - } 1209 - 1210 - if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist && 1211 - vif->type == NL80211_IFTYPE_ADHOC) { 1212 - /* 1213 - * pretend to have high BT traffic as long as we 1214 - * are operating in IBSS mode, as this will cause 1215 - * the rate scaling etc. to behave as intended. 1216 - */ 1217 - priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH; 1218 - } 1219 - 1220 - return 0; 1221 - } 1222 - 1223 - int iwlagn_mac_add_interface(struct ieee80211_hw *hw, 1224 - struct ieee80211_vif *vif) 1225 - { 1226 - struct iwl_priv *priv = hw->priv; 1227 - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 1228 - struct iwl_rxon_context *tmp, *ctx = NULL; 1229 - int err; 1230 - enum nl80211_iftype viftype = ieee80211_vif_type_p2p(vif); 1231 - 1232 - IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", 1233 - viftype, vif->addr); 1234 - 1235 - cancel_delayed_work_sync(&priv->hw_roc_disable_work); 1236 - 1237 - mutex_lock(&priv->shrd->mutex); 1238 - 1239 - iwlagn_disable_roc(priv); 1240 - 1241 - if (!iwl_is_ready_rf(priv->shrd)) { 1242 - IWL_WARN(priv, "Try to add interface when device not ready\n"); 1243 - err = -EINVAL; 1244 - goto out; 1245 - } 1246 - 1247 - for_each_context(priv, tmp) { 1248 - u32 possible_modes = 1249 - tmp->interface_modes | tmp->exclusive_interface_modes; 1250 - 1251 - if (tmp->vif) { 1252 - /* check if this busy context is exclusive */ 1253 - if (tmp->exclusive_interface_modes & 1254 - BIT(tmp->vif->type)) { 1255 - err = -EINVAL; 1256 - goto out; 1257 - } 1258 - continue; 1259 - } 1260 - 1261 - if (!(possible_modes & BIT(viftype))) 1262 - continue; 1263 - 1264 - /* have maybe usable context w/o interface */ 1265 - ctx = tmp; 1266 - break; 1267 - } 1268 - 1269 - if (!ctx) { 1270 - err = -EOPNOTSUPP; 1271 - goto out; 1272 - } 1273 - 1274 - vif_priv->ctx = ctx; 1275 - ctx->vif = vif; 1276 - 1277 - err = iwl_setup_interface(priv, ctx); 1278 - if (!err) 1279 - goto out; 1280 - 1281 - ctx->vif = NULL; 1282 - priv->iw_mode = NL80211_IFTYPE_STATION; 1283 - out: 1284 - mutex_unlock(&priv->shrd->mutex); 1285 - 1286 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1287 - return err; 1288 - } 1289 - 1290 - static void iwl_teardown_interface(struct iwl_priv *priv, 1291 - struct ieee80211_vif *vif, 1292 - bool mode_change) 1293 - { 1294 - struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); 1295 - 1296 - lockdep_assert_held(&priv->shrd->mutex); 1297 - 1298 - if (priv->scan_vif == vif) { 1299 - iwl_scan_cancel_timeout(priv, 200); 1300 - iwl_force_scan_end(priv); 1301 - } 1302 - 1303 - if (!mode_change) { 1304 - iwl_set_mode(priv, ctx); 1305 - if (!ctx->always_active) 1306 - ctx->is_active = false; 1307 - } 1308 - 1309 - /* 1310 - * When removing the IBSS interface, overwrite the 1311 - * BT traffic load with the stored one from the last 1312 - * notification, if any. If this is a device that 1313 - * doesn't implement this, this has no effect since 1314 - * both values are the same and zero. 1315 - */ 1316 - if (vif->type == NL80211_IFTYPE_ADHOC) 1317 - priv->bt_traffic_load = priv->last_bt_traffic_load; 1318 - } 1319 - 1320 - void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, 1321 - struct ieee80211_vif *vif) 1322 - { 1323 - struct iwl_priv *priv = hw->priv; 1324 - struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); 1325 - 1326 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1327 - 1328 - mutex_lock(&priv->shrd->mutex); 1329 - 1330 - if (WARN_ON(ctx->vif != vif)) { 1331 - struct iwl_rxon_context *tmp; 1332 - IWL_ERR(priv, "ctx->vif = %p, vif = %p\n", ctx->vif, vif); 1333 - for_each_context(priv, tmp) 1334 - IWL_ERR(priv, "\tID = %d:\tctx = %p\tctx->vif = %p\n", 1335 - tmp->ctxid, tmp, tmp->vif); 1336 - } 1337 - ctx->vif = NULL; 1338 - 1339 - iwl_teardown_interface(priv, vif, false); 1340 - 1341 - mutex_unlock(&priv->shrd->mutex); 1342 - 1343 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1344 - 1345 - } 1346 1125 1347 1126 #ifdef CONFIG_IWLWIFI_DEBUGFS 1348 1127 ··· 1428 1649 return 0; 1429 1650 } 1430 1651 1431 - int iwlagn_mac_change_interface(struct ieee80211_hw *hw, 1432 - struct ieee80211_vif *vif, 1433 - enum nl80211_iftype newtype, bool newp2p) 1434 - { 1435 - struct iwl_priv *priv = hw->priv; 1436 - struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); 1437 - struct iwl_rxon_context *bss_ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 1438 - struct iwl_rxon_context *tmp; 1439 - enum nl80211_iftype newviftype = newtype; 1440 - u32 interface_modes; 1441 - int err; 1442 - 1443 - IWL_DEBUG_MAC80211(priv, "enter\n"); 1444 - 1445 - newtype = ieee80211_iftype_p2p(newtype, newp2p); 1446 - 1447 - mutex_lock(&priv->shrd->mutex); 1448 - 1449 - if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) { 1450 - /* 1451 - * Huh? But wait ... this can maybe happen when 1452 - * we're in the middle of a firmware restart! 1453 - */ 1454 - err = -EBUSY; 1455 - goto out; 1456 - } 1457 - 1458 - interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes; 1459 - 1460 - if (!(interface_modes & BIT(newtype))) { 1461 - err = -EBUSY; 1462 - goto out; 1463 - } 1464 - 1465 - /* 1466 - * Refuse a change that should be done by moving from the PAN 1467 - * context to the BSS context instead, if the BSS context is 1468 - * available and can support the new interface type. 1469 - */ 1470 - if (ctx->ctxid == IWL_RXON_CTX_PAN && !bss_ctx->vif && 1471 - (bss_ctx->interface_modes & BIT(newtype) || 1472 - bss_ctx->exclusive_interface_modes & BIT(newtype))) { 1473 - BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); 1474 - err = -EBUSY; 1475 - goto out; 1476 - } 1477 - 1478 - if (ctx->exclusive_interface_modes & BIT(newtype)) { 1479 - for_each_context(priv, tmp) { 1480 - if (ctx == tmp) 1481 - continue; 1482 - 1483 - if (!tmp->vif) 1484 - continue; 1485 - 1486 - /* 1487 - * The current mode switch would be exclusive, but 1488 - * another context is active ... refuse the switch. 1489 - */ 1490 - err = -EBUSY; 1491 - goto out; 1492 - } 1493 - } 1494 - 1495 - /* success */ 1496 - iwl_teardown_interface(priv, vif, true); 1497 - vif->type = newviftype; 1498 - vif->p2p = newp2p; 1499 - err = iwl_setup_interface(priv, ctx); 1500 - WARN_ON(err); 1501 - /* 1502 - * We've switched internally, but submitting to the 1503 - * device may have failed for some reason. Mask this 1504 - * error, because otherwise mac80211 will not switch 1505 - * (and set the interface type back) and we'll be 1506 - * out of sync with it. 1507 - */ 1508 - err = 0; 1509 - 1510 - out: 1511 - mutex_unlock(&priv->shrd->mutex); 1512 - IWL_DEBUG_MAC80211(priv, "leave\n"); 1513 - 1514 - return err; 1515 - } 1516 1652 1517 1653 int iwl_cmd_echo_test(struct iwl_priv *priv) 1518 1654 { 1519 1655 int ret; 1520 1656 struct iwl_host_cmd cmd = { 1521 1657 .id = REPLY_ECHO, 1658 + .len = { 0 }, 1522 1659 .flags = CMD_SYNC, 1523 1660 }; 1524 1661
-14
drivers/net/wireless/iwlwifi/iwl-core.h
··· 237 237 * L i b * 238 238 ***************************/ 239 239 240 - int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, 241 - struct ieee80211_vif *vif, u16 queue, 242 - const struct ieee80211_tx_queue_params *params); 243 - int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw); 244 240 void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, struct iwl_rxon_context *ctx, 245 241 int hw_decrypt); 246 242 int iwl_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx); ··· 256 260 void iwl_connection_init_rx_config(struct iwl_priv *priv, 257 261 struct iwl_rxon_context *ctx); 258 262 void iwl_set_rate(struct iwl_priv *priv); 259 - int iwlagn_mac_add_interface(struct ieee80211_hw *hw, 260 - struct ieee80211_vif *vif); 261 - void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, 262 - struct ieee80211_vif *vif); 263 - int iwlagn_mac_change_interface(struct ieee80211_hw *hw, 264 - struct ieee80211_vif *vif, 265 - enum nl80211_iftype newtype, bool newp2p); 266 263 int iwl_cmd_echo_test(struct iwl_priv *priv); 267 264 #ifdef CONFIG_IWLWIFI_DEBUGFS 268 265 int iwl_alloc_traffic_mem(struct iwl_priv *priv); ··· 312 323 int iwl_scan_cancel(struct iwl_priv *priv); 313 324 void iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); 314 325 void iwl_force_scan_end(struct iwl_priv *priv); 315 - int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, 316 - struct ieee80211_vif *vif, 317 - struct cfg80211_scan_request *req); 318 326 void iwl_internal_short_hw_scan(struct iwl_priv *priv); 319 327 int iwl_force_reset(struct iwl_priv *priv, int mode, bool external); 320 328 u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame,
+2 -2
drivers/net/wireless/iwlwifi/iwl-csr.h
··· 284 284 #define CSR_HW_REV_TYPE_6x35 CSR_HW_REV_TYPE_6x05 285 285 #define CSR_HW_REV_TYPE_2x30 (0x00000C0) 286 286 #define CSR_HW_REV_TYPE_2x00 (0x0000100) 287 - #define CSR_HW_REV_TYPE_200 (0x0000110) 288 - #define CSR_HW_REV_TYPE_230 (0x0000120) 287 + #define CSR_HW_REV_TYPE_105 (0x0000110) 288 + #define CSR_HW_REV_TYPE_135 (0x0000120) 289 289 #define CSR_HW_REV_TYPE_NONE (0x00001F0) 290 290 291 291 /* EEPROM REG */
+17 -2
drivers/net/wireless/iwlwifi/iwl-debug.h
··· 70 70 DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ 71 71 } while (0) 72 72 73 + #define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \ 74 + do { \ 75 + if (!iwl_is_rfkill(p->shrd)) \ 76 + dev_printk(KERN_ERR, bus(p)->dev, "%c %s " fmt, \ 77 + (in_interrupt() ? 'I' : 'U'), __func__ , ##args); \ 78 + else if (iwl_get_debug_level(p->shrd) & IWL_DL_RADIO) \ 79 + dev_printk(KERN_ERR, bus(p)->dev, "(RFKILL) %c %s " fmt, \ 80 + (in_interrupt() ? 'I' : 'U'), __func__ , ##args); \ 81 + } while (0) 82 + 73 83 #else 74 84 #define IWL_DEBUG(m, level, fmt, args...) 75 85 #define IWL_DEBUG_LIMIT(m, level, fmt, args...) 76 86 #define iwl_print_hex_dump(m, level, p, len) 87 + #define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \ 88 + do { \ 89 + if (!iwl_is_rfkill(p->shrd)) \ 90 + IWL_ERR(p, fmt, ##args); \ 91 + } while (0) 77 92 #endif /* CONFIG_IWLWIFI_DEBUG */ 78 93 79 94 #ifdef CONFIG_IWLWIFI_DEBUGFS ··· 166 151 #define IWL_DL_11H (1 << 28) 167 152 #define IWL_DL_STATS (1 << 29) 168 153 #define IWL_DL_TX_REPLY (1 << 30) 169 - #define IWL_DL_QOS (1 << 31) 154 + #define IWL_DL_TX_QUEUES (1 << 31) 170 155 171 156 #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) 172 157 #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) ··· 203 188 #define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a) 204 189 #define IWL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ 205 190 IWL_DEBUG_LIMIT(p, IWL_DL_TX_REPLY, f, ## a) 206 - #define IWL_DEBUG_QOS(p, f, a...) IWL_DEBUG(p, IWL_DL_QOS, f, ## a) 191 + #define IWL_DEBUG_TX_QUEUES(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_QUEUES, f, ## a) 207 192 #define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a) 208 193 #define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a) 209 194 #define IWL_DEBUG_11H(p, f, a...) IWL_DEBUG(p, IWL_DL_11H, f, ## a)
+4 -4
drivers/net/wireless/iwlwifi/iwl-debugfs.c
··· 236 236 if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { 237 237 priv->dbgfs_sram_offset = 0x800000; 238 238 if (priv->ucode_type == IWL_UCODE_INIT) 239 - priv->dbgfs_sram_len = priv->ucode_init.data.len; 239 + priv->dbgfs_sram_len = trans(priv)->ucode_init.data.len; 240 240 else 241 - priv->dbgfs_sram_len = priv->ucode_rt.data.len; 241 + priv->dbgfs_sram_len = trans(priv)->ucode_rt.data.len; 242 242 } 243 243 len = priv->dbgfs_sram_len; 244 244 ··· 341 341 342 342 return simple_read_from_buffer(user_buf, count, ppos, 343 343 priv->wowlan_sram, 344 - priv->ucode_wowlan.data.len); 344 + trans(priv)->ucode_wowlan.data.len); 345 345 } 346 346 static ssize_t iwl_dbgfs_stations_read(struct file *file, char __user *user_buf, 347 347 size_t count, loff_t *ppos) ··· 430 430 eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); 431 431 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " 432 432 "version: 0x%x\n", 433 - (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) 433 + (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) 434 434 ? "OTP" : "EEPROM", eeprom_ver); 435 435 for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { 436 436 pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
+9 -25
drivers/net/wireless/iwlwifi/iwl-dev.h
··· 230 230 u8 ibss_bssid_sta_id; 231 231 }; 232 232 233 - /* one for each uCode image (inst/data, boot/init/runtime) */ 234 - struct fw_desc { 235 - void *v_addr; /* access by driver */ 236 - dma_addr_t p_addr; /* access by card's busmaster DMA */ 237 - u32 len; /* bytes */ 238 - }; 239 - 240 - struct fw_img { 241 - struct fw_desc code, data; 242 - }; 243 - 244 233 /* v1/v2 uCode file layout */ 245 234 struct iwl_ucode_header { 246 235 __le32 ver; /* major/minor/API/serial */ ··· 794 805 IWL_SCAN_ROC, 795 806 }; 796 807 797 - enum iwlagn_ucode_type { 798 - IWL_UCODE_NONE, 799 - IWL_UCODE_REGULAR, 800 - IWL_UCODE_INIT, 801 - IWL_UCODE_WOWLAN, 802 - }; 803 - 804 808 #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL 805 809 struct iwl_testmode_trace { 806 810 u32 buff_size; ··· 805 823 bool trace_enabled; 806 824 }; 807 825 #endif 826 + 827 + struct iwl_wipan_noa_data { 828 + struct rcu_head rcu_head; 829 + u32 length; 830 + u8 data[]; 831 + }; 808 832 809 833 struct iwl_priv { 810 834 ··· 871 883 /* init calibration results */ 872 884 struct iwl_calib_result calib_results[IWL_CALIB_MAX]; 873 885 886 + struct iwl_wipan_noa_data __rcu *noa_data; 887 + 874 888 /* Scan related variables */ 875 889 unsigned long scan_start; 876 890 unsigned long scan_start_tsf; ··· 897 907 u32 ucode_ver; /* version of ucode, copy of 898 908 iwl_ucode.ver */ 899 909 900 - struct fw_img ucode_rt; 901 - struct fw_img ucode_init; 902 - struct fw_img ucode_wowlan; 903 - 904 - enum iwlagn_ucode_type ucode_type; 905 - u8 ucode_write_complete; /* the image write is complete */ 910 + enum iwl_ucode_type ucode_type; 906 911 char firmware_name[25]; 907 912 908 913 struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; ··· 944 959 945 960 /* eeprom -- this is in the card's little endian byte order */ 946 961 u8 *eeprom; 947 - int nvm_device_type; 948 962 struct iwl_eeprom_calib_info *calib_info; 949 963 950 964 enum nl80211_iftype iw_mode;
+1 -1
drivers/net/wireless/iwlwifi/iwl-devtrace.c
··· 28 28 29 29 /* sparse doesn't like tracepoint macros */ 30 30 #ifndef __CHECKER__ 31 - #include "iwl-dev.h" 31 + #include "iwl-trans.h" 32 32 33 33 #define CREATE_TRACE_POINTS 34 34 #include "iwl-devtrace.h"
+11 -12
drivers/net/wireless/iwlwifi/iwl-devtrace.h
··· 29 29 30 30 #include <linux/tracepoint.h> 31 31 32 - struct iwl_priv; 33 32 34 33 #if !defined(CONFIG_IWLWIFI_DEVICE_TRACING) || defined(__CHECKER__) 35 34 #undef TRACE_EVENT ··· 36 37 static inline void trace_ ## name(proto) {} 37 38 #endif 38 39 39 - #define PRIV_ENTRY __field(struct iwl_priv *, priv) 40 + #define PRIV_ENTRY __field(void *, priv) 40 41 #define PRIV_ASSIGN __entry->priv = priv 41 42 42 43 #undef TRACE_SYSTEM 43 44 #define TRACE_SYSTEM iwlwifi_io 44 45 45 46 TRACE_EVENT(iwlwifi_dev_ioread32, 46 - TP_PROTO(struct iwl_priv *priv, u32 offs, u32 val), 47 + TP_PROTO(void *priv, u32 offs, u32 val), 47 48 TP_ARGS(priv, offs, val), 48 49 TP_STRUCT__entry( 49 50 PRIV_ENTRY ··· 59 60 ); 60 61 61 62 TRACE_EVENT(iwlwifi_dev_iowrite8, 62 - TP_PROTO(struct iwl_priv *priv, u32 offs, u8 val), 63 + TP_PROTO(void *priv, u32 offs, u8 val), 63 64 TP_ARGS(priv, offs, val), 64 65 TP_STRUCT__entry( 65 66 PRIV_ENTRY ··· 75 76 ); 76 77 77 78 TRACE_EVENT(iwlwifi_dev_iowrite32, 78 - TP_PROTO(struct iwl_priv *priv, u32 offs, u32 val), 79 + TP_PROTO(void *priv, u32 offs, u32 val), 79 80 TP_ARGS(priv, offs, val), 80 81 TP_STRUCT__entry( 81 82 PRIV_ENTRY ··· 94 95 #define TRACE_SYSTEM iwlwifi_ucode 95 96 96 97 TRACE_EVENT(iwlwifi_dev_ucode_cont_event, 97 - TP_PROTO(struct iwl_priv *priv, u32 time, u32 data, u32 ev), 98 + TP_PROTO(void *priv, u32 time, u32 data, u32 ev), 98 99 TP_ARGS(priv, time, data, ev), 99 100 TP_STRUCT__entry( 100 101 PRIV_ENTRY ··· 114 115 ); 115 116 116 117 TRACE_EVENT(iwlwifi_dev_ucode_wrap_event, 117 - TP_PROTO(struct iwl_priv *priv, u32 wraps, u32 n_entry, u32 p_entry), 118 + TP_PROTO(void *priv, u32 wraps, u32 n_entry, u32 p_entry), 118 119 TP_ARGS(priv, wraps, n_entry, p_entry), 119 120 TP_STRUCT__entry( 120 121 PRIV_ENTRY ··· 138 139 #define TRACE_SYSTEM iwlwifi 139 140 140 141 TRACE_EVENT(iwlwifi_dev_hcmd, 141 - TP_PROTO(struct iwl_priv *priv, u32 flags, 142 + TP_PROTO(void *priv, u32 flags, 142 143 const void *hcmd0, size_t len0, 143 144 const void *hcmd1, size_t len1, 144 145 const void *hcmd2, size_t len2), ··· 163 164 ); 164 165 165 166 TRACE_EVENT(iwlwifi_dev_rx, 166 - TP_PROTO(struct iwl_priv *priv, void *rxbuf, size_t len), 167 + TP_PROTO(void *priv, void *rxbuf, size_t len), 167 168 TP_ARGS(priv, rxbuf, len), 168 169 TP_STRUCT__entry( 169 170 PRIV_ENTRY ··· 178 179 ); 179 180 180 181 TRACE_EVENT(iwlwifi_dev_tx, 181 - TP_PROTO(struct iwl_priv *priv, void *tfd, size_t tfdlen, 182 + TP_PROTO(void *priv, void *tfd, size_t tfdlen, 182 183 void *buf0, size_t buf0_len, 183 184 void *buf1, size_t buf1_len), 184 185 TP_ARGS(priv, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len), ··· 210 211 ); 211 212 212 213 TRACE_EVENT(iwlwifi_dev_ucode_error, 213 - TP_PROTO(struct iwl_priv *priv, u32 desc, u32 tsf_low, 214 + TP_PROTO(void *priv, u32 desc, u32 tsf_low, 214 215 u32 data1, u32 data2, u32 line, u32 blink1, 215 216 u32 blink2, u32 ilink1, u32 ilink2, u32 bcon_time, 216 217 u32 gp1, u32 gp2, u32 gp3, u32 ucode_ver, u32 hw_ver, ··· 270 271 ); 271 272 272 273 TRACE_EVENT(iwlwifi_dev_ucode_event, 273 - TP_PROTO(struct iwl_priv *priv, u32 time, u32 data, u32 ev), 274 + TP_PROTO(void *priv, u32 time, u32 data, u32 ev), 274 275 TP_ARGS(priv, time, data, ev), 275 276 TP_STRUCT__entry( 276 277 PRIV_ENTRY
+71 -71
drivers/net/wireless/iwlwifi/iwl-eeprom.c
··· 149 149 * EEPROM chip, not a single event, so even reads could conflict if they 150 150 * weren't arbitrated by the semaphore. 151 151 */ 152 - static int iwl_eeprom_acquire_semaphore(struct iwl_priv *priv) 152 + static int iwl_eeprom_acquire_semaphore(struct iwl_bus *bus) 153 153 { 154 154 u16 count; 155 155 int ret; 156 156 157 157 for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { 158 158 /* Request semaphore */ 159 - iwl_set_bit(bus(priv), CSR_HW_IF_CONFIG_REG, 159 + iwl_set_bit(bus, CSR_HW_IF_CONFIG_REG, 160 160 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); 161 161 162 162 /* See if we got it */ 163 - ret = iwl_poll_bit(bus(priv), CSR_HW_IF_CONFIG_REG, 163 + ret = iwl_poll_bit(bus, CSR_HW_IF_CONFIG_REG, 164 164 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, 165 165 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, 166 166 EEPROM_SEM_TIMEOUT); 167 167 if (ret >= 0) { 168 - IWL_DEBUG_EEPROM(priv, 168 + IWL_DEBUG_EEPROM(bus, 169 169 "Acquired semaphore after %d tries.\n", 170 170 count+1); 171 171 return ret; ··· 175 175 return ret; 176 176 } 177 177 178 - static void iwl_eeprom_release_semaphore(struct iwl_priv *priv) 178 + static void iwl_eeprom_release_semaphore(struct iwl_bus *bus) 179 179 { 180 - iwl_clear_bit(bus(priv), CSR_HW_IF_CONFIG_REG, 180 + iwl_clear_bit(bus, CSR_HW_IF_CONFIG_REG, 181 181 CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); 182 182 183 183 } 184 184 185 - static int iwl_eeprom_verify_signature(struct iwl_priv *priv) 185 + static int iwl_eeprom_verify_signature(struct iwl_trans *trans) 186 186 { 187 - u32 gp = iwl_read32(bus(priv), CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; 187 + u32 gp = iwl_read32(bus(trans), CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; 188 188 int ret = 0; 189 189 190 - IWL_DEBUG_EEPROM(priv, "EEPROM signature=0x%08x\n", gp); 190 + IWL_DEBUG_EEPROM(trans, "EEPROM signature=0x%08x\n", gp); 191 191 switch (gp) { 192 192 case CSR_EEPROM_GP_BAD_SIG_EEP_GOOD_SIG_OTP: 193 - if (priv->nvm_device_type != NVM_DEVICE_TYPE_OTP) { 194 - IWL_ERR(priv, "EEPROM with bad signature: 0x%08x\n", 193 + if (trans->nvm_device_type != NVM_DEVICE_TYPE_OTP) { 194 + IWL_ERR(trans, "EEPROM with bad signature: 0x%08x\n", 195 195 gp); 196 196 ret = -ENOENT; 197 197 } 198 198 break; 199 199 case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: 200 200 case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: 201 - if (priv->nvm_device_type != NVM_DEVICE_TYPE_EEPROM) { 202 - IWL_ERR(priv, "OTP with bad signature: 0x%08x\n", gp); 201 + if (trans->nvm_device_type != NVM_DEVICE_TYPE_EEPROM) { 202 + IWL_ERR(trans, "OTP with bad signature: 0x%08x\n", gp); 203 203 ret = -ENOENT; 204 204 } 205 205 break; 206 206 case CSR_EEPROM_GP_BAD_SIGNATURE_BOTH_EEP_AND_OTP: 207 207 default: 208 - IWL_ERR(priv, "bad EEPROM/OTP signature, type=%s, " 208 + IWL_ERR(trans, "bad EEPROM/OTP signature, type=%s, " 209 209 "EEPROM_GP=0x%08x\n", 210 - (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) 210 + (trans->nvm_device_type == NVM_DEVICE_TYPE_OTP) 211 211 ? "OTP" : "EEPROM", gp); 212 212 ret = -ENOENT; 213 213 break; ··· 302 302 * 303 303 ******************************************************************************/ 304 304 305 - static void iwl_set_otp_access(struct iwl_priv *priv, enum iwl_access_mode mode) 305 + static void iwl_set_otp_access(struct iwl_bus *bus, enum iwl_access_mode mode) 306 306 { 307 - iwl_read32(bus(priv), CSR_OTP_GP_REG); 307 + iwl_read32(bus, CSR_OTP_GP_REG); 308 308 309 309 if (mode == IWL_OTP_ACCESS_ABSOLUTE) 310 - iwl_clear_bit(bus(priv), CSR_OTP_GP_REG, 310 + iwl_clear_bit(bus, CSR_OTP_GP_REG, 311 311 CSR_OTP_GP_REG_OTP_ACCESS_MODE); 312 312 else 313 - iwl_set_bit(bus(priv), CSR_OTP_GP_REG, 313 + iwl_set_bit(bus, CSR_OTP_GP_REG, 314 314 CSR_OTP_GP_REG_OTP_ACCESS_MODE); 315 315 } 316 316 317 - static int iwl_get_nvm_type(struct iwl_priv *priv, u32 hw_rev) 317 + static int iwl_get_nvm_type(struct iwl_bus *bus, u32 hw_rev) 318 318 { 319 319 u32 otpgp; 320 320 int nvm_type; ··· 322 322 /* OTP only valid for CP/PP and after */ 323 323 switch (hw_rev & CSR_HW_REV_TYPE_MSK) { 324 324 case CSR_HW_REV_TYPE_NONE: 325 - IWL_ERR(priv, "Unknown hardware type\n"); 325 + IWL_ERR(bus, "Unknown hardware type\n"); 326 326 return -ENOENT; 327 327 case CSR_HW_REV_TYPE_5300: 328 328 case CSR_HW_REV_TYPE_5350: ··· 331 331 nvm_type = NVM_DEVICE_TYPE_EEPROM; 332 332 break; 333 333 default: 334 - otpgp = iwl_read32(bus(priv), CSR_OTP_GP_REG); 334 + otpgp = iwl_read32(bus, CSR_OTP_GP_REG); 335 335 if (otpgp & CSR_OTP_GP_REG_DEVICE_SELECT) 336 336 nvm_type = NVM_DEVICE_TYPE_OTP; 337 337 else ··· 341 341 return nvm_type; 342 342 } 343 343 344 - static int iwl_init_otp_access(struct iwl_priv *priv) 344 + static int iwl_init_otp_access(struct iwl_bus *bus) 345 345 { 346 346 int ret; 347 347 348 348 /* Enable 40MHz radio clock */ 349 - iwl_write32(bus(priv), CSR_GP_CNTRL, 350 - iwl_read32(bus(priv), CSR_GP_CNTRL) | 349 + iwl_write32(bus, CSR_GP_CNTRL, 350 + iwl_read32(bus, CSR_GP_CNTRL) | 351 351 CSR_GP_CNTRL_REG_FLAG_INIT_DONE); 352 352 353 353 /* wait for clock to be ready */ 354 - ret = iwl_poll_bit(bus(priv), CSR_GP_CNTRL, 354 + ret = iwl_poll_bit(bus, CSR_GP_CNTRL, 355 355 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 356 356 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 357 357 25000); 358 358 if (ret < 0) 359 - IWL_ERR(priv, "Time out access OTP\n"); 359 + IWL_ERR(bus, "Time out access OTP\n"); 360 360 else { 361 - iwl_set_bits_prph(bus(priv), APMG_PS_CTRL_REG, 361 + iwl_set_bits_prph(bus, APMG_PS_CTRL_REG, 362 362 APMG_PS_CTRL_VAL_RESET_REQ); 363 363 udelay(5); 364 - iwl_clear_bits_prph(bus(priv), APMG_PS_CTRL_REG, 364 + iwl_clear_bits_prph(bus, APMG_PS_CTRL_REG, 365 365 APMG_PS_CTRL_VAL_RESET_REQ); 366 366 367 367 /* 368 368 * CSR auto clock gate disable bit - 369 369 * this is only applicable for HW with OTP shadow RAM 370 370 */ 371 - if (priv->cfg->base_params->shadow_ram_support) 372 - iwl_set_bit(bus(priv), CSR_DBG_LINK_PWR_MGMT_REG, 371 + if (priv(bus)->cfg->base_params->shadow_ram_support) 372 + iwl_set_bit(bus, CSR_DBG_LINK_PWR_MGMT_REG, 373 373 CSR_RESET_LINK_PWR_MGMT_DISABLED); 374 374 } 375 375 return ret; 376 376 } 377 377 378 - static int iwl_read_otp_word(struct iwl_priv *priv, u16 addr, __le16 *eeprom_data) 378 + static int iwl_read_otp_word(struct iwl_bus *bus, u16 addr, __le16 *eeprom_data) 379 379 { 380 380 int ret = 0; 381 381 u32 r; 382 382 u32 otpgp; 383 383 384 - iwl_write32(bus(priv), CSR_EEPROM_REG, 384 + iwl_write32(bus, CSR_EEPROM_REG, 385 385 CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); 386 - ret = iwl_poll_bit(bus(priv), CSR_EEPROM_REG, 386 + ret = iwl_poll_bit(bus, CSR_EEPROM_REG, 387 387 CSR_EEPROM_REG_READ_VALID_MSK, 388 388 CSR_EEPROM_REG_READ_VALID_MSK, 389 389 IWL_EEPROM_ACCESS_TIMEOUT); 390 390 if (ret < 0) { 391 - IWL_ERR(priv, "Time out reading OTP[%d]\n", addr); 391 + IWL_ERR(bus, "Time out reading OTP[%d]\n", addr); 392 392 return ret; 393 393 } 394 - r = iwl_read32(bus(priv), CSR_EEPROM_REG); 394 + r = iwl_read32(bus, CSR_EEPROM_REG); 395 395 /* check for ECC errors: */ 396 - otpgp = iwl_read32(bus(priv), CSR_OTP_GP_REG); 396 + otpgp = iwl_read32(bus, CSR_OTP_GP_REG); 397 397 if (otpgp & CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK) { 398 398 /* stop in this case */ 399 399 /* set the uncorrectable OTP ECC bit for acknowledgement */ 400 - iwl_set_bit(bus(priv), CSR_OTP_GP_REG, 400 + iwl_set_bit(bus, CSR_OTP_GP_REG, 401 401 CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); 402 - IWL_ERR(priv, "Uncorrectable OTP ECC error, abort OTP read\n"); 402 + IWL_ERR(bus, "Uncorrectable OTP ECC error, abort OTP read\n"); 403 403 return -EINVAL; 404 404 } 405 405 if (otpgp & CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK) { 406 406 /* continue in this case */ 407 407 /* set the correctable OTP ECC bit for acknowledgement */ 408 - iwl_set_bit(bus(priv), CSR_OTP_GP_REG, 408 + iwl_set_bit(bus, CSR_OTP_GP_REG, 409 409 CSR_OTP_GP_REG_ECC_CORR_STATUS_MSK); 410 - IWL_ERR(priv, "Correctable OTP ECC error, continue read\n"); 410 + IWL_ERR(bus, "Correctable OTP ECC error, continue read\n"); 411 411 } 412 412 *eeprom_data = cpu_to_le16(r >> 16); 413 413 return 0; ··· 416 416 /* 417 417 * iwl_is_otp_empty: check for empty OTP 418 418 */ 419 - static bool iwl_is_otp_empty(struct iwl_priv *priv) 419 + static bool iwl_is_otp_empty(struct iwl_bus *bus) 420 420 { 421 421 u16 next_link_addr = 0; 422 422 __le16 link_value; 423 423 bool is_empty = false; 424 424 425 425 /* locate the beginning of OTP link list */ 426 - if (!iwl_read_otp_word(priv, next_link_addr, &link_value)) { 426 + if (!iwl_read_otp_word(bus, next_link_addr, &link_value)) { 427 427 if (!link_value) { 428 - IWL_ERR(priv, "OTP is empty\n"); 428 + IWL_ERR(bus, "OTP is empty\n"); 429 429 is_empty = true; 430 430 } 431 431 } else { 432 - IWL_ERR(priv, "Unable to read first block of OTP list.\n"); 432 + IWL_ERR(bus, "Unable to read first block of OTP list.\n"); 433 433 is_empty = true; 434 434 } 435 435 ··· 446 446 * we should read and used to configure the device. 447 447 * only perform this operation if shadow RAM is disabled 448 448 */ 449 - static int iwl_find_otp_image(struct iwl_priv *priv, 449 + static int iwl_find_otp_image(struct iwl_bus *bus, 450 450 u16 *validblockaddr) 451 451 { 452 452 u16 next_link_addr = 0, valid_addr; ··· 454 454 int usedblocks = 0; 455 455 456 456 /* set addressing mode to absolute to traverse the link list */ 457 - iwl_set_otp_access(priv, IWL_OTP_ACCESS_ABSOLUTE); 457 + iwl_set_otp_access(bus, IWL_OTP_ACCESS_ABSOLUTE); 458 458 459 459 /* checking for empty OTP or error */ 460 - if (iwl_is_otp_empty(priv)) 460 + if (iwl_is_otp_empty(bus)) 461 461 return -EINVAL; 462 462 463 463 /* ··· 471 471 */ 472 472 valid_addr = next_link_addr; 473 473 next_link_addr = le16_to_cpu(link_value) * sizeof(u16); 474 - IWL_DEBUG_EEPROM(priv, "OTP blocks %d addr 0x%x\n", 474 + IWL_DEBUG_EEPROM(bus, "OTP blocks %d addr 0x%x\n", 475 475 usedblocks, next_link_addr); 476 - if (iwl_read_otp_word(priv, next_link_addr, &link_value)) 476 + if (iwl_read_otp_word(bus, next_link_addr, &link_value)) 477 477 return -EINVAL; 478 478 if (!link_value) { 479 479 /* ··· 488 488 } 489 489 /* more in the link list, continue */ 490 490 usedblocks++; 491 - } while (usedblocks <= priv->cfg->base_params->max_ll_items); 491 + } while (usedblocks <= priv(bus)->cfg->base_params->max_ll_items); 492 492 493 493 /* OTP has no valid blocks */ 494 - IWL_DEBUG_EEPROM(priv, "OTP has no valid blocks\n"); 494 + IWL_DEBUG_EEPROM(bus, "OTP has no valid blocks\n"); 495 495 return -EINVAL; 496 496 } 497 497 ··· 504 504 * iwl_get_max_txpower_avg - get the highest tx power from all chains. 505 505 * find the highest tx power from all chains for the channel 506 506 */ 507 - static s8 iwl_get_max_txpower_avg(struct iwl_priv *priv, 507 + static s8 iwl_get_max_txpower_avg(struct iwl_cfg *cfg, 508 508 struct iwl_eeprom_enhanced_txpwr *enhanced_txpower, 509 509 int element, s8 *max_txpower_in_half_dbm) 510 510 { 511 511 s8 max_txpower_avg = 0; /* (dBm) */ 512 512 513 513 /* Take the highest tx power from any valid chains */ 514 - if ((priv->cfg->valid_tx_ant & ANT_A) && 514 + if ((cfg->valid_tx_ant & ANT_A) && 515 515 (enhanced_txpower[element].chain_a_max > max_txpower_avg)) 516 516 max_txpower_avg = enhanced_txpower[element].chain_a_max; 517 - if ((priv->cfg->valid_tx_ant & ANT_B) && 517 + if ((cfg->valid_tx_ant & ANT_B) && 518 518 (enhanced_txpower[element].chain_b_max > max_txpower_avg)) 519 519 max_txpower_avg = enhanced_txpower[element].chain_b_max; 520 - if ((priv->cfg->valid_tx_ant & ANT_C) && 520 + if ((cfg->valid_tx_ant & ANT_C) && 521 521 (enhanced_txpower[element].chain_c_max > max_txpower_avg)) 522 522 max_txpower_avg = enhanced_txpower[element].chain_c_max; 523 - if (((priv->cfg->valid_tx_ant == ANT_AB) | 524 - (priv->cfg->valid_tx_ant == ANT_BC) | 525 - (priv->cfg->valid_tx_ant == ANT_AC)) && 523 + if (((cfg->valid_tx_ant == ANT_AB) | 524 + (cfg->valid_tx_ant == ANT_BC) | 525 + (cfg->valid_tx_ant == ANT_AC)) && 526 526 (enhanced_txpower[element].mimo2_max > max_txpower_avg)) 527 527 max_txpower_avg = enhanced_txpower[element].mimo2_max; 528 - if ((priv->cfg->valid_tx_ant == ANT_ABC) && 528 + if ((cfg->valid_tx_ant == ANT_ABC) && 529 529 (enhanced_txpower[element].mimo3_max > max_txpower_avg)) 530 530 max_txpower_avg = enhanced_txpower[element].mimo3_max; 531 531 ··· 627 627 ((txp->delta_20_in_40 & 0xf0) >> 4), 628 628 (txp->delta_20_in_40 & 0x0f)); 629 629 630 - max_txp_avg = iwl_get_max_txpower_avg(priv, txp_array, idx, 630 + max_txp_avg = iwl_get_max_txpower_avg(priv->cfg, txp_array, idx, 631 631 &max_txp_avg_halfdbm); 632 632 633 633 /* ··· 660 660 u16 validblockaddr = 0; 661 661 u16 cache_addr = 0; 662 662 663 - priv->nvm_device_type = iwl_get_nvm_type(priv, hw_rev); 664 - if (priv->nvm_device_type == -ENOENT) 663 + trans(priv)->nvm_device_type = iwl_get_nvm_type(bus(priv), hw_rev); 664 + if (trans(priv)->nvm_device_type == -ENOENT) 665 665 return -ENOENT; 666 666 /* allocate eeprom */ 667 667 sz = priv->cfg->base_params->eeprom_size; ··· 675 675 676 676 iwl_apm_init(priv); 677 677 678 - ret = iwl_eeprom_verify_signature(priv); 678 + ret = iwl_eeprom_verify_signature(trans(priv)); 679 679 if (ret < 0) { 680 680 IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); 681 681 ret = -ENOENT; ··· 683 683 } 684 684 685 685 /* Make sure driver (instead of uCode) is allowed to read EEPROM */ 686 - ret = iwl_eeprom_acquire_semaphore(priv); 686 + ret = iwl_eeprom_acquire_semaphore(bus(priv)); 687 687 if (ret < 0) { 688 688 IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); 689 689 ret = -ENOENT; 690 690 goto err; 691 691 } 692 692 693 - if (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) { 693 + if (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) { 694 694 695 - ret = iwl_init_otp_access(priv); 695 + ret = iwl_init_otp_access(bus(priv)); 696 696 if (ret) { 697 697 IWL_ERR(priv, "Failed to initialize OTP access.\n"); 698 698 ret = -ENOENT; ··· 707 707 CSR_OTP_GP_REG_ECC_UNCORR_STATUS_MSK); 708 708 /* traversing the linked list if no shadow ram supported */ 709 709 if (!priv->cfg->base_params->shadow_ram_support) { 710 - if (iwl_find_otp_image(priv, &validblockaddr)) { 710 + if (iwl_find_otp_image(bus(priv), &validblockaddr)) { 711 711 ret = -ENOENT; 712 712 goto done; 713 713 } ··· 716 716 addr += sizeof(u16)) { 717 717 __le16 eeprom_data; 718 718 719 - ret = iwl_read_otp_word(priv, addr, &eeprom_data); 719 + ret = iwl_read_otp_word(bus(priv), addr, &eeprom_data); 720 720 if (ret) 721 721 goto done; 722 722 e[cache_addr / 2] = eeprom_data; ··· 744 744 } 745 745 746 746 IWL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", 747 - (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) 747 + (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) 748 748 ? "OTP" : "EEPROM", 749 749 iwl_eeprom_query16(priv, EEPROM_VERSION)); 750 750 751 751 ret = 0; 752 752 done: 753 - iwl_eeprom_release_semaphore(priv); 753 + iwl_eeprom_release_semaphore(bus(priv)); 754 754 755 755 err: 756 756 if (ret)
+1632
drivers/net/wireless/iwlwifi/iwl-mac80211.c
··· 1 + /****************************************************************************** 2 + * 3 + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. 4 + * 5 + * Portions of this file are derived from the ipw3945 project, as well 6 + * as portions of the ieee80211 subsystem header files. 7 + * 8 + * This program is free software; you can redistribute it and/or modify it 9 + * under the terms of version 2 of the GNU General Public License as 10 + * published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, but WITHOUT 13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 + * more details. 16 + * 17 + * You should have received a copy of the GNU General Public License along with 18 + * this program; if not, write to the Free Software Foundation, Inc., 19 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA 20 + * 21 + * The full GNU General Public License is included in this distribution in the 22 + * file called LICENSE. 23 + * 24 + * Contact Information: 25 + * Intel Linux Wireless <ilw@linux.intel.com> 26 + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 27 + * 28 + *****************************************************************************/ 29 + #include <linux/kernel.h> 30 + #include <linux/module.h> 31 + #include <linux/init.h> 32 + #include <linux/slab.h> 33 + #include <linux/dma-mapping.h> 34 + #include <linux/delay.h> 35 + #include <linux/sched.h> 36 + #include <linux/skbuff.h> 37 + #include <linux/netdevice.h> 38 + #include <linux/firmware.h> 39 + #include <linux/etherdevice.h> 40 + #include <linux/if_arp.h> 41 + 42 + #include <net/mac80211.h> 43 + 44 + #include <asm/div64.h> 45 + 46 + #include "iwl-eeprom.h" 47 + #include "iwl-dev.h" 48 + #include "iwl-core.h" 49 + #include "iwl-io.h" 50 + #include "iwl-agn-calib.h" 51 + #include "iwl-agn.h" 52 + #include "iwl-shared.h" 53 + #include "iwl-bus.h" 54 + #include "iwl-trans.h" 55 + 56 + /***************************************************************************** 57 + * 58 + * mac80211 entry point functions 59 + * 60 + *****************************************************************************/ 61 + 62 + static const struct ieee80211_iface_limit iwlagn_sta_ap_limits[] = { 63 + { 64 + .max = 1, 65 + .types = BIT(NL80211_IFTYPE_STATION), 66 + }, 67 + { 68 + .max = 1, 69 + .types = BIT(NL80211_IFTYPE_AP), 70 + }, 71 + }; 72 + 73 + static const struct ieee80211_iface_limit iwlagn_2sta_limits[] = { 74 + { 75 + .max = 2, 76 + .types = BIT(NL80211_IFTYPE_STATION), 77 + }, 78 + }; 79 + 80 + static const struct ieee80211_iface_limit iwlagn_p2p_sta_go_limits[] = { 81 + { 82 + .max = 1, 83 + .types = BIT(NL80211_IFTYPE_STATION), 84 + }, 85 + { 86 + .max = 1, 87 + .types = BIT(NL80211_IFTYPE_P2P_GO) | 88 + BIT(NL80211_IFTYPE_AP), 89 + }, 90 + }; 91 + 92 + static const struct ieee80211_iface_limit iwlagn_p2p_2sta_limits[] = { 93 + { 94 + .max = 2, 95 + .types = BIT(NL80211_IFTYPE_STATION), 96 + }, 97 + { 98 + .max = 1, 99 + .types = BIT(NL80211_IFTYPE_P2P_CLIENT), 100 + }, 101 + }; 102 + 103 + static const struct ieee80211_iface_combination 104 + iwlagn_iface_combinations_dualmode[] = { 105 + { .num_different_channels = 1, 106 + .max_interfaces = 2, 107 + .beacon_int_infra_match = true, 108 + .limits = iwlagn_sta_ap_limits, 109 + .n_limits = ARRAY_SIZE(iwlagn_sta_ap_limits), 110 + }, 111 + { .num_different_channels = 1, 112 + .max_interfaces = 2, 113 + .limits = iwlagn_2sta_limits, 114 + .n_limits = ARRAY_SIZE(iwlagn_2sta_limits), 115 + }, 116 + }; 117 + 118 + static const struct ieee80211_iface_combination 119 + iwlagn_iface_combinations_p2p[] = { 120 + { .num_different_channels = 1, 121 + .max_interfaces = 2, 122 + .beacon_int_infra_match = true, 123 + .limits = iwlagn_p2p_sta_go_limits, 124 + .n_limits = ARRAY_SIZE(iwlagn_p2p_sta_go_limits), 125 + }, 126 + { .num_different_channels = 1, 127 + .max_interfaces = 2, 128 + .limits = iwlagn_p2p_2sta_limits, 129 + .n_limits = ARRAY_SIZE(iwlagn_p2p_2sta_limits), 130 + }, 131 + }; 132 + 133 + /* 134 + * Not a mac80211 entry point function, but it fits in with all the 135 + * other mac80211 functions grouped here. 136 + */ 137 + int iwlagn_mac_setup_register(struct iwl_priv *priv, 138 + struct iwlagn_ucode_capabilities *capa) 139 + { 140 + int ret; 141 + struct ieee80211_hw *hw = priv->hw; 142 + struct iwl_rxon_context *ctx; 143 + 144 + hw->rate_control_algorithm = "iwl-agn-rs"; 145 + 146 + /* Tell mac80211 our characteristics */ 147 + hw->flags = IEEE80211_HW_SIGNAL_DBM | 148 + IEEE80211_HW_AMPDU_AGGREGATION | 149 + IEEE80211_HW_NEED_DTIM_PERIOD | 150 + IEEE80211_HW_SPECTRUM_MGMT | 151 + IEEE80211_HW_REPORTS_TX_ACK_STATUS; 152 + 153 + /* 154 + * Including the following line will crash some AP's. This 155 + * workaround removes the stimulus which causes the crash until 156 + * the AP software can be fixed. 157 + hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF; 158 + */ 159 + 160 + hw->flags |= IEEE80211_HW_SUPPORTS_PS | 161 + IEEE80211_HW_SUPPORTS_DYNAMIC_PS; 162 + 163 + if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE) 164 + hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | 165 + IEEE80211_HW_SUPPORTS_STATIC_SMPS; 166 + 167 + if (capa->flags & IWL_UCODE_TLV_FLAGS_MFP) 168 + hw->flags |= IEEE80211_HW_MFP_CAPABLE; 169 + 170 + hw->sta_data_size = sizeof(struct iwl_station_priv); 171 + hw->vif_data_size = sizeof(struct iwl_vif_priv); 172 + 173 + for_each_context(priv, ctx) { 174 + hw->wiphy->interface_modes |= ctx->interface_modes; 175 + hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; 176 + } 177 + 178 + BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); 179 + 180 + if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT)) { 181 + hw->wiphy->iface_combinations = iwlagn_iface_combinations_p2p; 182 + hw->wiphy->n_iface_combinations = 183 + ARRAY_SIZE(iwlagn_iface_combinations_p2p); 184 + } else if (hw->wiphy->interface_modes & BIT(NL80211_IFTYPE_AP)) { 185 + hw->wiphy->iface_combinations = 186 + iwlagn_iface_combinations_dualmode; 187 + hw->wiphy->n_iface_combinations = 188 + ARRAY_SIZE(iwlagn_iface_combinations_dualmode); 189 + } 190 + 191 + hw->wiphy->max_remain_on_channel_duration = 1000; 192 + 193 + hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | 194 + WIPHY_FLAG_DISABLE_BEACON_HINTS | 195 + WIPHY_FLAG_IBSS_RSN; 196 + 197 + if (trans(priv)->ucode_wowlan.code.len && 198 + device_can_wakeup(bus(priv)->dev)) { 199 + hw->wiphy->wowlan.flags = WIPHY_WOWLAN_MAGIC_PKT | 200 + WIPHY_WOWLAN_DISCONNECT | 201 + WIPHY_WOWLAN_EAP_IDENTITY_REQ | 202 + WIPHY_WOWLAN_RFKILL_RELEASE; 203 + if (!iwlagn_mod_params.sw_crypto) 204 + hw->wiphy->wowlan.flags |= 205 + WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | 206 + WIPHY_WOWLAN_GTK_REKEY_FAILURE; 207 + 208 + hw->wiphy->wowlan.n_patterns = IWLAGN_WOWLAN_MAX_PATTERNS; 209 + hw->wiphy->wowlan.pattern_min_len = 210 + IWLAGN_WOWLAN_MIN_PATTERN_LEN; 211 + hw->wiphy->wowlan.pattern_max_len = 212 + IWLAGN_WOWLAN_MAX_PATTERN_LEN; 213 + } 214 + 215 + if (iwlagn_mod_params.power_save) 216 + hw->wiphy->flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT; 217 + else 218 + hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 219 + 220 + hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; 221 + /* we create the 802.11 header and a zero-length SSID element */ 222 + hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2; 223 + 224 + /* Default value; 4 EDCA QOS priorities */ 225 + hw->queues = 4; 226 + 227 + hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; 228 + 229 + if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) 230 + priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = 231 + &priv->bands[IEEE80211_BAND_2GHZ]; 232 + if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) 233 + priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = 234 + &priv->bands[IEEE80211_BAND_5GHZ]; 235 + 236 + iwl_leds_init(priv); 237 + 238 + ret = ieee80211_register_hw(priv->hw); 239 + if (ret) { 240 + IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); 241 + return ret; 242 + } 243 + priv->mac80211_registered = 1; 244 + 245 + return 0; 246 + } 247 + 248 + static int __iwl_up(struct iwl_priv *priv) 249 + { 250 + struct iwl_rxon_context *ctx; 251 + int ret; 252 + 253 + lockdep_assert_held(&priv->shrd->mutex); 254 + 255 + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { 256 + IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); 257 + return -EIO; 258 + } 259 + 260 + for_each_context(priv, ctx) { 261 + ret = iwlagn_alloc_bcast_station(priv, ctx); 262 + if (ret) { 263 + iwl_dealloc_bcast_stations(priv); 264 + return ret; 265 + } 266 + } 267 + 268 + ret = iwlagn_run_init_ucode(priv); 269 + if (ret) { 270 + IWL_ERR(priv, "Failed to run INIT ucode: %d\n", ret); 271 + goto error; 272 + } 273 + 274 + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); 275 + if (ret) { 276 + IWL_ERR(priv, "Failed to start RT ucode: %d\n", ret); 277 + goto error; 278 + } 279 + 280 + ret = iwl_alive_start(priv); 281 + if (ret) 282 + goto error; 283 + return 0; 284 + 285 + error: 286 + set_bit(STATUS_EXIT_PENDING, &priv->shrd->status); 287 + __iwl_down(priv); 288 + clear_bit(STATUS_EXIT_PENDING, &priv->shrd->status); 289 + 290 + IWL_ERR(priv, "Unable to initialize device.\n"); 291 + return ret; 292 + } 293 + 294 + static int iwlagn_mac_start(struct ieee80211_hw *hw) 295 + { 296 + struct iwl_priv *priv = hw->priv; 297 + int ret; 298 + 299 + IWL_DEBUG_MAC80211(priv, "enter\n"); 300 + 301 + /* we should be verifying the device is ready to be opened */ 302 + mutex_lock(&priv->shrd->mutex); 303 + ret = __iwl_up(priv); 304 + mutex_unlock(&priv->shrd->mutex); 305 + if (ret) 306 + return ret; 307 + 308 + IWL_DEBUG_INFO(priv, "Start UP work done.\n"); 309 + 310 + /* Now we should be done, and the READY bit should be set. */ 311 + if (WARN_ON(!test_bit(STATUS_READY, &priv->shrd->status))) 312 + ret = -EIO; 313 + 314 + iwlagn_led_enable(priv); 315 + 316 + priv->is_open = 1; 317 + IWL_DEBUG_MAC80211(priv, "leave\n"); 318 + return 0; 319 + } 320 + 321 + static void iwlagn_mac_stop(struct ieee80211_hw *hw) 322 + { 323 + struct iwl_priv *priv = hw->priv; 324 + 325 + IWL_DEBUG_MAC80211(priv, "enter\n"); 326 + 327 + if (!priv->is_open) 328 + return; 329 + 330 + priv->is_open = 0; 331 + 332 + iwl_down(priv); 333 + 334 + flush_workqueue(priv->shrd->workqueue); 335 + 336 + /* User space software may expect getting rfkill changes 337 + * even if interface is down */ 338 + iwl_write32(bus(priv), CSR_INT, 0xFFFFFFFF); 339 + iwl_enable_rfkill_int(priv); 340 + 341 + IWL_DEBUG_MAC80211(priv, "leave\n"); 342 + } 343 + 344 + static void iwlagn_mac_set_rekey_data(struct ieee80211_hw *hw, 345 + struct ieee80211_vif *vif, 346 + struct cfg80211_gtk_rekey_data *data) 347 + { 348 + struct iwl_priv *priv = hw->priv; 349 + 350 + if (iwlagn_mod_params.sw_crypto) 351 + return; 352 + 353 + IWL_DEBUG_MAC80211(priv, "enter\n"); 354 + mutex_lock(&priv->shrd->mutex); 355 + 356 + if (priv->contexts[IWL_RXON_CTX_BSS].vif != vif) 357 + goto out; 358 + 359 + memcpy(priv->kek, data->kek, NL80211_KEK_LEN); 360 + memcpy(priv->kck, data->kck, NL80211_KCK_LEN); 361 + priv->replay_ctr = 362 + cpu_to_le64(be64_to_cpup((__be64 *)&data->replay_ctr)); 363 + priv->have_rekey_data = true; 364 + 365 + out: 366 + mutex_unlock(&priv->shrd->mutex); 367 + IWL_DEBUG_MAC80211(priv, "leave\n"); 368 + } 369 + 370 + #ifdef CONFIG_PM_SLEEP 371 + 372 + static int iwlagn_mac_suspend(struct ieee80211_hw *hw, 373 + struct cfg80211_wowlan *wowlan) 374 + { 375 + struct iwl_priv *priv = hw->priv; 376 + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 377 + int ret; 378 + 379 + if (WARN_ON(!wowlan)) 380 + return -EINVAL; 381 + 382 + IWL_DEBUG_MAC80211(priv, "enter\n"); 383 + mutex_lock(&priv->shrd->mutex); 384 + 385 + /* Don't attempt WoWLAN when not associated, tear down instead. */ 386 + if (!ctx->vif || ctx->vif->type != NL80211_IFTYPE_STATION || 387 + !iwl_is_associated_ctx(ctx)) { 388 + ret = 1; 389 + goto out; 390 + } 391 + 392 + ret = iwlagn_suspend(priv, hw, wowlan); 393 + if (ret) 394 + goto error; 395 + 396 + device_set_wakeup_enable(bus(priv)->dev, true); 397 + 398 + /* Now let the ucode operate on its own */ 399 + iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_SET, 400 + CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); 401 + 402 + goto out; 403 + 404 + error: 405 + priv->shrd->wowlan = false; 406 + iwlagn_prepare_restart(priv); 407 + ieee80211_restart_hw(priv->hw); 408 + out: 409 + mutex_unlock(&priv->shrd->mutex); 410 + IWL_DEBUG_MAC80211(priv, "leave\n"); 411 + 412 + return ret; 413 + } 414 + 415 + static int iwlagn_mac_resume(struct ieee80211_hw *hw) 416 + { 417 + struct iwl_priv *priv = hw->priv; 418 + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 419 + struct ieee80211_vif *vif; 420 + unsigned long flags; 421 + u32 base, status = 0xffffffff; 422 + int ret = -EIO; 423 + 424 + IWL_DEBUG_MAC80211(priv, "enter\n"); 425 + mutex_lock(&priv->shrd->mutex); 426 + 427 + iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, 428 + CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); 429 + 430 + base = priv->device_pointers.error_event_table; 431 + if (iwlagn_hw_valid_rtc_data_addr(base)) { 432 + spin_lock_irqsave(&bus(priv)->reg_lock, flags); 433 + ret = iwl_grab_nic_access_silent(bus(priv)); 434 + if (ret == 0) { 435 + iwl_write32(bus(priv), HBUS_TARG_MEM_RADDR, base); 436 + status = iwl_read32(bus(priv), HBUS_TARG_MEM_RDAT); 437 + iwl_release_nic_access(bus(priv)); 438 + } 439 + spin_unlock_irqrestore(&bus(priv)->reg_lock, flags); 440 + 441 + #ifdef CONFIG_IWLWIFI_DEBUGFS 442 + if (ret == 0) { 443 + struct iwl_trans *trans = trans(priv); 444 + if (!priv->wowlan_sram) 445 + priv->wowlan_sram = 446 + kzalloc(trans->ucode_wowlan.data.len, 447 + GFP_KERNEL); 448 + 449 + if (priv->wowlan_sram) 450 + _iwl_read_targ_mem_words( 451 + bus(priv), 0x800000, priv->wowlan_sram, 452 + trans->ucode_wowlan.data.len / 4); 453 + } 454 + #endif 455 + } 456 + 457 + /* we'll clear ctx->vif during iwlagn_prepare_restart() */ 458 + vif = ctx->vif; 459 + 460 + priv->shrd->wowlan = false; 461 + 462 + device_set_wakeup_enable(bus(priv)->dev, false); 463 + 464 + iwlagn_prepare_restart(priv); 465 + 466 + memset((void *)&ctx->active, 0, sizeof(ctx->active)); 467 + iwl_connection_init_rx_config(priv, ctx); 468 + iwlagn_set_rxon_chain(priv, ctx); 469 + 470 + mutex_unlock(&priv->shrd->mutex); 471 + IWL_DEBUG_MAC80211(priv, "leave\n"); 472 + 473 + ieee80211_resume_disconnect(vif); 474 + 475 + return 1; 476 + } 477 + 478 + #endif 479 + 480 + static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 481 + { 482 + struct iwl_priv *priv = hw->priv; 483 + 484 + IWL_DEBUG_MACDUMP(priv, "enter\n"); 485 + 486 + IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, 487 + ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); 488 + 489 + if (iwlagn_tx_skb(priv, skb)) 490 + dev_kfree_skb_any(skb); 491 + 492 + IWL_DEBUG_MACDUMP(priv, "leave\n"); 493 + } 494 + 495 + static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, 496 + struct ieee80211_vif *vif, 497 + struct ieee80211_key_conf *keyconf, 498 + struct ieee80211_sta *sta, 499 + u32 iv32, u16 *phase1key) 500 + { 501 + struct iwl_priv *priv = hw->priv; 502 + 503 + iwl_update_tkip_key(priv, vif, keyconf, sta, iv32, phase1key); 504 + } 505 + 506 + static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 507 + struct ieee80211_vif *vif, 508 + struct ieee80211_sta *sta, 509 + struct ieee80211_key_conf *key) 510 + { 511 + struct iwl_priv *priv = hw->priv; 512 + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 513 + struct iwl_rxon_context *ctx = vif_priv->ctx; 514 + int ret; 515 + bool is_default_wep_key = false; 516 + 517 + IWL_DEBUG_MAC80211(priv, "enter\n"); 518 + 519 + if (iwlagn_mod_params.sw_crypto) { 520 + IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); 521 + return -EOPNOTSUPP; 522 + } 523 + 524 + /* 525 + * We could program these keys into the hardware as well, but we 526 + * don't expect much multicast traffic in IBSS and having keys 527 + * for more stations is probably more useful. 528 + * 529 + * Mark key TX-only and return 0. 530 + */ 531 + if (vif->type == NL80211_IFTYPE_ADHOC && 532 + !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { 533 + key->hw_key_idx = WEP_INVALID_OFFSET; 534 + return 0; 535 + } 536 + 537 + /* If they key was TX-only, accept deletion */ 538 + if (cmd == DISABLE_KEY && key->hw_key_idx == WEP_INVALID_OFFSET) 539 + return 0; 540 + 541 + mutex_lock(&priv->shrd->mutex); 542 + iwl_scan_cancel_timeout(priv, 100); 543 + 544 + BUILD_BUG_ON(WEP_INVALID_OFFSET == IWLAGN_HW_KEY_DEFAULT); 545 + 546 + /* 547 + * If we are getting WEP group key and we didn't receive any key mapping 548 + * so far, we are in legacy wep mode (group key only), otherwise we are 549 + * in 1X mode. 550 + * In legacy wep mode, we use another host command to the uCode. 551 + */ 552 + if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || 553 + key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { 554 + if (cmd == SET_KEY) 555 + is_default_wep_key = !ctx->key_mapping_keys; 556 + else 557 + is_default_wep_key = 558 + key->hw_key_idx == IWLAGN_HW_KEY_DEFAULT; 559 + } 560 + 561 + 562 + switch (cmd) { 563 + case SET_KEY: 564 + if (is_default_wep_key) { 565 + ret = iwl_set_default_wep_key(priv, vif_priv->ctx, key); 566 + break; 567 + } 568 + ret = iwl_set_dynamic_key(priv, vif_priv->ctx, key, sta); 569 + if (ret) { 570 + /* 571 + * can't add key for RX, but we don't need it 572 + * in the device for TX so still return 0 573 + */ 574 + ret = 0; 575 + key->hw_key_idx = WEP_INVALID_OFFSET; 576 + } 577 + 578 + IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); 579 + break; 580 + case DISABLE_KEY: 581 + if (is_default_wep_key) 582 + ret = iwl_remove_default_wep_key(priv, ctx, key); 583 + else 584 + ret = iwl_remove_dynamic_key(priv, ctx, key, sta); 585 + 586 + IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); 587 + break; 588 + default: 589 + ret = -EINVAL; 590 + } 591 + 592 + mutex_unlock(&priv->shrd->mutex); 593 + IWL_DEBUG_MAC80211(priv, "leave\n"); 594 + 595 + return ret; 596 + } 597 + 598 + static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw, 599 + struct ieee80211_vif *vif, 600 + enum ieee80211_ampdu_mlme_action action, 601 + struct ieee80211_sta *sta, u16 tid, u16 *ssn, 602 + u8 buf_size) 603 + { 604 + struct iwl_priv *priv = hw->priv; 605 + int ret = -EINVAL; 606 + struct iwl_station_priv *sta_priv = (void *) sta->drv_priv; 607 + struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); 608 + 609 + IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", 610 + sta->addr, tid); 611 + 612 + if (!(priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE)) 613 + return -EACCES; 614 + 615 + IWL_DEBUG_MAC80211(priv, "enter\n"); 616 + mutex_lock(&priv->shrd->mutex); 617 + 618 + switch (action) { 619 + case IEEE80211_AMPDU_RX_START: 620 + IWL_DEBUG_HT(priv, "start Rx\n"); 621 + ret = iwl_sta_rx_agg_start(priv, sta, tid, *ssn); 622 + break; 623 + case IEEE80211_AMPDU_RX_STOP: 624 + IWL_DEBUG_HT(priv, "stop Rx\n"); 625 + ret = iwl_sta_rx_agg_stop(priv, sta, tid); 626 + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) 627 + ret = 0; 628 + break; 629 + case IEEE80211_AMPDU_TX_START: 630 + IWL_DEBUG_HT(priv, "start Tx\n"); 631 + ret = iwlagn_tx_agg_start(priv, vif, sta, tid, ssn); 632 + break; 633 + case IEEE80211_AMPDU_TX_STOP: 634 + IWL_DEBUG_HT(priv, "stop Tx\n"); 635 + ret = iwlagn_tx_agg_stop(priv, vif, sta, tid); 636 + if ((ret == 0) && (priv->agg_tids_count > 0)) { 637 + priv->agg_tids_count--; 638 + IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", 639 + priv->agg_tids_count); 640 + } 641 + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) 642 + ret = 0; 643 + if (!priv->agg_tids_count && priv->cfg->ht_params && 644 + priv->cfg->ht_params->use_rts_for_aggregation) { 645 + /* 646 + * switch off RTS/CTS if it was previously enabled 647 + */ 648 + sta_priv->lq_sta.lq.general_params.flags &= 649 + ~LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; 650 + iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), 651 + &sta_priv->lq_sta.lq, CMD_ASYNC, false); 652 + } 653 + break; 654 + case IEEE80211_AMPDU_TX_OPERATIONAL: 655 + buf_size = min_t(int, buf_size, LINK_QUAL_AGG_FRAME_LIMIT_DEF); 656 + 657 + iwl_trans_tx_agg_setup(trans(priv), ctx->ctxid, iwl_sta_id(sta), 658 + tid, buf_size); 659 + 660 + /* 661 + * If the limit is 0, then it wasn't initialised yet, 662 + * use the default. We can do that since we take the 663 + * minimum below, and we don't want to go above our 664 + * default due to hardware restrictions. 665 + */ 666 + if (sta_priv->max_agg_bufsize == 0) 667 + sta_priv->max_agg_bufsize = 668 + LINK_QUAL_AGG_FRAME_LIMIT_DEF; 669 + 670 + /* 671 + * Even though in theory the peer could have different 672 + * aggregation reorder buffer sizes for different sessions, 673 + * our ucode doesn't allow for that and has a global limit 674 + * for each station. Therefore, use the minimum of all the 675 + * aggregation sessions and our default value. 676 + */ 677 + sta_priv->max_agg_bufsize = 678 + min(sta_priv->max_agg_bufsize, buf_size); 679 + 680 + if (priv->cfg->ht_params && 681 + priv->cfg->ht_params->use_rts_for_aggregation) { 682 + /* 683 + * switch to RTS/CTS if it is the prefer protection 684 + * method for HT traffic 685 + */ 686 + 687 + sta_priv->lq_sta.lq.general_params.flags |= 688 + LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK; 689 + } 690 + priv->agg_tids_count++; 691 + IWL_DEBUG_HT(priv, "priv->agg_tids_count = %u\n", 692 + priv->agg_tids_count); 693 + 694 + sta_priv->lq_sta.lq.agg_params.agg_frame_cnt_limit = 695 + sta_priv->max_agg_bufsize; 696 + 697 + iwl_send_lq_cmd(priv, iwl_rxon_ctx_from_vif(vif), 698 + &sta_priv->lq_sta.lq, CMD_ASYNC, false); 699 + 700 + IWL_INFO(priv, "Tx aggregation enabled on ra = %pM tid = %d\n", 701 + sta->addr, tid); 702 + ret = 0; 703 + break; 704 + } 705 + mutex_unlock(&priv->shrd->mutex); 706 + IWL_DEBUG_MAC80211(priv, "leave\n"); 707 + return ret; 708 + } 709 + 710 + static int iwlagn_mac_sta_add(struct ieee80211_hw *hw, 711 + struct ieee80211_vif *vif, 712 + struct ieee80211_sta *sta) 713 + { 714 + struct iwl_priv *priv = hw->priv; 715 + struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; 716 + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 717 + bool is_ap = vif->type == NL80211_IFTYPE_STATION; 718 + int ret = 0; 719 + u8 sta_id; 720 + 721 + IWL_DEBUG_MAC80211(priv, "received request to add station %pM\n", 722 + sta->addr); 723 + mutex_lock(&priv->shrd->mutex); 724 + IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", 725 + sta->addr); 726 + sta_priv->sta_id = IWL_INVALID_STATION; 727 + 728 + atomic_set(&sta_priv->pending_frames, 0); 729 + if (vif->type == NL80211_IFTYPE_AP) 730 + sta_priv->client = true; 731 + 732 + ret = iwl_add_station_common(priv, vif_priv->ctx, sta->addr, 733 + is_ap, sta, &sta_id); 734 + if (ret) { 735 + IWL_ERR(priv, "Unable to add station %pM (%d)\n", 736 + sta->addr, ret); 737 + /* Should we return success if return code is EEXIST ? */ 738 + goto out; 739 + } 740 + 741 + sta_priv->sta_id = sta_id; 742 + 743 + /* Initialize rate scaling */ 744 + IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", 745 + sta->addr); 746 + iwl_rs_rate_init(priv, sta, sta_id); 747 + out: 748 + mutex_unlock(&priv->shrd->mutex); 749 + IWL_DEBUG_MAC80211(priv, "leave\n"); 750 + 751 + return ret; 752 + } 753 + 754 + static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, 755 + struct ieee80211_channel_switch *ch_switch) 756 + { 757 + struct iwl_priv *priv = hw->priv; 758 + const struct iwl_channel_info *ch_info; 759 + struct ieee80211_conf *conf = &hw->conf; 760 + struct ieee80211_channel *channel = ch_switch->channel; 761 + struct iwl_ht_config *ht_conf = &priv->current_ht_config; 762 + /* 763 + * MULTI-FIXME 764 + * When we add support for multiple interfaces, we need to 765 + * revisit this. The channel switch command in the device 766 + * only affects the BSS context, but what does that really 767 + * mean? And what if we get a CSA on the second interface? 768 + * This needs a lot of work. 769 + */ 770 + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 771 + u16 ch; 772 + 773 + IWL_DEBUG_MAC80211(priv, "enter\n"); 774 + 775 + mutex_lock(&priv->shrd->mutex); 776 + 777 + if (iwl_is_rfkill(priv->shrd)) 778 + goto out; 779 + 780 + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status) || 781 + test_bit(STATUS_SCANNING, &priv->shrd->status) || 782 + test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status)) 783 + goto out; 784 + 785 + if (!iwl_is_associated_ctx(ctx)) 786 + goto out; 787 + 788 + if (!priv->cfg->lib->set_channel_switch) 789 + goto out; 790 + 791 + ch = channel->hw_value; 792 + if (le16_to_cpu(ctx->active.channel) == ch) 793 + goto out; 794 + 795 + ch_info = iwl_get_channel_info(priv, channel->band, ch); 796 + if (!is_channel_valid(ch_info)) { 797 + IWL_DEBUG_MAC80211(priv, "invalid channel\n"); 798 + goto out; 799 + } 800 + 801 + spin_lock_irq(&priv->shrd->lock); 802 + 803 + priv->current_ht_config.smps = conf->smps_mode; 804 + 805 + /* Configure HT40 channels */ 806 + ctx->ht.enabled = conf_is_ht(conf); 807 + if (ctx->ht.enabled) { 808 + if (conf_is_ht40_minus(conf)) { 809 + ctx->ht.extension_chan_offset = 810 + IEEE80211_HT_PARAM_CHA_SEC_BELOW; 811 + ctx->ht.is_40mhz = true; 812 + } else if (conf_is_ht40_plus(conf)) { 813 + ctx->ht.extension_chan_offset = 814 + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; 815 + ctx->ht.is_40mhz = true; 816 + } else { 817 + ctx->ht.extension_chan_offset = 818 + IEEE80211_HT_PARAM_CHA_SEC_NONE; 819 + ctx->ht.is_40mhz = false; 820 + } 821 + } else 822 + ctx->ht.is_40mhz = false; 823 + 824 + if ((le16_to_cpu(ctx->staging.channel) != ch)) 825 + ctx->staging.flags = 0; 826 + 827 + iwl_set_rxon_channel(priv, channel, ctx); 828 + iwl_set_rxon_ht(priv, ht_conf); 829 + iwl_set_flags_for_band(priv, ctx, channel->band, ctx->vif); 830 + 831 + spin_unlock_irq(&priv->shrd->lock); 832 + 833 + iwl_set_rate(priv); 834 + /* 835 + * at this point, staging_rxon has the 836 + * configuration for channel switch 837 + */ 838 + set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); 839 + priv->switch_channel = cpu_to_le16(ch); 840 + if (priv->cfg->lib->set_channel_switch(priv, ch_switch)) { 841 + clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->shrd->status); 842 + priv->switch_channel = 0; 843 + ieee80211_chswitch_done(ctx->vif, false); 844 + } 845 + 846 + out: 847 + mutex_unlock(&priv->shrd->mutex); 848 + IWL_DEBUG_MAC80211(priv, "leave\n"); 849 + } 850 + 851 + static void iwlagn_configure_filter(struct ieee80211_hw *hw, 852 + unsigned int changed_flags, 853 + unsigned int *total_flags, 854 + u64 multicast) 855 + { 856 + struct iwl_priv *priv = hw->priv; 857 + __le32 filter_or = 0, filter_nand = 0; 858 + struct iwl_rxon_context *ctx; 859 + 860 + #define CHK(test, flag) do { \ 861 + if (*total_flags & (test)) \ 862 + filter_or |= (flag); \ 863 + else \ 864 + filter_nand |= (flag); \ 865 + } while (0) 866 + 867 + IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", 868 + changed_flags, *total_flags); 869 + 870 + CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); 871 + /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ 872 + CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); 873 + CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); 874 + 875 + #undef CHK 876 + 877 + mutex_lock(&priv->shrd->mutex); 878 + 879 + for_each_context(priv, ctx) { 880 + ctx->staging.filter_flags &= ~filter_nand; 881 + ctx->staging.filter_flags |= filter_or; 882 + 883 + /* 884 + * Not committing directly because hardware can perform a scan, 885 + * but we'll eventually commit the filter flags change anyway. 886 + */ 887 + } 888 + 889 + mutex_unlock(&priv->shrd->mutex); 890 + 891 + /* 892 + * Receiving all multicast frames is always enabled by the 893 + * default flags setup in iwl_connection_init_rx_config() 894 + * since we currently do not support programming multicast 895 + * filters into the device. 896 + */ 897 + *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | 898 + FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; 899 + } 900 + 901 + static void iwlagn_mac_flush(struct ieee80211_hw *hw, bool drop) 902 + { 903 + struct iwl_priv *priv = hw->priv; 904 + 905 + mutex_lock(&priv->shrd->mutex); 906 + IWL_DEBUG_MAC80211(priv, "enter\n"); 907 + 908 + if (test_bit(STATUS_EXIT_PENDING, &priv->shrd->status)) { 909 + IWL_DEBUG_TX(priv, "Aborting flush due to device shutdown\n"); 910 + goto done; 911 + } 912 + if (iwl_is_rfkill(priv->shrd)) { 913 + IWL_DEBUG_TX(priv, "Aborting flush due to RF Kill\n"); 914 + goto done; 915 + } 916 + 917 + /* 918 + * mac80211 will not push any more frames for transmit 919 + * until the flush is completed 920 + */ 921 + if (drop) { 922 + IWL_DEBUG_MAC80211(priv, "send flush command\n"); 923 + if (iwlagn_txfifo_flush(priv, IWL_DROP_ALL)) { 924 + IWL_ERR(priv, "flush request fail\n"); 925 + goto done; 926 + } 927 + } 928 + IWL_DEBUG_MAC80211(priv, "wait transmit/flush all frames\n"); 929 + iwl_trans_wait_tx_queue_empty(trans(priv)); 930 + done: 931 + mutex_unlock(&priv->shrd->mutex); 932 + IWL_DEBUG_MAC80211(priv, "leave\n"); 933 + } 934 + 935 + static int iwlagn_mac_remain_on_channel(struct ieee80211_hw *hw, 936 + struct ieee80211_channel *channel, 937 + enum nl80211_channel_type channel_type, 938 + int duration) 939 + { 940 + struct iwl_priv *priv = hw->priv; 941 + struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_PAN]; 942 + int err = 0; 943 + 944 + if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) 945 + return -EOPNOTSUPP; 946 + 947 + if (!(ctx->interface_modes & BIT(NL80211_IFTYPE_P2P_CLIENT))) 948 + return -EOPNOTSUPP; 949 + 950 + IWL_DEBUG_MAC80211(priv, "enter\n"); 951 + mutex_lock(&priv->shrd->mutex); 952 + 953 + if (test_bit(STATUS_SCAN_HW, &priv->shrd->status)) { 954 + err = -EBUSY; 955 + goto out; 956 + } 957 + 958 + priv->hw_roc_channel = channel; 959 + priv->hw_roc_chantype = channel_type; 960 + /* convert from ms to TU */ 961 + priv->hw_roc_duration = DIV_ROUND_UP(1000 * duration, 1024); 962 + priv->hw_roc_start_notified = false; 963 + cancel_delayed_work(&priv->hw_roc_disable_work); 964 + 965 + if (!ctx->is_active) { 966 + static const struct iwl_qos_info default_qos_data = { 967 + .def_qos_parm = { 968 + .ac[0] = { 969 + .cw_min = cpu_to_le16(3), 970 + .cw_max = cpu_to_le16(7), 971 + .aifsn = 2, 972 + .edca_txop = cpu_to_le16(1504), 973 + }, 974 + .ac[1] = { 975 + .cw_min = cpu_to_le16(7), 976 + .cw_max = cpu_to_le16(15), 977 + .aifsn = 2, 978 + .edca_txop = cpu_to_le16(3008), 979 + }, 980 + .ac[2] = { 981 + .cw_min = cpu_to_le16(15), 982 + .cw_max = cpu_to_le16(1023), 983 + .aifsn = 3, 984 + }, 985 + .ac[3] = { 986 + .cw_min = cpu_to_le16(15), 987 + .cw_max = cpu_to_le16(1023), 988 + .aifsn = 7, 989 + }, 990 + }, 991 + }; 992 + 993 + ctx->is_active = true; 994 + ctx->qos_data = default_qos_data; 995 + ctx->staging.dev_type = RXON_DEV_TYPE_P2P; 996 + memcpy(ctx->staging.node_addr, 997 + priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, 998 + ETH_ALEN); 999 + memcpy(ctx->staging.bssid_addr, 1000 + priv->contexts[IWL_RXON_CTX_BSS].staging.node_addr, 1001 + ETH_ALEN); 1002 + err = iwlagn_commit_rxon(priv, ctx); 1003 + if (err) 1004 + goto out; 1005 + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK | 1006 + RXON_FILTER_PROMISC_MSK | 1007 + RXON_FILTER_CTL2HOST_MSK; 1008 + 1009 + err = iwlagn_commit_rxon(priv, ctx); 1010 + if (err) { 1011 + iwlagn_disable_roc(priv); 1012 + goto out; 1013 + } 1014 + priv->hw_roc_setup = true; 1015 + } 1016 + 1017 + err = iwl_scan_initiate(priv, ctx->vif, IWL_SCAN_ROC, channel->band); 1018 + if (err) 1019 + iwlagn_disable_roc(priv); 1020 + 1021 + out: 1022 + mutex_unlock(&priv->shrd->mutex); 1023 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1024 + 1025 + return err; 1026 + } 1027 + 1028 + static int iwlagn_mac_cancel_remain_on_channel(struct ieee80211_hw *hw) 1029 + { 1030 + struct iwl_priv *priv = hw->priv; 1031 + 1032 + if (!(priv->shrd->valid_contexts & BIT(IWL_RXON_CTX_PAN))) 1033 + return -EOPNOTSUPP; 1034 + 1035 + IWL_DEBUG_MAC80211(priv, "enter\n"); 1036 + mutex_lock(&priv->shrd->mutex); 1037 + iwl_scan_cancel_timeout(priv, priv->hw_roc_duration); 1038 + iwlagn_disable_roc(priv); 1039 + mutex_unlock(&priv->shrd->mutex); 1040 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1041 + 1042 + return 0; 1043 + } 1044 + 1045 + static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw, 1046 + struct ieee80211_vif *vif, 1047 + const u8 *bssid, 1048 + enum ieee80211_tx_sync_type type) 1049 + { 1050 + struct iwl_priv *priv = hw->priv; 1051 + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 1052 + struct iwl_rxon_context *ctx = vif_priv->ctx; 1053 + int ret; 1054 + u8 sta_id; 1055 + 1056 + IWL_DEBUG_MAC80211(priv, "enter\n"); 1057 + mutex_lock(&priv->shrd->mutex); 1058 + 1059 + if (iwl_is_associated_ctx(ctx)) { 1060 + ret = 0; 1061 + goto out; 1062 + } 1063 + 1064 + if (ctx->preauth_bssid || test_bit(STATUS_SCAN_HW, 1065 + &priv->shrd->status)) { 1066 + ret = -EBUSY; 1067 + goto out; 1068 + } 1069 + 1070 + ret = iwl_add_station_common(priv, ctx, bssid, true, NULL, &sta_id); 1071 + if (ret) 1072 + goto out; 1073 + 1074 + if (WARN_ON(sta_id != ctx->ap_sta_id)) { 1075 + ret = -EIO; 1076 + goto out_remove_sta; 1077 + } 1078 + 1079 + memcpy(ctx->bssid, bssid, ETH_ALEN); 1080 + ctx->preauth_bssid = true; 1081 + 1082 + ret = iwlagn_commit_rxon(priv, ctx); 1083 + 1084 + if (ret == 0) 1085 + goto out; 1086 + 1087 + out_remove_sta: 1088 + iwl_remove_station(priv, sta_id, bssid); 1089 + out: 1090 + mutex_unlock(&priv->shrd->mutex); 1091 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1092 + 1093 + return ret; 1094 + } 1095 + 1096 + static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw, 1097 + struct ieee80211_vif *vif, 1098 + const u8 *bssid, 1099 + enum ieee80211_tx_sync_type type) 1100 + { 1101 + struct iwl_priv *priv = hw->priv; 1102 + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 1103 + struct iwl_rxon_context *ctx = vif_priv->ctx; 1104 + 1105 + IWL_DEBUG_MAC80211(priv, "enter\n"); 1106 + mutex_lock(&priv->shrd->mutex); 1107 + 1108 + if (iwl_is_associated_ctx(ctx)) 1109 + goto out; 1110 + 1111 + iwl_remove_station(priv, ctx->ap_sta_id, bssid); 1112 + ctx->preauth_bssid = false; 1113 + /* no need to commit */ 1114 + out: 1115 + mutex_unlock(&priv->shrd->mutex); 1116 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1117 + } 1118 + 1119 + static void iwlagn_mac_rssi_callback(struct ieee80211_hw *hw, 1120 + enum ieee80211_rssi_event rssi_event) 1121 + { 1122 + struct iwl_priv *priv = hw->priv; 1123 + 1124 + IWL_DEBUG_MAC80211(priv, "enter\n"); 1125 + mutex_lock(&priv->shrd->mutex); 1126 + 1127 + if (priv->cfg->bt_params && 1128 + priv->cfg->bt_params->advanced_bt_coexist) { 1129 + if (rssi_event == RSSI_EVENT_LOW) 1130 + priv->bt_enable_pspoll = true; 1131 + else if (rssi_event == RSSI_EVENT_HIGH) 1132 + priv->bt_enable_pspoll = false; 1133 + 1134 + iwlagn_send_advance_bt_config(priv); 1135 + } else { 1136 + IWL_DEBUG_MAC80211(priv, "Advanced BT coex disabled," 1137 + "ignoring RSSI callback\n"); 1138 + } 1139 + 1140 + mutex_unlock(&priv->shrd->mutex); 1141 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1142 + } 1143 + 1144 + static int iwlagn_mac_set_tim(struct ieee80211_hw *hw, 1145 + struct ieee80211_sta *sta, bool set) 1146 + { 1147 + struct iwl_priv *priv = hw->priv; 1148 + 1149 + queue_work(priv->shrd->workqueue, &priv->beacon_update); 1150 + 1151 + return 0; 1152 + } 1153 + 1154 + static int iwlagn_mac_conf_tx(struct ieee80211_hw *hw, 1155 + struct ieee80211_vif *vif, u16 queue, 1156 + const struct ieee80211_tx_queue_params *params) 1157 + { 1158 + struct iwl_priv *priv = hw->priv; 1159 + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 1160 + struct iwl_rxon_context *ctx = vif_priv->ctx; 1161 + unsigned long flags; 1162 + int q; 1163 + 1164 + if (WARN_ON(!ctx)) 1165 + return -EINVAL; 1166 + 1167 + IWL_DEBUG_MAC80211(priv, "enter\n"); 1168 + 1169 + if (!iwl_is_ready_rf(priv->shrd)) { 1170 + IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); 1171 + return -EIO; 1172 + } 1173 + 1174 + if (queue >= AC_NUM) { 1175 + IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); 1176 + return 0; 1177 + } 1178 + 1179 + q = AC_NUM - 1 - queue; 1180 + 1181 + spin_lock_irqsave(&priv->shrd->lock, flags); 1182 + 1183 + ctx->qos_data.def_qos_parm.ac[q].cw_min = 1184 + cpu_to_le16(params->cw_min); 1185 + ctx->qos_data.def_qos_parm.ac[q].cw_max = 1186 + cpu_to_le16(params->cw_max); 1187 + ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; 1188 + ctx->qos_data.def_qos_parm.ac[q].edca_txop = 1189 + cpu_to_le16((params->txop * 32)); 1190 + 1191 + ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; 1192 + 1193 + spin_unlock_irqrestore(&priv->shrd->lock, flags); 1194 + 1195 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1196 + return 0; 1197 + } 1198 + 1199 + static int iwlagn_mac_tx_last_beacon(struct ieee80211_hw *hw) 1200 + { 1201 + struct iwl_priv *priv = hw->priv; 1202 + 1203 + return priv->ibss_manager == IWL_IBSS_MANAGER; 1204 + } 1205 + 1206 + static int iwl_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx) 1207 + { 1208 + iwl_connection_init_rx_config(priv, ctx); 1209 + 1210 + iwlagn_set_rxon_chain(priv, ctx); 1211 + 1212 + return iwlagn_commit_rxon(priv, ctx); 1213 + } 1214 + 1215 + static int iwl_setup_interface(struct iwl_priv *priv, 1216 + struct iwl_rxon_context *ctx) 1217 + { 1218 + struct ieee80211_vif *vif = ctx->vif; 1219 + int err; 1220 + 1221 + lockdep_assert_held(&priv->shrd->mutex); 1222 + 1223 + /* 1224 + * This variable will be correct only when there's just 1225 + * a single context, but all code using it is for hardware 1226 + * that supports only one context. 1227 + */ 1228 + priv->iw_mode = vif->type; 1229 + 1230 + ctx->is_active = true; 1231 + 1232 + err = iwl_set_mode(priv, ctx); 1233 + if (err) { 1234 + if (!ctx->always_active) 1235 + ctx->is_active = false; 1236 + return err; 1237 + } 1238 + 1239 + if (priv->cfg->bt_params && priv->cfg->bt_params->advanced_bt_coexist && 1240 + vif->type == NL80211_IFTYPE_ADHOC) { 1241 + /* 1242 + * pretend to have high BT traffic as long as we 1243 + * are operating in IBSS mode, as this will cause 1244 + * the rate scaling etc. to behave as intended. 1245 + */ 1246 + priv->bt_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_HIGH; 1247 + } 1248 + 1249 + return 0; 1250 + } 1251 + 1252 + static int iwlagn_mac_add_interface(struct ieee80211_hw *hw, 1253 + struct ieee80211_vif *vif) 1254 + { 1255 + struct iwl_priv *priv = hw->priv; 1256 + struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; 1257 + struct iwl_rxon_context *tmp, *ctx = NULL; 1258 + int err; 1259 + enum nl80211_iftype viftype = ieee80211_vif_type_p2p(vif); 1260 + 1261 + IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", 1262 + viftype, vif->addr); 1263 + 1264 + cancel_delayed_work_sync(&priv->hw_roc_disable_work); 1265 + 1266 + mutex_lock(&priv->shrd->mutex); 1267 + 1268 + iwlagn_disable_roc(priv); 1269 + 1270 + if (!iwl_is_ready_rf(priv->shrd)) { 1271 + IWL_WARN(priv, "Try to add interface when device not ready\n"); 1272 + err = -EINVAL; 1273 + goto out; 1274 + } 1275 + 1276 + for_each_context(priv, tmp) { 1277 + u32 possible_modes = 1278 + tmp->interface_modes | tmp->exclusive_interface_modes; 1279 + 1280 + if (tmp->vif) { 1281 + /* check if this busy context is exclusive */ 1282 + if (tmp->exclusive_interface_modes & 1283 + BIT(tmp->vif->type)) { 1284 + err = -EINVAL; 1285 + goto out; 1286 + } 1287 + continue; 1288 + } 1289 + 1290 + if (!(possible_modes & BIT(viftype))) 1291 + continue; 1292 + 1293 + /* have maybe usable context w/o interface */ 1294 + ctx = tmp; 1295 + break; 1296 + } 1297 + 1298 + if (!ctx) { 1299 + err = -EOPNOTSUPP; 1300 + goto out; 1301 + } 1302 + 1303 + vif_priv->ctx = ctx; 1304 + ctx->vif = vif; 1305 + 1306 + err = iwl_setup_interface(priv, ctx); 1307 + if (!err) 1308 + goto out; 1309 + 1310 + ctx->vif = NULL; 1311 + priv->iw_mode = NL80211_IFTYPE_STATION; 1312 + out: 1313 + mutex_unlock(&priv->shrd->mutex); 1314 + 1315 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1316 + return err; 1317 + } 1318 + 1319 + static void iwl_teardown_interface(struct iwl_priv *priv, 1320 + struct ieee80211_vif *vif, 1321 + bool mode_change) 1322 + { 1323 + struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); 1324 + 1325 + lockdep_assert_held(&priv->shrd->mutex); 1326 + 1327 + if (priv->scan_vif == vif) { 1328 + iwl_scan_cancel_timeout(priv, 200); 1329 + iwl_force_scan_end(priv); 1330 + } 1331 + 1332 + if (!mode_change) { 1333 + iwl_set_mode(priv, ctx); 1334 + if (!ctx->always_active) 1335 + ctx->is_active = false; 1336 + } 1337 + 1338 + /* 1339 + * When removing the IBSS interface, overwrite the 1340 + * BT traffic load with the stored one from the last 1341 + * notification, if any. If this is a device that 1342 + * doesn't implement this, this has no effect since 1343 + * both values are the same and zero. 1344 + */ 1345 + if (vif->type == NL80211_IFTYPE_ADHOC) 1346 + priv->bt_traffic_load = priv->last_bt_traffic_load; 1347 + } 1348 + 1349 + static void iwlagn_mac_remove_interface(struct ieee80211_hw *hw, 1350 + struct ieee80211_vif *vif) 1351 + { 1352 + struct iwl_priv *priv = hw->priv; 1353 + struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); 1354 + 1355 + IWL_DEBUG_MAC80211(priv, "enter\n"); 1356 + 1357 + mutex_lock(&priv->shrd->mutex); 1358 + 1359 + if (WARN_ON(ctx->vif != vif)) { 1360 + struct iwl_rxon_context *tmp; 1361 + IWL_ERR(priv, "ctx->vif = %p, vif = %p\n", ctx->vif, vif); 1362 + for_each_context(priv, tmp) 1363 + IWL_ERR(priv, "\tID = %d:\tctx = %p\tctx->vif = %p\n", 1364 + tmp->ctxid, tmp, tmp->vif); 1365 + } 1366 + ctx->vif = NULL; 1367 + 1368 + iwl_teardown_interface(priv, vif, false); 1369 + 1370 + mutex_unlock(&priv->shrd->mutex); 1371 + 1372 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1373 + 1374 + } 1375 + 1376 + static int iwlagn_mac_change_interface(struct ieee80211_hw *hw, 1377 + struct ieee80211_vif *vif, 1378 + enum nl80211_iftype newtype, bool newp2p) 1379 + { 1380 + struct iwl_priv *priv = hw->priv; 1381 + struct iwl_rxon_context *ctx = iwl_rxon_ctx_from_vif(vif); 1382 + struct iwl_rxon_context *bss_ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 1383 + struct iwl_rxon_context *tmp; 1384 + enum nl80211_iftype newviftype = newtype; 1385 + u32 interface_modes; 1386 + int err; 1387 + 1388 + IWL_DEBUG_MAC80211(priv, "enter\n"); 1389 + 1390 + newtype = ieee80211_iftype_p2p(newtype, newp2p); 1391 + 1392 + mutex_lock(&priv->shrd->mutex); 1393 + 1394 + if (!ctx->vif || !iwl_is_ready_rf(priv->shrd)) { 1395 + /* 1396 + * Huh? But wait ... this can maybe happen when 1397 + * we're in the middle of a firmware restart! 1398 + */ 1399 + err = -EBUSY; 1400 + goto out; 1401 + } 1402 + 1403 + interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes; 1404 + 1405 + if (!(interface_modes & BIT(newtype))) { 1406 + err = -EBUSY; 1407 + goto out; 1408 + } 1409 + 1410 + /* 1411 + * Refuse a change that should be done by moving from the PAN 1412 + * context to the BSS context instead, if the BSS context is 1413 + * available and can support the new interface type. 1414 + */ 1415 + if (ctx->ctxid == IWL_RXON_CTX_PAN && !bss_ctx->vif && 1416 + (bss_ctx->interface_modes & BIT(newtype) || 1417 + bss_ctx->exclusive_interface_modes & BIT(newtype))) { 1418 + BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); 1419 + err = -EBUSY; 1420 + goto out; 1421 + } 1422 + 1423 + if (ctx->exclusive_interface_modes & BIT(newtype)) { 1424 + for_each_context(priv, tmp) { 1425 + if (ctx == tmp) 1426 + continue; 1427 + 1428 + if (!tmp->vif) 1429 + continue; 1430 + 1431 + /* 1432 + * The current mode switch would be exclusive, but 1433 + * another context is active ... refuse the switch. 1434 + */ 1435 + err = -EBUSY; 1436 + goto out; 1437 + } 1438 + } 1439 + 1440 + /* success */ 1441 + iwl_teardown_interface(priv, vif, true); 1442 + vif->type = newviftype; 1443 + vif->p2p = newp2p; 1444 + err = iwl_setup_interface(priv, ctx); 1445 + WARN_ON(err); 1446 + /* 1447 + * We've switched internally, but submitting to the 1448 + * device may have failed for some reason. Mask this 1449 + * error, because otherwise mac80211 will not switch 1450 + * (and set the interface type back) and we'll be 1451 + * out of sync with it. 1452 + */ 1453 + err = 0; 1454 + 1455 + out: 1456 + mutex_unlock(&priv->shrd->mutex); 1457 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1458 + 1459 + return err; 1460 + } 1461 + 1462 + static int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, 1463 + struct ieee80211_vif *vif, 1464 + struct cfg80211_scan_request *req) 1465 + { 1466 + struct iwl_priv *priv = hw->priv; 1467 + int ret; 1468 + 1469 + IWL_DEBUG_MAC80211(priv, "enter\n"); 1470 + 1471 + if (req->n_channels == 0) 1472 + return -EINVAL; 1473 + 1474 + mutex_lock(&priv->shrd->mutex); 1475 + 1476 + /* 1477 + * If an internal scan is in progress, just set 1478 + * up the scan_request as per above. 1479 + */ 1480 + if (priv->scan_type != IWL_SCAN_NORMAL) { 1481 + IWL_DEBUG_SCAN(priv, 1482 + "SCAN request during internal scan - defer\n"); 1483 + priv->scan_request = req; 1484 + priv->scan_vif = vif; 1485 + ret = 0; 1486 + } else { 1487 + priv->scan_request = req; 1488 + priv->scan_vif = vif; 1489 + /* 1490 + * mac80211 will only ask for one band at a time 1491 + * so using channels[0] here is ok 1492 + */ 1493 + ret = iwl_scan_initiate(priv, vif, IWL_SCAN_NORMAL, 1494 + req->channels[0]->band); 1495 + if (ret) { 1496 + priv->scan_request = NULL; 1497 + priv->scan_vif = NULL; 1498 + } 1499 + } 1500 + 1501 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1502 + 1503 + mutex_unlock(&priv->shrd->mutex); 1504 + 1505 + return ret; 1506 + } 1507 + 1508 + static int iwlagn_mac_sta_remove(struct ieee80211_hw *hw, 1509 + struct ieee80211_vif *vif, 1510 + struct ieee80211_sta *sta) 1511 + { 1512 + struct iwl_priv *priv = hw->priv; 1513 + struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; 1514 + int ret; 1515 + 1516 + IWL_DEBUG_MAC80211(priv, "enter: received request to remove " 1517 + "station %pM\n", sta->addr); 1518 + mutex_lock(&priv->shrd->mutex); 1519 + IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", 1520 + sta->addr); 1521 + ret = iwl_remove_station(priv, sta_priv->sta_id, sta->addr); 1522 + if (ret) 1523 + IWL_DEBUG_QUIET_RFKILL(priv, "Error removing station %pM\n", 1524 + sta->addr); 1525 + mutex_unlock(&priv->shrd->mutex); 1526 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1527 + 1528 + return ret; 1529 + } 1530 + 1531 + static void iwl_sta_modify_ps_wake(struct iwl_priv *priv, int sta_id) 1532 + { 1533 + unsigned long flags; 1534 + 1535 + spin_lock_irqsave(&priv->shrd->sta_lock, flags); 1536 + priv->stations[sta_id].sta.station_flags &= ~STA_FLG_PWR_SAVE_MSK; 1537 + priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; 1538 + priv->stations[sta_id].sta.sta.modify_mask = 0; 1539 + priv->stations[sta_id].sta.sleep_tx_count = 0; 1540 + priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; 1541 + iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); 1542 + spin_unlock_irqrestore(&priv->shrd->sta_lock, flags); 1543 + 1544 + } 1545 + 1546 + static void iwlagn_mac_sta_notify(struct ieee80211_hw *hw, 1547 + struct ieee80211_vif *vif, 1548 + enum sta_notify_cmd cmd, 1549 + struct ieee80211_sta *sta) 1550 + { 1551 + struct iwl_priv *priv = hw->priv; 1552 + struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; 1553 + int sta_id; 1554 + 1555 + IWL_DEBUG_MAC80211(priv, "enter\n"); 1556 + 1557 + switch (cmd) { 1558 + case STA_NOTIFY_SLEEP: 1559 + WARN_ON(!sta_priv->client); 1560 + sta_priv->asleep = true; 1561 + if (atomic_read(&sta_priv->pending_frames) > 0) 1562 + ieee80211_sta_block_awake(hw, sta, true); 1563 + break; 1564 + case STA_NOTIFY_AWAKE: 1565 + WARN_ON(!sta_priv->client); 1566 + if (!sta_priv->asleep) 1567 + break; 1568 + sta_priv->asleep = false; 1569 + sta_id = iwl_sta_id(sta); 1570 + if (sta_id != IWL_INVALID_STATION) 1571 + iwl_sta_modify_ps_wake(priv, sta_id); 1572 + break; 1573 + default: 1574 + break; 1575 + } 1576 + IWL_DEBUG_MAC80211(priv, "leave\n"); 1577 + } 1578 + 1579 + struct ieee80211_ops iwlagn_hw_ops = { 1580 + .tx = iwlagn_mac_tx, 1581 + .start = iwlagn_mac_start, 1582 + .stop = iwlagn_mac_stop, 1583 + #ifdef CONFIG_PM_SLEEP 1584 + .suspend = iwlagn_mac_suspend, 1585 + .resume = iwlagn_mac_resume, 1586 + #endif 1587 + .add_interface = iwlagn_mac_add_interface, 1588 + .remove_interface = iwlagn_mac_remove_interface, 1589 + .change_interface = iwlagn_mac_change_interface, 1590 + .config = iwlagn_mac_config, 1591 + .configure_filter = iwlagn_configure_filter, 1592 + .set_key = iwlagn_mac_set_key, 1593 + .update_tkip_key = iwlagn_mac_update_tkip_key, 1594 + .set_rekey_data = iwlagn_mac_set_rekey_data, 1595 + .conf_tx = iwlagn_mac_conf_tx, 1596 + .bss_info_changed = iwlagn_bss_info_changed, 1597 + .ampdu_action = iwlagn_mac_ampdu_action, 1598 + .hw_scan = iwlagn_mac_hw_scan, 1599 + .sta_notify = iwlagn_mac_sta_notify, 1600 + .sta_add = iwlagn_mac_sta_add, 1601 + .sta_remove = iwlagn_mac_sta_remove, 1602 + .channel_switch = iwlagn_mac_channel_switch, 1603 + .flush = iwlagn_mac_flush, 1604 + .tx_last_beacon = iwlagn_mac_tx_last_beacon, 1605 + .remain_on_channel = iwlagn_mac_remain_on_channel, 1606 + .cancel_remain_on_channel = iwlagn_mac_cancel_remain_on_channel, 1607 + .rssi_callback = iwlagn_mac_rssi_callback, 1608 + CFG80211_TESTMODE_CMD(iwlagn_mac_testmode_cmd) 1609 + CFG80211_TESTMODE_DUMP(iwlagn_mac_testmode_dump) 1610 + .tx_sync = iwlagn_mac_tx_sync, 1611 + .finish_tx_sync = iwlagn_mac_finish_tx_sync, 1612 + .set_tim = iwlagn_mac_set_tim, 1613 + }; 1614 + 1615 + /* This function both allocates and initializes hw and priv. */ 1616 + struct ieee80211_hw *iwl_alloc_all(void) 1617 + { 1618 + struct iwl_priv *priv; 1619 + /* mac80211 allocates memory for this device instance, including 1620 + * space for this driver's private structure */ 1621 + struct ieee80211_hw *hw; 1622 + 1623 + hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), &iwlagn_hw_ops); 1624 + if (!hw) 1625 + goto out; 1626 + 1627 + priv = hw->priv; 1628 + priv->hw = hw; 1629 + 1630 + out: 1631 + return hw; 1632 + }
+2 -18
drivers/net/wireless/iwlwifi/iwl-pci.c
··· 256 256 {IWL_PCI_DEVICE(0x0082, 0xC020, iwl6005_2agn_sff_cfg)}, 257 257 {IWL_PCI_DEVICE(0x0085, 0xC220, iwl6005_2agn_sff_cfg)}, 258 258 {IWL_PCI_DEVICE(0x0082, 0x1341, iwl6005_2agn_d_cfg)}, 259 + {IWL_PCI_DEVICE(0x0082, 0x1304, iwl6005_2agn_cfg)},/* low 5GHz active */ 260 + {IWL_PCI_DEVICE(0x0082, 0x1305, iwl6005_2agn_cfg)},/* high 5GHz active */ 259 261 260 262 /* 6x30 Series */ 261 263 {IWL_PCI_DEVICE(0x008A, 0x5305, iwl1030_bgn_cfg)}, ··· 327 325 {IWL_PCI_DEVICE(0x0890, 0x4022, iwl2000_2bgn_cfg)}, 328 326 {IWL_PCI_DEVICE(0x0891, 0x4222, iwl2000_2bgn_cfg)}, 329 327 {IWL_PCI_DEVICE(0x0890, 0x4422, iwl2000_2bgn_cfg)}, 330 - {IWL_PCI_DEVICE(0x0890, 0x4026, iwl2000_2bg_cfg)}, 331 - {IWL_PCI_DEVICE(0x0891, 0x4226, iwl2000_2bg_cfg)}, 332 - {IWL_PCI_DEVICE(0x0890, 0x4426, iwl2000_2bg_cfg)}, 333 328 {IWL_PCI_DEVICE(0x0890, 0x4822, iwl2000_2bgn_d_cfg)}, 334 329 335 330 /* 2x30 Series */ 336 331 {IWL_PCI_DEVICE(0x0887, 0x4062, iwl2030_2bgn_cfg)}, 337 332 {IWL_PCI_DEVICE(0x0888, 0x4262, iwl2030_2bgn_cfg)}, 338 333 {IWL_PCI_DEVICE(0x0887, 0x4462, iwl2030_2bgn_cfg)}, 339 - {IWL_PCI_DEVICE(0x0887, 0x4066, iwl2030_2bg_cfg)}, 340 - {IWL_PCI_DEVICE(0x0888, 0x4266, iwl2030_2bg_cfg)}, 341 - {IWL_PCI_DEVICE(0x0887, 0x4466, iwl2030_2bg_cfg)}, 342 334 343 335 /* 6x35 Series */ 344 336 {IWL_PCI_DEVICE(0x088E, 0x4060, iwl6035_2agn_cfg)}, 345 337 {IWL_PCI_DEVICE(0x088F, 0x4260, iwl6035_2agn_cfg)}, 346 338 {IWL_PCI_DEVICE(0x088E, 0x4460, iwl6035_2agn_cfg)}, 347 - {IWL_PCI_DEVICE(0x088E, 0x4064, iwl6035_2abg_cfg)}, 348 - {IWL_PCI_DEVICE(0x088F, 0x4264, iwl6035_2abg_cfg)}, 349 - {IWL_PCI_DEVICE(0x088E, 0x4464, iwl6035_2abg_cfg)}, 350 - {IWL_PCI_DEVICE(0x088E, 0x4066, iwl6035_2bg_cfg)}, 351 - {IWL_PCI_DEVICE(0x088F, 0x4266, iwl6035_2bg_cfg)}, 352 - {IWL_PCI_DEVICE(0x088E, 0x4466, iwl6035_2bg_cfg)}, 353 339 354 340 /* 105 Series */ 355 341 {IWL_PCI_DEVICE(0x0894, 0x0022, iwl105_bgn_cfg)}, 356 342 {IWL_PCI_DEVICE(0x0895, 0x0222, iwl105_bgn_cfg)}, 357 343 {IWL_PCI_DEVICE(0x0894, 0x0422, iwl105_bgn_cfg)}, 358 - {IWL_PCI_DEVICE(0x0894, 0x0026, iwl105_bg_cfg)}, 359 - {IWL_PCI_DEVICE(0x0895, 0x0226, iwl105_bg_cfg)}, 360 - {IWL_PCI_DEVICE(0x0894, 0x0426, iwl105_bg_cfg)}, 361 344 {IWL_PCI_DEVICE(0x0894, 0x0822, iwl105_bgn_d_cfg)}, 362 345 363 346 /* 135 Series */ 364 347 {IWL_PCI_DEVICE(0x0892, 0x0062, iwl135_bgn_cfg)}, 365 348 {IWL_PCI_DEVICE(0x0893, 0x0262, iwl135_bgn_cfg)}, 366 349 {IWL_PCI_DEVICE(0x0892, 0x0462, iwl135_bgn_cfg)}, 367 - {IWL_PCI_DEVICE(0x0892, 0x0066, iwl135_bg_cfg)}, 368 - {IWL_PCI_DEVICE(0x0893, 0x0266, iwl135_bg_cfg)}, 369 - {IWL_PCI_DEVICE(0x0892, 0x0466, iwl135_bg_cfg)}, 370 350 371 351 {0} 372 352 };
+4 -46
drivers/net/wireless/iwlwifi/iwl-scan.c
··· 416 416 417 417 if (!iwl_is_associated_ctx(ctx)) 418 418 continue; 419 + if (ctx->staging.dev_type == RXON_DEV_TYPE_P2P) 420 + continue; 419 421 value = ctx->beacon_int; 420 422 if (!value) 421 423 value = IWL_PASSIVE_DWELL_BASE; ··· 680 678 priv->contexts[IWL_RXON_CTX_BSS].active.flags & 681 679 RXON_FLG_CHANNEL_MODE_MSK) 682 680 >> RXON_FLG_CHANNEL_MODE_POS; 683 - if (chan_mod == CHANNEL_MODE_PURE_40) { 681 + if ((priv->scan_request && priv->scan_request->no_cck) || 682 + chan_mod == CHANNEL_MODE_PURE_40) { 684 683 rate = IWL_RATE_6M_PLCP; 685 684 } else { 686 685 rate = IWL_RATE_1M_PLCP; ··· 941 938 return 0; 942 939 } 943 940 944 - int iwlagn_mac_hw_scan(struct ieee80211_hw *hw, 945 - struct ieee80211_vif *vif, 946 - struct cfg80211_scan_request *req) 947 - { 948 - struct iwl_priv *priv = hw->priv; 949 - int ret; 950 - 951 - IWL_DEBUG_MAC80211(priv, "enter\n"); 952 - 953 - if (req->n_channels == 0) 954 - return -EINVAL; 955 - 956 - mutex_lock(&priv->shrd->mutex); 957 - 958 - /* 959 - * If an internal scan is in progress, just set 960 - * up the scan_request as per above. 961 - */ 962 - if (priv->scan_type != IWL_SCAN_NORMAL) { 963 - IWL_DEBUG_SCAN(priv, 964 - "SCAN request during internal scan - defer\n"); 965 - priv->scan_request = req; 966 - priv->scan_vif = vif; 967 - ret = 0; 968 - } else { 969 - priv->scan_request = req; 970 - priv->scan_vif = vif; 971 - /* 972 - * mac80211 will only ask for one band at a time 973 - * so using channels[0] here is ok 974 - */ 975 - ret = iwl_scan_initiate(priv, vif, IWL_SCAN_NORMAL, 976 - req->channels[0]->band); 977 - if (ret) { 978 - priv->scan_request = NULL; 979 - priv->scan_vif = NULL; 980 - } 981 - } 982 - 983 - IWL_DEBUG_MAC80211(priv, "leave\n"); 984 - 985 - mutex_unlock(&priv->shrd->mutex); 986 - 987 - return ret; 988 - } 989 941 990 942 /* 991 943 * internal short scan, this function should only been called while associated.
+2 -5
drivers/net/wireless/iwlwifi/iwl-sv-open.c
··· 396 396 break; 397 397 398 398 case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: 399 - status = iwlagn_load_ucode_wait_alive(priv, &priv->ucode_init, 400 - IWL_UCODE_INIT); 399 + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); 401 400 if (status) 402 401 IWL_DEBUG_INFO(priv, 403 402 "Error loading init ucode: %d\n", status); ··· 408 409 break; 409 410 410 411 case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: 411 - status = iwlagn_load_ucode_wait_alive(priv, 412 - &priv->ucode_rt, 413 - IWL_UCODE_REGULAR); 412 + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); 414 413 if (status) { 415 414 IWL_DEBUG_INFO(priv, 416 415 "Error loading runtime ucode: %d\n", status);
+29 -6
drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h
··· 355 355 } 356 356 357 357 static inline void iwl_wake_queue(struct iwl_trans *trans, 358 - struct iwl_tx_queue *txq) 358 + struct iwl_tx_queue *txq, const char *msg) 359 359 { 360 360 u8 queue = txq->swq_id; 361 361 u8 ac = queue & 3; ··· 363 363 struct iwl_trans_pcie *trans_pcie = 364 364 IWL_TRANS_GET_PCIE_TRANS(trans); 365 365 366 - if (test_and_clear_bit(hwq, trans_pcie->queue_stopped)) 367 - if (atomic_dec_return(&trans_pcie->queue_stop_count[ac]) <= 0) 366 + if (test_and_clear_bit(hwq, trans_pcie->queue_stopped)) { 367 + if (atomic_dec_return(&trans_pcie->queue_stop_count[ac]) <= 0) { 368 368 iwl_wake_sw_queue(priv(trans), ac); 369 + IWL_DEBUG_TX_QUEUES(trans, "Wake hwq %d ac %d. %s", 370 + hwq, ac, msg); 371 + } else { 372 + IWL_DEBUG_TX_QUEUES(trans, "Don't wake hwq %d ac %d" 373 + " stop count %d. %s", 374 + hwq, ac, atomic_read(&trans_pcie-> 375 + queue_stop_count[ac]), msg); 376 + } 377 + } 369 378 } 370 379 371 380 static inline void iwl_stop_queue(struct iwl_trans *trans, 372 - struct iwl_tx_queue *txq) 381 + struct iwl_tx_queue *txq, const char *msg) 373 382 { 374 383 u8 queue = txq->swq_id; 375 384 u8 ac = queue & 3; ··· 386 377 struct iwl_trans_pcie *trans_pcie = 387 378 IWL_TRANS_GET_PCIE_TRANS(trans); 388 379 389 - if (!test_and_set_bit(hwq, trans_pcie->queue_stopped)) 390 - if (atomic_inc_return(&trans_pcie->queue_stop_count[ac]) > 0) 380 + if (!test_and_set_bit(hwq, trans_pcie->queue_stopped)) { 381 + if (atomic_inc_return(&trans_pcie->queue_stop_count[ac]) > 0) { 391 382 iwl_stop_sw_queue(priv(trans), ac); 383 + IWL_DEBUG_TX_QUEUES(trans, "Stop hwq %d ac %d" 384 + " stop count %d. %s", 385 + hwq, ac, atomic_read(&trans_pcie-> 386 + queue_stop_count[ac]), msg); 387 + } else { 388 + IWL_DEBUG_TX_QUEUES(trans, "Don't stop hwq %d ac %d" 389 + " stop count %d. %s", 390 + hwq, ac, atomic_read(&trans_pcie-> 391 + queue_stop_count[ac]), msg); 392 + } 393 + } else { 394 + IWL_DEBUG_TX_QUEUES(trans, "stop hwq %d, but it is stopped/ %s", 395 + hwq, msg); 396 + } 392 397 } 393 398 394 399 #ifdef ieee80211_stop_queue
+1 -1
drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c
··· 1108 1108 isr_stats->tx++; 1109 1109 handled |= CSR_INT_BIT_FH_TX; 1110 1110 /* Wake up uCode load routine, now that load is complete */ 1111 - priv(trans)->ucode_write_complete = 1; 1111 + trans->ucode_write_complete = 1; 1112 1112 wake_up(&trans->shrd->wait_command_queue); 1113 1113 } 1114 1114
+29 -23
drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c
··· 430 430 431 431 txq->sched_retry = scd_retry; 432 432 433 - IWL_DEBUG_INFO(trans, "%s %s Queue %d on FIFO %d\n", 433 + IWL_DEBUG_TX_QUEUES(trans, "%s %s Queue %d on FIFO %d\n", 434 434 active ? "Activate" : "Deactivate", 435 435 scd_retry ? "BA" : "AC/CMD", txq_id, tx_fifo_id); 436 436 } ··· 561 561 562 562 tid_data = &trans->shrd->tid_data[sta_id][tid]; 563 563 if (tid_data->tfds_in_queue == 0) { 564 - IWL_DEBUG_HT(trans, "HW queue is empty\n"); 564 + IWL_DEBUG_TX_QUEUES(trans, "HW queue is empty\n"); 565 565 tid_data->agg.state = IWL_AGG_ON; 566 566 iwl_start_tx_ba_trans_ready(priv(trans), ctx, sta_id, tid); 567 567 } else { 568 - IWL_DEBUG_HT(trans, "HW queue is NOT empty: %d packets in HW" 569 - "queue\n", tid_data->tfds_in_queue); 568 + IWL_DEBUG_TX_QUEUES(trans, 569 + "HW queue is NOT empty: %d packets in HW" 570 + " queue\n", tid_data->tfds_in_queue); 570 571 tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; 571 572 } 572 573 spin_unlock_irqrestore(&trans->shrd->sta_lock, flags); ··· 644 643 645 644 /* The queue is not empty */ 646 645 if (write_ptr != read_ptr) { 647 - IWL_DEBUG_HT(trans, "Stopping a non empty AGG HW QUEUE\n"); 646 + IWL_DEBUG_TX_QUEUES(trans, 647 + "Stopping a non empty AGG HW QUEUE\n"); 648 648 trans->shrd->tid_data[sta_id][tid].agg.state = 649 649 IWL_EMPTYING_HW_QUEUE_DELBA; 650 650 spin_unlock_irqrestore(&trans->shrd->sta_lock, flags); 651 651 return 0; 652 652 } 653 653 654 - IWL_DEBUG_HT(trans, "HW queue is empty\n"); 654 + IWL_DEBUG_TX_QUEUES(trans, "HW queue is empty\n"); 655 655 turn_off: 656 656 trans->shrd->tid_data[sta_id][tid].agg.state = IWL_AGG_OFF; 657 657 ··· 984 982 985 983 ret = iwl_enqueue_hcmd(trans, cmd); 986 984 if (ret < 0) { 987 - IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", 985 + IWL_DEBUG_QUIET_RFKILL(trans, 986 + "Error sending %s: enqueue_hcmd failed: %d\n", 988 987 get_cmd_string(cmd->id), ret); 989 988 return ret; 990 989 } ··· 1003 1000 IWL_DEBUG_INFO(trans, "Attempting to send sync command %s\n", 1004 1001 get_cmd_string(cmd->id)); 1005 1002 1003 + if (test_bit(STATUS_EXIT_PENDING, &trans->shrd->status)) 1004 + return -EBUSY; 1005 + 1006 + 1007 + if (test_bit(STATUS_RF_KILL_HW, &trans->shrd->status)) { 1008 + IWL_ERR(trans, "Command %s aborted: RF KILL Switch\n", 1009 + get_cmd_string(cmd->id)); 1010 + return -ECANCELED; 1011 + } 1012 + if (test_bit(STATUS_FW_ERROR, &trans->shrd->status)) { 1013 + IWL_ERR(trans, "Command %s failed: FW Error\n", 1014 + get_cmd_string(cmd->id)); 1015 + return -EIO; 1016 + } 1006 1017 set_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); 1007 1018 IWL_DEBUG_INFO(trans, "Setting HCMD_ACTIVE for command %s\n", 1008 1019 get_cmd_string(cmd->id)); ··· 1025 1008 if (cmd_idx < 0) { 1026 1009 ret = cmd_idx; 1027 1010 clear_bit(STATUS_HCMD_ACTIVE, &trans->shrd->status); 1028 - IWL_ERR(trans, "Error sending %s: enqueue_hcmd failed: %d\n", 1011 + IWL_DEBUG_QUIET_RFKILL(trans, 1012 + "Error sending %s: enqueue_hcmd failed: %d\n", 1029 1013 get_cmd_string(cmd->id), ret); 1030 1014 return ret; 1031 1015 } ··· 1040 1022 &trans_pcie->txq[trans->shrd->cmd_queue]; 1041 1023 struct iwl_queue *q = &txq->q; 1042 1024 1043 - IWL_ERR(trans, 1025 + IWL_DEBUG_QUIET_RFKILL(trans, 1044 1026 "Error sending %s: time out after %dms.\n", 1045 1027 get_cmd_string(cmd->id), 1046 1028 jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); 1047 1029 1048 - IWL_ERR(trans, 1030 + IWL_DEBUG_QUIET_RFKILL(trans, 1049 1031 "Current CMD queue read_ptr %d write_ptr %d\n", 1050 1032 q->read_ptr, q->write_ptr); 1051 1033 ··· 1057 1039 } 1058 1040 } 1059 1041 1060 - if (test_bit(STATUS_RF_KILL_HW, &trans->shrd->status)) { 1061 - IWL_ERR(trans, "Command %s aborted: RF KILL Switch\n", 1062 - get_cmd_string(cmd->id)); 1063 - ret = -ECANCELED; 1064 - goto fail; 1065 - } 1066 - if (test_bit(STATUS_FW_ERROR, &trans->shrd->status)) { 1067 - IWL_ERR(trans, "Command %s failed: FW Error\n", 1068 - get_cmd_string(cmd->id)); 1069 - ret = -EIO; 1070 - goto fail; 1071 - } 1072 1042 if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { 1073 1043 IWL_ERR(trans, "Error: Response NULL in '%s'\n", 1074 1044 get_cmd_string(cmd->id)); ··· 1077 1071 trans_pcie->txq[trans->shrd->cmd_queue].meta[cmd_idx].flags &= 1078 1072 ~CMD_WANT_SKB; 1079 1073 } 1080 - fail: 1074 + 1081 1075 if (cmd->reply_page) { 1082 1076 iwl_free_pages(trans->shrd, cmd->reply_page); 1083 1077 cmd->reply_page = 0;
+13 -10
drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
··· 1231 1231 txq->need_update = 1; 1232 1232 iwl_txq_update_write_ptr(trans, txq); 1233 1233 } else { 1234 - iwl_stop_queue(trans, txq); 1234 + iwl_stop_queue(trans, txq, "Queue is full"); 1235 1235 } 1236 1236 } 1237 1237 return 0; ··· 1283 1283 /* aggregated HW queue */ 1284 1284 if ((txq_id == tid_data->agg.txq_id) && 1285 1285 (q->read_ptr == q->write_ptr)) { 1286 - IWL_DEBUG_HT(trans, 1286 + IWL_DEBUG_TX_QUEUES(trans, 1287 1287 "HW queue empty: continue DELBA flow\n"); 1288 1288 iwl_trans_pcie_txq_agg_disable(trans, txq_id); 1289 1289 tid_data->agg.state = IWL_AGG_OFF; 1290 1290 iwl_stop_tx_ba_trans_ready(priv(trans), 1291 1291 NUM_IWL_RXON_CTX, 1292 1292 sta_id, tid); 1293 - iwl_wake_queue(trans, &trans_pcie->txq[txq_id]); 1293 + iwl_wake_queue(trans, &trans_pcie->txq[txq_id], 1294 + "DELBA flow complete"); 1294 1295 } 1295 1296 break; 1296 1297 case IWL_EMPTYING_HW_QUEUE_ADDBA: 1297 1298 /* We are reclaiming the last packet of the queue */ 1298 1299 if (tid_data->tfds_in_queue == 0) { 1299 - IWL_DEBUG_HT(trans, 1300 + IWL_DEBUG_TX_QUEUES(trans, 1300 1301 "HW queue empty: continue ADDBA flow\n"); 1301 1302 tid_data->agg.state = IWL_AGG_ON; 1302 1303 iwl_start_tx_ba_trans_ready(priv(trans), ··· 1355 1354 ssn , tfd_num, txq_id, txq->swq_id); 1356 1355 freed = iwl_tx_queue_reclaim(trans, txq_id, tfd_num, skbs); 1357 1356 if (iwl_queue_space(&txq->q) > txq->q.low_mark && cond) 1358 - iwl_wake_queue(trans, txq); 1357 + iwl_wake_queue(trans, txq, "Packets reclaimed"); 1359 1358 } 1360 1359 1361 1360 iwl_free_tfds_in_queue(trans, sta_id, tid, freed); ··· 1419 1418 #endif /* CONFIG_PM_SLEEP */ 1420 1419 1421 1420 static void iwl_trans_pcie_wake_any_queue(struct iwl_trans *trans, 1422 - enum iwl_rxon_context_id ctx) 1421 + enum iwl_rxon_context_id ctx, 1422 + const char *msg) 1423 1423 { 1424 1424 u8 ac, txq_id; 1425 1425 struct iwl_trans_pcie *trans_pcie = ··· 1428 1426 1429 1427 for (ac = 0; ac < AC_NUM; ac++) { 1430 1428 txq_id = trans_pcie->ac_to_queue[ctx][ac]; 1431 - IWL_DEBUG_INFO(trans, "Queue Status: Q[%d] %s\n", 1429 + IWL_DEBUG_TX_QUEUES(trans, "Queue Status: Q[%d] %s\n", 1432 1430 ac, 1433 1431 (atomic_read(&trans_pcie->queue_stop_count[ac]) > 0) 1434 1432 ? "stopped" : "awake"); 1435 - iwl_wake_queue(trans, &trans_pcie->txq[txq_id]); 1433 + iwl_wake_queue(trans, &trans_pcie->txq[txq_id], msg); 1436 1434 } 1437 1435 } 1438 1436 ··· 1455 1453 return iwl_trans; 1456 1454 } 1457 1455 1458 - static void iwl_trans_pcie_stop_queue(struct iwl_trans *trans, int txq_id) 1456 + static void iwl_trans_pcie_stop_queue(struct iwl_trans *trans, int txq_id, 1457 + const char *msg) 1459 1458 { 1460 1459 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 1461 1460 1462 - iwl_stop_queue(trans, &trans_pcie->txq[txq_id]); 1461 + iwl_stop_queue(trans, &trans_pcie->txq[txq_id], msg); 1463 1462 } 1464 1463 1465 1464 #define IWL_FLUSH_WAIT_MS 2000
+44 -6
drivers/net/wireless/iwlwifi/iwl-trans.h
··· 171 171 void (*tx_start)(struct iwl_trans *trans); 172 172 173 173 void (*wake_any_queue)(struct iwl_trans *trans, 174 - enum iwl_rxon_context_id ctx); 174 + enum iwl_rxon_context_id ctx, 175 + const char *msg); 175 176 176 177 int (*send_cmd)(struct iwl_trans *trans, struct iwl_host_cmd *cmd); 177 178 ··· 197 196 198 197 void (*free)(struct iwl_trans *trans); 199 198 200 - void (*stop_queue)(struct iwl_trans *trans, int q); 199 + void (*stop_queue)(struct iwl_trans *trans, int q, const char *msg); 201 200 202 201 int (*dbgfs_register)(struct iwl_trans *trans, struct dentry* dir); 203 202 int (*check_stuck_queue)(struct iwl_trans *trans, int q); ··· 208 207 #endif 209 208 }; 210 209 210 + /* one for each uCode image (inst/data, boot/init/runtime) */ 211 + struct fw_desc { 212 + dma_addr_t p_addr; /* hardware address */ 213 + void *v_addr; /* software address */ 214 + u32 len; /* size in bytes */ 215 + }; 216 + 217 + struct fw_img { 218 + struct fw_desc code; /* firmware code image */ 219 + struct fw_desc data; /* firmware data image */ 220 + }; 221 + 222 + enum iwl_ucode_type { 223 + IWL_UCODE_NONE, 224 + IWL_UCODE_REGULAR, 225 + IWL_UCODE_INIT, 226 + IWL_UCODE_WOWLAN, 227 + }; 228 + 211 229 /** 212 230 * struct iwl_trans - transport common data 213 231 * @ops - pointer to iwl_trans_ops 214 232 * @shrd - pointer to iwl_shared which holds shared data from the upper layer 215 233 * @hcmd_lock: protects HCMD 234 + * @ucode_write_complete: indicates that the ucode has been copied. 235 + * @ucode_rt: run time ucode image 236 + * @ucode_init: init ucode image 237 + * @ucode_wowlan: wake on wireless ucode image (optional) 216 238 */ 217 239 struct iwl_trans { 218 240 const struct iwl_trans_ops *ops; 219 241 struct iwl_shared *shrd; 220 242 spinlock_t hcmd_lock; 243 + 244 + u8 ucode_write_complete; /* the image write is complete */ 245 + struct fw_img ucode_rt; 246 + struct fw_img ucode_init; 247 + struct fw_img ucode_wowlan; 248 + 249 + /* eeprom related variables */ 250 + int nvm_device_type; 221 251 222 252 /* pointer to trans specific struct */ 223 253 /*Ensure that this pointer will always be aligned to sizeof pointer */ ··· 281 249 } 282 250 283 251 static inline void iwl_trans_wake_any_queue(struct iwl_trans *trans, 284 - enum iwl_rxon_context_id ctx) 252 + enum iwl_rxon_context_id ctx, 253 + const char *msg) 285 254 { 286 - trans->ops->wake_any_queue(trans, ctx); 255 + trans->ops->wake_any_queue(trans, ctx, msg); 287 256 } 288 257 289 258 ··· 344 311 trans->ops->free(trans); 345 312 } 346 313 347 - static inline void iwl_trans_stop_queue(struct iwl_trans *trans, int q) 314 + static inline void iwl_trans_stop_queue(struct iwl_trans *trans, int q, 315 + const char *msg) 348 316 { 349 - trans->ops->stop_queue(trans, q); 317 + trans->ops->stop_queue(trans, q, msg); 350 318 } 351 319 352 320 static inline int iwl_trans_wait_tx_queue_empty(struct iwl_trans *trans) ··· 381 347 * Transport layers implementations 382 348 ******************************************************/ 383 349 extern const struct iwl_trans_ops trans_ops_pcie; 350 + 351 + int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, 352 + const void *data, size_t len); 353 + void iwl_dealloc_ucode(struct iwl_trans *trans); 384 354 385 355 #endif /* __iwl_trans_h__ */
+13 -2
drivers/net/wireless/iwmc3200wifi/cfg80211.c
··· 165 165 struct key_params *params) 166 166 { 167 167 struct iwm_priv *iwm = ndev_to_iwm(ndev); 168 - struct iwm_key *key = &iwm->keys[key_index]; 168 + struct iwm_key *key; 169 169 int ret; 170 170 171 171 IWM_DBG_WEXT(iwm, DBG, "Adding key for %pM\n", mac_addr); 172 172 173 + if (key_index >= IWM_NUM_KEYS) 174 + return -ENOENT; 175 + 176 + key = &iwm->keys[key_index]; 173 177 memset(key, 0, sizeof(struct iwm_key)); 174 178 ret = iwm_key_init(key, key_index, mac_addr, params); 175 179 if (ret < 0) { ··· 218 214 u8 key_index, bool pairwise, const u8 *mac_addr) 219 215 { 220 216 struct iwm_priv *iwm = ndev_to_iwm(ndev); 221 - struct iwm_key *key = &iwm->keys[key_index]; 217 + struct iwm_key *key; 222 218 219 + if (key_index >= IWM_NUM_KEYS) 220 + return -ENOENT; 221 + 222 + key = &iwm->keys[key_index]; 223 223 if (!iwm->keys[key_index].key_len) { 224 224 IWM_DBG_WEXT(iwm, DBG, "Key %d not used\n", key_index); 225 225 return 0; ··· 243 235 struct iwm_priv *iwm = ndev_to_iwm(ndev); 244 236 245 237 IWM_DBG_WEXT(iwm, DBG, "Default key index is: %d\n", key_index); 238 + 239 + if (key_index >= IWM_NUM_KEYS) 240 + return -ENOENT; 246 241 247 242 if (!iwm->keys[key_index].key_len) { 248 243 IWM_ERR(iwm, "Key %d not used\n", key_index);
+15 -10
drivers/net/wireless/libertas/cfg.c
··· 485 485 static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy, 486 486 struct cmd_header *resp) 487 487 { 488 + struct cfg80211_bss *bss; 488 489 struct cmd_ds_802_11_scan_rsp *scanresp = (void *)resp; 489 490 int bsssize; 490 491 const u8 *pos; ··· 633 632 LBS_SCAN_RSSI_TO_MBM(rssi)/100); 634 633 635 634 if (channel && 636 - !(channel->flags & IEEE80211_CHAN_DISABLED)) 637 - cfg80211_inform_bss(wiphy, channel, 635 + !(channel->flags & IEEE80211_CHAN_DISABLED)) { 636 + bss = cfg80211_inform_bss(wiphy, channel, 638 637 bssid, le64_to_cpu(*(__le64 *)tsfdesc), 639 638 capa, intvl, ie, ielen, 640 639 LBS_SCAN_RSSI_TO_MBM(rssi), 641 640 GFP_KERNEL); 641 + cfg80211_put_bss(bss); 642 + } 642 643 } else 643 644 lbs_deb_scan("scan response: missing BSS channel IE\n"); 644 645 ··· 1723 1720 2 + 2 + /* atim */ 1724 1721 2 + 8]; /* extended rates */ 1725 1722 u8 *fake = fake_ie; 1723 + struct cfg80211_bss *bss; 1726 1724 1727 1725 lbs_deb_enter(LBS_DEB_CFG80211); 1728 1726 ··· 1767 1763 *fake++ = 0x6c; 1768 1764 lbs_deb_hex(LBS_DEB_CFG80211, "IE", fake_ie, fake - fake_ie); 1769 1765 1770 - cfg80211_inform_bss(priv->wdev->wiphy, 1771 - params->channel, 1772 - bssid, 1773 - 0, 1774 - capability, 1775 - params->beacon_interval, 1776 - fake_ie, fake - fake_ie, 1777 - 0, GFP_KERNEL); 1766 + bss = cfg80211_inform_bss(priv->wdev->wiphy, 1767 + params->channel, 1768 + bssid, 1769 + 0, 1770 + capability, 1771 + params->beacon_interval, 1772 + fake_ie, fake - fake_ie, 1773 + 0, GFP_KERNEL); 1774 + cfg80211_put_bss(bss); 1778 1775 1779 1776 memcpy(priv->wdev->ssid, params->ssid, params->ssid_len); 1780 1777 priv->wdev->ssid_len = params->ssid_len;
+2
drivers/net/wireless/mac80211_hwsim.c
··· 1748 1748 IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | 1749 1749 IEEE80211_HW_AMPDU_AGGREGATION; 1750 1750 1751 + hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS; 1752 + 1751 1753 /* ask mac80211 to reserve space for magic */ 1752 1754 hw->vif_data_size = sizeof(struct hwsim_vif_priv); 1753 1755 hw->sta_data_size = sizeof(struct hwsim_sta_priv);
+6 -12
drivers/net/wireless/mwifiex/11n_rxreorder.c
··· 33 33 * Since the buffer is linear, the function uses rotation to simulate 34 34 * circular buffer. 35 35 */ 36 - static int 36 + static void 37 37 mwifiex_11n_dispatch_pkt_until_start_win(struct mwifiex_private *priv, 38 38 struct mwifiex_rx_reorder_tbl 39 39 *rx_reor_tbl_ptr, int start_win) ··· 71 71 72 72 rx_reor_tbl_ptr->start_win = start_win; 73 73 spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); 74 - 75 - return 0; 76 74 } 77 75 78 76 /* ··· 81 83 * Since the buffer is linear, the function uses rotation to simulate 82 84 * circular buffer. 83 85 */ 84 - static int 86 + static void 85 87 mwifiex_11n_scan_and_dispatch(struct mwifiex_private *priv, 86 88 struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr) 87 89 { ··· 117 119 rx_reor_tbl_ptr->start_win = (rx_reor_tbl_ptr->start_win + i) 118 120 &(MAX_TID_VALUE - 1); 119 121 spin_unlock_irqrestore(&priv->rx_pkt_lock, flags); 120 - return 0; 121 122 } 122 123 123 124 /* ··· 402 405 u8 *ta, u8 pkt_type, void *payload) 403 406 { 404 407 struct mwifiex_rx_reorder_tbl *rx_reor_tbl_ptr; 405 - int start_win, end_win, win_size, ret; 408 + int start_win, end_win, win_size; 406 409 u16 pkt_index; 407 410 408 411 rx_reor_tbl_ptr = ··· 449 452 start_win = (end_win - win_size) + 1; 450 453 else 451 454 start_win = (MAX_TID_VALUE - (win_size - seq_num)) + 1; 452 - ret = mwifiex_11n_dispatch_pkt_until_start_win(priv, 455 + mwifiex_11n_dispatch_pkt_until_start_win(priv, 453 456 rx_reor_tbl_ptr, start_win); 454 - 455 - if (ret) 456 - return ret; 457 457 } 458 458 459 459 if (pkt_type != PKT_TYPE_BAR) { ··· 469 475 * Dispatch all packets sequentially from start_win until a 470 476 * hole is found and adjust the start_win appropriately 471 477 */ 472 - ret = mwifiex_11n_scan_and_dispatch(priv, rx_reor_tbl_ptr); 478 + mwifiex_11n_scan_and_dispatch(priv, rx_reor_tbl_ptr); 473 479 474 - return ret; 480 + return 0; 475 481 } 476 482 477 483 /*
+3 -1
drivers/net/wireless/mwifiex/cfg80211.c
··· 780 780 { 781 781 struct ieee80211_channel *chan; 782 782 struct mwifiex_bss_info bss_info; 783 + struct cfg80211_bss *bss; 783 784 int ie_len; 784 785 u8 ie_buf[IEEE80211_MAX_SSID_LEN + sizeof(struct ieee_types_header)]; 785 786 enum ieee80211_band band; ··· 801 800 ieee80211_channel_to_frequency(bss_info.bss_chan, 802 801 band)); 803 802 804 - cfg80211_inform_bss(priv->wdev->wiphy, chan, 803 + bss = cfg80211_inform_bss(priv->wdev->wiphy, chan, 805 804 bss_info.bssid, 0, WLAN_CAPABILITY_IBSS, 806 805 0, ie_buf, ie_len, 0, GFP_KERNEL); 806 + cfg80211_put_bss(bss); 807 807 memcpy(priv->cfg_bssid, bss_info.bssid, ETH_ALEN); 808 808 809 809 return 0;
+1 -1
drivers/net/wireless/mwifiex/fw.h
··· 673 673 union ieee_types_phy_param_set phy_param_set; 674 674 u16 reserved1; 675 675 __le16 cap_info_bitmap; 676 - u8 DataRate[HOSTCMD_SUPPORTED_RATES]; 676 + u8 data_rate[HOSTCMD_SUPPORTED_RATES]; 677 677 } __packed; 678 678 679 679 struct host_cmd_ds_802_11_ad_hoc_result {
+2 -2
drivers/net/wireless/mwifiex/init.c
··· 187 187 struct mwifiex_opt_sleep_confirm *sleep_cfm_buf = NULL; 188 188 189 189 skb_put(adapter->sleep_cfm, sizeof(struct mwifiex_opt_sleep_confirm)); 190 - sleep_cfm_buf = (struct mwifiex_opt_sleep_confirm *) 191 - (adapter->sleep_cfm->data); 192 190 193 191 adapter->cmd_sent = false; 194 192 ··· 252 254 mwifiex_wmm_init(adapter); 253 255 254 256 if (adapter->sleep_cfm) { 257 + sleep_cfm_buf = (struct mwifiex_opt_sleep_confirm *) 258 + adapter->sleep_cfm->data; 255 259 memset(sleep_cfm_buf, 0, adapter->sleep_cfm->len); 256 260 sleep_cfm_buf->command = 257 261 cpu_to_le16(HostCmd_CMD_802_11_PS_MODE_ENH);
+39 -55
drivers/net/wireless/mwifiex/join.c
··· 724 724 u32 cmd_append_size = 0; 725 725 u32 i; 726 726 u16 tmp_cap; 727 - uint16_t ht_cap_info; 728 727 struct mwifiex_ie_types_chan_list_param_set *chan_tlv; 728 + u8 radio_type; 729 729 730 730 struct mwifiex_ie_types_htcap *ht_cap; 731 731 struct mwifiex_ie_types_htinfo *ht_info; ··· 837 837 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL; 838 838 } 839 839 840 - memset(adhoc_start->DataRate, 0, sizeof(adhoc_start->DataRate)); 841 - mwifiex_get_active_data_rates(priv, adhoc_start->DataRate); 840 + memset(adhoc_start->data_rate, 0, sizeof(adhoc_start->data_rate)); 841 + mwifiex_get_active_data_rates(priv, adhoc_start->data_rate); 842 842 if ((adapter->adhoc_start_band & BAND_G) && 843 843 (priv->curr_pkt_filter & HostCmd_ACT_MAC_ADHOC_G_PROTECTION_ON)) { 844 844 if (mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL, ··· 850 850 } 851 851 } 852 852 /* Find the last non zero */ 853 - for (i = 0; i < sizeof(adhoc_start->DataRate) && 854 - adhoc_start->DataRate[i]; 855 - i++) 856 - ; 853 + for (i = 0; i < sizeof(adhoc_start->data_rate); i++) 854 + if (!adhoc_start->data_rate[i]) 855 + break; 857 856 858 857 priv->curr_bss_params.num_of_rates = i; 859 858 860 859 /* Copy the ad-hoc creating rates into Current BSS rate structure */ 861 860 memcpy(&priv->curr_bss_params.data_rates, 862 - &adhoc_start->DataRate, priv->curr_bss_params.num_of_rates); 861 + &adhoc_start->data_rate, priv->curr_bss_params.num_of_rates); 863 862 864 863 dev_dbg(adapter->dev, "info: ADHOC_S_CMD: rates=%02x %02x %02x %02x\n", 865 - adhoc_start->DataRate[0], adhoc_start->DataRate[1], 866 - adhoc_start->DataRate[2], adhoc_start->DataRate[3]); 864 + adhoc_start->data_rate[0], adhoc_start->data_rate[1], 865 + adhoc_start->data_rate[2], adhoc_start->data_rate[3]); 867 866 868 867 dev_dbg(adapter->dev, "info: ADHOC_S_CMD: AD-HOC Start command is ready\n"); 869 868 ··· 913 914 } 914 915 915 916 if (adapter->adhoc_11n_enabled) { 916 - { 917 - ht_cap = (struct mwifiex_ie_types_htcap *) pos; 918 - memset(ht_cap, 0, 919 - sizeof(struct mwifiex_ie_types_htcap)); 920 - ht_cap->header.type = 921 - cpu_to_le16(WLAN_EID_HT_CAPABILITY); 922 - ht_cap->header.len = 923 - cpu_to_le16(sizeof(struct ieee80211_ht_cap)); 924 - ht_cap_info = le16_to_cpu(ht_cap->ht_cap.cap_info); 917 + /* Fill HT CAPABILITY */ 918 + ht_cap = (struct mwifiex_ie_types_htcap *) pos; 919 + memset(ht_cap, 0, sizeof(struct mwifiex_ie_types_htcap)); 920 + ht_cap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY); 921 + ht_cap->header.len = 922 + cpu_to_le16(sizeof(struct ieee80211_ht_cap)); 923 + radio_type = mwifiex_band_to_radio_type( 924 + priv->adapter->config_bands); 925 + mwifiex_fill_cap_info(priv, radio_type, ht_cap); 925 926 926 - ht_cap_info |= IEEE80211_HT_CAP_SGI_20; 927 - if (adapter->chan_offset) { 928 - ht_cap_info |= IEEE80211_HT_CAP_SGI_40; 929 - ht_cap_info |= IEEE80211_HT_CAP_DSSSCCK40; 930 - ht_cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; 931 - SETHT_MCS32(ht_cap->ht_cap.mcs.rx_mask); 932 - } 927 + pos += sizeof(struct mwifiex_ie_types_htcap); 928 + cmd_append_size += 929 + sizeof(struct mwifiex_ie_types_htcap); 933 930 934 - ht_cap->ht_cap.ampdu_params_info 935 - = IEEE80211_HT_MAX_AMPDU_64K; 936 - ht_cap->ht_cap.mcs.rx_mask[0] = 0xff; 937 - pos += sizeof(struct mwifiex_ie_types_htcap); 938 - cmd_append_size += 939 - sizeof(struct mwifiex_ie_types_htcap); 940 - } 941 - { 942 - ht_info = (struct mwifiex_ie_types_htinfo *) pos; 943 - memset(ht_info, 0, 944 - sizeof(struct mwifiex_ie_types_htinfo)); 945 - ht_info->header.type = 946 - cpu_to_le16(WLAN_EID_HT_INFORMATION); 947 - ht_info->header.len = 948 - cpu_to_le16(sizeof(struct ieee80211_ht_info)); 949 - ht_info->ht_info.control_chan = 950 - (u8) priv->curr_bss_params.bss_descriptor. 951 - channel; 952 - if (adapter->chan_offset) { 953 - ht_info->ht_info.ht_param = 954 - adapter->chan_offset; 955 - ht_info->ht_info.ht_param |= 931 + /* Fill HT INFORMATION */ 932 + ht_info = (struct mwifiex_ie_types_htinfo *) pos; 933 + memset(ht_info, 0, sizeof(struct mwifiex_ie_types_htinfo)); 934 + ht_info->header.type = cpu_to_le16(WLAN_EID_HT_INFORMATION); 935 + ht_info->header.len = 936 + cpu_to_le16(sizeof(struct ieee80211_ht_info)); 937 + 938 + ht_info->ht_info.control_chan = 939 + (u8) priv->curr_bss_params.bss_descriptor.channel; 940 + if (adapter->chan_offset) { 941 + ht_info->ht_info.ht_param = adapter->chan_offset; 942 + ht_info->ht_info.ht_param |= 956 943 IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; 957 - } 958 - ht_info->ht_info.operation_mode = 959 - cpu_to_le16(IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); 960 - ht_info->ht_info.basic_set[0] = 0xff; 961 - pos += sizeof(struct mwifiex_ie_types_htinfo); 962 - cmd_append_size += 963 - sizeof(struct mwifiex_ie_types_htinfo); 964 944 } 945 + ht_info->ht_info.operation_mode = 946 + cpu_to_le16(IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); 947 + ht_info->ht_info.basic_set[0] = 0xff; 948 + pos += sizeof(struct mwifiex_ie_types_htinfo); 949 + cmd_append_size += 950 + sizeof(struct mwifiex_ie_types_htinfo); 965 951 } 966 952 967 953 cmd->size = cpu_to_le16((u16)
+6 -5
drivers/net/wireless/mwifiex/pcie.c
··· 386 386 card->txbd_ring_vbase = kzalloc(card->txbd_ring_size, GFP_KERNEL); 387 387 if (!card->txbd_ring_vbase) { 388 388 dev_err(adapter->dev, "Unable to allocate buffer for txbd ring.\n"); 389 - kfree(card->txbd_ring_vbase); 390 389 return -1; 391 390 } 392 391 card->txbd_ring_pbase = virt_to_phys(card->txbd_ring_vbase); ··· 1228 1229 if (!skb) 1229 1230 return 0; 1230 1231 1231 - if (rdptr >= MWIFIEX_MAX_EVT_BD) 1232 + if (rdptr >= MWIFIEX_MAX_EVT_BD) { 1232 1233 dev_err(adapter->dev, "event_complete: Invalid rdptr 0x%x\n", 1233 1234 rdptr); 1235 + ret = -EINVAL; 1236 + goto done; 1237 + } 1234 1238 1235 1239 /* Read the event ring write pointer set by firmware */ 1236 1240 if (mwifiex_read_reg(adapter, REG_EVTBD_WRPTR, &wrptr)) { ··· 1674 1672 struct sk_buff *skb, 1675 1673 struct mwifiex_tx_param *tx_param) 1676 1674 { 1677 - if (!adapter || !skb) { 1678 - dev_err(adapter->dev, "Invalid parameter in %s <%p, %p>\n", 1679 - __func__, adapter, skb); 1675 + if (!skb) { 1676 + dev_err(adapter->dev, "Passed NULL skb to %s\n", __func__); 1680 1677 return -1; 1681 1678 } 1682 1679
+3 -7
drivers/net/wireless/mwifiex/scan.c
··· 1469 1469 s32 rssi, const u8 *ie_buf, size_t ie_len, 1470 1470 u16 beacon_period, u16 cap_info_bitmap, u8 band) 1471 1471 { 1472 - struct mwifiex_bssdescriptor *bss_desc = NULL; 1472 + struct mwifiex_bssdescriptor *bss_desc; 1473 1473 int ret; 1474 1474 unsigned long flags; 1475 1475 u8 *beacon_ie; ··· 1484 1484 1485 1485 beacon_ie = kmemdup(ie_buf, ie_len, GFP_KERNEL); 1486 1486 if (!beacon_ie) { 1487 + kfree(bss_desc); 1487 1488 dev_err(priv->adapter->dev, " failed to alloc beacon_ie\n"); 1488 1489 return -ENOMEM; 1489 1490 } ··· 1533 1532 kfree(bss_desc); 1534 1533 kfree(beacon_ie); 1535 1534 return 0; 1536 - } 1537 - 1538 - static void mwifiex_free_bss_priv(struct cfg80211_bss *bss) 1539 - { 1540 - kfree(bss->priv); 1541 1535 } 1542 1536 1543 1537 /* ··· 1760 1764 cap_info_bitmap, beacon_period, 1761 1765 ie_buf, ie_len, rssi, GFP_KERNEL); 1762 1766 *(u8 *)bss->priv = band; 1763 - bss->free_priv = mwifiex_free_bss_priv; 1767 + cfg80211_put_bss(bss); 1764 1768 1765 1769 if (priv->media_connected && !memcmp(bssid, 1766 1770 priv->curr_bss_params.bss_descriptor
+2 -2
drivers/net/wireless/mwifiex/sdio.c
··· 1630 1630 card->mpa_tx.pkt_cnt = 0; 1631 1631 card->mpa_tx.start_port = 0; 1632 1632 1633 - card->mpa_tx.enabled = 0; 1633 + card->mpa_tx.enabled = 1; 1634 1634 card->mpa_tx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT; 1635 1635 1636 1636 card->mpa_rx.buf_len = 0; 1637 1637 card->mpa_rx.pkt_cnt = 0; 1638 1638 card->mpa_rx.start_port = 0; 1639 1639 1640 - card->mpa_rx.enabled = 0; 1640 + card->mpa_rx.enabled = 1; 1641 1641 card->mpa_rx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT; 1642 1642 1643 1643 /* Allocate buffers for SDIO MP-A */
+7 -5
drivers/net/wireless/mwifiex/sta_rx.c
··· 126 126 u16 rx_pkt_type; 127 127 struct mwifiex_private *priv = adapter->priv[rx_info->bss_index]; 128 128 129 + if (!priv) 130 + return -1; 131 + 129 132 local_rx_pd = (struct rxpd *) (skb->data); 130 133 rx_pkt_type = local_rx_pd->rx_pkt_type; 131 134 ··· 192 189 (u8) local_rx_pd->rx_pkt_type, 193 190 skb); 194 191 195 - if (ret || (rx_pkt_type == PKT_TYPE_BAR)) { 196 - if (priv && (ret == -1)) 197 - priv->stats.rx_dropped++; 198 - 192 + if (ret || (rx_pkt_type == PKT_TYPE_BAR)) 199 193 dev_kfree_skb_any(skb); 200 - } 194 + 195 + if (ret) 196 + priv->stats.rx_dropped++; 201 197 202 198 return ret; 203 199 }
+10 -6
drivers/net/wireless/orinoco/scan.c
··· 76 76 { 77 77 struct wiphy *wiphy = priv_to_wiphy(priv); 78 78 struct ieee80211_channel *channel; 79 + struct cfg80211_bss *cbss; 79 80 u8 *ie; 80 81 u8 ie_buf[46]; 81 82 u64 timestamp; ··· 122 121 beacon_interval = le16_to_cpu(bss->a.beacon_interv); 123 122 signal = SIGNAL_TO_MBM(le16_to_cpu(bss->a.level)); 124 123 125 - cfg80211_inform_bss(wiphy, channel, bss->a.bssid, timestamp, 126 - capability, beacon_interval, ie_buf, ie_len, 127 - signal, GFP_KERNEL); 124 + cbss = cfg80211_inform_bss(wiphy, channel, bss->a.bssid, timestamp, 125 + capability, beacon_interval, ie_buf, ie_len, 126 + signal, GFP_KERNEL); 127 + cfg80211_put_bss(cbss); 128 128 } 129 129 130 130 void orinoco_add_extscan_result(struct orinoco_private *priv, ··· 134 132 { 135 133 struct wiphy *wiphy = priv_to_wiphy(priv); 136 134 struct ieee80211_channel *channel; 135 + struct cfg80211_bss *cbss; 137 136 const u8 *ie; 138 137 u64 timestamp; 139 138 s32 signal; ··· 155 152 ie = bss->data; 156 153 signal = SIGNAL_TO_MBM(bss->level); 157 154 158 - cfg80211_inform_bss(wiphy, channel, bss->bssid, timestamp, 159 - capability, beacon_interval, ie, ie_len, 160 - signal, GFP_KERNEL); 155 + cbss = cfg80211_inform_bss(wiphy, channel, bss->bssid, timestamp, 156 + capability, beacon_interval, ie, ie_len, 157 + signal, GFP_KERNEL); 158 + cfg80211_put_bss(cbss); 161 159 } 162 160 163 161 void orinoco_add_hostscan_results(struct orinoco_private *priv,
+18 -5
drivers/net/wireless/rndis_wlan.c
··· 414 414 #define RNDIS_WLAN_ALG_TKIP (1<<1) 415 415 #define RNDIS_WLAN_ALG_CCMP (1<<2) 416 416 417 + #define RNDIS_WLAN_NUM_KEYS 4 417 418 #define RNDIS_WLAN_KEY_MGMT_NONE 0 418 419 #define RNDIS_WLAN_KEY_MGMT_802_1X (1<<0) 419 420 #define RNDIS_WLAN_KEY_MGMT_PSK (1<<1) ··· 517 516 518 517 /* encryption stuff */ 519 518 int encr_tx_key_index; 520 - struct rndis_wlan_encr_key encr_keys[4]; 519 + struct rndis_wlan_encr_key encr_keys[RNDIS_WLAN_NUM_KEYS]; 521 520 int wpa_version; 522 521 523 522 u8 command_buffer[COMMAND_BUFFER_SIZE]; ··· 1536 1535 bool is_wpa; 1537 1536 int ret; 1538 1537 1538 + if (index >= RNDIS_WLAN_NUM_KEYS) 1539 + return -ENOENT; 1540 + 1539 1541 if (priv->encr_keys[index].len == 0) 1540 1542 return 0; 1541 1543 ··· 1976 1972 return ret; 1977 1973 } 1978 1974 1979 - static struct cfg80211_bss *rndis_bss_info_update(struct usbnet *usbdev, 1980 - struct ndis_80211_bssid_ex *bssid) 1975 + static bool rndis_bss_info_update(struct usbnet *usbdev, 1976 + struct ndis_80211_bssid_ex *bssid) 1981 1977 { 1982 1978 struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); 1983 1979 struct ieee80211_channel *channel; 1980 + struct cfg80211_bss *bss; 1984 1981 s32 signal; 1985 1982 u64 timestamp; 1986 1983 u16 capability; ··· 2020 2015 capability = le16_to_cpu(fixed->capabilities); 2021 2016 beacon_interval = le16_to_cpu(fixed->beacon_interval); 2022 2017 2023 - return cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid->mac, 2018 + bss = cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid->mac, 2024 2019 timestamp, capability, beacon_interval, ie, ie_len, signal, 2025 2020 GFP_KERNEL); 2021 + cfg80211_put_bss(bss); 2022 + 2023 + return (bss != NULL); 2026 2024 } 2027 2025 2028 2026 static struct ndis_80211_bssid_ex *next_bssid_list_item( ··· 2459 2451 2460 2452 netdev_dbg(usbdev->net, "%s(%i)\n", __func__, key_index); 2461 2453 2454 + if (key_index >= RNDIS_WLAN_NUM_KEYS) 2455 + return -ENOENT; 2456 + 2462 2457 priv->encr_tx_key_index = key_index; 2463 2458 2464 2459 if (is_wpa_key(priv, key_index)) ··· 2652 2641 struct ieee80211_channel *channel; 2653 2642 struct ndis_80211_conf config; 2654 2643 struct ndis_80211_ssid ssid; 2644 + struct cfg80211_bss *bss; 2655 2645 s32 signal; 2656 2646 u64 timestamp; 2657 2647 u16 capability; ··· 2726 2714 bssid, (u32)timestamp, capability, beacon_interval, ie_len, 2727 2715 ssid.essid, signal); 2728 2716 2729 - cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid, 2717 + bss = cfg80211_inform_bss(priv->wdev.wiphy, channel, bssid, 2730 2718 timestamp, capability, beacon_interval, ie_buf, ie_len, 2731 2719 signal, GFP_KERNEL); 2720 + cfg80211_put_bss(bss); 2732 2721 } 2733 2722 2734 2723 /*
+32 -4
drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
··· 275 275 {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8191, rtl92cu_hal_cfg)}, 276 276 277 277 /****** 8188CU ********/ 278 + /* RTL8188CTV */ 279 + {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x018a, rtl92cu_hal_cfg)}, 278 280 /* 8188CE-VAU USB minCard */ 279 281 {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8170, rtl92cu_hal_cfg)}, 280 282 /* 8188cu 1*1 dongle */ ··· 293 291 {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817e, rtl92cu_hal_cfg)}, 294 292 /* 8188RU in Alfa AWUS036NHR */ 295 293 {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817f, rtl92cu_hal_cfg)}, 294 + /* RTL8188CUS-VL */ 295 + {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x818a, rtl92cu_hal_cfg)}, 296 296 /* 8188 Combo for BC4 */ 297 297 {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8754, rtl92cu_hal_cfg)}, 298 298 299 299 /****** 8192CU ********/ 300 - /* 8191cu 1*2 */ 301 - {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8177, rtl92cu_hal_cfg)}, 302 300 /* 8192cu 2*2 */ 303 - {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817b, rtl92cu_hal_cfg)}, 301 + {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8178, rtl92cu_hal_cfg)}, 304 302 /* 8192CE-VAU USB minCard */ 305 303 {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x817c, rtl92cu_hal_cfg)}, 306 304 ··· 311 309 {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/ 312 310 {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/ 313 311 {RTL_USB_DEVICE(0x0846, 0x9041, rtl92cu_hal_cfg)}, /*NetGear WNA1000M*/ 314 - {RTL_USB_DEVICE(0x0Df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ 312 + {RTL_USB_DEVICE(0x0df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ 313 + {RTL_USB_DEVICE(0x0df6, 0x005c, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ 315 314 {RTL_USB_DEVICE(0x0eb0, 0x9071, rtl92cu_hal_cfg)}, /*NO Brand - Etop*/ 316 315 /* HP - Lite-On ,8188CUS Slim Combo */ 317 316 {RTL_USB_DEVICE(0x103c, 0x1629, rtl92cu_hal_cfg)}, 318 317 {RTL_USB_DEVICE(0x13d3, 0x3357, rtl92cu_hal_cfg)}, /* AzureWave */ 319 318 {RTL_USB_DEVICE(0x2001, 0x3308, rtl92cu_hal_cfg)}, /*D-Link - Alpha*/ 319 + {RTL_USB_DEVICE(0x2019, 0x4902, rtl92cu_hal_cfg)}, /*Planex - Etop*/ 320 320 {RTL_USB_DEVICE(0x2019, 0xab2a, rtl92cu_hal_cfg)}, /*Planex - Abocom*/ 321 + /*SW-WF02-AD15 -Abocom*/ 322 + {RTL_USB_DEVICE(0x2019, 0xab2e, rtl92cu_hal_cfg)}, 321 323 {RTL_USB_DEVICE(0x2019, 0xed17, rtl92cu_hal_cfg)}, /*PCI - Edimax*/ 322 324 {RTL_USB_DEVICE(0x20f4, 0x648b, rtl92cu_hal_cfg)}, /*TRENDnet - Cameo*/ 323 325 {RTL_USB_DEVICE(0x7392, 0x7811, rtl92cu_hal_cfg)}, /*Edimax - Edimax*/ ··· 332 326 {RTL_USB_DEVICE(0x4855, 0x0091, rtl92cu_hal_cfg)}, /* NetweeN-Feixun */ 333 327 {RTL_USB_DEVICE(0x9846, 0x9041, rtl92cu_hal_cfg)}, /* Netgear Cameo */ 334 328 329 + /****** 8188 RU ********/ 330 + /* Netcore */ 331 + {RTL_USB_DEVICE(USB_VENDER_ID_REALTEK, 0x317f, rtl92cu_hal_cfg)}, 332 + 333 + /****** 8188CUS Slim Solo********/ 334 + {RTL_USB_DEVICE(0x04f2, 0xaff7, rtl92cu_hal_cfg)}, /*Xavi*/ 335 + {RTL_USB_DEVICE(0x04f2, 0xaff9, rtl92cu_hal_cfg)}, /*Xavi*/ 336 + {RTL_USB_DEVICE(0x04f2, 0xaffa, rtl92cu_hal_cfg)}, /*Xavi*/ 337 + 338 + /****** 8188CUS Slim Combo ********/ 339 + {RTL_USB_DEVICE(0x04f2, 0xaff8, rtl92cu_hal_cfg)}, /*Xavi*/ 340 + {RTL_USB_DEVICE(0x04f2, 0xaffb, rtl92cu_hal_cfg)}, /*Xavi*/ 341 + {RTL_USB_DEVICE(0x04f2, 0xaffc, rtl92cu_hal_cfg)}, /*Xavi*/ 342 + {RTL_USB_DEVICE(0x2019, 0x1201, rtl92cu_hal_cfg)}, /*Planex-Vencer*/ 343 + 335 344 /****** 8192CU ********/ 345 + {RTL_USB_DEVICE(0x050d, 0x2102, rtl92cu_hal_cfg)}, /*Belcom-Sercomm*/ 346 + {RTL_USB_DEVICE(0x050d, 0x2103, rtl92cu_hal_cfg)}, /*Belcom-Edimax*/ 336 347 {RTL_USB_DEVICE(0x0586, 0x341f, rtl92cu_hal_cfg)}, /*Zyxel -Abocom*/ 337 348 {RTL_USB_DEVICE(0x07aa, 0x0056, rtl92cu_hal_cfg)}, /*ATKK-Gemtek*/ 338 349 {RTL_USB_DEVICE(0x07b8, 0x8178, rtl92cu_hal_cfg)}, /*Funai -Abocom*/ 350 + {RTL_USB_DEVICE(0x0846, 0x9021, rtl92cu_hal_cfg)}, /*Netgear-Sercomm*/ 351 + {RTL_USB_DEVICE(0x0b05, 0x17ab, rtl92cu_hal_cfg)}, /*ASUS-Edimax*/ 352 + {RTL_USB_DEVICE(0x0df6, 0x0061, rtl92cu_hal_cfg)}, /*Sitecom-Edimax*/ 353 + {RTL_USB_DEVICE(0x0e66, 0x0019, rtl92cu_hal_cfg)}, /*Hawking-Edimax*/ 339 354 {RTL_USB_DEVICE(0x2001, 0x3307, rtl92cu_hal_cfg)}, /*D-Link-Cameo*/ 340 355 {RTL_USB_DEVICE(0x2001, 0x3309, rtl92cu_hal_cfg)}, /*D-Link-Alpha*/ 341 356 {RTL_USB_DEVICE(0x2001, 0x330a, rtl92cu_hal_cfg)}, /*D-Link-Alpha*/ 342 357 {RTL_USB_DEVICE(0x2019, 0xab2b, rtl92cu_hal_cfg)}, /*Planex -Abocom*/ 358 + {RTL_USB_DEVICE(0x20f4, 0x624d, rtl92cu_hal_cfg)}, /*TRENDNet*/ 343 359 {RTL_USB_DEVICE(0x7392, 0x7822, rtl92cu_hal_cfg)}, /*Edimax -Edimax*/ 344 360 {} 345 361 };
+1 -1
drivers/net/wireless/wl12xx/scan.c
··· 559 559 break; 560 560 } 561 561 /* Fail if SSID isn't present in the filters */ 562 - if (j == req->n_ssids) { 562 + if (j == cmd->n_ssids) { 563 563 ret = -EINVAL; 564 564 goto out_free; 565 565 }
+3
include/asm-generic/socket.h
··· 64 64 #define SO_DOMAIN 39 65 65 66 66 #define SO_RXQ_OVFL 40 67 + 68 + #define SO_WIFI_STATUS 41 69 + #define SCM_WIFI_STATUS SO_WIFI_STATUS 67 70 #endif /* __ASM_GENERIC_SOCKET_H */
+2 -1
include/linux/errqueue.h
··· 17 17 #define SO_EE_ORIGIN_LOCAL 1 18 18 #define SO_EE_ORIGIN_ICMP 2 19 19 #define SO_EE_ORIGIN_ICMP6 3 20 - #define SO_EE_ORIGIN_TIMESTAMPING 4 20 + #define SO_EE_ORIGIN_TXSTATUS 4 21 + #define SO_EE_ORIGIN_TIMESTAMPING SO_EE_ORIGIN_TXSTATUS 21 22 22 23 #define SO_EE_OFFENDER(ee) ((struct sockaddr*)((ee)+1)) 23 24
+6
include/linux/ieee80211.h
··· 128 128 #define IEEE80211_QOS_CTL_ACK_POLICY_NOACK 0x0020 129 129 #define IEEE80211_QOS_CTL_ACK_POLICY_NO_EXPL 0x0040 130 130 #define IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK 0x0060 131 + #define IEEE80211_QOS_CTL_ACK_POLICY_MASK 0x0060 131 132 /* A-MSDU 802.11n */ 132 133 #define IEEE80211_QOS_CTL_A_MSDU_PRESENT 0x0080 133 134 /* Mesh Control 802.11s */ ··· 770 769 } __attribute__ ((packed)) action; 771 770 } u; 772 771 } __attribute__ ((packed)); 772 + 773 + /* Supported Rates value encodings in 802.11n-2009 7.3.2.2 */ 774 + #define BSS_MEMBERSHIP_SELECTOR_HT_PHY 127 773 775 774 776 /* mgmt header + 1 byte category code */ 775 777 #define IEEE80211_MIN_ACTION_SIZE offsetof(struct ieee80211_mgmt, u.action.u) ··· 1555 1551 #define WLAN_CIPHER_SUITE_CCMP 0x000FAC04 1556 1552 #define WLAN_CIPHER_SUITE_WEP104 0x000FAC05 1557 1553 #define WLAN_CIPHER_SUITE_AES_CMAC 0x000FAC06 1554 + 1555 + #define WLAN_CIPHER_SUITE_SMS4 0x00147201 1558 1556 1559 1557 /* AKM suite selectors */ 1560 1558 #define WLAN_AKM_SUITE_8021X 0x000FAC01
+111
include/linux/nl80211.h
··· 509 509 * @NL80211_CMD_TDLS_OPER: Perform a high-level TDLS command (e.g. link setup). 510 510 * @NL80211_CMD_TDLS_MGMT: Send a TDLS management frame. 511 511 * 512 + * @NL80211_CMD_UNEXPECTED_FRAME: Used by an application controlling an AP 513 + * (or GO) interface (i.e. hostapd) to ask for unexpected frames to 514 + * implement sending deauth to stations that send unexpected class 3 515 + * frames. Also used as the event sent by the kernel when such a frame 516 + * is received. 517 + * For the event, the %NL80211_ATTR_MAC attribute carries the TA and 518 + * other attributes like the interface index are present. 519 + * If used as the command it must have an interface index and you can 520 + * only unsubscribe from the event by closing the socket. Subscription 521 + * is also for %NL80211_CMD_UNEXPECTED_4ADDR_FRAME events. 522 + * 523 + * @NL80211_CMD_UNEXPECTED_4ADDR_FRAME: Sent as an event indicating that the 524 + * associated station identified by %NL80211_ATTR_MAC sent a 4addr frame 525 + * and wasn't already in a 4-addr VLAN. The event will be sent similarly 526 + * to the %NL80211_CMD_UNEXPECTED_FRAME event, to the same listener. 527 + * 528 + * @NL80211_CMD_PROBE_CLIENT: Probe an associated station on an AP interface 529 + * by sending a null data frame to it and reporting when the frame is 530 + * acknowleged. This is used to allow timing out inactive clients. Uses 531 + * %NL80211_ATTR_IFINDEX and %NL80211_ATTR_MAC. The command returns a 532 + * direct reply with an %NL80211_ATTR_COOKIE that is later used to match 533 + * up the event with the request. The event includes the same data and 534 + * has %NL80211_ATTR_ACK set if the frame was ACKed. 535 + * 536 + * @NL80211_CMD_REGISTER_BEACONS: Register this socket to receive beacons from 537 + * other BSSes when any interfaces are in AP mode. This helps implement 538 + * OLBC handling in hostapd. Beacons are reported in %NL80211_CMD_FRAME 539 + * messages. Note that per PHY only one application may register. 540 + * 512 541 * @NL80211_CMD_MAX: highest used command number 513 542 * @__NL80211_CMD_AFTER_LAST: internal use 514 543 */ ··· 667 638 NL80211_CMD_TDLS_OPER, 668 639 NL80211_CMD_TDLS_MGMT, 669 640 641 + NL80211_CMD_UNEXPECTED_FRAME, 642 + 643 + NL80211_CMD_PROBE_CLIENT, 644 + 645 + NL80211_CMD_REGISTER_BEACONS, 646 + 647 + NL80211_CMD_UNEXPECTED_4ADDR_FRAME, 648 + 670 649 /* add new commands above here */ 671 650 672 651 /* used to define NL80211_CMD_MAX below */ ··· 694 657 #define NL80211_CMD_DEAUTHENTICATE NL80211_CMD_DEAUTHENTICATE 695 658 #define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE 696 659 #define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT 660 + 661 + #define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS 697 662 698 663 /* source-level API compatibility */ 699 664 #define NL80211_CMD_GET_MESH_PARAMS NL80211_CMD_GET_MESH_CONFIG ··· 1148 1109 * %NL80211_CMD_TDLS_MGMT. Otherwise %NL80211_CMD_TDLS_OPER should be 1149 1110 * used for asking the driver to perform a TDLS operation. 1150 1111 * 1112 + * @NL80211_ATTR_DEVICE_AP_SME: This u32 attribute may be listed for devices 1113 + * that have AP support to indicate that they have the AP SME integrated 1114 + * with support for the features listed in this attribute, see 1115 + * &enum nl80211_ap_sme_features. 1116 + * 1117 + * @NL80211_ATTR_DONT_WAIT_FOR_ACK: Used with %NL80211_CMD_FRAME, this tells 1118 + * the driver to not wait for an acknowledgement. Note that due to this, 1119 + * it will also not give a status callback nor return a cookie. This is 1120 + * mostly useful for probe responses to save airtime. 1121 + * 1122 + * @NL80211_ATTR_FEATURE_FLAGS: This u32 attribute contains flags from 1123 + * &enum nl80211_feature_flags and is advertised in wiphy information. 1124 + * @NL80211_ATTR_PROBE_RESP_OFFLOAD: Indicates that the HW responds to probe 1125 + * 1126 + * requests while operating in AP-mode. 1127 + * This attribute holds a bitmap of the supported protocols for 1128 + * offloading (see &enum nl80211_probe_resp_offload_support_attr). 1129 + * 1130 + * @NL80211_ATTR_PROBE_RESP: Probe Response template data. Contains the entire 1131 + * probe-response frame. The DA field in the 802.11 header is zero-ed out, 1132 + * to be filled by the FW. 1133 + * 1151 1134 * @NL80211_ATTR_MAX: highest attribute number currently defined 1152 1135 * @__NL80211_ATTR_AFTER_LAST: internal use 1153 1136 */ ··· 1398 1337 NL80211_ATTR_TDLS_SUPPORT, 1399 1338 NL80211_ATTR_TDLS_EXTERNAL_SETUP, 1400 1339 1340 + NL80211_ATTR_DEVICE_AP_SME, 1341 + 1342 + NL80211_ATTR_DONT_WAIT_FOR_ACK, 1343 + 1344 + NL80211_ATTR_FEATURE_FLAGS, 1345 + 1346 + NL80211_ATTR_PROBE_RESP_OFFLOAD, 1347 + 1348 + NL80211_ATTR_PROBE_RESP, 1349 + 1401 1350 /* add attributes here, update the policy in nl80211.c */ 1402 1351 1403 1352 __NL80211_ATTR_AFTER_LAST, ··· 1442 1371 #define NL80211_ATTR_AKM_SUITES NL80211_ATTR_AKM_SUITES 1443 1372 #define NL80211_ATTR_KEY NL80211_ATTR_KEY 1444 1373 #define NL80211_ATTR_KEYS NL80211_ATTR_KEYS 1374 + #define NL80211_ATTR_FEATURE_FLAGS NL80211_ATTR_FEATURE_FLAGS 1445 1375 1446 1376 #define NL80211_MAX_SUPP_RATES 32 1447 1377 #define NL80211_MAX_SUPP_REG_RULES 32 ··· 2720 2648 NL80211_TDLS_TEARDOWN, 2721 2649 NL80211_TDLS_ENABLE_LINK, 2722 2650 NL80211_TDLS_DISABLE_LINK, 2651 + }; 2652 + 2653 + /* 2654 + * enum nl80211_ap_sme_features - device-integrated AP features 2655 + * Reserved for future use, no bits are defined in 2656 + * NL80211_ATTR_DEVICE_AP_SME yet. 2657 + enum nl80211_ap_sme_features { 2658 + }; 2659 + */ 2660 + 2661 + /** 2662 + * enum nl80211_feature_flags - device/driver features 2663 + * @NL80211_FEATURE_SK_TX_STATUS: This driver supports reflecting back 2664 + * TX status to the socket error queue when requested with the 2665 + * socket option. 2666 + */ 2667 + enum nl80211_feature_flags { 2668 + NL80211_FEATURE_SK_TX_STATUS = 1 << 0, 2669 + }; 2670 + 2671 + /** 2672 + * enum nl80211_probe_resp_offload_support_attr - optional supported 2673 + * protocols for probe-response offloading by the driver/FW. 2674 + * To be used with the %NL80211_ATTR_PROBE_RESP_OFFLOAD attribute. 2675 + * Each enum value represents a bit in the bitmap of supported 2676 + * protocols. Typically a subset of probe-requests belonging to a 2677 + * supported protocol will be excluded from offload and uploaded 2678 + * to the host. 2679 + * 2680 + * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS: Support for WPS ver. 1 2681 + * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2: Support for WPS ver. 2 2682 + * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P: Support for P2P 2683 + * @NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U: Support for 802.11u 2684 + */ 2685 + enum nl80211_probe_resp_offload_support_attr { 2686 + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS = 1<<0, 2687 + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 = 1<<1, 2688 + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P = 1<<2, 2689 + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U = 1<<3, 2723 2690 }; 2724 2691 2725 2692 #endif /* __LINUX_NL80211_H */
+17 -2
include/linux/skbuff.h
··· 218 218 219 219 /* device driver supports TX zero-copy buffers */ 220 220 SKBTX_DEV_ZEROCOPY = 1 << 4, 221 + 222 + /* generate wifi status information (where possible) */ 223 + SKBTX_WIFI_STATUS = 1 << 5, 221 224 }; 222 225 223 226 /* ··· 355 352 * @ooo_okay: allow the mapping of a socket to a queue to be changed 356 353 * @l4_rxhash: indicate rxhash is a canonical 4-tuple hash over transport 357 354 * ports. 355 + * @wifi_acked_valid: wifi_acked was set 356 + * @wifi_acked: whether frame was acked on wifi or not 358 357 * @dma_cookie: a cookie to one of several possible DMA operations 359 358 * done by skb DMA functions 360 359 * @secmark: security marking ··· 450 445 #endif 451 446 __u8 ooo_okay:1; 452 447 __u8 l4_rxhash:1; 448 + __u8 wifi_acked_valid:1; 449 + __u8 wifi_acked:1; 450 + /* 10/12 bit hole (depending on ndisc_nodetype presence) */ 453 451 kmemcheck_bitfield_end(flags2); 454 - 455 - /* 0/13 bit hole */ 456 452 457 453 #ifdef CONFIG_NET_DMA 458 454 dma_cookie_t dma_cookie; ··· 2270 2264 skb_clone_tx_timestamp(skb); 2271 2265 sw_tx_timestamp(skb); 2272 2266 } 2267 + 2268 + /** 2269 + * skb_complete_wifi_ack - deliver skb with wifi status 2270 + * 2271 + * @skb: the original outgoing packet 2272 + * @acked: ack status 2273 + * 2274 + */ 2275 + void skb_complete_wifi_ack(struct sk_buff *skb, bool acked); 2273 2276 2274 2277 extern __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len); 2275 2278 extern __sum16 __skb_checksum_complete(struct sk_buff *skb);
+28 -1
include/net/bluetooth/bluetooth.h
··· 77 77 #define BT_POWER_FORCE_ACTIVE_OFF 0 78 78 #define BT_POWER_FORCE_ACTIVE_ON 1 79 79 80 + #define BT_CHANNEL_POLICY 10 81 + 82 + /* BR/EDR only (default policy) 83 + * AMP controllers cannot be used. 84 + * Channel move requests from the remote device are denied. 85 + * If the L2CAP channel is currently using AMP, move the channel to BR/EDR. 86 + */ 87 + #define BT_CHANNEL_POLICY_BREDR_ONLY 0 88 + 89 + /* BR/EDR Preferred 90 + * Allow use of AMP controllers. 91 + * If the L2CAP channel is currently on AMP, move it to BR/EDR. 92 + * Channel move requests from the remote device are allowed. 93 + */ 94 + #define BT_CHANNEL_POLICY_BREDR_PREFERRED 1 95 + 96 + /* AMP Preferred 97 + * Allow use of AMP controllers 98 + * If the L2CAP channel is currently on BR/EDR and AMP controller 99 + * resources are available, initiate a channel move to AMP. 100 + * Channel move requests from the remote device are allowed. 101 + * If the L2CAP socket has not been connected yet, try to create 102 + * and configure the channel directly on an AMP controller rather 103 + * than BR/EDR. 104 + */ 105 + #define BT_CHANNEL_POLICY_AMP_PREFERRED 2 106 + 80 107 __printf(2, 3) 81 108 int bt_printk(const char *level, const char *fmt, ...); 82 109 ··· 185 158 __u8 pkt_type; 186 159 __u8 incoming; 187 160 __u16 expect; 188 - __u8 tx_seq; 161 + __u16 tx_seq; 189 162 __u8 retries; 190 163 __u8 sar; 191 164 unsigned short channel;
+22
include/net/bluetooth/hci.h
··· 264 264 #define HCI_LK_SMP_IRK 0x82 265 265 #define HCI_LK_SMP_CSRK 0x83 266 266 267 + /* ---- HCI Error Codes ---- */ 268 + #define HCI_ERROR_AUTH_FAILURE 0x05 269 + #define HCI_ERROR_REJ_BAD_ADDR 0x0f 270 + #define HCI_ERROR_REMOTE_USER_TERM 0x13 271 + #define HCI_ERROR_LOCAL_HOST_TERM 0x16 272 + #define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18 273 + 267 274 /* ----- HCI Commands ---- */ 268 275 #define HCI_OP_NOP 0x0000 269 276 ··· 732 725 #define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47 733 726 #define PAGE_SCAN_TYPE_STANDARD 0x00 734 727 #define PAGE_SCAN_TYPE_INTERLACED 0x01 728 + 729 + #define HCI_OP_READ_LOCAL_AMP_INFO 0x1409 730 + struct hci_rp_read_local_amp_info { 731 + __u8 status; 732 + __u8 amp_status; 733 + __le32 total_bw; 734 + __le32 max_bw; 735 + __le32 min_latency; 736 + __le32 max_pdu; 737 + __u8 amp_type; 738 + __le16 pal_cap; 739 + __le16 max_assoc_size; 740 + __le32 max_flush_to; 741 + __le32 be_flush_to; 742 + } __packed; 735 743 736 744 #define HCI_OP_LE_SET_EVENT_MASK 0x2001 737 745 struct hci_cp_le_set_event_mask {
+103 -33
include/net/bluetooth/hci_core.h
··· 32 32 #define HCI_PROTO_L2CAP 0 33 33 #define HCI_PROTO_SCO 1 34 34 35 + /* HCI priority */ 36 + #define HCI_PRIO_MAX 7 37 + 35 38 /* HCI Core structures */ 36 39 struct inquiry_data { 37 40 bdaddr_t bdaddr; ··· 65 62 unsigned int acl_num; 66 63 unsigned int sco_num; 67 64 unsigned int le_num; 65 + }; 66 + 67 + struct hci_chan_hash { 68 + struct list_head list; 69 + spinlock_t lock; 70 + unsigned int num; 68 71 }; 69 72 70 73 struct bdaddr_list { ··· 159 150 __u16 sniff_min_interval; 160 151 __u16 sniff_max_interval; 161 152 153 + __u8 amp_status; 154 + __u32 amp_total_bw; 155 + __u32 amp_max_bw; 156 + __u32 amp_min_latency; 157 + __u32 amp_max_pdu; 158 + __u8 amp_type; 159 + __u16 amp_pal_cap; 160 + __u16 amp_assoc_size; 161 + __u32 amp_max_flush_to; 162 + __u32 amp_be_flush_to; 163 + 162 164 unsigned int auto_accept_delay; 163 165 164 166 unsigned long quirks; ··· 193 173 struct workqueue_struct *workqueue; 194 174 195 175 struct work_struct power_on; 196 - struct work_struct power_off; 197 - struct timer_list off_timer; 176 + struct delayed_work power_off; 177 + 178 + __u16 discov_timeout; 179 + struct delayed_work discov_off; 198 180 199 181 struct timer_list cmd_timer; 200 182 struct tasklet_struct cmd_task; ··· 216 194 __u32 req_result; 217 195 218 196 __u16 init_last_cmd; 197 + 198 + struct list_head mgmt_pending; 219 199 220 200 struct inquiry_cache inq_cache; 221 201 struct hci_conn_hash conn_hash; ··· 297 273 unsigned int sent; 298 274 299 275 struct sk_buff_head data_q; 276 + struct hci_chan_hash chan_hash; 300 277 301 278 struct timer_list disc_timer; 302 279 struct timer_list idle_timer; ··· 318 293 void (*connect_cfm_cb) (struct hci_conn *conn, u8 status); 319 294 void (*security_cfm_cb) (struct hci_conn *conn, u8 status); 320 295 void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); 296 + }; 297 + 298 + struct hci_chan { 299 + struct list_head list; 300 + 301 + struct hci_conn *conn; 302 + struct sk_buff_head data_q; 303 + unsigned int sent; 321 304 }; 322 305 323 306 extern struct hci_proto *hci_proto[]; ··· 488 455 return NULL; 489 456 } 490 457 458 + static inline void hci_chan_hash_init(struct hci_conn *c) 459 + { 460 + struct hci_chan_hash *h = &c->chan_hash; 461 + INIT_LIST_HEAD(&h->list); 462 + spin_lock_init(&h->lock); 463 + h->num = 0; 464 + } 465 + 466 + static inline void hci_chan_hash_add(struct hci_conn *c, struct hci_chan *chan) 467 + { 468 + struct hci_chan_hash *h = &c->chan_hash; 469 + list_add(&chan->list, &h->list); 470 + h->num++; 471 + } 472 + 473 + static inline void hci_chan_hash_del(struct hci_conn *c, struct hci_chan *chan) 474 + { 475 + struct hci_chan_hash *h = &c->chan_hash; 476 + list_del(&chan->list); 477 + h->num--; 478 + } 479 + 491 480 void hci_acl_connect(struct hci_conn *conn); 492 481 void hci_acl_disconn(struct hci_conn *conn, __u8 reason); 493 482 void hci_add_sco(struct hci_conn *conn, __u16 handle); ··· 520 465 int hci_conn_del(struct hci_conn *conn); 521 466 void hci_conn_hash_flush(struct hci_dev *hdev); 522 467 void hci_conn_check_pending(struct hci_dev *hdev); 468 + 469 + struct hci_chan *hci_chan_create(struct hci_conn *conn); 470 + int hci_chan_del(struct hci_chan *chan); 471 + void hci_chan_hash_flush(struct hci_conn *conn); 523 472 524 473 struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, 525 474 __u8 sec_level, __u8 auth_type); ··· 604 545 struct hci_dev *hci_alloc_dev(void); 605 546 void hci_free_dev(struct hci_dev *hdev); 606 547 int hci_register_dev(struct hci_dev *hdev); 607 - int hci_unregister_dev(struct hci_dev *hdev); 548 + void hci_unregister_dev(struct hci_dev *hdev); 608 549 int hci_suspend_dev(struct hci_dev *hdev); 609 550 int hci_resume_dev(struct hci_dev *hdev); 610 551 int hci_dev_open(__u16 dev); ··· 658 599 int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); 659 600 int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); 660 601 661 - int hci_register_sysfs(struct hci_dev *hdev); 662 - void hci_unregister_sysfs(struct hci_dev *hdev); 602 + void hci_init_sysfs(struct hci_dev *hdev); 603 + int hci_add_sysfs(struct hci_dev *hdev); 604 + void hci_del_sysfs(struct hci_dev *hdev); 663 605 void hci_conn_init_sysfs(struct hci_conn *conn); 664 606 void hci_conn_add_sysfs(struct hci_conn *conn); 665 607 void hci_conn_del_sysfs(struct hci_conn *conn); ··· 736 676 static inline int hci_proto_disconn_ind(struct hci_conn *conn) 737 677 { 738 678 register struct hci_proto *hp; 739 - int reason = 0x13; 679 + int reason = HCI_ERROR_REMOTE_USER_TERM; 740 680 741 681 hp = hci_proto[HCI_PROTO_L2CAP]; 742 682 if (hp && hp->disconn_ind) ··· 896 836 int hci_unregister_notifier(struct notifier_block *nb); 897 837 898 838 int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); 899 - void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags); 839 + void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); 900 840 void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); 901 841 902 842 void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); ··· 909 849 910 850 /* Management interface */ 911 851 int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); 912 - int mgmt_index_added(u16 index); 913 - int mgmt_index_removed(u16 index); 914 - int mgmt_powered(u16 index, u8 powered); 915 - int mgmt_discoverable(u16 index, u8 discoverable); 916 - int mgmt_connectable(u16 index, u8 connectable); 917 - int mgmt_new_key(u16 index, struct link_key *key, u8 persistent); 918 - int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type); 919 - int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); 920 - int mgmt_disconnect_failed(u16 index); 921 - int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status); 922 - int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure); 923 - int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); 924 - int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); 925 - int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value, 926 - u8 confirm_hint); 927 - int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); 928 - int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, 852 + int mgmt_index_added(struct hci_dev *hdev); 853 + int mgmt_index_removed(struct hci_dev *hdev); 854 + int mgmt_powered(struct hci_dev *hdev, u8 powered); 855 + int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable); 856 + int mgmt_connectable(struct hci_dev *hdev, u8 connectable); 857 + int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); 858 + int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, 859 + u8 persistent); 860 + int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); 861 + int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); 862 + int mgmt_disconnect_failed(struct hci_dev *hdev); 863 + int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, 929 864 u8 status); 930 - int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); 931 - int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status); 932 - int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, 865 + int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); 866 + int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 933 867 u8 status); 934 - int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, 935 - u8 *eir); 936 - int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); 937 - int mgmt_discovering(u16 index, u8 discovering); 938 - int mgmt_device_blocked(u16 index, bdaddr_t *bdaddr); 939 - int mgmt_device_unblocked(u16 index, bdaddr_t *bdaddr); 868 + int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 869 + u8 status); 870 + int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, 871 + __le32 value, u8 confirm_hint); 872 + int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 873 + u8 status); 874 + int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, 875 + bdaddr_t *bdaddr, u8 status); 876 + int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status); 877 + int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); 878 + int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, 879 + u8 *randomizer, u8 status); 880 + int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, 881 + u8 *dev_class, s8 rssi, u8 *eir); 882 + int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name); 883 + int mgmt_inquiry_failed(struct hci_dev *hdev, u8 status); 884 + int mgmt_discovering(struct hci_dev *hdev, u8 discovering); 885 + int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr); 886 + int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr); 940 887 941 888 /* HCI info for socket */ 942 889 #define hci_pi(sk) ((struct hci_pinfo *) sk) ··· 981 914 __u8 ltk[16]); 982 915 void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]); 983 916 void hci_le_ltk_neg_reply(struct hci_conn *conn); 917 + 918 + int hci_do_inquiry(struct hci_dev *hdev, u8 length); 919 + int hci_cancel_inquiry(struct hci_dev *hdev); 984 920 985 921 #endif /* __HCI_CORE_H */
+359 -55
include/net/bluetooth/l2cap.h
··· 27 27 #ifndef __L2CAP_H 28 28 #define __L2CAP_H 29 29 30 + #include <asm/unaligned.h> 31 + 30 32 /* L2CAP defaults */ 31 33 #define L2CAP_DEFAULT_MTU 672 32 34 #define L2CAP_DEFAULT_MIN_MTU 48 33 35 #define L2CAP_DEFAULT_FLUSH_TO 0xffff 34 36 #define L2CAP_DEFAULT_TX_WINDOW 63 37 + #define L2CAP_DEFAULT_EXT_WINDOW 0x3FFF 35 38 #define L2CAP_DEFAULT_MAX_TX 3 36 39 #define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ 37 40 #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ 38 41 #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ 39 42 #define L2CAP_DEFAULT_ACK_TO 200 40 43 #define L2CAP_LE_DEFAULT_MTU 23 44 + #define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF 45 + #define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF 46 + #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF 41 47 42 - #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ 43 - #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ 48 + #define L2CAP_DISC_TIMEOUT (100) 49 + #define L2CAP_DISC_REJ_TIMEOUT (5000) /* 5 seconds */ 50 + #define L2CAP_ENC_TIMEOUT (5000) /* 5 seconds */ 51 + #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ 52 + #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ 44 53 45 54 /* L2CAP socket address */ 46 55 struct sockaddr_l2 { ··· 97 88 #define L2CAP_ECHO_RSP 0x09 98 89 #define L2CAP_INFO_REQ 0x0a 99 90 #define L2CAP_INFO_RSP 0x0b 91 + #define L2CAP_CREATE_CHAN_REQ 0x0c 92 + #define L2CAP_CREATE_CHAN_RSP 0x0d 93 + #define L2CAP_MOVE_CHAN_REQ 0x0e 94 + #define L2CAP_MOVE_CHAN_RSP 0x0f 95 + #define L2CAP_MOVE_CHAN_CFM 0x10 96 + #define L2CAP_MOVE_CHAN_CFM_RSP 0x11 100 97 #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 101 98 #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 102 99 103 - /* L2CAP feature mask */ 100 + /* L2CAP extended feature mask */ 104 101 #define L2CAP_FEAT_FLOWCTL 0x00000001 105 102 #define L2CAP_FEAT_RETRANS 0x00000002 103 + #define L2CAP_FEAT_BIDIR_QOS 0x00000004 106 104 #define L2CAP_FEAT_ERTM 0x00000008 107 105 #define L2CAP_FEAT_STREAMING 0x00000010 108 106 #define L2CAP_FEAT_FCS 0x00000020 107 + #define L2CAP_FEAT_EXT_FLOW 0x00000040 109 108 #define L2CAP_FEAT_FIXED_CHAN 0x00000080 109 + #define L2CAP_FEAT_EXT_WINDOW 0x00000100 110 + #define L2CAP_FEAT_UCD 0x00000200 110 111 111 112 /* L2CAP checksum option */ 112 113 #define L2CAP_FCS_NONE 0x00 113 114 #define L2CAP_FCS_CRC16 0x01 114 115 115 - /* L2CAP Control Field bit masks */ 116 - #define L2CAP_CTRL_SAR 0xC000 117 - #define L2CAP_CTRL_REQSEQ 0x3F00 118 - #define L2CAP_CTRL_TXSEQ 0x007E 119 - #define L2CAP_CTRL_RETRANS 0x0080 120 - #define L2CAP_CTRL_FINAL 0x0080 121 - #define L2CAP_CTRL_POLL 0x0010 122 - #define L2CAP_CTRL_SUPERVISE 0x000C 123 - #define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ 116 + /* L2CAP fixed channels */ 117 + #define L2CAP_FC_L2CAP 0x02 118 + #define L2CAP_FC_A2MP 0x08 124 119 125 - #define L2CAP_CTRL_TXSEQ_SHIFT 1 126 - #define L2CAP_CTRL_REQSEQ_SHIFT 8 127 - #define L2CAP_CTRL_SAR_SHIFT 14 120 + /* L2CAP Control Field bit masks */ 121 + #define L2CAP_CTRL_SAR 0xC000 122 + #define L2CAP_CTRL_REQSEQ 0x3F00 123 + #define L2CAP_CTRL_TXSEQ 0x007E 124 + #define L2CAP_CTRL_SUPERVISE 0x000C 125 + 126 + #define L2CAP_CTRL_RETRANS 0x0080 127 + #define L2CAP_CTRL_FINAL 0x0080 128 + #define L2CAP_CTRL_POLL 0x0010 129 + #define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ 130 + 131 + #define L2CAP_CTRL_TXSEQ_SHIFT 1 132 + #define L2CAP_CTRL_SUPER_SHIFT 2 133 + #define L2CAP_CTRL_REQSEQ_SHIFT 8 134 + #define L2CAP_CTRL_SAR_SHIFT 14 135 + 136 + /* L2CAP Extended Control Field bit mask */ 137 + #define L2CAP_EXT_CTRL_TXSEQ 0xFFFC0000 138 + #define L2CAP_EXT_CTRL_SAR 0x00030000 139 + #define L2CAP_EXT_CTRL_SUPERVISE 0x00030000 140 + #define L2CAP_EXT_CTRL_REQSEQ 0x0000FFFC 141 + 142 + #define L2CAP_EXT_CTRL_POLL 0x00040000 143 + #define L2CAP_EXT_CTRL_FINAL 0x00000002 144 + #define L2CAP_EXT_CTRL_FRAME_TYPE 0x00000001 /* I- or S-Frame */ 145 + 146 + #define L2CAP_EXT_CTRL_REQSEQ_SHIFT 2 147 + #define L2CAP_EXT_CTRL_SAR_SHIFT 16 148 + #define L2CAP_EXT_CTRL_SUPER_SHIFT 16 149 + #define L2CAP_EXT_CTRL_TXSEQ_SHIFT 18 128 150 129 151 /* L2CAP Supervisory Function */ 130 - #define L2CAP_SUPER_RCV_READY 0x0000 131 - #define L2CAP_SUPER_REJECT 0x0004 132 - #define L2CAP_SUPER_RCV_NOT_READY 0x0008 133 - #define L2CAP_SUPER_SELECT_REJECT 0x000C 152 + #define L2CAP_SUPER_RR 0x00 153 + #define L2CAP_SUPER_REJ 0x01 154 + #define L2CAP_SUPER_RNR 0x02 155 + #define L2CAP_SUPER_SREJ 0x03 134 156 135 157 /* L2CAP Segmentation and Reassembly */ 136 - #define L2CAP_SDU_UNSEGMENTED 0x0000 137 - #define L2CAP_SDU_START 0x4000 138 - #define L2CAP_SDU_END 0x8000 139 - #define L2CAP_SDU_CONTINUE 0xC000 158 + #define L2CAP_SAR_UNSEGMENTED 0x00 159 + #define L2CAP_SAR_START 0x01 160 + #define L2CAP_SAR_END 0x02 161 + #define L2CAP_SAR_CONTINUE 0x03 140 162 141 163 /* L2CAP Command rej. reasons */ 142 - #define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 143 - #define L2CAP_REJ_MTU_EXCEEDED 0x0001 144 - #define L2CAP_REJ_INVALID_CID 0x0002 145 - 164 + #define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 165 + #define L2CAP_REJ_MTU_EXCEEDED 0x0001 166 + #define L2CAP_REJ_INVALID_CID 0x0002 146 167 147 168 /* L2CAP structures */ 148 169 struct l2cap_hdr { ··· 180 141 __le16 cid; 181 142 } __packed; 182 143 #define L2CAP_HDR_SIZE 4 144 + #define L2CAP_ENH_HDR_SIZE 6 145 + #define L2CAP_EXT_HDR_SIZE 8 146 + 147 + #define L2CAP_FCS_SIZE 2 148 + #define L2CAP_SDULEN_SIZE 2 149 + #define L2CAP_PSMLEN_SIZE 2 183 150 184 151 struct l2cap_cmd_hdr { 185 152 __u8 code; ··· 230 185 #define L2CAP_CID_DYN_START 0x0040 231 186 #define L2CAP_CID_DYN_END 0xffff 232 187 233 - /* connect result */ 188 + /* connect/create channel results */ 234 189 #define L2CAP_CR_SUCCESS 0x0000 235 190 #define L2CAP_CR_PEND 0x0001 236 191 #define L2CAP_CR_BAD_PSM 0x0002 237 192 #define L2CAP_CR_SEC_BLOCK 0x0003 238 193 #define L2CAP_CR_NO_MEM 0x0004 194 + #define L2CAP_CR_BAD_AMP 0x0005 239 195 240 - /* connect status */ 196 + /* connect/create channel status */ 241 197 #define L2CAP_CS_NO_INFO 0x0000 242 198 #define L2CAP_CS_AUTHEN_PEND 0x0001 243 199 #define L2CAP_CS_AUTHOR_PEND 0x0002 ··· 260 214 #define L2CAP_CONF_UNACCEPT 0x0001 261 215 #define L2CAP_CONF_REJECT 0x0002 262 216 #define L2CAP_CONF_UNKNOWN 0x0003 217 + #define L2CAP_CONF_PENDING 0x0004 218 + #define L2CAP_CONF_EFS_REJECT 0x0005 263 219 264 220 struct l2cap_conf_opt { 265 221 __u8 type; ··· 278 230 #define L2CAP_CONF_QOS 0x03 279 231 #define L2CAP_CONF_RFC 0x04 280 232 #define L2CAP_CONF_FCS 0x05 233 + #define L2CAP_CONF_EFS 0x06 234 + #define L2CAP_CONF_EWS 0x07 281 235 282 236 #define L2CAP_CONF_MAX_SIZE 22 283 237 ··· 297 247 #define L2CAP_MODE_FLOWCTL 0x02 298 248 #define L2CAP_MODE_ERTM 0x03 299 249 #define L2CAP_MODE_STREAMING 0x04 250 + 251 + struct l2cap_conf_efs { 252 + __u8 id; 253 + __u8 stype; 254 + __le16 msdu; 255 + __le32 sdu_itime; 256 + __le32 acc_lat; 257 + __le32 flush_to; 258 + } __packed; 259 + 260 + #define L2CAP_SERV_NOTRAFIC 0x00 261 + #define L2CAP_SERV_BESTEFFORT 0x01 262 + #define L2CAP_SERV_GUARANTEED 0x02 263 + 264 + #define L2CAP_BESTEFFORT_ID 0x01 300 265 301 266 struct l2cap_disconn_req { 302 267 __le16 dcid; ··· 333 268 __u8 data[0]; 334 269 } __packed; 335 270 271 + struct l2cap_create_chan_req { 272 + __le16 psm; 273 + __le16 scid; 274 + __u8 amp_id; 275 + } __packed; 276 + 277 + struct l2cap_create_chan_rsp { 278 + __le16 dcid; 279 + __le16 scid; 280 + __le16 result; 281 + __le16 status; 282 + } __packed; 283 + 284 + struct l2cap_move_chan_req { 285 + __le16 icid; 286 + __u8 dest_amp_id; 287 + } __packed; 288 + 289 + struct l2cap_move_chan_rsp { 290 + __le16 icid; 291 + __le16 result; 292 + } __packed; 293 + 294 + #define L2CAP_MR_SUCCESS 0x0000 295 + #define L2CAP_MR_PEND 0x0001 296 + #define L2CAP_MR_BAD_ID 0x0002 297 + #define L2CAP_MR_SAME_ID 0x0003 298 + #define L2CAP_MR_NOT_SUPP 0x0004 299 + #define L2CAP_MR_COLLISION 0x0005 300 + #define L2CAP_MR_NOT_ALLOWED 0x0006 301 + 302 + struct l2cap_move_chan_cfm { 303 + __le16 icid; 304 + __le16 result; 305 + } __packed; 306 + 307 + #define L2CAP_MC_CONFIRMED 0x0000 308 + #define L2CAP_MC_UNCONFIRMED 0x0001 309 + 310 + struct l2cap_move_chan_cfm_rsp { 311 + __le16 icid; 312 + } __packed; 313 + 336 314 /* info type */ 337 - #define L2CAP_IT_CL_MTU 0x0001 338 - #define L2CAP_IT_FEAT_MASK 0x0002 339 - #define L2CAP_IT_FIXED_CHAN 0x0003 315 + #define L2CAP_IT_CL_MTU 0x0001 316 + #define L2CAP_IT_FEAT_MASK 0x0002 317 + #define L2CAP_IT_FIXED_CHAN 0x0003 340 318 341 319 /* info result */ 342 - #define L2CAP_IR_SUCCESS 0x0000 343 - #define L2CAP_IR_NOTSUPP 0x0001 320 + #define L2CAP_IR_SUCCESS 0x0000 321 + #define L2CAP_IR_NOTSUPP 0x0001 344 322 345 323 struct l2cap_conn_param_update_req { 346 324 __le16 min; ··· 402 294 403 295 /* ----- L2CAP channels and connections ----- */ 404 296 struct srej_list { 405 - __u8 tx_seq; 297 + __u16 tx_seq; 406 298 struct list_head list; 407 299 }; 408 300 ··· 424 316 __u16 flush_to; 425 317 __u8 mode; 426 318 __u8 chan_type; 319 + __u8 chan_policy; 427 320 428 321 __le16 sport; 429 322 430 323 __u8 sec_level; 431 - __u8 role_switch; 432 - __u8 force_reliable; 433 - __u8 flushable; 434 - __u8 force_active; 435 324 436 325 __u8 ident; 437 326 ··· 439 334 440 335 __u8 fcs; 441 336 442 - __u8 tx_win; 337 + __u16 tx_win; 338 + __u16 tx_win_max; 443 339 __u8 max_tx; 444 340 __u16 retrans_timeout; 445 341 __u16 monitor_timeout; ··· 448 342 449 343 unsigned long conf_state; 450 344 unsigned long conn_state; 345 + unsigned long flags; 451 346 452 - __u8 next_tx_seq; 453 - __u8 expected_ack_seq; 454 - __u8 expected_tx_seq; 455 - __u8 buffer_seq; 456 - __u8 buffer_seq_srej; 457 - __u8 srej_save_reqseq; 458 - __u8 frames_sent; 459 - __u8 unacked_frames; 347 + __u16 next_tx_seq; 348 + __u16 expected_ack_seq; 349 + __u16 expected_tx_seq; 350 + __u16 buffer_seq; 351 + __u16 buffer_seq_srej; 352 + __u16 srej_save_reqseq; 353 + __u16 frames_sent; 354 + __u16 unacked_frames; 460 355 __u8 retry_count; 461 356 __u8 num_acked; 462 357 __u16 sdu_len; 463 358 struct sk_buff *sdu; 464 359 struct sk_buff *sdu_last_frag; 465 360 466 - __u8 remote_tx_win; 361 + __u16 remote_tx_win; 467 362 __u8 remote_max_tx; 468 363 __u16 remote_mps; 364 + 365 + __u8 local_id; 366 + __u8 local_stype; 367 + __u16 local_msdu; 368 + __u32 local_sdu_itime; 369 + __u32 local_acc_lat; 370 + __u32 local_flush_to; 371 + 372 + __u8 remote_id; 373 + __u8 remote_stype; 374 + __u16 remote_msdu; 375 + __u32 remote_sdu_itime; 376 + __u32 remote_acc_lat; 377 + __u32 remote_flush_to; 469 378 470 379 struct timer_list chan_timer; 471 380 struct timer_list retrans_timer; ··· 509 388 510 389 struct l2cap_conn { 511 390 struct hci_conn *hcon; 391 + struct hci_chan *hchan; 512 392 513 393 bdaddr_t *dst; 514 394 bdaddr_t *src; ··· 564 442 CONF_CONNECT_PEND, 565 443 CONF_NO_FCS_RECV, 566 444 CONF_STATE2_DEVICE, 445 + CONF_EWS_RECV, 446 + CONF_LOC_CONF_PEND, 447 + CONF_REM_CONF_PEND, 567 448 }; 568 449 569 450 #define L2CAP_CONF_MAX_CONF_REQ 2 ··· 584 459 CONN_RNR_SENT, 585 460 }; 586 461 462 + /* Definitions for flags in l2cap_chan */ 463 + enum { 464 + FLAG_ROLE_SWITCH, 465 + FLAG_FORCE_ACTIVE, 466 + FLAG_FORCE_RELIABLE, 467 + FLAG_FLUSHABLE, 468 + FLAG_EXT_CTRL, 469 + FLAG_EFS_ENABLE, 470 + }; 471 + 587 472 #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) 588 473 #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) 589 474 #define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ ··· 605 470 #define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ 606 471 L2CAP_DEFAULT_ACK_TO); 607 472 #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) 473 + 474 + static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2) 475 + { 476 + int offset; 477 + 478 + offset = (seq1 - seq2) % (chan->tx_win_max + 1); 479 + if (offset < 0) 480 + offset += (chan->tx_win_max + 1); 481 + 482 + return offset; 483 + } 484 + 485 + static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) 486 + { 487 + return (seq + 1) % (chan->tx_win_max + 1); 488 + } 608 489 609 490 static inline int l2cap_tx_window_full(struct l2cap_chan *ch) 610 491 { ··· 634 483 return sub == ch->remote_tx_win; 635 484 } 636 485 637 - #define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) 638 - #define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8) 639 - #define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) 640 - #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) 641 - #define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) 486 + static inline __u16 __get_reqseq(struct l2cap_chan *chan, __u32 ctrl) 487 + { 488 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 489 + return (ctrl & L2CAP_EXT_CTRL_REQSEQ) >> 490 + L2CAP_EXT_CTRL_REQSEQ_SHIFT; 491 + else 492 + return (ctrl & L2CAP_CTRL_REQSEQ) >> L2CAP_CTRL_REQSEQ_SHIFT; 493 + } 494 + 495 + static inline __u32 __set_reqseq(struct l2cap_chan *chan, __u32 reqseq) 496 + { 497 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 498 + return (reqseq << L2CAP_EXT_CTRL_REQSEQ_SHIFT) & 499 + L2CAP_EXT_CTRL_REQSEQ; 500 + else 501 + return (reqseq << L2CAP_CTRL_REQSEQ_SHIFT) & L2CAP_CTRL_REQSEQ; 502 + } 503 + 504 + static inline __u16 __get_txseq(struct l2cap_chan *chan, __u32 ctrl) 505 + { 506 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 507 + return (ctrl & L2CAP_EXT_CTRL_TXSEQ) >> 508 + L2CAP_EXT_CTRL_TXSEQ_SHIFT; 509 + else 510 + return (ctrl & L2CAP_CTRL_TXSEQ) >> L2CAP_CTRL_TXSEQ_SHIFT; 511 + } 512 + 513 + static inline __u32 __set_txseq(struct l2cap_chan *chan, __u32 txseq) 514 + { 515 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 516 + return (txseq << L2CAP_EXT_CTRL_TXSEQ_SHIFT) & 517 + L2CAP_EXT_CTRL_TXSEQ; 518 + else 519 + return (txseq << L2CAP_CTRL_TXSEQ_SHIFT) & L2CAP_CTRL_TXSEQ; 520 + } 521 + 522 + static inline bool __is_sframe(struct l2cap_chan *chan, __u32 ctrl) 523 + { 524 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 525 + return ctrl & L2CAP_EXT_CTRL_FRAME_TYPE; 526 + else 527 + return ctrl & L2CAP_CTRL_FRAME_TYPE; 528 + } 529 + 530 + static inline __u32 __set_sframe(struct l2cap_chan *chan) 531 + { 532 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 533 + return L2CAP_EXT_CTRL_FRAME_TYPE; 534 + else 535 + return L2CAP_CTRL_FRAME_TYPE; 536 + } 537 + 538 + static inline __u8 __get_ctrl_sar(struct l2cap_chan *chan, __u32 ctrl) 539 + { 540 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 541 + return (ctrl & L2CAP_EXT_CTRL_SAR) >> L2CAP_EXT_CTRL_SAR_SHIFT; 542 + else 543 + return (ctrl & L2CAP_CTRL_SAR) >> L2CAP_CTRL_SAR_SHIFT; 544 + } 545 + 546 + static inline __u32 __set_ctrl_sar(struct l2cap_chan *chan, __u32 sar) 547 + { 548 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 549 + return (sar << L2CAP_EXT_CTRL_SAR_SHIFT) & L2CAP_EXT_CTRL_SAR; 550 + else 551 + return (sar << L2CAP_CTRL_SAR_SHIFT) & L2CAP_CTRL_SAR; 552 + } 553 + 554 + static inline bool __is_sar_start(struct l2cap_chan *chan, __u32 ctrl) 555 + { 556 + return __get_ctrl_sar(chan, ctrl) == L2CAP_SAR_START; 557 + } 558 + 559 + static inline __u32 __get_sar_mask(struct l2cap_chan *chan) 560 + { 561 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 562 + return L2CAP_EXT_CTRL_SAR; 563 + else 564 + return L2CAP_CTRL_SAR; 565 + } 566 + 567 + static inline __u8 __get_ctrl_super(struct l2cap_chan *chan, __u32 ctrl) 568 + { 569 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 570 + return (ctrl & L2CAP_EXT_CTRL_SUPERVISE) >> 571 + L2CAP_EXT_CTRL_SUPER_SHIFT; 572 + else 573 + return (ctrl & L2CAP_CTRL_SUPERVISE) >> L2CAP_CTRL_SUPER_SHIFT; 574 + } 575 + 576 + static inline __u32 __set_ctrl_super(struct l2cap_chan *chan, __u32 super) 577 + { 578 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 579 + return (super << L2CAP_EXT_CTRL_SUPER_SHIFT) & 580 + L2CAP_EXT_CTRL_SUPERVISE; 581 + else 582 + return (super << L2CAP_CTRL_SUPER_SHIFT) & 583 + L2CAP_CTRL_SUPERVISE; 584 + } 585 + 586 + static inline __u32 __set_ctrl_final(struct l2cap_chan *chan) 587 + { 588 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 589 + return L2CAP_EXT_CTRL_FINAL; 590 + else 591 + return L2CAP_CTRL_FINAL; 592 + } 593 + 594 + static inline bool __is_ctrl_final(struct l2cap_chan *chan, __u32 ctrl) 595 + { 596 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 597 + return ctrl & L2CAP_EXT_CTRL_FINAL; 598 + else 599 + return ctrl & L2CAP_CTRL_FINAL; 600 + } 601 + 602 + static inline __u32 __set_ctrl_poll(struct l2cap_chan *chan) 603 + { 604 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 605 + return L2CAP_EXT_CTRL_POLL; 606 + else 607 + return L2CAP_CTRL_POLL; 608 + } 609 + 610 + static inline bool __is_ctrl_poll(struct l2cap_chan *chan, __u32 ctrl) 611 + { 612 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 613 + return ctrl & L2CAP_EXT_CTRL_POLL; 614 + else 615 + return ctrl & L2CAP_CTRL_POLL; 616 + } 617 + 618 + static inline __u32 __get_control(struct l2cap_chan *chan, void *p) 619 + { 620 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 621 + return get_unaligned_le32(p); 622 + else 623 + return get_unaligned_le16(p); 624 + } 625 + 626 + static inline void __put_control(struct l2cap_chan *chan, __u32 control, 627 + void *p) 628 + { 629 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 630 + return put_unaligned_le32(control, p); 631 + else 632 + return put_unaligned_le16(control, p); 633 + } 634 + 635 + static inline __u8 __ctrl_size(struct l2cap_chan *chan) 636 + { 637 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 638 + return L2CAP_EXT_HDR_SIZE - L2CAP_HDR_SIZE; 639 + else 640 + return L2CAP_ENH_HDR_SIZE - L2CAP_HDR_SIZE; 641 + } 642 642 643 643 extern int disable_ertm; 644 + extern int enable_hs; 644 645 645 646 int l2cap_init_sockets(void); 646 647 void l2cap_cleanup_sockets(void); ··· 807 504 void l2cap_chan_close(struct l2cap_chan *chan, int reason); 808 505 void l2cap_chan_destroy(struct l2cap_chan *chan); 809 506 int l2cap_chan_connect(struct l2cap_chan *chan); 810 - int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); 507 + int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, 508 + u32 priority); 811 509 void l2cap_chan_busy(struct l2cap_chan *chan, int busy); 812 510 813 511 #endif /* __L2CAP_H */
+26 -21
include/net/bluetooth/mgmt.h
··· 69 69 #define MGMT_OP_SET_POWERED 0x0005 70 70 71 71 #define MGMT_OP_SET_DISCOVERABLE 0x0006 72 + struct mgmt_cp_set_discoverable { 73 + __u8 val; 74 + __u16 timeout; 75 + } __packed; 72 76 73 77 #define MGMT_OP_SET_CONNECTABLE 0x0007 74 78 ··· 100 96 __u8 enable; 101 97 } __packed; 102 98 103 - struct mgmt_key_info { 99 + struct mgmt_link_key_info { 104 100 bdaddr_t bdaddr; 105 101 u8 type; 106 102 u8 val[16]; 107 103 u8 pin_len; 108 - u8 dlen; 109 - u8 data[0]; 110 104 } __packed; 111 105 112 - #define MGMT_OP_LOAD_KEYS 0x000D 113 - struct mgmt_cp_load_keys { 106 + #define MGMT_OP_LOAD_LINK_KEYS 0x000D 107 + struct mgmt_cp_load_link_keys { 114 108 __u8 debug_keys; 115 109 __le16 key_count; 116 - struct mgmt_key_info keys[0]; 110 + struct mgmt_link_key_info keys[0]; 117 111 } __packed; 118 112 119 - #define MGMT_OP_REMOVE_KEY 0x000E 120 - struct mgmt_cp_remove_key { 113 + #define MGMT_OP_REMOVE_KEYS 0x000E 114 + struct mgmt_cp_remove_keys { 121 115 bdaddr_t bdaddr; 122 116 __u8 disconnect; 123 117 } __packed; ··· 128 126 bdaddr_t bdaddr; 129 127 } __packed; 130 128 129 + #define MGMT_ADDR_BREDR 0x00 130 + #define MGMT_ADDR_LE 0x01 131 + #define MGMT_ADDR_BREDR_LE 0x02 132 + #define MGMT_ADDR_INVALID 0xff 133 + 134 + struct mgmt_addr_info { 135 + bdaddr_t bdaddr; 136 + __u8 type; 137 + } __packed; 138 + 131 139 #define MGMT_OP_GET_CONNECTIONS 0x0010 132 140 struct mgmt_rp_get_connections { 133 141 __le16 conn_count; 134 - bdaddr_t conn[0]; 142 + struct mgmt_addr_info addr[0]; 135 143 } __packed; 136 144 137 145 #define MGMT_OP_PIN_CODE_REPLY 0x0011 ··· 257 245 258 246 #define MGMT_EV_PAIRABLE 0x0009 259 247 260 - #define MGMT_EV_NEW_KEY 0x000A 261 - struct mgmt_ev_new_key { 248 + #define MGMT_EV_NEW_LINK_KEY 0x000A 249 + struct mgmt_ev_new_link_key { 262 250 __u8 store_hint; 263 - struct mgmt_key_info key; 251 + struct mgmt_link_key_info key; 264 252 } __packed; 265 253 266 254 #define MGMT_EV_CONNECTED 0x000B 267 - struct mgmt_ev_connected { 268 - bdaddr_t bdaddr; 269 - __u8 link_type; 270 - } __packed; 271 255 272 256 #define MGMT_EV_DISCONNECTED 0x000C 273 - struct mgmt_ev_disconnected { 274 - bdaddr_t bdaddr; 275 - } __packed; 276 257 277 258 #define MGMT_EV_CONNECT_FAILED 0x000D 278 259 struct mgmt_ev_connect_failed { 279 - bdaddr_t bdaddr; 260 + struct mgmt_addr_info addr; 280 261 __u8 status; 281 262 } __packed; 282 263 ··· 299 294 300 295 #define MGMT_EV_DEVICE_FOUND 0x0012 301 296 struct mgmt_ev_device_found { 302 - bdaddr_t bdaddr; 297 + struct mgmt_addr_info addr; 303 298 __u8 dev_class[3]; 304 299 __s8 rssi; 305 300 __u8 eir[HCI_MAX_EIR_LENGTH];
+108 -4
include/net/cfg80211.h
··· 391 391 * @assocresp_ies: extra information element(s) to add into (Re)Association 392 392 * Response frames or %NULL 393 393 * @assocresp_ies_len: length of assocresp_ies in octets 394 + * @probe_resp_len: length of probe response template (@probe_resp) 395 + * @probe_resp: probe response template (AP mode only) 394 396 */ 395 397 struct beacon_parameters { 396 398 u8 *head, *tail; ··· 410 408 size_t proberesp_ies_len; 411 409 const u8 *assocresp_ies; 412 410 size_t assocresp_ies_len; 411 + int probe_resp_len; 412 + u8 *probe_resp; 413 413 }; 414 414 415 415 /** ··· 460 456 * as the AC bitmap in the QoS info field 461 457 * @max_sp: max Service Period. same format as the MAX_SP in the 462 458 * QoS info field (but already shifted down) 459 + * @sta_modify_mask: bitmap indicating which parameters changed 460 + * (for those that don't have a natural "no change" value), 461 + * see &enum station_parameters_apply_mask 463 462 */ 464 463 struct station_parameters { 465 464 u8 *supported_rates; ··· 622 615 * user space MLME/SME implementation. The information is provided for 623 616 * the cfg80211_new_sta() calls to notify user space of the IEs. 624 617 * @assoc_req_ies_len: Length of assoc_req_ies buffer in octets. 618 + * @sta_flags: station flags mask & values 625 619 */ 626 620 struct station_info { 627 621 u32 filled; ··· 1346 1338 * doesn't verify much. Note, however, that the passed netdev may be 1347 1339 * %NULL as well if the user requested changing the channel for the 1348 1340 * device itself, or for a monitor interface. 1341 + * @get_channel: Get the current operating channel, should return %NULL if 1342 + * there's no single defined operating channel if for example the 1343 + * device implements channel hopping for multi-channel virtual interfaces. 1349 1344 * 1350 1345 * @scan: Request to do a scan. If returning zero, the scan request is given 1351 1346 * the driver, and will be valid until passed to cfg80211_scan_done(). ··· 1439 1428 * 1440 1429 * @tdls_mgmt: Transmit a TDLS management frame. 1441 1430 * @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup). 1431 + * 1432 + * @probe_client: probe an associated client, must return a cookie that it 1433 + * later passes to cfg80211_probe_status(). 1442 1434 */ 1443 1435 struct cfg80211_ops { 1444 1436 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); ··· 1595 1581 enum nl80211_channel_type channel_type, 1596 1582 bool channel_type_valid, unsigned int wait, 1597 1583 const u8 *buf, size_t len, bool no_cck, 1598 - u64 *cookie); 1584 + bool dont_wait_for_ack, u64 *cookie); 1599 1585 int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy, 1600 1586 struct net_device *dev, 1601 1587 u64 cookie); ··· 1631 1617 u16 status_code, const u8 *buf, size_t len); 1632 1618 int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev, 1633 1619 u8 *peer, enum nl80211_tdls_operation oper); 1620 + 1621 + int (*probe_client)(struct wiphy *wiphy, struct net_device *dev, 1622 + const u8 *peer, u64 *cookie); 1623 + 1624 + struct ieee80211_channel *(*get_channel)(struct wiphy *wiphy); 1634 1625 }; 1635 1626 1636 1627 /* ··· 1694 1675 * teardown packets should be sent through the @NL80211_CMD_TDLS_MGMT 1695 1676 * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be 1696 1677 * used for asking the driver/firmware to perform a TDLS operation. 1678 + * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME 1679 + * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes 1680 + * when there are virtual interfaces in AP mode by calling 1681 + * cfg80211_report_obss_beacon(). 1682 + * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device 1683 + * responds to probe-requests in hardware. 1697 1684 */ 1698 1685 enum wiphy_flags { 1699 1686 WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), ··· 1718 1693 WIPHY_FLAG_AP_UAPSD = BIT(14), 1719 1694 WIPHY_FLAG_SUPPORTS_TDLS = BIT(15), 1720 1695 WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16), 1696 + WIPHY_FLAG_HAVE_AP_SME = BIT(17), 1697 + WIPHY_FLAG_REPORTS_OBSS = BIT(18), 1698 + WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19), 1721 1699 }; 1722 1700 1723 1701 /** ··· 1893 1865 * @software_iftypes: bitmask of software interface types, these are not 1894 1866 * subject to any restrictions since they are purely managed in SW. 1895 1867 * @flags: wiphy flags, see &enum wiphy_flags 1868 + * @features: features advertised to nl80211, see &enum nl80211_feature_flags. 1896 1869 * @bss_priv_size: each BSS struct has private data allocated with it, 1897 1870 * this variable determines its size 1898 1871 * @max_scan_ssids: maximum number of SSIDs the device can scan for in ··· 1932 1903 * may request, if implemented. 1933 1904 * 1934 1905 * @wowlan: WoWLAN support information 1906 + * 1907 + * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features. 1935 1908 */ 1936 1909 struct wiphy { 1937 1910 /* assign these fields before you register the wiphy */ ··· 1955 1924 /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */ 1956 1925 u16 interface_modes; 1957 1926 1958 - u32 flags; 1927 + u32 flags, features; 1928 + 1929 + u32 ap_sme_capa; 1959 1930 1960 1931 enum cfg80211_signal_type signal_type; 1961 1932 ··· 1988 1955 1989 1956 u32 available_antennas_tx; 1990 1957 u32 available_antennas_rx; 1958 + 1959 + /* 1960 + * Bitmap of supported protocols for probe response offloading 1961 + * see &enum nl80211_probe_resp_offload_support_attr. Only valid 1962 + * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set. 1963 + */ 1964 + u32 probe_resp_offload; 1991 1965 1992 1966 /* If multiple wiphys are registered and you're handed e.g. 1993 1967 * a regular netdev with assigned ieee80211_ptr, you won't ··· 2218 2178 int ps_timeout; 2219 2179 2220 2180 int beacon_interval; 2181 + 2182 + u32 ap_unexpected_nlpid; 2221 2183 2222 2184 #ifdef CONFIG_CFG80211_WEXT 2223 2185 /* wext data */ ··· 2674 2632 * 2675 2633 * This informs cfg80211 that BSS information was found and 2676 2634 * the BSS should be updated/added. 2635 + * 2636 + * NOTE: Returns a referenced struct, must be released with cfg80211_put_bss()! 2677 2637 */ 2678 - struct cfg80211_bss* 2638 + struct cfg80211_bss * __must_check 2679 2639 cfg80211_inform_bss_frame(struct wiphy *wiphy, 2680 2640 struct ieee80211_channel *channel, 2681 2641 struct ieee80211_mgmt *mgmt, size_t len, ··· 2699 2655 * 2700 2656 * This informs cfg80211 that BSS information was found and 2701 2657 * the BSS should be updated/added. 2658 + * 2659 + * NOTE: Returns a referenced struct, must be released with cfg80211_put_bss()! 2702 2660 */ 2703 - struct cfg80211_bss* 2661 + struct cfg80211_bss * __must_check 2704 2662 cfg80211_inform_bss(struct wiphy *wiphy, 2705 2663 struct ieee80211_channel *channel, 2706 2664 const u8 *bssid, ··· 3230 3184 */ 3231 3185 void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, 3232 3186 const u8 *bssid, bool preauth, gfp_t gfp); 3187 + 3188 + /** 3189 + * cfg80211_rx_spurious_frame - inform userspace about a spurious frame 3190 + * @dev: The device the frame matched to 3191 + * @addr: the transmitter address 3192 + * @gfp: context flags 3193 + * 3194 + * This function is used in AP mode (only!) to inform userspace that 3195 + * a spurious class 3 frame was received, to be able to deauth the 3196 + * sender. 3197 + * Returns %true if the frame was passed to userspace (or this failed 3198 + * for a reason other than not having a subscription.) 3199 + */ 3200 + bool cfg80211_rx_spurious_frame(struct net_device *dev, 3201 + const u8 *addr, gfp_t gfp); 3202 + 3203 + /** 3204 + * cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame 3205 + * @dev: The device the frame matched to 3206 + * @addr: the transmitter address 3207 + * @gfp: context flags 3208 + * 3209 + * This function is used in AP mode (only!) to inform userspace that 3210 + * an associated station sent a 4addr frame but that wasn't expected. 3211 + * It is allowed and desirable to send this event only once for each 3212 + * station to avoid event flooding. 3213 + * Returns %true if the frame was passed to userspace (or this failed 3214 + * for a reason other than not having a subscription.) 3215 + */ 3216 + bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, 3217 + const u8 *addr, gfp_t gfp); 3218 + 3219 + /** 3220 + * cfg80211_probe_status - notify userspace about probe status 3221 + * @dev: the device the probe was sent on 3222 + * @addr: the address of the peer 3223 + * @cookie: the cookie filled in @probe_client previously 3224 + * @acked: indicates whether probe was acked or not 3225 + * @gfp: allocation flags 3226 + */ 3227 + void cfg80211_probe_status(struct net_device *dev, const u8 *addr, 3228 + u64 cookie, bool acked, gfp_t gfp); 3229 + 3230 + /** 3231 + * cfg80211_report_obss_beacon - report beacon from other APs 3232 + * @wiphy: The wiphy that received the beacon 3233 + * @frame: the frame 3234 + * @len: length of the frame 3235 + * @freq: frequency the frame was received on 3236 + * @gfp: allocation flags 3237 + * 3238 + * Use this function to report to userspace when a beacon was 3239 + * received. It is not useful to call this when there is no 3240 + * netdev that is in AP/GO mode. 3241 + */ 3242 + void cfg80211_report_obss_beacon(struct wiphy *wiphy, 3243 + const u8 *frame, size_t len, 3244 + int freq, gfp_t gfp); 3233 3245 3234 3246 /* Logging, debugging and troubleshooting/diagnostic helpers. */ 3235 3247
-8
include/net/ieee80211_radiotap.h
··· 271 271 #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 272 272 273 273 274 - /* Ugly macro to convert literal channel numbers into their mhz equivalents 275 - * There are certianly some conditions that will break this (like feeding it '30') 276 - * but they shouldn't arise since nothing talks on channel 30. */ 277 - #define ieee80211chan2mhz(x) \ 278 - (((x) <= 14) ? \ 279 - (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ 280 - ((x) + 1000) * 5) 281 - 282 274 /* helpers */ 283 275 static inline int ieee80211_get_radiotap_len(unsigned char *data) 284 276 {
+32 -3
include/net/mac80211.h
··· 166 166 * that it is only ever disabled for station mode. 167 167 * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface. 168 168 * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode) 169 + * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode) 169 170 */ 170 171 enum ieee80211_bss_change { 171 172 BSS_CHANGED_ASSOC = 1<<0, ··· 185 184 BSS_CHANGED_QOS = 1<<13, 186 185 BSS_CHANGED_IDLE = 1<<14, 187 186 BSS_CHANGED_SSID = 1<<15, 187 + BSS_CHANGED_AP_PROBE_RESP = 1<<16, 188 188 189 189 /* when adding here, make sure to change ieee80211_reconfig */ 190 190 }; ··· 520 518 * @flags: transmit info flags, defined above 521 519 * @band: the band to transmit on (use for checking for races) 522 520 * @antenna_sel_tx: antenna to use, 0 for automatic diversity 523 - * @pad: padding, ignore 521 + * @ack_frame_id: internal frame ID for TX status, used internally 524 522 * @control: union for control data 525 523 * @status: union for status data 526 524 * @driver_data: array of driver_data pointers ··· 537 535 538 536 u8 antenna_sel_tx; 539 537 540 - /* 2 byte hole */ 541 - u8 pad[2]; 538 + u16 ack_frame_id; 542 539 543 540 union { 544 541 struct { ··· 902 901 * @IEEE80211_KEY_FLAG_SW_MGMT: This flag should be set by the driver for a 903 902 * CCMP key if it requires CCMP encryption of management frames (MFP) to 904 903 * be done in software. 904 + * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver 905 + * for a CCMP key if space should be prepared for the IV, but the IV 906 + * itself should not be generated. Do not set together with 907 + * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. 905 908 */ 906 909 enum ieee80211_key_flags { 907 910 IEEE80211_KEY_FLAG_WMM_STA = 1<<0, ··· 913 908 IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2, 914 909 IEEE80211_KEY_FLAG_PAIRWISE = 1<<3, 915 910 IEEE80211_KEY_FLAG_SW_MGMT = 1<<4, 911 + IEEE80211_KEY_FLAG_PUT_IV_SPACE = 1<<5, 916 912 }; 917 913 918 914 /** ··· 1308 1302 return NULL; 1309 1303 return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[idx + 1].idx]; 1310 1304 } 1305 + 1306 + /** 1307 + * ieee80211_free_txskb - free TX skb 1308 + * @hw: the hardware 1309 + * @skb: the skb 1310 + * 1311 + * Free a transmit skb. Use this funtion when some failure 1312 + * to transmit happened and thus status cannot be reported. 1313 + */ 1314 + void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); 1311 1315 1312 1316 /** 1313 1317 * DOC: Hardware crypto acceleration ··· 2675 2659 { 2676 2660 return ieee80211_beacon_get_tim(hw, vif, NULL, NULL); 2677 2661 } 2662 + 2663 + /** 2664 + * ieee80211_proberesp_get - retrieve a Probe Response template 2665 + * @hw: pointer obtained from ieee80211_alloc_hw(). 2666 + * @vif: &struct ieee80211_vif pointer from the add_interface callback. 2667 + * 2668 + * Creates a Probe Response template which can, for example, be uploaded to 2669 + * hardware. The destination address should be set by the caller. 2670 + * 2671 + * Can only be called in AP mode. 2672 + */ 2673 + struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw, 2674 + struct ieee80211_vif *vif); 2678 2675 2679 2676 /** 2680 2677 * ieee80211_pspoll_get - retrieve a PS Poll template
+58 -51
include/net/nfc/nci.h
··· 36 36 /* NCI Status Codes */ 37 37 #define NCI_STATUS_OK 0x00 38 38 #define NCI_STATUS_REJECTED 0x01 39 - #define NCI_STATUS_MESSAGE_CORRUPTED 0x02 40 - #define NCI_STATUS_BUFFER_FULL 0x03 41 - #define NCI_STATUS_FAILED 0x04 42 - #define NCI_STATUS_NOT_INITIALIZED 0x05 43 - #define NCI_STATUS_SYNTAX_ERROR 0x06 44 - #define NCI_STATUS_SEMANTIC_ERROR 0x07 45 - #define NCI_STATUS_UNKNOWN_GID 0x08 46 - #define NCI_STATUS_UNKNOWN_OID 0x09 47 - #define NCI_STATUS_INVALID_PARAM 0x0a 48 - #define NCI_STATUS_MESSAGE_SIZE_EXCEEDED 0x0b 39 + #define NCI_STATUS_RF_FRAME_CORRUPTED 0x02 40 + #define NCI_STATUS_FAILED 0x03 41 + #define NCI_STATUS_NOT_INITIALIZED 0x04 42 + #define NCI_STATUS_SYNTAX_ERROR 0x05 43 + #define NCI_STATUS_SEMANTIC_ERROR 0x06 44 + #define NCI_STATUS_UNKNOWN_GID 0x07 45 + #define NCI_STATUS_UNKNOWN_OID 0x08 46 + #define NCI_STATUS_INVALID_PARAM 0x09 47 + #define NCI_STATUS_MESSAGE_SIZE_EXCEEDED 0x0a 49 48 /* Discovery Specific Status Codes */ 50 49 #define NCI_STATUS_DISCOVERY_ALREADY_STARTED 0xa0 51 50 #define NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED 0xa1 51 + #define NCI_STATUS_DISCOVERY_TEAR_DOWN 0xa2 52 52 /* RF Interface Specific Status Codes */ 53 53 #define NCI_STATUS_RF_TRANSMISSION_ERROR 0xb0 54 54 #define NCI_STATUS_RF_PROTOCOL_ERROR 0xb1 55 55 #define NCI_STATUS_RF_TIMEOUT_ERROR 0xb2 56 - #define NCI_STATUS_RF_LINK_LOSS_ERROR 0xb3 57 56 /* NFCEE Interface Specific Status Codes */ 58 57 #define NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED 0xc0 59 58 #define NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED 0xc1 ··· 72 73 #define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83 73 74 #define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85 74 75 76 + /* NCI RF Technologies */ 77 + #define NCI_NFC_RF_TECHNOLOGY_A 0x00 78 + #define NCI_NFC_RF_TECHNOLOGY_B 0x01 79 + #define NCI_NFC_RF_TECHNOLOGY_F 0x02 80 + #define NCI_NFC_RF_TECHNOLOGY_15693 0x03 81 + 82 + /* NCI Bit Rates */ 83 + #define NCI_NFC_BIT_RATE_106 0x00 84 + #define NCI_NFC_BIT_RATE_212 0x01 85 + #define NCI_NFC_BIT_RATE_424 0x02 86 + #define NCI_NFC_BIT_RATE_848 0x03 87 + #define NCI_NFC_BIT_RATE_1696 0x04 88 + #define NCI_NFC_BIT_RATE_3392 0x05 89 + #define NCI_NFC_BIT_RATE_6784 0x06 90 + 75 91 /* NCI RF Protocols */ 76 92 #define NCI_RF_PROTOCOL_UNKNOWN 0x00 77 93 #define NCI_RF_PROTOCOL_T1T 0x01 ··· 96 82 #define NCI_RF_PROTOCOL_NFC_DEP 0x05 97 83 98 84 /* NCI RF Interfaces */ 99 - #define NCI_RF_INTERFACE_RFU 0x00 85 + #define NCI_RF_INTERFACE_NFCEE_DIRECT 0x00 100 86 #define NCI_RF_INTERFACE_FRAME 0x01 101 87 #define NCI_RF_INTERFACE_ISO_DEP 0x02 102 88 #define NCI_RF_INTERFACE_NFC_DEP 0x03 89 + 90 + /* NCI Reset types */ 91 + #define NCI_RESET_TYPE_KEEP_CONFIG 0x00 92 + #define NCI_RESET_TYPE_RESET_CONFIG 0x01 93 + 94 + /* NCI Static RF connection ID */ 95 + #define NCI_STATIC_RF_CONN_ID 0x00 96 + 97 + /* NCI Data Flow Control */ 98 + #define NCI_DATA_FLOW_CONTROL_NOT_USED 0xff 103 99 104 100 /* NCI RF_DISCOVER_MAP_CMD modes */ 105 101 #define NCI_DISC_MAP_MODE_POLL 0x01 ··· 122 98 #define NCI_DISCOVERY_TYPE_POLL_F_PASSIVE 0x02 123 99 #define NCI_DISCOVERY_TYPE_POLL_A_ACTIVE 0x03 124 100 #define NCI_DISCOVERY_TYPE_POLL_F_ACTIVE 0x05 125 - #define NCI_DISCOVERY_TYPE_WAKEUP_A_PASSIVE 0x06 126 - #define NCI_DISCOVERY_TYPE_WAKEUP_B_PASSIVE 0x07 127 101 #define NCI_DISCOVERY_TYPE_WAKEUP_A_ACTIVE 0x09 128 102 #define NCI_DISCOVERY_TYPE_LISTEN_A_PASSIVE 0x80 129 103 #define NCI_DISCOVERY_TYPE_LISTEN_B_PASSIVE 0x81 ··· 133 111 #define NCI_DEACTIVATE_TYPE_IDLE_MODE 0x00 134 112 #define NCI_DEACTIVATE_TYPE_SLEEP_MODE 0x01 135 113 #define NCI_DEACTIVATE_TYPE_SLEEP_AF_MODE 0x02 136 - #define NCI_DEACTIVATE_TYPE_RF_LINK_LOSS 0x03 137 - #define NCI_DEACTIVATE_TYPE_DISCOVERY_ERROR 0x04 114 + #define NCI_DEACTIVATE_TYPE_DISCOVERY 0x03 138 115 139 116 /* Message Type (MT) */ 140 117 #define NCI_MT_DATA_PKT 0x00 ··· 190 169 /* ----- NCI Commands ---- */ 191 170 /* ------------------------ */ 192 171 #define NCI_OP_CORE_RESET_CMD nci_opcode_pack(NCI_GID_CORE, 0x00) 193 - 194 - #define NCI_OP_CORE_INIT_CMD nci_opcode_pack(NCI_GID_CORE, 0x01) 195 - 196 - #define NCI_OP_CORE_SET_CONFIG_CMD nci_opcode_pack(NCI_GID_CORE, 0x02) 197 - 198 - #define NCI_OP_CORE_CONN_CREATE_CMD nci_opcode_pack(NCI_GID_CORE, 0x04) 199 - struct nci_core_conn_create_cmd { 200 - __u8 target_handle; 201 - __u8 num_target_specific_params; 172 + struct nci_core_reset_cmd { 173 + __u8 reset_type; 202 174 } __packed; 203 175 204 - #define NCI_OP_CORE_CONN_CLOSE_CMD nci_opcode_pack(NCI_GID_CORE, 0x06) 176 + #define NCI_OP_CORE_INIT_CMD nci_opcode_pack(NCI_GID_CORE, 0x01) 205 177 206 178 #define NCI_OP_RF_DISCOVER_MAP_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x00) 207 179 struct disc_map_config { ··· 232 218 struct nci_core_reset_rsp { 233 219 __u8 status; 234 220 __u8 nci_ver; 221 + __u8 config_status; 235 222 } __packed; 236 223 237 224 #define NCI_OP_CORE_INIT_RSP nci_opcode_pack(NCI_GID_CORE, 0x01) ··· 247 232 struct nci_core_init_rsp_2 { 248 233 __u8 max_logical_connections; 249 234 __le16 max_routing_table_size; 250 - __u8 max_control_packet_payload_length; 251 - __le16 rf_sending_buffer_size; 252 - __le16 rf_receiving_buffer_size; 253 - __le16 manufacturer_id; 254 - } __packed; 255 - 256 - #define NCI_OP_CORE_SET_CONFIG_RSP nci_opcode_pack(NCI_GID_CORE, 0x02) 257 - 258 - #define NCI_OP_CORE_CONN_CREATE_RSP nci_opcode_pack(NCI_GID_CORE, 0x04) 259 - struct nci_core_conn_create_rsp { 260 - __u8 status; 261 - __u8 max_pkt_payload_size; 235 + __u8 max_ctrl_pkt_payload_len; 236 + __le16 max_size_for_large_params; 237 + __u8 max_data_pkt_payload_size; 262 238 __u8 initial_num_credits; 263 - __u8 conn_id; 239 + __u8 manufact_id; 240 + __le32 manufact_specific_info; 264 241 } __packed; 265 - 266 - #define NCI_OP_CORE_CONN_CLOSE_RSP nci_opcode_pack(NCI_GID_CORE, 0x06) 267 242 268 243 #define NCI_OP_RF_DISCOVER_MAP_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x00) 269 244 ··· 275 270 struct conn_credit_entry conn_entries[NCI_MAX_NUM_CONN]; 276 271 } __packed; 277 272 278 - #define NCI_OP_RF_FIELD_INFO_NTF nci_opcode_pack(NCI_GID_CORE, 0x08) 279 - struct nci_rf_field_info_ntf { 280 - __u8 rf_field_status; 281 - } __packed; 282 - 283 - #define NCI_OP_RF_ACTIVATE_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) 273 + #define NCI_OP_RF_INTF_ACTIVATED_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) 284 274 struct rf_tech_specific_params_nfca_poll { 285 275 __u16 sens_res; 286 276 __u8 nfcid1_len; /* 0, 4, 7, or 10 Bytes */ ··· 289 289 __u8 rats_res[20]; 290 290 }; 291 291 292 - struct nci_rf_activate_ntf { 293 - __u8 target_handle; 292 + struct nci_rf_intf_activated_ntf { 293 + __u8 rf_discovery_id; 294 + __u8 rf_interface_type; 294 295 __u8 rf_protocol; 295 - __u8 rf_tech_and_mode; 296 + __u8 activation_rf_tech_and_mode; 296 297 __u8 rf_tech_specific_params_len; 297 298 298 299 union { 299 300 struct rf_tech_specific_params_nfca_poll nfca_poll; 300 301 } rf_tech_specific_params; 301 302 302 - __u8 rf_interface_type; 303 + __u8 data_exch_rf_tech_and_mode; 304 + __u8 data_exch_tx_bit_rate; 305 + __u8 data_exch_rx_bit_rate; 303 306 __u8 activation_params_len; 304 307 305 308 union { ··· 312 309 } __packed; 313 310 314 311 #define NCI_OP_RF_DEACTIVATE_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) 312 + struct nci_rf_deactivate_ntf { 313 + __u8 type; 314 + __u8 reason; 315 + } __packed; 315 316 316 317 #endif /* __NCI_H */
+5 -8
include/net/nfc/nci_core.h
··· 109 109 [NCI_MAX_SUPPORTED_RF_INTERFACES]; 110 110 __u8 max_logical_connections; 111 111 __u16 max_routing_table_size; 112 - __u8 max_control_packet_payload_length; 113 - __u16 rf_sending_buffer_size; 114 - __u16 rf_receiving_buffer_size; 115 - __u16 manufacturer_id; 116 - 117 - /* received during NCI_OP_CORE_CONN_CREATE_RSP for static conn 0 */ 118 - __u8 max_pkt_payload_size; 112 + __u8 max_ctrl_pkt_payload_len; 113 + __u16 max_size_for_large_params; 114 + __u8 max_data_pkt_payload_size; 119 115 __u8 initial_num_credits; 120 - __u8 conn_id; 116 + __u8 manufact_id; 117 + __u32 manufact_specific_info; 121 118 122 119 /* stored during nci_data_exchange */ 123 120 data_exchange_cb_t data_exchange_cb;
+6
include/net/sock.h
··· 563 563 SOCK_FASYNC, /* fasync() active */ 564 564 SOCK_RXQ_OVFL, 565 565 SOCK_ZEROCOPY, /* buffers from userspace */ 566 + SOCK_WIFI_STATUS, /* push wifi status to userspace */ 566 567 }; 567 568 568 569 static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) ··· 1715 1714 1716 1715 extern void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, 1717 1716 struct sk_buff *skb); 1717 + extern void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, 1718 + struct sk_buff *skb); 1718 1719 1719 1720 static __inline__ void 1720 1721 sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) ··· 1744 1741 __sock_recv_timestamp(msg, sk, skb); 1745 1742 else 1746 1743 sk->sk_stamp = kt; 1744 + 1745 + if (sock_flag(sk, SOCK_WIFI_STATUS) && skb->wifi_acked_valid) 1746 + __sock_recv_wifi_status(msg, sk, skb); 1747 1747 } 1748 1748 1749 1749 extern void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
+4 -9
net/bluetooth/bnep/core.c
··· 65 65 static struct bnep_session *__bnep_get_session(u8 *dst) 66 66 { 67 67 struct bnep_session *s; 68 - struct list_head *p; 69 68 70 69 BT_DBG(""); 71 70 72 - list_for_each(p, &bnep_session_list) { 73 - s = list_entry(p, struct bnep_session, list); 71 + list_for_each_entry(s, &bnep_session_list, list) 74 72 if (!compare_ether_addr(dst, s->eh.h_source)) 75 73 return s; 76 - } 74 + 77 75 return NULL; 78 76 } 79 77 ··· 665 667 666 668 int bnep_get_connlist(struct bnep_connlist_req *req) 667 669 { 668 - struct list_head *p; 670 + struct bnep_session *s; 669 671 int err = 0, n = 0; 670 672 671 673 down_read(&bnep_session_sem); 672 674 673 - list_for_each(p, &bnep_session_list) { 674 - struct bnep_session *s; 675 + list_for_each_entry(s, &bnep_session_list, list) { 675 676 struct bnep_conninfo ci; 676 - 677 - s = list_entry(p, struct bnep_session, list); 678 677 679 678 __bnep_copy_ci(&ci, s); 680 679
+4 -9
net/bluetooth/cmtp/core.c
··· 53 53 static struct cmtp_session *__cmtp_get_session(bdaddr_t *bdaddr) 54 54 { 55 55 struct cmtp_session *session; 56 - struct list_head *p; 57 56 58 57 BT_DBG(""); 59 58 60 - list_for_each(p, &cmtp_session_list) { 61 - session = list_entry(p, struct cmtp_session, list); 59 + list_for_each_entry(session, &cmtp_session_list, list) 62 60 if (!bacmp(bdaddr, &session->bdaddr)) 63 61 return session; 64 - } 62 + 65 63 return NULL; 66 64 } 67 65 ··· 429 431 430 432 int cmtp_get_connlist(struct cmtp_connlist_req *req) 431 433 { 432 - struct list_head *p; 434 + struct cmtp_session *session; 433 435 int err = 0, n = 0; 434 436 435 437 BT_DBG(""); 436 438 437 439 down_read(&cmtp_session_sem); 438 440 439 - list_for_each(p, &cmtp_session_list) { 440 - struct cmtp_session *session; 441 + list_for_each_entry(session, &cmtp_session_list, list) { 441 442 struct cmtp_conninfo ci; 442 - 443 - session = list_entry(p, struct cmtp_session, list); 444 443 445 444 __cmtp_copy_session(session, &ci); 446 445
+59 -12
net/bluetooth/hci_conn.c
··· 374 374 375 375 skb_queue_head_init(&conn->data_q); 376 376 377 + hci_chan_hash_init(conn); 378 + 377 379 setup_timer(&conn->disc_timer, hci_conn_timeout, (unsigned long)conn); 378 380 setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn); 379 381 setup_timer(&conn->auto_accept_timer, hci_conn_auto_accept, ··· 434 432 435 433 tasklet_disable(&hdev->tx_task); 436 434 435 + hci_chan_hash_flush(conn); 436 + 437 437 hci_conn_hash_del(hdev, conn); 438 438 if (hdev->notify) 439 439 hdev->notify(hdev, HCI_NOTIFY_CONN_DEL); ··· 457 453 struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) 458 454 { 459 455 int use_src = bacmp(src, BDADDR_ANY); 460 - struct hci_dev *hdev = NULL; 461 - struct list_head *p; 456 + struct hci_dev *hdev = NULL, *d; 462 457 463 458 BT_DBG("%s -> %s", batostr(src), batostr(dst)); 464 459 465 460 read_lock_bh(&hci_dev_list_lock); 466 461 467 - list_for_each(p, &hci_dev_list) { 468 - struct hci_dev *d = list_entry(p, struct hci_dev, list); 469 - 462 + list_for_each_entry(d, &hci_dev_list, list) { 470 463 if (!test_bit(HCI_UP, &d->flags) || test_bit(HCI_RAW, &d->flags)) 471 464 continue; 472 465 ··· 674 673 goto encrypt; 675 674 676 675 auth: 677 - if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) 676 + if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) 678 677 return 0; 679 678 680 679 if (!hci_conn_auth(conn, sec_level, auth_type)) ··· 820 819 821 820 c->state = BT_CLOSED; 822 821 823 - hci_proto_disconn_cfm(c, 0x16); 822 + hci_proto_disconn_cfm(c, HCI_ERROR_LOCAL_HOST_TERM); 824 823 hci_conn_del(c); 825 824 } 826 825 } ··· 856 855 857 856 int hci_get_conn_list(void __user *arg) 858 857 { 858 + register struct hci_conn *c; 859 859 struct hci_conn_list_req req, *cl; 860 860 struct hci_conn_info *ci; 861 861 struct hci_dev *hdev; 862 - struct list_head *p; 863 862 int n = 0, size, err; 864 863 865 864 if (copy_from_user(&req, arg, sizeof(req))) ··· 883 882 ci = cl->conn_info; 884 883 885 884 hci_dev_lock_bh(hdev); 886 - list_for_each(p, &hdev->conn_hash.list) { 887 - register struct hci_conn *c; 888 - c = list_entry(p, struct hci_conn, list); 889 - 885 + list_for_each_entry(c, &hdev->conn_hash.list, list) { 890 886 bacpy(&(ci + n)->bdaddr, &c->dst); 891 887 (ci + n)->handle = c->handle; 892 888 (ci + n)->type = c->type; ··· 953 955 return -ENOENT; 954 956 955 957 return copy_to_user(arg, &req, sizeof(req)) ? -EFAULT : 0; 958 + } 959 + 960 + struct hci_chan *hci_chan_create(struct hci_conn *conn) 961 + { 962 + struct hci_dev *hdev = conn->hdev; 963 + struct hci_chan *chan; 964 + 965 + BT_DBG("%s conn %p", hdev->name, conn); 966 + 967 + chan = kzalloc(sizeof(struct hci_chan), GFP_ATOMIC); 968 + if (!chan) 969 + return NULL; 970 + 971 + chan->conn = conn; 972 + skb_queue_head_init(&chan->data_q); 973 + 974 + tasklet_disable(&hdev->tx_task); 975 + hci_chan_hash_add(conn, chan); 976 + tasklet_enable(&hdev->tx_task); 977 + 978 + return chan; 979 + } 980 + 981 + int hci_chan_del(struct hci_chan *chan) 982 + { 983 + struct hci_conn *conn = chan->conn; 984 + struct hci_dev *hdev = conn->hdev; 985 + 986 + BT_DBG("%s conn %p chan %p", hdev->name, conn, chan); 987 + 988 + tasklet_disable(&hdev->tx_task); 989 + hci_chan_hash_del(conn, chan); 990 + tasklet_enable(&hdev->tx_task); 991 + 992 + skb_queue_purge(&chan->data_q); 993 + kfree(chan); 994 + 995 + return 0; 996 + } 997 + 998 + void hci_chan_hash_flush(struct hci_conn *conn) 999 + { 1000 + struct hci_chan_hash *h = &conn->chan_hash; 1001 + struct hci_chan *chan, *tmp; 1002 + 1003 + BT_DBG("conn %p", conn); 1004 + 1005 + list_for_each_entry_safe(chan, tmp, &h->list, list) 1006 + hci_chan_del(chan); 956 1007 }
+303 -96
net/bluetooth/hci_core.c
··· 319 319 * Device is held on return. */ 320 320 struct hci_dev *hci_dev_get(int index) 321 321 { 322 - struct hci_dev *hdev = NULL; 323 - struct list_head *p; 322 + struct hci_dev *hdev = NULL, *d; 324 323 325 324 BT_DBG("%d", index); 326 325 ··· 327 328 return NULL; 328 329 329 330 read_lock(&hci_dev_list_lock); 330 - list_for_each(p, &hci_dev_list) { 331 - struct hci_dev *d = list_entry(p, struct hci_dev, list); 331 + list_for_each_entry(d, &hci_dev_list, list) { 332 332 if (d->id == index) { 333 333 hdev = hci_dev_hold(d); 334 334 break; ··· 549 551 hci_dev_hold(hdev); 550 552 set_bit(HCI_UP, &hdev->flags); 551 553 hci_notify(hdev, HCI_DEV_UP); 552 - if (!test_bit(HCI_SETUP, &hdev->flags)) 553 - mgmt_powered(hdev->id, 1); 554 + if (!test_bit(HCI_SETUP, &hdev->flags)) { 555 + hci_dev_lock_bh(hdev); 556 + mgmt_powered(hdev, 1); 557 + hci_dev_unlock_bh(hdev); 558 + } 554 559 } else { 555 560 /* Init failed, cleanup */ 556 561 tasklet_kill(&hdev->rx_task); ··· 598 597 tasklet_kill(&hdev->rx_task); 599 598 tasklet_kill(&hdev->tx_task); 600 599 600 + if (hdev->discov_timeout > 0) { 601 + cancel_delayed_work(&hdev->discov_off); 602 + hdev->discov_timeout = 0; 603 + } 604 + 605 + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) 606 + cancel_delayed_work(&hdev->power_off); 607 + 601 608 hci_dev_lock_bh(hdev); 602 609 inquiry_cache_flush(hdev); 603 610 hci_conn_hash_flush(hdev); ··· 645 636 * and no tasks are scheduled. */ 646 637 hdev->close(hdev); 647 638 648 - mgmt_powered(hdev->id, 0); 639 + hci_dev_lock_bh(hdev); 640 + mgmt_powered(hdev, 0); 641 + hci_dev_unlock_bh(hdev); 649 642 650 643 /* Clear flags */ 651 644 hdev->flags = 0; ··· 805 794 806 795 int hci_get_dev_list(void __user *arg) 807 796 { 797 + struct hci_dev *hdev; 808 798 struct hci_dev_list_req *dl; 809 799 struct hci_dev_req *dr; 810 - struct list_head *p; 811 800 int n = 0, size, err; 812 801 __u16 dev_num; 813 802 ··· 826 815 dr = dl->dev_req; 827 816 828 817 read_lock_bh(&hci_dev_list_lock); 829 - list_for_each(p, &hci_dev_list) { 830 - struct hci_dev *hdev; 831 - 832 - hdev = list_entry(p, struct hci_dev, list); 833 - 834 - hci_del_off_timer(hdev); 818 + list_for_each_entry(hdev, &hci_dev_list, list) { 819 + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) 820 + cancel_delayed_work(&hdev->power_off); 835 821 836 822 if (!test_bit(HCI_MGMT, &hdev->flags)) 837 823 set_bit(HCI_PAIRABLE, &hdev->flags); ··· 863 855 if (!hdev) 864 856 return -ENODEV; 865 857 866 - hci_del_off_timer(hdev); 858 + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) 859 + cancel_delayed_work_sync(&hdev->power_off); 867 860 868 861 if (!test_bit(HCI_MGMT, &hdev->flags)) 869 862 set_bit(HCI_PAIRABLE, &hdev->flags); ··· 921 912 if (!hdev) 922 913 return NULL; 923 914 915 + hci_init_sysfs(hdev); 924 916 skb_queue_head_init(&hdev->driver_init); 925 917 926 918 return hdev; ··· 948 938 return; 949 939 950 940 if (test_bit(HCI_AUTO_OFF, &hdev->flags)) 951 - mod_timer(&hdev->off_timer, 952 - jiffies + msecs_to_jiffies(AUTO_OFF_TIMEOUT)); 941 + queue_delayed_work(hdev->workqueue, &hdev->power_off, 942 + msecs_to_jiffies(AUTO_OFF_TIMEOUT)); 953 943 954 944 if (test_and_clear_bit(HCI_SETUP, &hdev->flags)) 955 - mgmt_index_added(hdev->id); 945 + mgmt_index_added(hdev); 956 946 } 957 947 958 948 static void hci_power_off(struct work_struct *work) 959 949 { 960 - struct hci_dev *hdev = container_of(work, struct hci_dev, power_off); 950 + struct hci_dev *hdev = container_of(work, struct hci_dev, 951 + power_off.work); 961 952 962 953 BT_DBG("%s", hdev->name); 954 + 955 + clear_bit(HCI_AUTO_OFF, &hdev->flags); 963 956 964 957 hci_dev_close(hdev->id); 965 958 } 966 959 967 - static void hci_auto_off(unsigned long data) 960 + static void hci_discov_off(struct work_struct *work) 968 961 { 969 - struct hci_dev *hdev = (struct hci_dev *) data; 962 + struct hci_dev *hdev; 963 + u8 scan = SCAN_PAGE; 964 + 965 + hdev = container_of(work, struct hci_dev, discov_off.work); 970 966 971 967 BT_DBG("%s", hdev->name); 972 968 973 - clear_bit(HCI_AUTO_OFF, &hdev->flags); 969 + hci_dev_lock_bh(hdev); 974 970 975 - queue_work(hdev->workqueue, &hdev->power_off); 976 - } 971 + hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, sizeof(scan), &scan); 977 972 978 - void hci_del_off_timer(struct hci_dev *hdev) 979 - { 980 - BT_DBG("%s", hdev->name); 973 + hdev->discov_timeout = 0; 981 974 982 - clear_bit(HCI_AUTO_OFF, &hdev->flags); 983 - del_timer(&hdev->off_timer); 975 + hci_dev_unlock_bh(hdev); 984 976 } 985 977 986 978 int hci_uuids_clear(struct hci_dev *hdev) ··· 1019 1007 1020 1008 struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr) 1021 1009 { 1022 - struct list_head *p; 1010 + struct link_key *k; 1023 1011 1024 - list_for_each(p, &hdev->link_keys) { 1025 - struct link_key *k; 1026 - 1027 - k = list_entry(p, struct link_key, list); 1028 - 1012 + list_for_each_entry(k, &hdev->link_keys, list) 1029 1013 if (bacmp(bdaddr, &k->bdaddr) == 0) 1030 1014 return k; 1031 - } 1032 1015 1033 1016 return NULL; 1034 1017 } ··· 1145 1138 1146 1139 persistent = hci_persistent_key(hdev, conn, type, old_key_type); 1147 1140 1148 - mgmt_new_key(hdev->id, key, persistent); 1141 + mgmt_new_link_key(hdev, key, persistent); 1149 1142 1150 1143 if (!persistent) { 1151 1144 list_del(&key->list); ··· 1188 1181 memcpy(id->rand, rand, sizeof(id->rand)); 1189 1182 1190 1183 if (new_key) 1191 - mgmt_new_key(hdev->id, key, old_key_type); 1184 + mgmt_new_link_key(hdev, key, old_key_type); 1192 1185 1193 1186 return 0; 1194 1187 } ··· 1286 1279 struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, 1287 1280 bdaddr_t *bdaddr) 1288 1281 { 1289 - struct list_head *p; 1282 + struct bdaddr_list *b; 1290 1283 1291 - list_for_each(p, &hdev->blacklist) { 1292 - struct bdaddr_list *b; 1293 - 1294 - b = list_entry(p, struct bdaddr_list, list); 1295 - 1284 + list_for_each_entry(b, &hdev->blacklist, list) 1296 1285 if (bacmp(bdaddr, &b->bdaddr) == 0) 1297 1286 return b; 1298 - } 1299 1287 1300 1288 return NULL; 1301 1289 } ··· 1329 1327 1330 1328 list_add(&entry->list, &hdev->blacklist); 1331 1329 1332 - return mgmt_device_blocked(hdev->id, bdaddr); 1330 + return mgmt_device_blocked(hdev, bdaddr); 1333 1331 } 1334 1332 1335 1333 int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr) ··· 1348 1346 list_del(&entry->list); 1349 1347 kfree(entry); 1350 1348 1351 - return mgmt_device_unblocked(hdev->id, bdaddr); 1349 + return mgmt_device_unblocked(hdev, bdaddr); 1352 1350 } 1353 1351 1354 1352 static void hci_clear_adv_cache(unsigned long arg) ··· 1427 1425 int hci_register_dev(struct hci_dev *hdev) 1428 1426 { 1429 1427 struct list_head *head = &hci_dev_list, *p; 1430 - int i, id = 0; 1428 + int i, id, error; 1431 1429 1432 1430 BT_DBG("%p name %s bus %d owner %p", hdev, hdev->name, 1433 1431 hdev->bus, hdev->owner); 1434 1432 1435 1433 if (!hdev->open || !hdev->close || !hdev->destruct) 1436 1434 return -EINVAL; 1435 + 1436 + /* Do not allow HCI_AMP devices to register at index 0, 1437 + * so the index can be used as the AMP controller ID. 1438 + */ 1439 + id = (hdev->dev_type == HCI_BREDR) ? 0 : 1; 1437 1440 1438 1441 write_lock_bh(&hci_dev_list_lock); 1439 1442 ··· 1486 1479 1487 1480 hci_conn_hash_init(hdev); 1488 1481 1482 + INIT_LIST_HEAD(&hdev->mgmt_pending); 1483 + 1489 1484 INIT_LIST_HEAD(&hdev->blacklist); 1490 1485 1491 1486 INIT_LIST_HEAD(&hdev->uuids); ··· 1501 1492 (unsigned long) hdev); 1502 1493 1503 1494 INIT_WORK(&hdev->power_on, hci_power_on); 1504 - INIT_WORK(&hdev->power_off, hci_power_off); 1505 - setup_timer(&hdev->off_timer, hci_auto_off, (unsigned long) hdev); 1495 + INIT_DELAYED_WORK(&hdev->power_off, hci_power_off); 1496 + 1497 + INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off); 1506 1498 1507 1499 memset(&hdev->stat, 0, sizeof(struct hci_dev_stats)); 1508 1500 ··· 1512 1502 write_unlock_bh(&hci_dev_list_lock); 1513 1503 1514 1504 hdev->workqueue = create_singlethread_workqueue(hdev->name); 1515 - if (!hdev->workqueue) 1516 - goto nomem; 1505 + if (!hdev->workqueue) { 1506 + error = -ENOMEM; 1507 + goto err; 1508 + } 1517 1509 1518 - hci_register_sysfs(hdev); 1510 + error = hci_add_sysfs(hdev); 1511 + if (error < 0) 1512 + goto err_wqueue; 1519 1513 1520 1514 hdev->rfkill = rfkill_alloc(hdev->name, &hdev->dev, 1521 1515 RFKILL_TYPE_BLUETOOTH, &hci_rfkill_ops, hdev); ··· 1538 1524 1539 1525 return id; 1540 1526 1541 - nomem: 1527 + err_wqueue: 1528 + destroy_workqueue(hdev->workqueue); 1529 + err: 1542 1530 write_lock_bh(&hci_dev_list_lock); 1543 1531 list_del(&hdev->list); 1544 1532 write_unlock_bh(&hci_dev_list_lock); 1545 1533 1546 - return -ENOMEM; 1534 + return error; 1547 1535 } 1548 1536 EXPORT_SYMBOL(hci_register_dev); 1549 1537 1550 1538 /* Unregister HCI device */ 1551 - int hci_unregister_dev(struct hci_dev *hdev) 1539 + void hci_unregister_dev(struct hci_dev *hdev) 1552 1540 { 1553 1541 int i; 1554 1542 ··· 1566 1550 kfree_skb(hdev->reassembly[i]); 1567 1551 1568 1552 if (!test_bit(HCI_INIT, &hdev->flags) && 1569 - !test_bit(HCI_SETUP, &hdev->flags)) 1570 - mgmt_index_removed(hdev->id); 1553 + !test_bit(HCI_SETUP, &hdev->flags)) { 1554 + hci_dev_lock_bh(hdev); 1555 + mgmt_index_removed(hdev); 1556 + hci_dev_unlock_bh(hdev); 1557 + } 1558 + 1559 + /* mgmt_index_removed should take care of emptying the 1560 + * pending list */ 1561 + BUG_ON(!list_empty(&hdev->mgmt_pending)); 1571 1562 1572 1563 hci_notify(hdev, HCI_DEV_UNREG); 1573 1564 ··· 1583 1560 rfkill_destroy(hdev->rfkill); 1584 1561 } 1585 1562 1586 - hci_unregister_sysfs(hdev); 1563 + hci_del_sysfs(hdev); 1587 1564 1588 - hci_del_off_timer(hdev); 1589 1565 del_timer(&hdev->adv_timer); 1590 1566 1591 1567 destroy_workqueue(hdev->workqueue); ··· 1598 1576 hci_dev_unlock_bh(hdev); 1599 1577 1600 1578 __hci_dev_put(hdev); 1601 - 1602 - return 0; 1603 1579 } 1604 1580 EXPORT_SYMBOL(hci_unregister_dev); 1605 1581 ··· 1968 1948 hdr->dlen = cpu_to_le16(len); 1969 1949 } 1970 1950 1971 - void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags) 1951 + static void hci_queue_acl(struct hci_conn *conn, struct sk_buff_head *queue, 1952 + struct sk_buff *skb, __u16 flags) 1972 1953 { 1973 1954 struct hci_dev *hdev = conn->hdev; 1974 1955 struct sk_buff *list; 1975 - 1976 - BT_DBG("%s conn %p flags 0x%x", hdev->name, conn, flags); 1977 - 1978 - skb->dev = (void *) hdev; 1979 - bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; 1980 - hci_add_acl_hdr(skb, conn->handle, flags); 1981 1956 1982 1957 list = skb_shinfo(skb)->frag_list; 1983 1958 if (!list) { 1984 1959 /* Non fragmented */ 1985 1960 BT_DBG("%s nonfrag skb %p len %d", hdev->name, skb, skb->len); 1986 1961 1987 - skb_queue_tail(&conn->data_q, skb); 1962 + skb_queue_tail(queue, skb); 1988 1963 } else { 1989 1964 /* Fragmented */ 1990 1965 BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len); ··· 1987 1972 skb_shinfo(skb)->frag_list = NULL; 1988 1973 1989 1974 /* Queue all fragments atomically */ 1990 - spin_lock_bh(&conn->data_q.lock); 1975 + spin_lock_bh(&queue->lock); 1991 1976 1992 - __skb_queue_tail(&conn->data_q, skb); 1977 + __skb_queue_tail(queue, skb); 1993 1978 1994 1979 flags &= ~ACL_START; 1995 1980 flags |= ACL_CONT; ··· 2002 1987 2003 1988 BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len); 2004 1989 2005 - __skb_queue_tail(&conn->data_q, skb); 1990 + __skb_queue_tail(queue, skb); 2006 1991 } while (list); 2007 1992 2008 - spin_unlock_bh(&conn->data_q.lock); 1993 + spin_unlock_bh(&queue->lock); 2009 1994 } 1995 + } 1996 + 1997 + void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags) 1998 + { 1999 + struct hci_conn *conn = chan->conn; 2000 + struct hci_dev *hdev = conn->hdev; 2001 + 2002 + BT_DBG("%s chan %p flags 0x%x", hdev->name, chan, flags); 2003 + 2004 + skb->dev = (void *) hdev; 2005 + bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; 2006 + hci_add_acl_hdr(skb, conn->handle, flags); 2007 + 2008 + hci_queue_acl(conn, &chan->data_q, skb, flags); 2010 2009 2011 2010 tasklet_schedule(&hdev->tx_task); 2012 2011 } ··· 2055 2026 static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int *quote) 2056 2027 { 2057 2028 struct hci_conn_hash *h = &hdev->conn_hash; 2058 - struct hci_conn *conn = NULL; 2029 + struct hci_conn *conn = NULL, *c; 2059 2030 int num = 0, min = ~0; 2060 - struct list_head *p; 2061 2031 2062 2032 /* We don't have to lock device here. Connections are always 2063 2033 * added and removed with TX task disabled. */ 2064 - list_for_each(p, &h->list) { 2065 - struct hci_conn *c; 2066 - c = list_entry(p, struct hci_conn, list); 2067 - 2034 + list_for_each_entry(c, &h->list, list) { 2068 2035 if (c->type != type || skb_queue_empty(&c->data_q)) 2069 2036 continue; 2070 2037 ··· 2109 2084 static inline void hci_link_tx_to(struct hci_dev *hdev, __u8 type) 2110 2085 { 2111 2086 struct hci_conn_hash *h = &hdev->conn_hash; 2112 - struct list_head *p; 2113 - struct hci_conn *c; 2087 + struct hci_conn *c; 2114 2088 2115 2089 BT_ERR("%s link tx timeout", hdev->name); 2116 2090 2117 2091 /* Kill stalled connections */ 2118 - list_for_each(p, &h->list) { 2119 - c = list_entry(p, struct hci_conn, list); 2092 + list_for_each_entry(c, &h->list, list) { 2120 2093 if (c->type == type && c->sent) { 2121 2094 BT_ERR("%s killing stalled connection %s", 2122 2095 hdev->name, batostr(&c->dst)); ··· 2123 2100 } 2124 2101 } 2125 2102 2103 + static inline struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type, 2104 + int *quote) 2105 + { 2106 + struct hci_conn_hash *h = &hdev->conn_hash; 2107 + struct hci_chan *chan = NULL; 2108 + int num = 0, min = ~0, cur_prio = 0; 2109 + struct hci_conn *conn; 2110 + int cnt, q, conn_num = 0; 2111 + 2112 + BT_DBG("%s", hdev->name); 2113 + 2114 + list_for_each_entry(conn, &h->list, list) { 2115 + struct hci_chan_hash *ch; 2116 + struct hci_chan *tmp; 2117 + 2118 + if (conn->type != type) 2119 + continue; 2120 + 2121 + if (conn->state != BT_CONNECTED && conn->state != BT_CONFIG) 2122 + continue; 2123 + 2124 + conn_num++; 2125 + 2126 + ch = &conn->chan_hash; 2127 + 2128 + list_for_each_entry(tmp, &ch->list, list) { 2129 + struct sk_buff *skb; 2130 + 2131 + if (skb_queue_empty(&tmp->data_q)) 2132 + continue; 2133 + 2134 + skb = skb_peek(&tmp->data_q); 2135 + if (skb->priority < cur_prio) 2136 + continue; 2137 + 2138 + if (skb->priority > cur_prio) { 2139 + num = 0; 2140 + min = ~0; 2141 + cur_prio = skb->priority; 2142 + } 2143 + 2144 + num++; 2145 + 2146 + if (conn->sent < min) { 2147 + min = conn->sent; 2148 + chan = tmp; 2149 + } 2150 + } 2151 + 2152 + if (hci_conn_num(hdev, type) == conn_num) 2153 + break; 2154 + } 2155 + 2156 + if (!chan) 2157 + return NULL; 2158 + 2159 + switch (chan->conn->type) { 2160 + case ACL_LINK: 2161 + cnt = hdev->acl_cnt; 2162 + break; 2163 + case SCO_LINK: 2164 + case ESCO_LINK: 2165 + cnt = hdev->sco_cnt; 2166 + break; 2167 + case LE_LINK: 2168 + cnt = hdev->le_mtu ? hdev->le_cnt : hdev->acl_cnt; 2169 + break; 2170 + default: 2171 + cnt = 0; 2172 + BT_ERR("Unknown link type"); 2173 + } 2174 + 2175 + q = cnt / num; 2176 + *quote = q ? q : 1; 2177 + BT_DBG("chan %p quote %d", chan, *quote); 2178 + return chan; 2179 + } 2180 + 2181 + static void hci_prio_recalculate(struct hci_dev *hdev, __u8 type) 2182 + { 2183 + struct hci_conn_hash *h = &hdev->conn_hash; 2184 + struct hci_conn *conn; 2185 + int num = 0; 2186 + 2187 + BT_DBG("%s", hdev->name); 2188 + 2189 + list_for_each_entry(conn, &h->list, list) { 2190 + struct hci_chan_hash *ch; 2191 + struct hci_chan *chan; 2192 + 2193 + if (conn->type != type) 2194 + continue; 2195 + 2196 + if (conn->state != BT_CONNECTED && conn->state != BT_CONFIG) 2197 + continue; 2198 + 2199 + num++; 2200 + 2201 + ch = &conn->chan_hash; 2202 + list_for_each_entry(chan, &ch->list, list) { 2203 + struct sk_buff *skb; 2204 + 2205 + if (chan->sent) { 2206 + chan->sent = 0; 2207 + continue; 2208 + } 2209 + 2210 + if (skb_queue_empty(&chan->data_q)) 2211 + continue; 2212 + 2213 + skb = skb_peek(&chan->data_q); 2214 + if (skb->priority >= HCI_PRIO_MAX - 1) 2215 + continue; 2216 + 2217 + skb->priority = HCI_PRIO_MAX - 1; 2218 + 2219 + BT_DBG("chan %p skb %p promoted to %d", chan, skb, 2220 + skb->priority); 2221 + } 2222 + 2223 + if (hci_conn_num(hdev, type) == num) 2224 + break; 2225 + } 2226 + } 2227 + 2126 2228 static inline void hci_sched_acl(struct hci_dev *hdev) 2127 2229 { 2128 - struct hci_conn *conn; 2230 + struct hci_chan *chan; 2129 2231 struct sk_buff *skb; 2130 2232 int quote; 2233 + unsigned int cnt; 2131 2234 2132 2235 BT_DBG("%s", hdev->name); 2133 2236 ··· 2267 2118 hci_link_tx_to(hdev, ACL_LINK); 2268 2119 } 2269 2120 2270 - while (hdev->acl_cnt && (conn = hci_low_sent(hdev, ACL_LINK, &quote))) { 2271 - while (quote-- && (skb = skb_dequeue(&conn->data_q))) { 2272 - BT_DBG("skb %p len %d", skb, skb->len); 2121 + cnt = hdev->acl_cnt; 2273 2122 2274 - hci_conn_enter_active_mode(conn, bt_cb(skb)->force_active); 2123 + while (hdev->acl_cnt && 2124 + (chan = hci_chan_sent(hdev, ACL_LINK, &quote))) { 2125 + u32 priority = (skb_peek(&chan->data_q))->priority; 2126 + while (quote-- && (skb = skb_peek(&chan->data_q))) { 2127 + BT_DBG("chan %p skb %p len %d priority %u", chan, skb, 2128 + skb->len, skb->priority); 2129 + 2130 + /* Stop if priority has changed */ 2131 + if (skb->priority < priority) 2132 + break; 2133 + 2134 + skb = skb_dequeue(&chan->data_q); 2135 + 2136 + hci_conn_enter_active_mode(chan->conn, 2137 + bt_cb(skb)->force_active); 2275 2138 2276 2139 hci_send_frame(skb); 2277 2140 hdev->acl_last_tx = jiffies; 2278 2141 2279 2142 hdev->acl_cnt--; 2280 - conn->sent++; 2143 + chan->sent++; 2144 + chan->conn->sent++; 2281 2145 } 2282 2146 } 2147 + 2148 + if (cnt != hdev->acl_cnt) 2149 + hci_prio_recalculate(hdev, ACL_LINK); 2283 2150 } 2284 2151 2285 2152 /* Schedule SCO */ ··· 2347 2182 2348 2183 static inline void hci_sched_le(struct hci_dev *hdev) 2349 2184 { 2350 - struct hci_conn *conn; 2185 + struct hci_chan *chan; 2351 2186 struct sk_buff *skb; 2352 - int quote, cnt; 2187 + int quote, cnt, tmp; 2353 2188 2354 2189 BT_DBG("%s", hdev->name); 2355 2190 ··· 2365 2200 } 2366 2201 2367 2202 cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt; 2368 - while (cnt && (conn = hci_low_sent(hdev, LE_LINK, &quote))) { 2369 - while (quote-- && (skb = skb_dequeue(&conn->data_q))) { 2370 - BT_DBG("skb %p len %d", skb, skb->len); 2203 + tmp = cnt; 2204 + while (cnt && (chan = hci_chan_sent(hdev, LE_LINK, &quote))) { 2205 + u32 priority = (skb_peek(&chan->data_q))->priority; 2206 + while (quote-- && (skb = skb_peek(&chan->data_q))) { 2207 + BT_DBG("chan %p skb %p len %d priority %u", chan, skb, 2208 + skb->len, skb->priority); 2209 + 2210 + /* Stop if priority has changed */ 2211 + if (skb->priority < priority) 2212 + break; 2213 + 2214 + skb = skb_dequeue(&chan->data_q); 2371 2215 2372 2216 hci_send_frame(skb); 2373 2217 hdev->le_last_tx = jiffies; 2374 2218 2375 2219 cnt--; 2376 - conn->sent++; 2220 + chan->sent++; 2221 + chan->conn->sent++; 2377 2222 } 2378 2223 } 2224 + 2379 2225 if (hdev->le_pkts) 2380 2226 hdev->le_cnt = cnt; 2381 2227 else 2382 2228 hdev->acl_cnt = cnt; 2229 + 2230 + if (cnt != tmp) 2231 + hci_prio_recalculate(hdev, LE_LINK); 2383 2232 } 2384 2233 2385 2234 static void hci_tx_task(unsigned long arg) ··· 2585 2406 tasklet_schedule(&hdev->cmd_task); 2586 2407 } 2587 2408 } 2409 + } 2410 + 2411 + int hci_do_inquiry(struct hci_dev *hdev, u8 length) 2412 + { 2413 + /* General inquiry access code (GIAC) */ 2414 + u8 lap[3] = { 0x33, 0x8b, 0x9e }; 2415 + struct hci_cp_inquiry cp; 2416 + 2417 + BT_DBG("%s", hdev->name); 2418 + 2419 + if (test_bit(HCI_INQUIRY, &hdev->flags)) 2420 + return -EINPROGRESS; 2421 + 2422 + memset(&cp, 0, sizeof(cp)); 2423 + memcpy(&cp.lap, lap, sizeof(cp.lap)); 2424 + cp.length = length; 2425 + 2426 + return hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp); 2427 + } 2428 + 2429 + int hci_cancel_inquiry(struct hci_dev *hdev) 2430 + { 2431 + BT_DBG("%s", hdev->name); 2432 + 2433 + if (!test_bit(HCI_INQUIRY, &hdev->flags)) 2434 + return -EPERM; 2435 + 2436 + return hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL); 2588 2437 }
+138 -83
net/bluetooth/hci_event.c
··· 58 58 if (status) 59 59 return; 60 60 61 - if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) && 62 - test_bit(HCI_MGMT, &hdev->flags)) 63 - mgmt_discovering(hdev->id, 0); 61 + clear_bit(HCI_INQUIRY, &hdev->flags); 62 + 63 + hci_dev_lock(hdev); 64 + mgmt_discovering(hdev, 0); 65 + hci_dev_unlock(hdev); 64 66 65 67 hci_req_complete(hdev, HCI_OP_INQUIRY_CANCEL, status); 66 68 ··· 77 75 78 76 if (status) 79 77 return; 80 - 81 - if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) && 82 - test_bit(HCI_MGMT, &hdev->flags)) 83 - mgmt_discovering(hdev->id, 0); 84 78 85 79 hci_conn_check_pending(hdev); 86 80 } ··· 203 205 if (!sent) 204 206 return; 205 207 208 + hci_dev_lock(hdev); 209 + 206 210 if (test_bit(HCI_MGMT, &hdev->flags)) 207 - mgmt_set_local_name_complete(hdev->id, sent, status); 211 + mgmt_set_local_name_complete(hdev, sent, status); 208 212 209 - if (status) 210 - return; 213 + if (status == 0) 214 + memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); 211 215 212 - memcpy(hdev->dev_name, sent, HCI_MAX_NAME_LENGTH); 216 + hci_dev_unlock(hdev); 213 217 } 214 218 215 219 static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb) ··· 274 274 275 275 static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb) 276 276 { 277 - __u8 status = *((__u8 *) skb->data); 277 + __u8 param, status = *((__u8 *) skb->data); 278 + int old_pscan, old_iscan; 278 279 void *sent; 279 280 280 281 BT_DBG("%s status 0x%x", hdev->name, status); ··· 284 283 if (!sent) 285 284 return; 286 285 287 - if (!status) { 288 - __u8 param = *((__u8 *) sent); 289 - int old_pscan, old_iscan; 286 + param = *((__u8 *) sent); 290 287 291 - old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags); 292 - old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags); 288 + hci_dev_lock(hdev); 293 289 294 - if (param & SCAN_INQUIRY) { 295 - set_bit(HCI_ISCAN, &hdev->flags); 296 - if (!old_iscan) 297 - mgmt_discoverable(hdev->id, 1); 298 - } else if (old_iscan) 299 - mgmt_discoverable(hdev->id, 0); 300 - 301 - if (param & SCAN_PAGE) { 302 - set_bit(HCI_PSCAN, &hdev->flags); 303 - if (!old_pscan) 304 - mgmt_connectable(hdev->id, 1); 305 - } else if (old_pscan) 306 - mgmt_connectable(hdev->id, 0); 290 + if (status != 0) { 291 + mgmt_write_scan_failed(hdev, param, status); 292 + hdev->discov_timeout = 0; 293 + goto done; 307 294 } 308 295 296 + old_pscan = test_and_clear_bit(HCI_PSCAN, &hdev->flags); 297 + old_iscan = test_and_clear_bit(HCI_ISCAN, &hdev->flags); 298 + 299 + if (param & SCAN_INQUIRY) { 300 + set_bit(HCI_ISCAN, &hdev->flags); 301 + if (!old_iscan) 302 + mgmt_discoverable(hdev, 1); 303 + if (hdev->discov_timeout > 0) { 304 + int to = msecs_to_jiffies(hdev->discov_timeout * 1000); 305 + queue_delayed_work(hdev->workqueue, &hdev->discov_off, 306 + to); 307 + } 308 + } else if (old_iscan) 309 + mgmt_discoverable(hdev, 0); 310 + 311 + if (param & SCAN_PAGE) { 312 + set_bit(HCI_PSCAN, &hdev->flags); 313 + if (!old_pscan) 314 + mgmt_connectable(hdev, 1); 315 + } else if (old_pscan) 316 + mgmt_connectable(hdev, 0); 317 + 318 + done: 319 + hci_dev_unlock(hdev); 309 320 hci_req_complete(hdev, HCI_OP_WRITE_SCAN_ENABLE, status); 310 321 } 311 322 ··· 761 748 hci_req_complete(hdev, HCI_OP_WRITE_CA_TIMEOUT, status); 762 749 } 763 750 751 + static void hci_cc_read_local_amp_info(struct hci_dev *hdev, 752 + struct sk_buff *skb) 753 + { 754 + struct hci_rp_read_local_amp_info *rp = (void *) skb->data; 755 + 756 + BT_DBG("%s status 0x%x", hdev->name, rp->status); 757 + 758 + if (rp->status) 759 + return; 760 + 761 + hdev->amp_status = rp->amp_status; 762 + hdev->amp_total_bw = __le32_to_cpu(rp->total_bw); 763 + hdev->amp_max_bw = __le32_to_cpu(rp->max_bw); 764 + hdev->amp_min_latency = __le32_to_cpu(rp->min_latency); 765 + hdev->amp_max_pdu = __le32_to_cpu(rp->max_pdu); 766 + hdev->amp_type = rp->amp_type; 767 + hdev->amp_pal_cap = __le16_to_cpu(rp->pal_cap); 768 + hdev->amp_assoc_size = __le16_to_cpu(rp->max_assoc_size); 769 + hdev->amp_be_flush_to = __le32_to_cpu(rp->be_flush_to); 770 + hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to); 771 + 772 + hci_req_complete(hdev, HCI_OP_READ_LOCAL_AMP_INFO, rp->status); 773 + } 774 + 764 775 static void hci_cc_delete_stored_link_key(struct hci_dev *hdev, 765 776 struct sk_buff *skb) 766 777 { ··· 841 804 842 805 BT_DBG("%s status 0x%x", hdev->name, rp->status); 843 806 807 + hci_dev_lock(hdev); 808 + 844 809 if (test_bit(HCI_MGMT, &hdev->flags)) 845 - mgmt_pin_code_reply_complete(hdev->id, &rp->bdaddr, rp->status); 810 + mgmt_pin_code_reply_complete(hdev, &rp->bdaddr, rp->status); 846 811 847 812 if (rp->status != 0) 848 - return; 813 + goto unlock; 849 814 850 815 cp = hci_sent_cmd_data(hdev, HCI_OP_PIN_CODE_REPLY); 851 816 if (!cp) 852 - return; 817 + goto unlock; 853 818 854 819 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr); 855 820 if (conn) 856 821 conn->pin_length = cp->pin_len; 822 + 823 + unlock: 824 + hci_dev_unlock(hdev); 857 825 } 858 826 859 827 static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb) ··· 867 825 868 826 BT_DBG("%s status 0x%x", hdev->name, rp->status); 869 827 828 + hci_dev_lock(hdev); 829 + 870 830 if (test_bit(HCI_MGMT, &hdev->flags)) 871 - mgmt_pin_code_neg_reply_complete(hdev->id, &rp->bdaddr, 831 + mgmt_pin_code_neg_reply_complete(hdev, &rp->bdaddr, 872 832 rp->status); 833 + 834 + hci_dev_unlock(hdev); 873 835 } 836 + 874 837 static void hci_cc_le_read_buffer_size(struct hci_dev *hdev, 875 838 struct sk_buff *skb) 876 839 { ··· 902 855 903 856 BT_DBG("%s status 0x%x", hdev->name, rp->status); 904 857 858 + hci_dev_lock(hdev); 859 + 905 860 if (test_bit(HCI_MGMT, &hdev->flags)) 906 - mgmt_user_confirm_reply_complete(hdev->id, &rp->bdaddr, 861 + mgmt_user_confirm_reply_complete(hdev, &rp->bdaddr, 907 862 rp->status); 863 + 864 + hci_dev_unlock(hdev); 908 865 } 909 866 910 867 static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev, ··· 918 867 919 868 BT_DBG("%s status 0x%x", hdev->name, rp->status); 920 869 870 + hci_dev_lock(hdev); 871 + 921 872 if (test_bit(HCI_MGMT, &hdev->flags)) 922 - mgmt_user_confirm_neg_reply_complete(hdev->id, &rp->bdaddr, 873 + mgmt_user_confirm_neg_reply_complete(hdev, &rp->bdaddr, 923 874 rp->status); 875 + 876 + hci_dev_unlock(hdev); 924 877 } 925 878 926 879 static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev, ··· 934 879 935 880 BT_DBG("%s status 0x%x", hdev->name, rp->status); 936 881 937 - mgmt_read_local_oob_data_reply_complete(hdev->id, rp->hash, 882 + hci_dev_lock(hdev); 883 + mgmt_read_local_oob_data_reply_complete(hdev, rp->hash, 938 884 rp->randomizer, rp->status); 885 + hci_dev_unlock(hdev); 939 886 } 940 887 941 888 static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, ··· 1012 955 if (status) { 1013 956 hci_req_complete(hdev, HCI_OP_INQUIRY, status); 1014 957 hci_conn_check_pending(hdev); 958 + hci_dev_lock(hdev); 959 + if (test_bit(HCI_MGMT, &hdev->flags)) 960 + mgmt_inquiry_failed(hdev, status); 961 + hci_dev_unlock(hdev); 1015 962 return; 1016 963 } 1017 964 1018 - if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags) && 1019 - test_bit(HCI_MGMT, &hdev->flags)) 1020 - mgmt_discovering(hdev->id, 1); 965 + set_bit(HCI_INQUIRY, &hdev->flags); 966 + 967 + hci_dev_lock(hdev); 968 + mgmt_discovering(hdev, 1); 969 + hci_dev_unlock(hdev); 1021 970 } 1022 971 1023 972 static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) ··· 1402 1339 1403 1340 BT_DBG("%s status %d", hdev->name, status); 1404 1341 1405 - if (test_and_clear_bit(HCI_INQUIRY, &hdev->flags) && 1406 - test_bit(HCI_MGMT, &hdev->flags)) 1407 - mgmt_discovering(hdev->id, 0); 1408 - 1409 1342 hci_req_complete(hdev, HCI_OP_INQUIRY, status); 1410 1343 1411 1344 hci_conn_check_pending(hdev); 1345 + 1346 + if (!test_and_clear_bit(HCI_INQUIRY, &hdev->flags)) 1347 + return; 1348 + 1349 + hci_dev_lock(hdev); 1350 + mgmt_discovering(hdev, 0); 1351 + hci_dev_unlock(hdev); 1412 1352 } 1413 1353 1414 1354 static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) ··· 1427 1361 1428 1362 hci_dev_lock(hdev); 1429 1363 1430 - if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) { 1431 - 1432 - if (test_bit(HCI_MGMT, &hdev->flags)) 1433 - mgmt_discovering(hdev->id, 1); 1434 - } 1435 - 1436 1364 for (; num_rsp; num_rsp--, info++) { 1437 1365 bacpy(&data.bdaddr, &info->bdaddr); 1438 1366 data.pscan_rep_mode = info->pscan_rep_mode; ··· 1437 1377 data.rssi = 0x00; 1438 1378 data.ssp_mode = 0x00; 1439 1379 hci_inquiry_cache_update(hdev, &data); 1440 - mgmt_device_found(hdev->id, &info->bdaddr, info->dev_class, 0, 1441 - NULL); 1380 + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 1381 + info->dev_class, 0, NULL); 1442 1382 } 1443 1383 1444 1384 hci_dev_unlock(hdev); ··· 1472 1412 conn->state = BT_CONFIG; 1473 1413 hci_conn_hold(conn); 1474 1414 conn->disc_timeout = HCI_DISCONN_TIMEOUT; 1475 - mgmt_connected(hdev->id, &ev->bdaddr, conn->type); 1415 + mgmt_connected(hdev, &ev->bdaddr, conn->type); 1476 1416 } else 1477 1417 conn->state = BT_CONNECTED; 1478 1418 ··· 1504 1444 } else { 1505 1445 conn->state = BT_CLOSED; 1506 1446 if (conn->type == ACL_LINK) 1507 - mgmt_connect_failed(hdev->id, &ev->bdaddr, ev->status); 1447 + mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, 1448 + ev->status); 1508 1449 } 1509 1450 1510 1451 if (conn->type == ACL_LINK) ··· 1592 1531 struct hci_cp_reject_conn_req cp; 1593 1532 1594 1533 bacpy(&cp.bdaddr, &ev->bdaddr); 1595 - cp.reason = 0x0f; 1534 + cp.reason = HCI_ERROR_REJ_BAD_ADDR; 1596 1535 hci_send_cmd(hdev, HCI_OP_REJECT_CONN_REQ, sizeof(cp), &cp); 1597 1536 } 1598 1537 } ··· 1605 1544 BT_DBG("%s status %d", hdev->name, ev->status); 1606 1545 1607 1546 if (ev->status) { 1608 - mgmt_disconnect_failed(hdev->id); 1547 + hci_dev_lock(hdev); 1548 + mgmt_disconnect_failed(hdev); 1549 + hci_dev_unlock(hdev); 1609 1550 return; 1610 1551 } 1611 1552 ··· 1620 1557 conn->state = BT_CLOSED; 1621 1558 1622 1559 if (conn->type == ACL_LINK || conn->type == LE_LINK) 1623 - mgmt_disconnected(hdev->id, &conn->dst); 1560 + mgmt_disconnected(hdev, &conn->dst, conn->type); 1624 1561 1625 1562 hci_proto_disconn_cfm(conn, ev->reason); 1626 1563 hci_conn_del(conn); ··· 1651 1588 conn->sec_level = conn->pending_sec_level; 1652 1589 } 1653 1590 } else { 1654 - mgmt_auth_failed(hdev->id, &conn->dst, ev->status); 1591 + mgmt_auth_failed(hdev, &conn->dst, ev->status); 1655 1592 } 1656 1593 1657 1594 clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); ··· 1706 1643 hci_dev_lock(hdev); 1707 1644 1708 1645 if (ev->status == 0 && test_bit(HCI_MGMT, &hdev->flags)) 1709 - mgmt_remote_name(hdev->id, &ev->bdaddr, ev->name); 1646 + mgmt_remote_name(hdev, &ev->bdaddr, ev->name); 1710 1647 1711 1648 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr); 1712 1649 if (!conn) ··· 1961 1898 hci_cc_write_ca_timeout(hdev, skb); 1962 1899 break; 1963 1900 1901 + case HCI_OP_READ_LOCAL_AMP_INFO: 1902 + hci_cc_read_local_amp_info(hdev, skb); 1903 + break; 1904 + 1964 1905 case HCI_OP_DELETE_STORED_LINK_KEY: 1965 1906 hci_cc_delete_stored_link_key(hdev, skb); 1966 1907 break; ··· 2096 2029 2097 2030 case HCI_OP_DISCONNECT: 2098 2031 if (ev->status != 0) 2099 - mgmt_disconnect_failed(hdev->id); 2032 + mgmt_disconnect_failed(hdev); 2100 2033 break; 2101 2034 2102 2035 case HCI_OP_LE_CREATE_CONN: ··· 2261 2194 else 2262 2195 secure = 0; 2263 2196 2264 - mgmt_pin_code_request(hdev->id, &ev->bdaddr, secure); 2197 + mgmt_pin_code_request(hdev, &ev->bdaddr, secure); 2265 2198 } 2266 2199 2267 2200 unlock: ··· 2430 2363 2431 2364 hci_dev_lock(hdev); 2432 2365 2433 - if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) { 2434 - 2435 - if (test_bit(HCI_MGMT, &hdev->flags)) 2436 - mgmt_discovering(hdev->id, 1); 2437 - } 2438 - 2439 2366 if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) { 2440 2367 struct inquiry_info_with_rssi_and_pscan_mode *info; 2441 2368 info = (void *) (skb->data + 1); ··· 2444 2383 data.rssi = info->rssi; 2445 2384 data.ssp_mode = 0x00; 2446 2385 hci_inquiry_cache_update(hdev, &data); 2447 - mgmt_device_found(hdev->id, &info->bdaddr, 2386 + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 2448 2387 info->dev_class, info->rssi, 2449 2388 NULL); 2450 2389 } ··· 2461 2400 data.rssi = info->rssi; 2462 2401 data.ssp_mode = 0x00; 2463 2402 hci_inquiry_cache_update(hdev, &data); 2464 - mgmt_device_found(hdev->id, &info->bdaddr, 2403 + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 2465 2404 info->dev_class, info->rssi, 2466 2405 NULL); 2467 2406 } ··· 2592 2531 if (!num_rsp) 2593 2532 return; 2594 2533 2595 - if (!test_and_set_bit(HCI_INQUIRY, &hdev->flags)) { 2596 - 2597 - if (test_bit(HCI_MGMT, &hdev->flags)) 2598 - mgmt_discovering(hdev->id, 1); 2599 - } 2600 - 2601 2534 hci_dev_lock(hdev); 2602 2535 2603 2536 for (; num_rsp; num_rsp--, info++) { ··· 2604 2549 data.rssi = info->rssi; 2605 2550 data.ssp_mode = 0x01; 2606 2551 hci_inquiry_cache_update(hdev, &data); 2607 - mgmt_device_found(hdev->id, &info->bdaddr, info->dev_class, 2608 - info->rssi, info->data); 2552 + mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 2553 + info->dev_class, info->rssi, info->data); 2609 2554 } 2610 2555 2611 2556 hci_dev_unlock(hdev); ··· 2669 2614 struct hci_cp_io_capability_neg_reply cp; 2670 2615 2671 2616 bacpy(&cp.bdaddr, &ev->bdaddr); 2672 - cp.reason = 0x18; /* Pairing not allowed */ 2617 + cp.reason = HCI_ERROR_PAIRING_NOT_ALLOWED; 2673 2618 2674 2619 hci_send_cmd(hdev, HCI_OP_IO_CAPABILITY_NEG_REPLY, 2675 2620 sizeof(cp), &cp); ··· 2761 2706 } 2762 2707 2763 2708 confirm: 2764 - mgmt_user_confirm_request(hdev->id, &ev->bdaddr, ev->passkey, 2709 + mgmt_user_confirm_request(hdev, &ev->bdaddr, ev->passkey, 2765 2710 confirm_hint); 2766 2711 2767 2712 unlock: ··· 2787 2732 * event gets always produced as initiator and is also mapped to 2788 2733 * the mgmt_auth_failed event */ 2789 2734 if (!test_bit(HCI_CONN_AUTH_PEND, &conn->pend) && ev->status != 0) 2790 - mgmt_auth_failed(hdev->id, &conn->dst, ev->status); 2735 + mgmt_auth_failed(hdev, &conn->dst, ev->status); 2791 2736 2792 2737 hci_conn_put(conn); 2793 2738 ··· 2868 2813 } 2869 2814 2870 2815 if (ev->status) { 2871 - mgmt_connect_failed(hdev->id, &ev->bdaddr, ev->status); 2816 + mgmt_connect_failed(hdev, &ev->bdaddr, conn->type, ev->status); 2872 2817 hci_proto_connect_cfm(conn, ev->status); 2873 2818 conn->state = BT_CLOSED; 2874 2819 hci_conn_del(conn); 2875 2820 goto unlock; 2876 2821 } 2877 2822 2878 - mgmt_connected(hdev->id, &ev->bdaddr, conn->type); 2823 + mgmt_connected(hdev, &ev->bdaddr, conn->type); 2879 2824 2880 2825 conn->sec_level = BT_SECURITY_LOW; 2881 2826 conn->handle = __le16_to_cpu(ev->handle); ··· 3159 3104 kfree_skb(skb); 3160 3105 } 3161 3106 3162 - module_param(enable_le, bool, 0444); 3107 + module_param(enable_le, bool, 0644); 3163 3108 MODULE_PARM_DESC(enable_le, "Enable LE support");
+18 -22
net/bluetooth/hci_sysfs.c
··· 436 436 static int blacklist_show(struct seq_file *f, void *p) 437 437 { 438 438 struct hci_dev *hdev = f->private; 439 - struct list_head *l; 439 + struct bdaddr_list *b; 440 440 441 441 hci_dev_lock_bh(hdev); 442 442 443 - list_for_each(l, &hdev->blacklist) { 444 - struct bdaddr_list *b; 445 - 446 - b = list_entry(l, struct bdaddr_list, list); 447 - 443 + list_for_each_entry(b, &hdev->blacklist, list) 448 444 seq_printf(f, "%s\n", batostr(&b->bdaddr)); 449 - } 450 445 451 446 hci_dev_unlock_bh(hdev); 452 447 ··· 480 485 static int uuids_show(struct seq_file *f, void *p) 481 486 { 482 487 struct hci_dev *hdev = f->private; 483 - struct list_head *l; 488 + struct bt_uuid *uuid; 484 489 485 490 hci_dev_lock_bh(hdev); 486 491 487 - list_for_each(l, &hdev->uuids) { 488 - struct bt_uuid *uuid; 489 - 490 - uuid = list_entry(l, struct bt_uuid, list); 491 - 492 + list_for_each_entry(uuid, &hdev->uuids, list) 492 493 print_bt_uuid(f, uuid->uuid); 493 - } 494 494 495 495 hci_dev_unlock_bh(hdev); 496 496 ··· 533 543 DEFINE_SIMPLE_ATTRIBUTE(auto_accept_delay_fops, auto_accept_delay_get, 534 544 auto_accept_delay_set, "%llu\n"); 535 545 536 - int hci_register_sysfs(struct hci_dev *hdev) 546 + void hci_init_sysfs(struct hci_dev *hdev) 547 + { 548 + struct device *dev = &hdev->dev; 549 + 550 + dev->type = &bt_host; 551 + dev->class = bt_class; 552 + 553 + dev_set_drvdata(dev, hdev); 554 + device_initialize(dev); 555 + } 556 + 557 + int hci_add_sysfs(struct hci_dev *hdev) 537 558 { 538 559 struct device *dev = &hdev->dev; 539 560 int err; 540 561 541 562 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); 542 563 543 - dev->type = &bt_host; 544 - dev->class = bt_class; 545 564 dev->parent = hdev->parent; 546 - 547 565 dev_set_name(dev, "%s", hdev->name); 548 566 549 - dev_set_drvdata(dev, hdev); 550 - 551 - err = device_register(dev); 567 + err = device_add(dev); 552 568 if (err < 0) 553 569 return err; 554 570 ··· 578 582 return 0; 579 583 } 580 584 581 - void hci_unregister_sysfs(struct hci_dev *hdev) 585 + void hci_del_sysfs(struct hci_dev *hdev) 582 586 { 583 587 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus); 584 588
+93 -80
net/bluetooth/hidp/core.c
··· 81 81 static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr) 82 82 { 83 83 struct hidp_session *session; 84 - struct list_head *p; 85 84 86 85 BT_DBG(""); 87 86 88 - list_for_each(p, &hidp_session_list) { 89 - session = list_entry(p, struct hidp_session, list); 87 + list_for_each_entry(session, &hidp_session_list, list) { 90 88 if (!bacmp(bdaddr, &session->bdaddr)) 91 89 return session; 92 90 } 91 + 93 92 return NULL; 94 93 } 95 94 96 95 static void __hidp_link_session(struct hidp_session *session) 97 96 { 98 - __module_get(THIS_MODULE); 99 97 list_add(&session->list, &hidp_session_list); 100 - 101 - hci_conn_hold_device(session->conn); 102 98 } 103 99 104 100 static void __hidp_unlink_session(struct hidp_session *session) ··· 102 106 hci_conn_put_device(session->conn); 103 107 104 108 list_del(&session->list); 105 - module_put(THIS_MODULE); 106 109 } 107 110 108 111 static void __hidp_copy_session(struct hidp_session *session, struct hidp_conninfo *ci) ··· 250 255 251 256 BT_DBG("session %p data %p size %d", session, data, size); 252 257 258 + if (atomic_read(&session->terminate)) 259 + return -EIO; 260 + 253 261 skb = alloc_skb(size + 1, GFP_ATOMIC); 254 262 if (!skb) { 255 263 BT_ERR("Can't allocate memory for new frame"); ··· 327 329 struct sk_buff *skb; 328 330 size_t len; 329 331 int numbered_reports = hid->report_enum[report_type].numbered; 332 + int ret; 330 333 331 334 switch (report_type) { 332 335 case HID_FEATURE_REPORT: ··· 351 352 session->waiting_report_number = numbered_reports ? report_number : -1; 352 353 set_bit(HIDP_WAITING_FOR_RETURN, &session->flags); 353 354 data[0] = report_number; 354 - if (hidp_send_ctrl_message(hid->driver_data, report_type, data, 1)) 355 - goto err_eio; 355 + ret = hidp_send_ctrl_message(hid->driver_data, report_type, data, 1); 356 + if (ret) 357 + goto err; 356 358 357 359 /* Wait for the return of the report. The returned report 358 360 gets put in session->report_return. */ ··· 365 365 5*HZ); 366 366 if (res == 0) { 367 367 /* timeout */ 368 - goto err_eio; 368 + ret = -EIO; 369 + goto err; 369 370 } 370 371 if (res < 0) { 371 372 /* signal */ 372 - goto err_restartsys; 373 + ret = -ERESTARTSYS; 374 + goto err; 373 375 } 374 376 } 375 377 ··· 392 390 393 391 return len; 394 392 395 - err_restartsys: 393 + err: 396 394 clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); 397 395 mutex_unlock(&session->report_mutex); 398 - return -ERESTARTSYS; 399 - err_eio: 400 - clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); 401 - mutex_unlock(&session->report_mutex); 402 - return -EIO; 396 + return ret; 403 397 } 404 398 405 399 static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count, ··· 420 422 421 423 /* Set up our wait, and send the report request to the device. */ 422 424 set_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); 423 - if (hidp_send_ctrl_message(hid->driver_data, report_type, 424 - data, count)) { 425 - ret = -ENOMEM; 425 + ret = hidp_send_ctrl_message(hid->driver_data, report_type, data, 426 + count); 427 + if (ret) 426 428 goto err; 427 - } 428 429 429 430 /* Wait for the ACK from the device. */ 430 431 while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) { ··· 493 496 case HIDP_HSHK_ERR_INVALID_REPORT_ID: 494 497 case HIDP_HSHK_ERR_UNSUPPORTED_REQUEST: 495 498 case HIDP_HSHK_ERR_INVALID_PARAMETER: 496 - if (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags)) { 497 - clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); 499 + if (test_and_clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags)) 498 500 wake_up_interruptible(&session->report_queue); 499 - } 501 + 500 502 /* FIXME: Call into SET_ GET_ handlers here */ 501 503 break; 502 504 ··· 516 520 } 517 521 518 522 /* Wake up the waiting thread. */ 519 - if (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) { 520 - clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); 523 + if (test_and_clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) 521 524 wake_up_interruptible(&session->report_queue); 522 - } 523 525 } 524 526 525 527 static void hidp_process_hid_control(struct hidp_session *session, ··· 657 663 return kernel_sendmsg(sock, &msg, &iv, 1, len); 658 664 } 659 665 660 - static void hidp_process_transmit(struct hidp_session *session) 666 + static void hidp_process_intr_transmit(struct hidp_session *session) 667 + { 668 + struct sk_buff *skb; 669 + 670 + BT_DBG("session %p", session); 671 + 672 + while ((skb = skb_dequeue(&session->intr_transmit))) { 673 + if (hidp_send_frame(session->intr_sock, skb->data, skb->len) < 0) { 674 + skb_queue_head(&session->intr_transmit, skb); 675 + break; 676 + } 677 + 678 + hidp_set_timer(session); 679 + kfree_skb(skb); 680 + } 681 + } 682 + 683 + static void hidp_process_ctrl_transmit(struct hidp_session *session) 661 684 { 662 685 struct sk_buff *skb; 663 686 ··· 683 672 while ((skb = skb_dequeue(&session->ctrl_transmit))) { 684 673 if (hidp_send_frame(session->ctrl_sock, skb->data, skb->len) < 0) { 685 674 skb_queue_head(&session->ctrl_transmit, skb); 686 - break; 687 - } 688 - 689 - hidp_set_timer(session); 690 - kfree_skb(skb); 691 - } 692 - 693 - while ((skb = skb_dequeue(&session->intr_transmit))) { 694 - if (hidp_send_frame(session->intr_sock, skb->data, skb->len) < 0) { 695 - skb_queue_head(&session->intr_transmit, skb); 696 675 break; 697 676 } 698 677 ··· 701 700 702 701 BT_DBG("session %p", session); 703 702 703 + __module_get(THIS_MODULE); 704 704 set_user_nice(current, -15); 705 705 706 706 init_waitqueue_entry(&ctrl_wait, current); ··· 716 714 intr_sk->sk_state != BT_CONNECTED) 717 715 break; 718 716 719 - while ((skb = skb_dequeue(&ctrl_sk->sk_receive_queue))) { 720 - skb_orphan(skb); 721 - if (!skb_linearize(skb)) 722 - hidp_recv_ctrl_frame(session, skb); 723 - else 724 - kfree_skb(skb); 725 - } 726 - 727 717 while ((skb = skb_dequeue(&intr_sk->sk_receive_queue))) { 728 718 skb_orphan(skb); 729 719 if (!skb_linearize(skb)) ··· 724 730 kfree_skb(skb); 725 731 } 726 732 727 - hidp_process_transmit(session); 733 + hidp_process_intr_transmit(session); 734 + 735 + while ((skb = skb_dequeue(&ctrl_sk->sk_receive_queue))) { 736 + skb_orphan(skb); 737 + if (!skb_linearize(skb)) 738 + hidp_recv_ctrl_frame(session, skb); 739 + else 740 + kfree_skb(skb); 741 + } 742 + 743 + hidp_process_ctrl_transmit(session); 728 744 729 745 schedule(); 730 746 set_current_state(TASK_INTERRUPTIBLE); ··· 742 738 set_current_state(TASK_RUNNING); 743 739 remove_wait_queue(sk_sleep(intr_sk), &intr_wait); 744 740 remove_wait_queue(sk_sleep(ctrl_sk), &ctrl_wait); 741 + 742 + clear_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags); 743 + clear_bit(HIDP_WAITING_FOR_RETURN, &session->flags); 744 + wake_up_interruptible(&session->report_queue); 745 745 746 746 down_write(&hidp_session_sem); 747 747 ··· 780 772 781 773 kfree(session->rd_data); 782 774 kfree(session); 775 + module_put_and_exit(0); 783 776 return 0; 784 777 } 785 778 786 - static struct device *hidp_get_device(struct hidp_session *session) 779 + static struct hci_conn *hidp_get_connection(struct hidp_session *session) 787 780 { 788 781 bdaddr_t *src = &bt_sk(session->ctrl_sock->sk)->src; 789 782 bdaddr_t *dst = &bt_sk(session->ctrl_sock->sk)->dst; 790 - struct device *device = NULL; 783 + struct hci_conn *conn; 791 784 struct hci_dev *hdev; 792 785 793 786 hdev = hci_get_route(dst, src); 794 787 if (!hdev) 795 788 return NULL; 796 789 797 - session->conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); 798 - if (session->conn) 799 - device = &session->conn->dev; 790 + hci_dev_lock_bh(hdev); 791 + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst); 792 + if (conn) 793 + hci_conn_hold_device(conn); 794 + hci_dev_unlock_bh(hdev); 800 795 801 796 hci_dev_put(hdev); 802 797 803 - return device; 798 + return conn; 804 799 } 805 800 806 801 static int hidp_setup_input(struct hidp_session *session, 807 802 struct hidp_connadd_req *req) 808 803 { 809 804 struct input_dev *input; 810 - int err, i; 805 + int i; 811 806 812 807 input = input_allocate_device(); 813 808 if (!input) ··· 853 842 input->relbit[0] |= BIT_MASK(REL_WHEEL); 854 843 } 855 844 856 - input->dev.parent = hidp_get_device(session); 845 + input->dev.parent = &session->conn->dev; 857 846 858 847 input->event = hidp_input_event; 859 - 860 - err = input_register_device(input); 861 - if (err < 0) { 862 - input_free_device(input); 863 - session->input = NULL; 864 - return err; 865 - } 866 848 867 849 return 0; 868 850 } ··· 953 949 strncpy(hid->phys, batostr(&bt_sk(session->ctrl_sock->sk)->src), 64); 954 950 strncpy(hid->uniq, batostr(&bt_sk(session->ctrl_sock->sk)->dst), 64); 955 951 956 - hid->dev.parent = hidp_get_device(session); 952 + hid->dev.parent = &session->conn->dev; 957 953 hid->ll_driver = &hidp_hid_driver; 958 954 959 955 hid->hid_get_raw_report = hidp_get_raw_report; ··· 980 976 bacmp(&bt_sk(ctrl_sock->sk)->dst, &bt_sk(intr_sock->sk)->dst)) 981 977 return -ENOTUNIQ; 982 978 983 - session = kzalloc(sizeof(struct hidp_session), GFP_KERNEL); 984 - if (!session) 985 - return -ENOMEM; 986 - 987 979 BT_DBG("rd_data %p rd_size %d", req->rd_data, req->rd_size); 988 980 989 981 down_write(&hidp_session_sem); 990 982 991 983 s = __hidp_get_session(&bt_sk(ctrl_sock->sk)->dst); 992 984 if (s && s->state == BT_CONNECTED) { 993 - err = -EEXIST; 994 - goto failed; 985 + up_write(&hidp_session_sem); 986 + return -EEXIST; 987 + } 988 + 989 + session = kzalloc(sizeof(struct hidp_session), GFP_KERNEL); 990 + if (!session) { 991 + up_write(&hidp_session_sem); 992 + return -ENOMEM; 995 993 } 996 994 997 995 bacpy(&session->bdaddr, &bt_sk(ctrl_sock->sk)->dst); ··· 1009 1003 session->intr_sock = intr_sock; 1010 1004 session->state = BT_CONNECTED; 1011 1005 1006 + session->conn = hidp_get_connection(session); 1007 + if (!session->conn) { 1008 + err = -ENOTCONN; 1009 + goto failed; 1010 + } 1011 + 1012 1012 setup_timer(&session->timer, hidp_idle_timeout, (unsigned long)session); 1013 1013 1014 1014 skb_queue_head_init(&session->ctrl_transmit); ··· 1027 1015 session->flags = req->flags & (1 << HIDP_BLUETOOTH_VENDOR_ID); 1028 1016 session->idle_to = req->idle_to; 1029 1017 1018 + __hidp_link_session(session); 1019 + 1030 1020 if (req->rd_size > 0) { 1031 1021 err = hidp_setup_hid(session, req); 1032 - if (err && err != -ENODEV) 1022 + if (err) 1033 1023 goto purge; 1034 1024 } 1035 1025 ··· 1040 1026 if (err < 0) 1041 1027 goto purge; 1042 1028 } 1043 - 1044 - __hidp_link_session(session); 1045 1029 1046 1030 hidp_set_timer(session); 1047 1031 ··· 1066 1054 !session->waiting_for_startup); 1067 1055 } 1068 1056 1069 - err = hid_add_device(session->hid); 1057 + if (session->hid) 1058 + err = hid_add_device(session->hid); 1059 + else 1060 + err = input_register_device(session->input); 1061 + 1070 1062 if (err < 0) { 1071 1063 atomic_inc(&session->terminate); 1072 1064 wake_up_process(session->task); ··· 1093 1077 unlink: 1094 1078 hidp_del_timer(session); 1095 1079 1096 - __hidp_unlink_session(session); 1097 - 1098 1080 if (session->input) { 1099 1081 input_unregister_device(session->input); 1100 1082 session->input = NULL; ··· 1107 1093 session->rd_data = NULL; 1108 1094 1109 1095 purge: 1096 + __hidp_unlink_session(session); 1097 + 1110 1098 skb_queue_purge(&session->ctrl_transmit); 1111 1099 skb_queue_purge(&session->intr_transmit); 1112 1100 ··· 1150 1134 1151 1135 int hidp_get_connlist(struct hidp_connlist_req *req) 1152 1136 { 1153 - struct list_head *p; 1137 + struct hidp_session *session; 1154 1138 int err = 0, n = 0; 1155 1139 1156 1140 BT_DBG(""); 1157 1141 1158 1142 down_read(&hidp_session_sem); 1159 1143 1160 - list_for_each(p, &hidp_session_list) { 1161 - struct hidp_session *session; 1144 + list_for_each_entry(session, &hidp_session_list, list) { 1162 1145 struct hidp_conninfo ci; 1163 - 1164 - session = list_entry(p, struct hidp_session, list); 1165 1146 1166 1147 __hidp_copy_session(session, &ci); 1167 1148
+716 -251
net/bluetooth/l2cap_core.c
··· 57 57 #include <net/bluetooth/smp.h> 58 58 59 59 int disable_ertm; 60 + int enable_hs; 60 61 61 62 static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN; 62 - static u8 l2cap_fixed_chan[8] = { 0x02, }; 63 + static u8 l2cap_fixed_chan[8] = { L2CAP_FC_L2CAP, }; 63 64 64 65 static LIST_HEAD(chan_list); 65 66 static DEFINE_RWLOCK(chan_list_lock); ··· 220 219 221 220 static void l2cap_set_timer(struct l2cap_chan *chan, struct timer_list *timer, long timeout) 222 221 { 223 - BT_DBG("chan %p state %d timeout %ld", chan->sk, chan->state, timeout); 222 + BT_DBG("chan %p state %d timeout %ld", chan, chan->state, timeout); 224 223 225 224 if (!mod_timer(timer, jiffies + msecs_to_jiffies(timeout))) 226 225 chan_hold(chan); ··· 252 251 253 252 if (sock_owned_by_user(sk)) { 254 253 /* sk is owned by user. Try again later */ 255 - __set_chan_timer(chan, HZ / 5); 254 + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); 256 255 bh_unlock_sock(sk); 257 256 chan_put(chan); 258 257 return; ··· 294 293 295 294 atomic_set(&chan->refcnt, 1); 296 295 296 + BT_DBG("sk %p chan %p", sk, chan); 297 + 297 298 return chan; 298 299 } 299 300 ··· 313 310 BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn, 314 311 chan->psm, chan->dcid); 315 312 316 - conn->disc_reason = 0x13; 313 + conn->disc_reason = HCI_ERROR_REMOTE_USER_TERM; 317 314 318 315 chan->conn = conn; 319 316 ··· 339 336 chan->dcid = L2CAP_CID_SIGNALING; 340 337 chan->omtu = L2CAP_DEFAULT_MTU; 341 338 } 339 + 340 + chan->local_id = L2CAP_BESTEFFORT_ID; 341 + chan->local_stype = L2CAP_SERV_BESTEFFORT; 342 + chan->local_msdu = L2CAP_DEFAULT_MAX_SDU_SIZE; 343 + chan->local_sdu_itime = L2CAP_DEFAULT_SDU_ITIME; 344 + chan->local_acc_lat = L2CAP_DEFAULT_ACC_LAT; 345 + chan->local_flush_to = L2CAP_DEFAULT_FLUSH_TO; 342 346 343 347 chan_hold(chan); 344 348 ··· 566 556 flags = ACL_START; 567 557 568 558 bt_cb(skb)->force_active = BT_POWER_FORCE_ACTIVE_ON; 559 + skb->priority = HCI_PRIO_MAX; 569 560 570 - hci_send_acl(conn->hcon, skb, flags); 561 + hci_send_acl(conn->hchan, skb, flags); 571 562 } 572 563 573 - static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control) 564 + static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) 565 + { 566 + struct hci_conn *hcon = chan->conn->hcon; 567 + u16 flags; 568 + 569 + BT_DBG("chan %p, skb %p len %d priority %u", chan, skb, skb->len, 570 + skb->priority); 571 + 572 + if (!test_bit(FLAG_FLUSHABLE, &chan->flags) && 573 + lmp_no_flush_capable(hcon->hdev)) 574 + flags = ACL_START_NO_FLUSH; 575 + else 576 + flags = ACL_START; 577 + 578 + bt_cb(skb)->force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags); 579 + hci_send_acl(chan->conn->hchan, skb, flags); 580 + } 581 + 582 + static inline void l2cap_send_sframe(struct l2cap_chan *chan, u32 control) 574 583 { 575 584 struct sk_buff *skb; 576 585 struct l2cap_hdr *lh; 577 586 struct l2cap_conn *conn = chan->conn; 578 - int count, hlen = L2CAP_HDR_SIZE + 2; 579 - u8 flags; 587 + int count, hlen; 580 588 581 589 if (chan->state != BT_CONNECTED) 582 590 return; 583 591 584 - if (chan->fcs == L2CAP_FCS_CRC16) 585 - hlen += 2; 592 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 593 + hlen = L2CAP_EXT_HDR_SIZE; 594 + else 595 + hlen = L2CAP_ENH_HDR_SIZE; 586 596 587 - BT_DBG("chan %p, control 0x%2.2x", chan, control); 597 + if (chan->fcs == L2CAP_FCS_CRC16) 598 + hlen += L2CAP_FCS_SIZE; 599 + 600 + BT_DBG("chan %p, control 0x%8.8x", chan, control); 588 601 589 602 count = min_t(unsigned int, conn->mtu, hlen); 590 - control |= L2CAP_CTRL_FRAME_TYPE; 603 + 604 + control |= __set_sframe(chan); 591 605 592 606 if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) 593 - control |= L2CAP_CTRL_FINAL; 607 + control |= __set_ctrl_final(chan); 594 608 595 609 if (test_and_clear_bit(CONN_SEND_PBIT, &chan->conn_state)) 596 - control |= L2CAP_CTRL_POLL; 610 + control |= __set_ctrl_poll(chan); 597 611 598 612 skb = bt_skb_alloc(count, GFP_ATOMIC); 599 613 if (!skb) ··· 626 592 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); 627 593 lh->len = cpu_to_le16(hlen - L2CAP_HDR_SIZE); 628 594 lh->cid = cpu_to_le16(chan->dcid); 629 - put_unaligned_le16(control, skb_put(skb, 2)); 595 + 596 + __put_control(chan, control, skb_put(skb, __ctrl_size(chan))); 630 597 631 598 if (chan->fcs == L2CAP_FCS_CRC16) { 632 - u16 fcs = crc16(0, (u8 *)lh, count - 2); 633 - put_unaligned_le16(fcs, skb_put(skb, 2)); 599 + u16 fcs = crc16(0, (u8 *)lh, count - L2CAP_FCS_SIZE); 600 + put_unaligned_le16(fcs, skb_put(skb, L2CAP_FCS_SIZE)); 634 601 } 635 602 636 - if (lmp_no_flush_capable(conn->hcon->hdev)) 637 - flags = ACL_START_NO_FLUSH; 638 - else 639 - flags = ACL_START; 640 - 641 - bt_cb(skb)->force_active = chan->force_active; 642 - 643 - hci_send_acl(chan->conn->hcon, skb, flags); 603 + skb->priority = HCI_PRIO_MAX; 604 + l2cap_do_send(chan, skb); 644 605 } 645 606 646 - static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u16 control) 607 + static inline void l2cap_send_rr_or_rnr(struct l2cap_chan *chan, u32 control) 647 608 { 648 609 if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { 649 - control |= L2CAP_SUPER_RCV_NOT_READY; 610 + control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); 650 611 set_bit(CONN_RNR_SENT, &chan->conn_state); 651 612 } else 652 - control |= L2CAP_SUPER_RCV_READY; 613 + control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); 653 614 654 - control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 615 + control |= __set_reqseq(chan, chan->buffer_seq); 655 616 656 617 l2cap_send_sframe(chan, control); 657 618 } ··· 976 947 list_for_each_entry(chan, &conn->chan_l, list) { 977 948 struct sock *sk = chan->sk; 978 949 979 - if (chan->force_reliable) 950 + if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags)) 980 951 sk->sk_err = err; 981 952 } 982 953 ··· 1015 986 chan->ops->close(chan->data); 1016 987 } 1017 988 989 + hci_chan_del(conn->hchan); 990 + 1018 991 if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) 1019 992 del_timer_sync(&conn->info_timer); 1020 993 ··· 1039 1008 static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) 1040 1009 { 1041 1010 struct l2cap_conn *conn = hcon->l2cap_data; 1011 + struct hci_chan *hchan; 1042 1012 1043 1013 if (conn || status) 1044 1014 return conn; 1045 1015 1046 - conn = kzalloc(sizeof(struct l2cap_conn), GFP_ATOMIC); 1047 - if (!conn) 1016 + hchan = hci_chan_create(hcon); 1017 + if (!hchan) 1048 1018 return NULL; 1019 + 1020 + conn = kzalloc(sizeof(struct l2cap_conn), GFP_ATOMIC); 1021 + if (!conn) { 1022 + hci_chan_del(hchan); 1023 + return NULL; 1024 + } 1049 1025 1050 1026 hcon->l2cap_data = conn; 1051 1027 conn->hcon = hcon; 1028 + conn->hchan = hchan; 1052 1029 1053 - BT_DBG("hcon %p conn %p", hcon, conn); 1030 + BT_DBG("hcon %p conn %p hchan %p", hcon, conn, hchan); 1054 1031 1055 1032 if (hcon->hdev->le_mtu && hcon->type == LE_LINK) 1056 1033 conn->mtu = hcon->hdev->le_mtu; ··· 1082 1043 setup_timer(&conn->info_timer, l2cap_info_timeout, 1083 1044 (unsigned long) conn); 1084 1045 1085 - conn->disc_reason = 0x13; 1046 + conn->disc_reason = HCI_ERROR_REMOTE_USER_TERM; 1086 1047 1087 1048 return conn; 1088 1049 } ··· 1284 1245 __clear_retrans_timer(chan); 1285 1246 } 1286 1247 1287 - static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) 1288 - { 1289 - struct hci_conn *hcon = chan->conn->hcon; 1290 - u16 flags; 1291 - 1292 - BT_DBG("chan %p, skb %p len %d", chan, skb, skb->len); 1293 - 1294 - if (!chan->flushable && lmp_no_flush_capable(hcon->hdev)) 1295 - flags = ACL_START_NO_FLUSH; 1296 - else 1297 - flags = ACL_START; 1298 - 1299 - bt_cb(skb)->force_active = chan->force_active; 1300 - hci_send_acl(hcon, skb, flags); 1301 - } 1302 - 1303 1248 static void l2cap_streaming_send(struct l2cap_chan *chan) 1304 1249 { 1305 1250 struct sk_buff *skb; 1306 - u16 control, fcs; 1251 + u32 control; 1252 + u16 fcs; 1307 1253 1308 1254 while ((skb = skb_dequeue(&chan->tx_q))) { 1309 - control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE); 1310 - control |= chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; 1311 - put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE); 1255 + control = __get_control(chan, skb->data + L2CAP_HDR_SIZE); 1256 + control |= __set_txseq(chan, chan->next_tx_seq); 1257 + __put_control(chan, control, skb->data + L2CAP_HDR_SIZE); 1312 1258 1313 1259 if (chan->fcs == L2CAP_FCS_CRC16) { 1314 - fcs = crc16(0, (u8 *)skb->data, skb->len - 2); 1315 - put_unaligned_le16(fcs, skb->data + skb->len - 2); 1260 + fcs = crc16(0, (u8 *)skb->data, 1261 + skb->len - L2CAP_FCS_SIZE); 1262 + put_unaligned_le16(fcs, 1263 + skb->data + skb->len - L2CAP_FCS_SIZE); 1316 1264 } 1317 1265 1318 1266 l2cap_do_send(chan, skb); 1319 1267 1320 - chan->next_tx_seq = (chan->next_tx_seq + 1) % 64; 1268 + chan->next_tx_seq = __next_seq(chan, chan->next_tx_seq); 1321 1269 } 1322 1270 } 1323 1271 1324 - static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u8 tx_seq) 1272 + static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u16 tx_seq) 1325 1273 { 1326 1274 struct sk_buff *skb, *tx_skb; 1327 - u16 control, fcs; 1275 + u16 fcs; 1276 + u32 control; 1328 1277 1329 1278 skb = skb_peek(&chan->tx_q); 1330 1279 if (!skb) ··· 1335 1308 1336 1309 tx_skb = skb_clone(skb, GFP_ATOMIC); 1337 1310 bt_cb(skb)->retries++; 1338 - control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); 1339 - control &= L2CAP_CTRL_SAR; 1311 + 1312 + control = __get_control(chan, tx_skb->data + L2CAP_HDR_SIZE); 1313 + control &= __get_sar_mask(chan); 1340 1314 1341 1315 if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) 1342 - control |= L2CAP_CTRL_FINAL; 1316 + control |= __set_ctrl_final(chan); 1343 1317 1344 - control |= (chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) 1345 - | (tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); 1318 + control |= __set_reqseq(chan, chan->buffer_seq); 1319 + control |= __set_txseq(chan, tx_seq); 1346 1320 1347 - put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); 1321 + __put_control(chan, control, tx_skb->data + L2CAP_HDR_SIZE); 1348 1322 1349 1323 if (chan->fcs == L2CAP_FCS_CRC16) { 1350 - fcs = crc16(0, (u8 *)tx_skb->data, tx_skb->len - 2); 1351 - put_unaligned_le16(fcs, tx_skb->data + tx_skb->len - 2); 1324 + fcs = crc16(0, (u8 *)tx_skb->data, 1325 + tx_skb->len - L2CAP_FCS_SIZE); 1326 + put_unaligned_le16(fcs, 1327 + tx_skb->data + tx_skb->len - L2CAP_FCS_SIZE); 1352 1328 } 1353 1329 1354 1330 l2cap_do_send(chan, tx_skb); ··· 1360 1330 static int l2cap_ertm_send(struct l2cap_chan *chan) 1361 1331 { 1362 1332 struct sk_buff *skb, *tx_skb; 1363 - u16 control, fcs; 1333 + u16 fcs; 1334 + u32 control; 1364 1335 int nsent = 0; 1365 1336 1366 1337 if (chan->state != BT_CONNECTED) ··· 1379 1348 1380 1349 bt_cb(skb)->retries++; 1381 1350 1382 - control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); 1383 - control &= L2CAP_CTRL_SAR; 1351 + control = __get_control(chan, tx_skb->data + L2CAP_HDR_SIZE); 1352 + control &= __get_sar_mask(chan); 1384 1353 1385 1354 if (test_and_clear_bit(CONN_SEND_FBIT, &chan->conn_state)) 1386 - control |= L2CAP_CTRL_FINAL; 1355 + control |= __set_ctrl_final(chan); 1387 1356 1388 - control |= (chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT) 1389 - | (chan->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT); 1390 - put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); 1357 + control |= __set_reqseq(chan, chan->buffer_seq); 1358 + control |= __set_txseq(chan, chan->next_tx_seq); 1391 1359 1360 + __put_control(chan, control, tx_skb->data + L2CAP_HDR_SIZE); 1392 1361 1393 1362 if (chan->fcs == L2CAP_FCS_CRC16) { 1394 - fcs = crc16(0, (u8 *)skb->data, tx_skb->len - 2); 1395 - put_unaligned_le16(fcs, skb->data + tx_skb->len - 2); 1363 + fcs = crc16(0, (u8 *)skb->data, 1364 + tx_skb->len - L2CAP_FCS_SIZE); 1365 + put_unaligned_le16(fcs, skb->data + 1366 + tx_skb->len - L2CAP_FCS_SIZE); 1396 1367 } 1397 1368 1398 1369 l2cap_do_send(chan, tx_skb); ··· 1402 1369 __set_retrans_timer(chan); 1403 1370 1404 1371 bt_cb(skb)->tx_seq = chan->next_tx_seq; 1405 - chan->next_tx_seq = (chan->next_tx_seq + 1) % 64; 1372 + 1373 + chan->next_tx_seq = __next_seq(chan, chan->next_tx_seq); 1406 1374 1407 1375 if (bt_cb(skb)->retries == 1) 1408 1376 chan->unacked_frames++; ··· 1435 1401 1436 1402 static void l2cap_send_ack(struct l2cap_chan *chan) 1437 1403 { 1438 - u16 control = 0; 1404 + u32 control = 0; 1439 1405 1440 - control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 1406 + control |= __set_reqseq(chan, chan->buffer_seq); 1441 1407 1442 1408 if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { 1443 - control |= L2CAP_SUPER_RCV_NOT_READY; 1409 + control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); 1444 1410 set_bit(CONN_RNR_SENT, &chan->conn_state); 1445 1411 l2cap_send_sframe(chan, control); 1446 1412 return; ··· 1449 1415 if (l2cap_ertm_send(chan) > 0) 1450 1416 return; 1451 1417 1452 - control |= L2CAP_SUPER_RCV_READY; 1418 + control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); 1453 1419 l2cap_send_sframe(chan, control); 1454 1420 } 1455 1421 1456 1422 static void l2cap_send_srejtail(struct l2cap_chan *chan) 1457 1423 { 1458 1424 struct srej_list *tail; 1459 - u16 control; 1425 + u32 control; 1460 1426 1461 - control = L2CAP_SUPER_SELECT_REJECT; 1462 - control |= L2CAP_CTRL_FINAL; 1427 + control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); 1428 + control |= __set_ctrl_final(chan); 1463 1429 1464 1430 tail = list_entry((&chan->srej_l)->prev, struct srej_list, list); 1465 - control |= tail->tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; 1431 + control |= __set_reqseq(chan, tail->tx_seq); 1466 1432 1467 1433 l2cap_send_sframe(chan, control); 1468 1434 } ··· 1490 1456 if (memcpy_fromiovec(skb_put(*frag, count), msg->msg_iov, count)) 1491 1457 return -EFAULT; 1492 1458 1459 + (*frag)->priority = skb->priority; 1460 + 1493 1461 sent += count; 1494 1462 len -= count; 1495 1463 ··· 1501 1465 return sent; 1502 1466 } 1503 1467 1504 - static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len) 1468 + static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, 1469 + struct msghdr *msg, size_t len, 1470 + u32 priority) 1505 1471 { 1506 1472 struct sock *sk = chan->sk; 1507 1473 struct l2cap_conn *conn = chan->conn; 1508 1474 struct sk_buff *skb; 1509 - int err, count, hlen = L2CAP_HDR_SIZE + 2; 1475 + int err, count, hlen = L2CAP_HDR_SIZE + L2CAP_PSMLEN_SIZE; 1510 1476 struct l2cap_hdr *lh; 1511 1477 1512 - BT_DBG("sk %p len %d", sk, (int)len); 1478 + BT_DBG("sk %p len %d priority %u", sk, (int)len, priority); 1513 1479 1514 1480 count = min_t(unsigned int, (conn->mtu - hlen), len); 1515 1481 skb = bt_skb_send_alloc(sk, count + hlen, 1516 1482 msg->msg_flags & MSG_DONTWAIT, &err); 1517 1483 if (!skb) 1518 1484 return ERR_PTR(err); 1485 + 1486 + skb->priority = priority; 1519 1487 1520 1488 /* Create L2CAP header */ 1521 1489 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); ··· 1535 1495 return skb; 1536 1496 } 1537 1497 1538 - static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len) 1498 + static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, 1499 + struct msghdr *msg, size_t len, 1500 + u32 priority) 1539 1501 { 1540 1502 struct sock *sk = chan->sk; 1541 1503 struct l2cap_conn *conn = chan->conn; ··· 1552 1510 msg->msg_flags & MSG_DONTWAIT, &err); 1553 1511 if (!skb) 1554 1512 return ERR_PTR(err); 1513 + 1514 + skb->priority = priority; 1555 1515 1556 1516 /* Create L2CAP header */ 1557 1517 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); ··· 1570 1526 1571 1527 static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, 1572 1528 struct msghdr *msg, size_t len, 1573 - u16 control, u16 sdulen) 1529 + u32 control, u16 sdulen) 1574 1530 { 1575 1531 struct sock *sk = chan->sk; 1576 1532 struct l2cap_conn *conn = chan->conn; 1577 1533 struct sk_buff *skb; 1578 - int err, count, hlen = L2CAP_HDR_SIZE + 2; 1534 + int err, count, hlen; 1579 1535 struct l2cap_hdr *lh; 1580 1536 1581 1537 BT_DBG("sk %p len %d", sk, (int)len); ··· 1583 1539 if (!conn) 1584 1540 return ERR_PTR(-ENOTCONN); 1585 1541 1542 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 1543 + hlen = L2CAP_EXT_HDR_SIZE; 1544 + else 1545 + hlen = L2CAP_ENH_HDR_SIZE; 1546 + 1586 1547 if (sdulen) 1587 - hlen += 2; 1548 + hlen += L2CAP_SDULEN_SIZE; 1588 1549 1589 1550 if (chan->fcs == L2CAP_FCS_CRC16) 1590 - hlen += 2; 1551 + hlen += L2CAP_FCS_SIZE; 1591 1552 1592 1553 count = min_t(unsigned int, (conn->mtu - hlen), len); 1593 1554 skb = bt_skb_send_alloc(sk, count + hlen, ··· 1604 1555 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); 1605 1556 lh->cid = cpu_to_le16(chan->dcid); 1606 1557 lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE)); 1607 - put_unaligned_le16(control, skb_put(skb, 2)); 1558 + 1559 + __put_control(chan, control, skb_put(skb, __ctrl_size(chan))); 1560 + 1608 1561 if (sdulen) 1609 - put_unaligned_le16(sdulen, skb_put(skb, 2)); 1562 + put_unaligned_le16(sdulen, skb_put(skb, L2CAP_SDULEN_SIZE)); 1610 1563 1611 1564 err = l2cap_skbuff_fromiovec(sk, msg, len, count, skb); 1612 1565 if (unlikely(err < 0)) { ··· 1617 1566 } 1618 1567 1619 1568 if (chan->fcs == L2CAP_FCS_CRC16) 1620 - put_unaligned_le16(0, skb_put(skb, 2)); 1569 + put_unaligned_le16(0, skb_put(skb, L2CAP_FCS_SIZE)); 1621 1570 1622 1571 bt_cb(skb)->retries = 0; 1623 1572 return skb; ··· 1627 1576 { 1628 1577 struct sk_buff *skb; 1629 1578 struct sk_buff_head sar_queue; 1630 - u16 control; 1579 + u32 control; 1631 1580 size_t size = 0; 1632 1581 1633 1582 skb_queue_head_init(&sar_queue); 1634 - control = L2CAP_SDU_START; 1583 + control = __set_ctrl_sar(chan, L2CAP_SAR_START); 1635 1584 skb = l2cap_create_iframe_pdu(chan, msg, chan->remote_mps, control, len); 1636 1585 if (IS_ERR(skb)) 1637 1586 return PTR_ERR(skb); ··· 1644 1593 size_t buflen; 1645 1594 1646 1595 if (len > chan->remote_mps) { 1647 - control = L2CAP_SDU_CONTINUE; 1596 + control = __set_ctrl_sar(chan, L2CAP_SAR_CONTINUE); 1648 1597 buflen = chan->remote_mps; 1649 1598 } else { 1650 - control = L2CAP_SDU_END; 1599 + control = __set_ctrl_sar(chan, L2CAP_SAR_END); 1651 1600 buflen = len; 1652 1601 } 1653 1602 ··· 1668 1617 return size; 1669 1618 } 1670 1619 1671 - int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len) 1620 + int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, 1621 + u32 priority) 1672 1622 { 1673 1623 struct sk_buff *skb; 1674 - u16 control; 1624 + u32 control; 1675 1625 int err; 1676 1626 1677 1627 /* Connectionless channel */ 1678 1628 if (chan->chan_type == L2CAP_CHAN_CONN_LESS) { 1679 - skb = l2cap_create_connless_pdu(chan, msg, len); 1629 + skb = l2cap_create_connless_pdu(chan, msg, len, priority); 1680 1630 if (IS_ERR(skb)) 1681 1631 return PTR_ERR(skb); 1682 1632 ··· 1692 1640 return -EMSGSIZE; 1693 1641 1694 1642 /* Create a basic PDU */ 1695 - skb = l2cap_create_basic_pdu(chan, msg, len); 1643 + skb = l2cap_create_basic_pdu(chan, msg, len, priority); 1696 1644 if (IS_ERR(skb)) 1697 1645 return PTR_ERR(skb); 1698 1646 ··· 1704 1652 case L2CAP_MODE_STREAMING: 1705 1653 /* Entire SDU fits into one PDU */ 1706 1654 if (len <= chan->remote_mps) { 1707 - control = L2CAP_SDU_UNSEGMENTED; 1655 + control = __set_ctrl_sar(chan, L2CAP_SAR_UNSEGMENTED); 1708 1656 skb = l2cap_create_iframe_pdu(chan, msg, len, control, 1709 1657 0); 1710 1658 if (IS_ERR(skb)) ··· 1902 1850 *ptr += L2CAP_CONF_OPT_SIZE + len; 1903 1851 } 1904 1852 1853 + static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan) 1854 + { 1855 + struct l2cap_conf_efs efs; 1856 + 1857 + switch(chan->mode) { 1858 + case L2CAP_MODE_ERTM: 1859 + efs.id = chan->local_id; 1860 + efs.stype = chan->local_stype; 1861 + efs.msdu = cpu_to_le16(chan->local_msdu); 1862 + efs.sdu_itime = cpu_to_le32(chan->local_sdu_itime); 1863 + efs.acc_lat = cpu_to_le32(L2CAP_DEFAULT_ACC_LAT); 1864 + efs.flush_to = cpu_to_le32(L2CAP_DEFAULT_FLUSH_TO); 1865 + break; 1866 + 1867 + case L2CAP_MODE_STREAMING: 1868 + efs.id = 1; 1869 + efs.stype = L2CAP_SERV_BESTEFFORT; 1870 + efs.msdu = cpu_to_le16(chan->local_msdu); 1871 + efs.sdu_itime = cpu_to_le32(chan->local_sdu_itime); 1872 + efs.acc_lat = 0; 1873 + efs.flush_to = 0; 1874 + break; 1875 + 1876 + default: 1877 + return; 1878 + } 1879 + 1880 + l2cap_add_conf_opt(ptr, L2CAP_CONF_EFS, sizeof(efs), 1881 + (unsigned long) &efs); 1882 + } 1883 + 1905 1884 static void l2cap_ack_timeout(unsigned long arg) 1906 1885 { 1907 1886 struct l2cap_chan *chan = (void *) arg; ··· 1979 1896 } 1980 1897 } 1981 1898 1899 + static inline bool __l2cap_ews_supported(struct l2cap_chan *chan) 1900 + { 1901 + return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_WINDOW; 1902 + } 1903 + 1904 + static inline bool __l2cap_efs_supported(struct l2cap_chan *chan) 1905 + { 1906 + return enable_hs && chan->conn->feat_mask & L2CAP_FEAT_EXT_FLOW; 1907 + } 1908 + 1909 + static inline void l2cap_txwin_setup(struct l2cap_chan *chan) 1910 + { 1911 + if (chan->tx_win > L2CAP_DEFAULT_TX_WINDOW && 1912 + __l2cap_ews_supported(chan)) { 1913 + /* use extended control field */ 1914 + set_bit(FLAG_EXT_CTRL, &chan->flags); 1915 + chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW; 1916 + } else { 1917 + chan->tx_win = min_t(u16, chan->tx_win, 1918 + L2CAP_DEFAULT_TX_WINDOW); 1919 + chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW; 1920 + } 1921 + } 1922 + 1982 1923 static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data) 1983 1924 { 1984 1925 struct l2cap_conf_req *req = data; 1985 1926 struct l2cap_conf_rfc rfc = { .mode = chan->mode }; 1986 1927 void *ptr = req->data; 1928 + u16 size; 1987 1929 1988 1930 BT_DBG("chan %p", chan); 1989 1931 ··· 2020 1912 case L2CAP_MODE_ERTM: 2021 1913 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state)) 2022 1914 break; 1915 + 1916 + if (__l2cap_efs_supported(chan)) 1917 + set_bit(FLAG_EFS_ENABLE, &chan->flags); 2023 1918 2024 1919 /* fall through */ 2025 1920 default: ··· 2053 1942 2054 1943 case L2CAP_MODE_ERTM: 2055 1944 rfc.mode = L2CAP_MODE_ERTM; 2056 - rfc.txwin_size = chan->tx_win; 2057 1945 rfc.max_transmit = chan->max_tx; 2058 1946 rfc.retrans_timeout = 0; 2059 1947 rfc.monitor_timeout = 0; 2060 - rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE); 2061 - if (L2CAP_DEFAULT_MAX_PDU_SIZE > chan->conn->mtu - 10) 2062 - rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10); 1948 + 1949 + size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - 1950 + L2CAP_EXT_HDR_SIZE - 1951 + L2CAP_SDULEN_SIZE - 1952 + L2CAP_FCS_SIZE); 1953 + rfc.max_pdu_size = cpu_to_le16(size); 1954 + 1955 + l2cap_txwin_setup(chan); 1956 + 1957 + rfc.txwin_size = min_t(u16, chan->tx_win, 1958 + L2CAP_DEFAULT_TX_WINDOW); 2063 1959 2064 1960 l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), 2065 1961 (unsigned long) &rfc); 1962 + 1963 + if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) 1964 + l2cap_add_opt_efs(&ptr, chan); 2066 1965 2067 1966 if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS)) 2068 1967 break; ··· 2082 1961 chan->fcs = L2CAP_FCS_NONE; 2083 1962 l2cap_add_conf_opt(&ptr, L2CAP_CONF_FCS, 1, chan->fcs); 2084 1963 } 1964 + 1965 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 1966 + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, 1967 + chan->tx_win); 2085 1968 break; 2086 1969 2087 1970 case L2CAP_MODE_STREAMING: ··· 2094 1969 rfc.max_transmit = 0; 2095 1970 rfc.retrans_timeout = 0; 2096 1971 rfc.monitor_timeout = 0; 2097 - rfc.max_pdu_size = cpu_to_le16(L2CAP_DEFAULT_MAX_PDU_SIZE); 2098 - if (L2CAP_DEFAULT_MAX_PDU_SIZE > chan->conn->mtu - 10) 2099 - rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10); 1972 + 1973 + size = min_t(u16, L2CAP_DEFAULT_MAX_PDU_SIZE, chan->conn->mtu - 1974 + L2CAP_EXT_HDR_SIZE - 1975 + L2CAP_SDULEN_SIZE - 1976 + L2CAP_FCS_SIZE); 1977 + rfc.max_pdu_size = cpu_to_le16(size); 2100 1978 2101 1979 l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, sizeof(rfc), 2102 1980 (unsigned long) &rfc); 1981 + 1982 + if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) 1983 + l2cap_add_opt_efs(&ptr, chan); 2103 1984 2104 1985 if (!(chan->conn->feat_mask & L2CAP_FEAT_FCS)) 2105 1986 break; ··· 2133 2002 int type, hint, olen; 2134 2003 unsigned long val; 2135 2004 struct l2cap_conf_rfc rfc = { .mode = L2CAP_MODE_BASIC }; 2005 + struct l2cap_conf_efs efs; 2006 + u8 remote_efs = 0; 2136 2007 u16 mtu = L2CAP_DEFAULT_MTU; 2137 2008 u16 result = L2CAP_CONF_SUCCESS; 2009 + u16 size; 2138 2010 2139 2011 BT_DBG("chan %p", chan); 2140 2012 ··· 2167 2033 case L2CAP_CONF_FCS: 2168 2034 if (val == L2CAP_FCS_NONE) 2169 2035 set_bit(CONF_NO_FCS_RECV, &chan->conf_state); 2036 + break; 2170 2037 2038 + case L2CAP_CONF_EFS: 2039 + remote_efs = 1; 2040 + if (olen == sizeof(efs)) 2041 + memcpy(&efs, (void *) val, olen); 2042 + break; 2043 + 2044 + case L2CAP_CONF_EWS: 2045 + if (!enable_hs) 2046 + return -ECONNREFUSED; 2047 + 2048 + set_bit(FLAG_EXT_CTRL, &chan->flags); 2049 + set_bit(CONF_EWS_RECV, &chan->conf_state); 2050 + chan->tx_win_max = L2CAP_DEFAULT_EXT_WINDOW; 2051 + chan->remote_tx_win = val; 2171 2052 break; 2172 2053 2173 2054 default: ··· 2207 2058 break; 2208 2059 } 2209 2060 2061 + if (remote_efs) { 2062 + if (__l2cap_efs_supported(chan)) 2063 + set_bit(FLAG_EFS_ENABLE, &chan->flags); 2064 + else 2065 + return -ECONNREFUSED; 2066 + } 2067 + 2210 2068 if (chan->mode != rfc.mode) 2211 2069 return -ECONNREFUSED; 2212 2070 ··· 2232 2076 sizeof(rfc), (unsigned long) &rfc); 2233 2077 } 2234 2078 2235 - 2236 2079 if (result == L2CAP_CONF_SUCCESS) { 2237 2080 /* Configure output options and let the other side know 2238 2081 * which ones we don't like. */ ··· 2244 2089 } 2245 2090 l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, chan->omtu); 2246 2091 2092 + if (remote_efs) { 2093 + if (chan->local_stype != L2CAP_SERV_NOTRAFIC && 2094 + efs.stype != L2CAP_SERV_NOTRAFIC && 2095 + efs.stype != chan->local_stype) { 2096 + 2097 + result = L2CAP_CONF_UNACCEPT; 2098 + 2099 + if (chan->num_conf_req >= 1) 2100 + return -ECONNREFUSED; 2101 + 2102 + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, 2103 + sizeof(efs), 2104 + (unsigned long) &efs); 2105 + } else { 2106 + /* Send PENDING Conf Rsp */ 2107 + result = L2CAP_CONF_PENDING; 2108 + set_bit(CONF_LOC_CONF_PEND, &chan->conf_state); 2109 + } 2110 + } 2111 + 2247 2112 switch (rfc.mode) { 2248 2113 case L2CAP_MODE_BASIC: 2249 2114 chan->fcs = L2CAP_FCS_NONE; ··· 2271 2096 break; 2272 2097 2273 2098 case L2CAP_MODE_ERTM: 2274 - chan->remote_tx_win = rfc.txwin_size; 2099 + if (!test_bit(CONF_EWS_RECV, &chan->conf_state)) 2100 + chan->remote_tx_win = rfc.txwin_size; 2101 + else 2102 + rfc.txwin_size = L2CAP_DEFAULT_TX_WINDOW; 2103 + 2275 2104 chan->remote_max_tx = rfc.max_transmit; 2276 2105 2277 - if (le16_to_cpu(rfc.max_pdu_size) > chan->conn->mtu - 10) 2278 - rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10); 2279 - 2280 - chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); 2106 + size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), 2107 + chan->conn->mtu - 2108 + L2CAP_EXT_HDR_SIZE - 2109 + L2CAP_SDULEN_SIZE - 2110 + L2CAP_FCS_SIZE); 2111 + rfc.max_pdu_size = cpu_to_le16(size); 2112 + chan->remote_mps = size; 2281 2113 2282 2114 rfc.retrans_timeout = 2283 2115 le16_to_cpu(L2CAP_DEFAULT_RETRANS_TO); ··· 2296 2114 l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, 2297 2115 sizeof(rfc), (unsigned long) &rfc); 2298 2116 2117 + if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { 2118 + chan->remote_id = efs.id; 2119 + chan->remote_stype = efs.stype; 2120 + chan->remote_msdu = le16_to_cpu(efs.msdu); 2121 + chan->remote_flush_to = 2122 + le32_to_cpu(efs.flush_to); 2123 + chan->remote_acc_lat = 2124 + le32_to_cpu(efs.acc_lat); 2125 + chan->remote_sdu_itime = 2126 + le32_to_cpu(efs.sdu_itime); 2127 + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, 2128 + sizeof(efs), (unsigned long) &efs); 2129 + } 2299 2130 break; 2300 2131 2301 2132 case L2CAP_MODE_STREAMING: 2302 - if (le16_to_cpu(rfc.max_pdu_size) > chan->conn->mtu - 10) 2303 - rfc.max_pdu_size = cpu_to_le16(chan->conn->mtu - 10); 2304 - 2305 - chan->remote_mps = le16_to_cpu(rfc.max_pdu_size); 2133 + size = min_t(u16, le16_to_cpu(rfc.max_pdu_size), 2134 + chan->conn->mtu - 2135 + L2CAP_EXT_HDR_SIZE - 2136 + L2CAP_SDULEN_SIZE - 2137 + L2CAP_FCS_SIZE); 2138 + rfc.max_pdu_size = cpu_to_le16(size); 2139 + chan->remote_mps = size; 2306 2140 2307 2141 set_bit(CONF_MODE_DONE, &chan->conf_state); 2308 2142 ··· 2351 2153 int type, olen; 2352 2154 unsigned long val; 2353 2155 struct l2cap_conf_rfc rfc; 2156 + struct l2cap_conf_efs efs; 2354 2157 2355 2158 BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data); 2356 2159 ··· 2387 2188 l2cap_add_conf_opt(&ptr, L2CAP_CONF_RFC, 2388 2189 sizeof(rfc), (unsigned long) &rfc); 2389 2190 break; 2191 + 2192 + case L2CAP_CONF_EWS: 2193 + chan->tx_win = min_t(u16, val, 2194 + L2CAP_DEFAULT_EXT_WINDOW); 2195 + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EWS, 2, 2196 + chan->tx_win); 2197 + break; 2198 + 2199 + case L2CAP_CONF_EFS: 2200 + if (olen == sizeof(efs)) 2201 + memcpy(&efs, (void *)val, olen); 2202 + 2203 + if (chan->local_stype != L2CAP_SERV_NOTRAFIC && 2204 + efs.stype != L2CAP_SERV_NOTRAFIC && 2205 + efs.stype != chan->local_stype) 2206 + return -ECONNREFUSED; 2207 + 2208 + l2cap_add_conf_opt(&ptr, L2CAP_CONF_EFS, 2209 + sizeof(efs), (unsigned long) &efs); 2210 + break; 2390 2211 } 2391 2212 } 2392 2213 ··· 2415 2196 2416 2197 chan->mode = rfc.mode; 2417 2198 2418 - if (*result == L2CAP_CONF_SUCCESS) { 2199 + if (*result == L2CAP_CONF_SUCCESS || *result == L2CAP_CONF_PENDING) { 2419 2200 switch (rfc.mode) { 2420 2201 case L2CAP_MODE_ERTM: 2421 2202 chan->retrans_timeout = le16_to_cpu(rfc.retrans_timeout); 2422 2203 chan->monitor_timeout = le16_to_cpu(rfc.monitor_timeout); 2423 2204 chan->mps = le16_to_cpu(rfc.max_pdu_size); 2205 + 2206 + if (test_bit(FLAG_EFS_ENABLE, &chan->flags)) { 2207 + chan->local_msdu = le16_to_cpu(efs.msdu); 2208 + chan->local_sdu_itime = 2209 + le32_to_cpu(efs.sdu_itime); 2210 + chan->local_acc_lat = le32_to_cpu(efs.acc_lat); 2211 + chan->local_flush_to = 2212 + le32_to_cpu(efs.flush_to); 2213 + } 2424 2214 break; 2215 + 2425 2216 case L2CAP_MODE_STREAMING: 2426 2217 chan->mps = le16_to_cpu(rfc.max_pdu_size); 2427 2218 } ··· 2559 2330 /* Check if the ACL is secure enough (if not SDP) */ 2560 2331 if (psm != cpu_to_le16(0x0001) && 2561 2332 !hci_conn_check_link_mode(conn->hcon)) { 2562 - conn->disc_reason = 0x05; 2333 + conn->disc_reason = HCI_ERROR_AUTH_FAILURE; 2563 2334 result = L2CAP_CR_SEC_BLOCK; 2564 2335 goto response; 2565 2336 } ··· 2717 2488 if (sock_owned_by_user(sk)) { 2718 2489 l2cap_state_change(chan, BT_DISCONN); 2719 2490 __clear_chan_timer(chan); 2720 - __set_chan_timer(chan, HZ / 5); 2491 + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); 2721 2492 break; 2722 2493 } 2723 2494 ··· 2831 2602 chan->num_conf_req++; 2832 2603 } 2833 2604 2605 + /* Got Conf Rsp PENDING from remote side and asume we sent 2606 + Conf Rsp PENDING in the code above */ 2607 + if (test_bit(CONF_REM_CONF_PEND, &chan->conf_state) && 2608 + test_bit(CONF_LOC_CONF_PEND, &chan->conf_state)) { 2609 + 2610 + /* check compatibility */ 2611 + 2612 + clear_bit(CONF_LOC_CONF_PEND, &chan->conf_state); 2613 + set_bit(CONF_OUTPUT_DONE, &chan->conf_state); 2614 + 2615 + l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, 2616 + l2cap_build_conf_rsp(chan, rsp, 2617 + L2CAP_CONF_SUCCESS, 0x0000), rsp); 2618 + } 2619 + 2834 2620 unlock: 2835 2621 bh_unlock_sock(sk); 2836 2622 return 0; ··· 2875 2631 switch (result) { 2876 2632 case L2CAP_CONF_SUCCESS: 2877 2633 l2cap_conf_rfc_get(chan, rsp->data, len); 2634 + clear_bit(CONF_REM_CONF_PEND, &chan->conf_state); 2878 2635 break; 2636 + 2637 + case L2CAP_CONF_PENDING: 2638 + set_bit(CONF_REM_CONF_PEND, &chan->conf_state); 2639 + 2640 + if (test_bit(CONF_LOC_CONF_PEND, &chan->conf_state)) { 2641 + char buf[64]; 2642 + 2643 + len = l2cap_parse_conf_rsp(chan, rsp->data, len, 2644 + buf, &result); 2645 + if (len < 0) { 2646 + l2cap_send_disconn_req(conn, chan, ECONNRESET); 2647 + goto done; 2648 + } 2649 + 2650 + /* check compatibility */ 2651 + 2652 + clear_bit(CONF_LOC_CONF_PEND, &chan->conf_state); 2653 + set_bit(CONF_OUTPUT_DONE, &chan->conf_state); 2654 + 2655 + l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP, 2656 + l2cap_build_conf_rsp(chan, buf, 2657 + L2CAP_CONF_SUCCESS, 0x0000), buf); 2658 + } 2659 + goto done; 2879 2660 2880 2661 case L2CAP_CONF_UNACCEPT: 2881 2662 if (chan->num_conf_rsp <= L2CAP_CONF_MAX_CONF_RSP) { ··· 2930 2661 2931 2662 default: 2932 2663 sk->sk_err = ECONNRESET; 2933 - __set_chan_timer(chan, HZ * 5); 2664 + __set_chan_timer(chan, L2CAP_DISC_REJ_TIMEOUT); 2934 2665 l2cap_send_disconn_req(conn, chan, ECONNRESET); 2935 2666 goto done; 2936 2667 } ··· 2987 2718 if (sock_owned_by_user(sk)) { 2988 2719 l2cap_state_change(chan, BT_DISCONN); 2989 2720 __clear_chan_timer(chan); 2990 - __set_chan_timer(chan, HZ / 5); 2721 + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); 2991 2722 bh_unlock_sock(sk); 2992 2723 return 0; 2993 2724 } ··· 3021 2752 if (sock_owned_by_user(sk)) { 3022 2753 l2cap_state_change(chan,BT_DISCONN); 3023 2754 __clear_chan_timer(chan); 3024 - __set_chan_timer(chan, HZ / 5); 2755 + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); 3025 2756 bh_unlock_sock(sk); 3026 2757 return 0; 3027 2758 } ··· 3051 2782 if (!disable_ertm) 3052 2783 feat_mask |= L2CAP_FEAT_ERTM | L2CAP_FEAT_STREAMING 3053 2784 | L2CAP_FEAT_FCS; 2785 + if (enable_hs) 2786 + feat_mask |= L2CAP_FEAT_EXT_FLOW 2787 + | L2CAP_FEAT_EXT_WINDOW; 2788 + 3054 2789 put_unaligned_le32(feat_mask, rsp->data); 3055 2790 l2cap_send_cmd(conn, cmd->ident, 3056 2791 L2CAP_INFO_RSP, sizeof(buf), buf); 3057 2792 } else if (type == L2CAP_IT_FIXED_CHAN) { 3058 2793 u8 buf[12]; 3059 2794 struct l2cap_info_rsp *rsp = (struct l2cap_info_rsp *) buf; 2795 + 2796 + if (enable_hs) 2797 + l2cap_fixed_chan[0] |= L2CAP_FC_A2MP; 2798 + else 2799 + l2cap_fixed_chan[0] &= ~L2CAP_FC_A2MP; 2800 + 3060 2801 rsp->type = cpu_to_le16(L2CAP_IT_FIXED_CHAN); 3061 2802 rsp->result = cpu_to_le16(L2CAP_IR_SUCCESS); 3062 - memcpy(buf + 4, l2cap_fixed_chan, 8); 2803 + memcpy(rsp->data, l2cap_fixed_chan, sizeof(l2cap_fixed_chan)); 3063 2804 l2cap_send_cmd(conn, cmd->ident, 3064 2805 L2CAP_INFO_RSP, sizeof(buf), buf); 3065 2806 } else { ··· 3132 2853 3133 2854 l2cap_conn_start(conn); 3134 2855 } 2856 + 2857 + return 0; 2858 + } 2859 + 2860 + static inline int l2cap_create_channel_req(struct l2cap_conn *conn, 2861 + struct l2cap_cmd_hdr *cmd, u16 cmd_len, 2862 + void *data) 2863 + { 2864 + struct l2cap_create_chan_req *req = data; 2865 + struct l2cap_create_chan_rsp rsp; 2866 + u16 psm, scid; 2867 + 2868 + if (cmd_len != sizeof(*req)) 2869 + return -EPROTO; 2870 + 2871 + if (!enable_hs) 2872 + return -EINVAL; 2873 + 2874 + psm = le16_to_cpu(req->psm); 2875 + scid = le16_to_cpu(req->scid); 2876 + 2877 + BT_DBG("psm %d, scid %d, amp_id %d", psm, scid, req->amp_id); 2878 + 2879 + /* Placeholder: Always reject */ 2880 + rsp.dcid = 0; 2881 + rsp.scid = cpu_to_le16(scid); 2882 + rsp.result = L2CAP_CR_NO_MEM; 2883 + rsp.status = L2CAP_CS_NO_INFO; 2884 + 2885 + l2cap_send_cmd(conn, cmd->ident, L2CAP_CREATE_CHAN_RSP, 2886 + sizeof(rsp), &rsp); 2887 + 2888 + return 0; 2889 + } 2890 + 2891 + static inline int l2cap_create_channel_rsp(struct l2cap_conn *conn, 2892 + struct l2cap_cmd_hdr *cmd, void *data) 2893 + { 2894 + BT_DBG("conn %p", conn); 2895 + 2896 + return l2cap_connect_rsp(conn, cmd, data); 2897 + } 2898 + 2899 + static void l2cap_send_move_chan_rsp(struct l2cap_conn *conn, u8 ident, 2900 + u16 icid, u16 result) 2901 + { 2902 + struct l2cap_move_chan_rsp rsp; 2903 + 2904 + BT_DBG("icid %d, result %d", icid, result); 2905 + 2906 + rsp.icid = cpu_to_le16(icid); 2907 + rsp.result = cpu_to_le16(result); 2908 + 2909 + l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_RSP, sizeof(rsp), &rsp); 2910 + } 2911 + 2912 + static void l2cap_send_move_chan_cfm(struct l2cap_conn *conn, 2913 + struct l2cap_chan *chan, u16 icid, u16 result) 2914 + { 2915 + struct l2cap_move_chan_cfm cfm; 2916 + u8 ident; 2917 + 2918 + BT_DBG("icid %d, result %d", icid, result); 2919 + 2920 + ident = l2cap_get_ident(conn); 2921 + if (chan) 2922 + chan->ident = ident; 2923 + 2924 + cfm.icid = cpu_to_le16(icid); 2925 + cfm.result = cpu_to_le16(result); 2926 + 2927 + l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_CFM, sizeof(cfm), &cfm); 2928 + } 2929 + 2930 + static void l2cap_send_move_chan_cfm_rsp(struct l2cap_conn *conn, u8 ident, 2931 + u16 icid) 2932 + { 2933 + struct l2cap_move_chan_cfm_rsp rsp; 2934 + 2935 + BT_DBG("icid %d", icid); 2936 + 2937 + rsp.icid = cpu_to_le16(icid); 2938 + l2cap_send_cmd(conn, ident, L2CAP_MOVE_CHAN_CFM_RSP, sizeof(rsp), &rsp); 2939 + } 2940 + 2941 + static inline int l2cap_move_channel_req(struct l2cap_conn *conn, 2942 + struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) 2943 + { 2944 + struct l2cap_move_chan_req *req = data; 2945 + u16 icid = 0; 2946 + u16 result = L2CAP_MR_NOT_ALLOWED; 2947 + 2948 + if (cmd_len != sizeof(*req)) 2949 + return -EPROTO; 2950 + 2951 + icid = le16_to_cpu(req->icid); 2952 + 2953 + BT_DBG("icid %d, dest_amp_id %d", icid, req->dest_amp_id); 2954 + 2955 + if (!enable_hs) 2956 + return -EINVAL; 2957 + 2958 + /* Placeholder: Always refuse */ 2959 + l2cap_send_move_chan_rsp(conn, cmd->ident, icid, result); 2960 + 2961 + return 0; 2962 + } 2963 + 2964 + static inline int l2cap_move_channel_rsp(struct l2cap_conn *conn, 2965 + struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) 2966 + { 2967 + struct l2cap_move_chan_rsp *rsp = data; 2968 + u16 icid, result; 2969 + 2970 + if (cmd_len != sizeof(*rsp)) 2971 + return -EPROTO; 2972 + 2973 + icid = le16_to_cpu(rsp->icid); 2974 + result = le16_to_cpu(rsp->result); 2975 + 2976 + BT_DBG("icid %d, result %d", icid, result); 2977 + 2978 + /* Placeholder: Always unconfirmed */ 2979 + l2cap_send_move_chan_cfm(conn, NULL, icid, L2CAP_MC_UNCONFIRMED); 2980 + 2981 + return 0; 2982 + } 2983 + 2984 + static inline int l2cap_move_channel_confirm(struct l2cap_conn *conn, 2985 + struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) 2986 + { 2987 + struct l2cap_move_chan_cfm *cfm = data; 2988 + u16 icid, result; 2989 + 2990 + if (cmd_len != sizeof(*cfm)) 2991 + return -EPROTO; 2992 + 2993 + icid = le16_to_cpu(cfm->icid); 2994 + result = le16_to_cpu(cfm->result); 2995 + 2996 + BT_DBG("icid %d, result %d", icid, result); 2997 + 2998 + l2cap_send_move_chan_cfm_rsp(conn, cmd->ident, icid); 2999 + 3000 + return 0; 3001 + } 3002 + 3003 + static inline int l2cap_move_channel_confirm_rsp(struct l2cap_conn *conn, 3004 + struct l2cap_cmd_hdr *cmd, u16 cmd_len, void *data) 3005 + { 3006 + struct l2cap_move_chan_cfm_rsp *rsp = data; 3007 + u16 icid; 3008 + 3009 + if (cmd_len != sizeof(*rsp)) 3010 + return -EPROTO; 3011 + 3012 + icid = le16_to_cpu(rsp->icid); 3013 + 3014 + BT_DBG("icid %d", icid); 3135 3015 3136 3016 return 0; 3137 3017 } ··· 3407 2969 err = l2cap_information_rsp(conn, cmd, data); 3408 2970 break; 3409 2971 2972 + case L2CAP_CREATE_CHAN_REQ: 2973 + err = l2cap_create_channel_req(conn, cmd, cmd_len, data); 2974 + break; 2975 + 2976 + case L2CAP_CREATE_CHAN_RSP: 2977 + err = l2cap_create_channel_rsp(conn, cmd, data); 2978 + break; 2979 + 2980 + case L2CAP_MOVE_CHAN_REQ: 2981 + err = l2cap_move_channel_req(conn, cmd, cmd_len, data); 2982 + break; 2983 + 2984 + case L2CAP_MOVE_CHAN_RSP: 2985 + err = l2cap_move_channel_rsp(conn, cmd, cmd_len, data); 2986 + break; 2987 + 2988 + case L2CAP_MOVE_CHAN_CFM: 2989 + err = l2cap_move_channel_confirm(conn, cmd, cmd_len, data); 2990 + break; 2991 + 2992 + case L2CAP_MOVE_CHAN_CFM_RSP: 2993 + err = l2cap_move_channel_confirm_rsp(conn, cmd, cmd_len, data); 2994 + break; 2995 + 3410 2996 default: 3411 2997 BT_ERR("Unknown BR/EDR signaling command 0x%2.2x", cmd->code); 3412 2998 err = -EINVAL; ··· 3509 3047 static int l2cap_check_fcs(struct l2cap_chan *chan, struct sk_buff *skb) 3510 3048 { 3511 3049 u16 our_fcs, rcv_fcs; 3512 - int hdr_size = L2CAP_HDR_SIZE + 2; 3050 + int hdr_size; 3051 + 3052 + if (test_bit(FLAG_EXT_CTRL, &chan->flags)) 3053 + hdr_size = L2CAP_EXT_HDR_SIZE; 3054 + else 3055 + hdr_size = L2CAP_ENH_HDR_SIZE; 3513 3056 3514 3057 if (chan->fcs == L2CAP_FCS_CRC16) { 3515 - skb_trim(skb, skb->len - 2); 3058 + skb_trim(skb, skb->len - L2CAP_FCS_SIZE); 3516 3059 rcv_fcs = get_unaligned_le16(skb->data + skb->len); 3517 3060 our_fcs = crc16(0, skb->data - hdr_size, skb->len + hdr_size); 3518 3061 ··· 3529 3062 3530 3063 static inline void l2cap_send_i_or_rr_or_rnr(struct l2cap_chan *chan) 3531 3064 { 3532 - u16 control = 0; 3065 + u32 control = 0; 3533 3066 3534 3067 chan->frames_sent = 0; 3535 3068 3536 - control |= chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3069 + control |= __set_reqseq(chan, chan->buffer_seq); 3537 3070 3538 3071 if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { 3539 - control |= L2CAP_SUPER_RCV_NOT_READY; 3072 + control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); 3540 3073 l2cap_send_sframe(chan, control); 3541 3074 set_bit(CONN_RNR_SENT, &chan->conn_state); 3542 3075 } ··· 3548 3081 3549 3082 if (!test_bit(CONN_LOCAL_BUSY, &chan->conn_state) && 3550 3083 chan->frames_sent == 0) { 3551 - control |= L2CAP_SUPER_RCV_READY; 3084 + control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); 3552 3085 l2cap_send_sframe(chan, control); 3553 3086 } 3554 3087 } 3555 3088 3556 - static int l2cap_add_to_srej_queue(struct l2cap_chan *chan, struct sk_buff *skb, u8 tx_seq, u8 sar) 3089 + static int l2cap_add_to_srej_queue(struct l2cap_chan *chan, struct sk_buff *skb, u16 tx_seq, u8 sar) 3557 3090 { 3558 3091 struct sk_buff *next_skb; 3559 3092 int tx_seq_offset, next_tx_seq_offset; ··· 3567 3100 return 0; 3568 3101 } 3569 3102 3570 - tx_seq_offset = (tx_seq - chan->buffer_seq) % 64; 3571 - if (tx_seq_offset < 0) 3572 - tx_seq_offset += 64; 3103 + tx_seq_offset = __seq_offset(chan, tx_seq, chan->buffer_seq); 3573 3104 3574 3105 do { 3575 3106 if (bt_cb(next_skb)->tx_seq == tx_seq) 3576 3107 return -EINVAL; 3577 3108 3578 - next_tx_seq_offset = (bt_cb(next_skb)->tx_seq - 3579 - chan->buffer_seq) % 64; 3580 - if (next_tx_seq_offset < 0) 3581 - next_tx_seq_offset += 64; 3109 + next_tx_seq_offset = __seq_offset(chan, 3110 + bt_cb(next_skb)->tx_seq, chan->buffer_seq); 3582 3111 3583 3112 if (next_tx_seq_offset > tx_seq_offset) { 3584 3113 __skb_queue_before(&chan->srej_q, next_skb, skb); ··· 3610 3147 skb->truesize += new_frag->truesize; 3611 3148 } 3612 3149 3613 - static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u16 control) 3150 + static int l2cap_reassemble_sdu(struct l2cap_chan *chan, struct sk_buff *skb, u32 control) 3614 3151 { 3615 3152 int err = -EINVAL; 3616 3153 3617 - switch (control & L2CAP_CTRL_SAR) { 3618 - case L2CAP_SDU_UNSEGMENTED: 3154 + switch (__get_ctrl_sar(chan, control)) { 3155 + case L2CAP_SAR_UNSEGMENTED: 3619 3156 if (chan->sdu) 3620 3157 break; 3621 3158 3622 3159 err = chan->ops->recv(chan->data, skb); 3623 3160 break; 3624 3161 3625 - case L2CAP_SDU_START: 3162 + case L2CAP_SAR_START: 3626 3163 if (chan->sdu) 3627 3164 break; 3628 3165 3629 3166 chan->sdu_len = get_unaligned_le16(skb->data); 3630 - skb_pull(skb, 2); 3167 + skb_pull(skb, L2CAP_SDULEN_SIZE); 3631 3168 3632 3169 if (chan->sdu_len > chan->imtu) { 3633 3170 err = -EMSGSIZE; ··· 3644 3181 err = 0; 3645 3182 break; 3646 3183 3647 - case L2CAP_SDU_CONTINUE: 3184 + case L2CAP_SAR_CONTINUE: 3648 3185 if (!chan->sdu) 3649 3186 break; 3650 3187 ··· 3658 3195 err = 0; 3659 3196 break; 3660 3197 3661 - case L2CAP_SDU_END: 3198 + case L2CAP_SAR_END: 3662 3199 if (!chan->sdu) 3663 3200 break; 3664 3201 ··· 3693 3230 3694 3231 static void l2cap_ertm_enter_local_busy(struct l2cap_chan *chan) 3695 3232 { 3696 - u16 control; 3233 + u32 control; 3697 3234 3698 3235 BT_DBG("chan %p, Enter local busy", chan); 3699 3236 3700 3237 set_bit(CONN_LOCAL_BUSY, &chan->conn_state); 3701 3238 3702 - control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3703 - control |= L2CAP_SUPER_RCV_NOT_READY; 3239 + control = __set_reqseq(chan, chan->buffer_seq); 3240 + control |= __set_ctrl_super(chan, L2CAP_SUPER_RNR); 3704 3241 l2cap_send_sframe(chan, control); 3705 3242 3706 3243 set_bit(CONN_RNR_SENT, &chan->conn_state); ··· 3710 3247 3711 3248 static void l2cap_ertm_exit_local_busy(struct l2cap_chan *chan) 3712 3249 { 3713 - u16 control; 3250 + u32 control; 3714 3251 3715 3252 if (!test_bit(CONN_RNR_SENT, &chan->conn_state)) 3716 3253 goto done; 3717 3254 3718 - control = chan->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3719 - control |= L2CAP_SUPER_RCV_READY | L2CAP_CTRL_POLL; 3255 + control = __set_reqseq(chan, chan->buffer_seq); 3256 + control |= __set_ctrl_poll(chan); 3257 + control |= __set_ctrl_super(chan, L2CAP_SUPER_RR); 3720 3258 l2cap_send_sframe(chan, control); 3721 3259 chan->retry_count = 1; 3722 3260 ··· 3743 3279 } 3744 3280 } 3745 3281 3746 - static void l2cap_check_srej_gap(struct l2cap_chan *chan, u8 tx_seq) 3282 + static void l2cap_check_srej_gap(struct l2cap_chan *chan, u16 tx_seq) 3747 3283 { 3748 3284 struct sk_buff *skb; 3749 - u16 control; 3285 + u32 control; 3750 3286 3751 3287 while ((skb = skb_peek(&chan->srej_q)) && 3752 3288 !test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { ··· 3756 3292 break; 3757 3293 3758 3294 skb = skb_dequeue(&chan->srej_q); 3759 - control = bt_cb(skb)->sar << L2CAP_CTRL_SAR_SHIFT; 3295 + control = __set_ctrl_sar(chan, bt_cb(skb)->sar); 3760 3296 err = l2cap_reassemble_sdu(chan, skb, control); 3761 3297 3762 3298 if (err < 0) { ··· 3764 3300 break; 3765 3301 } 3766 3302 3767 - chan->buffer_seq_srej = 3768 - (chan->buffer_seq_srej + 1) % 64; 3769 - tx_seq = (tx_seq + 1) % 64; 3303 + chan->buffer_seq_srej = __next_seq(chan, chan->buffer_seq_srej); 3304 + tx_seq = __next_seq(chan, tx_seq); 3770 3305 } 3771 3306 } 3772 3307 3773 - static void l2cap_resend_srejframe(struct l2cap_chan *chan, u8 tx_seq) 3308 + static void l2cap_resend_srejframe(struct l2cap_chan *chan, u16 tx_seq) 3774 3309 { 3775 3310 struct srej_list *l, *tmp; 3776 - u16 control; 3311 + u32 control; 3777 3312 3778 3313 list_for_each_entry_safe(l, tmp, &chan->srej_l, list) { 3779 3314 if (l->tx_seq == tx_seq) { ··· 3780 3317 kfree(l); 3781 3318 return; 3782 3319 } 3783 - control = L2CAP_SUPER_SELECT_REJECT; 3784 - control |= l->tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3320 + control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); 3321 + control |= __set_reqseq(chan, l->tx_seq); 3785 3322 l2cap_send_sframe(chan, control); 3786 3323 list_del(&l->list); 3787 3324 list_add_tail(&l->list, &chan->srej_l); 3788 3325 } 3789 3326 } 3790 3327 3791 - static void l2cap_send_srejframe(struct l2cap_chan *chan, u8 tx_seq) 3328 + static void l2cap_send_srejframe(struct l2cap_chan *chan, u16 tx_seq) 3792 3329 { 3793 3330 struct srej_list *new; 3794 - u16 control; 3331 + u32 control; 3795 3332 3796 3333 while (tx_seq != chan->expected_tx_seq) { 3797 - control = L2CAP_SUPER_SELECT_REJECT; 3798 - control |= chan->expected_tx_seq << L2CAP_CTRL_REQSEQ_SHIFT; 3334 + control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ); 3335 + control |= __set_reqseq(chan, chan->expected_tx_seq); 3799 3336 l2cap_send_sframe(chan, control); 3800 3337 3801 3338 new = kzalloc(sizeof(struct srej_list), GFP_ATOMIC); 3802 3339 new->tx_seq = chan->expected_tx_seq; 3803 - chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64; 3340 + 3341 + chan->expected_tx_seq = __next_seq(chan, chan->expected_tx_seq); 3342 + 3804 3343 list_add_tail(&new->list, &chan->srej_l); 3805 3344 } 3806 - chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64; 3345 + 3346 + chan->expected_tx_seq = __next_seq(chan, chan->expected_tx_seq); 3807 3347 } 3808 3348 3809 - static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) 3349 + static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u32 rx_control, struct sk_buff *skb) 3810 3350 { 3811 - u8 tx_seq = __get_txseq(rx_control); 3812 - u8 req_seq = __get_reqseq(rx_control); 3813 - u8 sar = rx_control >> L2CAP_CTRL_SAR_SHIFT; 3351 + u16 tx_seq = __get_txseq(chan, rx_control); 3352 + u16 req_seq = __get_reqseq(chan, rx_control); 3353 + u8 sar = __get_ctrl_sar(chan, rx_control); 3814 3354 int tx_seq_offset, expected_tx_seq_offset; 3815 3355 int num_to_ack = (chan->tx_win/6) + 1; 3816 3356 int err = 0; 3817 3357 3818 - BT_DBG("chan %p len %d tx_seq %d rx_control 0x%4.4x", chan, skb->len, 3358 + BT_DBG("chan %p len %d tx_seq %d rx_control 0x%8.8x", chan, skb->len, 3819 3359 tx_seq, rx_control); 3820 3360 3821 - if (L2CAP_CTRL_FINAL & rx_control && 3361 + if (__is_ctrl_final(chan, rx_control) && 3822 3362 test_bit(CONN_WAIT_F, &chan->conn_state)) { 3823 3363 __clear_monitor_timer(chan); 3824 3364 if (chan->unacked_frames > 0) ··· 3832 3366 chan->expected_ack_seq = req_seq; 3833 3367 l2cap_drop_acked_frames(chan); 3834 3368 3835 - tx_seq_offset = (tx_seq - chan->buffer_seq) % 64; 3836 - if (tx_seq_offset < 0) 3837 - tx_seq_offset += 64; 3369 + tx_seq_offset = __seq_offset(chan, tx_seq, chan->buffer_seq); 3838 3370 3839 3371 /* invalid tx_seq */ 3840 3372 if (tx_seq_offset >= chan->tx_win) { ··· 3880 3416 l2cap_send_srejframe(chan, tx_seq); 3881 3417 } 3882 3418 } else { 3883 - expected_tx_seq_offset = 3884 - (chan->expected_tx_seq - chan->buffer_seq) % 64; 3885 - if (expected_tx_seq_offset < 0) 3886 - expected_tx_seq_offset += 64; 3419 + expected_tx_seq_offset = __seq_offset(chan, 3420 + chan->expected_tx_seq, chan->buffer_seq); 3887 3421 3888 3422 /* duplicated tx_seq */ 3889 3423 if (tx_seq_offset < expected_tx_seq_offset) ··· 3906 3444 return 0; 3907 3445 3908 3446 expected: 3909 - chan->expected_tx_seq = (chan->expected_tx_seq + 1) % 64; 3447 + chan->expected_tx_seq = __next_seq(chan, chan->expected_tx_seq); 3910 3448 3911 3449 if (test_bit(CONN_SREJ_SENT, &chan->conn_state)) { 3912 3450 bt_cb(skb)->tx_seq = tx_seq; ··· 3916 3454 } 3917 3455 3918 3456 err = l2cap_reassemble_sdu(chan, skb, rx_control); 3919 - chan->buffer_seq = (chan->buffer_seq + 1) % 64; 3457 + chan->buffer_seq = __next_seq(chan, chan->buffer_seq); 3458 + 3920 3459 if (err < 0) { 3921 3460 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 3922 3461 return err; 3923 3462 } 3924 3463 3925 - if (rx_control & L2CAP_CTRL_FINAL) { 3464 + if (__is_ctrl_final(chan, rx_control)) { 3926 3465 if (!test_and_clear_bit(CONN_REJ_ACT, &chan->conn_state)) 3927 3466 l2cap_retransmit_frames(chan); 3928 3467 } ··· 3941 3478 return 0; 3942 3479 } 3943 3480 3944 - static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_control) 3481 + static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u32 rx_control) 3945 3482 { 3946 - BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, __get_reqseq(rx_control), 3947 - rx_control); 3483 + BT_DBG("chan %p, req_seq %d ctrl 0x%8.8x", chan, 3484 + __get_reqseq(chan, rx_control), rx_control); 3948 3485 3949 - chan->expected_ack_seq = __get_reqseq(rx_control); 3486 + chan->expected_ack_seq = __get_reqseq(chan, rx_control); 3950 3487 l2cap_drop_acked_frames(chan); 3951 3488 3952 - if (rx_control & L2CAP_CTRL_POLL) { 3489 + if (__is_ctrl_poll(chan, rx_control)) { 3953 3490 set_bit(CONN_SEND_FBIT, &chan->conn_state); 3954 3491 if (test_bit(CONN_SREJ_SENT, &chan->conn_state)) { 3955 3492 if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state) && ··· 3962 3499 l2cap_send_i_or_rr_or_rnr(chan); 3963 3500 } 3964 3501 3965 - } else if (rx_control & L2CAP_CTRL_FINAL) { 3502 + } else if (__is_ctrl_final(chan, rx_control)) { 3966 3503 clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); 3967 3504 3968 3505 if (!test_and_clear_bit(CONN_REJ_ACT, &chan->conn_state)) ··· 3981 3518 } 3982 3519 } 3983 3520 3984 - static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_control) 3521 + static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u32 rx_control) 3985 3522 { 3986 - u8 tx_seq = __get_reqseq(rx_control); 3523 + u16 tx_seq = __get_reqseq(chan, rx_control); 3987 3524 3988 - BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); 3525 + BT_DBG("chan %p, req_seq %d ctrl 0x%8.8x", chan, tx_seq, rx_control); 3989 3526 3990 3527 clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); 3991 3528 3992 3529 chan->expected_ack_seq = tx_seq; 3993 3530 l2cap_drop_acked_frames(chan); 3994 3531 3995 - if (rx_control & L2CAP_CTRL_FINAL) { 3532 + if (__is_ctrl_final(chan, rx_control)) { 3996 3533 if (!test_and_clear_bit(CONN_REJ_ACT, &chan->conn_state)) 3997 3534 l2cap_retransmit_frames(chan); 3998 3535 } else { ··· 4002 3539 set_bit(CONN_REJ_ACT, &chan->conn_state); 4003 3540 } 4004 3541 } 4005 - static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_control) 3542 + static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u32 rx_control) 4006 3543 { 4007 - u8 tx_seq = __get_reqseq(rx_control); 3544 + u16 tx_seq = __get_reqseq(chan, rx_control); 4008 3545 4009 - BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); 3546 + BT_DBG("chan %p, req_seq %d ctrl 0x%8.8x", chan, tx_seq, rx_control); 4010 3547 4011 3548 clear_bit(CONN_REMOTE_BUSY, &chan->conn_state); 4012 3549 4013 - if (rx_control & L2CAP_CTRL_POLL) { 3550 + if (__is_ctrl_poll(chan, rx_control)) { 4014 3551 chan->expected_ack_seq = tx_seq; 4015 3552 l2cap_drop_acked_frames(chan); 4016 3553 ··· 4023 3560 chan->srej_save_reqseq = tx_seq; 4024 3561 set_bit(CONN_SREJ_ACT, &chan->conn_state); 4025 3562 } 4026 - } else if (rx_control & L2CAP_CTRL_FINAL) { 3563 + } else if (__is_ctrl_final(chan, rx_control)) { 4027 3564 if (test_bit(CONN_SREJ_ACT, &chan->conn_state) && 4028 3565 chan->srej_save_reqseq == tx_seq) 4029 3566 clear_bit(CONN_SREJ_ACT, &chan->conn_state); ··· 4038 3575 } 4039 3576 } 4040 3577 4041 - static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_control) 3578 + static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u32 rx_control) 4042 3579 { 4043 - u8 tx_seq = __get_reqseq(rx_control); 3580 + u16 tx_seq = __get_reqseq(chan, rx_control); 4044 3581 4045 - BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control); 3582 + BT_DBG("chan %p, req_seq %d ctrl 0x%8.8x", chan, tx_seq, rx_control); 4046 3583 4047 3584 set_bit(CONN_REMOTE_BUSY, &chan->conn_state); 4048 3585 chan->expected_ack_seq = tx_seq; 4049 3586 l2cap_drop_acked_frames(chan); 4050 3587 4051 - if (rx_control & L2CAP_CTRL_POLL) 3588 + if (__is_ctrl_poll(chan, rx_control)) 4052 3589 set_bit(CONN_SEND_FBIT, &chan->conn_state); 4053 3590 4054 3591 if (!test_bit(CONN_SREJ_SENT, &chan->conn_state)) { 4055 3592 __clear_retrans_timer(chan); 4056 - if (rx_control & L2CAP_CTRL_POLL) 3593 + if (__is_ctrl_poll(chan, rx_control)) 4057 3594 l2cap_send_rr_or_rnr(chan, L2CAP_CTRL_FINAL); 4058 3595 return; 4059 3596 } 4060 3597 4061 - if (rx_control & L2CAP_CTRL_POLL) 3598 + if (__is_ctrl_poll(chan, rx_control)) { 4062 3599 l2cap_send_srejtail(chan); 4063 - else 4064 - l2cap_send_sframe(chan, L2CAP_SUPER_RCV_READY); 3600 + } else { 3601 + rx_control = __set_ctrl_super(chan, L2CAP_SUPER_RR); 3602 + l2cap_send_sframe(chan, rx_control); 3603 + } 4065 3604 } 4066 3605 4067 - static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb) 3606 + static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u32 rx_control, struct sk_buff *skb) 4068 3607 { 4069 - BT_DBG("chan %p rx_control 0x%4.4x len %d", chan, rx_control, skb->len); 3608 + BT_DBG("chan %p rx_control 0x%8.8x len %d", chan, rx_control, skb->len); 4070 3609 4071 - if (L2CAP_CTRL_FINAL & rx_control && 3610 + if (__is_ctrl_final(chan, rx_control) && 4072 3611 test_bit(CONN_WAIT_F, &chan->conn_state)) { 4073 3612 __clear_monitor_timer(chan); 4074 3613 if (chan->unacked_frames > 0) ··· 4078 3613 clear_bit(CONN_WAIT_F, &chan->conn_state); 4079 3614 } 4080 3615 4081 - switch (rx_control & L2CAP_CTRL_SUPERVISE) { 4082 - case L2CAP_SUPER_RCV_READY: 3616 + switch (__get_ctrl_super(chan, rx_control)) { 3617 + case L2CAP_SUPER_RR: 4083 3618 l2cap_data_channel_rrframe(chan, rx_control); 4084 3619 break; 4085 3620 4086 - case L2CAP_SUPER_REJECT: 3621 + case L2CAP_SUPER_REJ: 4087 3622 l2cap_data_channel_rejframe(chan, rx_control); 4088 3623 break; 4089 3624 4090 - case L2CAP_SUPER_SELECT_REJECT: 3625 + case L2CAP_SUPER_SREJ: 4091 3626 l2cap_data_channel_srejframe(chan, rx_control); 4092 3627 break; 4093 3628 4094 - case L2CAP_SUPER_RCV_NOT_READY: 3629 + case L2CAP_SUPER_RNR: 4095 3630 l2cap_data_channel_rnrframe(chan, rx_control); 4096 3631 break; 4097 3632 } ··· 4103 3638 static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb) 4104 3639 { 4105 3640 struct l2cap_chan *chan = l2cap_pi(sk)->chan; 4106 - u16 control; 4107 - u8 req_seq; 3641 + u32 control; 3642 + u16 req_seq; 4108 3643 int len, next_tx_seq_offset, req_seq_offset; 4109 3644 4110 - control = get_unaligned_le16(skb->data); 4111 - skb_pull(skb, 2); 3645 + control = __get_control(chan, skb->data); 3646 + skb_pull(skb, __ctrl_size(chan)); 4112 3647 len = skb->len; 4113 3648 4114 3649 /* ··· 4119 3654 if (l2cap_check_fcs(chan, skb)) 4120 3655 goto drop; 4121 3656 4122 - if (__is_sar_start(control) && __is_iframe(control)) 4123 - len -= 2; 3657 + if (__is_sar_start(chan, control) && !__is_sframe(chan, control)) 3658 + len -= L2CAP_SDULEN_SIZE; 4124 3659 4125 3660 if (chan->fcs == L2CAP_FCS_CRC16) 4126 - len -= 2; 3661 + len -= L2CAP_FCS_SIZE; 4127 3662 4128 3663 if (len > chan->mps) { 4129 3664 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 4130 3665 goto drop; 4131 3666 } 4132 3667 4133 - req_seq = __get_reqseq(control); 4134 - req_seq_offset = (req_seq - chan->expected_ack_seq) % 64; 4135 - if (req_seq_offset < 0) 4136 - req_seq_offset += 64; 3668 + req_seq = __get_reqseq(chan, control); 4137 3669 4138 - next_tx_seq_offset = 4139 - (chan->next_tx_seq - chan->expected_ack_seq) % 64; 4140 - if (next_tx_seq_offset < 0) 4141 - next_tx_seq_offset += 64; 3670 + req_seq_offset = __seq_offset(chan, req_seq, chan->expected_ack_seq); 3671 + 3672 + next_tx_seq_offset = __seq_offset(chan, chan->next_tx_seq, 3673 + chan->expected_ack_seq); 4142 3674 4143 3675 /* check for invalid req-seq */ 4144 3676 if (req_seq_offset > next_tx_seq_offset) { ··· 4143 3681 goto drop; 4144 3682 } 4145 3683 4146 - if (__is_iframe(control)) { 3684 + if (!__is_sframe(chan, control)) { 4147 3685 if (len < 0) { 4148 3686 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); 4149 3687 goto drop; ··· 4171 3709 { 4172 3710 struct l2cap_chan *chan; 4173 3711 struct sock *sk = NULL; 4174 - u16 control; 4175 - u8 tx_seq; 3712 + u32 control; 3713 + u16 tx_seq; 4176 3714 int len; 4177 3715 4178 3716 chan = l2cap_get_chan_by_scid(conn, cid); ··· 4213 3751 goto done; 4214 3752 4215 3753 case L2CAP_MODE_STREAMING: 4216 - control = get_unaligned_le16(skb->data); 4217 - skb_pull(skb, 2); 3754 + control = __get_control(chan, skb->data); 3755 + skb_pull(skb, __ctrl_size(chan)); 4218 3756 len = skb->len; 4219 3757 4220 3758 if (l2cap_check_fcs(chan, skb)) 4221 3759 goto drop; 4222 3760 4223 - if (__is_sar_start(control)) 4224 - len -= 2; 3761 + if (__is_sar_start(chan, control)) 3762 + len -= L2CAP_SDULEN_SIZE; 4225 3763 4226 3764 if (chan->fcs == L2CAP_FCS_CRC16) 4227 - len -= 2; 3765 + len -= L2CAP_FCS_SIZE; 4228 3766 4229 - if (len > chan->mps || len < 0 || __is_sframe(control)) 3767 + if (len > chan->mps || len < 0 || __is_sframe(chan, control)) 4230 3768 goto drop; 4231 3769 4232 - tx_seq = __get_txseq(control); 3770 + tx_seq = __get_txseq(chan, control); 4233 3771 4234 3772 if (chan->expected_tx_seq != tx_seq) { 4235 3773 /* Frame(s) missing - must discard partial SDU */ ··· 4241 3779 /* TODO: Notify userland of missing data */ 4242 3780 } 4243 3781 4244 - chan->expected_tx_seq = (tx_seq + 1) % 64; 3782 + chan->expected_tx_seq = __next_seq(chan, tx_seq); 4245 3783 4246 3784 if (l2cap_reassemble_sdu(chan, skb, control) == -EMSGSIZE) 4247 3785 l2cap_send_disconn_req(chan->conn, chan, ECONNRESET); ··· 4395 3933 4396 3934 if (!bacmp(&bt_sk(sk)->src, &hdev->bdaddr)) { 4397 3935 lm1 |= HCI_LM_ACCEPT; 4398 - if (c->role_switch) 3936 + if (test_bit(FLAG_ROLE_SWITCH, &c->flags)) 4399 3937 lm1 |= HCI_LM_MASTER; 4400 3938 exact++; 4401 3939 } else if (!bacmp(&bt_sk(sk)->src, BDADDR_ANY)) { 4402 3940 lm2 |= HCI_LM_ACCEPT; 4403 - if (c->role_switch) 3941 + if (test_bit(FLAG_ROLE_SWITCH, &c->flags)) 4404 3942 lm2 |= HCI_LM_MASTER; 4405 3943 } 4406 3944 } ··· 4435 3973 BT_DBG("hcon %p", hcon); 4436 3974 4437 3975 if ((hcon->type != ACL_LINK && hcon->type != LE_LINK) || !conn) 4438 - return 0x13; 3976 + return HCI_ERROR_REMOTE_USER_TERM; 4439 3977 4440 3978 return conn->disc_reason; 4441 3979 } ··· 4460 3998 if (encrypt == 0x00) { 4461 3999 if (chan->sec_level == BT_SECURITY_MEDIUM) { 4462 4000 __clear_chan_timer(chan); 4463 - __set_chan_timer(chan, HZ * 5); 4001 + __set_chan_timer(chan, L2CAP_ENC_TIMEOUT); 4464 4002 } else if (chan->sec_level == BT_SECURITY_HIGH) 4465 4003 l2cap_chan_close(chan, ECONNREFUSED); 4466 4004 } else { ··· 4528 4066 L2CAP_CONN_REQ, sizeof(req), &req); 4529 4067 } else { 4530 4068 __clear_chan_timer(chan); 4531 - __set_chan_timer(chan, HZ / 10); 4069 + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); 4532 4070 } 4533 4071 } else if (chan->state == BT_CONNECT2) { 4534 4072 struct l2cap_conn_rsp rsp; ··· 4548 4086 } 4549 4087 } else { 4550 4088 l2cap_state_change(chan, BT_DISCONN); 4551 - __set_chan_timer(chan, HZ / 10); 4089 + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); 4552 4090 res = L2CAP_CR_SEC_BLOCK; 4553 4091 stat = L2CAP_CS_NO_INFO; 4554 4092 } ··· 4768 4306 4769 4307 module_param(disable_ertm, bool, 0644); 4770 4308 MODULE_PARM_DESC(disable_ertm, "Disable enhanced retransmission mode"); 4309 + 4310 + module_param(enable_hs, bool, 0644); 4311 + MODULE_PARM_DESC(enable_hs, "Enable High Speed");
+68 -22
net/bluetooth/l2cap_sock.c
··· 334 334 opts.mode = chan->mode; 335 335 opts.fcs = chan->fcs; 336 336 opts.max_tx = chan->max_tx; 337 - opts.txwin_size = (__u16)chan->tx_win; 337 + opts.txwin_size = chan->tx_win; 338 338 339 339 len = min_t(unsigned int, len, sizeof(opts)); 340 340 if (copy_to_user(optval, (char *) &opts, len)) ··· 359 359 break; 360 360 } 361 361 362 - if (chan->role_switch) 362 + if (test_bit(FLAG_ROLE_SWITCH, &chan->flags)) 363 363 opt |= L2CAP_LM_MASTER; 364 364 365 - if (chan->force_reliable) 365 + if (test_bit(FLAG_FORCE_RELIABLE, &chan->flags)) 366 366 opt |= L2CAP_LM_RELIABLE; 367 367 368 368 if (put_user(opt, (u32 __user *) optval)) ··· 449 449 break; 450 450 451 451 case BT_FLUSHABLE: 452 - if (put_user(chan->flushable, (u32 __user *) optval)) 452 + if (put_user(test_bit(FLAG_FLUSHABLE, &chan->flags), 453 + (u32 __user *) optval)) 453 454 err = -EFAULT; 454 455 455 456 break; ··· 462 461 break; 463 462 } 464 463 465 - pwr.force_active = chan->force_active; 464 + pwr.force_active = test_bit(FLAG_FORCE_ACTIVE, &chan->flags); 466 465 467 466 len = min_t(unsigned int, len, sizeof(pwr)); 468 467 if (copy_to_user(optval, (char *) &pwr, len)) 469 468 err = -EFAULT; 470 469 470 + break; 471 + 472 + case BT_CHANNEL_POLICY: 473 + if (!enable_hs) { 474 + err = -ENOPROTOOPT; 475 + break; 476 + } 477 + 478 + if (put_user(chan->chan_policy, (u32 __user *) optval)) 479 + err = -EFAULT; 471 480 break; 472 481 473 482 default: ··· 514 503 opts.mode = chan->mode; 515 504 opts.fcs = chan->fcs; 516 505 opts.max_tx = chan->max_tx; 517 - opts.txwin_size = (__u16)chan->tx_win; 506 + opts.txwin_size = chan->tx_win; 518 507 519 508 len = min_t(unsigned int, sizeof(opts), optlen); 520 509 if (copy_from_user((char *) &opts, optval, len)) { ··· 522 511 break; 523 512 } 524 513 525 - if (opts.txwin_size > L2CAP_DEFAULT_TX_WINDOW) { 514 + if (opts.txwin_size > L2CAP_DEFAULT_EXT_WINDOW) { 526 515 err = -EINVAL; 527 516 break; 528 517 } ··· 546 535 chan->omtu = opts.omtu; 547 536 chan->fcs = opts.fcs; 548 537 chan->max_tx = opts.max_tx; 549 - chan->tx_win = (__u8)opts.txwin_size; 538 + chan->tx_win = opts.txwin_size; 550 539 break; 551 540 552 541 case L2CAP_LM: ··· 562 551 if (opt & L2CAP_LM_SECURE) 563 552 chan->sec_level = BT_SECURITY_HIGH; 564 553 565 - chan->role_switch = (opt & L2CAP_LM_MASTER); 566 - chan->force_reliable = (opt & L2CAP_LM_RELIABLE); 554 + if (opt & L2CAP_LM_MASTER) 555 + set_bit(FLAG_ROLE_SWITCH, &chan->flags); 556 + else 557 + clear_bit(FLAG_ROLE_SWITCH, &chan->flags); 558 + 559 + if (opt & L2CAP_LM_RELIABLE) 560 + set_bit(FLAG_FORCE_RELIABLE, &chan->flags); 561 + else 562 + clear_bit(FLAG_FORCE_RELIABLE, &chan->flags); 567 563 break; 568 564 569 565 default: ··· 676 658 } 677 659 } 678 660 679 - chan->flushable = opt; 661 + if (opt) 662 + set_bit(FLAG_FLUSHABLE, &chan->flags); 663 + else 664 + clear_bit(FLAG_FLUSHABLE, &chan->flags); 680 665 break; 681 666 682 667 case BT_POWER: ··· 696 675 err = -EFAULT; 697 676 break; 698 677 } 699 - chan->force_active = pwr.force_active; 678 + 679 + if (pwr.force_active) 680 + set_bit(FLAG_FORCE_ACTIVE, &chan->flags); 681 + else 682 + clear_bit(FLAG_FORCE_ACTIVE, &chan->flags); 683 + break; 684 + 685 + case BT_CHANNEL_POLICY: 686 + if (!enable_hs) { 687 + err = -ENOPROTOOPT; 688 + break; 689 + } 690 + 691 + if (get_user(opt, (u32 __user *) optval)) { 692 + err = -EFAULT; 693 + break; 694 + } 695 + 696 + if (opt > BT_CHANNEL_POLICY_AMP_PREFERRED) { 697 + err = -EINVAL; 698 + break; 699 + } 700 + 701 + if (chan->mode != L2CAP_MODE_ERTM && 702 + chan->mode != L2CAP_MODE_STREAMING) { 703 + err = -EOPNOTSUPP; 704 + break; 705 + } 706 + 707 + chan->chan_policy = (u8) opt; 700 708 break; 701 709 702 710 default: ··· 759 709 return -ENOTCONN; 760 710 } 761 711 762 - err = l2cap_chan_send(chan, msg, len); 712 + err = l2cap_chan_send(chan, msg, len, sk->sk_priority); 763 713 764 714 release_sock(sk); 765 715 return err; ··· 981 931 chan->fcs = pchan->fcs; 982 932 chan->max_tx = pchan->max_tx; 983 933 chan->tx_win = pchan->tx_win; 934 + chan->tx_win_max = pchan->tx_win_max; 984 935 chan->sec_level = pchan->sec_level; 985 - chan->role_switch = pchan->role_switch; 986 - chan->force_reliable = pchan->force_reliable; 987 - chan->flushable = pchan->flushable; 988 - chan->force_active = pchan->force_active; 936 + chan->flags = pchan->flags; 989 937 990 938 security_sk_clone(parent, sk); 991 939 } else { ··· 1012 964 chan->max_tx = L2CAP_DEFAULT_MAX_TX; 1013 965 chan->fcs = L2CAP_FCS_CRC16; 1014 966 chan->tx_win = L2CAP_DEFAULT_TX_WINDOW; 967 + chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW; 1015 968 chan->sec_level = BT_SECURITY_LOW; 1016 - chan->role_switch = 0; 1017 - chan->force_reliable = 0; 1018 - chan->flushable = BT_FLUSHABLE_OFF; 1019 - chan->force_active = BT_POWER_FORCE_ACTIVE_ON; 1020 - 969 + chan->flags = 0; 970 + set_bit(FLAG_FORCE_ACTIVE, &chan->flags); 1021 971 } 1022 972 1023 973 /* Default config options */
+280 -224
net/bluetooth/mgmt.c
··· 33 33 #define MGMT_VERSION 0 34 34 #define MGMT_REVISION 1 35 35 36 + #define INQUIRY_LEN_BREDR 0x08 /* TGAP(100) */ 37 + 36 38 struct pending_cmd { 37 39 struct list_head list; 38 - __u16 opcode; 40 + u16 opcode; 39 41 int index; 40 42 void *param; 41 43 struct sock *sk; 42 44 void *user_data; 43 45 }; 44 46 45 - static LIST_HEAD(cmd_list); 46 - 47 47 static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) 48 48 { 49 49 struct sk_buff *skb; 50 50 struct mgmt_hdr *hdr; 51 51 struct mgmt_ev_cmd_status *ev; 52 + int err; 52 53 53 54 BT_DBG("sock %p, index %u, cmd %u, status %u", sk, index, cmd, status); 54 55 ··· 67 66 ev->status = status; 68 67 put_unaligned_le16(cmd, &ev->opcode); 69 68 70 - if (sock_queue_rcv_skb(sk, skb) < 0) 69 + err = sock_queue_rcv_skb(sk, skb); 70 + if (err < 0) 71 71 kfree_skb(skb); 72 72 73 - return 0; 73 + return err; 74 74 } 75 75 76 76 static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp, ··· 80 78 struct sk_buff *skb; 81 79 struct mgmt_hdr *hdr; 82 80 struct mgmt_ev_cmd_complete *ev; 81 + int err; 83 82 84 83 BT_DBG("sock %p", sk); 85 84 ··· 100 97 if (rp) 101 98 memcpy(ev->data, rp, rp_len); 102 99 103 - if (sock_queue_rcv_skb(sk, skb) < 0) 100 + err = sock_queue_rcv_skb(sk, skb); 101 + if (err < 0) 104 102 kfree_skb(skb); 105 103 106 - return 0; 104 + return err;; 107 105 } 108 106 109 107 static int read_version(struct sock *sk) ··· 124 120 { 125 121 struct mgmt_rp_read_index_list *rp; 126 122 struct list_head *p; 123 + struct hci_dev *d; 127 124 size_t rp_len; 128 125 u16 count; 129 126 int i, err; ··· 148 143 put_unaligned_le16(count, &rp->num_controllers); 149 144 150 145 i = 0; 151 - list_for_each(p, &hci_dev_list) { 152 - struct hci_dev *d = list_entry(p, struct hci_dev, list); 153 - 154 - hci_del_off_timer(d); 146 + list_for_each_entry(d, &hci_dev_list, list) { 147 + if (test_and_clear_bit(HCI_AUTO_OFF, &d->flags)) 148 + cancel_delayed_work(&d->power_off); 155 149 156 150 if (test_bit(HCI_SETUP, &d->flags)) 157 151 continue; ··· 180 176 if (!hdev) 181 177 return cmd_status(sk, index, MGMT_OP_READ_INFO, ENODEV); 182 178 183 - hci_del_off_timer(hdev); 179 + if (test_and_clear_bit(HCI_AUTO_OFF, &hdev->flags)) 180 + cancel_delayed_work_sync(&hdev->power_off); 184 181 185 182 hci_dev_lock_bh(hdev); 186 183 ··· 226 221 } 227 222 228 223 static struct pending_cmd *mgmt_pending_add(struct sock *sk, u16 opcode, 229 - u16 index, void *data, u16 len) 224 + struct hci_dev *hdev, 225 + void *data, u16 len) 230 226 { 231 227 struct pending_cmd *cmd; 232 228 ··· 236 230 return NULL; 237 231 238 232 cmd->opcode = opcode; 239 - cmd->index = index; 233 + cmd->index = hdev->id; 240 234 241 235 cmd->param = kmalloc(len, GFP_ATOMIC); 242 236 if (!cmd->param) { ··· 250 244 cmd->sk = sk; 251 245 sock_hold(sk); 252 246 253 - list_add(&cmd->list, &cmd_list); 247 + list_add(&cmd->list, &hdev->mgmt_pending); 254 248 255 249 return cmd; 256 250 } 257 251 258 - static void mgmt_pending_foreach(u16 opcode, int index, 252 + static void mgmt_pending_foreach(u16 opcode, struct hci_dev *hdev, 259 253 void (*cb)(struct pending_cmd *cmd, void *data), 260 254 void *data) 261 255 { 262 256 struct list_head *p, *n; 263 257 264 - list_for_each_safe(p, n, &cmd_list) { 258 + list_for_each_safe(p, n, &hdev->mgmt_pending) { 265 259 struct pending_cmd *cmd; 266 260 267 261 cmd = list_entry(p, struct pending_cmd, list); 268 262 269 - if (cmd->opcode != opcode) 270 - continue; 271 - 272 - if (index >= 0 && cmd->index != index) 263 + if (opcode > 0 && cmd->opcode != opcode) 273 264 continue; 274 265 275 266 cb(cmd, data); 276 267 } 277 268 } 278 269 279 - static struct pending_cmd *mgmt_pending_find(u16 opcode, int index) 270 + static struct pending_cmd *mgmt_pending_find(u16 opcode, struct hci_dev *hdev) 280 271 { 281 - struct list_head *p; 272 + struct pending_cmd *cmd; 282 273 283 - list_for_each(p, &cmd_list) { 284 - struct pending_cmd *cmd; 285 - 286 - cmd = list_entry(p, struct pending_cmd, list); 287 - 288 - if (cmd->opcode != opcode) 289 - continue; 290 - 291 - if (index >= 0 && cmd->index != index) 292 - continue; 293 - 294 - return cmd; 274 + list_for_each_entry(cmd, &hdev->mgmt_pending, list) { 275 + if (cmd->opcode == opcode) 276 + return cmd; 295 277 } 296 278 297 279 return NULL; ··· 317 323 goto failed; 318 324 } 319 325 320 - if (mgmt_pending_find(MGMT_OP_SET_POWERED, index)) { 326 + if (mgmt_pending_find(MGMT_OP_SET_POWERED, hdev)) { 321 327 err = cmd_status(sk, index, MGMT_OP_SET_POWERED, EBUSY); 322 328 goto failed; 323 329 } 324 330 325 - cmd = mgmt_pending_add(sk, MGMT_OP_SET_POWERED, index, data, len); 331 + cmd = mgmt_pending_add(sk, MGMT_OP_SET_POWERED, hdev, data, len); 326 332 if (!cmd) { 327 333 err = -ENOMEM; 328 334 goto failed; ··· 331 337 if (cp->val) 332 338 queue_work(hdev->workqueue, &hdev->power_on); 333 339 else 334 - queue_work(hdev->workqueue, &hdev->power_off); 340 + queue_work(hdev->workqueue, &hdev->power_off.work); 335 341 336 342 err = 0; 337 343 ··· 344 350 static int set_discoverable(struct sock *sk, u16 index, unsigned char *data, 345 351 u16 len) 346 352 { 347 - struct mgmt_mode *cp; 353 + struct mgmt_cp_set_discoverable *cp; 348 354 struct hci_dev *hdev; 349 355 struct pending_cmd *cmd; 350 356 u8 scan; ··· 368 374 goto failed; 369 375 } 370 376 371 - if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, index) || 372 - mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, index)) { 377 + if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) || 378 + mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) { 373 379 err = cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, EBUSY); 374 380 goto failed; 375 381 } ··· 380 386 goto failed; 381 387 } 382 388 383 - cmd = mgmt_pending_add(sk, MGMT_OP_SET_DISCOVERABLE, index, data, len); 389 + cmd = mgmt_pending_add(sk, MGMT_OP_SET_DISCOVERABLE, hdev, data, len); 384 390 if (!cmd) { 385 391 err = -ENOMEM; 386 392 goto failed; ··· 390 396 391 397 if (cp->val) 392 398 scan |= SCAN_INQUIRY; 399 + else 400 + cancel_delayed_work(&hdev->discov_off); 393 401 394 402 err = hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan); 395 403 if (err < 0) 396 404 mgmt_pending_remove(cmd); 405 + 406 + if (cp->val) 407 + hdev->discov_timeout = get_unaligned_le16(&cp->timeout); 397 408 398 409 failed: 399 410 hci_dev_unlock_bh(hdev); ··· 434 435 goto failed; 435 436 } 436 437 437 - if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, index) || 438 - mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, index)) { 438 + if (mgmt_pending_find(MGMT_OP_SET_DISCOVERABLE, hdev) || 439 + mgmt_pending_find(MGMT_OP_SET_CONNECTABLE, hdev)) { 439 440 err = cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, EBUSY); 440 441 goto failed; 441 442 } ··· 445 446 goto failed; 446 447 } 447 448 448 - cmd = mgmt_pending_add(sk, MGMT_OP_SET_CONNECTABLE, index, data, len); 449 + cmd = mgmt_pending_add(sk, MGMT_OP_SET_CONNECTABLE, hdev, data, len); 449 450 if (!cmd) { 450 451 err = -ENOMEM; 451 452 goto failed; ··· 467 468 return err; 468 469 } 469 470 470 - static int mgmt_event(u16 event, u16 index, void *data, u16 data_len, 471 - struct sock *skip_sk) 471 + static int mgmt_event(u16 event, struct hci_dev *hdev, void *data, 472 + u16 data_len, struct sock *skip_sk) 472 473 { 473 474 struct sk_buff *skb; 474 475 struct mgmt_hdr *hdr; ··· 481 482 482 483 hdr = (void *) skb_put(skb, sizeof(*hdr)); 483 484 hdr->opcode = cpu_to_le16(event); 484 - hdr->index = cpu_to_le16(index); 485 + if (hdev) 486 + hdr->index = cpu_to_le16(hdev->id); 487 + else 488 + hdr->index = cpu_to_le16(MGMT_INDEX_NONE); 485 489 hdr->len = cpu_to_le16(data_len); 486 490 487 491 if (data) ··· 536 534 537 535 ev.val = cp->val; 538 536 539 - err = mgmt_event(MGMT_EV_PAIRABLE, index, &ev, sizeof(ev), sk); 537 + err = mgmt_event(MGMT_EV_PAIRABLE, hdev, &ev, sizeof(ev), sk); 540 538 541 539 failed: 542 540 hci_dev_unlock_bh(hdev); ··· 589 587 u16 eir_len = 0; 590 588 u16 uuid16_list[HCI_MAX_EIR_LENGTH / sizeof(u16)]; 591 589 int i, truncated = 0; 592 - struct list_head *p; 590 + struct bt_uuid *uuid; 593 591 size_t name_len; 594 592 595 593 name_len = strlen(hdev->dev_name); ··· 614 612 memset(uuid16_list, 0, sizeof(uuid16_list)); 615 613 616 614 /* Group all UUID16 types */ 617 - list_for_each(p, &hdev->uuids) { 618 - struct bt_uuid *uuid = list_entry(p, struct bt_uuid, list); 615 + list_for_each_entry(uuid, &hdev->uuids, list) { 619 616 u16 uuid16; 620 617 621 618 uuid16 = get_uuid16(uuid->uuid); ··· 690 689 691 690 static u8 get_service_classes(struct hci_dev *hdev) 692 691 { 693 - struct list_head *p; 692 + struct bt_uuid *uuid; 694 693 u8 val = 0; 695 694 696 - list_for_each(p, &hdev->uuids) { 697 - struct bt_uuid *uuid = list_entry(p, struct bt_uuid, list); 698 - 695 + list_for_each_entry(uuid, &hdev->uuids, list) 699 696 val |= uuid->svc_hint; 700 - } 701 697 702 698 return val; 703 699 } ··· 893 895 if (err == 0) 894 896 err = cmd_complete(sk, index, MGMT_OP_SET_SERVICE_CACHE, NULL, 895 897 0); 898 + else 899 + cmd_status(sk, index, MGMT_OP_SET_SERVICE_CACHE, -err); 900 + 896 901 897 902 hci_dev_unlock_bh(hdev); 898 903 hci_dev_put(hdev); ··· 903 902 return err; 904 903 } 905 904 906 - static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len) 905 + static int load_link_keys(struct sock *sk, u16 index, unsigned char *data, 906 + u16 len) 907 907 { 908 908 struct hci_dev *hdev; 909 - struct mgmt_cp_load_keys *cp; 909 + struct mgmt_cp_load_link_keys *cp; 910 910 u16 key_count, expected_len; 911 911 int i; 912 912 913 913 cp = (void *) data; 914 914 915 915 if (len < sizeof(*cp)) 916 - return -EINVAL; 916 + return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS, EINVAL); 917 917 918 918 key_count = get_unaligned_le16(&cp->key_count); 919 919 920 - expected_len = sizeof(*cp) + key_count * sizeof(struct mgmt_key_info); 920 + expected_len = sizeof(*cp) + key_count * 921 + sizeof(struct mgmt_link_key_info); 921 922 if (expected_len != len) { 922 - BT_ERR("load_keys: expected %u bytes, got %u bytes", 923 + BT_ERR("load_link_keys: expected %u bytes, got %u bytes", 923 924 len, expected_len); 924 - return -EINVAL; 925 + return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS, EINVAL); 925 926 } 926 927 927 928 hdev = hci_dev_get(index); 928 929 if (!hdev) 929 - return cmd_status(sk, index, MGMT_OP_LOAD_KEYS, ENODEV); 930 + return cmd_status(sk, index, MGMT_OP_LOAD_LINK_KEYS, ENODEV); 930 931 931 932 BT_DBG("hci%u debug_keys %u key_count %u", index, cp->debug_keys, 932 933 key_count); ··· 945 942 clear_bit(HCI_DEBUG_KEYS, &hdev->flags); 946 943 947 944 for (i = 0; i < key_count; i++) { 948 - struct mgmt_key_info *key = &cp->keys[i]; 945 + struct mgmt_link_key_info *key = &cp->keys[i]; 949 946 950 947 hci_add_link_key(hdev, NULL, 0, &key->bdaddr, key->val, key->type, 951 948 key->pin_len); ··· 957 954 return 0; 958 955 } 959 956 960 - static int remove_key(struct sock *sk, u16 index, unsigned char *data, u16 len) 957 + static int remove_keys(struct sock *sk, u16 index, unsigned char *data, 958 + u16 len) 961 959 { 962 960 struct hci_dev *hdev; 963 - struct mgmt_cp_remove_key *cp; 961 + struct mgmt_cp_remove_keys *cp; 964 962 struct hci_conn *conn; 965 963 int err; 966 964 967 965 cp = (void *) data; 968 966 969 967 if (len != sizeof(*cp)) 970 - return cmd_status(sk, index, MGMT_OP_REMOVE_KEY, EINVAL); 968 + return cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, EINVAL); 971 969 972 970 hdev = hci_dev_get(index); 973 971 if (!hdev) 974 - return cmd_status(sk, index, MGMT_OP_REMOVE_KEY, ENODEV); 972 + return cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, ENODEV); 975 973 976 974 hci_dev_lock_bh(hdev); 977 975 978 976 err = hci_remove_link_key(hdev, &cp->bdaddr); 979 977 if (err < 0) { 980 - err = cmd_status(sk, index, MGMT_OP_REMOVE_KEY, -err); 978 + err = cmd_status(sk, index, MGMT_OP_REMOVE_KEYS, -err); 981 979 goto unlock; 982 980 } 983 981 ··· 1030 1026 goto failed; 1031 1027 } 1032 1028 1033 - if (mgmt_pending_find(MGMT_OP_DISCONNECT, index)) { 1029 + if (mgmt_pending_find(MGMT_OP_DISCONNECT, hdev)) { 1034 1030 err = cmd_status(sk, index, MGMT_OP_DISCONNECT, EBUSY); 1035 1031 goto failed; 1036 1032 } ··· 1044 1040 goto failed; 1045 1041 } 1046 1042 1047 - cmd = mgmt_pending_add(sk, MGMT_OP_DISCONNECT, index, data, len); 1043 + cmd = mgmt_pending_add(sk, MGMT_OP_DISCONNECT, hdev, data, len); 1048 1044 if (!cmd) { 1049 1045 err = -ENOMEM; 1050 1046 goto failed; ··· 1064 1060 return err; 1065 1061 } 1066 1062 1063 + static u8 link_to_mgmt(u8 link_type) 1064 + { 1065 + switch (link_type) { 1066 + case LE_LINK: 1067 + return MGMT_ADDR_LE; 1068 + case ACL_LINK: 1069 + return MGMT_ADDR_BREDR; 1070 + default: 1071 + return MGMT_ADDR_INVALID; 1072 + } 1073 + } 1074 + 1067 1075 static int get_connections(struct sock *sk, u16 index) 1068 1076 { 1069 1077 struct mgmt_rp_get_connections *rp; 1070 1078 struct hci_dev *hdev; 1079 + struct hci_conn *c; 1071 1080 struct list_head *p; 1072 1081 size_t rp_len; 1073 1082 u16 count; ··· 1099 1082 count++; 1100 1083 } 1101 1084 1102 - rp_len = sizeof(*rp) + (count * sizeof(bdaddr_t)); 1085 + rp_len = sizeof(*rp) + (count * sizeof(struct mgmt_addr_info)); 1103 1086 rp = kmalloc(rp_len, GFP_ATOMIC); 1104 1087 if (!rp) { 1105 1088 err = -ENOMEM; ··· 1109 1092 put_unaligned_le16(count, &rp->conn_count); 1110 1093 1111 1094 i = 0; 1112 - list_for_each(p, &hdev->conn_hash.list) { 1113 - struct hci_conn *c = list_entry(p, struct hci_conn, list); 1114 - 1115 - bacpy(&rp->conn[i++], &c->dst); 1095 + list_for_each_entry(c, &hdev->conn_hash.list, list) { 1096 + bacpy(&rp->addr[i].bdaddr, &c->dst); 1097 + rp->addr[i].type = link_to_mgmt(c->type); 1098 + if (rp->addr[i].type == MGMT_ADDR_INVALID) 1099 + continue; 1100 + i++; 1116 1101 } 1102 + 1103 + /* Recalculate length in case of filtered SCO connections, etc */ 1104 + rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info)); 1117 1105 1118 1106 err = cmd_complete(sk, index, MGMT_OP_GET_CONNECTIONS, rp, rp_len); 1119 1107 ··· 1135 1113 struct pending_cmd *cmd; 1136 1114 int err; 1137 1115 1138 - cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_NEG_REPLY, index, cp, 1116 + cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_NEG_REPLY, hdev, cp, 1139 1117 sizeof(*cp)); 1140 1118 if (!cmd) 1141 1119 return -ENOMEM; ··· 1196 1174 goto failed; 1197 1175 } 1198 1176 1199 - cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, index, data, len); 1177 + cmd = mgmt_pending_add(sk, MGMT_OP_PIN_CODE_REPLY, hdev, data, len); 1200 1178 if (!cmd) { 1201 1179 err = -ENOMEM; 1202 1180 goto failed; ··· 1287 1265 static inline struct pending_cmd *find_pairing(struct hci_conn *conn) 1288 1266 { 1289 1267 struct hci_dev *hdev = conn->hdev; 1290 - struct list_head *p; 1268 + struct pending_cmd *cmd; 1291 1269 1292 - list_for_each(p, &cmd_list) { 1293 - struct pending_cmd *cmd; 1294 - 1295 - cmd = list_entry(p, struct pending_cmd, list); 1296 - 1270 + list_for_each_entry(cmd, &hdev->mgmt_pending, list) { 1297 1271 if (cmd->opcode != MGMT_OP_PAIR_DEVICE) 1298 - continue; 1299 - 1300 - if (cmd->index != hdev->id) 1301 1272 continue; 1302 1273 1303 1274 if (cmd->user_data != conn) ··· 1325 1310 static void pairing_complete_cb(struct hci_conn *conn, u8 status) 1326 1311 { 1327 1312 struct pending_cmd *cmd; 1313 + struct hci_dev *hdev = conn->hdev; 1328 1314 1329 1315 BT_DBG("status %u", status); 1330 1316 1331 - cmd = find_pairing(conn); 1332 - if (!cmd) { 1333 - BT_DBG("Unable to find a pending command"); 1334 - return; 1335 - } 1317 + hci_dev_lock_bh(hdev); 1336 1318 1337 - pairing_complete(cmd, status); 1319 + cmd = find_pairing(conn); 1320 + if (!cmd) 1321 + BT_DBG("Unable to find a pending command"); 1322 + else 1323 + pairing_complete(cmd, status); 1324 + 1325 + hci_dev_unlock_bh(hdev); 1338 1326 } 1339 1327 1340 1328 static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len) ··· 1388 1370 goto unlock; 1389 1371 } 1390 1372 1391 - cmd = mgmt_pending_add(sk, MGMT_OP_PAIR_DEVICE, index, data, len); 1373 + cmd = mgmt_pending_add(sk, MGMT_OP_PAIR_DEVICE, hdev, data, len); 1392 1374 if (!cmd) { 1393 1375 err = -ENOMEM; 1394 1376 hci_conn_put(conn); ··· 1450 1432 goto failed; 1451 1433 } 1452 1434 1453 - cmd = mgmt_pending_add(sk, mgmt_op, index, data, len); 1435 + cmd = mgmt_pending_add(sk, mgmt_op, hdev, data, len); 1454 1436 if (!cmd) { 1455 1437 err = -ENOMEM; 1456 1438 goto failed; ··· 1487 1469 1488 1470 hci_dev_lock_bh(hdev); 1489 1471 1490 - cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, index, data, len); 1472 + cmd = mgmt_pending_add(sk, MGMT_OP_SET_LOCAL_NAME, hdev, data, len); 1491 1473 if (!cmd) { 1492 1474 err = -ENOMEM; 1493 1475 goto failed; ··· 1533 1515 goto unlock; 1534 1516 } 1535 1517 1536 - if (mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, index)) { 1518 + if (mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, hdev)) { 1537 1519 err = cmd_status(sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, EBUSY); 1538 1520 goto unlock; 1539 1521 } 1540 1522 1541 - cmd = mgmt_pending_add(sk, MGMT_OP_READ_LOCAL_OOB_DATA, index, NULL, 0); 1523 + cmd = mgmt_pending_add(sk, MGMT_OP_READ_LOCAL_OOB_DATA, hdev, NULL, 0); 1542 1524 if (!cmd) { 1543 1525 err = -ENOMEM; 1544 1526 goto unlock; ··· 1625 1607 1626 1608 static int start_discovery(struct sock *sk, u16 index) 1627 1609 { 1628 - u8 lap[3] = { 0x33, 0x8b, 0x9e }; 1629 - struct hci_cp_inquiry cp; 1630 1610 struct pending_cmd *cmd; 1631 1611 struct hci_dev *hdev; 1632 1612 int err; ··· 1637 1621 1638 1622 hci_dev_lock_bh(hdev); 1639 1623 1640 - cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, index, NULL, 0); 1624 + if (!test_bit(HCI_UP, &hdev->flags)) { 1625 + err = cmd_status(sk, index, MGMT_OP_START_DISCOVERY, ENETDOWN); 1626 + goto failed; 1627 + } 1628 + 1629 + cmd = mgmt_pending_add(sk, MGMT_OP_START_DISCOVERY, hdev, NULL, 0); 1641 1630 if (!cmd) { 1642 1631 err = -ENOMEM; 1643 1632 goto failed; 1644 1633 } 1645 1634 1646 - memset(&cp, 0, sizeof(cp)); 1647 - memcpy(&cp.lap, lap, 3); 1648 - cp.length = 0x08; 1649 - cp.num_rsp = 0x00; 1650 - 1651 - err = hci_send_cmd(hdev, HCI_OP_INQUIRY, sizeof(cp), &cp); 1635 + err = hci_do_inquiry(hdev, INQUIRY_LEN_BREDR); 1652 1636 if (err < 0) 1653 1637 mgmt_pending_remove(cmd); 1654 1638 ··· 1673 1657 1674 1658 hci_dev_lock_bh(hdev); 1675 1659 1676 - cmd = mgmt_pending_add(sk, MGMT_OP_STOP_DISCOVERY, index, NULL, 0); 1660 + cmd = mgmt_pending_add(sk, MGMT_OP_STOP_DISCOVERY, hdev, NULL, 0); 1677 1661 if (!cmd) { 1678 1662 err = -ENOMEM; 1679 1663 goto failed; 1680 1664 } 1681 1665 1682 - err = hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL); 1666 + err = hci_cancel_inquiry(hdev); 1683 1667 if (err < 0) 1684 1668 mgmt_pending_remove(cmd); 1685 1669 ··· 1694 1678 u16 len) 1695 1679 { 1696 1680 struct hci_dev *hdev; 1697 - struct pending_cmd *cmd; 1698 1681 struct mgmt_cp_block_device *cp = (void *) data; 1699 1682 int err; 1700 1683 ··· 1710 1695 1711 1696 hci_dev_lock_bh(hdev); 1712 1697 1713 - cmd = mgmt_pending_add(sk, MGMT_OP_BLOCK_DEVICE, index, NULL, 0); 1714 - if (!cmd) { 1715 - err = -ENOMEM; 1716 - goto failed; 1717 - } 1718 - 1719 1698 err = hci_blacklist_add(hdev, &cp->bdaddr); 1720 - 1721 1699 if (err < 0) 1722 1700 err = cmd_status(sk, index, MGMT_OP_BLOCK_DEVICE, -err); 1723 1701 else 1724 1702 err = cmd_complete(sk, index, MGMT_OP_BLOCK_DEVICE, 1725 1703 NULL, 0); 1726 1704 1727 - mgmt_pending_remove(cmd); 1728 - 1729 - failed: 1730 1705 hci_dev_unlock_bh(hdev); 1731 1706 hci_dev_put(hdev); 1732 1707 ··· 1727 1722 u16 len) 1728 1723 { 1729 1724 struct hci_dev *hdev; 1730 - struct pending_cmd *cmd; 1731 1725 struct mgmt_cp_unblock_device *cp = (void *) data; 1732 1726 int err; 1733 1727 ··· 1743 1739 1744 1740 hci_dev_lock_bh(hdev); 1745 1741 1746 - cmd = mgmt_pending_add(sk, MGMT_OP_UNBLOCK_DEVICE, index, NULL, 0); 1747 - if (!cmd) { 1748 - err = -ENOMEM; 1749 - goto failed; 1750 - } 1751 - 1752 1742 err = hci_blacklist_del(hdev, &cp->bdaddr); 1753 1743 1754 1744 if (err < 0) ··· 1751 1753 err = cmd_complete(sk, index, MGMT_OP_UNBLOCK_DEVICE, 1752 1754 NULL, 0); 1753 1755 1754 - mgmt_pending_remove(cmd); 1755 - 1756 - failed: 1757 1756 hci_dev_unlock_bh(hdev); 1758 1757 hci_dev_put(hdev); 1759 1758 ··· 1878 1883 case MGMT_OP_SET_SERVICE_CACHE: 1879 1884 err = set_service_cache(sk, index, buf + sizeof(*hdr), len); 1880 1885 break; 1881 - case MGMT_OP_LOAD_KEYS: 1882 - err = load_keys(sk, index, buf + sizeof(*hdr), len); 1886 + case MGMT_OP_LOAD_LINK_KEYS: 1887 + err = load_link_keys(sk, index, buf + sizeof(*hdr), len); 1883 1888 break; 1884 - case MGMT_OP_REMOVE_KEY: 1885 - err = remove_key(sk, index, buf + sizeof(*hdr), len); 1889 + case MGMT_OP_REMOVE_KEYS: 1890 + err = remove_keys(sk, index, buf + sizeof(*hdr), len); 1886 1891 break; 1887 1892 case MGMT_OP_DISCONNECT: 1888 1893 err = disconnect(sk, index, buf + sizeof(*hdr), len); ··· 1953 1958 return err; 1954 1959 } 1955 1960 1956 - int mgmt_index_added(u16 index) 1961 + static void cmd_status_rsp(struct pending_cmd *cmd, void *data) 1957 1962 { 1958 - return mgmt_event(MGMT_EV_INDEX_ADDED, index, NULL, 0, NULL); 1963 + u8 *status = data; 1964 + 1965 + cmd_status(cmd->sk, cmd->index, cmd->opcode, *status); 1966 + mgmt_pending_remove(cmd); 1959 1967 } 1960 1968 1961 - int mgmt_index_removed(u16 index) 1969 + int mgmt_index_added(struct hci_dev *hdev) 1962 1970 { 1963 - return mgmt_event(MGMT_EV_INDEX_REMOVED, index, NULL, 0, NULL); 1971 + return mgmt_event(MGMT_EV_INDEX_ADDED, hdev, NULL, 0, NULL); 1972 + } 1973 + 1974 + int mgmt_index_removed(struct hci_dev *hdev) 1975 + { 1976 + u8 status = ENODEV; 1977 + 1978 + mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); 1979 + 1980 + return mgmt_event(MGMT_EV_INDEX_REMOVED, hdev, NULL, 0, NULL); 1964 1981 } 1965 1982 1966 1983 struct cmd_lookup { ··· 2000 1993 mgmt_pending_free(cmd); 2001 1994 } 2002 1995 2003 - int mgmt_powered(u16 index, u8 powered) 1996 + int mgmt_powered(struct hci_dev *hdev, u8 powered) 2004 1997 { 2005 1998 struct mgmt_mode ev; 2006 1999 struct cmd_lookup match = { powered, NULL }; 2007 2000 int ret; 2008 2001 2009 - mgmt_pending_foreach(MGMT_OP_SET_POWERED, index, mode_rsp, &match); 2002 + mgmt_pending_foreach(MGMT_OP_SET_POWERED, hdev, mode_rsp, &match); 2003 + 2004 + if (!powered) { 2005 + u8 status = ENETDOWN; 2006 + mgmt_pending_foreach(0, hdev, cmd_status_rsp, &status); 2007 + } 2010 2008 2011 2009 ev.val = powered; 2012 2010 2013 - ret = mgmt_event(MGMT_EV_POWERED, index, &ev, sizeof(ev), match.sk); 2011 + ret = mgmt_event(MGMT_EV_POWERED, hdev, &ev, sizeof(ev), match.sk); 2014 2012 2015 2013 if (match.sk) 2016 2014 sock_put(match.sk); ··· 2023 2011 return ret; 2024 2012 } 2025 2013 2026 - int mgmt_discoverable(u16 index, u8 discoverable) 2014 + int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable) 2027 2015 { 2028 2016 struct mgmt_mode ev; 2029 2017 struct cmd_lookup match = { discoverable, NULL }; 2030 2018 int ret; 2031 2019 2032 - mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, index, mode_rsp, &match); 2020 + mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, mode_rsp, &match); 2033 2021 2034 2022 ev.val = discoverable; 2035 2023 2036 - ret = mgmt_event(MGMT_EV_DISCOVERABLE, index, &ev, sizeof(ev), 2024 + ret = mgmt_event(MGMT_EV_DISCOVERABLE, hdev, &ev, sizeof(ev), 2037 2025 match.sk); 2038 2026 2039 2027 if (match.sk) ··· 2042 2030 return ret; 2043 2031 } 2044 2032 2045 - int mgmt_connectable(u16 index, u8 connectable) 2033 + int mgmt_connectable(struct hci_dev *hdev, u8 connectable) 2046 2034 { 2047 2035 struct mgmt_mode ev; 2048 2036 struct cmd_lookup match = { connectable, NULL }; 2049 2037 int ret; 2050 2038 2051 - mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, index, mode_rsp, &match); 2039 + mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, mode_rsp, &match); 2052 2040 2053 2041 ev.val = connectable; 2054 2042 2055 - ret = mgmt_event(MGMT_EV_CONNECTABLE, index, &ev, sizeof(ev), match.sk); 2043 + ret = mgmt_event(MGMT_EV_CONNECTABLE, hdev, &ev, sizeof(ev), match.sk); 2056 2044 2057 2045 if (match.sk) 2058 2046 sock_put(match.sk); ··· 2060 2048 return ret; 2061 2049 } 2062 2050 2063 - int mgmt_new_key(u16 index, struct link_key *key, u8 persistent) 2051 + int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status) 2064 2052 { 2065 - struct mgmt_ev_new_key ev; 2053 + if (scan & SCAN_PAGE) 2054 + mgmt_pending_foreach(MGMT_OP_SET_CONNECTABLE, hdev, 2055 + cmd_status_rsp, &status); 2056 + 2057 + if (scan & SCAN_INQUIRY) 2058 + mgmt_pending_foreach(MGMT_OP_SET_DISCOVERABLE, hdev, 2059 + cmd_status_rsp, &status); 2060 + 2061 + return 0; 2062 + } 2063 + 2064 + int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, 2065 + u8 persistent) 2066 + { 2067 + struct mgmt_ev_new_link_key ev; 2066 2068 2067 2069 memset(&ev, 0, sizeof(ev)); 2068 2070 ··· 2086 2060 memcpy(ev.key.val, key->val, 16); 2087 2061 ev.key.pin_len = key->pin_len; 2088 2062 2089 - return mgmt_event(MGMT_EV_NEW_KEY, index, &ev, sizeof(ev), NULL); 2063 + return mgmt_event(MGMT_EV_NEW_LINK_KEY, hdev, &ev, sizeof(ev), NULL); 2090 2064 } 2091 2065 2092 - int mgmt_connected(u16 index, bdaddr_t *bdaddr, u8 link_type) 2066 + int mgmt_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type) 2093 2067 { 2094 - struct mgmt_ev_connected ev; 2068 + struct mgmt_addr_info ev; 2095 2069 2096 2070 bacpy(&ev.bdaddr, bdaddr); 2097 - ev.link_type = link_type; 2071 + ev.type = link_to_mgmt(link_type); 2098 2072 2099 - return mgmt_event(MGMT_EV_CONNECTED, index, &ev, sizeof(ev), NULL); 2073 + return mgmt_event(MGMT_EV_CONNECTED, hdev, &ev, sizeof(ev), NULL); 2100 2074 } 2101 2075 2102 2076 static void disconnect_rsp(struct pending_cmd *cmd, void *data) ··· 2115 2089 mgmt_pending_remove(cmd); 2116 2090 } 2117 2091 2118 - int mgmt_disconnected(u16 index, bdaddr_t *bdaddr) 2092 + int mgmt_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) 2119 2093 { 2120 - struct mgmt_ev_disconnected ev; 2094 + struct mgmt_addr_info ev; 2121 2095 struct sock *sk = NULL; 2122 2096 int err; 2123 2097 2124 - mgmt_pending_foreach(MGMT_OP_DISCONNECT, index, disconnect_rsp, &sk); 2098 + mgmt_pending_foreach(MGMT_OP_DISCONNECT, hdev, disconnect_rsp, &sk); 2125 2099 2126 2100 bacpy(&ev.bdaddr, bdaddr); 2101 + ev.type = link_to_mgmt(type); 2127 2102 2128 - err = mgmt_event(MGMT_EV_DISCONNECTED, index, &ev, sizeof(ev), sk); 2103 + err = mgmt_event(MGMT_EV_DISCONNECTED, hdev, &ev, sizeof(ev), sk); 2129 2104 2130 2105 if (sk) 2131 2106 sock_put(sk); ··· 2134 2107 return err; 2135 2108 } 2136 2109 2137 - int mgmt_disconnect_failed(u16 index) 2110 + int mgmt_disconnect_failed(struct hci_dev *hdev) 2138 2111 { 2139 2112 struct pending_cmd *cmd; 2140 2113 int err; 2141 2114 2142 - cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, index); 2115 + cmd = mgmt_pending_find(MGMT_OP_DISCONNECT, hdev); 2143 2116 if (!cmd) 2144 2117 return -ENOENT; 2145 2118 2146 - err = cmd_status(cmd->sk, index, MGMT_OP_DISCONNECT, EIO); 2119 + err = cmd_status(cmd->sk, hdev->id, MGMT_OP_DISCONNECT, EIO); 2147 2120 2148 2121 mgmt_pending_remove(cmd); 2149 2122 2150 2123 return err; 2151 2124 } 2152 2125 2153 - int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status) 2126 + int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, 2127 + u8 status) 2154 2128 { 2155 2129 struct mgmt_ev_connect_failed ev; 2156 2130 2157 - bacpy(&ev.bdaddr, bdaddr); 2131 + bacpy(&ev.addr.bdaddr, bdaddr); 2132 + ev.addr.type = link_to_mgmt(type); 2158 2133 ev.status = status; 2159 2134 2160 - return mgmt_event(MGMT_EV_CONNECT_FAILED, index, &ev, sizeof(ev), NULL); 2135 + return mgmt_event(MGMT_EV_CONNECT_FAILED, hdev, &ev, sizeof(ev), NULL); 2161 2136 } 2162 2137 2163 - int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure) 2138 + int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure) 2164 2139 { 2165 2140 struct mgmt_ev_pin_code_request ev; 2166 2141 2167 2142 bacpy(&ev.bdaddr, bdaddr); 2168 2143 ev.secure = secure; 2169 2144 2170 - return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, index, &ev, sizeof(ev), 2145 + return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, hdev, &ev, sizeof(ev), 2171 2146 NULL); 2172 2147 } 2173 2148 2174 - int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status) 2149 + int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 2150 + u8 status) 2175 2151 { 2176 2152 struct pending_cmd *cmd; 2177 2153 struct mgmt_rp_pin_code_reply rp; 2178 2154 int err; 2179 2155 2180 - cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_REPLY, index); 2156 + cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_REPLY, hdev); 2181 2157 if (!cmd) 2182 2158 return -ENOENT; 2183 2159 2184 2160 bacpy(&rp.bdaddr, bdaddr); 2185 2161 rp.status = status; 2186 2162 2187 - err = cmd_complete(cmd->sk, index, MGMT_OP_PIN_CODE_REPLY, &rp, 2163 + err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_REPLY, &rp, 2188 2164 sizeof(rp)); 2189 2165 2190 2166 mgmt_pending_remove(cmd); ··· 2195 2165 return err; 2196 2166 } 2197 2167 2198 - int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status) 2168 + int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 2169 + u8 status) 2199 2170 { 2200 2171 struct pending_cmd *cmd; 2201 2172 struct mgmt_rp_pin_code_reply rp; 2202 2173 int err; 2203 2174 2204 - cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_NEG_REPLY, index); 2175 + cmd = mgmt_pending_find(MGMT_OP_PIN_CODE_NEG_REPLY, hdev); 2205 2176 if (!cmd) 2206 2177 return -ENOENT; 2207 2178 2208 2179 bacpy(&rp.bdaddr, bdaddr); 2209 2180 rp.status = status; 2210 2181 2211 - err = cmd_complete(cmd->sk, index, MGMT_OP_PIN_CODE_NEG_REPLY, &rp, 2182 + err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY, &rp, 2212 2183 sizeof(rp)); 2213 2184 2214 2185 mgmt_pending_remove(cmd); ··· 2217 2186 return err; 2218 2187 } 2219 2188 2220 - int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value, 2221 - u8 confirm_hint) 2189 + int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, 2190 + __le32 value, u8 confirm_hint) 2222 2191 { 2223 2192 struct mgmt_ev_user_confirm_request ev; 2224 2193 2225 - BT_DBG("hci%u", index); 2194 + BT_DBG("%s", hdev->name); 2226 2195 2227 2196 bacpy(&ev.bdaddr, bdaddr); 2228 2197 ev.confirm_hint = confirm_hint; 2229 2198 put_unaligned_le32(value, &ev.value); 2230 2199 2231 - return mgmt_event(MGMT_EV_USER_CONFIRM_REQUEST, index, &ev, sizeof(ev), 2200 + return mgmt_event(MGMT_EV_USER_CONFIRM_REQUEST, hdev, &ev, sizeof(ev), 2232 2201 NULL); 2233 2202 } 2234 2203 2235 - static int confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status, 2236 - u8 opcode) 2204 + static int confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 2205 + u8 status, u8 opcode) 2237 2206 { 2238 2207 struct pending_cmd *cmd; 2239 2208 struct mgmt_rp_user_confirm_reply rp; 2240 2209 int err; 2241 2210 2242 - cmd = mgmt_pending_find(opcode, index); 2211 + cmd = mgmt_pending_find(opcode, hdev); 2243 2212 if (!cmd) 2244 2213 return -ENOENT; 2245 2214 2246 2215 bacpy(&rp.bdaddr, bdaddr); 2247 2216 rp.status = status; 2248 - err = cmd_complete(cmd->sk, index, opcode, &rp, sizeof(rp)); 2217 + err = cmd_complete(cmd->sk, hdev->id, opcode, &rp, sizeof(rp)); 2249 2218 2250 2219 mgmt_pending_remove(cmd); 2251 2220 2252 2221 return err; 2253 2222 } 2254 2223 2255 - int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status) 2224 + int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, 2225 + u8 status) 2256 2226 { 2257 - return confirm_reply_complete(index, bdaddr, status, 2227 + return confirm_reply_complete(hdev, bdaddr, status, 2258 2228 MGMT_OP_USER_CONFIRM_REPLY); 2259 2229 } 2260 2230 2261 - int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status) 2231 + int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, 2232 + bdaddr_t *bdaddr, u8 status) 2262 2233 { 2263 - return confirm_reply_complete(index, bdaddr, status, 2234 + return confirm_reply_complete(hdev, bdaddr, status, 2264 2235 MGMT_OP_USER_CONFIRM_NEG_REPLY); 2265 2236 } 2266 2237 2267 - int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status) 2238 + int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 status) 2268 2239 { 2269 2240 struct mgmt_ev_auth_failed ev; 2270 2241 2271 2242 bacpy(&ev.bdaddr, bdaddr); 2272 2243 ev.status = status; 2273 2244 2274 - return mgmt_event(MGMT_EV_AUTH_FAILED, index, &ev, sizeof(ev), NULL); 2245 + return mgmt_event(MGMT_EV_AUTH_FAILED, hdev, &ev, sizeof(ev), NULL); 2275 2246 } 2276 2247 2277 - int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status) 2248 + int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status) 2278 2249 { 2279 2250 struct pending_cmd *cmd; 2280 - struct hci_dev *hdev; 2281 2251 struct mgmt_cp_set_local_name ev; 2282 2252 int err; 2283 2253 2284 2254 memset(&ev, 0, sizeof(ev)); 2285 2255 memcpy(ev.name, name, HCI_MAX_NAME_LENGTH); 2286 2256 2287 - cmd = mgmt_pending_find(MGMT_OP_SET_LOCAL_NAME, index); 2257 + cmd = mgmt_pending_find(MGMT_OP_SET_LOCAL_NAME, hdev); 2288 2258 if (!cmd) 2289 2259 goto send_event; 2290 2260 2291 2261 if (status) { 2292 - err = cmd_status(cmd->sk, index, MGMT_OP_SET_LOCAL_NAME, EIO); 2262 + err = cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, 2263 + EIO); 2293 2264 goto failed; 2294 2265 } 2295 2266 2296 - hdev = hci_dev_get(index); 2297 - if (hdev) { 2298 - hci_dev_lock_bh(hdev); 2299 - update_eir(hdev); 2300 - hci_dev_unlock_bh(hdev); 2301 - hci_dev_put(hdev); 2302 - } 2267 + update_eir(hdev); 2303 2268 2304 - err = cmd_complete(cmd->sk, index, MGMT_OP_SET_LOCAL_NAME, &ev, 2269 + err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_SET_LOCAL_NAME, &ev, 2305 2270 sizeof(ev)); 2306 2271 if (err < 0) 2307 2272 goto failed; 2308 2273 2309 2274 send_event: 2310 - err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, index, &ev, sizeof(ev), 2275 + err = mgmt_event(MGMT_EV_LOCAL_NAME_CHANGED, hdev, &ev, sizeof(ev), 2311 2276 cmd ? cmd->sk : NULL); 2312 2277 2313 2278 failed: ··· 2312 2285 return err; 2313 2286 } 2314 2287 2315 - int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, 2316 - u8 status) 2288 + int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, 2289 + u8 *randomizer, u8 status) 2317 2290 { 2318 2291 struct pending_cmd *cmd; 2319 2292 int err; 2320 2293 2321 - BT_DBG("hci%u status %u", index, status); 2294 + BT_DBG("%s status %u", hdev->name, status); 2322 2295 2323 - cmd = mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, index); 2296 + cmd = mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, hdev); 2324 2297 if (!cmd) 2325 2298 return -ENOENT; 2326 2299 2327 2300 if (status) { 2328 - err = cmd_status(cmd->sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, 2329 - EIO); 2301 + err = cmd_status(cmd->sk, hdev->id, 2302 + MGMT_OP_READ_LOCAL_OOB_DATA, EIO); 2330 2303 } else { 2331 2304 struct mgmt_rp_read_local_oob_data rp; 2332 2305 2333 2306 memcpy(rp.hash, hash, sizeof(rp.hash)); 2334 2307 memcpy(rp.randomizer, randomizer, sizeof(rp.randomizer)); 2335 2308 2336 - err = cmd_complete(cmd->sk, index, MGMT_OP_READ_LOCAL_OOB_DATA, 2337 - &rp, sizeof(rp)); 2309 + err = cmd_complete(cmd->sk, hdev->id, 2310 + MGMT_OP_READ_LOCAL_OOB_DATA, 2311 + &rp, sizeof(rp)); 2338 2312 } 2339 2313 2340 2314 mgmt_pending_remove(cmd); ··· 2343 2315 return err; 2344 2316 } 2345 2317 2346 - int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, 2347 - u8 *eir) 2318 + int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type, 2319 + u8 *dev_class, s8 rssi, u8 *eir) 2348 2320 { 2349 2321 struct mgmt_ev_device_found ev; 2350 2322 2351 2323 memset(&ev, 0, sizeof(ev)); 2352 2324 2353 - bacpy(&ev.bdaddr, bdaddr); 2325 + bacpy(&ev.addr.bdaddr, bdaddr); 2326 + ev.addr.type = link_to_mgmt(type); 2354 2327 ev.rssi = rssi; 2355 2328 2356 2329 if (eir) ··· 2360 2331 if (dev_class) 2361 2332 memcpy(ev.dev_class, dev_class, sizeof(ev.dev_class)); 2362 2333 2363 - return mgmt_event(MGMT_EV_DEVICE_FOUND, index, &ev, sizeof(ev), NULL); 2334 + return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, &ev, sizeof(ev), NULL); 2364 2335 } 2365 2336 2366 - int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name) 2337 + int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *name) 2367 2338 { 2368 2339 struct mgmt_ev_remote_name ev; 2369 2340 ··· 2372 2343 bacpy(&ev.bdaddr, bdaddr); 2373 2344 memcpy(ev.name, name, HCI_MAX_NAME_LENGTH); 2374 2345 2375 - return mgmt_event(MGMT_EV_REMOTE_NAME, index, &ev, sizeof(ev), NULL); 2346 + return mgmt_event(MGMT_EV_REMOTE_NAME, hdev, &ev, sizeof(ev), NULL); 2376 2347 } 2377 2348 2378 - int mgmt_discovering(u16 index, u8 discovering) 2349 + int mgmt_inquiry_failed(struct hci_dev *hdev, u8 status) 2379 2350 { 2380 - return mgmt_event(MGMT_EV_DISCOVERING, index, &discovering, 2351 + struct pending_cmd *cmd; 2352 + int err; 2353 + 2354 + cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev); 2355 + if (!cmd) 2356 + return -ENOENT; 2357 + 2358 + err = cmd_status(cmd->sk, hdev->id, cmd->opcode, status); 2359 + mgmt_pending_remove(cmd); 2360 + 2361 + return err; 2362 + } 2363 + 2364 + int mgmt_discovering(struct hci_dev *hdev, u8 discovering) 2365 + { 2366 + struct pending_cmd *cmd; 2367 + 2368 + if (discovering) 2369 + cmd = mgmt_pending_find(MGMT_OP_START_DISCOVERY, hdev); 2370 + else 2371 + cmd = mgmt_pending_find(MGMT_OP_STOP_DISCOVERY, hdev); 2372 + 2373 + if (cmd != NULL) { 2374 + cmd_complete(cmd->sk, hdev->id, cmd->opcode, NULL, 0); 2375 + mgmt_pending_remove(cmd); 2376 + } 2377 + 2378 + return mgmt_event(MGMT_EV_DISCOVERING, hdev, &discovering, 2381 2379 sizeof(discovering), NULL); 2382 2380 } 2383 2381 2384 - int mgmt_device_blocked(u16 index, bdaddr_t *bdaddr) 2382 + int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr) 2385 2383 { 2386 2384 struct pending_cmd *cmd; 2387 2385 struct mgmt_ev_device_blocked ev; 2388 2386 2389 - cmd = mgmt_pending_find(MGMT_OP_BLOCK_DEVICE, index); 2387 + cmd = mgmt_pending_find(MGMT_OP_BLOCK_DEVICE, hdev); 2390 2388 2391 2389 bacpy(&ev.bdaddr, bdaddr); 2392 2390 2393 - return mgmt_event(MGMT_EV_DEVICE_BLOCKED, index, &ev, sizeof(ev), 2394 - cmd ? cmd->sk : NULL); 2391 + return mgmt_event(MGMT_EV_DEVICE_BLOCKED, hdev, &ev, sizeof(ev), 2392 + cmd ? cmd->sk : NULL); 2395 2393 } 2396 2394 2397 - int mgmt_device_unblocked(u16 index, bdaddr_t *bdaddr) 2395 + int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr) 2398 2396 { 2399 2397 struct pending_cmd *cmd; 2400 2398 struct mgmt_ev_device_unblocked ev; 2401 2399 2402 - cmd = mgmt_pending_find(MGMT_OP_UNBLOCK_DEVICE, index); 2400 + cmd = mgmt_pending_find(MGMT_OP_UNBLOCK_DEVICE, hdev); 2403 2401 2404 2402 bacpy(&ev.bdaddr, bdaddr); 2405 2403 2406 - return mgmt_event(MGMT_EV_DEVICE_UNBLOCKED, index, &ev, sizeof(ev), 2407 - cmd ? cmd->sk : NULL); 2404 + return mgmt_event(MGMT_EV_DEVICE_UNBLOCKED, hdev, &ev, sizeof(ev), 2405 + cmd ? cmd->sk : NULL); 2408 2406 }
+40 -25
net/bluetooth/rfcomm/core.c
··· 65 65 66 66 static LIST_HEAD(session_list); 67 67 68 - static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len); 68 + static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len, 69 + u32 priority); 69 70 static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci); 70 71 static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci); 71 72 static int rfcomm_queue_disc(struct rfcomm_dlc *d); ··· 378 377 static struct rfcomm_dlc *rfcomm_dlc_get(struct rfcomm_session *s, u8 dlci) 379 378 { 380 379 struct rfcomm_dlc *d; 381 - struct list_head *p; 382 380 383 - list_for_each(p, &s->dlcs) { 384 - d = list_entry(p, struct rfcomm_dlc, list); 381 + list_for_each_entry(d, &s->dlcs, list) 385 382 if (d->dlci == dlci) 386 383 return d; 387 - } 384 + 388 385 return NULL; 389 386 } 390 387 ··· 748 749 } 749 750 750 751 /* ---- RFCOMM frame sending ---- */ 751 - static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len) 752 + static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len, 753 + u32 priority) 752 754 { 753 755 struct socket *sock = s->sock; 756 + struct sock *sk = sock->sk; 754 757 struct kvec iv = { data, len }; 755 758 struct msghdr msg; 756 759 757 - BT_DBG("session %p len %d", s, len); 760 + BT_DBG("session %p len %d priority %u", s, len, priority); 761 + 762 + if (sk->sk_priority != priority) { 763 + lock_sock(sk); 764 + sk->sk_priority = priority; 765 + release_sock(sk); 766 + } 758 767 759 768 memset(&msg, 0, sizeof(msg)); 760 769 761 770 return kernel_sendmsg(sock, &msg, &iv, 1, len); 771 + } 772 + 773 + static int rfcomm_send_cmd(struct rfcomm_session *s, struct rfcomm_cmd *cmd) 774 + { 775 + BT_DBG("%p cmd %u", s, cmd->ctrl); 776 + 777 + return rfcomm_send_frame(s, (void *) cmd, sizeof(*cmd), HCI_PRIO_MAX); 762 778 } 763 779 764 780 static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci) ··· 787 773 cmd.len = __len8(0); 788 774 cmd.fcs = __fcs2((u8 *) &cmd); 789 775 790 - return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); 776 + return rfcomm_send_cmd(s, &cmd); 791 777 } 792 778 793 779 static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci) ··· 801 787 cmd.len = __len8(0); 802 788 cmd.fcs = __fcs2((u8 *) &cmd); 803 789 804 - return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); 790 + return rfcomm_send_cmd(s, &cmd); 805 791 } 806 792 807 793 static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci) ··· 815 801 cmd.len = __len8(0); 816 802 cmd.fcs = __fcs2((u8 *) &cmd); 817 803 818 - return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); 804 + return rfcomm_send_cmd(s, &cmd); 819 805 } 820 806 821 807 static int rfcomm_queue_disc(struct rfcomm_dlc *d) ··· 828 814 skb = alloc_skb(sizeof(*cmd), GFP_KERNEL); 829 815 if (!skb) 830 816 return -ENOMEM; 817 + 818 + skb->priority = HCI_PRIO_MAX; 831 819 832 820 cmd = (void *) __skb_put(skb, sizeof(*cmd)); 833 821 cmd->addr = d->addr; ··· 853 837 cmd.len = __len8(0); 854 838 cmd.fcs = __fcs2((u8 *) &cmd); 855 839 856 - return rfcomm_send_frame(s, (void *) &cmd, sizeof(cmd)); 840 + return rfcomm_send_cmd(s, &cmd); 857 841 } 858 842 859 843 static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type) ··· 878 862 879 863 *ptr = __fcs(buf); ptr++; 880 864 881 - return rfcomm_send_frame(s, buf, ptr - buf); 865 + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); 882 866 } 883 867 884 868 static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d) ··· 920 904 921 905 *ptr = __fcs(buf); ptr++; 922 906 923 - return rfcomm_send_frame(s, buf, ptr - buf); 907 + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); 924 908 } 925 909 926 910 int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, ··· 958 942 959 943 *ptr = __fcs(buf); ptr++; 960 944 961 - return rfcomm_send_frame(s, buf, ptr - buf); 945 + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); 962 946 } 963 947 964 948 static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status) ··· 985 969 986 970 *ptr = __fcs(buf); ptr++; 987 971 988 - return rfcomm_send_frame(s, buf, ptr - buf); 972 + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); 989 973 } 990 974 991 975 static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig) ··· 1012 996 1013 997 *ptr = __fcs(buf); ptr++; 1014 998 1015 - return rfcomm_send_frame(s, buf, ptr - buf); 999 + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); 1016 1000 } 1017 1001 1018 1002 static int rfcomm_send_fcoff(struct rfcomm_session *s, int cr) ··· 1034 1018 1035 1019 *ptr = __fcs(buf); ptr++; 1036 1020 1037 - return rfcomm_send_frame(s, buf, ptr - buf); 1021 + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); 1038 1022 } 1039 1023 1040 1024 static int rfcomm_send_fcon(struct rfcomm_session *s, int cr) ··· 1056 1040 1057 1041 *ptr = __fcs(buf); ptr++; 1058 1042 1059 - return rfcomm_send_frame(s, buf, ptr - buf); 1043 + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); 1060 1044 } 1061 1045 1062 1046 static int rfcomm_send_test(struct rfcomm_session *s, int cr, u8 *pattern, int len) ··· 1107 1091 1108 1092 *ptr = __fcs(buf); ptr++; 1109 1093 1110 - return rfcomm_send_frame(s, buf, ptr - buf); 1094 + return rfcomm_send_frame(s, buf, ptr - buf, HCI_PRIO_MAX); 1111 1095 } 1112 1096 1113 1097 static void rfcomm_make_uih(struct sk_buff *skb, u8 addr) ··· 1785 1769 return skb_queue_len(&d->tx_queue); 1786 1770 1787 1771 while (d->tx_credits && (skb = skb_dequeue(&d->tx_queue))) { 1788 - err = rfcomm_send_frame(d->session, skb->data, skb->len); 1772 + err = rfcomm_send_frame(d->session, skb->data, skb->len, 1773 + skb->priority); 1789 1774 if (err < 0) { 1790 1775 skb_queue_head(&d->tx_queue, skb); 1791 1776 break; ··· 2137 2120 static int rfcomm_dlc_debugfs_show(struct seq_file *f, void *x) 2138 2121 { 2139 2122 struct rfcomm_session *s; 2140 - struct list_head *pp, *p; 2141 2123 2142 2124 rfcomm_lock(); 2143 2125 2144 - list_for_each(p, &session_list) { 2145 - s = list_entry(p, struct rfcomm_session, list); 2146 - list_for_each(pp, &s->dlcs) { 2126 + list_for_each_entry(s, &session_list, list) { 2127 + struct rfcomm_dlc *d; 2128 + list_for_each_entry(d, &s->dlcs, list) { 2147 2129 struct sock *sk = s->sock->sk; 2148 - struct rfcomm_dlc *d = list_entry(pp, struct rfcomm_dlc, list); 2149 2130 2150 2131 seq_printf(f, "%s %s %ld %d %d %d %d\n", 2151 2132 batostr(&bt_sk(sk)->src),
+2
net/bluetooth/rfcomm/sock.c
··· 600 600 break; 601 601 } 602 602 603 + skb->priority = sk->sk_priority; 604 + 603 605 err = rfcomm_dlc_send(d, skb); 604 606 if (err < 0) { 605 607 kfree_skb(skb);
+22 -23
net/bluetooth/rfcomm/tty.c
··· 34 34 #include <linux/capability.h> 35 35 #include <linux/slab.h> 36 36 #include <linux/skbuff.h> 37 + #include <linux/workqueue.h> 37 38 38 39 #include <net/bluetooth/bluetooth.h> 39 40 #include <net/bluetooth/hci_core.h> ··· 66 65 struct rfcomm_dlc *dlc; 67 66 struct tty_struct *tty; 68 67 wait_queue_head_t wait; 69 - struct tasklet_struct wakeup_task; 68 + struct work_struct wakeup_task; 70 69 71 70 struct device *tty_dev; 72 71 ··· 82 81 static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err); 83 82 static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig); 84 83 85 - static void rfcomm_tty_wakeup(unsigned long arg); 84 + static void rfcomm_tty_wakeup(struct work_struct *work); 86 85 87 86 /* ---- Device functions ---- */ 88 87 static void rfcomm_dev_destruct(struct rfcomm_dev *dev) ··· 134 133 static struct rfcomm_dev *__rfcomm_dev_get(int id) 135 134 { 136 135 struct rfcomm_dev *dev; 137 - struct list_head *p; 138 136 139 - list_for_each(p, &rfcomm_dev_list) { 140 - dev = list_entry(p, struct rfcomm_dev, list); 137 + list_for_each_entry(dev, &rfcomm_dev_list, list) 141 138 if (dev->id == id) 142 139 return dev; 143 - } 144 140 145 141 return NULL; 146 142 } ··· 195 197 196 198 static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc) 197 199 { 198 - struct rfcomm_dev *dev; 200 + struct rfcomm_dev *dev, *entry; 199 201 struct list_head *head = &rfcomm_dev_list, *p; 200 202 int err = 0; 201 203 ··· 210 212 if (req->dev_id < 0) { 211 213 dev->id = 0; 212 214 213 - list_for_each(p, &rfcomm_dev_list) { 214 - if (list_entry(p, struct rfcomm_dev, list)->id != dev->id) 215 + list_for_each_entry(entry, &rfcomm_dev_list, list) { 216 + if (entry->id != dev->id) 215 217 break; 216 218 217 219 dev->id++; ··· 220 222 } else { 221 223 dev->id = req->dev_id; 222 224 223 - list_for_each(p, &rfcomm_dev_list) { 224 - struct rfcomm_dev *entry = list_entry(p, struct rfcomm_dev, list); 225 - 225 + list_for_each_entry(entry, &rfcomm_dev_list, list) { 226 226 if (entry->id == dev->id) { 227 227 err = -EADDRINUSE; 228 228 goto out; ··· 253 257 atomic_set(&dev->opened, 0); 254 258 255 259 init_waitqueue_head(&dev->wait); 256 - tasklet_init(&dev->wakeup_task, rfcomm_tty_wakeup, (unsigned long) dev); 260 + INIT_WORK(&dev->wakeup_task, rfcomm_tty_wakeup); 257 261 258 262 skb_queue_head_init(&dev->pending); 259 263 ··· 347 351 struct rfcomm_dev *dev = (void *) skb->sk; 348 352 atomic_sub(skb->truesize, &dev->wmem_alloc); 349 353 if (test_bit(RFCOMM_TTY_ATTACHED, &dev->flags)) 350 - tasklet_schedule(&dev->wakeup_task); 354 + queue_work(system_nrt_wq, &dev->wakeup_task); 351 355 rfcomm_dev_put(dev); 352 356 } 353 357 ··· 451 455 452 456 static int rfcomm_get_dev_list(void __user *arg) 453 457 { 458 + struct rfcomm_dev *dev; 454 459 struct rfcomm_dev_list_req *dl; 455 460 struct rfcomm_dev_info *di; 456 - struct list_head *p; 457 461 int n = 0, size, err; 458 462 u16 dev_num; 459 463 ··· 475 479 476 480 read_lock_bh(&rfcomm_dev_lock); 477 481 478 - list_for_each(p, &rfcomm_dev_list) { 479 - struct rfcomm_dev *dev = list_entry(p, struct rfcomm_dev, list); 482 + list_for_each_entry(dev, &rfcomm_dev_list, list) { 480 483 if (test_bit(RFCOMM_TTY_RELEASED, &dev->flags)) 481 484 continue; 482 485 (di + n)->id = dev->id; ··· 630 635 } 631 636 632 637 /* ---- TTY functions ---- */ 633 - static void rfcomm_tty_wakeup(unsigned long arg) 638 + static void rfcomm_tty_wakeup(struct work_struct *work) 634 639 { 635 - struct rfcomm_dev *dev = (void *) arg; 640 + struct rfcomm_dev *dev = container_of(work, struct rfcomm_dev, 641 + wakeup_task); 636 642 struct tty_struct *tty = dev->tty; 637 643 if (!tty) 638 644 return; ··· 758 762 rfcomm_dlc_close(dev->dlc, 0); 759 763 760 764 clear_bit(RFCOMM_TTY_ATTACHED, &dev->flags); 761 - tasklet_kill(&dev->wakeup_task); 765 + cancel_work_sync(&dev->wakeup_task); 762 766 763 767 rfcomm_dlc_lock(dev->dlc); 764 768 tty->driver_data = NULL; ··· 1151 1155 1152 1156 int __init rfcomm_init_ttys(void) 1153 1157 { 1158 + int error; 1159 + 1154 1160 rfcomm_tty_driver = alloc_tty_driver(RFCOMM_TTY_PORTS); 1155 1161 if (!rfcomm_tty_driver) 1156 - return -1; 1162 + return -ENOMEM; 1157 1163 1158 1164 rfcomm_tty_driver->owner = THIS_MODULE; 1159 1165 rfcomm_tty_driver->driver_name = "rfcomm"; ··· 1170 1172 rfcomm_tty_driver->init_termios.c_lflag &= ~ICANON; 1171 1173 tty_set_operations(rfcomm_tty_driver, &rfcomm_ops); 1172 1174 1173 - if (tty_register_driver(rfcomm_tty_driver)) { 1175 + error = tty_register_driver(rfcomm_tty_driver); 1176 + if (error) { 1174 1177 BT_ERR("Can't register RFCOMM TTY driver"); 1175 1178 put_tty_driver(rfcomm_tty_driver); 1176 - return -1; 1179 + return error; 1177 1180 } 1178 1181 1179 1182 BT_INFO("RFCOMM TTY layer initialized");
+2 -1
net/bluetooth/smp.c
··· 181 181 if (!skb) 182 182 return; 183 183 184 - hci_send_acl(conn->hcon, skb, 0); 184 + skb->priority = HCI_PRIO_MAX; 185 + hci_send_acl(conn->hchan, skb, 0); 185 186 186 187 mod_timer(&conn->security_timer, jiffies + 187 188 msecs_to_jiffies(SMP_TIMEOUT));
+20
net/core/skbuff.c
··· 3218 3218 } 3219 3219 EXPORT_SYMBOL_GPL(skb_tstamp_tx); 3220 3220 3221 + void skb_complete_wifi_ack(struct sk_buff *skb, bool acked) 3222 + { 3223 + struct sock *sk = skb->sk; 3224 + struct sock_exterr_skb *serr; 3225 + int err; 3226 + 3227 + skb->wifi_acked_valid = 1; 3228 + skb->wifi_acked = acked; 3229 + 3230 + serr = SKB_EXT_ERR(skb); 3231 + memset(serr, 0, sizeof(*serr)); 3232 + serr->ee.ee_errno = ENOMSG; 3233 + serr->ee.ee_origin = SO_EE_ORIGIN_TXSTATUS; 3234 + 3235 + err = sock_queue_err_skb(sk, skb); 3236 + if (err) 3237 + kfree_skb(skb); 3238 + } 3239 + EXPORT_SYMBOL_GPL(skb_complete_wifi_ack); 3240 + 3221 3241 3222 3242 /** 3223 3243 * skb_partial_csum_set - set up and verify partial csum values for packet
+9
net/core/sock.c
··· 740 740 case SO_RXQ_OVFL: 741 741 sock_valbool_flag(sk, SOCK_RXQ_OVFL, valbool); 742 742 break; 743 + 744 + case SO_WIFI_STATUS: 745 + sock_valbool_flag(sk, SOCK_WIFI_STATUS, valbool); 746 + break; 747 + 743 748 default: 744 749 ret = -ENOPROTOOPT; 745 750 break; ··· 964 959 965 960 case SO_RXQ_OVFL: 966 961 v.val = !!sock_flag(sk, SOCK_RXQ_OVFL); 962 + break; 963 + 964 + case SO_WIFI_STATUS: 965 + v.val = !!sock_flag(sk, SOCK_WIFI_STATUS); 967 966 break; 968 967 969 968 default:
+2 -1
net/mac80211/agg-rx.c
··· 177 177 memcpy(mgmt->da, da, ETH_ALEN); 178 178 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); 179 179 if (sdata->vif.type == NL80211_IFTYPE_AP || 180 - sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 180 + sdata->vif.type == NL80211_IFTYPE_AP_VLAN || 181 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT) 181 182 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); 182 183 else if (sdata->vif.type == NL80211_IFTYPE_STATION) 183 184 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
+3 -7
net/mac80211/agg-tx.c
··· 78 78 memcpy(mgmt->da, da, ETH_ALEN); 79 79 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); 80 80 if (sdata->vif.type == NL80211_IFTYPE_AP || 81 - sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 81 + sdata->vif.type == NL80211_IFTYPE_AP_VLAN || 82 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT) 82 83 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); 83 84 else if (sdata->vif.type == NL80211_IFTYPE_STATION) 84 85 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); ··· 373 372 pubsta->addr, tid); 374 373 #endif /* CONFIG_MAC80211_HT_DEBUG */ 375 374 376 - /* 377 - * The aggregation code is not prepared to handle 378 - * anything but STA/AP due to the BSSID handling. 379 - * IBSS could work in the code but isn't supported 380 - * by drivers or the standard. 381 - */ 382 375 if (sdata->vif.type != NL80211_IFTYPE_STATION && 376 + sdata->vif.type != NL80211_IFTYPE_MESH_POINT && 383 377 sdata->vif.type != NL80211_IFTYPE_AP_VLAN && 384 378 sdata->vif.type != NL80211_IFTYPE_AP) 385 379 return -EINVAL;
+156 -11
net/mac80211/cfg.c
··· 411 411 BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) | 412 412 BIT(NL80211_STA_FLAG_WME) | 413 413 BIT(NL80211_STA_FLAG_MFP) | 414 - BIT(NL80211_STA_FLAG_AUTHENTICATED); 414 + BIT(NL80211_STA_FLAG_AUTHENTICATED) | 415 + BIT(NL80211_STA_FLAG_TDLS_PEER); 415 416 if (test_sta_flag(sta, WLAN_STA_AUTHORIZED)) 416 417 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED); 417 418 if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE)) ··· 423 422 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP); 424 423 if (test_sta_flag(sta, WLAN_STA_AUTH)) 425 424 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED); 425 + if (test_sta_flag(sta, WLAN_STA_TDLS_PEER)) 426 + sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER); 426 427 } 427 428 428 429 ··· 491 488 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE); 492 489 } 493 490 491 + static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata, 492 + u8 *resp, size_t resp_len) 493 + { 494 + struct sk_buff *new, *old; 495 + 496 + if (!resp || !resp_len) 497 + return -EINVAL; 498 + 499 + old = sdata->u.ap.probe_resp; 500 + 501 + new = dev_alloc_skb(resp_len); 502 + if (!new) 503 + return -ENOMEM; 504 + 505 + memcpy(skb_put(new, resp_len), resp, resp_len); 506 + 507 + rcu_assign_pointer(sdata->u.ap.probe_resp, new); 508 + synchronize_rcu(); 509 + 510 + if (old) 511 + dev_kfree_skb(old); 512 + 513 + return 0; 514 + } 515 + 494 516 /* 495 517 * This handles both adding a beacon and setting new beacon info 496 518 */ ··· 526 498 int new_head_len, new_tail_len; 527 499 int size; 528 500 int err = -EINVAL; 501 + u32 changed = 0; 529 502 530 503 old = rtnl_dereference(sdata->u.ap.beacon); 531 504 ··· 610 581 611 582 kfree(old); 612 583 613 - ieee80211_config_ap_ssid(sdata, params); 584 + err = ieee80211_set_probe_resp(sdata, params->probe_resp, 585 + params->probe_resp_len); 586 + if (!err) 587 + changed |= BSS_CHANGED_AP_PROBE_RESP; 614 588 615 - ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED | 616 - BSS_CHANGED_BEACON | 617 - BSS_CHANGED_SSID); 589 + ieee80211_config_ap_ssid(sdata, params); 590 + changed |= BSS_CHANGED_BEACON_ENABLED | 591 + BSS_CHANGED_BEACON | 592 + BSS_CHANGED_SSID; 593 + 594 + ieee80211_bss_info_change_notify(sdata, changed); 618 595 return 0; 619 596 } 620 597 ··· 629 594 { 630 595 struct ieee80211_sub_if_data *sdata; 631 596 struct beacon_data *old; 597 + struct ieee80211_sub_if_data *vlan; 598 + int ret; 632 599 633 600 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 634 601 ··· 638 601 if (old) 639 602 return -EALREADY; 640 603 641 - return ieee80211_config_beacon(sdata, params); 604 + ret = ieee80211_config_beacon(sdata, params); 605 + if (ret) 606 + return ret; 607 + 608 + /* 609 + * Apply control port protocol, this allows us to 610 + * not encrypt dynamic WEP control frames. 611 + */ 612 + sdata->control_port_protocol = params->crypto.control_port_ethertype; 613 + sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt; 614 + list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) { 615 + vlan->control_port_protocol = 616 + params->crypto.control_port_ethertype; 617 + vlan->control_port_no_encrypt = 618 + params->crypto.control_port_no_encrypt; 619 + } 620 + 621 + return 0; 642 622 } 643 623 644 624 static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, ··· 901 847 902 848 sta_apply_parameters(local, sta, params); 903 849 904 - rate_control_rate_init(sta); 850 + /* 851 + * for TDLS, rate control should be initialized only when supported 852 + * rates are known. 853 + */ 854 + if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER)) 855 + rate_control_rate_init(sta); 905 856 906 857 layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN || 907 858 sdata->vif.type == NL80211_IFTYPE_AP; ··· 989 930 } 990 931 991 932 sta_apply_parameters(local, sta, params); 933 + 934 + if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates) 935 + rate_control_rate_init(sta); 992 936 993 937 rcu_read_unlock(); 994 938 ··· 1456 1394 (old_oper_type != local->_oper_channel_type)) 1457 1395 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); 1458 1396 1459 - if ((sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) && 1397 + if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR && 1460 1398 old_vif_oper_type != sdata->vif.bss_conf.channel_type) 1461 1399 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT); 1462 1400 ··· 1979 1917 enum nl80211_channel_type channel_type, 1980 1918 bool channel_type_valid, unsigned int wait, 1981 1919 const u8 *buf, size_t len, bool no_cck, 1982 - u64 *cookie) 1920 + bool dont_wait_for_ack, u64 *cookie) 1983 1921 { 1984 1922 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 1985 1923 struct ieee80211_local *local = sdata->local; ··· 1987 1925 struct sta_info *sta; 1988 1926 struct ieee80211_work *wk; 1989 1927 const struct ieee80211_mgmt *mgmt = (void *)buf; 1990 - u32 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX | 1991 - IEEE80211_TX_CTL_REQ_TX_STATUS; 1928 + u32 flags; 1992 1929 bool is_offchan = false; 1930 + 1931 + if (dont_wait_for_ack) 1932 + flags = IEEE80211_TX_CTL_NO_ACK; 1933 + else 1934 + flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX | 1935 + IEEE80211_TX_CTL_REQ_TX_STATUS; 1993 1936 1994 1937 /* Check that we are on the requested channel for transmission */ 1995 1938 if (chan != local->tmp_channel && ··· 2555 2488 return 0; 2556 2489 } 2557 2490 2491 + static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev, 2492 + const u8 *peer, u64 *cookie) 2493 + { 2494 + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2495 + struct ieee80211_local *local = sdata->local; 2496 + struct ieee80211_qos_hdr *nullfunc; 2497 + struct sk_buff *skb; 2498 + int size = sizeof(*nullfunc); 2499 + __le16 fc; 2500 + bool qos; 2501 + struct ieee80211_tx_info *info; 2502 + struct sta_info *sta; 2503 + 2504 + rcu_read_lock(); 2505 + sta = sta_info_get(sdata, peer); 2506 + if (sta) { 2507 + qos = test_sta_flag(sta, WLAN_STA_WME); 2508 + rcu_read_unlock(); 2509 + } else { 2510 + rcu_read_unlock(); 2511 + return -ENOLINK; 2512 + } 2513 + 2514 + if (qos) { 2515 + fc = cpu_to_le16(IEEE80211_FTYPE_DATA | 2516 + IEEE80211_STYPE_QOS_NULLFUNC | 2517 + IEEE80211_FCTL_FROMDS); 2518 + } else { 2519 + size -= 2; 2520 + fc = cpu_to_le16(IEEE80211_FTYPE_DATA | 2521 + IEEE80211_STYPE_NULLFUNC | 2522 + IEEE80211_FCTL_FROMDS); 2523 + } 2524 + 2525 + skb = dev_alloc_skb(local->hw.extra_tx_headroom + size); 2526 + if (!skb) 2527 + return -ENOMEM; 2528 + 2529 + skb->dev = dev; 2530 + 2531 + skb_reserve(skb, local->hw.extra_tx_headroom); 2532 + 2533 + nullfunc = (void *) skb_put(skb, size); 2534 + nullfunc->frame_control = fc; 2535 + nullfunc->duration_id = 0; 2536 + memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN); 2537 + memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN); 2538 + memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN); 2539 + nullfunc->seq_ctrl = 0; 2540 + 2541 + info = IEEE80211_SKB_CB(skb); 2542 + 2543 + info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS | 2544 + IEEE80211_TX_INTFL_NL80211_FRAME_TX; 2545 + 2546 + skb_set_queue_mapping(skb, IEEE80211_AC_VO); 2547 + skb->priority = 7; 2548 + if (qos) 2549 + nullfunc->qos_ctrl = cpu_to_le16(7); 2550 + 2551 + local_bh_disable(); 2552 + ieee80211_xmit(sdata, skb); 2553 + local_bh_enable(); 2554 + 2555 + *cookie = (unsigned long) skb; 2556 + return 0; 2557 + } 2558 + 2559 + static struct ieee80211_channel * 2560 + ieee80211_wiphy_get_channel(struct wiphy *wiphy) 2561 + { 2562 + struct ieee80211_local *local = wiphy_priv(wiphy); 2563 + 2564 + return local->oper_channel; 2565 + } 2566 + 2558 2567 struct cfg80211_ops mac80211_config_ops = { 2559 2568 .add_virtual_intf = ieee80211_add_iface, 2560 2569 .del_virtual_intf = ieee80211_del_iface, ··· 2696 2553 .set_rekey_data = ieee80211_set_rekey_data, 2697 2554 .tdls_oper = ieee80211_tdls_oper, 2698 2555 .tdls_mgmt = ieee80211_tdls_mgmt, 2556 + .probe_client = ieee80211_probe_client, 2557 + .get_channel = ieee80211_wiphy_get_channel, 2699 2558 };
+1 -1
net/mac80211/debugfs.c
··· 190 190 return -EFAULT; 191 191 buf[len] = '\0'; 192 192 193 - ret = strict_strtoul(buf, 0, &val); 193 + ret = kstrtoul(buf, 0, &val); 194 194 195 195 if (ret) 196 196 return -EINVAL;
+62 -6
net/mac80211/driver-ops.h
··· 5 5 #include "ieee80211_i.h" 6 6 #include "driver-trace.h" 7 7 8 + static inline void check_sdata_in_driver(struct ieee80211_sub_if_data *sdata) 9 + { 10 + WARN_ON(!(sdata->flags & IEEE80211_SDATA_IN_DRIVER)); 11 + } 12 + 8 13 static inline void drv_tx(struct ieee80211_local *local, struct sk_buff *skb) 9 14 { 10 15 local->ops->tx(&local->hw, skb); ··· 74 69 #endif 75 70 76 71 static inline int drv_add_interface(struct ieee80211_local *local, 77 - struct ieee80211_vif *vif) 72 + struct ieee80211_sub_if_data *sdata) 78 73 { 79 74 int ret; 80 75 81 76 might_sleep(); 82 77 83 - trace_drv_add_interface(local, vif_to_sdata(vif)); 84 - ret = local->ops->add_interface(&local->hw, vif); 78 + if (WARN_ON(sdata->vif.type == NL80211_IFTYPE_AP_VLAN || 79 + sdata->vif.type == NL80211_IFTYPE_MONITOR)) 80 + return -EINVAL; 81 + 82 + trace_drv_add_interface(local, sdata); 83 + ret = local->ops->add_interface(&local->hw, &sdata->vif); 85 84 trace_drv_return_int(local, ret); 85 + 86 + if (ret == 0) 87 + sdata->flags |= IEEE80211_SDATA_IN_DRIVER; 88 + 86 89 return ret; 87 90 } 88 91 ··· 102 89 103 90 might_sleep(); 104 91 92 + check_sdata_in_driver(sdata); 93 + 105 94 trace_drv_change_interface(local, sdata, type, p2p); 106 95 ret = local->ops->change_interface(&local->hw, &sdata->vif, type, p2p); 107 96 trace_drv_return_int(local, ret); ··· 111 96 } 112 97 113 98 static inline void drv_remove_interface(struct ieee80211_local *local, 114 - struct ieee80211_vif *vif) 99 + struct ieee80211_sub_if_data *sdata) 115 100 { 116 101 might_sleep(); 117 102 118 - trace_drv_remove_interface(local, vif_to_sdata(vif)); 119 - local->ops->remove_interface(&local->hw, vif); 103 + check_sdata_in_driver(sdata); 104 + 105 + trace_drv_remove_interface(local, sdata); 106 + local->ops->remove_interface(&local->hw, &sdata->vif); 107 + sdata->flags &= ~IEEE80211_SDATA_IN_DRIVER; 120 108 trace_drv_return_void(local); 121 109 } 122 110 ··· 142 124 { 143 125 might_sleep(); 144 126 127 + check_sdata_in_driver(sdata); 128 + 145 129 trace_drv_bss_info_changed(local, sdata, info, changed); 146 130 if (local->ops->bss_info_changed) 147 131 local->ops->bss_info_changed(&local->hw, &sdata->vif, info, changed); ··· 159 139 160 140 might_sleep(); 161 141 142 + check_sdata_in_driver(sdata); 143 + 162 144 trace_drv_tx_sync(local, sdata, bssid, type); 163 145 if (local->ops->tx_sync) 164 146 ret = local->ops->tx_sync(&local->hw, &sdata->vif, ··· 175 153 enum ieee80211_tx_sync_type type) 176 154 { 177 155 might_sleep(); 156 + 157 + check_sdata_in_driver(sdata); 178 158 179 159 trace_drv_finish_tx_sync(local, sdata, bssid, type); 180 160 if (local->ops->finish_tx_sync) ··· 235 211 236 212 might_sleep(); 237 213 214 + check_sdata_in_driver(sdata); 215 + 238 216 trace_drv_set_key(local, cmd, sdata, sta, key); 239 217 ret = local->ops->set_key(&local->hw, cmd, &sdata->vif, sta, key); 240 218 trace_drv_return_int(local, ret); ··· 254 228 if (sta) 255 229 ista = &sta->sta; 256 230 231 + check_sdata_in_driver(sdata); 232 + 257 233 trace_drv_update_tkip_key(local, sdata, conf, ista, iv32); 258 234 if (local->ops->update_tkip_key) 259 235 local->ops->update_tkip_key(&local->hw, &sdata->vif, conf, ··· 271 243 272 244 might_sleep(); 273 245 246 + check_sdata_in_driver(sdata); 247 + 274 248 trace_drv_hw_scan(local, sdata); 275 249 ret = local->ops->hw_scan(&local->hw, &sdata->vif, req); 276 250 trace_drv_return_int(local, ret); ··· 283 253 struct ieee80211_sub_if_data *sdata) 284 254 { 285 255 might_sleep(); 256 + 257 + check_sdata_in_driver(sdata); 286 258 287 259 trace_drv_cancel_hw_scan(local, sdata); 288 260 local->ops->cancel_hw_scan(&local->hw, &sdata->vif); ··· 301 269 302 270 might_sleep(); 303 271 272 + check_sdata_in_driver(sdata); 273 + 304 274 trace_drv_sched_scan_start(local, sdata); 305 275 ret = local->ops->sched_scan_start(&local->hw, &sdata->vif, 306 276 req, ies); ··· 314 280 struct ieee80211_sub_if_data *sdata) 315 281 { 316 282 might_sleep(); 283 + 284 + check_sdata_in_driver(sdata); 317 285 318 286 trace_drv_sched_scan_stop(local, sdata); 319 287 local->ops->sched_scan_stop(&local->hw, &sdata->vif); ··· 413 377 enum sta_notify_cmd cmd, 414 378 struct ieee80211_sta *sta) 415 379 { 380 + check_sdata_in_driver(sdata); 381 + 416 382 trace_drv_sta_notify(local, sdata, cmd, sta); 417 383 if (local->ops->sta_notify) 418 384 local->ops->sta_notify(&local->hw, &sdata->vif, cmd, sta); ··· 428 390 int ret = 0; 429 391 430 392 might_sleep(); 393 + 394 + check_sdata_in_driver(sdata); 431 395 432 396 trace_drv_sta_add(local, sdata, sta); 433 397 if (local->ops->sta_add) ··· 446 406 { 447 407 might_sleep(); 448 408 409 + check_sdata_in_driver(sdata); 410 + 449 411 trace_drv_sta_remove(local, sdata, sta); 450 412 if (local->ops->sta_remove) 451 413 local->ops->sta_remove(&local->hw, &sdata->vif, sta); ··· 462 420 int ret = -EOPNOTSUPP; 463 421 464 422 might_sleep(); 423 + 424 + check_sdata_in_driver(sdata); 465 425 466 426 trace_drv_conf_tx(local, sdata, queue, params); 467 427 if (local->ops->conf_tx) ··· 480 436 481 437 might_sleep(); 482 438 439 + check_sdata_in_driver(sdata); 440 + 483 441 trace_drv_get_tsf(local, sdata); 484 442 if (local->ops->get_tsf) 485 443 ret = local->ops->get_tsf(&local->hw, &sdata->vif); ··· 495 449 { 496 450 might_sleep(); 497 451 452 + check_sdata_in_driver(sdata); 453 + 498 454 trace_drv_set_tsf(local, sdata, tsf); 499 455 if (local->ops->set_tsf) 500 456 local->ops->set_tsf(&local->hw, &sdata->vif, tsf); ··· 507 459 struct ieee80211_sub_if_data *sdata) 508 460 { 509 461 might_sleep(); 462 + 463 + check_sdata_in_driver(sdata); 510 464 511 465 trace_drv_reset_tsf(local, sdata); 512 466 if (local->ops->reset_tsf) ··· 538 488 int ret = -EOPNOTSUPP; 539 489 540 490 might_sleep(); 491 + 492 + check_sdata_in_driver(sdata); 541 493 542 494 trace_drv_ampdu_action(local, sdata, action, sta, tid, ssn, buf_size); 543 495 ··· 696 644 697 645 might_sleep(); 698 646 647 + check_sdata_in_driver(sdata); 648 + 699 649 trace_drv_set_bitrate_mask(local, sdata, mask); 700 650 if (local->ops->set_bitrate_mask) 701 651 ret = local->ops->set_bitrate_mask(&local->hw, ··· 711 657 struct ieee80211_sub_if_data *sdata, 712 658 struct cfg80211_gtk_rekey_data *data) 713 659 { 660 + check_sdata_in_driver(sdata); 661 + 714 662 trace_drv_set_rekey_data(local, sdata, data); 715 663 if (local->ops->set_rekey_data) 716 664 local->ops->set_rekey_data(&local->hw, &sdata->vif, data);
+2 -1
net/mac80211/ht.c
··· 196 196 memcpy(mgmt->da, da, ETH_ALEN); 197 197 memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); 198 198 if (sdata->vif.type == NL80211_IFTYPE_AP || 199 - sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 199 + sdata->vif.type == NL80211_IFTYPE_AP_VLAN || 200 + sdata->vif.type == NL80211_IFTYPE_MESH_POINT) 200 201 memcpy(mgmt->bssid, sdata->vif.addr, ETH_ALEN); 201 202 else if (sdata->vif.type == NL80211_IFTYPE_STATION) 202 203 memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
+3
net/mac80211/ibss.c
··· 97 97 /* if merging, indicate to driver that we leave the old IBSS */ 98 98 if (sdata->vif.bss_conf.ibss_joined) { 99 99 sdata->vif.bss_conf.ibss_joined = false; 100 + netif_carrier_off(sdata->dev); 100 101 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IBSS); 101 102 } 102 103 ··· 208 207 bss = cfg80211_inform_bss_frame(local->hw.wiphy, local->hw.conf.channel, 209 208 mgmt, skb->len, 0, GFP_KERNEL); 210 209 cfg80211_put_bss(bss); 210 + netif_carrier_on(sdata->dev); 211 211 cfg80211_ibss_joined(sdata->dev, ifibss->bssid, GFP_KERNEL); 212 212 } 213 213 ··· 992 990 } 993 991 994 992 sta_info_flush(sdata->local, sdata); 993 + netif_carrier_off(sdata->dev); 995 994 996 995 /* remove beacon */ 997 996 kfree(sdata->u.ibss.ie);
+23 -6
net/mac80211/ieee80211_i.h
··· 24 24 #include <linux/spinlock.h> 25 25 #include <linux/etherdevice.h> 26 26 #include <linux/leds.h> 27 + #include <linux/idr.h> 27 28 #include <net/ieee80211_radiotap.h> 28 29 #include <net/cfg80211.h> 29 30 #include <net/mac80211.h> ··· 185 184 * enum ieee80211_rx_flags - RX data flags 186 185 * 187 186 * @IEEE80211_RX_CMNTR: received on cooked monitor already 187 + * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported 188 + * to cfg80211_report_obss_beacon(). 188 189 * 189 190 * These flags are used across handling multiple interfaces 190 191 * for a single frame. 191 192 */ 192 193 enum ieee80211_rx_flags { 193 194 IEEE80211_RX_CMNTR = BIT(0), 195 + IEEE80211_RX_BEACON_REPORTED = BIT(1), 194 196 }; 195 197 196 198 struct ieee80211_rx_data { ··· 232 228 233 229 struct ieee80211_if_ap { 234 230 struct beacon_data __rcu *beacon; 231 + struct sk_buff __rcu *probe_resp; 235 232 236 233 struct list_head vlans; 237 234 ··· 548 543 * associated stations and deliver multicast frames both 549 544 * back to wireless media and to the local net stack. 550 545 * @IEEE80211_SDATA_DISCONNECT_RESUME: Disconnect after resume. 546 + * @IEEE80211_SDATA_IN_DRIVER: indicates interface was added to driver 551 547 */ 552 548 enum ieee80211_sub_if_data_flags { 553 549 IEEE80211_SDATA_ALLMULTI = BIT(0), ··· 556 550 IEEE80211_SDATA_OPERATING_GMODE = BIT(2), 557 551 IEEE80211_SDATA_DONT_BRIDGE_PACKETS = BIT(3), 558 552 IEEE80211_SDATA_DISCONNECT_RESUME = BIT(4), 553 + IEEE80211_SDATA_IN_DRIVER = BIT(5), 559 554 }; 560 555 561 556 /** ··· 729 722 * operating channel 730 723 * @SCAN_SET_CHANNEL: Set the next channel to be scanned 731 724 * @SCAN_SEND_PROBE: Send probe requests and wait for probe responses 732 - * @SCAN_LEAVE_OPER_CHANNEL: Leave the operating channel, notify the AP 733 - * about us leaving the channel and stop all associated STA interfaces 734 - * @SCAN_ENTER_OPER_CHANNEL: Enter the operating channel again, notify the 735 - * AP about us being back and restart all associated STA interfaces 725 + * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to 726 + * send out data 727 + * @SCAN_RESUME: Resume the scan and scan the next channel 736 728 */ 737 729 enum mac80211_scan_state { 738 730 SCAN_DECISION, 739 731 SCAN_SET_CHANNEL, 740 732 SCAN_SEND_PROBE, 741 - SCAN_LEAVE_OPER_CHANNEL, 742 - SCAN_ENTER_OPER_CHANNEL, 733 + SCAN_SUSPEND, 734 + SCAN_RESUME, 743 735 }; 744 736 745 737 struct ieee80211_local { ··· 1017 1011 unsigned int hw_roc_duration; 1018 1012 u32 hw_roc_cookie; 1019 1013 bool hw_roc_for_tx; 1014 + 1015 + struct idr ack_status_frames; 1016 + spinlock_t ack_status_lock; 1020 1017 1021 1018 /* dummy netdev for use w/ NAPI */ 1022 1019 struct net_device napi_dev; ··· 1343 1334 size_t ieee80211_ie_split(const u8 *ies, size_t ielen, 1344 1335 const u8 *ids, int n_ids, size_t offset); 1345 1336 size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset); 1337 + u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_supported_band *sband, 1338 + u16 cap); 1339 + u8 *ieee80211_ie_build_ht_info(u8 *pos, 1340 + struct ieee80211_sta_ht_cap *ht_cap, 1341 + struct ieee80211_channel *channel, 1342 + enum nl80211_channel_type channel_type); 1346 1343 1347 1344 /* internal work items */ 1348 1345 void ieee80211_work_init(struct ieee80211_local *local); ··· 1377 1362 bool ieee80211_set_channel_type(struct ieee80211_local *local, 1378 1363 struct ieee80211_sub_if_data *sdata, 1379 1364 enum nl80211_channel_type chantype); 1365 + enum nl80211_channel_type 1366 + ieee80211_ht_info_to_channel_type(struct ieee80211_ht_info *ht_info); 1380 1367 1381 1368 #ifdef CONFIG_MAC80211_NOINLINE 1382 1369 #define debug_noinline noinline
+30 -14
net/mac80211/iface.c
··· 188 188 if (!is_valid_ether_addr(sdata->u.wds.remote_addr)) 189 189 return -ENOLINK; 190 190 break; 191 - case NL80211_IFTYPE_AP_VLAN: 191 + case NL80211_IFTYPE_AP_VLAN: { 192 + struct ieee80211_sub_if_data *master; 193 + 192 194 if (!sdata->bss) 193 195 return -ENOLINK; 196 + 194 197 list_add(&sdata->u.vlan.list, &sdata->bss->vlans); 198 + 199 + master = container_of(sdata->bss, 200 + struct ieee80211_sub_if_data, u.ap); 201 + sdata->control_port_protocol = 202 + master->control_port_protocol; 203 + sdata->control_port_no_encrypt = 204 + master->control_port_no_encrypt; 195 205 break; 206 + } 196 207 case NL80211_IFTYPE_AP: 197 208 sdata->bss = &sdata->u.ap; 198 209 break; ··· 276 265 break; 277 266 default: 278 267 if (coming_up) { 279 - res = drv_add_interface(local, &sdata->vif); 268 + res = drv_add_interface(local, sdata); 280 269 if (res) 281 270 goto err_stop; 282 271 } ··· 293 282 changed |= ieee80211_reset_erp_info(sdata); 294 283 ieee80211_bss_info_change_notify(sdata, changed); 295 284 296 - if (sdata->vif.type == NL80211_IFTYPE_STATION) 285 + if (sdata->vif.type == NL80211_IFTYPE_STATION || 286 + sdata->vif.type == NL80211_IFTYPE_ADHOC) 297 287 netif_carrier_off(dev); 298 288 else 299 289 netif_carrier_on(dev); 290 + 291 + /* 292 + * set default queue parameters so drivers don't 293 + * need to initialise the hardware if the hardware 294 + * doesn't start up with sane defaults 295 + */ 296 + ieee80211_set_wmm_default(sdata); 300 297 } 301 298 302 299 set_bit(SDATA_STATE_RUNNING, &sdata->state); ··· 348 329 if (coming_up) 349 330 local->open_count++; 350 331 351 - if (hw_reconf_flags) { 332 + if (hw_reconf_flags) 352 333 ieee80211_hw_config(local, hw_reconf_flags); 353 - /* 354 - * set default queue parameters so drivers don't 355 - * need to initialise the hardware if the hardware 356 - * doesn't start up with sane defaults 357 - */ 358 - ieee80211_set_wmm_default(sdata); 359 - } 360 334 361 335 ieee80211_recalc_ps(local, -1); 362 336 ··· 357 345 358 346 return 0; 359 347 err_del_interface: 360 - drv_remove_interface(local, &sdata->vif); 348 + drv_remove_interface(local, sdata); 361 349 err_stop: 362 350 if (!local->open_count) 363 351 drv_stop(local); ··· 462 450 struct ieee80211_sub_if_data *vlan, *tmpsdata; 463 451 struct beacon_data *old_beacon = 464 452 rtnl_dereference(sdata->u.ap.beacon); 453 + struct sk_buff *old_probe_resp = 454 + rtnl_dereference(sdata->u.ap.probe_resp); 465 455 466 456 /* sdata_running will return false, so this will disable */ 467 457 ieee80211_bss_info_change_notify(sdata, 468 458 BSS_CHANGED_BEACON_ENABLED); 469 459 470 - /* remove beacon */ 460 + /* remove beacon and probe response */ 471 461 RCU_INIT_POINTER(sdata->u.ap.beacon, NULL); 462 + RCU_INIT_POINTER(sdata->u.ap.probe_resp, NULL); 472 463 synchronize_rcu(); 473 464 kfree(old_beacon); 465 + kfree(old_probe_resp); 474 466 475 467 /* down all dependent devices, that is VLANs */ 476 468 list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, ··· 536 520 ieee80211_free_keys(sdata); 537 521 538 522 if (going_down) 539 - drv_remove_interface(local, &sdata->vif); 523 + drv_remove_interface(local, sdata); 540 524 } 541 525 542 526 sdata->bss = NULL;
+7 -2
net/mac80211/key.c
··· 134 134 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; 135 135 136 136 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || 137 - (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))) 137 + (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) || 138 + (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE))) 138 139 sdata->crypto_tx_tailroom_needed_cnt--; 140 + 141 + WARN_ON((key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE) && 142 + (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV)); 139 143 140 144 return 0; 141 145 } ··· 183 179 sdata = key->sdata; 184 180 185 181 if (!((key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_MMIC) || 186 - (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV))) 182 + (key->conf.flags & IEEE80211_KEY_FLAG_GENERATE_IV) || 183 + (key->conf.flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE))) 187 184 increment_tailroom_need_count(sdata); 188 185 189 186 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
+28 -11
net/mac80211/main.c
··· 100 100 */ 101 101 bool ieee80211_cfg_on_oper_channel(struct ieee80211_local *local) 102 102 { 103 - struct ieee80211_channel *chan, *scan_chan; 103 + struct ieee80211_channel *chan; 104 104 enum nl80211_channel_type channel_type; 105 105 106 106 /* This logic needs to match logic in ieee80211_hw_config */ ··· 114 114 else 115 115 channel_type = NL80211_CHAN_NO_HT; 116 116 } else if (local->tmp_channel) { 117 - chan = scan_chan = local->tmp_channel; 117 + chan = local->tmp_channel; 118 118 channel_type = local->tmp_channel_type; 119 119 } else { 120 120 chan = local->oper_channel; ··· 126 126 return false; 127 127 128 128 /* Check current hardware-config against oper_channel. */ 129 - if ((local->oper_channel != local->hw.conf.channel) || 130 - (local->_oper_channel_type != local->hw.conf.channel_type)) 129 + if (local->oper_channel != local->hw.conf.channel || 130 + local->_oper_channel_type != local->hw.conf.channel_type) 131 131 return false; 132 132 133 133 return true; ··· 135 135 136 136 int ieee80211_hw_config(struct ieee80211_local *local, u32 changed) 137 137 { 138 - struct ieee80211_channel *chan, *scan_chan; 138 + struct ieee80211_channel *chan; 139 139 int ret = 0; 140 140 int power; 141 141 enum nl80211_channel_type channel_type; ··· 143 143 144 144 might_sleep(); 145 145 146 - scan_chan = local->scan_channel; 147 - 148 146 /* If this off-channel logic ever changes, ieee80211_on_oper_channel 149 147 * may need to change as well. 150 148 */ 151 149 offchannel_flag = local->hw.conf.flags & IEEE80211_CONF_OFFCHANNEL; 152 - if (scan_chan) { 153 - chan = scan_chan; 150 + if (local->scan_channel) { 151 + chan = local->scan_channel; 154 152 /* If scanning on oper channel, use whatever channel-type 155 153 * is currently in use. 156 154 */ ··· 157 159 else 158 160 channel_type = NL80211_CHAN_NO_HT; 159 161 } else if (local->tmp_channel) { 160 - chan = scan_chan = local->tmp_channel; 162 + chan = local->tmp_channel; 161 163 channel_type = local->tmp_channel_type; 162 164 } else { 163 165 chan = local->oper_channel; ··· 593 595 594 596 wiphy->flags |= WIPHY_FLAG_NETNS_OK | 595 597 WIPHY_FLAG_4ADDR_AP | 596 - WIPHY_FLAG_4ADDR_STATION; 598 + WIPHY_FLAG_4ADDR_STATION | 599 + WIPHY_FLAG_REPORTS_OBSS; 600 + 601 + wiphy->features = NL80211_FEATURE_SK_TX_STATUS; 597 602 598 603 if (!ops->set_key) 599 604 wiphy->flags |= WIPHY_FLAG_IBSS_RSN; ··· 670 669 671 670 INIT_WORK(&local->sched_scan_stopped_work, 672 671 ieee80211_sched_scan_stopped_work); 672 + 673 + spin_lock_init(&local->ack_status_lock); 674 + idr_init(&local->ack_status_frames); 675 + /* preallocate at least one entry */ 676 + idr_pre_get(&local->ack_status_frames, GFP_KERNEL); 673 677 674 678 sta_info_init(local); 675 679 ··· 1051 1045 } 1052 1046 EXPORT_SYMBOL(ieee80211_unregister_hw); 1053 1047 1048 + static int ieee80211_free_ack_frame(int id, void *p, void *data) 1049 + { 1050 + WARN_ONCE(1, "Have pending ack frames!\n"); 1051 + kfree_skb(p); 1052 + return 0; 1053 + } 1054 + 1054 1055 void ieee80211_free_hw(struct ieee80211_hw *hw) 1055 1056 { 1056 1057 struct ieee80211_local *local = hw_to_local(hw); ··· 1067 1054 1068 1055 if (local->wiphy_ciphers_allocated) 1069 1056 kfree(local->hw.wiphy->cipher_suites); 1057 + 1058 + idr_for_each(&local->ack_status_frames, 1059 + ieee80211_free_ack_frame, NULL); 1060 + idr_destroy(&local->ack_status_frames); 1070 1061 1071 1062 wiphy_free(local->hw.wiphy); 1072 1063 }
+60 -8
net/mac80211/mesh.c
··· 76 76 bool mesh_matches_local(struct ieee802_11_elems *ie, struct ieee80211_sub_if_data *sdata) 77 77 { 78 78 struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh; 79 + struct ieee80211_local *local = sdata->local; 79 80 80 81 /* 81 82 * As support for each feature is added, check for matching ··· 88 87 * - MDA enabled 89 88 * - Power management control on fc 90 89 */ 91 - if (ifmsh->mesh_id_len == ie->mesh_id_len && 92 - memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 && 93 - (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) && 94 - (ifmsh->mesh_pm_id == ie->mesh_config->meshconf_pmetric) && 95 - (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) && 96 - (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) && 97 - (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth)) 98 - return true; 90 + if (!(ifmsh->mesh_id_len == ie->mesh_id_len && 91 + memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 && 92 + (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) && 93 + (ifmsh->mesh_pm_id == ie->mesh_config->meshconf_pmetric) && 94 + (ifmsh->mesh_cc_id == ie->mesh_config->meshconf_congest) && 95 + (ifmsh->mesh_sp_id == ie->mesh_config->meshconf_synch) && 96 + (ifmsh->mesh_auth_id == ie->mesh_config->meshconf_auth))) 97 + goto mismatch; 99 98 99 + /* disallow peering with mismatched channel types for now */ 100 + if (ie->ht_info_elem && 101 + (local->_oper_channel_type != 102 + ieee80211_ht_info_to_channel_type(ie->ht_info_elem))) 103 + goto mismatch; 104 + 105 + return true; 106 + mismatch: 100 107 return false; 101 108 } 102 109 ··· 350 341 return 0; 351 342 } 352 343 344 + int mesh_add_ht_cap_ie(struct sk_buff *skb, 345 + struct ieee80211_sub_if_data *sdata) 346 + { 347 + struct ieee80211_local *local = sdata->local; 348 + struct ieee80211_supported_band *sband; 349 + u8 *pos; 350 + 351 + sband = local->hw.wiphy->bands[local->oper_channel->band]; 352 + if (!sband->ht_cap.ht_supported || 353 + local->_oper_channel_type == NL80211_CHAN_NO_HT) 354 + return 0; 355 + 356 + if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_cap)) 357 + return -ENOMEM; 358 + 359 + pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_cap)); 360 + ieee80211_ie_build_ht_cap(pos, sband, sband->ht_cap.cap); 361 + 362 + return 0; 363 + } 364 + 365 + int mesh_add_ht_info_ie(struct sk_buff *skb, 366 + struct ieee80211_sub_if_data *sdata) 367 + { 368 + struct ieee80211_local *local = sdata->local; 369 + struct ieee80211_channel *channel = local->oper_channel; 370 + enum nl80211_channel_type channel_type = local->_oper_channel_type; 371 + struct ieee80211_supported_band *sband = 372 + local->hw.wiphy->bands[channel->band]; 373 + struct ieee80211_sta_ht_cap *ht_cap = &sband->ht_cap; 374 + u8 *pos; 375 + 376 + if (!ht_cap->ht_supported || channel_type == NL80211_CHAN_NO_HT) 377 + return 0; 378 + 379 + if (skb_tailroom(skb) < 2 + sizeof(struct ieee80211_ht_info)) 380 + return -ENOMEM; 381 + 382 + pos = skb_put(skb, 2 + sizeof(struct ieee80211_ht_info)); 383 + ieee80211_ie_build_ht_info(pos, ht_cap, channel, channel_type); 384 + 385 + return 0; 386 + } 353 387 static void ieee80211_mesh_path_timer(unsigned long data) 354 388 { 355 389 struct ieee80211_sub_if_data *sdata =
+7
net/mac80211/mesh.h
··· 31 31 * @MESH_PATH_FIXED: the mesh path has been manually set and should not be 32 32 * modified 33 33 * @MESH_PATH_RESOLVED: the mesh path can has been resolved 34 + * @MESH_PATH_REQ_QUEUED: there is an unsent path request for this destination 35 + * already queued up, waiting for the discovery process to start. 34 36 * 35 37 * MESH_PATH_RESOLVED is used by the mesh path timer to 36 38 * decide when to stop or cancel the mesh path discovery. ··· 43 41 MESH_PATH_SN_VALID = BIT(2), 44 42 MESH_PATH_FIXED = BIT(3), 45 43 MESH_PATH_RESOLVED = BIT(4), 44 + MESH_PATH_REQ_QUEUED = BIT(5), 46 45 }; 47 46 48 47 /** ··· 215 212 struct ieee80211_sub_if_data *sdata); 216 213 int mesh_add_ds_params_ie(struct sk_buff *skb, 217 214 struct ieee80211_sub_if_data *sdata); 215 + int mesh_add_ht_cap_ie(struct sk_buff *skb, 216 + struct ieee80211_sub_if_data *sdata); 217 + int mesh_add_ht_info_ie(struct sk_buff *skb, 218 + struct ieee80211_sub_if_data *sdata); 218 219 void mesh_rmc_free(struct ieee80211_sub_if_data *sdata); 219 220 int mesh_rmc_init(struct ieee80211_sub_if_data *sdata); 220 221 void ieee80211s_init(void);
+32 -20
net/mac80211/mesh_hwmp.c
··· 113 113 struct ieee80211_sub_if_data *sdata) 114 114 { 115 115 struct ieee80211_local *local = sdata->local; 116 - struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); 116 + struct sk_buff *skb; 117 117 struct ieee80211_mgmt *mgmt; 118 - u8 *pos; 119 - int ie_len; 118 + u8 *pos, ie_len; 119 + int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.mesh_action) + 120 + sizeof(mgmt->u.action.u.mesh_action); 120 121 122 + skb = dev_alloc_skb(local->hw.extra_tx_headroom + 123 + hdr_len + 124 + 2 + 37); /* max HWMP IE */ 121 125 if (!skb) 122 126 return -1; 123 127 skb_reserve(skb, local->hw.extra_tx_headroom); 124 - /* 25 is the size of the common mgmt part (24) plus the size of the 125 - * common action part (1) 126 - */ 127 - mgmt = (struct ieee80211_mgmt *) 128 - skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action)); 129 - memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action)); 128 + mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len); 129 + memset(mgmt, 0, hdr_len); 130 130 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 131 131 IEEE80211_STYPE_ACTION); 132 132 ··· 240 240 struct ieee80211_sub_if_data *sdata) 241 241 { 242 242 struct ieee80211_local *local = sdata->local; 243 - struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); 243 + struct sk_buff *skb; 244 244 struct ieee80211_mgmt *mgmt; 245 - u8 *pos; 246 - int ie_len; 245 + u8 *pos, ie_len; 246 + int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.mesh_action) + 247 + sizeof(mgmt->u.action.u.mesh_action); 247 248 249 + skb = dev_alloc_skb(local->hw.extra_tx_headroom + 250 + hdr_len + 251 + 2 + 15 /* PERR IE */); 248 252 if (!skb) 249 253 return -1; 250 254 skb_reserve(skb, local->tx_headroom + local->hw.extra_tx_headroom); 251 - /* 25 is the size of the common mgmt part (24) plus the size of the 252 - * common action part (1) 253 - */ 254 - mgmt = (struct ieee80211_mgmt *) 255 - skb_put(skb, 25 + sizeof(mgmt->u.action.u.mesh_action)); 256 - memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.mesh_action)); 255 + mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len); 256 + memset(mgmt, 0, hdr_len); 257 257 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 258 258 IEEE80211_STYPE_ACTION); 259 259 ··· 867 867 return; 868 868 } 869 869 870 + spin_lock_bh(&mpath->state_lock); 871 + if (mpath->flags & MESH_PATH_REQ_QUEUED) { 872 + spin_unlock_bh(&mpath->state_lock); 873 + spin_unlock_bh(&ifmsh->mesh_preq_queue_lock); 874 + return; 875 + } 876 + 870 877 memcpy(preq_node->dst, mpath->dst, ETH_ALEN); 871 878 preq_node->flags = flags; 879 + 880 + mpath->flags |= MESH_PATH_REQ_QUEUED; 881 + spin_unlock_bh(&mpath->state_lock); 872 882 873 883 list_add_tail(&preq_node->list, &ifmsh->preq_queue.list); 874 884 ++ifmsh->preq_queue_len; ··· 931 921 goto enddiscovery; 932 922 933 923 spin_lock_bh(&mpath->state_lock); 924 + mpath->flags &= ~MESH_PATH_REQ_QUEUED; 934 925 if (preq_node->flags & PREQ_Q_F_START) { 935 926 if (mpath->flags & MESH_PATH_RESOLVING) { 936 927 spin_unlock_bh(&mpath->state_lock); ··· 1039 1028 mesh_queue_preq(mpath, PREQ_Q_F_START); 1040 1029 } 1041 1030 1042 - if (skb_queue_len(&mpath->frame_queue) >= 1043 - MESH_FRAME_QUEUE_LEN) 1031 + if (skb_queue_len(&mpath->frame_queue) >= MESH_FRAME_QUEUE_LEN) 1044 1032 skb_to_free = skb_dequeue(&mpath->frame_queue); 1045 1033 1046 1034 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; 1035 + ieee80211_set_qos_hdr(sdata, skb); 1047 1036 skb_queue_tail(&mpath->frame_queue, skb); 1048 1037 if (skb_to_free) 1049 1038 mesh_path_discard_frame(skb_to_free, sdata); ··· 1072 1061 } else if (mpath->discovery_retries < max_preq_retries(sdata)) { 1073 1062 ++mpath->discovery_retries; 1074 1063 mpath->discovery_timeout *= 2; 1064 + mpath->flags &= ~MESH_PATH_REQ_QUEUED; 1075 1065 spin_unlock_bh(&mpath->state_lock); 1076 1066 mesh_queue_preq(mpath, 0); 1077 1067 } else {
-3
net/mac80211/mesh_pathtbl.c
··· 213 213 struct ieee80211_hdr *hdr; 214 214 struct sk_buff_head tmpq; 215 215 unsigned long flags; 216 - struct ieee80211_sub_if_data *sdata = mpath->sdata; 217 216 218 217 rcu_assign_pointer(mpath->next_hop, sta); 219 218 ··· 223 224 while ((skb = __skb_dequeue(&mpath->frame_queue)) != NULL) { 224 225 hdr = (struct ieee80211_hdr *) skb->data; 225 226 memcpy(hdr->addr1, sta->sta.addr, ETH_ALEN); 226 - skb_set_queue_mapping(skb, ieee80211_select_queue(sdata, skb)); 227 - ieee80211_set_qos_hdr(sdata, skb); 228 227 __skb_queue_tail(&tmpq, skb); 229 228 } 230 229
+35 -13
net/mac80211/mesh_plink.c
··· 80 80 * on it in the lifecycle management section! 81 81 */ 82 82 static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata, 83 - u8 *hw_addr, u32 rates) 83 + u8 *hw_addr, u32 rates, 84 + struct ieee802_11_elems *elems) 84 85 { 85 86 struct ieee80211_local *local = sdata->local; 87 + struct ieee80211_supported_band *sband; 86 88 struct sta_info *sta; 89 + 90 + sband = local->hw.wiphy->bands[local->oper_channel->band]; 87 91 88 92 if (local->num_sta >= MESH_MAX_PLINKS) 89 93 return NULL; ··· 100 96 set_sta_flag(sta, WLAN_STA_AUTHORIZED); 101 97 set_sta_flag(sta, WLAN_STA_WME); 102 98 sta->sta.supp_rates[local->hw.conf.channel->band] = rates; 99 + if (elems->ht_cap_elem) 100 + ieee80211_ht_cap_ie_to_sta_ht_cap(sband, elems->ht_cap_elem, 101 + &sta->sta.ht_cap); 103 102 rate_control_rate_init(sta); 104 103 105 104 return sta; ··· 160 153 enum ieee80211_self_protected_actioncode action, 161 154 u8 *da, __le16 llid, __le16 plid, __le16 reason) { 162 155 struct ieee80211_local *local = sdata->local; 163 - struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400 + 164 - sdata->u.mesh.ie_len); 156 + struct sk_buff *skb; 165 157 struct ieee80211_mgmt *mgmt; 166 158 bool include_plid = false; 167 - int ie_len = 4; 168 159 u16 peering_proto = 0; 169 - u8 *pos; 160 + u8 *pos, ie_len = 4; 161 + int hdr_len = offsetof(struct ieee80211_mgmt, u.action.u.self_prot) + 162 + sizeof(mgmt->u.action.u.self_prot); 170 163 164 + skb = dev_alloc_skb(local->hw.extra_tx_headroom + 165 + hdr_len + 166 + 2 + /* capability info */ 167 + 2 + /* AID */ 168 + 2 + 8 + /* supported rates */ 169 + 2 + (IEEE80211_MAX_SUPP_RATES - 8) + 170 + 2 + sdata->u.mesh.mesh_id_len + 171 + 2 + sizeof(struct ieee80211_meshconf_ie) + 172 + 2 + sizeof(struct ieee80211_ht_cap) + 173 + 2 + sizeof(struct ieee80211_ht_info) + 174 + 2 + 8 + /* peering IE */ 175 + sdata->u.mesh.ie_len); 171 176 if (!skb) 172 177 return -1; 173 178 skb_reserve(skb, local->hw.extra_tx_headroom); 174 - /* 25 is the size of the common mgmt part (24) plus the size of the 175 - * common action part (1) 176 - */ 177 - mgmt = (struct ieee80211_mgmt *) 178 - skb_put(skb, 25 + sizeof(mgmt->u.action.u.self_prot)); 179 - memset(mgmt, 0, 25 + sizeof(mgmt->u.action.u.self_prot)); 179 + mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len); 180 + memset(mgmt, 0, hdr_len); 180 181 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 181 182 IEEE80211_STYPE_ACTION); 182 183 memcpy(mgmt->da, da, ETH_ALEN); ··· 250 235 memcpy(pos, &reason, 2); 251 236 pos += 2; 252 237 } 238 + 239 + if (action != WLAN_SP_MESH_PEERING_CLOSE) { 240 + if (mesh_add_ht_cap_ie(skb, sdata) || 241 + mesh_add_ht_info_ie(skb, sdata)) 242 + return -1; 243 + } 244 + 253 245 if (mesh_add_vendor_ies(skb, sdata)) 254 246 return -1; 255 247 ··· 283 261 elems->ie_start, elems->total_len, 284 262 GFP_KERNEL); 285 263 else 286 - sta = mesh_plink_alloc(sdata, hw_addr, rates); 264 + sta = mesh_plink_alloc(sdata, hw_addr, rates, elems); 287 265 if (!sta) 288 266 return; 289 267 if (sta_info_insert_rcu(sta)) { ··· 574 552 } 575 553 576 554 rates = ieee80211_sta_get_rates(local, &elems, rx_status->band); 577 - sta = mesh_plink_alloc(sdata, mgmt->sa, rates); 555 + sta = mesh_plink_alloc(sdata, mgmt->sa, rates, &elems); 578 556 if (!sta) { 579 557 mpl_dbg("Mesh plink error: plink table full\n"); 580 558 return;
+58 -31
net/mac80211/mlme.c
··· 1468 1468 return RX_MGMT_CFG80211_DISASSOC; 1469 1469 } 1470 1470 1471 + static void ieee80211_get_rates(struct ieee80211_supported_band *sband, 1472 + u8 *supp_rates, unsigned int supp_rates_len, 1473 + u32 *rates, u32 *basic_rates, 1474 + bool *have_higher_than_11mbit, 1475 + int *min_rate, int *min_rate_index) 1476 + { 1477 + int i, j; 1478 + 1479 + for (i = 0; i < supp_rates_len; i++) { 1480 + int rate = (supp_rates[i] & 0x7f) * 5; 1481 + bool is_basic = !!(supp_rates[i] & 0x80); 1482 + 1483 + if (rate > 110) 1484 + *have_higher_than_11mbit = true; 1485 + 1486 + /* 1487 + * BSS_MEMBERSHIP_SELECTOR_HT_PHY is defined in 802.11n-2009 1488 + * 7.3.2.2 as a magic value instead of a rate. Hence, skip it. 1489 + * 1490 + * Note: Even through the membership selector and the basic 1491 + * rate flag share the same bit, they are not exactly 1492 + * the same. 1493 + */ 1494 + if (!!(supp_rates[i] & 0x80) && 1495 + (supp_rates[i] & 0x7f) == BSS_MEMBERSHIP_SELECTOR_HT_PHY) 1496 + continue; 1497 + 1498 + for (j = 0; j < sband->n_bitrates; j++) { 1499 + if (sband->bitrates[j].bitrate == rate) { 1500 + *rates |= BIT(j); 1501 + if (is_basic) 1502 + *basic_rates |= BIT(j); 1503 + if (rate < *min_rate) { 1504 + *min_rate = rate; 1505 + *min_rate_index = j; 1506 + } 1507 + break; 1508 + } 1509 + } 1510 + } 1511 + } 1471 1512 1472 1513 static bool ieee80211_assoc_success(struct ieee80211_work *wk, 1473 1514 struct ieee80211_mgmt *mgmt, size_t len) ··· 1525 1484 struct ieee802_11_elems elems; 1526 1485 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; 1527 1486 u32 changed = 0; 1528 - int i, j, err; 1487 + int err; 1529 1488 bool have_higher_than_11mbit = false; 1530 1489 u16 ap_ht_cap_flags; 1490 + int min_rate = INT_MAX, min_rate_index = -1; 1531 1491 1532 1492 /* AssocResp and ReassocResp have identical structure */ 1533 1493 ··· 1583 1541 basic_rates = 0; 1584 1542 sband = local->hw.wiphy->bands[wk->chan->band]; 1585 1543 1586 - for (i = 0; i < elems.supp_rates_len; i++) { 1587 - int rate = (elems.supp_rates[i] & 0x7f) * 5; 1588 - bool is_basic = !!(elems.supp_rates[i] & 0x80); 1544 + ieee80211_get_rates(sband, elems.supp_rates, elems.supp_rates_len, 1545 + &rates, &basic_rates, &have_higher_than_11mbit, 1546 + &min_rate, &min_rate_index); 1589 1547 1590 - if (rate > 110) 1591 - have_higher_than_11mbit = true; 1548 + ieee80211_get_rates(sband, elems.ext_supp_rates, 1549 + elems.ext_supp_rates_len, &rates, &basic_rates, 1550 + &have_higher_than_11mbit, 1551 + &min_rate, &min_rate_index); 1592 1552 1593 - for (j = 0; j < sband->n_bitrates; j++) { 1594 - if (sband->bitrates[j].bitrate == rate) { 1595 - rates |= BIT(j); 1596 - if (is_basic) 1597 - basic_rates |= BIT(j); 1598 - break; 1599 - } 1600 - } 1601 - } 1602 - 1603 - for (i = 0; i < elems.ext_supp_rates_len; i++) { 1604 - int rate = (elems.ext_supp_rates[i] & 0x7f) * 5; 1605 - bool is_basic = !!(elems.ext_supp_rates[i] & 0x80); 1606 - 1607 - if (rate > 110) 1608 - have_higher_than_11mbit = true; 1609 - 1610 - for (j = 0; j < sband->n_bitrates; j++) { 1611 - if (sband->bitrates[j].bitrate == rate) { 1612 - rates |= BIT(j); 1613 - if (is_basic) 1614 - basic_rates |= BIT(j); 1615 - break; 1616 - } 1617 - } 1553 + /* 1554 + * some buggy APs don't advertise basic_rates. use the lowest 1555 + * supported rate instead. 1556 + */ 1557 + if (unlikely(!basic_rates) && min_rate_index >= 0) { 1558 + printk(KERN_DEBUG "%s: No basic rates in AssocResp. " 1559 + "Using min supported rate instead.\n", sdata->name); 1560 + basic_rates = BIT(min_rate_index); 1618 1561 } 1619 1562 1620 1563 sta->sta.supp_rates[wk->chan->band] = rates;
+1 -1
net/mac80211/pm.c
··· 125 125 ieee80211_bss_info_change_notify(sdata, 126 126 BSS_CHANGED_BEACON_ENABLED); 127 127 128 - drv_remove_interface(local, &sdata->vif); 128 + drv_remove_interface(local, sdata); 129 129 } 130 130 131 131 /* stop hardware - this must stop RX */
+3 -4
net/mac80211/rc80211_minstrel.c
··· 334 334 335 335 336 336 static void 337 - calc_rate_durations(struct minstrel_sta_info *mi, struct ieee80211_local *local, 338 - struct minstrel_rate *d, struct ieee80211_rate *rate) 337 + calc_rate_durations(struct ieee80211_local *local, struct minstrel_rate *d, 338 + struct ieee80211_rate *rate) 339 339 { 340 340 int erp = !!(rate->flags & IEEE80211_RATE_ERP_G); 341 341 ··· 402 402 403 403 mr->rix = i; 404 404 mr->bitrate = sband->bitrates[i].bitrate / 5; 405 - calc_rate_durations(mi, local, mr, 406 - &sband->bitrates[i]); 405 + calc_rate_durations(local, mr, &sband->bitrates[i]); 407 406 408 407 /* calculate maximum number of retransmissions before 409 408 * fallback (based on maximum segment size) */
+56 -17
net/mac80211/rx.c
··· 745 745 struct ieee80211_local *local = rx->local; 746 746 struct ieee80211_hw *hw = &local->hw; 747 747 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 748 + struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); 748 749 struct sta_info *sta = rx->sta; 749 750 struct tid_ampdu_rx *tid_agg_rx; 750 751 u16 sc; 751 - int tid; 752 + u8 tid, ack_policy; 752 753 753 754 if (!ieee80211_is_data_qos(hdr->frame_control)) 754 755 goto dont_reorder; ··· 762 761 if (!sta) 763 762 goto dont_reorder; 764 763 764 + ack_policy = *ieee80211_get_qos_ctl(hdr) & 765 + IEEE80211_QOS_CTL_ACK_POLICY_MASK; 765 766 tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK; 766 767 767 768 tid_agg_rx = rcu_dereference(sta->ampdu_mlme.tid_rx[tid]); ··· 772 769 773 770 /* qos null data frames are excluded */ 774 771 if (unlikely(hdr->frame_control & cpu_to_le16(IEEE80211_STYPE_NULLFUNC))) 772 + goto dont_reorder; 773 + 774 + /* not part of a BA session */ 775 + if (ack_policy != IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK && 776 + ack_policy != IEEE80211_QOS_CTL_ACK_POLICY_NORMAL) 777 + goto dont_reorder; 778 + 779 + /* not actually part of this BA session */ 780 + if (!(status->rx_flags & IEEE80211_RX_RA_MATCH)) 775 781 goto dont_reorder; 776 782 777 783 /* new, potentially un-ordered, ampdu frame - process it */ ··· 867 855 rx->sdata->control_port_protocol) 868 856 return RX_CONTINUE; 869 857 } 858 + 859 + if (rx->sdata->vif.type == NL80211_IFTYPE_AP && 860 + cfg80211_rx_spurious_frame(rx->sdata->dev, 861 + hdr->addr2, 862 + GFP_ATOMIC)) 863 + return RX_DROP_UNUSABLE; 864 + 870 865 return RX_DROP_MONITOR; 871 866 } 872 867 ··· 1343 1324 1344 1325 /* 1345 1326 * If we receive a 4-addr nullfunc frame from a STA 1346 - * that was not moved to a 4-addr STA vlan yet, drop 1347 - * the frame to the monitor interface, to make sure 1348 - * that hostapd sees it 1327 + * that was not moved to a 4-addr STA vlan yet send 1328 + * the event to userspace and for older hostapd drop 1329 + * the frame to the monitor interface. 1349 1330 */ 1350 1331 if (ieee80211_has_a4(hdr->frame_control) && 1351 1332 (rx->sdata->vif.type == NL80211_IFTYPE_AP || 1352 1333 (rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN && 1353 - !rx->sdata->u.vlan.sta))) 1334 + !rx->sdata->u.vlan.sta))) { 1335 + if (!test_and_set_sta_flag(sta, WLAN_STA_4ADDR_EVENT)) 1336 + cfg80211_rx_unexpected_4addr_frame( 1337 + rx->sdata->dev, sta->sta.addr, 1338 + GFP_ATOMIC); 1354 1339 return RX_DROP_MONITOR; 1340 + } 1355 1341 /* 1356 1342 * Update counter and free packet here to avoid 1357 1343 * counting this as a dropped packed. ··· 1954 1930 compare_ether_addr(sdata->vif.addr, hdr->addr3) == 0) 1955 1931 return RX_CONTINUE; 1956 1932 1933 + skb_set_queue_mapping(skb, ieee80211_select_queue(sdata, skb)); 1957 1934 mesh_hdr->ttl--; 1958 1935 1959 1936 if (status->rx_flags & IEEE80211_RX_RA_MATCH) { ··· 1979 1954 memset(info, 0, sizeof(*info)); 1980 1955 info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING; 1981 1956 info->control.vif = &rx->sdata->vif; 1957 + info->control.jiffies = jiffies; 1982 1958 if (is_multicast_ether_addr(fwd_hdr->addr1)) { 1983 1959 IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.mesh, 1984 1960 fwded_mcast); 1985 - skb_set_queue_mapping(fwd_skb, 1986 - ieee80211_select_queue(sdata, fwd_skb)); 1987 - ieee80211_set_qos_hdr(sdata, fwd_skb); 1988 1961 } else { 1989 1962 int err; 1990 1963 /* ··· 2034 2011 return RX_DROP_MONITOR; 2035 2012 2036 2013 /* 2037 - * Allow the cooked monitor interface of an AP to see 4-addr frames so 2038 - * that a 4-addr station can be detected and moved into a separate VLAN 2014 + * Send unexpected-4addr-frame event to hostapd. For older versions, 2015 + * also drop the frame to cooked monitor interfaces. 2039 2016 */ 2040 2017 if (ieee80211_has_a4(hdr->frame_control) && 2041 - sdata->vif.type == NL80211_IFTYPE_AP) 2018 + sdata->vif.type == NL80211_IFTYPE_AP) { 2019 + if (rx->sta && 2020 + !test_and_set_sta_flag(rx->sta, WLAN_STA_4ADDR_EVENT)) 2021 + cfg80211_rx_unexpected_4addr_frame( 2022 + rx->sdata->dev, rx->sta->sta.addr, GFP_ATOMIC); 2042 2023 return RX_DROP_MONITOR; 2024 + } 2043 2025 2044 2026 err = __ieee80211_data_to_8023(rx, &port_control); 2045 2027 if (unlikely(err)) ··· 2199 2171 if (!ieee80211_is_mgmt(mgmt->frame_control)) 2200 2172 return RX_DROP_MONITOR; 2201 2173 2174 + if (rx->sdata->vif.type == NL80211_IFTYPE_AP && 2175 + ieee80211_is_beacon(mgmt->frame_control) && 2176 + !(rx->flags & IEEE80211_RX_BEACON_REPORTED)) { 2177 + struct ieee80211_rx_status *status; 2178 + 2179 + status = IEEE80211_SKB_RXCB(rx->skb); 2180 + cfg80211_report_obss_beacon(rx->local->hw.wiphy, 2181 + rx->skb->data, rx->skb->len, 2182 + status->freq, GFP_ATOMIC); 2183 + rx->flags |= IEEE80211_RX_BEACON_REPORTED; 2184 + } 2185 + 2202 2186 if (!(status->rx_flags & IEEE80211_RX_RA_MATCH)) 2203 2187 return RX_DROP_MONITOR; 2204 2188 ··· 2244 2204 2245 2205 switch (mgmt->u.action.category) { 2246 2206 case WLAN_CATEGORY_BACK: 2247 - /* 2248 - * The aggregation code is not prepared to handle 2249 - * anything but STA/AP due to the BSSID handling; 2250 - * IBSS could work in the code but isn't supported 2251 - * by drivers or the standard. 2252 - */ 2253 2207 if (sdata->vif.type != NL80211_IFTYPE_STATION && 2208 + sdata->vif.type != NL80211_IFTYPE_MESH_POINT && 2254 2209 sdata->vif.type != NL80211_IFTYPE_AP_VLAN && 2255 2210 sdata->vif.type != NL80211_IFTYPE_AP) 2256 2211 break; ··· 2524 2489 if (rx->flags & IEEE80211_RX_CMNTR) 2525 2490 goto out_free_skb; 2526 2491 rx->flags |= IEEE80211_RX_CMNTR; 2492 + 2493 + /* If there are no cooked monitor interfaces, just free the SKB */ 2494 + if (!local->cooked_mntrs) 2495 + goto out_free_skb; 2527 2496 2528 2497 if (skb_headroom(skb) < sizeof(*rthdr) && 2529 2498 pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC))
+78 -123
net/mac80211/scan.c
··· 213 213 if (bss) 214 214 ieee80211_rx_bss_put(sdata->local, bss); 215 215 216 - /* If we are on-operating-channel, and this packet is for the 217 - * current channel, pass the pkt on up the stack so that 218 - * the rest of the stack can make use of it. 219 - */ 220 - if (ieee80211_cfg_on_oper_channel(sdata->local) 221 - && (channel == sdata->local->oper_channel)) 216 + if (channel == sdata->local->oper_channel) 222 217 return RX_CONTINUE; 223 218 224 219 dev_kfree_skb(skb); ··· 259 264 bool was_hw_scan) 260 265 { 261 266 struct ieee80211_local *local = hw_to_local(hw); 262 - bool on_oper_chan; 263 - bool enable_beacons = false; 264 267 265 268 lockdep_assert_held(&local->mtx); 266 269 ··· 291 298 local->scanning = 0; 292 299 local->scan_channel = NULL; 293 300 294 - on_oper_chan = ieee80211_cfg_on_oper_channel(local); 295 - 296 - if (was_hw_scan || !on_oper_chan) 297 - ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); 298 - else 299 - /* Set power back to normal operating levels. */ 300 - ieee80211_hw_config(local, 0); 301 + /* Set power back to normal operating levels. */ 302 + ieee80211_hw_config(local, 0); 301 303 302 304 if (!was_hw_scan) { 303 - bool on_oper_chan2; 304 305 ieee80211_configure_filter(local); 305 306 drv_sw_scan_complete(local); 306 - on_oper_chan2 = ieee80211_cfg_on_oper_channel(local); 307 - /* We should always be on-channel at this point. */ 308 - WARN_ON(!on_oper_chan2); 309 - if (on_oper_chan2 && (on_oper_chan != on_oper_chan2)) 310 - enable_beacons = true; 311 - 312 - ieee80211_offchannel_return(local, enable_beacons, true); 307 + ieee80211_offchannel_return(local, true, true); 313 308 } 314 309 315 310 ieee80211_recalc_idle(local); ··· 342 361 local->next_scan_state = SCAN_DECISION; 343 362 local->scan_channel_idx = 0; 344 363 345 - /* We always want to use off-channel PS, even if we 346 - * are not really leaving oper-channel. Don't 347 - * tell the AP though, as long as we are on-channel. 348 - */ 349 - ieee80211_offchannel_enable_all_ps(local, false); 364 + ieee80211_offchannel_stop_vifs(local, true); 350 365 351 366 ieee80211_configure_filter(local); 352 367 ··· 350 373 ieee80211_hw_config(local, 0); 351 374 352 375 ieee80211_queue_delayed_work(&local->hw, 353 - &local->scan_work, 354 - IEEE80211_CHANNEL_TIME); 376 + &local->scan_work, 0); 355 377 356 378 return 0; 357 379 } ··· 486 510 487 511 next_chan = local->scan_req->channels[local->scan_channel_idx]; 488 512 489 - if (ieee80211_cfg_on_oper_channel(local)) { 490 - /* We're currently on operating channel. */ 491 - if (next_chan == local->oper_channel) 492 - /* We don't need to move off of operating channel. */ 493 - local->next_scan_state = SCAN_SET_CHANNEL; 494 - else 495 - /* 496 - * We do need to leave operating channel, as next 497 - * scan is somewhere else. 498 - */ 499 - local->next_scan_state = SCAN_LEAVE_OPER_CHANNEL; 500 - } else { 501 - /* 502 - * we're currently scanning a different channel, let's 503 - * see if we can scan another channel without interfering 504 - * with the current traffic situation. 505 - * 506 - * Since we don't know if the AP has pending frames for us 507 - * we can only check for our tx queues and use the current 508 - * pm_qos requirements for rx. Hence, if no tx traffic occurs 509 - * at all we will scan as many channels in a row as the pm_qos 510 - * latency allows us to. Additionally we also check for the 511 - * currently negotiated listen interval to prevent losing 512 - * frames unnecessarily. 513 - * 514 - * Otherwise switch back to the operating channel. 515 - */ 513 + /* 514 + * we're currently scanning a different channel, let's 515 + * see if we can scan another channel without interfering 516 + * with the current traffic situation. 517 + * 518 + * Since we don't know if the AP has pending frames for us 519 + * we can only check for our tx queues and use the current 520 + * pm_qos requirements for rx. Hence, if no tx traffic occurs 521 + * at all we will scan as many channels in a row as the pm_qos 522 + * latency allows us to. Additionally we also check for the 523 + * currently negotiated listen interval to prevent losing 524 + * frames unnecessarily. 525 + * 526 + * Otherwise switch back to the operating channel. 527 + */ 516 528 517 - bad_latency = time_after(jiffies + 518 - ieee80211_scan_get_channel_time(next_chan), 519 - local->leave_oper_channel_time + 520 - usecs_to_jiffies(pm_qos_request(PM_QOS_NETWORK_LATENCY))); 529 + bad_latency = time_after(jiffies + 530 + ieee80211_scan_get_channel_time(next_chan), 531 + local->leave_oper_channel_time + 532 + usecs_to_jiffies(pm_qos_request(PM_QOS_NETWORK_LATENCY))); 521 533 522 - listen_int_exceeded = time_after(jiffies + 523 - ieee80211_scan_get_channel_time(next_chan), 524 - local->leave_oper_channel_time + 525 - usecs_to_jiffies(min_beacon_int * 1024) * 526 - local->hw.conf.listen_interval); 534 + listen_int_exceeded = time_after(jiffies + 535 + ieee80211_scan_get_channel_time(next_chan), 536 + local->leave_oper_channel_time + 537 + usecs_to_jiffies(min_beacon_int * 1024) * 538 + local->hw.conf.listen_interval); 527 539 528 - if (associated && ( !tx_empty || bad_latency || 529 - listen_int_exceeded)) 530 - local->next_scan_state = SCAN_ENTER_OPER_CHANNEL; 531 - else 532 - local->next_scan_state = SCAN_SET_CHANNEL; 533 - } 540 + if (associated && (!tx_empty || bad_latency || listen_int_exceeded)) 541 + local->next_scan_state = SCAN_SUSPEND; 542 + else 543 + local->next_scan_state = SCAN_SET_CHANNEL; 534 544 535 545 *next_delay = 0; 536 - } 537 - 538 - static void ieee80211_scan_state_leave_oper_channel(struct ieee80211_local *local, 539 - unsigned long *next_delay) 540 - { 541 - /* PS will already be in off-channel mode, 542 - * we do that once at the beginning of scanning. 543 - */ 544 - ieee80211_offchannel_stop_vifs(local, false); 545 - 546 - /* 547 - * What if the nullfunc frames didn't arrive? 548 - */ 549 - drv_flush(local, false); 550 - if (local->ops->flush) 551 - *next_delay = 0; 552 - else 553 - *next_delay = HZ / 10; 554 - 555 - /* remember when we left the operating channel */ 556 - local->leave_oper_channel_time = jiffies; 557 - 558 - /* advance to the next channel to be scanned */ 559 - local->next_scan_state = SCAN_SET_CHANNEL; 560 - } 561 - 562 - static void ieee80211_scan_state_enter_oper_channel(struct ieee80211_local *local, 563 - unsigned long *next_delay) 564 - { 565 - /* switch back to the operating channel */ 566 - local->scan_channel = NULL; 567 - if (!ieee80211_cfg_on_oper_channel(local)) 568 - ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); 569 - 570 - /* 571 - * Re-enable vifs and beaconing. Leave PS 572 - * in off-channel state..will put that back 573 - * on-channel at the end of scanning. 574 - */ 575 - ieee80211_offchannel_return(local, true, false); 576 - 577 - *next_delay = HZ / 5; 578 - local->next_scan_state = SCAN_DECISION; 579 546 } 580 547 581 548 static void ieee80211_scan_state_set_channel(struct ieee80211_local *local, ··· 532 613 533 614 local->scan_channel = chan; 534 615 535 - /* Only call hw-config if we really need to change channels. */ 536 - if (chan != local->hw.conf.channel) 537 - if (ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL)) 538 - skip = 1; 616 + if (ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL)) 617 + skip = 1; 539 618 540 619 /* advance state machine to next channel/band */ 541 620 local->scan_channel_idx++; ··· 587 670 * on the channel. 588 671 */ 589 672 *next_delay = IEEE80211_CHANNEL_TIME; 673 + local->next_scan_state = SCAN_DECISION; 674 + } 675 + 676 + static void ieee80211_scan_state_suspend(struct ieee80211_local *local, 677 + unsigned long *next_delay) 678 + { 679 + /* switch back to the operating channel */ 680 + local->scan_channel = NULL; 681 + ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); 682 + 683 + /* 684 + * Re-enable vifs and beaconing. Leave PS 685 + * in off-channel state..will put that back 686 + * on-channel at the end of scanning. 687 + */ 688 + ieee80211_offchannel_return(local, true, false); 689 + 690 + *next_delay = HZ / 5; 691 + /* afterwards, resume scan & go to next channel */ 692 + local->next_scan_state = SCAN_RESUME; 693 + } 694 + 695 + static void ieee80211_scan_state_resume(struct ieee80211_local *local, 696 + unsigned long *next_delay) 697 + { 698 + /* PS already is in off-channel mode */ 699 + ieee80211_offchannel_stop_vifs(local, false); 700 + 701 + if (local->ops->flush) { 702 + drv_flush(local, false); 703 + *next_delay = 0; 704 + } else 705 + *next_delay = HZ / 10; 706 + 707 + /* remember when we left the operating channel */ 708 + local->leave_oper_channel_time = jiffies; 709 + 710 + /* advance to the next channel to be scanned */ 590 711 local->next_scan_state = SCAN_DECISION; 591 712 } 592 713 ··· 698 743 case SCAN_SEND_PROBE: 699 744 ieee80211_scan_state_send_probe(local, &next_delay); 700 745 break; 701 - case SCAN_LEAVE_OPER_CHANNEL: 702 - ieee80211_scan_state_leave_oper_channel(local, &next_delay); 746 + case SCAN_SUSPEND: 747 + ieee80211_scan_state_suspend(local, &next_delay); 703 748 break; 704 - case SCAN_ENTER_OPER_CHANNEL: 705 - ieee80211_scan_state_enter_oper_channel(local, &next_delay); 749 + case SCAN_RESUME: 750 + ieee80211_scan_state_resume(local, &next_delay); 706 751 break; 707 752 } 708 753 } while (next_delay == 0);
+4 -4
net/mac80211/sta_info.c
··· 1354 1354 * Use MoreData flag to indicate whether there are 1355 1355 * more buffered frames for this STA 1356 1356 */ 1357 - if (!more_data) 1358 - hdr->frame_control &= 1359 - cpu_to_le16(~IEEE80211_FCTL_MOREDATA); 1360 - else 1357 + if (more_data || !skb_queue_empty(&frames)) 1361 1358 hdr->frame_control |= 1362 1359 cpu_to_le16(IEEE80211_FCTL_MOREDATA); 1360 + else 1361 + hdr->frame_control &= 1362 + cpu_to_le16(~IEEE80211_FCTL_MOREDATA); 1363 1363 1364 1364 if (ieee80211_is_data_qos(hdr->frame_control) || 1365 1365 ieee80211_is_qos_nullfunc(hdr->frame_control))
+8
net/mac80211/sta_info.h
··· 52 52 * unblocks the station. 53 53 * @WLAN_STA_SP: Station is in a service period, so don't try to 54 54 * reply to other uAPSD trigger frames or PS-Poll. 55 + * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame. 55 56 */ 56 57 enum ieee80211_sta_info_flags { 57 58 WLAN_STA_AUTH, ··· 72 71 WLAN_STA_TDLS_PEER_AUTH, 73 72 WLAN_STA_UAPSD, 74 73 WLAN_STA_SP, 74 + WLAN_STA_4ADDR_EVENT, 75 75 }; 76 76 77 77 #define STA_TID_NUM 16 ··· 390 388 enum ieee80211_sta_info_flags flag) 391 389 { 392 390 return test_and_clear_bit(flag, &sta->_flags); 391 + } 392 + 393 + static inline int test_and_set_sta_flag(struct sta_info *sta, 394 + enum ieee80211_sta_info_flags flag) 395 + { 396 + return test_and_set_bit(flag, &sta->_flags); 393 397 } 394 398 395 399 void ieee80211_assign_tid_tx(struct sta_info *sta, int tid,
+71 -18
net/mac80211/status.c
··· 517 517 } 518 518 519 519 if (info->flags & IEEE80211_TX_INTFL_NL80211_FRAME_TX) { 520 - struct ieee80211_work *wk; 521 520 u64 cookie = (unsigned long)skb; 522 521 523 - rcu_read_lock(); 524 - list_for_each_entry_rcu(wk, &local->work_list, list) { 525 - if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX) 526 - continue; 527 - if (wk->offchan_tx.frame != skb) 528 - continue; 529 - wk->offchan_tx.status = true; 530 - break; 531 - } 532 - rcu_read_unlock(); 533 - if (local->hw_roc_skb_for_status == skb) { 534 - cookie = local->hw_roc_cookie ^ 2; 535 - local->hw_roc_skb_for_status = NULL; 536 - } 522 + if (ieee80211_is_nullfunc(hdr->frame_control) || 523 + ieee80211_is_qos_nullfunc(hdr->frame_control)) { 524 + bool acked = info->flags & IEEE80211_TX_STAT_ACK; 525 + cfg80211_probe_status(skb->dev, hdr->addr1, 526 + cookie, acked, GFP_ATOMIC); 527 + } else { 528 + struct ieee80211_work *wk; 537 529 538 - cfg80211_mgmt_tx_status( 539 - skb->dev, cookie, skb->data, skb->len, 540 - !!(info->flags & IEEE80211_TX_STAT_ACK), GFP_ATOMIC); 530 + rcu_read_lock(); 531 + list_for_each_entry_rcu(wk, &local->work_list, list) { 532 + if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX) 533 + continue; 534 + if (wk->offchan_tx.frame != skb) 535 + continue; 536 + wk->offchan_tx.status = true; 537 + break; 538 + } 539 + rcu_read_unlock(); 540 + if (local->hw_roc_skb_for_status == skb) { 541 + cookie = local->hw_roc_cookie ^ 2; 542 + local->hw_roc_skb_for_status = NULL; 543 + } 544 + 545 + cfg80211_mgmt_tx_status( 546 + skb->dev, cookie, skb->data, skb->len, 547 + !!(info->flags & IEEE80211_TX_STAT_ACK), 548 + GFP_ATOMIC); 549 + } 550 + } 551 + 552 + if (unlikely(info->ack_frame_id)) { 553 + struct sk_buff *ack_skb; 554 + unsigned long flags; 555 + 556 + spin_lock_irqsave(&local->ack_status_lock, flags); 557 + ack_skb = idr_find(&local->ack_status_frames, 558 + info->ack_frame_id); 559 + if (ack_skb) 560 + idr_remove(&local->ack_status_frames, 561 + info->ack_frame_id); 562 + spin_unlock_irqrestore(&local->ack_status_lock, flags); 563 + 564 + /* consumes ack_skb */ 565 + if (ack_skb) 566 + skb_complete_wifi_ack(ack_skb, 567 + info->flags & IEEE80211_TX_STAT_ACK); 541 568 } 542 569 543 570 /* this was a transmitted frame, but now we want to reuse it */ ··· 637 610 num_packets, GFP_ATOMIC); 638 611 } 639 612 EXPORT_SYMBOL(ieee80211_report_low_ack); 613 + 614 + void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb) 615 + { 616 + struct ieee80211_local *local = hw_to_local(hw); 617 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 618 + 619 + if (unlikely(info->ack_frame_id)) { 620 + struct sk_buff *ack_skb; 621 + unsigned long flags; 622 + 623 + spin_lock_irqsave(&local->ack_status_lock, flags); 624 + ack_skb = idr_find(&local->ack_status_frames, 625 + info->ack_frame_id); 626 + if (ack_skb) 627 + idr_remove(&local->ack_status_frames, 628 + info->ack_frame_id); 629 + spin_unlock_irqrestore(&local->ack_status_lock, flags); 630 + 631 + /* consumes ack_skb */ 632 + if (ack_skb) 633 + dev_kfree_skb_any(ack_skb); 634 + } 635 + 636 + dev_kfree_skb_any(skb); 637 + } 638 + EXPORT_SYMBOL(ieee80211_free_txskb);
+101 -9
net/mac80211/tx.c
··· 1685 1685 int nh_pos, h_pos; 1686 1686 struct sta_info *sta = NULL; 1687 1687 bool wme_sta = false, authorized = false, tdls_auth = false; 1688 - struct sk_buff *tmp_skb; 1689 1688 bool tdls_direct = false; 1689 + bool multicast; 1690 + u32 info_flags = 0; 1691 + u16 info_id = 0; 1690 1692 1691 1693 if (unlikely(skb->len < ETH_HLEN)) { 1692 1694 ret = NETDEV_TX_OK; ··· 1875 1873 * if it is a multicast address (which can only happen 1876 1874 * in AP mode) 1877 1875 */ 1878 - if (!is_multicast_ether_addr(hdr.addr1)) { 1876 + multicast = is_multicast_ether_addr(hdr.addr1); 1877 + if (!multicast) { 1879 1878 rcu_read_lock(); 1880 1879 sta = sta_info_get(sdata, hdr.addr1); 1881 1880 if (sta) { ··· 1917 1914 goto fail; 1918 1915 } 1919 1916 1917 + if (unlikely(!multicast && skb->sk && 1918 + skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS)) { 1919 + struct sk_buff *orig_skb = skb; 1920 + 1921 + skb = skb_clone(skb, GFP_ATOMIC); 1922 + if (skb) { 1923 + unsigned long flags; 1924 + int id, r; 1925 + 1926 + spin_lock_irqsave(&local->ack_status_lock, flags); 1927 + r = idr_get_new_above(&local->ack_status_frames, 1928 + orig_skb, 1, &id); 1929 + if (r == -EAGAIN) { 1930 + idr_pre_get(&local->ack_status_frames, 1931 + GFP_ATOMIC); 1932 + r = idr_get_new_above(&local->ack_status_frames, 1933 + orig_skb, 1, &id); 1934 + } 1935 + if (WARN_ON(!id) || id > 0xffff) { 1936 + idr_remove(&local->ack_status_frames, id); 1937 + r = -ERANGE; 1938 + } 1939 + spin_unlock_irqrestore(&local->ack_status_lock, flags); 1940 + 1941 + if (!r) { 1942 + info_id = id; 1943 + info_flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; 1944 + } else if (skb_shared(skb)) { 1945 + kfree_skb(orig_skb); 1946 + } else { 1947 + kfree_skb(skb); 1948 + skb = orig_skb; 1949 + } 1950 + } else { 1951 + /* couldn't clone -- lose tx status ... */ 1952 + skb = orig_skb; 1953 + } 1954 + } 1955 + 1920 1956 /* 1921 1957 * If the skb is shared we need to obtain our own copy. 1922 1958 */ 1923 1959 if (skb_shared(skb)) { 1924 - tmp_skb = skb; 1960 + struct sk_buff *tmp_skb = skb; 1961 + 1962 + /* can't happen -- skb is a clone if info_id != 0 */ 1963 + WARN_ON(info_id); 1964 + 1925 1965 skb = skb_clone(skb, GFP_ATOMIC); 1926 1966 kfree_skb(tmp_skb); 1927 1967 ··· 2065 2019 memset(info, 0, sizeof(*info)); 2066 2020 2067 2021 dev->trans_start = jiffies; 2022 + 2023 + info->flags = info_flags; 2024 + info->ack_frame_id = info_id; 2025 + 2068 2026 ieee80211_xmit(sdata, skb); 2069 2027 2070 2028 return NETDEV_TX_OK; ··· 2329 2279 } else if (ieee80211_vif_is_mesh(&sdata->vif)) { 2330 2280 struct ieee80211_mgmt *mgmt; 2331 2281 u8 *pos; 2282 + int hdr_len = offsetof(struct ieee80211_mgmt, u.beacon) + 2283 + sizeof(mgmt->u.beacon); 2332 2284 2333 2285 #ifdef CONFIG_MAC80211_MESH 2334 2286 if (!sdata->u.mesh.mesh_id_len) 2335 2287 goto out; 2336 2288 #endif 2337 2289 2338 - /* headroom, head length, tail length and maximum TIM length */ 2339 - skb = dev_alloc_skb(local->tx_headroom + 400 + 2340 - sdata->u.mesh.ie_len); 2290 + skb = dev_alloc_skb(local->tx_headroom + 2291 + hdr_len + 2292 + 2 + /* NULL SSID */ 2293 + 2 + 8 + /* supported rates */ 2294 + 2 + 3 + /* DS params */ 2295 + 2 + (IEEE80211_MAX_SUPP_RATES - 8) + 2296 + 2 + sizeof(struct ieee80211_ht_cap) + 2297 + 2 + sizeof(struct ieee80211_ht_info) + 2298 + 2 + sdata->u.mesh.mesh_id_len + 2299 + 2 + sizeof(struct ieee80211_meshconf_ie) + 2300 + sdata->u.mesh.ie_len); 2341 2301 if (!skb) 2342 2302 goto out; 2343 2303 2344 2304 skb_reserve(skb, local->hw.extra_tx_headroom); 2345 - mgmt = (struct ieee80211_mgmt *) 2346 - skb_put(skb, 24 + sizeof(mgmt->u.beacon)); 2347 - memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); 2305 + mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len); 2306 + memset(mgmt, 0, hdr_len); 2348 2307 mgmt->frame_control = 2349 2308 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON); 2350 2309 memset(mgmt->da, 0xff, ETH_ALEN); ··· 2372 2313 mesh_add_ds_params_ie(skb, sdata) || 2373 2314 ieee80211_add_ext_srates_ie(&sdata->vif, skb) || 2374 2315 mesh_add_rsn_ie(skb, sdata) || 2316 + mesh_add_ht_cap_ie(skb, sdata) || 2317 + mesh_add_ht_info_ie(skb, sdata) || 2375 2318 mesh_add_meshid_ie(skb, sdata) || 2376 2319 mesh_add_meshconf_ie(skb, sdata) || 2377 2320 mesh_add_vendor_ies(skb, sdata)) { ··· 2415 2354 return skb; 2416 2355 } 2417 2356 EXPORT_SYMBOL(ieee80211_beacon_get_tim); 2357 + 2358 + struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw, 2359 + struct ieee80211_vif *vif) 2360 + { 2361 + struct ieee80211_if_ap *ap = NULL; 2362 + struct sk_buff *presp = NULL, *skb = NULL; 2363 + struct ieee80211_hdr *hdr; 2364 + struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif); 2365 + 2366 + if (sdata->vif.type != NL80211_IFTYPE_AP) 2367 + return NULL; 2368 + 2369 + rcu_read_lock(); 2370 + 2371 + ap = &sdata->u.ap; 2372 + presp = rcu_dereference(ap->probe_resp); 2373 + if (!presp) 2374 + goto out; 2375 + 2376 + skb = skb_copy(presp, GFP_ATOMIC); 2377 + if (!skb) 2378 + goto out; 2379 + 2380 + hdr = (struct ieee80211_hdr *) skb->data; 2381 + memset(hdr->addr1, 0, sizeof(hdr->addr1)); 2382 + 2383 + out: 2384 + rcu_read_unlock(); 2385 + return skb; 2386 + } 2387 + EXPORT_SYMBOL(ieee80211_proberesp_get); 2418 2388 2419 2389 struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw, 2420 2390 struct ieee80211_vif *vif)
+106 -20
net/mac80211/util.c
··· 812 812 offset = noffset; 813 813 } 814 814 815 - if (sband->ht_cap.ht_supported) { 816 - u16 cap = sband->ht_cap.cap; 817 - __le16 tmp; 818 - 819 - *pos++ = WLAN_EID_HT_CAPABILITY; 820 - *pos++ = sizeof(struct ieee80211_ht_cap); 821 - memset(pos, 0, sizeof(struct ieee80211_ht_cap)); 822 - tmp = cpu_to_le16(cap); 823 - memcpy(pos, &tmp, sizeof(u16)); 824 - pos += sizeof(u16); 825 - *pos++ = sband->ht_cap.ampdu_factor | 826 - (sband->ht_cap.ampdu_density << 827 - IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT); 828 - memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); 829 - pos += sizeof(sband->ht_cap.mcs); 830 - pos += 2 + 4 + 1; /* ext info, BF cap, antsel */ 831 - } 815 + if (sband->ht_cap.ht_supported) 816 + pos = ieee80211_ie_build_ht_cap(pos, sband, sband->ht_cap.cap); 832 817 833 818 /* 834 819 * If adding more here, adjust code in main.c ··· 1007 1022 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN && 1008 1023 sdata->vif.type != NL80211_IFTYPE_MONITOR && 1009 1024 ieee80211_sdata_running(sdata)) 1010 - res = drv_add_interface(local, &sdata->vif); 1025 + res = drv_add_interface(local, sdata); 1011 1026 } 1012 1027 1013 1028 /* add STAs back */ ··· 1058 1073 BSS_CHANGED_BEACON_INT | 1059 1074 BSS_CHANGED_BSSID | 1060 1075 BSS_CHANGED_CQM | 1061 - BSS_CHANGED_QOS; 1076 + BSS_CHANGED_QOS | 1077 + BSS_CHANGED_IDLE; 1062 1078 1063 1079 switch (sdata->vif.type) { 1064 1080 case NL80211_IFTYPE_STATION: ··· 1072 1086 changed |= BSS_CHANGED_IBSS; 1073 1087 /* fall through */ 1074 1088 case NL80211_IFTYPE_AP: 1075 - changed |= BSS_CHANGED_SSID; 1089 + changed |= BSS_CHANGED_SSID | 1090 + BSS_CHANGED_AP_PROBE_RESP; 1076 1091 /* fall through */ 1077 1092 case NL80211_IFTYPE_MESH_POINT: 1078 1093 changed |= BSS_CHANGED_BEACON | ··· 1094 1107 break; 1095 1108 } 1096 1109 } 1110 + 1111 + ieee80211_recalc_ps(local, -1); 1097 1112 1098 1113 /* 1099 1114 * Clear the WLAN_STA_BLOCK_BA flag so new aggregation ··· 1351 1362 _ieee80211_enable_rssi_reports(sdata, 0, 0); 1352 1363 } 1353 1364 EXPORT_SYMBOL(ieee80211_disable_rssi_reports); 1365 + 1366 + u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_supported_band *sband, 1367 + u16 cap) 1368 + { 1369 + __le16 tmp; 1370 + 1371 + *pos++ = WLAN_EID_HT_CAPABILITY; 1372 + *pos++ = sizeof(struct ieee80211_ht_cap); 1373 + memset(pos, 0, sizeof(struct ieee80211_ht_cap)); 1374 + 1375 + /* capability flags */ 1376 + tmp = cpu_to_le16(cap); 1377 + memcpy(pos, &tmp, sizeof(u16)); 1378 + pos += sizeof(u16); 1379 + 1380 + /* AMPDU parameters */ 1381 + *pos++ = sband->ht_cap.ampdu_factor | 1382 + (sband->ht_cap.ampdu_density << 1383 + IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT); 1384 + 1385 + /* MCS set */ 1386 + memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); 1387 + pos += sizeof(sband->ht_cap.mcs); 1388 + 1389 + /* extended capabilities */ 1390 + pos += sizeof(__le16); 1391 + 1392 + /* BF capabilities */ 1393 + pos += sizeof(__le32); 1394 + 1395 + /* antenna selection */ 1396 + pos += sizeof(u8); 1397 + 1398 + return pos; 1399 + } 1400 + 1401 + u8 *ieee80211_ie_build_ht_info(u8 *pos, 1402 + struct ieee80211_sta_ht_cap *ht_cap, 1403 + struct ieee80211_channel *channel, 1404 + enum nl80211_channel_type channel_type) 1405 + { 1406 + struct ieee80211_ht_info *ht_info; 1407 + /* Build HT Information */ 1408 + *pos++ = WLAN_EID_HT_INFORMATION; 1409 + *pos++ = sizeof(struct ieee80211_ht_info); 1410 + ht_info = (struct ieee80211_ht_info *)pos; 1411 + ht_info->control_chan = 1412 + ieee80211_frequency_to_channel(channel->center_freq); 1413 + switch (channel_type) { 1414 + case NL80211_CHAN_HT40MINUS: 1415 + ht_info->ht_param = IEEE80211_HT_PARAM_CHA_SEC_BELOW; 1416 + break; 1417 + case NL80211_CHAN_HT40PLUS: 1418 + ht_info->ht_param = IEEE80211_HT_PARAM_CHA_SEC_ABOVE; 1419 + break; 1420 + case NL80211_CHAN_HT20: 1421 + default: 1422 + ht_info->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE; 1423 + break; 1424 + } 1425 + if (ht_cap->cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) 1426 + ht_info->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY; 1427 + ht_info->operation_mode = 0x0000; 1428 + ht_info->stbc_param = 0x0000; 1429 + 1430 + /* It seems that Basic MCS set and Supported MCS set 1431 + are identical for the first 10 bytes */ 1432 + memset(&ht_info->basic_set, 0, 16); 1433 + memcpy(&ht_info->basic_set, &ht_cap->mcs, 10); 1434 + 1435 + return pos + sizeof(struct ieee80211_ht_info); 1436 + } 1437 + 1438 + enum nl80211_channel_type 1439 + ieee80211_ht_info_to_channel_type(struct ieee80211_ht_info *ht_info) 1440 + { 1441 + enum nl80211_channel_type channel_type; 1442 + 1443 + if (!ht_info) 1444 + return NL80211_CHAN_NO_HT; 1445 + 1446 + switch (ht_info->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { 1447 + case IEEE80211_HT_PARAM_CHA_SEC_NONE: 1448 + channel_type = NL80211_CHAN_HT20; 1449 + break; 1450 + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: 1451 + channel_type = NL80211_CHAN_HT40PLUS; 1452 + break; 1453 + case IEEE80211_HT_PARAM_CHA_SEC_BELOW: 1454 + channel_type = NL80211_CHAN_HT40MINUS; 1455 + break; 1456 + default: 1457 + channel_type = NL80211_CHAN_NO_HT; 1458 + } 1459 + 1460 + return channel_type; 1461 + } 1354 1462 1355 1463 int ieee80211_add_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb) 1356 1464 {
+7 -3
net/mac80211/wme.c
··· 83 83 break; 84 84 #ifdef CONFIG_MAC80211_MESH 85 85 case NL80211_IFTYPE_MESH_POINT: 86 - ra = skb->data; 86 + qos = true; 87 87 break; 88 88 #endif 89 89 case NL80211_IFTYPE_STATION: ··· 143 143 /* Fill in the QoS header if there is one. */ 144 144 if (ieee80211_is_data_qos(hdr->frame_control)) { 145 145 u8 *p = ieee80211_get_qos_ctl(hdr); 146 - u8 ack_policy = 0, tid; 146 + u8 ack_policy, tid; 147 147 148 148 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; 149 149 150 - if (unlikely(sdata->local->wifi_wme_noack_test)) 150 + /* preserve EOSP bit */ 151 + ack_policy = *p & IEEE80211_QOS_CTL_EOSP; 152 + 153 + if (unlikely(sdata->local->wifi_wme_noack_test) || 154 + is_multicast_ether_addr(hdr->addr1)) 151 155 ack_policy |= IEEE80211_QOS_CTL_ACK_POLICY_NOACK; 152 156 /* qos header is 2 bytes */ 153 157 *p++ = ack_policy | tid;
+4 -42
net/mac80211/work.c
··· 103 103 u8 *pos; 104 104 u32 flags = channel->flags; 105 105 u16 cap = sband->ht_cap.cap; 106 - __le16 tmp; 107 106 108 107 if (!sband->ht_cap.ht_supported) 109 108 return; ··· 153 154 } 154 155 155 156 /* reserve and fill IE */ 156 - 157 157 pos = skb_put(skb, sizeof(struct ieee80211_ht_cap) + 2); 158 - *pos++ = WLAN_EID_HT_CAPABILITY; 159 - *pos++ = sizeof(struct ieee80211_ht_cap); 160 - memset(pos, 0, sizeof(struct ieee80211_ht_cap)); 161 - 162 - /* capability flags */ 163 - tmp = cpu_to_le16(cap); 164 - memcpy(pos, &tmp, sizeof(u16)); 165 - pos += sizeof(u16); 166 - 167 - /* AMPDU parameters */ 168 - *pos++ = sband->ht_cap.ampdu_factor | 169 - (sband->ht_cap.ampdu_density << 170 - IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT); 171 - 172 - /* MCS set */ 173 - memcpy(pos, &sband->ht_cap.mcs, sizeof(sband->ht_cap.mcs)); 174 - pos += sizeof(sband->ht_cap.mcs); 175 - 176 - /* extended capabilities */ 177 - pos += sizeof(__le16); 178 - 179 - /* BF capabilities */ 180 - pos += sizeof(__le32); 181 - 182 - /* antenna selection */ 183 - pos += sizeof(u8); 158 + ieee80211_ie_build_ht_cap(pos, sband, cap); 184 159 } 185 160 186 161 static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata, ··· 942 969 } 943 970 944 971 if (!started && !local->tmp_channel) { 945 - bool on_oper_chan; 946 - bool tmp_chan_changed = false; 947 - bool on_oper_chan2; 972 + bool on_oper_chan, on_oper_chan2; 948 973 enum nl80211_channel_type wk_ct; 974 + 949 975 on_oper_chan = ieee80211_cfg_on_oper_channel(local); 950 976 951 977 /* Work with existing channel type if possible. */ ··· 952 980 if (wk->chan == local->hw.conf.channel) 953 981 wk_ct = ieee80211_calc_ct(wk->chan_type, 954 982 local->hw.conf.channel_type); 955 - 956 - if (local->tmp_channel) 957 - if ((local->tmp_channel != wk->chan) || 958 - (local->tmp_channel_type != wk_ct)) 959 - tmp_chan_changed = true; 960 983 961 984 local->tmp_channel = wk->chan; 962 985 local->tmp_channel_type = wk_ct; ··· 975 1008 true, 976 1009 false); 977 1010 } 978 - } else if (tmp_chan_changed) 979 - /* Still off-channel, but on some other 980 - * channel, so update hardware. 981 - * PS should already be off-channel. 982 - */ 983 - ieee80211_hw_config(local, 0); 1011 + } 984 1012 985 1013 started = true; 986 1014 wk->timeout = jiffies;
+8 -1
net/mac80211/wpa.c
··· 390 390 u8 scratch[6 * AES_BLOCK_SIZE]; 391 391 392 392 if (info->control.hw_key && 393 - !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) { 393 + !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) && 394 + !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) { 394 395 /* 395 396 * hwaccel has no need for preallocated room for CCMP 396 397 * header or MIC fields ··· 413 412 414 413 pos = skb_push(skb, CCMP_HDR_LEN); 415 414 memmove(pos, pos + CCMP_HDR_LEN, hdrlen); 415 + 416 + /* the HW only needs room for the IV, but not the actual IV */ 417 + if (info->control.hw_key && 418 + (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) 419 + return 0; 420 + 416 421 hdr = (struct ieee80211_hdr *) pos; 417 422 pos += hdrlen; 418 423
+9 -9
net/nfc/nci/core.c
··· 126 126 127 127 static void nci_reset_req(struct nci_dev *ndev, unsigned long opt) 128 128 { 129 - nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 0, NULL); 129 + struct nci_core_reset_cmd cmd; 130 + 131 + cmd.reset_type = NCI_RESET_TYPE_RESET_CONFIG; 132 + nci_send_cmd(ndev, NCI_OP_CORE_RESET_CMD, 1, &cmd); 130 133 } 131 134 132 135 static void nci_init_req(struct nci_dev *ndev, unsigned long opt) ··· 139 136 140 137 static void nci_init_complete_req(struct nci_dev *ndev, unsigned long opt) 141 138 { 142 - struct nci_core_conn_create_cmd conn_cmd; 143 139 struct nci_rf_disc_map_cmd cmd; 144 140 struct disc_map_config *cfg = cmd.mapping_configs; 145 141 __u8 *num = &cmd.num_mapping_configs; 146 142 int i; 147 - 148 - /* create static rf connection */ 149 - conn_cmd.target_handle = 0; 150 - conn_cmd.num_target_specific_params = 0; 151 - nci_send_cmd(ndev, NCI_OP_CORE_CONN_CREATE_CMD, 2, &conn_cmd); 152 143 153 144 /* set rf mapping configurations */ 154 145 *num = 0; ··· 467 470 ndev->data_exchange_cb = cb; 468 471 ndev->data_exchange_cb_context = cb_context; 469 472 470 - rc = nci_send_data(ndev, ndev->conn_id, skb); 473 + rc = nci_send_data(ndev, NCI_STATIC_RF_CONN_ID, skb); 471 474 if (rc) 472 475 clear_bit(NCI_DATA_EXCHANGE, &ndev->flags); 473 476 ··· 723 726 if (!skb) 724 727 return; 725 728 726 - atomic_dec(&ndev->credits_cnt); 729 + /* Check if data flow control is used */ 730 + if (atomic_read(&ndev->credits_cnt) != 731 + NCI_DATA_FLOW_CONTROL_NOT_USED) 732 + atomic_dec(&ndev->credits_cnt); 727 733 728 734 nfc_dbg("NCI TX: MT=data, PBF=%d, conn_id=%d, plen=%d", 729 735 nci_pbf(skb->data),
+3 -2
net/nfc/nci/data.c
··· 95 95 __skb_queue_head_init(&frags_q); 96 96 97 97 while (total_len) { 98 - frag_len = min_t(int, total_len, ndev->max_pkt_payload_size); 98 + frag_len = 99 + min_t(int, total_len, ndev->max_data_pkt_payload_size); 99 100 100 101 skb_frag = nci_skb_alloc(ndev, 101 102 (NCI_DATA_HDR_SIZE + frag_len), ··· 152 151 nfc_dbg("entry, conn_id 0x%x, plen %d", conn_id, skb->len); 153 152 154 153 /* check if the packet need to be fragmented */ 155 - if (skb->len <= ndev->max_pkt_payload_size) { 154 + if (skb->len <= ndev->max_data_pkt_payload_size) { 156 155 /* no need to fragment packet */ 157 156 nci_push_data_hdr(ndev, conn_id, skb, NCI_PBF_LAST); 158 157
+1 -7
net/nfc/nci/lib.c
··· 42 42 case NCI_STATUS_REJECTED: 43 43 return -EBUSY; 44 44 45 - case NCI_STATUS_MESSAGE_CORRUPTED: 45 + case NCI_STATUS_RF_FRAME_CORRUPTED: 46 46 return -EBADMSG; 47 - 48 - case NCI_STATUS_BUFFER_FULL: 49 - return -ENOBUFS; 50 47 51 48 case NCI_STATUS_NOT_INITIALIZED: 52 49 return -EHOSTDOWN; ··· 76 79 case NCI_STATUS_RF_TIMEOUT_ERROR: 77 80 case NCI_STATUS_NFCEE_TIMEOUT_ERROR: 78 81 return -ETIMEDOUT; 79 - 80 - case NCI_STATUS_RF_LINK_LOSS_ERROR: 81 - return -ENOLINK; 82 82 83 83 case NCI_STATUS_MAX_ACTIVE_NFCEE_INTERFACES_REACHED: 84 84 return -EDQUOT;
+89 -61
net/nfc/nci/ntf.c
··· 54 54 ntf->conn_entries[i].conn_id, 55 55 ntf->conn_entries[i].credits); 56 56 57 - if (ntf->conn_entries[i].conn_id == ndev->conn_id) { 57 + if (ntf->conn_entries[i].conn_id == NCI_STATIC_RF_CONN_ID) { 58 58 /* found static rf connection */ 59 59 atomic_add(ntf->conn_entries[i].credits, 60 60 &ndev->credits_cnt); ··· 66 66 queue_work(ndev->tx_wq, &ndev->tx_work); 67 67 } 68 68 69 - static void nci_rf_field_info_ntf_packet(struct nci_dev *ndev, 70 - struct sk_buff *skb) 71 - { 72 - struct nci_rf_field_info_ntf *ntf = (void *) skb->data; 73 - 74 - nfc_dbg("entry, rf_field_status %d", ntf->rf_field_status); 75 - } 76 - 77 - static int nci_rf_activate_nfca_passive_poll(struct nci_dev *ndev, 78 - struct nci_rf_activate_ntf *ntf, __u8 *data) 69 + static __u8 *nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev, 70 + struct nci_rf_intf_activated_ntf *ntf, __u8 *data) 79 71 { 80 72 struct rf_tech_specific_params_nfca_poll *nfca_poll; 81 - struct activation_params_nfca_poll_iso_dep *nfca_poll_iso_dep; 82 73 83 74 nfca_poll = &ntf->rf_tech_specific_params.nfca_poll; 84 - nfca_poll_iso_dep = &ntf->activation_params.nfca_poll_iso_dep; 85 75 86 76 nfca_poll->sens_res = __le16_to_cpu(*((__u16 *)data)); 87 77 data += 2; ··· 90 100 if (nfca_poll->sel_res_len != 0) 91 101 nfca_poll->sel_res = *data++; 92 102 93 - ntf->rf_interface_type = *data++; 94 - ntf->activation_params_len = *data++; 95 - 96 - nfc_dbg("sel_res_len %d, sel_res 0x%x, rf_interface_type %d, activation_params_len %d", 103 + nfc_dbg("sel_res_len %d, sel_res 0x%x", 97 104 nfca_poll->sel_res_len, 98 - nfca_poll->sel_res, 99 - ntf->rf_interface_type, 100 - ntf->activation_params_len); 105 + nfca_poll->sel_res); 101 106 102 - switch (ntf->rf_interface_type) { 103 - case NCI_RF_INTERFACE_ISO_DEP: 104 - nfca_poll_iso_dep->rats_res_len = *data++; 105 - if (nfca_poll_iso_dep->rats_res_len > 0) { 106 - memcpy(nfca_poll_iso_dep->rats_res, 107 + return data; 108 + } 109 + 110 + static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev, 111 + struct nci_rf_intf_activated_ntf *ntf, __u8 *data) 112 + { 113 + struct activation_params_nfca_poll_iso_dep *nfca_poll; 114 + 115 + switch (ntf->activation_rf_tech_and_mode) { 116 + case NCI_NFC_A_PASSIVE_POLL_MODE: 117 + nfca_poll = &ntf->activation_params.nfca_poll_iso_dep; 118 + nfca_poll->rats_res_len = *data++; 119 + if (nfca_poll->rats_res_len > 0) { 120 + memcpy(nfca_poll->rats_res, 107 121 data, 108 - nfca_poll_iso_dep->rats_res_len); 122 + nfca_poll->rats_res_len); 109 123 } 110 124 break; 111 125 112 - case NCI_RF_INTERFACE_FRAME: 113 - /* no activation params */ 114 - break; 115 - 116 126 default: 117 - nfc_err("unsupported rf_interface_type 0x%x", 118 - ntf->rf_interface_type); 127 + nfc_err("unsupported activation_rf_tech_and_mode 0x%x", 128 + ntf->activation_rf_tech_and_mode); 119 129 return -EPROTO; 120 130 } 121 131 ··· 123 133 } 124 134 125 135 static void nci_target_found(struct nci_dev *ndev, 126 - struct nci_rf_activate_ntf *ntf) 136 + struct nci_rf_intf_activated_ntf *ntf) 127 137 { 128 138 struct nfc_target nfc_tgt; 129 139 ··· 131 141 nfc_tgt.supported_protocols = NFC_PROTO_MIFARE_MASK; 132 142 else if (ntf->rf_protocol == NCI_RF_PROTOCOL_ISO_DEP) /* 4A */ 133 143 nfc_tgt.supported_protocols = NFC_PROTO_ISO14443_MASK; 144 + else 145 + nfc_tgt.supported_protocols = 0; 134 146 135 147 nfc_tgt.sens_res = ntf->rf_tech_specific_params.nfca_poll.sens_res; 136 148 nfc_tgt.sel_res = ntf->rf_tech_specific_params.nfca_poll.sel_res; ··· 150 158 nfc_targets_found(ndev->nfc_dev, &nfc_tgt, 1); 151 159 } 152 160 153 - static void nci_rf_activate_ntf_packet(struct nci_dev *ndev, 154 - struct sk_buff *skb) 161 + static void nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, 162 + struct sk_buff *skb) 155 163 { 156 - struct nci_rf_activate_ntf ntf; 164 + struct nci_rf_intf_activated_ntf ntf; 157 165 __u8 *data = skb->data; 158 - int rc = -1; 166 + int err = 0; 159 167 160 168 clear_bit(NCI_DISCOVERY, &ndev->flags); 161 169 set_bit(NCI_POLL_ACTIVE, &ndev->flags); 162 170 163 - ntf.target_handle = *data++; 171 + ntf.rf_discovery_id = *data++; 172 + ntf.rf_interface_type = *data++; 164 173 ntf.rf_protocol = *data++; 165 - ntf.rf_tech_and_mode = *data++; 174 + ntf.activation_rf_tech_and_mode = *data++; 166 175 ntf.rf_tech_specific_params_len = *data++; 167 176 168 - nfc_dbg("target_handle %d, rf_protocol 0x%x, rf_tech_and_mode 0x%x, rf_tech_specific_params_len %d", 169 - ntf.target_handle, 170 - ntf.rf_protocol, 171 - ntf.rf_tech_and_mode, 177 + nfc_dbg("rf_discovery_id %d", ntf.rf_discovery_id); 178 + nfc_dbg("rf_interface_type 0x%x", ntf.rf_interface_type); 179 + nfc_dbg("rf_protocol 0x%x", ntf.rf_protocol); 180 + nfc_dbg("activation_rf_tech_and_mode 0x%x", 181 + ntf.activation_rf_tech_and_mode); 182 + nfc_dbg("rf_tech_specific_params_len %d", 172 183 ntf.rf_tech_specific_params_len); 173 184 174 - switch (ntf.rf_tech_and_mode) { 175 - case NCI_NFC_A_PASSIVE_POLL_MODE: 176 - rc = nci_rf_activate_nfca_passive_poll(ndev, &ntf, 177 - data); 178 - break; 185 + if (ntf.rf_tech_specific_params_len > 0) { 186 + switch (ntf.activation_rf_tech_and_mode) { 187 + case NCI_NFC_A_PASSIVE_POLL_MODE: 188 + data = nci_extract_rf_params_nfca_passive_poll(ndev, 189 + &ntf, data); 190 + break; 179 191 180 - default: 181 - nfc_err("unsupported rf_tech_and_mode 0x%x", 182 - ntf.rf_tech_and_mode); 183 - return; 192 + default: 193 + nfc_err("unsupported activation_rf_tech_and_mode 0x%x", 194 + ntf.activation_rf_tech_and_mode); 195 + return; 196 + } 184 197 } 185 198 186 - if (!rc) 199 + ntf.data_exch_rf_tech_and_mode = *data++; 200 + ntf.data_exch_tx_bit_rate = *data++; 201 + ntf.data_exch_rx_bit_rate = *data++; 202 + ntf.activation_params_len = *data++; 203 + 204 + nfc_dbg("data_exch_rf_tech_and_mode 0x%x", 205 + ntf.data_exch_rf_tech_and_mode); 206 + nfc_dbg("data_exch_tx_bit_rate 0x%x", 207 + ntf.data_exch_tx_bit_rate); 208 + nfc_dbg("data_exch_rx_bit_rate 0x%x", 209 + ntf.data_exch_rx_bit_rate); 210 + nfc_dbg("activation_params_len %d", 211 + ntf.activation_params_len); 212 + 213 + if (ntf.activation_params_len > 0) { 214 + switch (ntf.rf_interface_type) { 215 + case NCI_RF_INTERFACE_ISO_DEP: 216 + err = nci_extract_activation_params_iso_dep(ndev, 217 + &ntf, data); 218 + break; 219 + 220 + case NCI_RF_INTERFACE_FRAME: 221 + /* no activation params */ 222 + break; 223 + 224 + default: 225 + nfc_err("unsupported rf_interface_type 0x%x", 226 + ntf.rf_interface_type); 227 + return; 228 + } 229 + } 230 + 231 + if (!err) 187 232 nci_target_found(ndev, &ntf); 188 233 } 189 234 190 235 static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, 191 236 struct sk_buff *skb) 192 237 { 193 - __u8 type = skb->data[0]; 238 + struct nci_rf_deactivate_ntf *ntf = (void *) skb->data; 194 239 195 - nfc_dbg("entry, type 0x%x", type); 240 + nfc_dbg("entry, type 0x%x, reason 0x%x", ntf->type, ntf->reason); 196 241 197 242 clear_bit(NCI_POLL_ACTIVE, &ndev->flags); 198 243 ndev->target_active_prot = 0; ··· 242 213 kfree_skb(ndev->rx_data_reassembly); 243 214 ndev->rx_data_reassembly = 0; 244 215 } 216 + 217 + /* set the available credits to initial value */ 218 + atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); 245 219 246 220 /* complete the data exchange transaction, if exists */ 247 221 if (test_bit(NCI_DATA_EXCHANGE, &ndev->flags)) ··· 269 237 nci_core_conn_credits_ntf_packet(ndev, skb); 270 238 break; 271 239 272 - case NCI_OP_RF_FIELD_INFO_NTF: 273 - nci_rf_field_info_ntf_packet(ndev, skb); 274 - break; 275 - 276 - case NCI_OP_RF_ACTIVATE_NTF: 277 - nci_rf_activate_ntf_packet(ndev, skb); 240 + case NCI_OP_RF_INTF_ACTIVATED_NTF: 241 + nci_rf_intf_activated_ntf_packet(ndev, skb); 278 242 break; 279 243 280 244 case NCI_OP_RF_DEACTIVATE_NTF:
+34 -47
net/nfc/nci/rsp.c
··· 42 42 43 43 nfc_dbg("entry, status 0x%x", rsp->status); 44 44 45 - if (rsp->status == NCI_STATUS_OK) 45 + if (rsp->status == NCI_STATUS_OK) { 46 46 ndev->nci_ver = rsp->nci_ver; 47 - 48 - nfc_dbg("nci_ver 0x%x", ndev->nci_ver); 47 + nfc_dbg("nci_ver 0x%x, config_status 0x%x", 48 + rsp->nci_ver, rsp->config_status); 49 + } 49 50 50 51 nci_req_complete(ndev, rsp->status); 51 52 } ··· 59 58 nfc_dbg("entry, status 0x%x", rsp_1->status); 60 59 61 60 if (rsp_1->status != NCI_STATUS_OK) 62 - return; 61 + goto exit; 63 62 64 63 ndev->nfcc_features = __le32_to_cpu(rsp_1->nfcc_features); 65 64 ndev->num_supported_rf_interfaces = rsp_1->num_supported_rf_interfaces; 66 65 67 66 if (ndev->num_supported_rf_interfaces > 68 - NCI_MAX_SUPPORTED_RF_INTERFACES) { 67 + NCI_MAX_SUPPORTED_RF_INTERFACES) { 69 68 ndev->num_supported_rf_interfaces = 70 69 NCI_MAX_SUPPORTED_RF_INTERFACES; 71 70 } ··· 74 73 rsp_1->supported_rf_interfaces, 75 74 ndev->num_supported_rf_interfaces); 76 75 77 - rsp_2 = (void *) (skb->data + 6 + ndev->num_supported_rf_interfaces); 76 + rsp_2 = (void *) (skb->data + 6 + rsp_1->num_supported_rf_interfaces); 78 77 79 78 ndev->max_logical_connections = 80 79 rsp_2->max_logical_connections; 81 80 ndev->max_routing_table_size = 82 81 __le16_to_cpu(rsp_2->max_routing_table_size); 83 - ndev->max_control_packet_payload_length = 84 - rsp_2->max_control_packet_payload_length; 85 - ndev->rf_sending_buffer_size = 86 - __le16_to_cpu(rsp_2->rf_sending_buffer_size); 87 - ndev->rf_receiving_buffer_size = 88 - __le16_to_cpu(rsp_2->rf_receiving_buffer_size); 89 - ndev->manufacturer_id = 90 - __le16_to_cpu(rsp_2->manufacturer_id); 82 + ndev->max_ctrl_pkt_payload_len = 83 + rsp_2->max_ctrl_pkt_payload_len; 84 + ndev->max_size_for_large_params = 85 + __le16_to_cpu(rsp_2->max_size_for_large_params); 86 + ndev->max_data_pkt_payload_size = 87 + rsp_2->max_data_pkt_payload_size; 88 + ndev->initial_num_credits = 89 + rsp_2->initial_num_credits; 90 + ndev->manufact_id = 91 + rsp_2->manufact_id; 92 + ndev->manufact_specific_info = 93 + __le32_to_cpu(rsp_2->manufact_specific_info); 94 + 95 + atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); 91 96 92 97 nfc_dbg("nfcc_features 0x%x", 93 98 ndev->nfcc_features); ··· 111 104 ndev->max_logical_connections); 112 105 nfc_dbg("max_routing_table_size %d", 113 106 ndev->max_routing_table_size); 114 - nfc_dbg("max_control_packet_payload_length %d", 115 - ndev->max_control_packet_payload_length); 116 - nfc_dbg("rf_sending_buffer_size %d", 117 - ndev->rf_sending_buffer_size); 118 - nfc_dbg("rf_receiving_buffer_size %d", 119 - ndev->rf_receiving_buffer_size); 120 - nfc_dbg("manufacturer_id 0x%x", 121 - ndev->manufacturer_id); 107 + nfc_dbg("max_ctrl_pkt_payload_len %d", 108 + ndev->max_ctrl_pkt_payload_len); 109 + nfc_dbg("max_size_for_large_params %d", 110 + ndev->max_size_for_large_params); 111 + nfc_dbg("max_data_pkt_payload_size %d", 112 + ndev->max_data_pkt_payload_size); 113 + nfc_dbg("initial_num_credits %d", 114 + ndev->initial_num_credits); 115 + nfc_dbg("manufact_id 0x%x", 116 + ndev->manufact_id); 117 + nfc_dbg("manufact_specific_info 0x%x", 118 + ndev->manufact_specific_info); 122 119 120 + exit: 123 121 nci_req_complete(ndev, rsp_1->status); 124 - } 125 - 126 - static void nci_core_conn_create_rsp_packet(struct nci_dev *ndev, 127 - struct sk_buff *skb) 128 - { 129 - struct nci_core_conn_create_rsp *rsp = (void *) skb->data; 130 - 131 - nfc_dbg("entry, status 0x%x", rsp->status); 132 - 133 - if (rsp->status != NCI_STATUS_OK) 134 - return; 135 - 136 - ndev->max_pkt_payload_size = rsp->max_pkt_payload_size; 137 - ndev->initial_num_credits = rsp->initial_num_credits; 138 - ndev->conn_id = rsp->conn_id; 139 - 140 - atomic_set(&ndev->credits_cnt, ndev->initial_num_credits); 141 - 142 - nfc_dbg("max_pkt_payload_size %d", ndev->max_pkt_payload_size); 143 - nfc_dbg("initial_num_credits %d", ndev->initial_num_credits); 144 - nfc_dbg("conn_id %d", ndev->conn_id); 145 122 } 146 123 147 124 static void nci_rf_disc_map_rsp_packet(struct nci_dev *ndev, ··· 185 194 186 195 case NCI_OP_CORE_INIT_RSP: 187 196 nci_core_init_rsp_packet(ndev, skb); 188 - break; 189 - 190 - case NCI_OP_CORE_CONN_CREATE_RSP: 191 - nci_core_conn_create_rsp_packet(ndev, skb); 192 197 break; 193 198 194 199 case NCI_OP_RF_DISCOVER_MAP_RSP:
+2 -2
net/rfkill/core.c
··· 644 644 if (!capable(CAP_NET_ADMIN)) 645 645 return -EPERM; 646 646 647 - err = strict_strtoul(buf, 0, &state); 647 + err = kstrtoul(buf, 0, &state); 648 648 if (err) 649 649 return err; 650 650 ··· 688 688 if (!capable(CAP_NET_ADMIN)) 689 689 return -EPERM; 690 690 691 - err = strict_strtoul(buf, 0, &state); 691 + err = kstrtoul(buf, 0, &state); 692 692 if (err) 693 693 return err; 694 694
+18
net/socket.c
··· 538 538 *tx_flags |= SKBTX_HW_TSTAMP; 539 539 if (sock_flag(sk, SOCK_TIMESTAMPING_TX_SOFTWARE)) 540 540 *tx_flags |= SKBTX_SW_TSTAMP; 541 + if (sock_flag(sk, SOCK_WIFI_STATUS)) 542 + *tx_flags |= SKBTX_WIFI_STATUS; 541 543 return 0; 542 544 } 543 545 EXPORT_SYMBOL(sock_tx_timestamp); ··· 675 673 SCM_TIMESTAMPING, sizeof(ts), &ts); 676 674 } 677 675 EXPORT_SYMBOL_GPL(__sock_recv_timestamp); 676 + 677 + void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, 678 + struct sk_buff *skb) 679 + { 680 + int ack; 681 + 682 + if (!sock_flag(sk, SOCK_WIFI_STATUS)) 683 + return; 684 + if (!skb->wifi_acked_valid) 685 + return; 686 + 687 + ack = skb->wifi_acked; 688 + 689 + put_cmsg(msg, SOL_SOCKET, SCM_WIFI_STATUS, sizeof(ack), &ack); 690 + } 691 + EXPORT_SYMBOL_GPL(__sock_recv_wifi_status); 678 692 679 693 static inline void sock_recv_drops(struct msghdr *msg, struct sock *sk, 680 694 struct sk_buff *skb)
+4
net/wireless/core.c
··· 492 492 !(wiphy->wowlan.flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY))) 493 493 return -EINVAL; 494 494 495 + if (WARN_ON(wiphy->ap_sme_capa && 496 + !(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME))) 497 + return -EINVAL; 498 + 495 499 if (WARN_ON(wiphy->addresses && !wiphy->n_addresses)) 496 500 return -EINVAL; 497 501
+3 -1
net/wireless/core.h
··· 54 54 int opencount; /* also protected by devlist_mtx */ 55 55 wait_queue_head_t dev_wait; 56 56 57 + u32 ap_beacons_nlpid; 58 + 57 59 /* BSSes/scanning */ 58 60 spinlock_t bss_lock; 59 61 struct list_head bss_list; ··· 378 376 enum nl80211_channel_type channel_type, 379 377 bool channel_type_valid, unsigned int wait, 380 378 const u8 *buf, size_t len, bool no_cck, 381 - u64 *cookie); 379 + bool dont_wait_for_ack, u64 *cookie); 382 380 383 381 /* SME */ 384 382 int __cfg80211_connect(struct cfg80211_registered_device *rdev,
+33 -2
net/wireless/mlme.c
··· 879 879 } 880 880 881 881 spin_unlock_bh(&wdev->mgmt_registrations_lock); 882 + 883 + if (nlpid == wdev->ap_unexpected_nlpid) 884 + wdev->ap_unexpected_nlpid = 0; 882 885 } 883 886 884 887 void cfg80211_mlme_purge_registrations(struct wireless_dev *wdev) ··· 904 901 enum nl80211_channel_type channel_type, 905 902 bool channel_type_valid, unsigned int wait, 906 903 const u8 *buf, size_t len, bool no_cck, 907 - u64 *cookie) 904 + bool dont_wait_for_ack, u64 *cookie) 908 905 { 909 906 struct wireless_dev *wdev = dev->ieee80211_ptr; 910 907 const struct ieee80211_mgmt *mgmt; ··· 995 992 /* Transmit the Action frame as requested by user space */ 996 993 return rdev->ops->mgmt_tx(&rdev->wiphy, dev, chan, offchan, 997 994 channel_type, channel_type_valid, 998 - wait, buf, len, no_cck, cookie); 995 + wait, buf, len, no_cck, dont_wait_for_ack, 996 + cookie); 999 997 } 1000 998 1001 999 bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf, ··· 1111 1107 nl80211_pmksa_candidate_notify(rdev, dev, index, bssid, preauth, gfp); 1112 1108 } 1113 1109 EXPORT_SYMBOL(cfg80211_pmksa_candidate_notify); 1110 + 1111 + bool cfg80211_rx_spurious_frame(struct net_device *dev, 1112 + const u8 *addr, gfp_t gfp) 1113 + { 1114 + struct wireless_dev *wdev = dev->ieee80211_ptr; 1115 + 1116 + if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 1117 + wdev->iftype != NL80211_IFTYPE_P2P_GO)) 1118 + return false; 1119 + 1120 + return nl80211_unexpected_frame(dev, addr, gfp); 1121 + } 1122 + EXPORT_SYMBOL(cfg80211_rx_spurious_frame); 1123 + 1124 + bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, 1125 + const u8 *addr, gfp_t gfp) 1126 + { 1127 + struct wireless_dev *wdev = dev->ieee80211_ptr; 1128 + 1129 + if (WARN_ON(wdev->iftype != NL80211_IFTYPE_AP && 1130 + wdev->iftype != NL80211_IFTYPE_P2P_GO && 1131 + wdev->iftype != NL80211_IFTYPE_AP_VLAN)) 1132 + return false; 1133 + 1134 + return nl80211_unexpected_4addr_frame(dev, addr, gfp); 1135 + } 1136 + EXPORT_SYMBOL(cfg80211_rx_unexpected_4addr_frame);
+323 -96
net/wireless/nl80211.c
··· 98 98 [NL80211_ATTR_KEY_IDX] = { .type = NLA_U8 }, 99 99 [NL80211_ATTR_KEY_CIPHER] = { .type = NLA_U32 }, 100 100 [NL80211_ATTR_KEY_DEFAULT] = { .type = NLA_FLAG }, 101 - [NL80211_ATTR_KEY_SEQ] = { .type = NLA_BINARY, .len = 8 }, 101 + [NL80211_ATTR_KEY_SEQ] = { .type = NLA_BINARY, .len = 16 }, 102 102 [NL80211_ATTR_KEY_TYPE] = { .type = NLA_U32 }, 103 103 104 104 [NL80211_ATTR_BEACON_INTERVAL] = { .type = NLA_U32 }, ··· 132 132 [NL80211_ATTR_MESH_CONFIG] = { .type = NLA_NESTED }, 133 133 [NL80211_ATTR_SUPPORT_MESH_AUTH] = { .type = NLA_FLAG }, 134 134 135 - [NL80211_ATTR_HT_CAPABILITY] = { .type = NLA_BINARY, 136 - .len = NL80211_HT_CAPABILITY_LEN }, 135 + [NL80211_ATTR_HT_CAPABILITY] = { .len = NL80211_HT_CAPABILITY_LEN }, 137 136 138 137 [NL80211_ATTR_MGMT_SUBTYPE] = { .type = NLA_U8 }, 139 138 [NL80211_ATTR_IE] = { .type = NLA_BINARY, ··· 196 197 [NL80211_ATTR_TDLS_OPERATION] = { .type = NLA_U8 }, 197 198 [NL80211_ATTR_TDLS_SUPPORT] = { .type = NLA_FLAG }, 198 199 [NL80211_ATTR_TDLS_EXTERNAL_SETUP] = { .type = NLA_FLAG }, 200 + [NL80211_ATTR_DONT_WAIT_FOR_ACK] = { .type = NLA_FLAG }, 201 + [NL80211_ATTR_PROBE_RESP] = { .type = NLA_BINARY, 202 + .len = IEEE80211_MAX_DATA_LEN }, 199 203 }; 200 204 201 205 /* policy for the key attributes */ ··· 206 204 [NL80211_KEY_DATA] = { .type = NLA_BINARY, .len = WLAN_MAX_KEY_LEN }, 207 205 [NL80211_KEY_IDX] = { .type = NLA_U8 }, 208 206 [NL80211_KEY_CIPHER] = { .type = NLA_U32 }, 209 - [NL80211_KEY_SEQ] = { .type = NLA_BINARY, .len = 8 }, 207 + [NL80211_KEY_SEQ] = { .type = NLA_BINARY, .len = 16 }, 210 208 [NL80211_KEY_DEFAULT] = { .type = NLA_FLAG }, 211 209 [NL80211_KEY_DEFAULT_MGMT] = { .type = NLA_FLAG }, 212 210 [NL80211_KEY_TYPE] = { .type = NLA_U32 }, ··· 761 759 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX, 762 760 dev->wiphy.available_antennas_rx); 763 761 762 + if (dev->wiphy.flags & WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD) 763 + NLA_PUT_U32(msg, NL80211_ATTR_PROBE_RESP_OFFLOAD, 764 + dev->wiphy.probe_resp_offload); 765 + 764 766 if ((dev->wiphy.available_antennas_tx || 765 767 dev->wiphy.available_antennas_rx) && dev->ops->get_antenna) { 766 768 u32 tx_ant = 0, rx_ant = 0; ··· 897 891 } 898 892 if (dev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) 899 893 CMD(sched_scan_start, START_SCHED_SCAN); 894 + CMD(probe_client, PROBE_CLIENT); 895 + if (dev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS) { 896 + i++; 897 + NLA_PUT_U32(msg, i, NL80211_CMD_REGISTER_BEACONS); 898 + } 900 899 901 900 #undef CMD 902 901 ··· 1018 1007 1019 1008 if (nl80211_put_iface_combinations(&dev->wiphy, msg)) 1020 1009 goto nla_put_failure; 1010 + 1011 + if (dev->wiphy.flags & WIPHY_FLAG_HAVE_AP_SME) 1012 + NLA_PUT_U32(msg, NL80211_ATTR_DEVICE_AP_SME, 1013 + dev->wiphy.ap_sme_capa); 1014 + 1015 + NLA_PUT_U32(msg, NL80211_ATTR_FEATURE_FLAGS, dev->wiphy.features); 1021 1016 1022 1017 return genlmsg_end(msg, hdr); 1023 1018 ··· 1266 1249 } 1267 1250 1268 1251 if (!netdev) { 1252 + result = -EINVAL; 1253 + goto bad_res; 1254 + } 1255 + 1256 + if (netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && 1257 + netdev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) { 1269 1258 result = -EINVAL; 1270 1259 goto bad_res; 1271 1260 } ··· 2171 2148 nla_data(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]); 2172 2149 params.assocresp_ies_len = 2173 2150 nla_len(info->attrs[NL80211_ATTR_IE_ASSOC_RESP]); 2151 + } 2152 + 2153 + if (info->attrs[NL80211_ATTR_PROBE_RESP]) { 2154 + params.probe_resp = 2155 + nla_data(info->attrs[NL80211_ATTR_PROBE_RESP]); 2156 + params.probe_resp_len = 2157 + nla_len(info->attrs[NL80211_ATTR_PROBE_RESP]); 2174 2158 } 2175 2159 2176 2160 err = call(&rdev->wiphy, dev, &params); ··· 5296 5266 bool channel_type_valid = false; 5297 5267 u32 freq; 5298 5268 int err; 5299 - void *hdr; 5269 + void *hdr = NULL; 5300 5270 u64 cookie; 5301 - struct sk_buff *msg; 5271 + struct sk_buff *msg = NULL; 5302 5272 unsigned int wait = 0; 5303 - bool offchan; 5304 - bool no_cck; 5273 + bool offchan, no_cck, dont_wait_for_ack; 5274 + 5275 + dont_wait_for_ack = info->attrs[NL80211_ATTR_DONT_WAIT_FOR_ACK]; 5305 5276 5306 5277 if (!info->attrs[NL80211_ATTR_FRAME] || 5307 5278 !info->attrs[NL80211_ATTR_WIPHY_FREQ]) ··· 5346 5315 if (chan == NULL) 5347 5316 return -EINVAL; 5348 5317 5349 - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 5350 - if (!msg) 5351 - return -ENOMEM; 5318 + if (!dont_wait_for_ack) { 5319 + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 5320 + if (!msg) 5321 + return -ENOMEM; 5352 5322 5353 - hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, 5354 - NL80211_CMD_FRAME); 5323 + hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, 5324 + NL80211_CMD_FRAME); 5355 5325 5356 - if (IS_ERR(hdr)) { 5357 - err = PTR_ERR(hdr); 5358 - goto free_msg; 5326 + if (IS_ERR(hdr)) { 5327 + err = PTR_ERR(hdr); 5328 + goto free_msg; 5329 + } 5359 5330 } 5331 + 5360 5332 err = cfg80211_mlme_mgmt_tx(rdev, dev, chan, offchan, channel_type, 5361 5333 channel_type_valid, wait, 5362 5334 nla_data(info->attrs[NL80211_ATTR_FRAME]), 5363 5335 nla_len(info->attrs[NL80211_ATTR_FRAME]), 5364 - no_cck, &cookie); 5336 + no_cck, dont_wait_for_ack, &cookie); 5365 5337 if (err) 5366 5338 goto free_msg; 5367 5339 5368 - NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); 5340 + if (msg) { 5341 + NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); 5369 5342 5370 - genlmsg_end(msg, hdr); 5371 - return genlmsg_reply(msg, info); 5343 + genlmsg_end(msg, hdr); 5344 + return genlmsg_reply(msg, info); 5345 + } 5346 + 5347 + return 0; 5372 5348 5373 5349 nla_put_failure: 5374 5350 err = -ENOBUFS; ··· 5863 5825 out: 5864 5826 wdev_unlock(wdev); 5865 5827 return err; 5828 + } 5829 + 5830 + static int nl80211_register_unexpected_frame(struct sk_buff *skb, 5831 + struct genl_info *info) 5832 + { 5833 + struct net_device *dev = info->user_ptr[1]; 5834 + struct wireless_dev *wdev = dev->ieee80211_ptr; 5835 + 5836 + if (wdev->iftype != NL80211_IFTYPE_AP && 5837 + wdev->iftype != NL80211_IFTYPE_P2P_GO) 5838 + return -EINVAL; 5839 + 5840 + if (wdev->ap_unexpected_nlpid) 5841 + return -EBUSY; 5842 + 5843 + wdev->ap_unexpected_nlpid = info->snd_pid; 5844 + return 0; 5845 + } 5846 + 5847 + static int nl80211_probe_client(struct sk_buff *skb, 5848 + struct genl_info *info) 5849 + { 5850 + struct cfg80211_registered_device *rdev = info->user_ptr[0]; 5851 + struct net_device *dev = info->user_ptr[1]; 5852 + struct wireless_dev *wdev = dev->ieee80211_ptr; 5853 + struct sk_buff *msg; 5854 + void *hdr; 5855 + const u8 *addr; 5856 + u64 cookie; 5857 + int err; 5858 + 5859 + if (wdev->iftype != NL80211_IFTYPE_AP && 5860 + wdev->iftype != NL80211_IFTYPE_P2P_GO) 5861 + return -EOPNOTSUPP; 5862 + 5863 + if (!info->attrs[NL80211_ATTR_MAC]) 5864 + return -EINVAL; 5865 + 5866 + if (!rdev->ops->probe_client) 5867 + return -EOPNOTSUPP; 5868 + 5869 + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); 5870 + if (!msg) 5871 + return -ENOMEM; 5872 + 5873 + hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0, 5874 + NL80211_CMD_PROBE_CLIENT); 5875 + 5876 + if (IS_ERR(hdr)) { 5877 + err = PTR_ERR(hdr); 5878 + goto free_msg; 5879 + } 5880 + 5881 + addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 5882 + 5883 + err = rdev->ops->probe_client(&rdev->wiphy, dev, addr, &cookie); 5884 + if (err) 5885 + goto free_msg; 5886 + 5887 + NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); 5888 + 5889 + genlmsg_end(msg, hdr); 5890 + 5891 + return genlmsg_reply(msg, info); 5892 + 5893 + nla_put_failure: 5894 + err = -ENOBUFS; 5895 + free_msg: 5896 + nlmsg_free(msg); 5897 + return err; 5898 + } 5899 + 5900 + static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info) 5901 + { 5902 + struct cfg80211_registered_device *rdev = info->user_ptr[0]; 5903 + 5904 + if (!(rdev->wiphy.flags & WIPHY_FLAG_REPORTS_OBSS)) 5905 + return -EOPNOTSUPP; 5906 + 5907 + if (rdev->ap_beacons_nlpid) 5908 + return -EBUSY; 5909 + 5910 + rdev->ap_beacons_nlpid = info->snd_pid; 5911 + 5912 + return 0; 5866 5913 } 5867 5914 5868 5915 #define NL80211_FLAG_NEED_WIPHY 0x01 ··· 6505 6382 .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | 6506 6383 NL80211_FLAG_NEED_RTNL, 6507 6384 }, 6385 + { 6386 + .cmd = NL80211_CMD_UNEXPECTED_FRAME, 6387 + .doit = nl80211_register_unexpected_frame, 6388 + .policy = nl80211_policy, 6389 + .flags = GENL_ADMIN_PERM, 6390 + .internal_flags = NL80211_FLAG_NEED_NETDEV | 6391 + NL80211_FLAG_NEED_RTNL, 6392 + }, 6393 + { 6394 + .cmd = NL80211_CMD_PROBE_CLIENT, 6395 + .doit = nl80211_probe_client, 6396 + .policy = nl80211_policy, 6397 + .flags = GENL_ADMIN_PERM, 6398 + .internal_flags = NL80211_FLAG_NEED_NETDEV | 6399 + NL80211_FLAG_NEED_RTNL, 6400 + }, 6401 + { 6402 + .cmd = NL80211_CMD_REGISTER_BEACONS, 6403 + .doit = nl80211_register_beacons, 6404 + .policy = nl80211_policy, 6405 + .flags = GENL_ADMIN_PERM, 6406 + .internal_flags = NL80211_FLAG_NEED_WIPHY | 6407 + NL80211_FLAG_NEED_RTNL, 6408 + }, 6508 6409 }; 6509 6410 6510 6411 static struct genl_multicast_group nl80211_mlme_mcgrp = { ··· 6781 6634 if (wiphy_idx_valid(request->wiphy_idx)) 6782 6635 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, request->wiphy_idx); 6783 6636 6784 - if (genlmsg_end(msg, hdr) < 0) { 6785 - nlmsg_free(msg); 6786 - return; 6787 - } 6637 + genlmsg_end(msg, hdr); 6788 6638 6789 6639 rcu_read_lock(); 6790 6640 genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id, ··· 6817 6673 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); 6818 6674 NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); 6819 6675 6820 - if (genlmsg_end(msg, hdr) < 0) { 6821 - nlmsg_free(msg); 6822 - return; 6823 - } 6676 + genlmsg_end(msg, hdr); 6824 6677 6825 6678 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 6826 6679 nl80211_mlme_mcgrp.id, gfp); ··· 6898 6757 NLA_PUT_FLAG(msg, NL80211_ATTR_TIMED_OUT); 6899 6758 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); 6900 6759 6901 - if (genlmsg_end(msg, hdr) < 0) { 6902 - nlmsg_free(msg); 6903 - return; 6904 - } 6760 + genlmsg_end(msg, hdr); 6905 6761 6906 6762 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 6907 6763 nl80211_mlme_mcgrp.id, gfp); ··· 6954 6816 if (resp_ie) 6955 6817 NLA_PUT(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie); 6956 6818 6957 - if (genlmsg_end(msg, hdr) < 0) { 6958 - nlmsg_free(msg); 6959 - return; 6960 - } 6819 + genlmsg_end(msg, hdr); 6961 6820 6962 6821 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 6963 6822 nl80211_mlme_mcgrp.id, gfp); ··· 6992 6857 if (resp_ie) 6993 6858 NLA_PUT(msg, NL80211_ATTR_RESP_IE, resp_ie_len, resp_ie); 6994 6859 6995 - if (genlmsg_end(msg, hdr) < 0) { 6996 - nlmsg_free(msg); 6997 - return; 6998 - } 6860 + genlmsg_end(msg, hdr); 6999 6861 7000 6862 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7001 6863 nl80211_mlme_mcgrp.id, gfp); ··· 7030 6898 if (ie) 7031 6899 NLA_PUT(msg, NL80211_ATTR_IE, ie_len, ie); 7032 6900 7033 - if (genlmsg_end(msg, hdr) < 0) { 7034 - nlmsg_free(msg); 7035 - return; 7036 - } 6901 + genlmsg_end(msg, hdr); 7037 6902 7038 6903 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7039 6904 nl80211_mlme_mcgrp.id, GFP_KERNEL); ··· 7063 6934 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); 7064 6935 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, bssid); 7065 6936 7066 - if (genlmsg_end(msg, hdr) < 0) { 7067 - nlmsg_free(msg); 7068 - return; 7069 - } 6937 + genlmsg_end(msg, hdr); 7070 6938 7071 6939 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7072 6940 nl80211_mlme_mcgrp.id, gfp); ··· 7098 6972 if (ie_len && ie) 7099 6973 NLA_PUT(msg, NL80211_ATTR_IE, ie_len , ie); 7100 6974 7101 - if (genlmsg_end(msg, hdr) < 0) { 7102 - nlmsg_free(msg); 7103 - return; 7104 - } 6975 + genlmsg_end(msg, hdr); 7105 6976 7106 6977 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7107 6978 nl80211_mlme_mcgrp.id, gfp); ··· 7137 7014 if (tsc) 7138 7015 NLA_PUT(msg, NL80211_ATTR_KEY_SEQ, 6, tsc); 7139 7016 7140 - if (genlmsg_end(msg, hdr) < 0) { 7141 - nlmsg_free(msg); 7142 - return; 7143 - } 7017 + genlmsg_end(msg, hdr); 7144 7018 7145 7019 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7146 7020 nl80211_mlme_mcgrp.id, gfp); ··· 7188 7068 goto nla_put_failure; 7189 7069 nla_nest_end(msg, nl_freq); 7190 7070 7191 - if (genlmsg_end(msg, hdr) < 0) { 7192 - nlmsg_free(msg); 7193 - return; 7194 - } 7071 + genlmsg_end(msg, hdr); 7195 7072 7196 7073 rcu_read_lock(); 7197 7074 genlmsg_multicast_allns(msg, 0, nl80211_regulatory_mcgrp.id, ··· 7231 7114 if (cmd == NL80211_CMD_REMAIN_ON_CHANNEL) 7232 7115 NLA_PUT_U32(msg, NL80211_ATTR_DURATION, duration); 7233 7116 7234 - if (genlmsg_end(msg, hdr) < 0) { 7235 - nlmsg_free(msg); 7236 - return; 7237 - } 7117 + genlmsg_end(msg, hdr); 7238 7118 7239 7119 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7240 7120 nl80211_mlme_mcgrp.id, gfp); ··· 7302 7188 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); 7303 7189 NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr); 7304 7190 7305 - if (genlmsg_end(msg, hdr) < 0) { 7306 - nlmsg_free(msg); 7307 - return; 7308 - } 7191 + genlmsg_end(msg, hdr); 7309 7192 7310 7193 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7311 7194 nl80211_mlme_mcgrp.id, gfp); ··· 7313 7202 nlmsg_free(msg); 7314 7203 } 7315 7204 7205 + static bool __nl80211_unexpected_frame(struct net_device *dev, u8 cmd, 7206 + const u8 *addr, gfp_t gfp) 7207 + { 7208 + struct wireless_dev *wdev = dev->ieee80211_ptr; 7209 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 7210 + struct sk_buff *msg; 7211 + void *hdr; 7212 + int err; 7213 + u32 nlpid = ACCESS_ONCE(wdev->ap_unexpected_nlpid); 7214 + 7215 + if (!nlpid) 7216 + return false; 7217 + 7218 + msg = nlmsg_new(100, gfp); 7219 + if (!msg) 7220 + return true; 7221 + 7222 + hdr = nl80211hdr_put(msg, 0, 0, 0, cmd); 7223 + if (!hdr) { 7224 + nlmsg_free(msg); 7225 + return true; 7226 + } 7227 + 7228 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); 7229 + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); 7230 + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); 7231 + 7232 + err = genlmsg_end(msg, hdr); 7233 + if (err < 0) { 7234 + nlmsg_free(msg); 7235 + return true; 7236 + } 7237 + 7238 + genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlpid); 7239 + return true; 7240 + 7241 + nla_put_failure: 7242 + genlmsg_cancel(msg, hdr); 7243 + nlmsg_free(msg); 7244 + return true; 7245 + } 7246 + 7247 + bool nl80211_unexpected_frame(struct net_device *dev, const u8 *addr, gfp_t gfp) 7248 + { 7249 + return __nl80211_unexpected_frame(dev, NL80211_CMD_UNEXPECTED_FRAME, 7250 + addr, gfp); 7251 + } 7252 + 7253 + bool nl80211_unexpected_4addr_frame(struct net_device *dev, 7254 + const u8 *addr, gfp_t gfp) 7255 + { 7256 + return __nl80211_unexpected_frame(dev, 7257 + NL80211_CMD_UNEXPECTED_4ADDR_FRAME, 7258 + addr, gfp); 7259 + } 7260 + 7316 7261 int nl80211_send_mgmt(struct cfg80211_registered_device *rdev, 7317 7262 struct net_device *netdev, u32 nlpid, 7318 7263 int freq, const u8 *buf, size_t len, gfp_t gfp) 7319 7264 { 7320 7265 struct sk_buff *msg; 7321 7266 void *hdr; 7322 - int err; 7323 7267 7324 7268 msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); 7325 7269 if (!msg) ··· 7391 7225 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); 7392 7226 NLA_PUT(msg, NL80211_ATTR_FRAME, len, buf); 7393 7227 7394 - err = genlmsg_end(msg, hdr); 7395 - if (err < 0) { 7396 - nlmsg_free(msg); 7397 - return err; 7398 - } 7228 + genlmsg_end(msg, hdr); 7399 7229 7400 - err = genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlpid); 7401 - if (err < 0) 7402 - return err; 7403 - return 0; 7230 + return genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlpid); 7404 7231 7405 7232 nla_put_failure: 7406 7233 genlmsg_cancel(msg, hdr); ··· 7426 7267 if (ack) 7427 7268 NLA_PUT_FLAG(msg, NL80211_ATTR_ACK); 7428 7269 7429 - if (genlmsg_end(msg, hdr) < 0) { 7430 - nlmsg_free(msg); 7431 - return; 7432 - } 7270 + genlmsg_end(msg, hdr); 7433 7271 7434 7272 genlmsg_multicast(msg, 0, nl80211_mlme_mcgrp.id, gfp); 7435 7273 return; ··· 7468 7312 7469 7313 nla_nest_end(msg, pinfoattr); 7470 7314 7471 - if (genlmsg_end(msg, hdr) < 0) { 7472 - nlmsg_free(msg); 7473 - return; 7474 - } 7315 + genlmsg_end(msg, hdr); 7475 7316 7476 7317 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7477 7318 nl80211_mlme_mcgrp.id, gfp); ··· 7510 7357 7511 7358 nla_nest_end(msg, rekey_attr); 7512 7359 7513 - if (genlmsg_end(msg, hdr) < 0) { 7514 - nlmsg_free(msg); 7515 - return; 7516 - } 7360 + genlmsg_end(msg, hdr); 7517 7361 7518 7362 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7519 7363 nl80211_mlme_mcgrp.id, gfp); ··· 7553 7403 7554 7404 nla_nest_end(msg, attr); 7555 7405 7556 - if (genlmsg_end(msg, hdr) < 0) { 7557 - nlmsg_free(msg); 7558 - return; 7559 - } 7406 + genlmsg_end(msg, hdr); 7560 7407 7561 7408 genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7562 7409 nl80211_mlme_mcgrp.id, gfp); ··· 7595 7448 7596 7449 nla_nest_end(msg, pinfoattr); 7597 7450 7598 - if (genlmsg_end(msg, hdr) < 0) { 7451 + genlmsg_end(msg, hdr); 7452 + 7453 + genlmsg_multicast_netns(wiphy_net(&rdev->wiphy), msg, 0, 7454 + nl80211_mlme_mcgrp.id, gfp); 7455 + return; 7456 + 7457 + nla_put_failure: 7458 + genlmsg_cancel(msg, hdr); 7459 + nlmsg_free(msg); 7460 + } 7461 + 7462 + void cfg80211_probe_status(struct net_device *dev, const u8 *addr, 7463 + u64 cookie, bool acked, gfp_t gfp) 7464 + { 7465 + struct wireless_dev *wdev = dev->ieee80211_ptr; 7466 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 7467 + struct sk_buff *msg; 7468 + void *hdr; 7469 + int err; 7470 + 7471 + msg = nlmsg_new(NLMSG_GOODSIZE, gfp); 7472 + if (!msg) 7473 + return; 7474 + 7475 + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_PROBE_CLIENT); 7476 + if (!hdr) { 7477 + nlmsg_free(msg); 7478 + return; 7479 + } 7480 + 7481 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); 7482 + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex); 7483 + NLA_PUT(msg, NL80211_ATTR_MAC, ETH_ALEN, addr); 7484 + NLA_PUT_U64(msg, NL80211_ATTR_COOKIE, cookie); 7485 + if (acked) 7486 + NLA_PUT_FLAG(msg, NL80211_ATTR_ACK); 7487 + 7488 + err = genlmsg_end(msg, hdr); 7489 + if (err < 0) { 7599 7490 nlmsg_free(msg); 7600 7491 return; 7601 7492 } ··· 7646 7461 genlmsg_cancel(msg, hdr); 7647 7462 nlmsg_free(msg); 7648 7463 } 7464 + EXPORT_SYMBOL(cfg80211_probe_status); 7465 + 7466 + void cfg80211_report_obss_beacon(struct wiphy *wiphy, 7467 + const u8 *frame, size_t len, 7468 + int freq, gfp_t gfp) 7469 + { 7470 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy); 7471 + struct sk_buff *msg; 7472 + void *hdr; 7473 + u32 nlpid = ACCESS_ONCE(rdev->ap_beacons_nlpid); 7474 + 7475 + if (!nlpid) 7476 + return; 7477 + 7478 + msg = nlmsg_new(len + 100, gfp); 7479 + if (!msg) 7480 + return; 7481 + 7482 + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FRAME); 7483 + if (!hdr) { 7484 + nlmsg_free(msg); 7485 + return; 7486 + } 7487 + 7488 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); 7489 + if (freq) 7490 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq); 7491 + NLA_PUT(msg, NL80211_ATTR_FRAME, len, frame); 7492 + 7493 + genlmsg_end(msg, hdr); 7494 + 7495 + genlmsg_unicast(wiphy_net(&rdev->wiphy), msg, nlpid); 7496 + return; 7497 + 7498 + nla_put_failure: 7499 + genlmsg_cancel(msg, hdr); 7500 + nlmsg_free(msg); 7501 + } 7502 + EXPORT_SYMBOL(cfg80211_report_obss_beacon); 7649 7503 7650 7504 static int nl80211_netlink_notify(struct notifier_block * nb, 7651 7505 unsigned long state, ··· 7699 7475 7700 7476 rcu_read_lock(); 7701 7477 7702 - list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) 7478 + list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) { 7703 7479 list_for_each_entry_rcu(wdev, &rdev->netdev_list, list) 7704 7480 cfg80211_mlme_unregister_socket(wdev, notify->pid); 7481 + if (rdev->ap_beacons_nlpid == notify->pid) 7482 + rdev->ap_beacons_nlpid = 0; 7483 + } 7705 7484 7706 7485 rcu_read_unlock(); 7707 7486
+5
net/wireless/nl80211.h
··· 117 117 struct net_device *netdev, int index, 118 118 const u8 *bssid, bool preauth, gfp_t gfp); 119 119 120 + bool nl80211_unexpected_frame(struct net_device *dev, 121 + const u8 *addr, gfp_t gfp); 122 + bool nl80211_unexpected_4addr_frame(struct net_device *dev, 123 + const u8 *addr, gfp_t gfp); 124 + 120 125 #endif /* __NET_WIRELESS_NL80211_H */
+122 -8
net/wireless/scan.c
··· 259 259 { 260 260 const u8 *ie1 = cfg80211_find_ie(num, ies1, len1); 261 261 const u8 *ie2 = cfg80211_find_ie(num, ies2, len2); 262 - int r; 263 262 263 + /* equal if both missing */ 264 264 if (!ie1 && !ie2) 265 265 return 0; 266 - if (!ie1 || !ie2) 266 + /* sort missing IE before (left of) present IE */ 267 + if (!ie1) 267 268 return -1; 269 + if (!ie2) 270 + return 1; 268 271 269 - r = memcmp(ie1 + 2, ie2 + 2, min(ie1[1], ie2[1])); 270 - if (r == 0 && ie1[1] != ie2[1]) 272 + /* sort by length first, then by contents */ 273 + if (ie1[1] != ie2[1]) 271 274 return ie2[1] - ie1[1]; 272 - return r; 275 + return memcmp(ie1 + 2, ie2 + 2, ie1[1]); 273 276 } 274 277 275 278 static bool is_bss(struct cfg80211_bss *a, ··· 355 352 sizeof(struct ieee80211_meshconf_ie) - 2) == 0; 356 353 } 357 354 358 - static int cmp_bss(struct cfg80211_bss *a, 359 - struct cfg80211_bss *b) 355 + static int cmp_bss_core(struct cfg80211_bss *a, 356 + struct cfg80211_bss *b) 360 357 { 361 358 int r; 362 359 ··· 378 375 b->len_information_elements); 379 376 } 380 377 381 - r = memcmp(a->bssid, b->bssid, ETH_ALEN); 378 + return memcmp(a->bssid, b->bssid, ETH_ALEN); 379 + } 380 + 381 + static int cmp_bss(struct cfg80211_bss *a, 382 + struct cfg80211_bss *b) 383 + { 384 + int r; 385 + 386 + r = cmp_bss_core(a, b); 382 387 if (r) 383 388 return r; 384 389 ··· 395 384 a->len_information_elements, 396 385 b->information_elements, 397 386 b->len_information_elements); 387 + } 388 + 389 + static int cmp_hidden_bss(struct cfg80211_bss *a, 390 + struct cfg80211_bss *b) 391 + { 392 + const u8 *ie1; 393 + const u8 *ie2; 394 + int i; 395 + int r; 396 + 397 + r = cmp_bss_core(a, b); 398 + if (r) 399 + return r; 400 + 401 + ie1 = cfg80211_find_ie(WLAN_EID_SSID, 402 + a->information_elements, 403 + a->len_information_elements); 404 + ie2 = cfg80211_find_ie(WLAN_EID_SSID, 405 + b->information_elements, 406 + b->len_information_elements); 407 + 408 + /* Key comparator must use same algorithm in any rb-tree 409 + * search function (order is important), otherwise ordering 410 + * of items in the tree is broken and search gives incorrect 411 + * results. This code uses same order as cmp_ies() does. */ 412 + 413 + /* sort missing IE before (left of) present IE */ 414 + if (!ie1) 415 + return -1; 416 + if (!ie2) 417 + return 1; 418 + 419 + /* zero-size SSID is used as an indication of the hidden bss */ 420 + if (!ie2[1]) 421 + return 0; 422 + 423 + /* sort by length first, then by contents */ 424 + if (ie1[1] != ie2[1]) 425 + return ie2[1] - ie1[1]; 426 + 427 + /* zeroed SSID ie is another indication of a hidden bss */ 428 + for (i = 0; i < ie2[1]; i++) 429 + if (ie2[i + 2]) 430 + return -1; 431 + 432 + return 0; 398 433 } 399 434 400 435 struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, ··· 559 502 } 560 503 561 504 static struct cfg80211_internal_bss * 505 + rb_find_hidden_bss(struct cfg80211_registered_device *dev, 506 + struct cfg80211_internal_bss *res) 507 + { 508 + struct rb_node *n = dev->bss_tree.rb_node; 509 + struct cfg80211_internal_bss *bss; 510 + int r; 511 + 512 + while (n) { 513 + bss = rb_entry(n, struct cfg80211_internal_bss, rbn); 514 + r = cmp_hidden_bss(&res->pub, &bss->pub); 515 + 516 + if (r == 0) 517 + return bss; 518 + else if (r < 0) 519 + n = n->rb_left; 520 + else 521 + n = n->rb_right; 522 + } 523 + 524 + return NULL; 525 + } 526 + 527 + static void 528 + copy_hidden_ies(struct cfg80211_internal_bss *res, 529 + struct cfg80211_internal_bss *hidden) 530 + { 531 + if (unlikely(res->pub.beacon_ies)) 532 + return; 533 + if (WARN_ON(!hidden->pub.beacon_ies)) 534 + return; 535 + 536 + res->pub.beacon_ies = kmalloc(hidden->pub.len_beacon_ies, GFP_ATOMIC); 537 + if (unlikely(!res->pub.beacon_ies)) 538 + return; 539 + 540 + res->beacon_ies_allocated = true; 541 + res->pub.len_beacon_ies = hidden->pub.len_beacon_ies; 542 + memcpy(res->pub.beacon_ies, hidden->pub.beacon_ies, 543 + res->pub.len_beacon_ies); 544 + } 545 + 546 + static struct cfg80211_internal_bss * 562 547 cfg80211_bss_update(struct cfg80211_registered_device *dev, 563 548 struct cfg80211_internal_bss *res) 564 549 { ··· 703 604 704 605 kref_put(&res->ref, bss_release); 705 606 } else { 607 + struct cfg80211_internal_bss *hidden; 608 + 609 + /* First check if the beacon is a probe response from 610 + * a hidden bss. If so, copy beacon ies (with nullified 611 + * ssid) into the probe response bss entry (with real ssid). 612 + * It is required basically for PSM implementation 613 + * (probe responses do not contain tim ie) */ 614 + 615 + /* TODO: The code is not trying to update existing probe 616 + * response bss entries when beacon ies are 617 + * getting changed. */ 618 + hidden = rb_find_hidden_bss(dev, res); 619 + if (hidden) 620 + copy_hidden_ies(res, hidden); 621 + 706 622 /* this "consumes" the reference */ 707 623 list_add_tail(&res->list, &dev->bss_list); 708 624 rb_insert_bss(dev, res);
+12
net/wireless/wext-compat.c
··· 819 819 struct iw_freq *freq, char *extra) 820 820 { 821 821 struct wireless_dev *wdev = dev->ieee80211_ptr; 822 + struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); 823 + struct ieee80211_channel *chan; 822 824 823 825 switch (wdev->iftype) { 824 826 case NL80211_IFTYPE_STATION: 825 827 return cfg80211_mgd_wext_giwfreq(dev, info, freq, extra); 826 828 case NL80211_IFTYPE_ADHOC: 827 829 return cfg80211_ibss_wext_giwfreq(dev, info, freq, extra); 830 + case NL80211_IFTYPE_MONITOR: 831 + if (!rdev->ops->get_channel) 832 + return -EINVAL; 833 + 834 + chan = rdev->ops->get_channel(wdev->wiphy); 835 + if (!chan) 836 + return -EINVAL; 837 + freq->m = chan->center_freq; 838 + freq->e = 6; 839 + return 0; 828 840 default: 829 841 if (!wdev->channel) 830 842 return -EINVAL;