History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

Pull more networking updates from David Miller: "Ok, everything from here on out will be bug fixes." 1) One final sync of wireless and bluetooth stuff from John Linville. These changes have all been in his tree for more than a week, and therefore have had the necessary -next exposure. John was just away on a trip and didn't have a change to send the pull request until a day or two ago. 2) Put back some defines in user exposed header file areas that were removed during the tokenring purge. From Stephen Hemminger and Paul Gortmaker. 3) A bug fix for UDP hash table allocation got lost in the pile due to one of those "you got it.. no I've got it.." situations. :-) From Tim Bird. 4) SKB coalescing in TCP needs to have stricter checks, otherwise we'll try to coalesce overlapping frags and crash. Fix from Eric Dumazet. 5) RCU routing table lookups can race with free_fib_info(), causing crashes when we deref the device pointers in the route. Fix by releasing the net device in the RCU callback. From Yanmin Zhang. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (293 commits) tcp: take care of overlaps in tcp_try_coalesce() ipv4: fix the rcu race between free_fib_info and ip_route_output_slow mm: add a low limit to alloc_large_system_hash ipx: restore token ring define to include/linux/ipx.h if: restore token ring ARP type to header xen: do not disable netfront in dom0 phy/micrel: Fix ID of KSZ9021 mISDN: Add X-Tensions USB ISDN TA XC-525 gianfar:don't add FCB length to hard_header_len Bluetooth: Report proper error number in disconnection Bluetooth: Create flags for bt_sk() Bluetooth: report the right security level in getsockopt Bluetooth: Lock the L2CAP channel when sending Bluetooth: Restore locking semantics when looking up L2CAP channels Bluetooth: Fix a redundant and problematic incoming MTU check Bluetooth: Add support for Foxconn/Hon Hai AR5BBU22 0489:E03C Bluetooth: Fix EIR data generation for mgmt_device_found Bluetooth: Fix Inquiry with RSSI event mask Bluetooth: improve readability of l2cap_seq_list code Bluetooth: Fix skb length calculation ...

Linus Torvalds committed 14 years ago

Commit 28f3d712 parents 654443e 1ca7ee3189 files · +6665 −5539Browse files

Unified · Split

189 files
  1. Documentation/feature-removal-schedule.txt +12 −0
  2. Documentation/nfc/nfc-hci.txt +35 −10
  3. arch/mips/bcm47xx/setup.c +7 −8
  4. arch/mips/bcm47xx/sprom.c +26 −2
  5. arch/mips/include/asm/mach-bcm47xx/bcm47xx.h +9 −0
  6. drivers/bcma/core.c +2 −1
  7. drivers/bcma/driver_pci.c +51 −2
  8. drivers/bcma/driver_pci_host.c +5 −5
  9. drivers/bcma/host_pci.c +5 −2
  10. drivers/bcma/scan.c +40 −14
  11. drivers/bcma/sprom.c +148 −1
  12. drivers/bluetooth/ath3k.c +6 −0
  13. drivers/bluetooth/btmrvl_drv.h +3 −0
  14. drivers/bluetooth/btmrvl_main.c +33 −23
  15. drivers/bluetooth/btmrvl_sdio.c +105 −7
  16. drivers/bluetooth/btusb.c +14 −2
  17. drivers/bluetooth/hci_ldisc.c +1 −1
  18. drivers/bluetooth/hci_vhci.c +2 −1
  19. drivers/isdn/hardware/mISDN/hfcsusb.h +6 −0
  20. drivers/net/ethernet/freescale/gianfar.c +1 −1
  21. drivers/net/wireless/ath/ath6kl/cfg80211.c +167 −71
  22. drivers/net/wireless/ath/ath6kl/cfg80211.h +2 −0
  23. drivers/net/wireless/ath/ath6kl/core.h +24 −9
  24. drivers/net/wireless/ath/ath6kl/debug.c +11 −1
  25. drivers/net/wireless/ath/ath6kl/htc_mbox.c +28 −17
  26. drivers/net/wireless/ath/ath6kl/htc_pipe.c +3 −8
  27. drivers/net/wireless/ath/ath6kl/init.c +24 −5
  28. drivers/net/wireless/ath/ath6kl/main.c +88 −16
  29. drivers/net/wireless/ath/ath6kl/sdio.c +11 −6
  30. drivers/net/wireless/ath/ath6kl/txrx.c +4 −8
  31. drivers/net/wireless/ath/ath6kl/usb.c +12 −0
  32. drivers/net/wireless/ath/ath6kl/wmi.c +57 −37
  33. drivers/net/wireless/ath/ath6kl/wmi.h +24 −0
  34. drivers/net/wireless/ath/ath9k/ar9003_calib.c +10 −40
  35. drivers/net/wireless/ath/ath9k/ar9003_mci.c +1 −1
  36. drivers/net/wireless/ath/ath9k/ar9003_rtt.c +69 −15
  37. drivers/net/wireless/ath/ath9k/ar9003_rtt.h +3 −2
  38. drivers/net/wireless/ath/ath9k/hw.c +4 −5
  39. drivers/net/wireless/ath/ath9k/hw.h +2 −7
  40. drivers/net/wireless/b43/bus.c +2 −4
  41. drivers/net/wireless/b43/dma.c +1 −1
  42. drivers/net/wireless/b43/main.c +2 −2
  43. drivers/net/wireless/b43legacy/main.c +1 −3
  44. drivers/net/wireless/b43legacy/phy.c +2 −2
  45. drivers/net/wireless/b43legacy/radio.c +5 −5
  46. drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +117 −127
  47. drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +3 −29
  48. drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +147 −203
  49. drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +138 −127
  50. drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h +11 −26
  51. drivers/net/wireless/brcm80211/brcmsmac/Makefile +0 −3
  52. drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +39 −440
  53. drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +0 −24
  54. drivers/net/wireless/brcm80211/brcmsmac/antsel.c +8 −8
  55. drivers/net/wireless/brcm80211/brcmsmac/channel.c +3 −4
  56. drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +5 −6
  57. drivers/net/wireless/brcm80211/brcmsmac/main.c +60 −82
  58. drivers/net/wireless/brcm80211/brcmsmac/nicpci.c +0 −826
  59. drivers/net/wireless/brcm80211/brcmsmac/nicpci.h +0 −77
  60. drivers/net/wireless/brcm80211/brcmsmac/otp.c +0 −410
  61. drivers/net/wireless/brcm80211/brcmsmac/otp.h +0 −36
  62. drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c +25 −42
  63. drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +108 −225
  64. drivers/net/wireless/brcm80211/brcmsmac/phy_shim.c +0 −9
  65. drivers/net/wireless/brcm80211/brcmsmac/phy_shim.h +0 −3
  66. drivers/net/wireless/brcm80211/brcmsmac/pub.h +0 −228
  67. drivers/net/wireless/brcm80211/brcmsmac/srom.c +0 −980
  68. drivers/net/wireless/brcm80211/brcmsmac/srom.h +0 −29
  69. drivers/net/wireless/brcm80211/brcmsmac/stf.c +4 −2
  70. drivers/net/wireless/iwlwifi/iwl-agn-lib.c +33 −2
  71. drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +4 −0
  72. drivers/net/wireless/iwlwifi/iwl-agn-tx.c +12 −7
  73. drivers/net/wireless/iwlwifi/iwl-agn.c +1 −1
  74. drivers/net/wireless/iwlwifi/iwl-commands.h +6 −1
  75. drivers/net/wireless/iwlwifi/iwl-mac80211.c +3 −2
  76. drivers/net/wireless/iwlwifi/iwl-power.c +6 −2
  77. drivers/net/wireless/iwlwifi/iwl-scan.c +38 −14
  78. drivers/net/wireless/mac80211_hwsim.c +5 −0
  79. drivers/net/wireless/mwifiex/Makefile +2 −0
  80. drivers/net/wireless/mwifiex/cfg80211.c +351 −147
  81. drivers/net/wireless/mwifiex/cfg80211.h +1 −1
  82. drivers/net/wireless/mwifiex/cmdevt.c +19 −2
  83. drivers/net/wireless/mwifiex/decl.h +12 −1
  84. drivers/net/wireless/mwifiex/fw.h +158 −1
  85. drivers/net/wireless/mwifiex/ie.c +396 −0
  86. drivers/net/wireless/mwifiex/init.c +1 −0
  87. drivers/net/wireless/mwifiex/ioctl.h +32 −0
  88. drivers/net/wireless/mwifiex/join.c +16 −10
  89. drivers/net/wireless/mwifiex/main.c +36 −21
  90. drivers/net/wireless/mwifiex/main.h +24 −2
  91. drivers/net/wireless/mwifiex/sta_cmd.c +47 −22
  92. drivers/net/wireless/mwifiex/sta_cmdresp.c +8 −0
  93. drivers/net/wireless/mwifiex/sta_event.c +50 −1
  94. drivers/net/wireless/mwifiex/sta_ioctl.c +7 −2
  95. drivers/net/wireless/mwifiex/uap_cmd.c +432 −0
  96. drivers/net/wireless/mwifiex/wmm.c +4 −0
  97. drivers/net/wireless/rndis_wlan.c +0 −14
  98. drivers/net/wireless/rt2x00/rt2800pci.c +1 −0
  99. drivers/net/wireless/ti/wl12xx/Kconfig +1 −0
  100. drivers/net/wireless/ti/wlcore/Kconfig +1 −1
  101. drivers/net/wireless/ti/wlcore/acx.c +80 −0
  102. drivers/net/wireless/ti/wlcore/acx.h +30 −0
  103. drivers/net/wireless/ti/wlcore/boot.c +2 −1
  104. drivers/net/wireless/ti/wlcore/cmd.c +5 −3
  105. drivers/net/wireless/ti/wlcore/event.c +12 −17
  106. drivers/net/wireless/ti/wlcore/main.c +315 −8
  107. drivers/net/wireless/ti/wlcore/rx.c +36 −0
  108. drivers/net/wireless/ti/wlcore/rx.h +4 −0
  109. drivers/net/wireless/ti/wlcore/wl12xx.h +41 −0
  110. drivers/net/wireless/ti/wlcore/wlcore.h +6 −0
  111. drivers/net/xen-netfront.c +0 −6
  112. drivers/nfc/Kconfig +13 −0
  113. drivers/nfc/Makefile +1 −0
  114. drivers/nfc/pn533.c +8 −11
  115. drivers/nfc/pn544_hci.c +947 −0
  116. drivers/ssb/b43_pci_bridge.c +2 −0
  117. drivers/ssb/pci.c +82 −6
  118. fs/dcache.c +2 −0
  119. fs/inode.c +2 −0
  120. include/linux/Kbuild +1 −0
  121. include/linux/bcma/bcma.h +7 −0
  122. include/linux/bcma/bcma_driver_pci.h +11 −0
  123. include/linux/bootmem.h +2 −1
  124. include/linux/if_arp.h +1 −1
  125. include/linux/ipx.h +1 −1
  126. include/linux/micrel_phy.h +1 −1
  127. include/linux/nfc/pn544.h +7 −0
  128. include/linux/nl80211.h +5 −3
  129. include/linux/ssb/ssb.h +0 −1
  130. include/linux/ssb/ssb_regs.h +57 −4
  131. include/net/bluetooth/bluetooth.h +24 −8
  132. include/net/bluetooth/hci.h +7 −1
  133. include/net/bluetooth/hci_core.h +36 −31
  134. include/net/bluetooth/l2cap.h +79 −14
  135. include/net/bluetooth/mgmt.h +9 −0
  136. include/net/bluetooth/smp.h +1 −1
  137. include/net/cfg80211.h +3 −3
  138. include/net/mac80211.h +11 −1
  139. include/net/nfc/hci.h +2 −4
  140. include/net/nfc/nfc.h +10 −9
  141. include/net/nfc/shdlc.h +2 −0
  142. kernel/pid.c +2 −1
  143. mm/page_alloc.c +5 −2
  144. net/bluetooth/af_bluetooth.c +4 −4
  145. net/bluetooth/bnep/core.c +1 −1
  146. net/bluetooth/hci_conn.c +11 −45
  147. net/bluetooth/hci_core.c +107 −160
  148. net/bluetooth/hci_event.c +54 −21
  149. net/bluetooth/hci_sysfs.c +2 −3
  150. net/bluetooth/l2cap_core.c +538 −224
  151. net/bluetooth/l2cap_sock.c +46 −30
  152. net/bluetooth/mgmt.c +172 −114
  153. net/bluetooth/rfcomm/sock.c +10 −4
  154. net/bluetooth/sco.c +44 −31
  155. net/bluetooth/smp.c +1 −1
  156. net/ipv4/fib_semantics.c +6 −6
  157. net/ipv4/route.c +1 −0
  158. net/ipv4/tcp.c +2 −0
  159. net/ipv4/tcp_input.c +5 −0
  160. net/ipv4/udp.c +10 −20
  161. net/mac80211/agg-tx.c +8 −2
  162. net/mac80211/debugfs_netdev.c +2 −0
  163. net/mac80211/ibss.c +5 −0
  164. net/mac80211/iface.c +3 −1
  165. net/mac80211/main.c +3 −0
  166. net/mac80211/mesh.c +4 −2
  167. net/mac80211/mesh_hwmp.c +4 −1
  168. net/mac80211/mesh_plink.c +33 −32
  169. net/mac80211/rx.c +3 −3
  170. net/mac80211/wep.c +12 −3
  171. net/mac80211/wpa.c +9 −1
  172. net/nfc/core.c +85 −27
  173. net/nfc/hci/Kconfig +1 −0
  174. net/nfc/hci/core.c +23 −55
  175. net/nfc/hci/shdlc.c +12 −0
  176. net/nfc/llcp/commands.c +2 −2
  177. net/nfc/llcp/llcp.c +7 −0
  178. net/nfc/llcp/sock.c +55 −2
  179. net/nfc/nci/core.c +14 −13
  180. net/nfc/nci/data.c +4 −4
  181. net/nfc/nci/lib.c +1 −0
  182. net/nfc/nci/ntf.c +1 −1
  183. net/nfc/netlink.c +3 −3
  184. net/nfc/nfc.h +1 −1
  185. net/wireless/chan.c +1 −1
  186. net/wireless/core.c +2 −2
  187. net/wireless/core.h +0 −2
  188. net/wireless/nl80211.c +37 −32
  189. net/wireless/util.c +1 −1
Documentation/feature-removal-schedule.txt+12−0
@@ -541,6 +541,18 @@ Who: Kees Cook <keescook@chromium.org> · 540 unmodified lines
541541
542542 ----------------------------
543543
544+What: Removing the pn544 raw driver.
545+When: 3.6
546+Why: With the introduction of the NFC HCI and SHDL kernel layers, pn544.c
547+ is being replaced by pn544_hci.c which is accessible through the netlink
548+ and socket NFC APIs. Moreover, pn544.c is outdated and does not seem to
549+ work properly with the latest Android stacks.
550+ Having 2 drivers for the same hardware is confusing and as such we
551+ should only keep the one following the kernel NFC APIs.
552+Who: Samuel Ortiz <sameo@linux.intel.com>
553+
554+----------------------------
555+
544556 What: setitimer accepts user NULL pointer (value)
545557 When: 3.6
546558 Why: setitimer is not returning -EFAULT if user pointer is NULL. This
Documentation/nfc/nfc-hci.txt+35−10
@@ -22,9 +22,9 @@ response to arrive. · 21 unmodified lines
2222 HCI events can also be received from the host controller. They will be handled
2323 and a translation will be forwarded to NFC Core as needed.
2424 HCI uses 2 execution contexts:
25−- one if for executing commands : nfc_hci_msg_tx_work(). Only one command
25+- one for executing commands : nfc_hci_msg_tx_work(). Only one command
2626 can be executing at any given moment.
27−- one if for dispatching received events and responses : nfc_hci_msg_rx_work()
27+- one for dispatching received events and commands : nfc_hci_msg_rx_work().
2828
2929 HCI Session initialization:
3030 ---------------------------
@@ -52,18 +52,42 @@ entry points: · 21 unmodified lines
5252 struct nfc_hci_ops {
5353 int (*open)(struct nfc_hci_dev *hdev);
5454 void (*close)(struct nfc_hci_dev *hdev);
55+ int (*hci_ready) (struct nfc_hci_dev *hdev);
5556 int (*xmit)(struct nfc_hci_dev *hdev, struct sk_buff *skb);
5657 int (*start_poll)(struct nfc_hci_dev *hdev, u32 protocols);
5758 int (*target_from_gate)(struct nfc_hci_dev *hdev, u8 gate,
5859 struct nfc_target *target);
60+ int (*complete_target_discovered) (struct nfc_hci_dev *hdev, u8 gate,
61+ struct nfc_target *target);
62+ int (*data_exchange) (struct nfc_hci_dev *hdev,
63+ struct nfc_target *target,
64+ struct sk_buff *skb, struct sk_buff **res_skb);
65+ int (*check_presence)(struct nfc_hci_dev *hdev,
66+ struct nfc_target *target);
5967 };
6068
61−open() and close() shall turn the hardware on and off. xmit() shall simply
62−write a frame to the chip. start_poll() is an optional entrypoint that shall
63−set the hardware in polling mode. This must be implemented only if the hardware
64−uses proprietary gates or a mechanism slightly different from the HCI standard.
65−target_from_gate() is another optional entrypoint to return the protocols
69+- open() and close() shall turn the hardware on and off.
70+- hci_ready() is an optional entry point that is called right after the hci
71+session has been set up. The driver can use it to do additional initialization
72+that must be performed using HCI commands.
73+- xmit() shall simply write a frame to the chip.
74+- start_poll() is an optional entrypoint that shall set the hardware in polling
75+mode. This must be implemented only if the hardware uses proprietary gates or a
76+mechanism slightly different from the HCI standard.
77+- target_from_gate() is an optional entrypoint to return the nfc protocols
6678 corresponding to a proprietary gate.
79+- complete_target_discovered() is an optional entry point to let the driver
80+perform additional proprietary processing necessary to auto activate the
81+discovered target.
82+- data_exchange() must be implemented by the driver if proprietary HCI commands
83+are required to send data to the tag. Some tag types will require custom
84+commands, others can be written to using the standard HCI commands. The driver
85+can check the tag type and either do proprietary processing, or return 1 to ask
86+for standard processing.
87+- check_presence() is an optional entry point that will be called regularly
88+by the core to check that an activated tag is still in the field. If this is
89+not implemented, the core will not be able to push tag_lost events to the user
90+space
6791
6892 On the rx path, the driver is responsible to push incoming HCP frames to HCI
6993 using nfc_hci_recv_frame(). HCI will take care of re-aggregation and handling
@@ -99,7 +123,8 @@ fast, cannot sleep. stores incoming frames into an shdlc rx queue · 29 unmodified lines
99123 handles shdlc rx & tx queues. Dispatches HCI cmd responses.
100124
101125 - HCI Tx Cmd worker (MSGTXWQ)
102−Serialize execution of HCI commands. Complete execution in case of resp timeout.
126+Serializes execution of HCI commands. Completes execution in case of response
127+timeout.
103128
104129 - HCI Rx worker (MSGRXWQ)
105130 Dispatches incoming HCI commands or events.
@@ -133,11 +158,11 @@ able to complete the command with a timeout error if no response arrive. · 27 unmodified lines
133158 SMW context gets scheduled and invokes nfc_shdlc_sm_work(). This function
134159 handles shdlc framing in and out. It uses the driver xmit to send frames and
135160 receives incoming frames in an skb queue filled from the driver IRQ handler.
136−SHDLC I(nformation) frames payload are HCP fragments. They are agregated to
161+SHDLC I(nformation) frames payload are HCP fragments. They are aggregated to
137162 form complete HCI frames, which can be a response, command, or event.
138163
139164 HCI Responses are dispatched immediately from this context to unblock
140−waiting command execution. Reponse processing involves invoking the completion
165+waiting command execution. Response processing involves invoking the completion
141166 callback that was provided by nfc_hci_msg_tx_work() when it sent the command.
142167 The completion callback will then wake the syscall context.
143168
arch/mips/bcm47xx/setup.c+7−8
@@ -90,6 +90,7 @@ static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out) · 89 unmodified lines
9090 char prefix[10];
9191
9292 if (bus->bustype == SSB_BUSTYPE_PCI) {
93+ memset(out, 0, sizeof(struct ssb_sprom));
9394 snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
9495 bus->host_pci->bus->number + 1,
9596 PCI_SLOT(bus->host_pci->devfn));
@@ -109,15 +110,9 @@ static int bcm47xx_get_invariants(struct ssb_bus *bus, · 13 unmodified lines
109110 /* Fill boardinfo structure */
110111 memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
111112
112− if (nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
113− iv->boardinfo.vendor = (u16)simple_strtoul(buf, NULL, 0);
114− else
115− iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
116− if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
117− iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
118− if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
119− iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
113+ bcm47xx_fill_ssb_boardinfo(&iv->boardinfo, NULL);
120114
115+ memset(&iv->sprom, 0, sizeof(struct ssb_sprom));
121116 bcm47xx_fill_sprom(&iv->sprom, NULL);
122117
123118 if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
@@ -166,12 +161,14 @@ static int bcm47xx_get_sprom_bcma(struct bcma_bus *bus, struct ssb_sprom *out) · 42 unmodified lines
166161
167162 switch (bus->hosttype) {
168163 case BCMA_HOSTTYPE_PCI:
164+ memset(out, 0, sizeof(struct ssb_sprom));
169165 snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
170166 bus->host_pci->bus->number + 1,
171167 PCI_SLOT(bus->host_pci->devfn));
172168 bcm47xx_fill_sprom(out, prefix);
173169 return 0;
174170 case BCMA_HOSTTYPE_SOC:
171+ memset(out, 0, sizeof(struct ssb_sprom));
175172 bcm47xx_fill_sprom_ethernet(out, NULL);
176173 core = bcma_find_core(bus, BCMA_CORE_80211);
177174 if (core) {
@@ -197,6 +194,8 @@ static void __init bcm47xx_register_bcma(void) · 19 unmodified lines
197194 err = bcma_host_soc_register(&bcm47xx_bus.bcma);
198195 if (err)
199196 panic("Failed to initialize BCMA bus (err %d)", err);
197+
198+ bcm47xx_fill_bcma_boardinfo(&bcm47xx_bus.bcma.bus.boardinfo, NULL);
200199 }
201200 #endif
202201
arch/mips/bcm47xx/sprom.c+26−2
@@ -165,6 +165,8 @@ static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom, · 164 unmodified lines
165165 const char *prefix)
166166 {
167167 nvram_read_u16(prefix, NULL, "boardrev", &sprom->board_rev, 0);
168+ if (!sprom->board_rev)
169+ nvram_read_u16(NULL, NULL, "boardrev", &sprom->board_rev, 0);
168170 nvram_read_u16(prefix, NULL, "boardnum", &sprom->board_num, 0);
169171 nvram_read_u8(prefix, NULL, "ledbh0", &sprom->gpio0, 0xff);
170172 nvram_read_u8(prefix, NULL, "ledbh1", &sprom->gpio1, 0xff);
@@ -555,8 +557,6 @@ void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, const char *prefix) · 384 unmodified lines
555557
556558 void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix)
557559 {
558− memset(sprom, 0, sizeof(struct ssb_sprom));
559−
560560 bcm47xx_fill_sprom_ethernet(sprom, prefix);
561561
562562 nvram_read_u8(prefix, NULL, "sromrev", &sprom->revision, 0);
@@ -618,3 +618,27 @@ void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix) · 55 unmodified lines
618618 bcm47xx_fill_sprom_r1(sprom, prefix);
619619 }
620620 }
621+
622+#ifdef CONFIG_BCM47XX_SSB
623+void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
624+ const char *prefix)
625+{
626+ nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0);
627+ if (!boardinfo->vendor)
628+ boardinfo->vendor = SSB_BOARDVENDOR_BCM;
629+
630+ nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0);
631+}
632+#endif
633+
634+#ifdef CONFIG_BCM47XX_BCMA
635+void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
636+ const char *prefix)
637+{
638+ nvram_read_u16(prefix, NULL, "boardvendor", &boardinfo->vendor, 0);
639+ if (!boardinfo->vendor)
640+ boardinfo->vendor = SSB_BOARDVENDOR_BCM;
641+
642+ nvram_read_u16(prefix, NULL, "boardtype", &boardinfo->type, 0);
643+}
644+#endif
arch/mips/include/asm/mach-bcm47xx/bcm47xx.h+9−0
@@ -47,4 +47,13 @@ extern enum bcm47xx_bus_type bcm47xx_bus_type; · 46 unmodified lines
4747 void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix);
4848 void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, const char *prefix);
4949
50+#ifdef CONFIG_BCM47XX_SSB
51+void bcm47xx_fill_ssb_boardinfo(struct ssb_boardinfo *boardinfo,
52+ const char *prefix);
53+#endif
54+#ifdef CONFIG_BCM47XX_BCMA
55+void bcm47xx_fill_bcma_boardinfo(struct bcma_boardinfo *boardinfo,
56+ const char *prefix);
57+#endif
58+
5059 #endif /* __ASM_BCM47XX_H */
drivers/bcma/core.c+2−1
@@ -30,6 +30,7 @@ void bcma_core_disable(struct bcma_device *core, u32 flags) · 29 unmodified lines
3030 udelay(10);
3131
3232 bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
33+ bcma_aread32(core, BCMA_RESET_CTL);
3334 udelay(1);
3435 }
3536 EXPORT_SYMBOL_GPL(bcma_core_disable);
@@ -77,7 +78,7 @@ void bcma_core_set_clockmode(struct bcma_device *core, · 41 unmodified lines
7778 pr_err("HT force timeout\n");
7879 break;
7980 case BCMA_CLKMODE_DYNAMIC:
80− pr_warn("Dynamic clockmode not supported yet!\n");
81+ bcma_set32(core, BCMA_CLKCTLST, ~BCMA_CLKCTLST_FORCEHT);
8182 break;
8283 }
8384 }
drivers/bcma/driver_pci.c+51−2
@@ -24,14 +24,12 @@ u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address) · 23 unmodified lines
2424 return pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_DATA);
2525 }
2626
27−#if 0
2827 static void bcma_pcie_write(struct bcma_drv_pci *pc, u32 address, u32 data)
2928 {
3029 pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_ADDR, address);
3130 pcicore_read32(pc, BCMA_CORE_PCI_PCIEIND_ADDR);
3231 pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data);
3332 }
34−#endif
3533
3634 static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
3735 {
@@ -170,13 +168,50 @@ static void bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc) · 132 unmodified lines
170168 tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN);
171169 }
172170
171+static void bcma_core_pci_fixcfg(struct bcma_drv_pci *pc)
172+{
173+ struct bcma_device *core = pc->core;
174+ u16 val16, core_index;
175+ uint regoff;
176+
177+ regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_PI_OFFSET);
178+ core_index = (u16)core->core_index;
179+
180+ val16 = pcicore_read16(pc, regoff);
181+ if (((val16 & BCMA_CORE_PCI_SPROM_PI_MASK) >> BCMA_CORE_PCI_SPROM_PI_SHIFT)
182+ != core_index) {
183+ val16 = (core_index << BCMA_CORE_PCI_SPROM_PI_SHIFT) |
184+ (val16 & ~BCMA_CORE_PCI_SPROM_PI_MASK);
185+ pcicore_write16(pc, regoff, val16);
186+ }
187+}
188+
189+/* Fix MISC config to allow coming out of L2/L3-Ready state w/o PRST */
190+/* Needs to happen when coming out of 'standby'/'hibernate' */
191+static void bcma_core_pci_config_fixup(struct bcma_drv_pci *pc)
192+{
193+ u16 val16;
194+ uint regoff;
195+
196+ regoff = BCMA_CORE_PCI_SPROM(BCMA_CORE_PCI_SPROM_MISC_CONFIG);
197+
198+ val16 = pcicore_read16(pc, regoff);
199+
200+ if (!(val16 & BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST)) {
201+ val16 |= BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST;
202+ pcicore_write16(pc, regoff, val16);
203+ }
204+}
205+
173206 /**************************************************
174207 * Init.
175208 **************************************************/
176209
177210 static void __devinit bcma_core_pci_clientmode_init(struct bcma_drv_pci *pc)
178211 {
212+ bcma_core_pci_fixcfg(pc);
179213 bcma_pcicore_serdes_workaround(pc);
214+ bcma_core_pci_config_fixup(pc);
180215 }
181216
182217 void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc)
@@ -224,3 +259,17 @@ out: · 41 unmodified lines
224259 return err;
225260 }
226261 EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
262+
263+void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
264+{
265+ u32 w;
266+
267+ w = bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
268+ if (extend)
269+ w |= BCMA_CORE_PCI_ASPMTIMER_EXTEND;
270+ else
271+ w &= ~BCMA_CORE_PCI_ASPMTIMER_EXTEND;
272+ bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w);
273+ bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
274+}
275+EXPORT_SYMBOL_GPL(bcma_core_pci_extend_L1timer);
drivers/bcma/driver_pci_host.c+5−5
@@ -119,7 +119,7 @@ static int bcma_extpci_read_config(struct bcma_drv_pci *pc, unsigned int dev, · 118 unmodified lines
119119 if (unlikely(!addr))
120120 goto out;
121121 err = -ENOMEM;
122− mmio = ioremap_nocache(addr, len);
122+ mmio = ioremap_nocache(addr, sizeof(val));
123123 if (!mmio)
124124 goto out;
125125
@@ -171,7 +171,7 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev, · 45 unmodified lines
171171 addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
172172 addr |= (func << 8);
173173 addr |= (off & 0xfc);
174− mmio = ioremap_nocache(addr, len);
174+ mmio = ioremap_nocache(addr, sizeof(val));
175175 if (!mmio)
176176 goto out;
177177 }
@@ -180,7 +180,7 @@ static int bcma_extpci_write_config(struct bcma_drv_pci *pc, unsigned int dev, · 2 unmodified lines
180180 if (unlikely(!addr))
181181 goto out;
182182 err = -ENOMEM;
183− mmio = ioremap_nocache(addr, len);
183+ mmio = ioremap_nocache(addr, sizeof(val));
184184 if (!mmio)
185185 goto out;
186186
@@ -491,8 +491,8 @@ void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc) · 304 unmodified lines
491491 /* Ok, ready to run, register it to the system.
492492 * The following needs change, if we want to port hostmode
493493 * to non-MIPS platform. */
494− io_map_base = (unsigned long)ioremap_nocache(BCMA_SOC_PCI_MEM,
495− 0x04000000);
494+ io_map_base = (unsigned long)ioremap_nocache(pc_host->mem_resource.start,
495+ resource_size(&pc_host->mem_resource));
496496 pc_host->pci_controller.io_map_base = io_map_base;
497497 set_io_port_base(pc_host->pci_controller.io_map_base);
498498 /* Give some time to the PCI controller to configure itself with the new
drivers/bcma/host_pci.c+5−2
@@ -201,6 +201,9 @@ static int __devinit bcma_host_pci_probe(struct pci_dev *dev, · 200 unmodified lines
201201 bus->hosttype = BCMA_HOSTTYPE_PCI;
202202 bus->ops = &bcma_host_pci_ops;
203203
204+ bus->boardinfo.vendor = bus->host_pci->subsystem_vendor;
205+ bus->boardinfo.type = bus->host_pci->subsystem_device;
206+
204207 /* Register */
205208 err = bcma_bus_register(bus);
206209 if (err)
@@ -222,7 +225,7 @@ err_kfree_bus: · 15 unmodified lines
222225 return err;
223226 }
224227
225−static void bcma_host_pci_remove(struct pci_dev *dev)
228+static void __devexit bcma_host_pci_remove(struct pci_dev *dev)
226229 {
227230 struct bcma_bus *bus = pci_get_drvdata(dev);
228231
@@ -277,7 +280,7 @@ static struct pci_driver bcma_pci_bridge_driver = { · 48 unmodified lines
277280 .name = "bcma-pci-bridge",
278281 .id_table = bcma_pci_bridge_tbl,
279282 .probe = bcma_host_pci_probe,
280− .remove = bcma_host_pci_remove,
283+ .remove = __devexit_p(bcma_host_pci_remove),
281284 .driver.pm = BCMA_PM_OPS,
282285 };
283286
drivers/bcma/scan.c+40−14
@@ -19,7 +19,14 @@ struct bcma_device_id_name { · 18 unmodified lines
1919 u16 id;
2020 const char *name;
2121 };
22−struct bcma_device_id_name bcma_device_names[] = {
22+
23+static const struct bcma_device_id_name bcma_arm_device_names[] = {
24+ { BCMA_CORE_ARM_1176, "ARM 1176" },
25+ { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" },
26+ { BCMA_CORE_ARM_CM3, "ARM CM3" },
27+};
28+
29+static const struct bcma_device_id_name bcma_bcm_device_names[] = {
2330 { BCMA_CORE_OOB_ROUTER, "OOB Router" },
2431 { BCMA_CORE_INVALID, "Invalid" },
2532 { BCMA_CORE_CHIPCOMMON, "ChipCommon" },
@@ -27,7 +34,6 @@ struct bcma_device_id_name bcma_device_names[] = { · 1 unmodified line
2734 { BCMA_CORE_SRAM, "SRAM" },
2835 { BCMA_CORE_SDRAM, "SDRAM" },
2936 { BCMA_CORE_PCI, "PCI" },
30− { BCMA_CORE_MIPS, "MIPS" },
3137 { BCMA_CORE_ETHERNET, "Fast Ethernet" },
3238 { BCMA_CORE_V90, "V90" },
3339 { BCMA_CORE_USB11_HOSTDEV, "USB 1.1 Hostdev" },
@@ -44,7 +50,6 @@ struct bcma_device_id_name bcma_device_names[] = { · 10 unmodified lines
4450 { BCMA_CORE_PHY_A, "PHY A" },
4551 { BCMA_CORE_PHY_B, "PHY B" },
4652 { BCMA_CORE_PHY_G, "PHY G" },
47− { BCMA_CORE_MIPS_3302, "MIPS 3302" },
4853 { BCMA_CORE_USB11_HOST, "USB 1.1 Host" },
4954 { BCMA_CORE_USB11_DEV, "USB 1.1 Device" },
5055 { BCMA_CORE_USB20_HOST, "USB 2.0 Host" },
@@ -58,15 +63,11 @@ struct bcma_device_id_name bcma_device_names[] = { · 7 unmodified lines
5863 { BCMA_CORE_PHY_N, "PHY N" },
5964 { BCMA_CORE_SRAM_CTL, "SRAM Controller" },
6065 { BCMA_CORE_MINI_MACPHY, "Mini MACPHY" },
61− { BCMA_CORE_ARM_1176, "ARM 1176" },
62− { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" },
6366 { BCMA_CORE_PHY_LP, "PHY LP" },
6467 { BCMA_CORE_PMU, "PMU" },
6568 { BCMA_CORE_PHY_SSN, "PHY SSN" },
6669 { BCMA_CORE_SDIO_DEV, "SDIO Device" },
67− { BCMA_CORE_ARM_CM3, "ARM CM3" },
6870 { BCMA_CORE_PHY_HT, "PHY HT" },
69− { BCMA_CORE_MIPS_74K, "MIPS 74K" },
7071 { BCMA_CORE_MAC_GBIT, "GBit MAC" },
7172 { BCMA_CORE_DDR12_MEM_CTL, "DDR1/DDR2 Memory Controller" },
7273 { BCMA_CORE_PCIE_RC, "PCIe Root Complex" },
@@ -79,16 +80,41 @@ struct bcma_device_id_name bcma_device_names[] = { · 6 unmodified lines
7980 { BCMA_CORE_SHIM, "SHIM" },
8081 { BCMA_CORE_DEFAULT, "Default" },
8182 };
82−const char *bcma_device_name(struct bcma_device_id *id)
83+
84+static const struct bcma_device_id_name bcma_mips_device_names[] = {
85+ { BCMA_CORE_MIPS, "MIPS" },
86+ { BCMA_CORE_MIPS_3302, "MIPS 3302" },
87+ { BCMA_CORE_MIPS_74K, "MIPS 74K" },
88+};
89+
90+static const char *bcma_device_name(const struct bcma_device_id *id)
8391 {
84− int i;
92+ const struct bcma_device_id_name *names;
93+ int size, i;
94+
95+ /* search manufacturer specific names */
96+ switch (id->manuf) {
97+ case BCMA_MANUF_ARM:
98+ names = bcma_arm_device_names;
99+ size = ARRAY_SIZE(bcma_arm_device_names);
100+ break;
101+ case BCMA_MANUF_BCM:
102+ names = bcma_bcm_device_names;
103+ size = ARRAY_SIZE(bcma_bcm_device_names);
104+ break;
105+ case BCMA_MANUF_MIPS:
106+ names = bcma_mips_device_names;
107+ size = ARRAY_SIZE(bcma_mips_device_names);
108+ break;
109+ default:
110+ return "UNKNOWN";
111+ }
85112
86− if (id->manuf == BCMA_MANUF_BCM) {
87− for (i = 0; i < ARRAY_SIZE(bcma_device_names); i++) {
88− if (bcma_device_names[i].id == id->id)
89− return bcma_device_names[i].name;
90− }
113+ for (i = 0; i < size; i++) {
114+ if (names[i].id == id->id)
115+ return names[i].name;
91116 }
117+
92118 return "UNKNOWN";
93119 }
94120
drivers/bcma/sprom.c+148−1
@@ -181,6 +181,22 @@ static int bcma_sprom_valid(const u16 *sprom) · 180 unmodified lines
181181 #define SPEX(_field, _offset, _mask, _shift) \
182182 bus->sprom._field = ((sprom[SPOFF(_offset)] & (_mask)) >> (_shift))
183183
184+#define SPEX32(_field, _offset, _mask, _shift) \
185+ bus->sprom._field = ((((u32)sprom[SPOFF((_offset)+2)] << 16 | \
186+ sprom[SPOFF(_offset)]) & (_mask)) >> (_shift))
187+
188+#define SPEX_ARRAY8(_field, _offset, _mask, _shift) \
189+ do { \
190+ SPEX(_field[0], _offset + 0, _mask, _shift); \
191+ SPEX(_field[1], _offset + 2, _mask, _shift); \
192+ SPEX(_field[2], _offset + 4, _mask, _shift); \
193+ SPEX(_field[3], _offset + 6, _mask, _shift); \
194+ SPEX(_field[4], _offset + 8, _mask, _shift); \
195+ SPEX(_field[5], _offset + 10, _mask, _shift); \
196+ SPEX(_field[6], _offset + 12, _mask, _shift); \
197+ SPEX(_field[7], _offset + 14, _mask, _shift); \
198+ } while (0)
199+
184200 static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
185201 {
186202 u16 v, o;
@@ -243,7 +259,8 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) · 56 unmodified lines
243259 SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, ~0, 0);
244260 SPEX(boardflags2_hi, SSB_SPROM8_BFL2HI, ~0, 0);
245261
246− SPEX(country_code, SSB_SPROM8_CCODE, ~0, 0);
262+ SPEX(alpha2[0], SSB_SPROM8_CCODE, 0xff00, 8);
263+ SPEX(alpha2[1], SSB_SPROM8_CCODE, 0x00ff, 0);
247264
248265 /* Extract cores power info info */
249266 for (i = 0; i < ARRAY_SIZE(pwr_info_offset); i++) {
@@ -298,6 +315,136 @@ static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom) · 48 unmodified lines
298315 SSB_SROM8_FEM_TR_ISO_SHIFT);
299316 SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G, SSB_SROM8_FEM_ANTSWLUT,
300317 SSB_SROM8_FEM_ANTSWLUT_SHIFT);
318+
319+ SPEX(ant_available_a, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_A,
320+ SSB_SPROM8_ANTAVAIL_A_SHIFT);
321+ SPEX(ant_available_bg, SSB_SPROM8_ANTAVAIL, SSB_SPROM8_ANTAVAIL_BG,
322+ SSB_SPROM8_ANTAVAIL_BG_SHIFT);
323+ SPEX(maxpwr_bg, SSB_SPROM8_MAXP_BG, SSB_SPROM8_MAXP_BG_MASK, 0);
324+ SPEX(itssi_bg, SSB_SPROM8_MAXP_BG, SSB_SPROM8_ITSSI_BG,
325+ SSB_SPROM8_ITSSI_BG_SHIFT);
326+ SPEX(maxpwr_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_MAXP_A_MASK, 0);
327+ SPEX(itssi_a, SSB_SPROM8_MAXP_A, SSB_SPROM8_ITSSI_A,
328+ SSB_SPROM8_ITSSI_A_SHIFT);
329+ SPEX(maxpwr_ah, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AH_MASK, 0);
330+ SPEX(maxpwr_al, SSB_SPROM8_MAXP_AHL, SSB_SPROM8_MAXP_AL_MASK,
331+ SSB_SPROM8_MAXP_AL_SHIFT);
332+ SPEX(gpio0, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P0, 0);
333+ SPEX(gpio1, SSB_SPROM8_GPIOA, SSB_SPROM8_GPIOA_P1,
334+ SSB_SPROM8_GPIOA_P1_SHIFT);
335+ SPEX(gpio2, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P2, 0);
336+ SPEX(gpio3, SSB_SPROM8_GPIOB, SSB_SPROM8_GPIOB_P3,
337+ SSB_SPROM8_GPIOB_P3_SHIFT);
338+ SPEX(tri2g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI2G, 0);
339+ SPEX(tri5g, SSB_SPROM8_TRI25G, SSB_SPROM8_TRI5G,
340+ SSB_SPROM8_TRI5G_SHIFT);
341+ SPEX(tri5gl, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GL, 0);
342+ SPEX(tri5gh, SSB_SPROM8_TRI5GHL, SSB_SPROM8_TRI5GH,
343+ SSB_SPROM8_TRI5GH_SHIFT);
344+ SPEX(rxpo2g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO2G,
345+ SSB_SPROM8_RXPO2G_SHIFT);
346+ SPEX(rxpo5g, SSB_SPROM8_RXPO, SSB_SPROM8_RXPO5G,
347+ SSB_SPROM8_RXPO5G_SHIFT);
348+ SPEX(rssismf2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMF2G, 0);
349+ SPEX(rssismc2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISMC2G,
350+ SSB_SPROM8_RSSISMC2G_SHIFT);
351+ SPEX(rssisav2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_RSSISAV2G,
352+ SSB_SPROM8_RSSISAV2G_SHIFT);
353+ SPEX(bxa2g, SSB_SPROM8_RSSIPARM2G, SSB_SPROM8_BXA2G,
354+ SSB_SPROM8_BXA2G_SHIFT);
355+ SPEX(rssismf5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMF5G, 0);
356+ SPEX(rssismc5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISMC5G,
357+ SSB_SPROM8_RSSISMC5G_SHIFT);
358+ SPEX(rssisav5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_RSSISAV5G,
359+ SSB_SPROM8_RSSISAV5G_SHIFT);
360+ SPEX(bxa5g, SSB_SPROM8_RSSIPARM5G, SSB_SPROM8_BXA5G,
361+ SSB_SPROM8_BXA5G_SHIFT);
362+
363+ SPEX(pa0b0, SSB_SPROM8_PA0B0, ~0, 0);
364+ SPEX(pa0b1, SSB_SPROM8_PA0B1, ~0, 0);
365+ SPEX(pa0b2, SSB_SPROM8_PA0B2, ~0, 0);
366+ SPEX(pa1b0, SSB_SPROM8_PA1B0, ~0, 0);
367+ SPEX(pa1b1, SSB_SPROM8_PA1B1, ~0, 0);
368+ SPEX(pa1b2, SSB_SPROM8_PA1B2, ~0, 0);
369+ SPEX(pa1lob0, SSB_SPROM8_PA1LOB0, ~0, 0);
370+ SPEX(pa1lob1, SSB_SPROM8_PA1LOB1, ~0, 0);
371+ SPEX(pa1lob2, SSB_SPROM8_PA1LOB2, ~0, 0);
372+ SPEX(pa1hib0, SSB_SPROM8_PA1HIB0, ~0, 0);
373+ SPEX(pa1hib1, SSB_SPROM8_PA1HIB1, ~0, 0);
374+ SPEX(pa1hib2, SSB_SPROM8_PA1HIB2, ~0, 0);
375+ SPEX(cck2gpo, SSB_SPROM8_CCK2GPO, ~0, 0);
376+ SPEX32(ofdm2gpo, SSB_SPROM8_OFDM2GPO, ~0, 0);
377+ SPEX32(ofdm5glpo, SSB_SPROM8_OFDM5GLPO, ~0, 0);
378+ SPEX32(ofdm5gpo, SSB_SPROM8_OFDM5GPO, ~0, 0);
379+ SPEX32(ofdm5ghpo, SSB_SPROM8_OFDM5GHPO, ~0, 0);
380+
381+ /* Extract the antenna gain values. */
382+ SPEX(antenna_gain.a0, SSB_SPROM8_AGAIN01,
383+ SSB_SPROM8_AGAIN0, SSB_SPROM8_AGAIN0_SHIFT);
384+ SPEX(antenna_gain.a1, SSB_SPROM8_AGAIN01,
385+ SSB_SPROM8_AGAIN1, SSB_SPROM8_AGAIN1_SHIFT);
386+ SPEX(antenna_gain.a2, SSB_SPROM8_AGAIN23,
387+ SSB_SPROM8_AGAIN2, SSB_SPROM8_AGAIN2_SHIFT);
388+ SPEX(antenna_gain.a3, SSB_SPROM8_AGAIN23,
389+ SSB_SPROM8_AGAIN3, SSB_SPROM8_AGAIN3_SHIFT);
390+
391+ SPEX(leddc_on_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_ON,
392+ SSB_SPROM8_LEDDC_ON_SHIFT);
393+ SPEX(leddc_off_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_OFF,
394+ SSB_SPROM8_LEDDC_OFF_SHIFT);
395+
396+ SPEX(txchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_TXCHAIN,
397+ SSB_SPROM8_TXRXC_TXCHAIN_SHIFT);
398+ SPEX(rxchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_RXCHAIN,
399+ SSB_SPROM8_TXRXC_RXCHAIN_SHIFT);
400+ SPEX(antswitch, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_SWITCH,
401+ SSB_SPROM8_TXRXC_SWITCH_SHIFT);
402+
403+ SPEX(opo, SSB_SPROM8_OFDM2GPO, 0x00ff, 0);
404+
405+ SPEX_ARRAY8(mcs2gpo, SSB_SPROM8_2G_MCSPO, ~0, 0);
406+ SPEX_ARRAY8(mcs5gpo, SSB_SPROM8_5G_MCSPO, ~0, 0);
407+ SPEX_ARRAY8(mcs5glpo, SSB_SPROM8_5GL_MCSPO, ~0, 0);
408+ SPEX_ARRAY8(mcs5ghpo, SSB_SPROM8_5GH_MCSPO, ~0, 0);
409+
410+ SPEX(rawtempsense, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_RAWTEMP,
411+ SSB_SPROM8_RAWTS_RAWTEMP_SHIFT);
412+ SPEX(measpower, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_MEASPOWER,
413+ SSB_SPROM8_RAWTS_MEASPOWER_SHIFT);
414+ SPEX(tempsense_slope, SSB_SPROM8_OPT_CORRX,
415+ SSB_SPROM8_OPT_CORRX_TEMP_SLOPE,
416+ SSB_SPROM8_OPT_CORRX_TEMP_SLOPE_SHIFT);
417+ SPEX(tempcorrx, SSB_SPROM8_OPT_CORRX, SSB_SPROM8_OPT_CORRX_TEMPCORRX,
418+ SSB_SPROM8_OPT_CORRX_TEMPCORRX_SHIFT);
419+ SPEX(tempsense_option, SSB_SPROM8_OPT_CORRX,
420+ SSB_SPROM8_OPT_CORRX_TEMP_OPTION,
421+ SSB_SPROM8_OPT_CORRX_TEMP_OPTION_SHIFT);
422+ SPEX(freqoffset_corr, SSB_SPROM8_HWIQ_IQSWP,
423+ SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR,
424+ SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR_SHIFT);
425+ SPEX(iqcal_swp_dis, SSB_SPROM8_HWIQ_IQSWP,
426+ SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP,
427+ SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP_SHIFT);
428+ SPEX(hw_iqcal_en, SSB_SPROM8_HWIQ_IQSWP, SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL,
429+ SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL_SHIFT);
430+
431+ SPEX(bw40po, SSB_SPROM8_BW40PO, ~0, 0);
432+ SPEX(cddpo, SSB_SPROM8_CDDPO, ~0, 0);
433+ SPEX(stbcpo, SSB_SPROM8_STBCPO, ~0, 0);
434+ SPEX(bwduppo, SSB_SPROM8_BWDUPPO, ~0, 0);
435+
436+ SPEX(tempthresh, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_TRESH,
437+ SSB_SPROM8_THERMAL_TRESH_SHIFT);
438+ SPEX(tempoffset, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_OFFSET,
439+ SSB_SPROM8_THERMAL_OFFSET_SHIFT);
440+ SPEX(phycal_tempdelta, SSB_SPROM8_TEMPDELTA,
441+ SSB_SPROM8_TEMPDELTA_PHYCAL,
442+ SSB_SPROM8_TEMPDELTA_PHYCAL_SHIFT);
443+ SPEX(temps_period, SSB_SPROM8_TEMPDELTA, SSB_SPROM8_TEMPDELTA_PERIOD,
444+ SSB_SPROM8_TEMPDELTA_PERIOD_SHIFT);
445+ SPEX(temps_hysteresis, SSB_SPROM8_TEMPDELTA,
446+ SSB_SPROM8_TEMPDELTA_HYSTERESIS,
447+ SSB_SPROM8_TEMPDELTA_HYSTERESIS_SHIFT);
301448 }
302449
303450 /*
drivers/bluetooth/ath3k.c+6−0
@@ -81,6 +81,9 @@ static struct usb_device_id ath3k_table[] = { · 80 unmodified lines
8181 /* Atheros AR5BBU12 with sflash firmware */
8282 { USB_DEVICE(0x0489, 0xE02C) },
8383
84+ /* Atheros AR5BBU22 with sflash firmware */
85+ { USB_DEVICE(0x0489, 0xE03C) },
86+
8487 { } /* Terminating entry */
8588 };
8689
@@ -99,6 +102,9 @@ static struct usb_device_id ath3k_blist_tbl[] = { · 12 unmodified lines
99102 { USB_DEVICE(0x13d3, 0x3362), .driver_info = BTUSB_ATH3012 },
100103 { USB_DEVICE(0x0cf3, 0xe004), .driver_info = BTUSB_ATH3012 },
101104
105+ /* Atheros AR5BBU22 with sflash firmware */
106+ { USB_DEVICE(0x0489, 0xE03C), .driver_info = BTUSB_ATH3012 },
107+
102108 { } /* Terminating entry */
103109 };
104110
drivers/bluetooth/btmrvl_drv.h+3−0
@@ -67,6 +67,7 @@ struct btmrvl_adapter { · 66 unmodified lines
6767 u8 wakeup_tries;
6868 wait_queue_head_t cmd_wait_q;
6969 u8 cmd_complete;
70+ bool is_suspended;
7071 };
7172
7273 struct btmrvl_private {
@@ -139,8 +140,10 @@ void btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb); · 66 unmodified lines
139140 int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb);
140141
141142 int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd);
143+int btmrvl_send_hscfg_cmd(struct btmrvl_private *priv);
142144 int btmrvl_enable_ps(struct btmrvl_private *priv);
143145 int btmrvl_prepare_command(struct btmrvl_private *priv);
146+int btmrvl_enable_hs(struct btmrvl_private *priv);
144147
145148 #ifdef CONFIG_DEBUG_FS
146149 void btmrvl_debugfs_init(struct hci_dev *hdev);
drivers/bluetooth/btmrvl_main.c+33−23
@@ -200,6 +200,36 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd) · 199 unmodified lines
200200 }
201201 EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd);
202202
203+int btmrvl_send_hscfg_cmd(struct btmrvl_private *priv)
204+{
205+ struct sk_buff *skb;
206+ struct btmrvl_cmd *cmd;
207+
208+ skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
209+ if (!skb) {
210+ BT_ERR("No free skb");
211+ return -ENOMEM;
212+ }
213+
214+ cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
215+ cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF,
216+ BT_CMD_HOST_SLEEP_CONFIG));
217+ cmd->length = 2;
218+ cmd->data[0] = (priv->btmrvl_dev.gpio_gap & 0xff00) >> 8;
219+ cmd->data[1] = (u8) (priv->btmrvl_dev.gpio_gap & 0x00ff);
220+
221+ bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
222+
223+ skb->dev = (void *) priv->btmrvl_dev.hcidev;
224+ skb_queue_head(&priv->adapter->tx_queue, skb);
225+
226+ BT_DBG("Queue HSCFG Command, gpio=0x%x, gap=0x%x", cmd->data[0],
227+ cmd->data[1]);
228+
229+ return 0;
230+}
231+EXPORT_SYMBOL_GPL(btmrvl_send_hscfg_cmd);
232+
203233 int btmrvl_enable_ps(struct btmrvl_private *priv)
204234 {
205235 struct sk_buff *skb;
@@ -232,7 +262,7 @@ int btmrvl_enable_ps(struct btmrvl_private *priv) · 26 unmodified lines
232262 }
233263 EXPORT_SYMBOL_GPL(btmrvl_enable_ps);
234264
235−static int btmrvl_enable_hs(struct btmrvl_private *priv)
265+int btmrvl_enable_hs(struct btmrvl_private *priv)
236266 {
237267 struct sk_buff *skb;
238268 struct btmrvl_cmd *cmd;
@@ -268,35 +298,15 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv) · 29 unmodified lines
268298
269299 return ret;
270300 }
301+EXPORT_SYMBOL_GPL(btmrvl_enable_hs);
271302
272303 int btmrvl_prepare_command(struct btmrvl_private *priv)
273304 {
274− struct sk_buff *skb = NULL;
275− struct btmrvl_cmd *cmd;
276305 int ret = 0;
277306
278307 if (priv->btmrvl_dev.hscfgcmd) {
279308 priv->btmrvl_dev.hscfgcmd = 0;
280−
281− skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
282− if (skb == NULL) {
283− BT_ERR("No free skb");
284− return -ENOMEM;
285− }
286−
287− cmd = (struct btmrvl_cmd *) skb_put(skb, sizeof(*cmd));
288− cmd->ocf_ogf = cpu_to_le16(hci_opcode_pack(OGF, BT_CMD_HOST_SLEEP_CONFIG));
289− cmd->length = 2;
290− cmd->data[0] = (priv->btmrvl_dev.gpio_gap & 0xff00) >> 8;
291− cmd->data[1] = (u8) (priv->btmrvl_dev.gpio_gap & 0x00ff);
292−
293− bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
294−
295− skb->dev = (void *) priv->btmrvl_dev.hcidev;
296− skb_queue_head(&priv->adapter->tx_queue, skb);
297−
298− BT_DBG("Queue HSCFG Command, gpio=0x%x, gap=0x%x",
299− cmd->data[0], cmd->data[1]);
309+ btmrvl_send_hscfg_cmd(priv);
300310 }
301311
302312 if (priv->btmrvl_dev.pscmd) {
drivers/bluetooth/btmrvl_sdio.c+105−7
@@ -339,9 +339,7 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card) · 338 unmodified lines
339339
340340 done:
341341 kfree(tmphlprbuf);
342− if (fw_helper)
343− release_firmware(fw_helper);
344−
342+ release_firmware(fw_helper);
345343 return ret;
346344 }
347345
@@ -484,10 +482,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card) · 136 unmodified lines
484482
485483 done:
486484 kfree(tmpfwbuf);
487−
488− if (fw_firmware)
489− release_firmware(fw_firmware);
490−
485+ release_firmware(fw_firmware);
491486 return ret;
492487 }
493488
@@ -1013,6 +1008,9 @@ static int btmrvl_sdio_probe(struct sdio_func *func, · 519 unmodified lines
10131008 priv->btmrvl_dev.psmode = 1;
10141009 btmrvl_enable_ps(priv);
10151010
1011+ priv->btmrvl_dev.gpio_gap = 0xffff;
1012+ btmrvl_send_hscfg_cmd(priv);
1013+
10161014 return 0;
10171015
10181016 disable_host_int:
@@ -1048,11 +1046,111 @@ static void btmrvl_sdio_remove(struct sdio_func *func) · 29 unmodified lines
10481046 }
10491047 }
10501048
1049+static int btmrvl_sdio_suspend(struct device *dev)
1050+{
1051+ struct sdio_func *func = dev_to_sdio_func(dev);
1052+ struct btmrvl_sdio_card *card;
1053+ struct btmrvl_private *priv;
1054+ mmc_pm_flag_t pm_flags;
1055+ struct hci_dev *hcidev;
1056+
1057+ if (func) {
1058+ pm_flags = sdio_get_host_pm_caps(func);
1059+ BT_DBG("%s: suspend: PM flags = 0x%x", sdio_func_id(func),
1060+ pm_flags);
1061+ if (!(pm_flags & MMC_PM_KEEP_POWER)) {
1062+ BT_ERR("%s: cannot remain alive while suspended",
1063+ sdio_func_id(func));
1064+ return -ENOSYS;
1065+ }
1066+ card = sdio_get_drvdata(func);
1067+ if (!card || !card->priv) {
1068+ BT_ERR("card or priv structure is not valid");
1069+ return 0;
1070+ }
1071+ } else {
1072+ BT_ERR("sdio_func is not specified");
1073+ return 0;
1074+ }
1075+
1076+ priv = card->priv;
1077+
1078+ if (priv->adapter->hs_state != HS_ACTIVATED) {
1079+ if (btmrvl_enable_hs(priv)) {
1080+ BT_ERR("HS not actived, suspend failed!");
1081+ return -EBUSY;
1082+ }
1083+ }
1084+ hcidev = priv->btmrvl_dev.hcidev;
1085+ BT_DBG("%s: SDIO suspend", hcidev->name);
1086+ hci_suspend_dev(hcidev);
1087+ skb_queue_purge(&priv->adapter->tx_queue);
1088+
1089+ priv->adapter->is_suspended = true;
1090+
1091+ /* We will keep the power when hs enabled successfully */
1092+ if (priv->adapter->hs_state == HS_ACTIVATED) {
1093+ BT_DBG("suspend with MMC_PM_KEEP_POWER");
1094+ return sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
1095+ } else {
1096+ BT_DBG("suspend without MMC_PM_KEEP_POWER");
1097+ return 0;
1098+ }
1099+}
1100+
1101+static int btmrvl_sdio_resume(struct device *dev)
1102+{
1103+ struct sdio_func *func = dev_to_sdio_func(dev);
1104+ struct btmrvl_sdio_card *card;
1105+ struct btmrvl_private *priv;
1106+ mmc_pm_flag_t pm_flags;
1107+ struct hci_dev *hcidev;
1108+
1109+ if (func) {
1110+ pm_flags = sdio_get_host_pm_caps(func);
1111+ BT_DBG("%s: resume: PM flags = 0x%x", sdio_func_id(func),
1112+ pm_flags);
1113+ card = sdio_get_drvdata(func);
1114+ if (!card || !card->priv) {
1115+ BT_ERR("card or priv structure is not valid");
1116+ return 0;
1117+ }
1118+ } else {
1119+ BT_ERR("sdio_func is not specified");
1120+ return 0;
1121+ }
1122+ priv = card->priv;
1123+
1124+ if (!priv->adapter->is_suspended) {
1125+ BT_DBG("device already resumed");
1126+ return 0;
1127+ }
1128+
1129+ priv->adapter->is_suspended = false;
1130+ hcidev = priv->btmrvl_dev.hcidev;
1131+ BT_DBG("%s: SDIO resume", hcidev->name);
1132+ hci_resume_dev(hcidev);
1133+ priv->hw_wakeup_firmware(priv);
1134+ priv->adapter->hs_state = HS_DEACTIVATED;
1135+ BT_DBG("%s: HS DEACTIVATED in resume!", hcidev->name);
1136+
1137+ return 0;
1138+}
1139+
1140+static const struct dev_pm_ops btmrvl_sdio_pm_ops = {
1141+ .suspend = btmrvl_sdio_suspend,
1142+ .resume = btmrvl_sdio_resume,
1143+};
1144+
10511145 static struct sdio_driver bt_mrvl_sdio = {
10521146 .name = "btmrvl_sdio",
10531147 .id_table = btmrvl_sdio_ids,
10541148 .probe = btmrvl_sdio_probe,
10551149 .remove = btmrvl_sdio_remove,
1150+ .drv = {
1151+ .owner = THIS_MODULE,
1152+ .pm = &btmrvl_sdio_pm_ops,
1153+ }
10561154 };
10571155
10581156 static int __init btmrvl_sdio_init_module(void)
drivers/bluetooth/btusb.c+14−2
@@ -143,6 +143,9 @@ static struct usb_device_id blacklist_table[] = { · 142 unmodified lines
143143 /* Atheros AR5BBU12 with sflash firmware */
144144 { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
145145
146+ /* Atheros AR5BBU12 with sflash firmware */
147+ { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 },
148+
146149 /* Broadcom BCM2035 */
147150 { USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU },
148151 { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU },
@@ -855,6 +858,7 @@ static void btusb_work(struct work_struct *work) · 706 unmodified lines
855858 {
856859 struct btusb_data *data = container_of(work, struct btusb_data, work);
857860 struct hci_dev *hdev = data->hdev;
861+ int new_alts;
858862 int err;
859863
860864 if (hdev->conn_hash.sco_num > 0) {
@@ -868,11 +872,19 @@ static void btusb_work(struct work_struct *work) · 7 unmodified lines
868872
869873 set_bit(BTUSB_DID_ISO_RESUME, &data->flags);
870874 }
871− if (data->isoc_altsetting != 2) {
875+
876+ if (hdev->voice_setting & 0x0020) {
877+ static const int alts[3] = { 2, 4, 5 };
878+ new_alts = alts[hdev->conn_hash.sco_num - 1];
879+ } else {
880+ new_alts = hdev->conn_hash.sco_num;
881+ }
882+
883+ if (data->isoc_altsetting != new_alts) {
872884 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
873885 usb_kill_anchored_urbs(&data->isoc_anchor);
874886
875− if (__set_isoc_interface(hdev, 2) < 0)
887+ if (__set_isoc_interface(hdev, new_alts) < 0)
876888 return;
877889 }
878890
drivers/bluetooth/hci_ldisc.c+1−1
@@ -388,7 +388,7 @@ static int hci_uart_register_dev(struct hci_uart *hu) · 387 unmodified lines
388388 hdev->close = hci_uart_close;
389389 hdev->flush = hci_uart_flush;
390390 hdev->send = hci_uart_send_frame;
391− hdev->parent = hu->tty->dev;
391+ SET_HCIDEV_DEV(hdev, hu->tty->dev);
392392
393393 if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags))
394394 set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
drivers/bluetooth/hci_vhci.c+2−1
@@ -252,8 +252,9 @@ static int vhci_open(struct inode *inode, struct file *file) · 251 unmodified lines
252252 }
253253
254254 file->private_data = data;
255+ nonseekable_open(inode, file);
255256
256− return nonseekable_open(inode, file);
257+ return 0;
257258 }
258259
259260 static int vhci_release(struct inode *inode, struct file *file)
drivers/isdn/hardware/mISDN/hfcsusb.h+6−0
@@ -410,6 +410,12 @@ static struct usb_device_id hfcsusb_idtab[] = { · 409 unmodified lines
410410 {LED_SCHEME1, {0x88, -64, -32, -16},
411411 "ZyXEL OMNI.NET USB II"}),
412412 },
413+ {
414+ USB_DEVICE(0x1ae7, 0x0525),
415+ .driver_info = (unsigned long) &((struct hfcsusb_vdata)
416+ {LED_SCHEME1, {0x88, -64, -32, -16},
417+ "X-Tensions USB ISDN TA XC-525"}),
418+ },
413419 { }
414420 };
415421
drivers/net/ethernet/freescale/gianfar.c+1−1
@@ -1082,7 +1082,7 @@ static int gfar_probe(struct platform_device *ofdev) · 1081 unmodified lines
10821082
10831083 if (dev->features & NETIF_F_IP_CSUM ||
10841084 priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)
1085− dev->hard_header_len += GMAC_FCB_LEN;
1085+ dev->needed_headroom = GMAC_FCB_LEN;
10861086
10871087 /* Program the isrg regs only if number of grps > 1 */
10881088 if (priv->num_grps > 1) {
drivers/net/wireless/ath/ath6kl/cfg80211.c+167−71
@@ -693,8 +693,8 @@ ath6kl_add_bss_if_needed(struct ath6kl_vif *vif, · 692 unmodified lines
693693 ie, 2 + vif->ssid_len + beacon_ie_len,
694694 0, GFP_KERNEL);
695695 if (bss)
696− ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "added bss %pM to "
697− "cfg80211\n", bssid);
696+ ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
697+ "added bss %pM to cfg80211\n", bssid);
698698 kfree(ie);
699699 } else
700700 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "cfg80211 already has a bss\n");
@@ -882,6 +882,32 @@ void ath6kl_cfg80211_disconnect_event(struct ath6kl_vif *vif, u8 reason, · 181 unmodified lines
882882 vif->sme_state = SME_DISCONNECTED;
883883 }
884884
885+static int ath6kl_set_probed_ssids(struct ath6kl *ar,
886+ struct ath6kl_vif *vif,
887+ struct cfg80211_ssid *ssids, int n_ssids)
888+{
889+ u8 i;
890+
891+ if (n_ssids > MAX_PROBED_SSID_INDEX)
892+ return -EINVAL;
893+
894+ for (i = 0; i < n_ssids; i++) {
895+ ath6kl_wmi_probedssid_cmd(ar->wmi, vif->fw_vif_idx, i,
896+ ssids[i].ssid_len ?
897+ SPECIFIC_SSID_FLAG : ANY_SSID_FLAG,
898+ ssids[i].ssid_len,
899+ ssids[i].ssid);
900+ }
901+
902+ /* Make sure no old entries are left behind */
903+ for (i = n_ssids; i < MAX_PROBED_SSID_INDEX; i++) {
904+ ath6kl_wmi_probedssid_cmd(ar->wmi, vif->fw_vif_idx, i,
905+ DISABLE_SSID_FLAG, 0, NULL);
906+ }
907+
908+ return 0;
909+}
910+
885911 static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev,
886912 struct cfg80211_scan_request *request)
887913 {
@@ -899,36 +925,25 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, · 11 unmodified lines
899925
900926 if (!ar->usr_bss_filter) {
901927 clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags);
902− ret = ath6kl_wmi_bssfilter_cmd(
903− ar->wmi, vif->fw_vif_idx,
904− (test_bit(CONNECTED, &vif->flags) ?
905− ALL_BUT_BSS_FILTER : ALL_BSS_FILTER), 0);
928+ ret = ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
929+ ALL_BSS_FILTER, 0);
906930 if (ret) {
907931 ath6kl_err("couldn't set bss filtering\n");
908932 return ret;
909933 }
910934 }
911935
912− if (request->n_ssids && request->ssids[0].ssid_len) {
913− u8 i;
914−
915− if (request->n_ssids > (MAX_PROBED_SSID_INDEX - 1))
916− request->n_ssids = MAX_PROBED_SSID_INDEX - 1;
917−
918− for (i = 0; i < request->n_ssids; i++)
919− ath6kl_wmi_probedssid_cmd(ar->wmi, vif->fw_vif_idx,
920− i + 1, SPECIFIC_SSID_FLAG,
921− request->ssids[i].ssid_len,
922− request->ssids[i].ssid);
923− }
936+ ret = ath6kl_set_probed_ssids(ar, vif, request->ssids,
937+ request->n_ssids);
938+ if (ret < 0)
939+ return ret;
924940
925941 /* this also clears IE in fw if it's not set */
926942 ret = ath6kl_wmi_set_appie_cmd(ar->wmi, vif->fw_vif_idx,
927943 WMI_FRAME_PROBE_REQ,
928944 request->ie, request->ie_len);
929945 if (ret) {
930− ath6kl_err("failed to set Probe Request appie for "
931− "scan");
946+ ath6kl_err("failed to set Probe Request appie for scan");
932947 return ret;
933948 }
934949
@@ -945,8 +960,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, struct net_device *ndev, · 10 unmodified lines
945960
946961 channels = kzalloc(n_channels * sizeof(u16), GFP_KERNEL);
947962 if (channels == NULL) {
948− ath6kl_warn("failed to set scan channels, "
949− "scan all channels");
963+ ath6kl_warn("failed to set scan channels, scan all channels");
950964 n_channels = 0;
951965 }
952966
@@ -1018,6 +1032,20 @@ out: · 65 unmodified lines
10181032 vif->scan_req = NULL;
10191033 }
10201034
1035+void ath6kl_cfg80211_ch_switch_notify(struct ath6kl_vif *vif, int freq,
1036+ enum wmi_phy_mode mode)
1037+{
1038+ enum nl80211_channel_type type;
1039+
1040+ ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
1041+ "channel switch notify nw_type %d freq %d mode %d\n",
1042+ vif->nw_type, freq, mode);
1043+
1044+ type = (mode == WMI_11G_HT20) ? NL80211_CHAN_HT20 : NL80211_CHAN_NO_HT;
1045+
1046+ cfg80211_ch_switch_notify(vif->ndev, freq, type);
1047+}
1048+
10211049 static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
10221050 u8 key_index, bool pairwise,
10231051 const u8 *mac_addr,
@@ -1111,9 +1139,8 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, · 87 unmodified lines
11111139 ar->ap_mode_bkey.key_len = key->key_len;
11121140 memcpy(ar->ap_mode_bkey.key, key->key, key->key_len);
11131141 if (!test_bit(CONNECTED, &vif->flags)) {
1114− ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delay initial group "
1115− "key configuration until AP mode has been "
1116− "started\n");
1142+ ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
1143+ "Delay initial group key configuration until AP mode has been started\n");
11171144 /*
11181145 * The key will be set in ath6kl_connect_ap_mode() once
11191146 * the connected event is received from the target.
@@ -1129,8 +1156,8 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, · 9 unmodified lines
11291156 * the AP mode has properly started
11301157 * (ath6kl_install_statioc_wep_keys).
11311158 */
1132− ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delay WEP key configuration "
1133− "until AP mode has been started\n");
1159+ ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
1160+ "Delay WEP key configuration until AP mode has been started\n");
11341161 vif->wep_key_list[key_index].key_len = key->key_len;
11351162 memcpy(vif->wep_key_list[key_index].key, key->key,
11361163 key->key_len);
@@ -1962,8 +1989,7 @@ static int ath6kl_wow_sta(struct ath6kl *ar, struct ath6kl_vif *vif) · 825 unmodified lines
19621989 sizeof(discvr_pattern), discvr_offset,
19631990 discvr_pattern, discvr_mask);
19641991 if (ret) {
1965− ath6kl_err("failed to add WOW mDNS/SSDP/LLMNR "
1966− "pattern\n");
1992+ ath6kl_err("failed to add WOW mDNS/SSDP/LLMNR pattern\n");
19671993 return ret;
19681994 }
19691995 }
@@ -2031,6 +2057,10 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) · 61 unmodified lines
20312057 u8 index = 0;
20322058 __be32 ips[MAX_IP_ADDRS];
20332059
2060+ /* The FW currently can't support multi-vif WoW properly. */
2061+ if (ar->num_vif > 1)
2062+ return -EIO;
2063+
20342064 vif = ath6kl_vif_first(ar);
20352065 if (!vif)
20362066 return -EIO;
@@ -2044,6 +2074,13 @@ static int ath6kl_wow_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) · 7 unmodified lines
20442074 if (wow && (wow->n_patterns > WOW_MAX_FILTERS_PER_LIST))
20452075 return -EINVAL;
20462076
2077+ if (!test_bit(NETDEV_MCAST_ALL_ON, &vif->flags)) {
2078+ ret = ath6kl_wmi_mcast_filter_cmd(vif->ar->wmi,
2079+ vif->fw_vif_idx, false);
2080+ if (ret)
2081+ return ret;
2082+ }
2083+
20472084 /* Clear existing WOW patterns */
20482085 for (i = 0; i < WOW_MAX_FILTERS_PER_LIST; i++)
20492086 ath6kl_wmi_del_wow_pattern_cmd(ar->wmi, vif->fw_vif_idx,
@@ -2147,8 +2184,8 @@ static int ath6kl_wow_resume(struct ath6kl *ar) · 97 unmodified lines
21472184 ret = ath6kl_wmi_set_host_sleep_mode_cmd(ar->wmi, vif->fw_vif_idx,
21482185 ATH6KL_HOST_MODE_AWAKE);
21492186 if (ret) {
2150− ath6kl_warn("Failed to configure host sleep mode for "
2151− "wow resume: %d\n", ret);
2187+ ath6kl_warn("Failed to configure host sleep mode for wow resume: %d\n",
2188+ ret);
21522189 ar->state = ATH6KL_STATE_WOW;
21532190 return ret;
21542191 }
@@ -2172,6 +2209,13 @@ static int ath6kl_wow_resume(struct ath6kl *ar) · 17 unmodified lines
21722209
21732210 ar->state = ATH6KL_STATE_ON;
21742211
2212+ if (!test_bit(NETDEV_MCAST_ALL_OFF, &vif->flags)) {
2213+ ret = ath6kl_wmi_mcast_filter_cmd(vif->ar->wmi,
2214+ vif->fw_vif_idx, true);
2215+ if (ret)
2216+ return ret;
2217+ }
2218+
21752219 netif_wake_queue(vif->ndev);
21762220
21772221 return 0;
@@ -2186,8 +2230,10 @@ static int ath6kl_cfg80211_deepsleep_suspend(struct ath6kl *ar) · 8 unmodified lines
21862230 if (!vif)
21872231 return -EIO;
21882232
2189− if (!ath6kl_cfg80211_ready(vif))
2233+ if (!test_bit(WMI_READY, &ar->flag)) {
2234+ ath6kl_err("deepsleep failed as wmi is not ready\n");
21902235 return -EIO;
2236+ }
21912237
21922238 ath6kl_cfg80211_stop_all(ar);
21932239
@@ -2447,6 +2493,24 @@ static int ath6kl_set_htcap(struct ath6kl_vif *vif, enum ieee80211_band band, · 253 unmodified lines
24472493 band, htcap);
24482494 }
24492495
2496+static int ath6kl_restore_htcap(struct ath6kl_vif *vif)
2497+{
2498+ struct wiphy *wiphy = vif->ar->wiphy;
2499+ int band, ret = 0;
2500+
2501+ for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
2502+ if (!wiphy->bands[band])
2503+ continue;
2504+
2505+ ret = ath6kl_set_htcap(vif, band,
2506+ wiphy->bands[band]->ht_cap.ht_supported);
2507+ if (ret)
2508+ return ret;
2509+ }
2510+
2511+ return ret;
2512+}
2513+
24502514 static bool ath6kl_is_p2p_ie(const u8 *pos)
24512515 {
24522516 return pos[0] == WLAN_EID_VENDOR_SPECIFIC && pos[1] >= 4 &&
@@ -2568,28 +2632,34 @@ static int ath6kl_get_rsn_capab(struct cfg80211_beacon_data *beacon, · 115 unmodified lines
25682632 /* skip element id and length */
25692633 rsn_ie += 2;
25702634
2571− /* skip version, group cipher */
2572− if (rsn_ie_len < 6)
2635+ /* skip version */
2636+ if (rsn_ie_len < 2)
25732637 return -EINVAL;
2574− rsn_ie += 6;
2575− rsn_ie_len -= 6;
2638+ rsn_ie += 2;
2639+ rsn_ie_len -= 2;
2640+
2641+ /* skip group cipher suite */
2642+ if (rsn_ie_len < 4)
2643+ return 0;
2644+ rsn_ie += 4;
2645+ rsn_ie_len -= 4;
25762646
25772647 /* skip pairwise cipher suite */
25782648 if (rsn_ie_len < 2)
2579− return -EINVAL;
2580− cnt = *((u16 *) rsn_ie);
2649+ return 0;
2650+ cnt = get_unaligned_le16(rsn_ie);
25812651 rsn_ie += (2 + cnt * 4);
25822652 rsn_ie_len -= (2 + cnt * 4);
25832653
25842654 /* skip akm suite */
25852655 if (rsn_ie_len < 2)
2586− return -EINVAL;
2587− cnt = *((u16 *) rsn_ie);
2656+ return 0;
2657+ cnt = get_unaligned_le16(rsn_ie);
25882658 rsn_ie += (2 + cnt * 4);
25892659 rsn_ie_len -= (2 + cnt * 4);
25902660
25912661 if (rsn_ie_len < 2)
2592− return -EINVAL;
2662+ return 0;
25932663
25942664 memcpy(rsn_capab, rsn_ie, 2);
25952665
@@ -2766,6 +2836,7 @@ static int ath6kl_start_ap(struct wiphy *wiphy, struct net_device *dev, · 170 unmodified lines
27662836 return res;
27672837 }
27682838
2839+ memcpy(&vif->profile, &p, sizeof(p));
27692840 res = ath6kl_wmi_ap_profile_commit(ar->wmi, vif->fw_vif_idx, &p);
27702841 if (res < 0)
27712842 return res;
@@ -2801,13 +2872,7 @@ static int ath6kl_stop_ap(struct wiphy *wiphy, struct net_device *dev) · 29 unmodified lines
28012872 clear_bit(CONNECTED, &vif->flags);
28022873
28032874 /* Restore ht setting in firmware */
2804− if (ath6kl_set_htcap(vif, IEEE80211_BAND_2GHZ, true))
2805− return -EIO;
2806−
2807− if (ath6kl_set_htcap(vif, IEEE80211_BAND_5GHZ, true))
2808− return -EIO;
2809−
2810− return 0;
2875+ return ath6kl_restore_htcap(vif);
28112876 }
28122877
28132878 static const u8 bcast_addr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
@@ -3081,7 +3146,6 @@ static int ath6kl_cfg80211_sscan_start(struct wiphy *wiphy, · 267 unmodified lines
30813146 struct ath6kl_vif *vif = netdev_priv(dev);
30823147 u16 interval;
30833148 int ret;
3084− u8 i;
30853149
30863150 if (ar->state != ATH6KL_STATE_ON)
30873151 return -EIO;
@@ -3089,29 +3153,23 @@ static int ath6kl_cfg80211_sscan_start(struct wiphy *wiphy, · 1 unmodified line
30893153 if (vif->sme_state != SME_DISCONNECTED)
30903154 return -EBUSY;
30913155
3156+ /* The FW currently can't support multi-vif WoW properly. */
3157+ if (ar->num_vif > 1)
3158+ return -EIO;
3159+
30923160 ath6kl_cfg80211_scan_complete_event(vif, true);
30933161
3094− for (i = 0; i < ar->wiphy->max_sched_scan_ssids; i++) {
3095− ath6kl_wmi_probedssid_cmd(ar->wmi, vif->fw_vif_idx,
3096− i, DISABLE_SSID_FLAG,
3097− 0, NULL);
3098− }
3162+ ret = ath6kl_set_probed_ssids(ar, vif, request->ssids,
3163+ request->n_ssids);
3164+ if (ret < 0)
3165+ return ret;
30993166
31003167 /* fw uses seconds, also make sure that it's >0 */
31013168 interval = max_t(u16, 1, request->interval / 1000);
31023169
31033170 ath6kl_wmi_scanparams_cmd(ar->wmi, vif->fw_vif_idx,
31043171 interval, interval,
3105− 10, 0, 0, 0, 3, 0, 0, 0);
3106−
3107− if (request->n_ssids && request->ssids[0].ssid_len) {
3108− for (i = 0; i < request->n_ssids; i++) {
3109− ath6kl_wmi_probedssid_cmd(ar->wmi, vif->fw_vif_idx,
3110− i, SPECIFIC_SSID_FLAG,
3111− request->ssids[i].ssid_len,
3112− request->ssids[i].ssid);
3113− }
3114− }
3172+ vif->bg_scan_period, 0, 0, 0, 3, 0, 0, 0);
31153173
31163174 ret = ath6kl_wmi_set_wow_mode_cmd(ar->wmi, vif->fw_vif_idx,
31173175 ATH6KL_WOW_MODE_ENABLE,
@@ -3271,8 +3329,7 @@ void ath6kl_cfg80211_stop_all(struct ath6kl *ar) · 153 unmodified lines
32713329 ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode;
32723330
32733331 if (ath6kl_wmi_powermode_cmd(ar->wmi, 0, REC_POWER) != 0)
3274− ath6kl_warn("ath6kl_deep_sleep_enable: "
3275− "wmi_powermode_cmd failed\n");
3332+ ath6kl_warn("ath6kl_deep_sleep_enable: wmi_powermode_cmd failed\n");
32763333 return;
32773334 }
32783335
@@ -3352,6 +3409,7 @@ struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name, · 73 unmodified lines
33523409 vif->next_mode = nw_type;
33533410 vif->listen_intvl_t = ATH6KL_DEFAULT_LISTEN_INTVAL;
33543411 vif->bmiss_time_t = ATH6KL_DEFAULT_BMISS_TIME;
3412+ vif->bg_scan_period = 0;
33553413 vif->htcap.ht_enable = true;
33563414
33573415 memcpy(ndev->dev_addr, ar->mac_addr, ETH_ALEN);
@@ -3393,6 +3451,7 @@ err: · 35 unmodified lines
33933451 int ath6kl_cfg80211_init(struct ath6kl *ar)
33943452 {
33953453 struct wiphy *wiphy = ar->wiphy;
3454+ bool band_2gig = false, band_5gig = false, ht = false;
33963455 int ret;
33973456
33983457 wiphy->mgmt_stypes = ath6kl_mgmt_stypes;
@@ -3413,8 +3472,46 @@ int ath6kl_cfg80211_init(struct ath6kl *ar) · 14 unmodified lines
34133472 /* max num of ssids that can be probed during scanning */
34143473 wiphy->max_scan_ssids = MAX_PROBED_SSID_INDEX;
34153474 wiphy->max_scan_ie_len = 1000; /* FIX: what is correct limit? */
3416− wiphy->bands[IEEE80211_BAND_2GHZ] = &ath6kl_band_2ghz;
3417− wiphy->bands[IEEE80211_BAND_5GHZ] = &ath6kl_band_5ghz;
3475+ switch (ar->hw.cap) {
3476+ case WMI_11AN_CAP:
3477+ ht = true;
3478+ case WMI_11A_CAP:
3479+ band_5gig = true;
3480+ break;
3481+ case WMI_11GN_CAP:
3482+ ht = true;
3483+ case WMI_11G_CAP:
3484+ band_2gig = true;
3485+ break;
3486+ case WMI_11AGN_CAP:
3487+ ht = true;
3488+ case WMI_11AG_CAP:
3489+ band_2gig = true;
3490+ band_5gig = true;
3491+ break;
3492+ default:
3493+ ath6kl_err("invalid phy capability!\n");
3494+ return -EINVAL;
3495+ }
3496+
3497+ /*
3498+ * Even if the fw has HT support, advertise HT cap only when
3499+ * the firmware has support to override RSN capability, otherwise
3500+ * 4-way handshake would fail.
3501+ */
3502+ if (!(ht &&
3503+ test_bit(ATH6KL_FW_CAPABILITY_RSN_CAP_OVERRIDE,
3504+ ar->fw_capabilities))) {
3505+ ath6kl_band_2ghz.ht_cap.cap = 0;
3506+ ath6kl_band_2ghz.ht_cap.ht_supported = false;
3507+ ath6kl_band_5ghz.ht_cap.cap = 0;
3508+ ath6kl_band_5ghz.ht_cap.ht_supported = false;
3509+ }
3510+ if (band_2gig)
3511+ wiphy->bands[IEEE80211_BAND_2GHZ] = &ath6kl_band_2ghz;
3512+ if (band_5gig)
3513+ wiphy->bands[IEEE80211_BAND_5GHZ] = &ath6kl_band_5ghz;
3514+
34183515 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
34193516
34203517 wiphy->cipher_suites = cipher_suites;
@@ -3430,7 +3527,7 @@ int ath6kl_cfg80211_init(struct ath6kl *ar) · 9 unmodified lines
34303527 wiphy->wowlan.pattern_min_len = 1;
34313528 wiphy->wowlan.pattern_max_len = WOW_PATTERN_SIZE;
34323529
3433− wiphy->max_sched_scan_ssids = 10;
3530+ wiphy->max_sched_scan_ssids = MAX_PROBED_SSID_INDEX;
34343531
34353532 ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM |
34363533 WIPHY_FLAG_HAVE_AP_SME |
@@ -3447,8 +3544,7 @@ int ath6kl_cfg80211_init(struct ath6kl *ar) · 10 unmodified lines
34473544 ar->wiphy->probe_resp_offload =
34483545 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
34493546 NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 |
3450− NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P |
3451− NL80211_PROBE_RESP_OFFLOAD_SUPPORT_80211U;
3547+ NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P;
34523548
34533549 ret = wiphy_register(wiphy);
34543550 if (ret < 0) {
drivers/net/wireless/ath/ath6kl/cfg80211.h+2−0
@@ -28,6 +28,8 @@ enum ath6kl_cfg_suspend_mode { · 27 unmodified lines
2828 struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name,
2929 enum nl80211_iftype type,
3030 u8 fw_vif_idx, u8 nw_type);
31+void ath6kl_cfg80211_ch_switch_notify(struct ath6kl_vif *vif, int freq,
32+ enum wmi_phy_mode mode);
3133 void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted);
3234
3335 void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel,
drivers/net/wireless/ath/ath6kl/core.h+24−9
@@ -126,9 +126,9 @@ struct ath6kl_fw_ie { · 125 unmodified lines
126126 #define AR6003_HW_2_0_FIRMWARE_FILE "athwlan.bin.z77"
127127 #define AR6003_HW_2_0_TCMD_FIRMWARE_FILE "athtcmd_ram.bin"
128128 #define AR6003_HW_2_0_PATCH_FILE "data.patch.bin"
129−#define AR6003_HW_2_0_BOARD_DATA_FILE "ath6k/AR6003/hw2.0/bdata.bin"
129+#define AR6003_HW_2_0_BOARD_DATA_FILE AR6003_HW_2_0_FW_DIR "/bdata.bin"
130130 #define AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE \
131− "ath6k/AR6003/hw2.0/bdata.SD31.bin"
131+ AR6003_HW_2_0_FW_DIR "/bdata.SD31.bin"
132132
133133 /* AR6003 3.0 definitions */
134134 #define AR6003_HW_2_1_1_VERSION 0x30000582
@@ -139,25 +139,33 @@ struct ath6kl_fw_ie { · 4 unmodified lines
139139 #define AR6003_HW_2_1_1_UTF_FIRMWARE_FILE "utf.bin"
140140 #define AR6003_HW_2_1_1_TESTSCRIPT_FILE "nullTestFlow.bin"
141141 #define AR6003_HW_2_1_1_PATCH_FILE "data.patch.bin"
142−#define AR6003_HW_2_1_1_BOARD_DATA_FILE "ath6k/AR6003/hw2.1.1/bdata.bin"
142+#define AR6003_HW_2_1_1_BOARD_DATA_FILE AR6003_HW_2_1_1_FW_DIR "/bdata.bin"
143143 #define AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE \
144− "ath6k/AR6003/hw2.1.1/bdata.SD31.bin"
144+ AR6003_HW_2_1_1_FW_DIR "/bdata.SD31.bin"
145145
146146 /* AR6004 1.0 definitions */
147147 #define AR6004_HW_1_0_VERSION 0x30000623
148148 #define AR6004_HW_1_0_FW_DIR "ath6k/AR6004/hw1.0"
149149 #define AR6004_HW_1_0_FIRMWARE_FILE "fw.ram.bin"
150−#define AR6004_HW_1_0_BOARD_DATA_FILE "ath6k/AR6004/hw1.0/bdata.bin"
150+#define AR6004_HW_1_0_BOARD_DATA_FILE AR6004_HW_1_0_FW_DIR "/bdata.bin"
151151 #define AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE \
152− "ath6k/AR6004/hw1.0/bdata.DB132.bin"
152+ AR6004_HW_1_0_FW_DIR "/bdata.DB132.bin"
153153
154154 /* AR6004 1.1 definitions */
155155 #define AR6004_HW_1_1_VERSION 0x30000001
156156 #define AR6004_HW_1_1_FW_DIR "ath6k/AR6004/hw1.1"
157157 #define AR6004_HW_1_1_FIRMWARE_FILE "fw.ram.bin"
158−#define AR6004_HW_1_1_BOARD_DATA_FILE "ath6k/AR6004/hw1.1/bdata.bin"
158+#define AR6004_HW_1_1_BOARD_DATA_FILE AR6004_HW_1_1_FW_DIR "/bdata.bin"
159159 #define AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE \
160− "ath6k/AR6004/hw1.1/bdata.DB132.bin"
160+ AR6004_HW_1_1_FW_DIR "/bdata.DB132.bin"
161+
162+/* AR6004 1.2 definitions */
163+#define AR6004_HW_1_2_VERSION 0x300007e8
164+#define AR6004_HW_1_2_FW_DIR "ath6k/AR6004/hw1.2"
165+#define AR6004_HW_1_2_FIRMWARE_FILE "fw.ram.bin"
166+#define AR6004_HW_1_2_BOARD_DATA_FILE AR6004_HW_1_2_FW_DIR "/bdata.bin"
167+#define AR6004_HW_1_2_DEFAULT_BOARD_DATA_FILE \
168+ AR6004_HW_1_2_FW_DIR "/bdata.bin"
161169
162170 /* Per STA data, used in AP mode */
163171 #define STA_PS_AWAKE BIT(0)
@@ -502,6 +510,8 @@ enum ath6kl_vif_state { · 338 unmodified lines
502510 WLAN_ENABLED,
503511 STATS_UPDATE_PEND,
504512 HOST_SLEEP_MODE_CMD_PROCESSED,
513+ NETDEV_MCAST_ALL_ON,
514+ NETDEV_MCAST_ALL_OFF,
505515 };
506516
507517 struct ath6kl_vif {
@@ -549,9 +559,11 @@ struct ath6kl_vif { · 41 unmodified lines
549559 u16 assoc_bss_beacon_int;
550560 u16 listen_intvl_t;
551561 u16 bmiss_time_t;
562+ u16 bg_scan_period;
552563 u8 assoc_bss_dtim_period;
553564 struct net_device_stats net_stats;
554565 struct target_stats target_stats;
566+ struct wmi_connect_cmd profile;
555567
556568 struct list_head mc_filter;
557569 };
@@ -640,6 +652,7 @@ struct ath6kl { · 82 unmodified lines
640652 u8 sta_list_index;
641653 struct ath6kl_req_key ap_mode_bkey;
642654 struct sk_buff_head mcastpsq;
655+ u32 want_ch_switch;
643656
644657 /*
645658 * FIXME: protects access to mcastpsq but is actually useless as
@@ -672,6 +685,7 @@ struct ath6kl { · 26 unmodified lines
672685 u32 refclk_hz;
673686 u32 uarttx_pin;
674687 u32 testscript_addr;
688+ enum wmi_phy_cap cap;
675689
676690 struct ath6kl_hw_fw {
677691 const char *dir;
@@ -805,7 +819,8 @@ void aggr_reset_state(struct aggr_info_conn *aggr_conn); · 127 unmodified lines
805819 struct ath6kl_sta *ath6kl_find_sta(struct ath6kl_vif *vif, u8 *node_addr);
806820 struct ath6kl_sta *ath6kl_find_sta_by_aid(struct ath6kl *ar, u8 aid);
807821
808−void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver);
822+void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver,
823+ enum wmi_phy_cap cap);
809824 int ath6kl_control_tx(void *devt, struct sk_buff *skb,
810825 enum htc_endpoint_id eid);
811826 void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel,
drivers/net/wireless/ath/ath6kl/debug.c+11−1
@@ -401,8 +401,10 @@ static ssize_t ath6kl_fwlog_block_read(struct file *file, · 400 unmodified lines
401401
402402 ret = wait_for_completion_interruptible(
403403 &ar->debug.fwlog_completion);
404− if (ret == -ERESTARTSYS)
404+ if (ret == -ERESTARTSYS) {
405+ vfree(buf);
405406 return ret;
407+ }
406408
407409 spin_lock(&ar->debug.fwlog_queue.lock);
408410 }
@@ -1570,10 +1572,15 @@ static ssize_t ath6kl_bgscan_int_write(struct file *file, · 1161 unmodified lines
15701572 size_t count, loff_t *ppos)
15711573 {
15721574 struct ath6kl *ar = file->private_data;
1575+ struct ath6kl_vif *vif;
15731576 u16 bgscan_int;
15741577 char buf[32];
15751578 ssize_t len;
15761579
1580+ vif = ath6kl_vif_first(ar);
1581+ if (!vif)
1582+ return -EIO;
1583+
15771584 len = min(count, sizeof(buf) - 1);
15781585 if (copy_from_user(buf, user_buf, len))
15791586 return -EFAULT;
@@ -1585,6 +1592,8 @@ static ssize_t ath6kl_bgscan_int_write(struct file *file, · 5 unmodified lines
15851592 if (bgscan_int == 0)
15861593 bgscan_int = 0xffff;
15871594
1595+ vif->bg_scan_period = bgscan_int;
1596+
15881597 ath6kl_wmi_scanparams_cmd(ar->wmi, 0, 0, 0, bgscan_int, 0, 0, 0, 3,
15891598 0, 0, 0);
15901599
@@ -1809,6 +1818,7 @@ int ath6kl_debug_init_fs(struct ath6kl *ar) · 218 unmodified lines
18091818 void ath6kl_debug_cleanup(struct ath6kl *ar)
18101819 {
18111820 skb_queue_purge(&ar->debug.fwlog_queue);
1821+ complete(&ar->debug.fwlog_completion);
18121822 kfree(ar->debug.roam_tbl);
18131823 }
18141824
drivers/net/wireless/ath/ath6kl/htc_mbox.c+28−17
@@ -83,10 +83,7 @@ static void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info, · 82 unmodified lines
8383 * never goes inactive EVER.
8484 */
8585 cur_ep_dist->dist_flags |= HTC_EP_ACTIVE;
86− } else if (cur_ep_dist->svc_id == WMI_DATA_BK_SVC)
87− /* this is the lowest priority data endpoint */
88− /* FIXME: this looks fishy, check */
89− cred_info->lowestpri_ep_dist = cur_ep_dist->list;
86+ }
9087
9188 /*
9289 * Streams have to be created (explicit | implicit) for all
@@ -100,6 +97,13 @@ static void ath6kl_credit_init(struct ath6kl_htc_credit_info *cred_info, · 7 unmodified lines
10097 */
10198 }
10299
100+ /*
101+ * For ath6kl_credit_seek function,
102+ * it use list_for_each_entry_reverse to walk around the whole ep list.
103+ * Therefore assign this lowestpri_ep_dist after walk around the ep_list
104+ */
105+ cred_info->lowestpri_ep_dist = cur_ep_dist->list;
106+
103107 WARN_ON(cred_info->cur_free_credits <= 0);
104108
105109 list_for_each_entry(cur_ep_dist, ep_list, list) {
@@ -758,7 +762,7 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, · 652 unmodified lines
758762 u32 txb_mask;
759763 u8 ac = WMM_NUM_AC;
760764
761− if ((HTC_CTRL_RSVD_SVC != endpoint->svc_id) ||
765+ if ((HTC_CTRL_RSVD_SVC != endpoint->svc_id) &&
762766 (WMI_CONTROL_SVC != endpoint->svc_id))
763767 ac = target->dev->ar->ep2ac_map[endpoint->eid];
764768
@@ -793,16 +797,17 @@ static void ath6kl_htc_tx_bundle(struct htc_endpoint *endpoint, · 28 unmodified lines
793797 * itself
794798 */
795799 txb_mask = ((1 << ac) - 1);
796− /*
797− * when the scatter request resources drop below a
798− * certain threshold, disable Tx bundling for all
799− * AC's with priority lower than the current requesting
800− * AC. Otherwise re-enable Tx bundling for them
801− */
802− if (scat_req->scat_q_depth < ATH6KL_SCATTER_REQS)
803− target->tx_bndl_mask &= ~txb_mask;
804− else
805− target->tx_bndl_mask |= txb_mask;
800+
801+ /*
802+ * when the scatter request resources drop below a
803+ * certain threshold, disable Tx bundling for all
804+ * AC's with priority lower than the current requesting
805+ * AC. Otherwise re-enable Tx bundling for them
806+ */
807+ if (scat_req->scat_q_depth < ATH6KL_SCATTER_REQS)
808+ target->tx_bndl_mask &= ~txb_mask;
809+ else
810+ target->tx_bndl_mask |= txb_mask;
806811 }
807812
808813 ath6kl_dbg(ATH6KL_DBG_HTC, "htc tx pkts to scatter: %d\n",
@@ -849,6 +854,7 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, · 40 unmodified lines
849854 int bundle_sent;
850855 int n_pkts_bundle;
851856 u8 ac = WMM_NUM_AC;
857+ int status;
852858
853859 spin_lock_bh(&target->tx_lock);
854860
@@ -866,7 +872,7 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, · 11 unmodified lines
866872 */
867873 INIT_LIST_HEAD(&txq);
868874
869− if ((HTC_CTRL_RSVD_SVC != endpoint->svc_id) ||
875+ if ((HTC_CTRL_RSVD_SVC != endpoint->svc_id) &&
870876 (WMI_CONTROL_SVC != endpoint->svc_id))
871877 ac = target->dev->ar->ep2ac_map[endpoint->eid];
872878
@@ -910,7 +916,12 @@ static void ath6kl_htc_tx_from_queue(struct htc_target *target, · 37 unmodified lines
910916
911917 ath6kl_htc_tx_prep_pkt(packet, packet->info.tx.flags,
912918 0, packet->info.tx.seqno);
913− ath6kl_htc_tx_issue(target, packet);
919+ status = ath6kl_htc_tx_issue(target, packet);
920+
921+ if (status) {
922+ packet->status = status;
923+ packet->completion(packet->context, packet);
924+ }
914925 }
915926
916927 spin_lock_bh(&target->tx_lock);
drivers/net/wireless/ath/ath6kl/htc_pipe.c+3−8
@@ -108,8 +108,6 @@ static void get_htc_packet_credit_based(struct htc_target *target, · 107 unmodified lines
108108
109109 /* get packet at head, but don't remove it */
110110 packet = list_first_entry(&ep->txq, struct htc_packet, list);
111− if (packet == NULL)
112− break;
113111
114112 ath6kl_dbg(ATH6KL_DBG_HTC,
115113 "%s: got head packet:0x%p , queue depth: %d\n",
@@ -803,8 +801,6 @@ static int htc_send_packets_multiple(struct htc_target *target, · 687 unmodified lines
803801
804802 /* get first packet to find out which ep the packets will go into */
805803 packet = list_first_entry(pkt_queue, struct htc_packet, list);
806− if (packet == NULL)
807− return -EINVAL;
808804
809805 if (packet->endpoint >= ENDPOINT_MAX) {
810806 WARN_ON_ONCE(1);
@@ -1382,6 +1378,9 @@ static int ath6kl_htc_pipe_conn_service(struct htc_target *target, · 571 unmodified lines
13821378 /* copy all the callbacks */
13831379 ep->ep_cb = conn_req->ep_cb;
13841380
1381+ /* initialize tx_drop_packet_threshold */
1382+ ep->tx_drop_packet_threshold = MAX_HI_COOKIE_NUM;
1383+
13851384 status = ath6kl_hif_pipe_map_service(ar, ep->svc_id,
13861385 &ep->pipe.pipeid_ul,
13871386 &ep->pipe.pipeid_dl);
@@ -1636,10 +1635,6 @@ static int ath6kl_htc_pipe_add_rxbuf_multiple(struct htc_target *target, · 248 unmodified lines
16361635 return -EINVAL;
16371636
16381637 first = list_first_entry(pkt_queue, struct htc_packet, list);
1639− if (first == NULL) {
1640− WARN_ON_ONCE(1);
1641− return -EINVAL;
1642− }
16431638
16441639 if (first->endpoint >= ENDPOINT_MAX) {
16451640 WARN_ON_ONCE(1);
drivers/net/wireless/ath/ath6kl/init.c+24−5
@@ -119,6 +119,24 @@ static const struct ath6kl_hw hw_list[] = { · 118 unmodified lines
119119 .fw_board = AR6004_HW_1_1_BOARD_DATA_FILE,
120120 .fw_default_board = AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE,
121121 },
122+ {
123+ .id = AR6004_HW_1_2_VERSION,
124+ .name = "ar6004 hw 1.2",
125+ .dataset_patch_addr = 0x436ecc,
126+ .app_load_addr = 0x1234,
127+ .board_ext_data_addr = 0x437000,
128+ .reserved_ram_size = 9216,
129+ .board_addr = 0x435c00,
130+ .refclk_hz = 40000000,
131+ .uarttx_pin = 11,
132+
133+ .fw = {
134+ .dir = AR6004_HW_1_2_FW_DIR,
135+ .fw = AR6004_HW_1_2_FIRMWARE_FILE,
136+ },
137+ .fw_board = AR6004_HW_1_2_BOARD_DATA_FILE,
138+ .fw_default_board = AR6004_HW_1_2_DEFAULT_BOARD_DATA_FILE,
139+ },
122140 };
123141
124142 /*
@@ -445,9 +463,9 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx) · 320 unmodified lines
445463 P2P_FLAG_MACADDR_REQ |
446464 P2P_FLAG_HMODEL_REQ);
447465 if (ret) {
448− ath6kl_dbg(ATH6KL_DBG_TRC, "failed to request P2P "
449− "capabilities (%d) - assuming P2P not "
450− "supported\n", ret);
466+ ath6kl_dbg(ATH6KL_DBG_TRC,
467+ "failed to request P2P capabilities (%d) - assuming P2P not supported\n",
468+ ret);
451469 ar->p2p = false;
452470 }
453471 }
@@ -456,8 +474,9 @@ static int ath6kl_target_config_wlan_params(struct ath6kl *ar, int idx) · 2 unmodified lines
456474 /* Enable Probe Request reporting for P2P */
457475 ret = ath6kl_wmi_probe_report_req_cmd(ar->wmi, idx, true);
458476 if (ret) {
459− ath6kl_dbg(ATH6KL_DBG_TRC, "failed to enable Probe "
460− "Request reporting (%d)\n", ret);
477+ ath6kl_dbg(ATH6KL_DBG_TRC,
478+ "failed to enable Probe Request reporting (%d)\n",
479+ ret);
461480 }
462481 }
463482
drivers/net/wireless/ath/ath6kl/main.c+88−16
@@ -421,8 +421,8 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel) · 420 unmodified lines
421421 if (!ik->valid)
422422 break;
423423
424− ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delayed addkey for "
425− "the initial group key for AP mode\n");
424+ ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
425+ "Delayed addkey for the initial group key for AP mode\n");
426426 memset(key_rsc, 0, sizeof(key_rsc));
427427 res = ath6kl_wmi_addkey_cmd(
428428 ar->wmi, vif->fw_vif_idx, ik->key_index, ik->key_type,
@@ -430,12 +430,19 @@ void ath6kl_connect_ap_mode_bss(struct ath6kl_vif *vif, u16 channel) · 1 unmodified line
430430 ik->key,
431431 KEY_OP_INIT_VAL, NULL, SYNC_BOTH_WMIFLAG);
432432 if (res) {
433− ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "Delayed "
434− "addkey failed: %d\n", res);
433+ ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
434+ "Delayed addkey failed: %d\n", res);
435435 }
436436 break;
437437 }
438438
439+ if (ar->want_ch_switch & (1 << vif->fw_vif_idx)) {
440+ ar->want_ch_switch &= ~(1 << vif->fw_vif_idx);
441+ /* we actually don't know the phymode, default to HT20 */
442+ ath6kl_cfg80211_ch_switch_notify(vif, channel,
443+ WMI_11G_HT20);
444+ }
445+
439446 ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, NONE_BSS_FILTER, 0);
440447 set_bit(CONNECTED, &vif->flags);
441448 netif_carrier_on(vif->ndev);
@@ -541,7 +548,8 @@ void ath6kl_disconnect(struct ath6kl_vif *vif) · 99 unmodified lines
541548
542549 /* WMI Event handlers */
543550
544−void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver)
551+void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver,
552+ enum wmi_phy_cap cap)
545553 {
546554 struct ath6kl *ar = devt;
547555
@@ -551,6 +559,7 @@ void ath6kl_ready_event(void *devt, u8 *datap, u32 sw_ver, u32 abi_ver) · 3 unmodified lines
551559
552560 ar->version.wlan_ver = sw_ver;
553561 ar->version.abi_ver = abi_ver;
562+ ar->hw.cap = cap;
554563
555564 snprintf(ar->wiphy->fw_version,
556565 sizeof(ar->wiphy->fw_version),
@@ -584,6 +593,45 @@ void ath6kl_scan_complete_evt(struct ath6kl_vif *vif, int status) · 27 unmodified lines
584593 ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "scan complete: %d\n", status);
585594 }
586595
596+static int ath6kl_commit_ch_switch(struct ath6kl_vif *vif, u16 channel)
597+{
598+
599+ struct ath6kl *ar = vif->ar;
600+
601+ vif->next_chan = channel;
602+ vif->profile.ch = cpu_to_le16(channel);
603+
604+ switch (vif->nw_type) {
605+ case AP_NETWORK:
606+ return ath6kl_wmi_ap_profile_commit(ar->wmi, vif->fw_vif_idx,
607+ &vif->profile);
608+ default:
609+ ath6kl_err("won't switch channels nw_type=%d\n", vif->nw_type);
610+ return -ENOTSUPP;
611+ }
612+}
613+
614+static void ath6kl_check_ch_switch(struct ath6kl *ar, u16 channel)
615+{
616+
617+ struct ath6kl_vif *vif;
618+ int res = 0;
619+
620+ if (!ar->want_ch_switch)
621+ return;
622+
623+ spin_lock_bh(&ar->list_lock);
624+ list_for_each_entry(vif, &ar->vif_list, list) {
625+ if (ar->want_ch_switch & (1 << vif->fw_vif_idx))
626+ res = ath6kl_commit_ch_switch(vif, channel);
627+
628+ if (res)
629+ ath6kl_err("channel switch failed nw_type %d res %d\n",
630+ vif->nw_type, res);
631+ }
632+ spin_unlock_bh(&ar->list_lock);
633+}
634+
587635 void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid,
588636 u16 listen_int, u16 beacon_int,
589637 enum network_type net_type, u8 beacon_ie_len,
@@ -601,9 +649,11 @@ void ath6kl_connect_event(struct ath6kl_vif *vif, u16 channel, u8 *bssid, · 11 unmodified lines
601649 memcpy(vif->bssid, bssid, sizeof(vif->bssid));
602650 vif->bss_ch = channel;
603651
604− if ((vif->nw_type == INFRA_NETWORK))
652+ if ((vif->nw_type == INFRA_NETWORK)) {
605653 ath6kl_wmi_listeninterval_cmd(ar->wmi, vif->fw_vif_idx,
606654 vif->listen_intvl_t, 0);
655+ ath6kl_check_ch_switch(ar, channel);
656+ }
607657
608658 netif_wake_queue(vif->ndev);
609659
@@ -926,6 +976,11 @@ void ath6kl_disconnect_event(struct ath6kl_vif *vif, u8 reason, u8 *bssid, · 316 unmodified lines
926976 struct ath6kl *ar = vif->ar;
927977
928978 if (vif->nw_type == AP_NETWORK) {
979+ /* disconnect due to other STA vif switching channels */
980+ if (reason == BSS_DISCONNECTED &&
981+ prot_reason_status == WMI_AP_REASON_STA_ROAM)
982+ ar->want_ch_switch |= 1 << vif->fw_vif_idx;
983+
929984 if (!ath6kl_remove_sta(ar, bssid, prot_reason_status))
930985 return;
931986
@@ -1090,7 +1145,7 @@ static int ath6kl_set_features(struct net_device *dev, · 158 unmodified lines
10901145 static void ath6kl_set_multicast_list(struct net_device *ndev)
10911146 {
10921147 struct ath6kl_vif *vif = netdev_priv(ndev);
1093− bool mc_all_on = false, mc_all_off = false;
1148+ bool mc_all_on = false;
10941149 int mc_count = netdev_mc_count(ndev);
10951150 struct netdev_hw_addr *ha;
10961151 bool found;
@@ -1102,24 +1157,41 @@ static void ath6kl_set_multicast_list(struct net_device *ndev) · 5 unmodified lines
11021157 !test_bit(WLAN_ENABLED, &vif->flags))
11031158 return;
11041159
1160+ /* Enable multicast-all filter. */
11051161 mc_all_on = !!(ndev->flags & IFF_PROMISC) ||
11061162 !!(ndev->flags & IFF_ALLMULTI) ||
11071163 !!(mc_count > ATH6K_MAX_MC_FILTERS_PER_LIST);
11081164
1109− mc_all_off = !(ndev->flags & IFF_MULTICAST) || mc_count == 0;
1165+ if (mc_all_on)
1166+ set_bit(NETDEV_MCAST_ALL_ON, &vif->flags);
1167+ else
1168+ clear_bit(NETDEV_MCAST_ALL_ON, &vif->flags);
1169+
1170+ mc_all_on = mc_all_on || (vif->ar->state == ATH6KL_STATE_ON);
11101171
1111− if (mc_all_on || mc_all_off) {
1112− /* Enable/disable all multicast */
1113− ath6kl_dbg(ATH6KL_DBG_TRC, "%s multicast filter\n",
1114− mc_all_on ? "enabling" : "disabling");
1115− ret = ath6kl_wmi_mcast_filter_cmd(vif->ar->wmi, vif->fw_vif_idx,
1172+ if (!(ndev->flags & IFF_MULTICAST)) {
1173+ mc_all_on = false;
1174+ set_bit(NETDEV_MCAST_ALL_OFF, &vif->flags);
1175+ } else {
1176+ clear_bit(NETDEV_MCAST_ALL_OFF, &vif->flags);
1177+ }
1178+
1179+ /* Enable/disable "multicast-all" filter*/
1180+ ath6kl_dbg(ATH6KL_DBG_TRC, "%s multicast-all filter\n",
1181+ mc_all_on ? "enabling" : "disabling");
1182+
1183+ ret = ath6kl_wmi_mcast_filter_cmd(vif->ar->wmi, vif->fw_vif_idx,
11161184 mc_all_on);
1117− if (ret)
1118− ath6kl_warn("Failed to %s multicast receive\n",
1119− mc_all_on ? "enable" : "disable");
1185+ if (ret) {
1186+ ath6kl_warn("Failed to %s multicast-all receive\n",
1187+ mc_all_on ? "enable" : "disable");
11201188 return;
11211189 }
11221190
1191+ if (test_bit(NETDEV_MCAST_ALL_ON, &vif->flags))
1192+ return;
1193+
1194+ /* Keep the driver and firmware mcast list in sync. */
11231195 list_for_each_entry_safe(mc_filter, tmp, &vif->mc_filter, list) {
11241196 found = false;
11251197 netdev_for_each_mc_addr(ha, ndev) {
drivers/net/wireless/ath/ath6kl/sdio.c+11−6
@@ -552,7 +552,7 @@ static int ath6kl_sdio_write_async(struct ath6kl *ar, u32 address, u8 *buffer, · 551 unmodified lines
552552
553553 bus_req = ath6kl_sdio_alloc_busreq(ar_sdio);
554554
555− if (!bus_req)
555+ if (WARN_ON_ONCE(!bus_req))
556556 return -ENOMEM;
557557
558558 bus_req->address = address;
@@ -915,6 +915,9 @@ static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow) · 356 unmodified lines
915915 }
916916
917917 cut_pwr:
918+ if (func->card && func->card->host)
919+ func->card->host->pm_flags &= ~MMC_PM_KEEP_POWER;
920+
918921 return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_CUTPOWER, NULL);
919922 }
920923
@@ -985,9 +988,8 @@ static int ath6kl_set_addrwin_reg(struct ath6kl *ar, u32 reg_addr, u32 addr) · 64 unmodified lines
985988 }
986989
987990 if (status) {
988− ath6kl_err("%s: failed to write initial bytes of 0x%x "
989− "to window reg: 0x%X\n", __func__,
990− addr, reg_addr);
991+ ath6kl_err("%s: failed to write initial bytes of 0x%x to window reg: 0x%X\n",
992+ __func__, addr, reg_addr);
991993 return status;
992994 }
993995
@@ -1076,8 +1078,8 @@ static int ath6kl_sdio_bmi_credits(struct ath6kl *ar) · 82 unmodified lines
10761078 (u8 *)&ar->bmi.cmd_credits, 4,
10771079 HIF_RD_SYNC_BYTE_INC);
10781080 if (ret) {
1079− ath6kl_err("Unable to decrement the command credit "
1080− "count register: %d\n", ret);
1081+ ath6kl_err("Unable to decrement the command credit count register: %d\n",
1082+ ret);
10811083 return ret;
10821084 }
10831085
@@ -1457,3 +1459,6 @@ MODULE_FIRMWARE(AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE); · 373 unmodified lines
14571459 MODULE_FIRMWARE(AR6004_HW_1_1_FW_DIR "/" AR6004_HW_1_1_FIRMWARE_FILE);
14581460 MODULE_FIRMWARE(AR6004_HW_1_1_BOARD_DATA_FILE);
14591461 MODULE_FIRMWARE(AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE);
1462+MODULE_FIRMWARE(AR6004_HW_1_2_FW_DIR "/" AR6004_HW_1_2_FIRMWARE_FILE);
1463+MODULE_FIRMWARE(AR6004_HW_1_2_BOARD_DATA_FILE);
1464+MODULE_FIRMWARE(AR6004_HW_1_2_DEFAULT_BOARD_DATA_FILE);
drivers/net/wireless/ath/ath6kl/txrx.c+4−8
@@ -362,15 +362,11 @@ int ath6kl_data_tx(struct sk_buff *skb, struct net_device *dev) · 361 unmodified lines
362362 skb, skb->data, skb->len);
363363
364364 /* If target is not associated */
365− if (!test_bit(CONNECTED, &vif->flags)) {
366− dev_kfree_skb(skb);
367− return 0;
368− }
365+ if (!test_bit(CONNECTED, &vif->flags))
366+ goto fail_tx;
369367
370− if (WARN_ON_ONCE(ar->state != ATH6KL_STATE_ON)) {
371− dev_kfree_skb(skb);
372− return 0;
373− }
368+ if (WARN_ON_ONCE(ar->state != ATH6KL_STATE_ON))
369+ goto fail_tx;
374370
375371 if (!test_bit(WMI_READY, &ar->flag))
376372 goto fail_tx;
drivers/net/wireless/ath/ath6kl/usb.c+12−0
@@ -1037,6 +1037,14 @@ static void ath6kl_usb_stop(struct ath6kl *ar) · 1036 unmodified lines
10371037 hif_stop(ar);
10381038 }
10391039
1040+static void ath6kl_usb_cleanup_scatter(struct ath6kl *ar)
1041+{
1042+ /*
1043+ * USB doesn't support it. Just return.
1044+ */
1045+ return;
1046+}
1047+
10401048 static const struct ath6kl_hif_ops ath6kl_usb_ops = {
10411049 .diag_read32 = ath6kl_usb_diag_read32,
10421050 .diag_write32 = ath6kl_usb_diag_write32,
@@ -1049,6 +1057,7 @@ static const struct ath6kl_hif_ops ath6kl_usb_ops = { · 6 unmodified lines
10491057 .pipe_get_default = ath6kl_usb_get_default_pipe,
10501058 .pipe_map_service = ath6kl_usb_map_service_pipe,
10511059 .pipe_get_free_queue_number = ath6kl_usb_get_free_queue_number,
1060+ .cleanup_scatter = ath6kl_usb_cleanup_scatter,
10521061 };
10531062
10541063 /* ath6kl usb driver registered functions */
@@ -1208,3 +1217,6 @@ MODULE_FIRMWARE(AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE); · 153 unmodified lines
12081217 MODULE_FIRMWARE(AR6004_HW_1_1_FIRMWARE_FILE);
12091218 MODULE_FIRMWARE(AR6004_HW_1_1_BOARD_DATA_FILE);
12101219 MODULE_FIRMWARE(AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE);
1220+MODULE_FIRMWARE(AR6004_HW_1_2_FIRMWARE_FILE);
1221+MODULE_FIRMWARE(AR6004_HW_1_2_BOARD_DATA_FILE);
1222+MODULE_FIRMWARE(AR6004_HW_1_2_DEFAULT_BOARD_DATA_FILE);
drivers/net/wireless/ath/ath6kl/wmi.c+57−37
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 */
1717
1818 #include <linux/ip.h>
19+#include <linux/in.h>
1920 #include "core.h"
2021 #include "debug.h"
2122 #include "testmode.h"
@@ -289,6 +290,13 @@ int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx, · 267 unmodified lines
289290 layer2_priority);
290291 } else
291292 usr_pri = layer2_priority & 0x7;
293+
294+ /*
295+ * Queue the EAPOL frames in the same WMM_AC_VO queue
296+ * as that of management frames.
297+ */
298+ if (skb->protocol == cpu_to_be16(ETH_P_PAE))
299+ usr_pri = WMI_VOICE_USER_PRIORITY;
292300 }
293301
294302 /*
@@ -460,8 +468,9 @@ static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, · 165 unmodified lines
460468 freq, dur);
461469 chan = ieee80211_get_channel(ar->wiphy, freq);
462470 if (!chan) {
463− ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel "
464− "(freq=%u)\n", freq);
471+ ath6kl_dbg(ATH6KL_DBG_WMI,
472+ "remain_on_chnl: Unknown channel (freq=%u)\n",
473+ freq);
465474 return -EINVAL;
466475 }
467476 id = vif->last_roc_id;
@@ -488,12 +497,14 @@ static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, · 20 unmodified lines
488497 ev = (struct wmi_cancel_remain_on_chnl_event *) datap;
489498 freq = le32_to_cpu(ev->freq);
490499 dur = le32_to_cpu(ev->duration);
491− ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u "
492− "status=%u\n", freq, dur, ev->status);
500+ ath6kl_dbg(ATH6KL_DBG_WMI,
501+ "cancel_remain_on_chnl: freq=%u dur=%u status=%u\n",
502+ freq, dur, ev->status);
493503 chan = ieee80211_get_channel(ar->wiphy, freq);
494504 if (!chan) {
495− ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown "
496− "channel (freq=%u)\n", freq);
505+ ath6kl_dbg(ATH6KL_DBG_WMI,
506+ "cancel_remain_on_chnl: Unknown channel (freq=%u)\n",
507+ freq);
497508 return -EINVAL;
498509 }
499510 if (vif->last_cancel_roc_id &&
@@ -548,12 +559,12 @@ static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len, · 48 unmodified lines
548559 freq = le32_to_cpu(ev->freq);
549560 dlen = le16_to_cpu(ev->len);
550561 if (datap + len < ev->data + dlen) {
551− ath6kl_err("invalid wmi_p2p_rx_probe_req_event: "
552− "len=%d dlen=%u\n", len, dlen);
562+ ath6kl_err("invalid wmi_p2p_rx_probe_req_event: len=%d dlen=%u\n",
563+ len, dlen);
553564 return -EINVAL;
554565 }
555− ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u "
556− "probe_req_report=%d\n",
566+ ath6kl_dbg(ATH6KL_DBG_WMI,
567+ "rx_probe_req: len=%u freq=%u probe_req_report=%d\n",
557568 dlen, freq, vif->probe_req_report);
558569
559570 if (vif->probe_req_report || vif->nw_type == AP_NETWORK)
@@ -592,8 +603,8 @@ static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len, · 32 unmodified lines
592603 freq = le32_to_cpu(ev->freq);
593604 dlen = le16_to_cpu(ev->len);
594605 if (datap + len < ev->data + dlen) {
595− ath6kl_err("invalid wmi_rx_action_event: "
596− "len=%d dlen=%u\n", len, dlen);
606+ ath6kl_err("invalid wmi_rx_action_event: len=%d dlen=%u\n",
607+ len, dlen);
597608 return -EINVAL;
598609 }
599610 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq);
@@ -687,7 +698,7 @@ static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) · 87 unmodified lines
687698
688699 ath6kl_ready_event(wmi->parent_dev, ev->mac_addr,
689700 le32_to_cpu(ev->sw_version),
690− le32_to_cpu(ev->abi_version));
701+ le32_to_cpu(ev->abi_version), ev->phy_cap);
691702
692703 return 0;
693704 }
@@ -777,16 +788,15 @@ static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, · 83 unmodified lines
777788 /* AP mode start/STA connected event */
778789 struct net_device *dev = vif->ndev;
779790 if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) {
780− ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM "
781− "(AP started)\n",
791+ ath6kl_dbg(ATH6KL_DBG_WMI,
792+ "%s: freq %d bssid %pM (AP started)\n",
782793 __func__, le16_to_cpu(ev->u.ap_bss.ch),
783794 ev->u.ap_bss.bssid);
784795 ath6kl_connect_ap_mode_bss(
785796 vif, le16_to_cpu(ev->u.ap_bss.ch));
786797 } else {
787− ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM "
788− "auth=%u keymgmt=%u cipher=%u apsd_info=%u "
789− "(STA connected)\n",
798+ ath6kl_dbg(ATH6KL_DBG_WMI,
799+ "%s: aid %u mac_addr %pM auth=%u keymgmt=%u cipher=%u apsd_info=%u (STA connected)\n",
790800 __func__, ev->u.ap_sta.aid,
791801 ev->u.ap_sta.mac_addr,
792802 ev->u.ap_sta.auth,
@@ -1229,8 +1239,9 @@ static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap, · 436 unmodified lines
12291239 ev = (struct wmi_neighbor_report_event *) datap;
12301240 if (sizeof(*ev) + ev->num_neighbors * sizeof(struct wmi_neighbor_info)
12311241 > len) {
1232− ath6kl_dbg(ATH6KL_DBG_WMI, "truncated neighbor event "
1233− "(num=%d len=%d)\n", ev->num_neighbors, len);
1242+ ath6kl_dbg(ATH6KL_DBG_WMI,
1243+ "truncated neighbor event (num=%d len=%d)\n",
1244+ ev->num_neighbors, len);
12341245 return -EINVAL;
12351246 }
12361247 for (i = 0; i < ev->num_neighbors; i++) {
@@ -1814,12 +1825,14 @@ int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx, · 577 unmodified lines
18141825 u32 home_dwell_time, u32 force_scan_interval,
18151826 s8 num_chan, u16 *ch_list, u32 no_cck, u32 *rates)
18161827 {
1828+ struct ieee80211_supported_band *sband;
18171829 struct sk_buff *skb;
18181830 struct wmi_begin_scan_cmd *sc;
1819− s8 size;
1831+ s8 size, *supp_rates;
18201832 int i, band, ret;
18211833 struct ath6kl *ar = wmi->parent_dev;
18221834 int num_rates;
1835+ u32 ratemask;
18231836
18241837 size = sizeof(struct wmi_begin_scan_cmd);
18251838
@@ -1846,10 +1859,13 @@ int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx, · 20 unmodified lines
18461859 sc->num_ch = num_chan;
18471860
18481861 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
1849− struct ieee80211_supported_band *sband =
1850− ar->wiphy->bands[band];
1851− u32 ratemask = rates[band];
1852− u8 *supp_rates = sc->supp_rates[band].rates;
1862+ sband = ar->wiphy->bands[band];
1863+
1864+ if (!sband)
1865+ continue;
1866+
1867+ ratemask = rates[band];
1868+ supp_rates = sc->supp_rates[band].rates;
18531869 num_rates = 0;
18541870
18551871 for (i = 0; i < sband->n_bitrates; i++) {
@@ -2129,8 +2145,8 @@ int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, · 273 unmodified lines
21292145 struct wmi_add_cipher_key_cmd *cmd;
21302146 int ret;
21312147
2132− ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d "
2133− "key_usage=%d key_len=%d key_op_ctrl=%d\n",
2148+ ath6kl_dbg(ATH6KL_DBG_WMI,
2149+ "addkey cmd: key_index=%u key_type=%d key_usage=%d key_len=%d key_op_ctrl=%d\n",
21342150 key_index, key_type, key_usage, key_len, key_op_ctrl);
21352151
21362152 if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) ||
@@ -3047,8 +3063,8 @@ int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, · 910 unmodified lines
30473063
30483064 res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID,
30493065 NO_SYNC_WMIFLAG);
3050− ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u "
3051− "ctrl_flags=0x%x-> res=%d\n",
3066+ ath6kl_dbg(ATH6KL_DBG_WMI,
3067+ "%s: nw_type=%u auth_mode=%u ch=%u ctrl_flags=0x%x-> res=%d\n",
30523068 __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch),
30533069 le32_to_cpu(p->ctrl_flags), res);
30543070 return res;
@@ -3208,8 +3224,9 @@ int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, · 153 unmodified lines
32083224 if (!skb)
32093225 return -ENOMEM;
32103226
3211− ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u "
3212− "ie_len=%u\n", mgmt_frm_type, ie_len);
3227+ ath6kl_dbg(ATH6KL_DBG_WMI,
3228+ "set_appie_cmd: mgmt_frm_type=%u ie_len=%u\n",
3229+ mgmt_frm_type, ie_len);
32133230 p = (struct wmi_set_appie_cmd *) skb->data;
32143231 p->mgmt_frm_type = mgmt_frm_type;
32153232 p->ie_len = ie_len;
@@ -3310,8 +3327,9 @@ static int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, · 94 unmodified lines
33103327 wmi->last_mgmt_tx_frame = buf;
33113328 wmi->last_mgmt_tx_frame_len = data_len;
33123329
3313− ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u "
3314− "len=%u\n", id, freq, wait, data_len);
3330+ ath6kl_dbg(ATH6KL_DBG_WMI,
3331+ "send_action_cmd: id=%u freq=%u wait=%u len=%u\n",
3332+ id, freq, wait, data_len);
33153333 p = (struct wmi_send_action_cmd *) skb->data;
33163334 p->id = cpu_to_le32(id);
33173335 p->freq = cpu_to_le32(freq);
@@ -3348,8 +3366,9 @@ static int __ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, · 30 unmodified lines
33483366 wmi->last_mgmt_tx_frame = buf;
33493367 wmi->last_mgmt_tx_frame_len = data_len;
33503368
3351− ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u "
3352− "len=%u\n", id, freq, wait, data_len);
3369+ ath6kl_dbg(ATH6KL_DBG_WMI,
3370+ "send_action_cmd: id=%u freq=%u wait=%u len=%u\n",
3371+ id, freq, wait, data_len);
33533372 p = (struct wmi_send_mgmt_cmd *) skb->data;
33543373 p->id = cpu_to_le32(id);
33553374 p->freq = cpu_to_le32(freq);
@@ -3402,8 +3421,9 @@ int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, · 46 unmodified lines
34023421 if (!skb)
34033422 return -ENOMEM;
34043423
3405− ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM "
3406− "len=%u\n", freq, dst, data_len);
3424+ ath6kl_dbg(ATH6KL_DBG_WMI,
3425+ "send_probe_response_cmd: freq=%u dst=%pM len=%u\n",
3426+ freq, dst, data_len);
34073427 p = (struct wmi_p2p_probe_response_cmd *) skb->data;
34083428 p->freq = cpu_to_le32(freq);
34093429 memcpy(p->destination_addr, dst, ETH_ALEN);
drivers/net/wireless/ath/ath6kl/wmi.h+24−0
@@ -106,6 +106,8 @@ struct wmi_data_sync_bufs { · 105 unmodified lines
106106 #define WMM_AC_VI 2 /* video */
107107 #define WMM_AC_VO 3 /* voice */
108108
109+#define WMI_VOICE_USER_PRIORITY 0x7
110+
109111 struct wmi {
110112 u16 stream_exist_for_ac[WMM_NUM_AC];
111113 u8 fat_pipe_exist;
@@ -1151,6 +1153,7 @@ enum wmi_phy_mode { · 1039 unmodified lines
11511153 WMI_11AG_MODE = 0x3,
11521154 WMI_11B_MODE = 0x4,
11531155 WMI_11GONLY_MODE = 0x5,
1156+ WMI_11G_HT20 = 0x6,
11541157 };
11551158
11561159 #define WMI_MAX_CHANNELS 32
@@ -1416,6 +1419,16 @@ struct wmi_ready_event_2 { · 259 unmodified lines
14161419 u8 phy_cap;
14171420 } __packed;
14181421
1422+/* WMI_PHY_CAPABILITY */
1423+enum wmi_phy_cap {
1424+ WMI_11A_CAP = 0x01,
1425+ WMI_11G_CAP = 0x02,
1426+ WMI_11AG_CAP = 0x03,
1427+ WMI_11AN_CAP = 0x04,
1428+ WMI_11GN_CAP = 0x05,
1429+ WMI_11AGN_CAP = 0x06,
1430+};
1431+
14191432 /* Connect Event */
14201433 struct wmi_connect_event {
14211434 union {
@@ -1468,6 +1481,17 @@ enum wmi_disconnect_reason { · 46 unmodified lines
14681481 IBSS_MERGE = 0xe,
14691482 };
14701483
1484+/* AP mode disconnect proto_reasons */
1485+enum ap_disconnect_reason {
1486+ WMI_AP_REASON_STA_LEFT = 101,
1487+ WMI_AP_REASON_FROM_HOST = 102,
1488+ WMI_AP_REASON_COMM_TIMEOUT = 103,
1489+ WMI_AP_REASON_MAX_STA = 104,
1490+ WMI_AP_REASON_ACL = 105,
1491+ WMI_AP_REASON_STA_ROAM = 106,
1492+ WMI_AP_REASON_DFS_CHANNEL = 107,
1493+};
1494+
14711495 #define ATH6KL_COUNTRY_RD_SHIFT 16
14721496
14731497 struct ath6kl_wmi_regdomain {
drivers/net/wireless/ath/ath9k/ar9003_calib.c+10−40
@@ -892,34 +892,6 @@ static void ar9003_hw_tx_iq_cal_reload(struct ath_hw *ah) · 891 unmodified lines
892892 AR_PHY_RX_IQCAL_CORR_B0_LOOPBACK_IQCORR_EN, 0x1);
893893 }
894894
895−static bool ar9003_hw_rtt_restore(struct ath_hw *ah, struct ath9k_channel *chan)
896−{
897− struct ath9k_rtt_hist *hist;
898− u32 *table;
899− int i;
900− bool restore;
901−
902− if (!ah->caldata)
903− return false;
904−
905− hist = &ah->caldata->rtt_hist;
906− if (!hist->num_readings)
907− return false;
908−
909− ar9003_hw_rtt_enable(ah);
910− ar9003_hw_rtt_set_mask(ah, 0x00);
911− for (i = 0; i < AR9300_MAX_CHAINS; i++) {
912− if (!(ah->rxchainmask & (1 << i)))
913− continue;
914− table = &hist->table[i][hist->num_readings][0];
915− ar9003_hw_rtt_load_hist(ah, i, table);
916− }
917− restore = ar9003_hw_rtt_force_restore(ah);
918− ar9003_hw_rtt_disable(ah);
919−
920− return restore;
921−}
922−
923895 static bool ar9003_hw_init_cal(struct ath_hw *ah,
924896 struct ath9k_channel *chan)
925897 {
@@ -942,9 +914,10 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah, · 16 unmodified lines
942914 if (!ar9003_hw_rtt_restore(ah, chan))
943915 run_rtt_cal = true;
944916
945− ath_dbg(common, CALIBRATE, "RTT restore %s\n",
946− run_rtt_cal ? "failed" : "succeed");
917+ if (run_rtt_cal)
918+ ath_dbg(common, CALIBRATE, "RTT calibration to be done\n");
947919 }
920+
948921 run_agc_cal = run_rtt_cal;
949922
950923 if (run_rtt_cal) {
@@ -1069,17 +1042,14 @@ skip_tx_iqcal: · 118 unmodified lines
10691042 #undef CL_TAB_ENTRY
10701043
10711044 if (run_rtt_cal && caldata) {
1072− struct ath9k_rtt_hist *hist = &caldata->rtt_hist;
1073− if (is_reusable && (hist->num_readings < RTT_HIST_MAX)) {
1074− u32 *table;
1045+ if (is_reusable) {
1046+ if (!ath9k_hw_rfbus_req(ah))
1047+ ath_err(ath9k_hw_common(ah),
1048+ "Could not stop baseband\n");
1049+ else
1050+ ar9003_hw_rtt_fill_hist(ah);
10751051
1076− hist->num_readings++;
1077− for (i = 0; i < AR9300_MAX_CHAINS; i++) {
1078− if (!(ah->rxchainmask & (1 << i)))
1079− continue;
1080− table = &hist->table[i][hist->num_readings][0];
1081− ar9003_hw_rtt_fill_hist(ah, i, table);
1082− }
1052+ ath9k_hw_rfbus_done(ah);
10831053 }
10841054
10851055 ar9003_hw_rtt_disable(ah);
drivers/net/wireless/ath/ath9k/ar9003_mci.c+1−1
@@ -756,7 +756,7 @@ int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan, · 755 unmodified lines
756756 if (caldata) {
757757 caldata->done_txiqcal_once = false;
758758 caldata->done_txclcal_once = false;
759− caldata->rtt_hist.num_readings = 0;
759+ caldata->rtt_done = false;
760760 }
761761
762762 if (!ath9k_hw_init_cal(ah, chan))
drivers/net/wireless/ath/ath9k/ar9003_rtt.c+69−15
@@ -15,6 +15,7 @@ · 14 unmodified lines
1515 */
1616
1717 #include "hw.h"
18+#include "hw-ops.h"
1819 #include "ar9003_phy.h"
1920 #include "ar9003_rtt.h"
2021
@@ -69,7 +70,7 @@ bool ar9003_hw_rtt_force_restore(struct ath_hw *ah) · 48 unmodified lines
6970 }
7071
7172 static void ar9003_hw_rtt_load_hist_entry(struct ath_hw *ah, u8 chain,
72− u32 index, u32 data28)
73+ u32 index, u32 data28)
7374 {
7475 u32 val;
7576
@@ -100,12 +101,21 @@ static void ar9003_hw_rtt_load_hist_entry(struct ath_hw *ah, u8 chain, · 24 unmodified lines
100101 RTT_ACCESS_TIMEOUT);
101102 }
102103
103−void ar9003_hw_rtt_load_hist(struct ath_hw *ah, u8 chain, u32 *table)
104+void ar9003_hw_rtt_load_hist(struct ath_hw *ah)
104105 {
105− int i;
106+ int chain, i;
106107
107− for (i = 0; i < MAX_RTT_TABLE_ENTRY; i++)
108− ar9003_hw_rtt_load_hist_entry(ah, chain, i, table[i]);
108+ for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
109+ if (!(ah->rxchainmask & (1 << chain)))
110+ continue;
111+ for (i = 0; i < MAX_RTT_TABLE_ENTRY; i++) {
112+ ar9003_hw_rtt_load_hist_entry(ah, chain, i,
113+ ah->caldata->rtt_table[chain][i]);
114+ ath_dbg(ath9k_hw_common(ah), CALIBRATE,
115+ "Load RTT value at idx %d, chain %d: 0x%x\n",
116+ i, chain, ah->caldata->rtt_table[chain][i]);
117+ }
118+ }
109119 }
110120
111121 static int ar9003_hw_rtt_fill_hist_entry(struct ath_hw *ah, u8 chain, u32 index)
@@ -128,27 +138,71 @@ static int ar9003_hw_rtt_fill_hist_entry(struct ath_hw *ah, u8 chain, u32 index) · 16 unmodified lines
128138 RTT_ACCESS_TIMEOUT))
129139 return RTT_BAD_VALUE;
130140
131− val = REG_READ(ah, AR_PHY_RTT_TABLE_SW_INTF_1_B(chain));
141+ val = MS(REG_READ(ah, AR_PHY_RTT_TABLE_SW_INTF_1_B(chain)),
142+ AR_PHY_RTT_SW_RTT_TABLE_DATA);
143+
132144
133145 return val;
134146 }
135147
136−void ar9003_hw_rtt_fill_hist(struct ath_hw *ah, u8 chain, u32 *table)
148+void ar9003_hw_rtt_fill_hist(struct ath_hw *ah)
137149 {
138− int i;
150+ int chain, i;
151+
152+ for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
153+ if (!(ah->rxchainmask & (1 << chain)))
154+ continue;
155+ for (i = 0; i < MAX_RTT_TABLE_ENTRY; i++) {
156+ ah->caldata->rtt_table[chain][i] =
157+ ar9003_hw_rtt_fill_hist_entry(ah, chain, i);
158+ ath_dbg(ath9k_hw_common(ah), CALIBRATE,
159+ "RTT value at idx %d, chain %d is: 0x%x\n",
160+ i, chain, ah->caldata->rtt_table[chain][i]);
161+ }
162+ }
139163
140− for (i = 0; i < MAX_RTT_TABLE_ENTRY; i++)
141− table[i] = ar9003_hw_rtt_fill_hist_entry(ah, chain, i);
164+ ah->caldata->rtt_done = true;
142165 }
143166
144167 void ar9003_hw_rtt_clear_hist(struct ath_hw *ah)
145168 {
146− int i, j;
169+ int chain, i;
147170
148− for (i = 0; i < AR9300_MAX_CHAINS; i++) {
149− if (!(ah->rxchainmask & (1 << i)))
171+ for (chain = 0; chain < AR9300_MAX_CHAINS; chain++) {
172+ if (!(ah->rxchainmask & (1 << chain)))
150173 continue;
151− for (j = 0; j < MAX_RTT_TABLE_ENTRY; j++)
152− ar9003_hw_rtt_load_hist_entry(ah, i, j, 0);
174+ for (i = 0; i < MAX_RTT_TABLE_ENTRY; i++)
175+ ar9003_hw_rtt_load_hist_entry(ah, chain, i, 0);
153176 }
177+
178+ if (ah->caldata)
179+ ah->caldata->rtt_done = false;
180+}
181+
182+bool ar9003_hw_rtt_restore(struct ath_hw *ah, struct ath9k_channel *chan)
183+{
184+ bool restore;
185+
186+ if (!ah->caldata)
187+ return false;
188+
189+ if (!ah->caldata->rtt_done)
190+ return false;
191+
192+ ar9003_hw_rtt_enable(ah);
193+ ar9003_hw_rtt_set_mask(ah, 0x10);
194+
195+ if (!ath9k_hw_rfbus_req(ah)) {
196+ ath_err(ath9k_hw_common(ah), "Could not stop baseband\n");
197+ restore = false;
198+ goto fail;
199+ }
200+
201+ ar9003_hw_rtt_load_hist(ah);
202+ restore = ar9003_hw_rtt_force_restore(ah);
203+
204+fail:
205+ ath9k_hw_rfbus_done(ah);
206+ ar9003_hw_rtt_disable(ah);
207+ return restore;
154208 }
drivers/net/wireless/ath/ath9k/ar9003_rtt.h+3−2
@@ -21,8 +21,9 @@ void ar9003_hw_rtt_enable(struct ath_hw *ah); · 20 unmodified lines
2121 void ar9003_hw_rtt_disable(struct ath_hw *ah);
2222 void ar9003_hw_rtt_set_mask(struct ath_hw *ah, u32 rtt_mask);
2323 bool ar9003_hw_rtt_force_restore(struct ath_hw *ah);
24−void ar9003_hw_rtt_load_hist(struct ath_hw *ah, u8 chain, u32 *table);
25−void ar9003_hw_rtt_fill_hist(struct ath_hw *ah, u8 chain, u32 *table);
24+void ar9003_hw_rtt_load_hist(struct ath_hw *ah);
25+void ar9003_hw_rtt_fill_hist(struct ath_hw *ah);
2626 void ar9003_hw_rtt_clear_hist(struct ath_hw *ah);
27+bool ar9003_hw_rtt_restore(struct ath_hw *ah, struct ath9k_channel *chan);
2728
2829 #endif
drivers/net/wireless/ath/ath9k/hw.c+4−5
@@ -1702,10 +1702,10 @@ static int ath9k_hw_do_fastcc(struct ath_hw *ah, struct ath9k_channel *chan) · 1701 unmodified lines
17021702 * For AR9462, make sure that calibration data for
17031703 * re-using are present.
17041704 */
1705− if (AR_SREV_9462(ah) && (!ah->caldata ||
1706− !ah->caldata->done_txiqcal_once ||
1707− !ah->caldata->done_txclcal_once ||
1708− !ah->caldata->rtt_hist.num_readings))
1705+ if (AR_SREV_9462(ah) && (ah->caldata &&
1706+ (!ah->caldata->done_txiqcal_once ||
1707+ !ah->caldata->done_txclcal_once ||
1708+ !ah->caldata->rtt_done)))
17091709 goto fail;
17101710
17111711 ath_dbg(common, RESET, "FastChannelChange for %d -> %d\n",
@@ -1941,7 +1941,6 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, · 229 unmodified lines
19411941 if (caldata) {
19421942 caldata->done_txiqcal_once = false;
19431943 caldata->done_txclcal_once = false;
1944− caldata->rtt_hist.num_readings = 0;
19451944 }
19461945 if (!ath9k_hw_init_cal(ah, chan))
19471946 return -EIO;
drivers/net/wireless/ath/ath9k/hw.h+2−7
@@ -348,12 +348,6 @@ enum ath9k_int { · 347 unmodified lines
348348 CHANNEL_HT40MINUS)
349349
350350 #define MAX_RTT_TABLE_ENTRY 6
351−#define RTT_HIST_MAX 3
352−struct ath9k_rtt_hist {
353− u32 table[AR9300_MAX_CHAINS][RTT_HIST_MAX][MAX_RTT_TABLE_ENTRY];
354− u8 num_readings;
355−};
356−
357351 #define MAX_IQCAL_MEASUREMENT 8
358352 #define MAX_CL_TAB_ENTRY 16
359353
@@ -363,6 +357,7 @@ struct ath9k_hw_cal_data { · 3 unmodified lines
363357 int32_t CalValid;
364358 int8_t iCoff;
365359 int8_t qCoff;
360+ bool rtt_done;
366361 bool paprd_done;
367362 bool nfcal_pending;
368363 bool nfcal_interference;
@@ -373,8 +368,8 @@ struct ath9k_hw_cal_data { · 4 unmodified lines
373368 u32 num_measures[AR9300_MAX_CHAINS];
374369 int tx_corr_coeff[MAX_IQCAL_MEASUREMENT][AR9300_MAX_CHAINS];
375370 u32 tx_clcal[AR9300_MAX_CHAINS][MAX_CL_TAB_ENTRY];
371+ u32 rtt_table[AR9300_MAX_CHAINS][MAX_RTT_TABLE_ENTRY];
376372 struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
377− struct ath9k_rtt_hist rtt_hist;
378373 };
379374
380375 struct ath9k_channel {
drivers/net/wireless/b43/bus.c+2−4
@@ -107,11 +107,9 @@ struct b43_bus_dev *b43_bus_dev_bcma_init(struct bcma_device *core) · 106 unmodified lines
107107 dev->dma_dev = core->dma_dev;
108108 dev->irq = core->irq;
109109
110− /*
111110 dev->board_vendor = core->bus->boardinfo.vendor;
112111 dev->board_type = core->bus->boardinfo.type;
113− dev->board_rev = core->bus->boardinfo.rev;
114− */
112+ dev->board_rev = core->bus->sprom.board_rev;
115113
116114 dev->chip_id = core->bus->chipinfo.id;
117115 dev->chip_rev = core->bus->chipinfo.rev;
@@ -210,7 +208,7 @@ struct b43_bus_dev *b43_bus_dev_ssb_init(struct ssb_device *sdev) · 92 unmodified lines
210208
211209 dev->board_vendor = sdev->bus->boardinfo.vendor;
212210 dev->board_type = sdev->bus->boardinfo.type;
213− dev->board_rev = sdev->bus->boardinfo.rev;
211+ dev->board_rev = sdev->bus->sprom.board_rev;
214212
215213 dev->chip_id = sdev->bus->chip_id;
216214 dev->chip_rev = sdev->bus->chip_rev;
drivers/net/wireless/b43/dma.c+1−1
@@ -1109,7 +1109,7 @@ static bool b43_dma_translation_in_low_word(struct b43_wldev *dev, · 1108 unmodified lines
11091109 #ifdef CONFIG_B43_SSB
11101110 if (dev->dev->bus_type == B43_BUS_SSB &&
11111111 dev->dev->sdev->bus->bustype == SSB_BUSTYPE_PCI &&
1112− !(dev->dev->sdev->bus->host_pci->is_pcie &&
1112+ !(pci_is_pcie(dev->dev->sdev->bus->host_pci) &&
11131113 ssb_read32(dev->dev->sdev, SSB_TMSHIGH) & SSB_TMSHIGH_DMA64))
11141114 return 1;
11151115 #endif
drivers/net/wireless/b43/main.c+2−2
@@ -5243,10 +5243,10 @@ static void b43_sprom_fixup(struct ssb_bus *bus) · 5242 unmodified lines
52435243
52445244 /* boardflags workarounds */
52455245 if (bus->boardinfo.vendor == SSB_BOARDVENDOR_DELL &&
5246− bus->chip_id == 0x4301 && bus->boardinfo.rev == 0x74)
5246+ bus->chip_id == 0x4301 && bus->sprom.board_rev == 0x74)
52475247 bus->sprom.boardflags_lo |= B43_BFL_BTCOEXIST;
52485248 if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE &&
5249− bus->boardinfo.type == 0x4E && bus->boardinfo.rev > 0x40)
5249+ bus->boardinfo.type == 0x4E && bus->sprom.board_rev > 0x40)
52505250 bus->sprom.boardflags_lo |= B43_BFL_PACTRL;
52515251 if (bus->bustype == SSB_BUSTYPE_PCI) {
52525252 pdev = bus->host_pci;
drivers/net/wireless/b43legacy/main.c+1−3
@@ -1573,8 +1573,6 @@ static void b43legacy_request_firmware(struct work_struct *work) · 1572 unmodified lines
15731573 const char *filename;
15741574 int err;
15751575
1576− /* do dummy read */
1577− ssb_read32(dev->dev, SSB_TMSHIGH);
15781576 if (!fw->ucode) {
15791577 if (rev == 2)
15801578 filename = "ucode2";
@@ -3781,7 +3779,7 @@ static void b43legacy_sprom_fixup(struct ssb_bus *bus) · 2200 unmodified lines
37813779 /* boardflags workarounds */
37823780 if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE &&
37833781 bus->boardinfo.type == 0x4E &&
3784− bus->boardinfo.rev > 0x40)
3782+ bus->sprom.board_rev > 0x40)
37853783 bus->sprom.boardflags_lo |= B43legacy_BFL_PACTRL;
37863784 }
37873785
drivers/net/wireless/b43legacy/phy.c+2−2
@@ -408,7 +408,7 @@ static void b43legacy_phy_setupg(struct b43legacy_wldev *dev) · 407 unmodified lines
408408
409409 if (is_bcm_board_vendor(dev) &&
410410 (dev->dev->bus->boardinfo.type == 0x0416) &&
411− (dev->dev->bus->boardinfo.rev == 0x0017))
411+ (dev->dev->bus->sprom.board_rev == 0x0017))
412412 return;
413413
414414 b43legacy_ilt_write(dev, 0x5001, 0x0002);
@@ -424,7 +424,7 @@ static void b43legacy_phy_setupg(struct b43legacy_wldev *dev) · 9 unmodified lines
424424
425425 if (is_bcm_board_vendor(dev) &&
426426 (dev->dev->bus->boardinfo.type == 0x0416) &&
427− (dev->dev->bus->boardinfo.rev == 0x0017))
427+ (dev->dev->bus->sprom.board_rev == 0x0017))
428428 return;
429429
430430 b43legacy_ilt_write(dev, 0x0401, 0x0002);
drivers/net/wireless/b43legacy/radio.c+5−5
@@ -1998,7 +1998,7 @@ u16 b43legacy_default_radio_attenuation(struct b43legacy_wldev *dev) · 1997 unmodified lines
19981998 if (phy->type == B43legacy_PHYTYPE_G) {
19991999 if (is_bcm_board_vendor(dev) &&
20002000 dev->dev->bus->boardinfo.type == 0x421 &&
2001− dev->dev->bus->boardinfo.rev >= 30)
2001+ dev->dev->bus->sprom.board_rev >= 30)
20022002 att = 3;
20032003 else if (is_bcm_board_vendor(dev) &&
20042004 dev->dev->bus->boardinfo.type == 0x416)
@@ -2008,7 +2008,7 @@ u16 b43legacy_default_radio_attenuation(struct b43legacy_wldev *dev) · 3 unmodified lines
20082008 } else {
20092009 if (is_bcm_board_vendor(dev) &&
20102010 dev->dev->bus->boardinfo.type == 0x421 &&
2011− dev->dev->bus->boardinfo.rev >= 30)
2011+ dev->dev->bus->sprom.board_rev >= 30)
20122012 att = 7;
20132013 else
20142014 att = 6;
@@ -2018,7 +2018,7 @@ u16 b43legacy_default_radio_attenuation(struct b43legacy_wldev *dev) · 3 unmodified lines
20182018 if (phy->type == B43legacy_PHYTYPE_G) {
20192019 if (is_bcm_board_vendor(dev) &&
20202020 dev->dev->bus->boardinfo.type == 0x421 &&
2021− dev->dev->bus->boardinfo.rev >= 30)
2021+ dev->dev->bus->sprom.board_rev >= 30)
20222022 att = 3;
20232023 else if (is_bcm_board_vendor(dev) &&
20242024 dev->dev->bus->boardinfo.type ==
@@ -2052,9 +2052,9 @@ u16 b43legacy_default_radio_attenuation(struct b43legacy_wldev *dev) · 27 unmodified lines
20522052 }
20532053 if (is_bcm_board_vendor(dev) &&
20542054 dev->dev->bus->boardinfo.type == 0x421) {
2055− if (dev->dev->bus->boardinfo.rev < 0x43)
2055+ if (dev->dev->bus->sprom.board_rev < 0x43)
20562056 att = 2;
2057− else if (dev->dev->bus->boardinfo.rev < 0x51)
2057+ else if (dev->dev->bus->sprom.board_rev < 0x51)
20582058 att = 3;
20592059 }
20602060 if (att == 0xFFFF)
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c+117−127
@@ -85,18 +85,15 @@ int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev) · 84 unmodified lines
8585 sdiodev->irq_wake = true;
8686
8787 /* must configure SDIO_CCCR_IENx to enable irq */
88− data = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_0,
89− SDIO_CCCR_IENx, &ret);
88+ data = brcmf_sdio_regrb(sdiodev, SDIO_CCCR_IENx, &ret);
9089 data |= 1 << SDIO_FUNC_1 | 1 << SDIO_FUNC_2 | 1;
91− brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_0, SDIO_CCCR_IENx,
92− data, &ret);
90+ brcmf_sdio_regwb(sdiodev, SDIO_CCCR_IENx, data, &ret);
9391
9492 /* redirect, configure ane enable io for interrupt signal */
9593 data = SDIO_SEPINT_MASK | SDIO_SEPINT_OE;
9694 if (sdiodev->irq_flags | IRQF_TRIGGER_HIGH)
9795 data |= SDIO_SEPINT_ACT_HI;
98− brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_0, SDIO_CCCR_BRCM_SEPINT,
99− data, &ret);
96+ brcmf_sdio_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, &ret);
10097
10198 return 0;
10299 }
@@ -105,9 +102,8 @@ int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev) · 2 unmodified lines
105102 {
106103 brcmf_dbg(TRACE, "Entering\n");
107104
108− brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_0, SDIO_CCCR_BRCM_SEPINT,
109− 0, NULL);
110− brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_0, SDIO_CCCR_IENx, 0, NULL);
105+ brcmf_sdio_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, 0, NULL);
106+ brcmf_sdio_regwb(sdiodev, SDIO_CCCR_IENx, 0, NULL);
111107
112108 if (sdiodev->irq_wake) {
113109 disable_irq_wake(sdiodev->irq);
@@ -158,153 +154,147 @@ int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev) · 44 unmodified lines
158154 }
159155 #endif /* CONFIG_BRCMFMAC_SDIO_OOB */
160156
161−u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr,
162− int *err)
163−{
164− int status;
165− s32 retry = 0;
166− u8 data = 0;
167−
168− do {
169− if (retry) /* wait for 1 ms till bus get settled down */
170− udelay(1000);
171− status = brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, fnc_num,
172− addr, (u8 *) &data);
173− } while (status != 0
174− && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT));
175− if (err)
176− *err = status;
177−
178− brcmf_dbg(INFO, "fun = %d, addr = 0x%x, u8data = 0x%x\n",
179− fnc_num, addr, data);
180−
181− return data;
182−}
183−
184−void
185−brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr,
186− u8 data, int *err)
187−{
188− int status;
189− s32 retry = 0;
190−
191− do {
192− if (retry) /* wait for 1 ms till bus get settled down */
193− udelay(1000);
194− status = brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE, fnc_num,
195− addr, (u8 *) &data);
196− } while (status != 0
197− && (retry++ < SDIOH_API_ACCESS_RETRY_LIMIT));
198− if (err)
199− *err = status;
200−
201− brcmf_dbg(INFO, "fun = %d, addr = 0x%x, u8data = 0x%x\n",
202− fnc_num, addr, data);
203−}
204−
205157 int
206158 brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address)
207159 {
208− int err = 0;
209− brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW,
210− (address >> 8) & SBSDIO_SBADDRLOW_MASK, &err);
211− if (!err)
212− brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1,
213− SBSDIO_FUNC1_SBADDRMID,
214− (address >> 16) & SBSDIO_SBADDRMID_MASK,
215− &err);
216− if (!err)
217− brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1,
218− SBSDIO_FUNC1_SBADDRHIGH,
219− (address >> 24) & SBSDIO_SBADDRHIGH_MASK,
220− &err);
160+ int err = 0, i;
161+ u8 addr[3];
162+ s32 retry;
163+
164+ addr[0] = (address >> 8) & SBSDIO_SBADDRLOW_MASK;
165+ addr[1] = (address >> 16) & SBSDIO_SBADDRMID_MASK;
166+ addr[2] = (address >> 24) & SBSDIO_SBADDRHIGH_MASK;
167+
168+ for (i = 0; i < 3; i++) {
169+ retry = 0;
170+ do {
171+ if (retry)
172+ usleep_range(1000, 2000);
173+ err = brcmf_sdioh_request_byte(sdiodev, SDIOH_WRITE,
174+ SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW + i,
175+ &addr[i]);
176+ } while (err != 0 && retry++ < SDIOH_API_ACCESS_RETRY_LIMIT);
177+
178+ if (err) {
179+ brcmf_dbg(ERROR, "failed at addr:0x%0x\n",
180+ SBSDIO_FUNC1_SBADDRLOW + i);
181+ break;
182+ }
183+ }
221184
222185 return err;
223186 }
224187
225−u32 brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size)
188+static int
189+brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr,
190+ void *data, bool write)
226191 {
227− int status;
228− u32 word = 0;
229− uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
230−
231− brcmf_dbg(INFO, "fun = 1, addr = 0x%x\n", addr);
232−
233− if (bar0 != sdiodev->sbwad) {
234− if (brcmf_sdcard_set_sbaddr_window(sdiodev, bar0))
235− return 0xFFFFFFFF;
192+ u8 func_num, reg_size;
193+ u32 bar;
194+ s32 retry = 0;
195+ int ret;
236196
237− sdiodev->sbwad = bar0;
197+ /*
198+ * figure out how to read the register based on address range
199+ * 0x00 ~ 0x7FF: function 0 CCCR and FBR
200+ * 0x10000 ~ 0x1FFFF: function 1 miscellaneous registers
201+ * The rest: function 1 silicon backplane core registers
202+ */
203+ if ((addr & ~REG_F0_REG_MASK) == 0) {
204+ func_num = SDIO_FUNC_0;
205+ reg_size = 1;
206+ } else if ((addr & ~REG_F1_MISC_MASK) == 0) {
207+ func_num = SDIO_FUNC_1;
208+ reg_size = 1;
209+ } else {
210+ func_num = SDIO_FUNC_1;
211+ reg_size = 4;
212+
213+ /* Set the window for SB core register */
214+ bar = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
215+ if (bar != sdiodev->sbwad) {
216+ ret = brcmf_sdcard_set_sbaddr_window(sdiodev, bar);
217+ if (ret != 0) {
218+ memset(data, 0xFF, reg_size);
219+ return ret;
220+ }
221+ sdiodev->sbwad = bar;
222+ }
223+ addr &= SBSDIO_SB_OFT_ADDR_MASK;
224+ addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
238225 }
239226
240− addr &= SBSDIO_SB_OFT_ADDR_MASK;
241− if (size == 4)
242− addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
227+ do {
228+ if (!write)
229+ memset(data, 0, reg_size);
230+ if (retry) /* wait for 1 ms till bus get settled down */
231+ usleep_range(1000, 2000);
232+ if (reg_size == 1)
233+ ret = brcmf_sdioh_request_byte(sdiodev, write,
234+ func_num, addr, data);
235+ else
236+ ret = brcmf_sdioh_request_word(sdiodev, write,
237+ func_num, addr, data, 4);
238+ } while (ret != 0 && retry++ < SDIOH_API_ACCESS_RETRY_LIMIT);
243239
244− status = brcmf_sdioh_request_word(sdiodev, SDIOH_READ, SDIO_FUNC_1,
245− addr, &word, size);
240+ if (ret != 0)
241+ brcmf_dbg(ERROR, "failed with %d\n", ret);
246242
247− sdiodev->regfail = (status != 0);
243+ return ret;
244+}
248245
249− brcmf_dbg(INFO, "u32data = 0x%x\n", word);
246+u8 brcmf_sdio_regrb(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret)
247+{
248+ u8 data;
249+ int retval;
250250
251− /* if ok, return appropriately masked word */
252− if (status == 0) {
253− switch (size) {
254− case sizeof(u8):
255− return word & 0xff;
256− case sizeof(u16):
257− return word & 0xffff;
258− case sizeof(u32):
259− return word;
260− default:
261− sdiodev->regfail = true;
251+ brcmf_dbg(INFO, "addr:0x%08x\n", addr);
252+ retval = brcmf_sdio_regrw_helper(sdiodev, addr, &data, false);
253+ brcmf_dbg(INFO, "data:0x%02x\n", data);
262254
263− }
264− }
255+ if (ret)
256+ *ret = retval;
265257
266− /* otherwise, bad sdio access or invalid size */
267− brcmf_dbg(ERROR, "error reading addr 0x%04x size %d\n", addr, size);
268− return 0xFFFFFFFF;
258+ return data;
269259 }
270260
271−u32 brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size,
272− u32 data)
261+u32 brcmf_sdio_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret)
273262 {
274− int status;
275− uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
276− int err = 0;
263+ u32 data;
264+ int retval;
277265
278− brcmf_dbg(INFO, "fun = 1, addr = 0x%x, uint%ddata = 0x%x\n",
279− addr, size * 8, data);
266+ brcmf_dbg(INFO, "addr:0x%08x\n", addr);
267+ retval = brcmf_sdio_regrw_helper(sdiodev, addr, &data, false);
268+ brcmf_dbg(INFO, "data:0x%08x\n", data);
280269
281− if (bar0 != sdiodev->sbwad) {
282− err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0);
283− if (err)
284− return err;
270+ if (ret)
271+ *ret = retval;
285272
286− sdiodev->sbwad = bar0;
287− }
273+ return data;
274+}
288275
289− addr &= SBSDIO_SB_OFT_ADDR_MASK;
290− if (size == 4)
291− addr |= SBSDIO_SB_ACCESS_2_4B_FLAG;
292− status =
293− brcmf_sdioh_request_word(sdiodev, SDIOH_WRITE, SDIO_FUNC_1,
294− addr, &data, size);
295− sdiodev->regfail = (status != 0);
276+void brcmf_sdio_regwb(struct brcmf_sdio_dev *sdiodev, u32 addr,
277+ u8 data, int *ret)
278+{
279+ int retval;
296280
297− if (status == 0)
298− return 0;
281+ brcmf_dbg(INFO, "addr:0x%08x, data:0x%02x\n", addr, data);
282+ retval = brcmf_sdio_regrw_helper(sdiodev, addr, &data, true);
299283
300− brcmf_dbg(ERROR, "error writing 0x%08x to addr 0x%04x size %d\n",
301− data, addr, size);
302− return 0xFFFFFFFF;
284+ if (ret)
285+ *ret = retval;
303286 }
304287
305−bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev)
288+void brcmf_sdio_regwl(struct brcmf_sdio_dev *sdiodev, u32 addr,
289+ u32 data, int *ret)
306290 {
307− return sdiodev->regfail;
291+ int retval;
292+
293+ brcmf_dbg(INFO, "addr:0x%08x, data:0x%08x\n", addr, data);
294+ retval = brcmf_sdio_regrw_helper(sdiodev, addr, &data, true);
295+
296+ if (ret)
297+ *ret = retval;
308298 }
309299
310300 static int brcmf_sdcard_recv_prepare(struct brcmf_sdio_dev *sdiodev, uint fn,
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c+3−29
@@ -346,43 +346,17 @@ int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, · 345 unmodified lines
346346 return status;
347347 }
348348
349−/* Read client card reg */
350−static int
351−brcmf_sdioh_card_regread(struct brcmf_sdio_dev *sdiodev, int func, u32 regaddr,
352− int regsize, u32 *data)
353−{
354−
355− if ((func == 0) || (regsize == 1)) {
356− u8 temp = 0;
357−
358− brcmf_sdioh_request_byte(sdiodev, SDIOH_READ, func, regaddr,
359− &temp);
360− *data = temp;
361− *data &= 0xff;
362− brcmf_dbg(DATA, "byte read data=0x%02x\n", *data);
363− } else {
364− brcmf_sdioh_request_word(sdiodev, SDIOH_READ, func, regaddr,
365− data, regsize);
366− if (regsize == 2)
367− *data &= 0xffff;
368−
369− brcmf_dbg(DATA, "word read data=0x%08x\n", *data);
370− }
371−
372− return SUCCESS;
373−}
374−
375349 static int brcmf_sdioh_get_cisaddr(struct brcmf_sdio_dev *sdiodev, u32 regaddr)
376350 {
377351 /* read 24 bits and return valid 17 bit addr */
378− int i;
352+ int i, ret;
379353 u32 scratch, regdata;
380354 __le32 scratch_le;
381355 u8 *ptr = (u8 *)&scratch_le;
382356
383357 for (i = 0; i < 3; i++) {
384− if ((brcmf_sdioh_card_regread(sdiodev, 0, regaddr, 1,
385− &regdata)) != SUCCESS)
358+ regdata = brcmf_sdio_regrl(sdiodev, regaddr, &ret);
359+ if (ret != 0)
386360 brcmf_dbg(ERROR, "Can't read!\n");
387361
388362 *ptr++ = (u8) regdata;
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c+147−203
@@ -629,43 +629,29 @@ static bool data_ok(struct brcmf_sdio *bus) · 628 unmodified lines
629629 * Reads a register in the SDIO hardware block. This block occupies a series of
630630 * adresses on the 32 bit backplane bus.
631631 */
632−static void
633−r_sdreg32(struct brcmf_sdio *bus, u32 *regvar, u32 reg_offset, u32 *retryvar)
632+static int
633+r_sdreg32(struct brcmf_sdio *bus, u32 *regvar, u32 offset)
634634 {
635635 u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV);
636− *retryvar = 0;
637− do {
638− *regvar = brcmf_sdcard_reg_read(bus->sdiodev,
639− bus->ci->c_inf[idx].base + reg_offset,
640− sizeof(u32));
641− } while (brcmf_sdcard_regfail(bus->sdiodev) &&
642− (++(*retryvar) <= retry_limit));
643− if (*retryvar) {
644− bus->regfails += (*retryvar-1);
645− if (*retryvar > retry_limit) {
646− brcmf_dbg(ERROR, "FAILED READ %Xh\n", reg_offset);
647− *regvar = 0;
648− }
649− }
636+ int ret;
637+
638+ *regvar = brcmf_sdio_regrl(bus->sdiodev,
639+ bus->ci->c_inf[idx].base + offset, &ret);
640+
641+ return ret;
650642 }
651643
652−static void
653−w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset, u32 *retryvar)
644+static int
645+w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset)
654646 {
655647 u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV);
656− *retryvar = 0;
657− do {
658− brcmf_sdcard_reg_write(bus->sdiodev,
659− bus->ci->c_inf[idx].base + reg_offset,
660− sizeof(u32), regval);
661− } while (brcmf_sdcard_regfail(bus->sdiodev) &&
662− (++(*retryvar) <= retry_limit));
663− if (*retryvar) {
664− bus->regfails += (*retryvar-1);
665− if (*retryvar > retry_limit)
666− brcmf_dbg(ERROR, "FAILED REGISTER WRITE %Xh\n",
667− reg_offset);
668− }
648+ int ret;
649+
650+ brcmf_sdio_regwl(bus->sdiodev,
651+ bus->ci->c_inf[idx].base + reg_offset,
652+ regval, &ret);
653+
654+ return ret;
669655 }
670656
671657 #define PKT_AVAILABLE() (intstatus & I_HMB_FRAME_IND)
@@ -697,16 +683,16 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) · 25 unmodified lines
697683 clkreq =
698684 bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ;
699685
700− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
701− SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err);
686+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
687+ clkreq, &err);
702688 if (err) {
703689 brcmf_dbg(ERROR, "HT Avail request error: %d\n", err);
704690 return -EBADE;
705691 }
706692
707693 /* Check current status */
708− clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
709− SBSDIO_FUNC1_CHIPCLKCSR, &err);
694+ clkctl = brcmf_sdio_regrb(bus->sdiodev,
695+ SBSDIO_FUNC1_CHIPCLKCSR, &err);
710696 if (err) {
711697 brcmf_dbg(ERROR, "HT Avail read error: %d\n", err);
712698 return -EBADE;
@@ -715,9 +701,8 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) · 2 unmodified lines
715701 /* Go to pending and await interrupt if appropriate */
716702 if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) {
717703 /* Allow only clock-available interrupt */
718− devctl = brcmf_sdcard_cfg_read(bus->sdiodev,
719− SDIO_FUNC_1,
720− SBSDIO_DEVICE_CTL, &err);
704+ devctl = brcmf_sdio_regrb(bus->sdiodev,
705+ SBSDIO_DEVICE_CTL, &err);
721706 if (err) {
722707 brcmf_dbg(ERROR, "Devctl error setting CA: %d\n",
723708 err);
@@ -725,30 +710,28 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) · 1 unmodified line
725710 }
726711
727712 devctl |= SBSDIO_DEVCTL_CA_INT_ONLY;
728− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
729− SBSDIO_DEVICE_CTL, devctl, &err);
713+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_DEVICE_CTL,
714+ devctl, &err);
730715 brcmf_dbg(INFO, "CLKCTL: set PENDING\n");
731716 bus->clkstate = CLK_PENDING;
732717
733718 return 0;
734719 } else if (bus->clkstate == CLK_PENDING) {
735720 /* Cancel CA-only interrupt filter */
736− devctl =
737− brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
721+ devctl = brcmf_sdio_regrb(bus->sdiodev,
738722 SBSDIO_DEVICE_CTL, &err);
739723 devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
740− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
741− SBSDIO_DEVICE_CTL, devctl, &err);
724+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_DEVICE_CTL,
725+ devctl, &err);
742726 }
743727
744728 /* Otherwise, wait here (polling) for HT Avail */
745729 timeout = jiffies +
746730 msecs_to_jiffies(PMU_MAX_TRANSITION_DLY/1000);
747731 while (!SBSDIO_CLKAV(clkctl, bus->alp_only)) {
748− clkctl = brcmf_sdcard_cfg_read(bus->sdiodev,
749− SDIO_FUNC_1,
750− SBSDIO_FUNC1_CHIPCLKCSR,
751− &err);
732+ clkctl = brcmf_sdio_regrb(bus->sdiodev,
733+ SBSDIO_FUNC1_CHIPCLKCSR,
734+ &err);
752735 if (time_after(jiffies, timeout))
753736 break;
754737 else
@@ -781,17 +764,16 @@ static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) · 26 unmodified lines
781764
782765 if (bus->clkstate == CLK_PENDING) {
783766 /* Cancel CA-only interrupt filter */
784− devctl = brcmf_sdcard_cfg_read(bus->sdiodev,
785− SDIO_FUNC_1,
786− SBSDIO_DEVICE_CTL, &err);
767+ devctl = brcmf_sdio_regrb(bus->sdiodev,
768+ SBSDIO_DEVICE_CTL, &err);
787769 devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
788− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
789− SBSDIO_DEVICE_CTL, devctl, &err);
770+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_DEVICE_CTL,
771+ devctl, &err);
790772 }
791773
792774 bus->clkstate = CLK_SDONLY;
793− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
794− SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err);
775+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
776+ clkreq, &err);
795777 brcmf_dbg(INFO, "CLKCTL: turned OFF\n");
796778 if (err) {
797779 brcmf_dbg(ERROR, "Failed access turning clock off: %d\n",
@@ -874,7 +856,7 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_sdio *bus, uint target, bool pendok) · 76 unmodified lines
874856
875857 static int brcmf_sdbrcm_bussleep(struct brcmf_sdio *bus, bool sleep)
876858 {
877− uint retries = 0;
859+ int ret;
878860
879861 brcmf_dbg(INFO, "request %s (currently %s)\n",
880862 sleep ? "SLEEP" : "WAKE",
@@ -894,22 +876,20 @@ static int brcmf_sdbrcm_bussleep(struct brcmf_sdio *bus, bool sleep) · 13 unmodified lines
894876 brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false);
895877
896878 /* Tell device to start using OOB wakeup */
897− w_sdreg32(bus, SMB_USE_OOB,
898− offsetof(struct sdpcmd_regs, tosbmailbox), &retries);
899− if (retries > retry_limit)
879+ ret = w_sdreg32(bus, SMB_USE_OOB,
880+ offsetof(struct sdpcmd_regs, tosbmailbox));
881+ if (ret != 0)
900882 brcmf_dbg(ERROR, "CANNOT SIGNAL CHIP, WILL NOT WAKE UP!!\n");
901883
902884 /* Turn off our contribution to the HT clock request */
903885 brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false);
904886
905− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
906− SBSDIO_FUNC1_CHIPCLKCSR,
907− SBSDIO_FORCE_HW_CLKREQ_OFF, NULL);
887+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
888+ SBSDIO_FORCE_HW_CLKREQ_OFF, NULL);
908889
909890 /* Isolate the bus */
910− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
911− SBSDIO_DEVICE_CTL,
912− SBSDIO_DEVCTL_PADS_ISO, NULL);
891+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_DEVICE_CTL,
892+ SBSDIO_DEVCTL_PADS_ISO, NULL);
913893
914894 /* Change state */
915895 bus->sleeping = true;
@@ -917,21 +897,20 @@ static int brcmf_sdbrcm_bussleep(struct brcmf_sdio *bus, bool sleep) · 1 unmodified line
917897 } else {
918898 /* Waking up: bus power up is ok, set local state */
919899
920− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
921− SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL);
900+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
901+ 0, NULL);
922902
923903 /* Make sure the controller has the bus up */
924904 brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false);
925905
926906 /* Send misc interrupt to indicate OOB not needed */
927− w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, tosbmailboxdata),
928− &retries);
929− if (retries <= retry_limit)
930− w_sdreg32(bus, SMB_DEV_INT,
931− offsetof(struct sdpcmd_regs, tosbmailbox),
932− &retries);
933−
934− if (retries > retry_limit)
907+ ret = w_sdreg32(bus, 0,
908+ offsetof(struct sdpcmd_regs, tosbmailboxdata));
909+ if (ret == 0)
910+ ret = w_sdreg32(bus, SMB_DEV_INT,
911+ offsetof(struct sdpcmd_regs, tosbmailbox));
912+
913+ if (ret != 0)
935914 brcmf_dbg(ERROR, "CANNOT SIGNAL CHIP TO CLEAR OOB!!\n");
936915
937916 /* Make sure we have SD bus access */
@@ -955,17 +934,17 @@ static u32 brcmf_sdbrcm_hostmail(struct brcmf_sdio *bus) · 17 unmodified lines
955934 u32 intstatus = 0;
956935 u32 hmb_data;
957936 u8 fcbits;
958− uint retries = 0;
937+ int ret;
959938
960939 brcmf_dbg(TRACE, "Enter\n");
961940
962941 /* Read mailbox data and ack that we did so */
963− r_sdreg32(bus, &hmb_data,
964− offsetof(struct sdpcmd_regs, tohostmailboxdata), &retries);
942+ ret = r_sdreg32(bus, &hmb_data,
943+ offsetof(struct sdpcmd_regs, tohostmailboxdata));
965944
966− if (retries <= retry_limit)
945+ if (ret == 0)
967946 w_sdreg32(bus, SMB_INT_ACK,
968− offsetof(struct sdpcmd_regs, tosbmailbox), &retries);
947+ offsetof(struct sdpcmd_regs, tosbmailbox));
969948 bus->f1regdata += 2;
970949
971950 /* Dongle recomposed rx frames, accept them again */
@@ -1040,17 +1019,16 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_sdio *bus, bool abort, bool rtx) · 68 unmodified lines
10401019 if (abort)
10411020 brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2);
10421021
1043− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
1044− SBSDIO_FUNC1_FRAMECTRL,
1045− SFC_RF_TERM, &err);
1022+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_FRAMECTRL,
1023+ SFC_RF_TERM, &err);
10461024 bus->f1regdata++;
10471025
10481026 /* Wait until the packet has been flushed (device/FIFO stable) */
10491027 for (lastrbc = retries = 0xffff; retries > 0; retries--) {
1050− hi = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
1051− SBSDIO_FUNC1_RFRAMEBCHI, NULL);
1052− lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
1053− SBSDIO_FUNC1_RFRAMEBCLO, NULL);
1028+ hi = brcmf_sdio_regrb(bus->sdiodev,
1029+ SBSDIO_FUNC1_RFRAMEBCHI, &err);
1030+ lo = brcmf_sdio_regrb(bus->sdiodev,
1031+ SBSDIO_FUNC1_RFRAMEBCLO, &err);
10541032 bus->f1regdata += 2;
10551033
10561034 if ((hi == 0) && (lo == 0))
@@ -1070,11 +1048,11 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_sdio *bus, bool abort, bool rtx) · 13 unmodified lines
10701048
10711049 if (rtx) {
10721050 bus->rxrtx++;
1073− w_sdreg32(bus, SMB_NAK,
1074− offsetof(struct sdpcmd_regs, tosbmailbox), &retries);
1051+ err = w_sdreg32(bus, SMB_NAK,
1052+ offsetof(struct sdpcmd_regs, tosbmailbox));
10751053
10761054 bus->f1regdata++;
1077− if (retries <= retry_limit)
1055+ if (err == 0)
10781056 bus->rxskip = true;
10791057 }
10801058
@@ -1082,7 +1060,7 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_sdio *bus, bool abort, bool rtx) · 1 unmodified line
10821060 bus->nextlen = 0;
10831061
10841062 /* If we can't reach the device, signal failure */
1085− if (err || brcmf_sdcard_regfail(bus->sdiodev))
1063+ if (err)
10861064 bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN;
10871065 }
10881066
@@ -2178,21 +2156,16 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, · 1089 unmodified lines
21782156 bus->tx_sderrs++;
21792157
21802158 brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2);
2181− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
2182− SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM,
2183− NULL);
2159+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_FRAMECTRL,
2160+ SFC_WF_TERM, NULL);
21842161 bus->f1regdata++;
21852162
21862163 for (i = 0; i < 3; i++) {
21872164 u8 hi, lo;
2188− hi = brcmf_sdcard_cfg_read(bus->sdiodev,
2189− SDIO_FUNC_1,
2190− SBSDIO_FUNC1_WFRAMEBCHI,
2191− NULL);
2192− lo = brcmf_sdcard_cfg_read(bus->sdiodev,
2193− SDIO_FUNC_1,
2194− SBSDIO_FUNC1_WFRAMEBCLO,
2195− NULL);
2165+ hi = brcmf_sdio_regrb(bus->sdiodev,
2166+ SBSDIO_FUNC1_WFRAMEBCHI, NULL);
2167+ lo = brcmf_sdio_regrb(bus->sdiodev,
2168+ SBSDIO_FUNC1_WFRAMEBCLO, NULL);
21962169 bus->f1regdata += 2;
21972170 if ((hi == 0) && (lo == 0))
21982171 break;
@@ -2219,7 +2192,6 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_sdio *bus, uint maxframes) · 20 unmodified lines
22192192 {
22202193 struct sk_buff *pkt;
22212194 u32 intstatus = 0;
2222− uint retries = 0;
22232195 int ret = 0, prec_out;
22242196 uint cnt = 0;
22252197 uint datalen;
@@ -2249,11 +2221,11 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_sdio *bus, uint maxframes) · 23 unmodified lines
22492221 /* In poll mode, need to check for other events */
22502222 if (!bus->intr && cnt) {
22512223 /* Check device status, signal pending interrupt */
2252− r_sdreg32(bus, &intstatus,
2253− offsetof(struct sdpcmd_regs, intstatus),
2254− &retries);
2224+ ret = r_sdreg32(bus, &intstatus,
2225+ offsetof(struct sdpcmd_regs,
2226+ intstatus));
22552227 bus->f2txdata++;
2256− if (brcmf_sdcard_regfail(bus->sdiodev))
2228+ if (ret != 0)
22572229 break;
22582230 if (intstatus & bus->hostintmask)
22592231 bus->ipend = true;
@@ -2275,7 +2247,6 @@ static void brcmf_sdbrcm_bus_stop(struct device *dev) · 15 unmodified lines
22752247 {
22762248 u32 local_hostintmask;
22772249 u8 saveclk;
2278− uint retries;
22792250 int err;
22802251 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
22812252 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
@@ -2303,7 +2274,7 @@ static void brcmf_sdbrcm_bus_stop(struct device *dev) · 21 unmodified lines
23032274 brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false);
23042275
23052276 /* Disable and clear interrupts at the chip level also */
2306− w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, hostintmask), &retries);
2277+ w_sdreg32(bus, 0, offsetof(struct sdpcmd_regs, hostintmask));
23072278 local_hostintmask = bus->hostintmask;
23082279 bus->hostintmask = 0;
23092280
@@ -2311,24 +2282,23 @@ static void brcmf_sdbrcm_bus_stop(struct device *dev) · 1 unmodified line
23112282 bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN;
23122283
23132284 /* Force clocks on backplane to be sure F2 interrupt propagates */
2314− saveclk = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
2315− SBSDIO_FUNC1_CHIPCLKCSR, &err);
2285+ saveclk = brcmf_sdio_regrb(bus->sdiodev,
2286+ SBSDIO_FUNC1_CHIPCLKCSR, &err);
23162287 if (!err) {
2317− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
2318− SBSDIO_FUNC1_CHIPCLKCSR,
2319− (saveclk | SBSDIO_FORCE_HT), &err);
2288+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
2289+ (saveclk | SBSDIO_FORCE_HT), &err);
23202290 }
23212291 if (err)
23222292 brcmf_dbg(ERROR, "Failed to force clock for F2: err %d\n", err);
23232293
23242294 /* Turn off the bus (F2), free any pending packets */
23252295 brcmf_dbg(INTR, "disable SDIO interrupts\n");
2326− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx,
2327− SDIO_FUNC_ENABLE_1, NULL);
2296+ brcmf_sdio_regwb(bus->sdiodev, SDIO_CCCR_IOEx, SDIO_FUNC_ENABLE_1,
2297+ NULL);
23282298
23292299 /* Clear any pending interrupts now that F2 is disabled */
23302300 w_sdreg32(bus, local_hostintmask,
2331− offsetof(struct sdpcmd_regs, intstatus), &retries);
2301+ offsetof(struct sdpcmd_regs, intstatus));
23322302
23332303 /* Turn off the backplane clock (only) */
23342304 brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false);
@@ -2373,12 +2343,12 @@ static inline void brcmf_sdbrcm_clrintr(struct brcmf_sdio *bus) · 38 unmodified lines
23732343 static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus)
23742344 {
23752345 u32 intstatus, newstatus = 0;
2376− uint retries = 0;
23772346 uint rxlimit = bus->rxbound; /* Rx frames to read before resched */
23782347 uint txlimit = bus->txbound; /* Tx frames to send before resched */
23792348 uint framecnt = 0; /* Temporary counter of tx/rx frames */
23802349 bool rxdone = true; /* Flag for no more read data */
23812350 bool resched = false; /* Flag indicating resched wanted */
2351+ int err;
23822352
23832353 brcmf_dbg(TRACE, "Enter\n");
23842354
@@ -2389,13 +2359,12 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) · 4 unmodified lines
23892359
23902360 /* If waiting for HTAVAIL, check status */
23912361 if (bus->clkstate == CLK_PENDING) {
2392− int err;
23932362 u8 clkctl, devctl = 0;
23942363
23952364 #ifdef DEBUG
23962365 /* Check for inconsistent device control */
2397− devctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
2398− SBSDIO_DEVICE_CTL, &err);
2366+ devctl = brcmf_sdio_regrb(bus->sdiodev,
2367+ SBSDIO_DEVICE_CTL, &err);
23992368 if (err) {
24002369 brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err);
24012370 bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN;
@@ -2403,8 +2372,8 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) · 1 unmodified line
24032372 #endif /* DEBUG */
24042373
24052374 /* Read CSR, if clock on switch to AVAIL, else ignore */
2406− clkctl = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
2407− SBSDIO_FUNC1_CHIPCLKCSR, &err);
2375+ clkctl = brcmf_sdio_regrb(bus->sdiodev,
2376+ SBSDIO_FUNC1_CHIPCLKCSR, &err);
24082377 if (err) {
24092378 brcmf_dbg(ERROR, "error reading CSR: %d\n",
24102379 err);
@@ -2415,17 +2384,16 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) · 4 unmodified lines
24152384 devctl, clkctl);
24162385
24172386 if (SBSDIO_HTAV(clkctl)) {
2418− devctl = brcmf_sdcard_cfg_read(bus->sdiodev,
2419− SDIO_FUNC_1,
2420− SBSDIO_DEVICE_CTL, &err);
2387+ devctl = brcmf_sdio_regrb(bus->sdiodev,
2388+ SBSDIO_DEVICE_CTL, &err);
24212389 if (err) {
24222390 brcmf_dbg(ERROR, "error reading DEVCTL: %d\n",
24232391 err);
24242392 bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN;
24252393 }
24262394 devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
2427− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
2428− SBSDIO_DEVICE_CTL, devctl, &err);
2395+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_DEVICE_CTL,
2396+ devctl, &err);
24292397 if (err) {
24302398 brcmf_dbg(ERROR, "error writing DEVCTL: %d\n",
24312399 err);
@@ -2447,17 +2415,17 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) · 15 unmodified lines
24472415 /* Pending interrupt indicates new device status */
24482416 if (bus->ipend) {
24492417 bus->ipend = false;
2450− r_sdreg32(bus, &newstatus,
2451− offsetof(struct sdpcmd_regs, intstatus), &retries);
2418+ err = r_sdreg32(bus, &newstatus,
2419+ offsetof(struct sdpcmd_regs, intstatus));
24522420 bus->f1regdata++;
2453− if (brcmf_sdcard_regfail(bus->sdiodev))
2421+ if (err != 0)
24542422 newstatus = 0;
24552423 newstatus &= bus->hostintmask;
24562424 bus->fcstate = !!(newstatus & I_HMB_FC_STATE);
24572425 if (newstatus) {
2458− w_sdreg32(bus, newstatus,
2459− offsetof(struct sdpcmd_regs, intstatus),
2460− &retries);
2426+ err = w_sdreg32(bus, newstatus,
2427+ offsetof(struct sdpcmd_regs,
2428+ intstatus));
24612429 bus->f1regdata++;
24622430 }
24632431 }
@@ -2472,11 +2440,11 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) · 8 unmodified lines
24722440 */
24732441 if (intstatus & I_HMB_FC_CHANGE) {
24742442 intstatus &= ~I_HMB_FC_CHANGE;
2475− w_sdreg32(bus, I_HMB_FC_CHANGE,
2476− offsetof(struct sdpcmd_regs, intstatus), &retries);
2443+ err = w_sdreg32(bus, I_HMB_FC_CHANGE,
2444+ offsetof(struct sdpcmd_regs, intstatus));
24772445
2478− r_sdreg32(bus, &newstatus,
2479− offsetof(struct sdpcmd_regs, intstatus), &retries);
2446+ err = r_sdreg32(bus, &newstatus,
2447+ offsetof(struct sdpcmd_regs, intstatus));
24802448 bus->f1regdata += 2;
24812449 bus->fcstate =
24822450 !!(newstatus & (I_HMB_FC_STATE | I_HMB_FC_CHANGE));
@@ -2546,21 +2514,18 @@ clkwait: · 63 unmodified lines
25462514
25472515 brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2);
25482516
2549− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
2550− SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM,
2551− NULL);
2517+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_FRAMECTRL,
2518+ SFC_WF_TERM, &err);
25522519 bus->f1regdata++;
25532520
25542521 for (i = 0; i < 3; i++) {
25552522 u8 hi, lo;
2556− hi = brcmf_sdcard_cfg_read(bus->sdiodev,
2557− SDIO_FUNC_1,
2558− SBSDIO_FUNC1_WFRAMEBCHI,
2559− NULL);
2560− lo = brcmf_sdcard_cfg_read(bus->sdiodev,
2561− SDIO_FUNC_1,
2562− SBSDIO_FUNC1_WFRAMEBCLO,
2563− NULL);
2523+ hi = brcmf_sdio_regrb(bus->sdiodev,
2524+ SBSDIO_FUNC1_WFRAMEBCHI,
2525+ &err);
2526+ lo = brcmf_sdio_regrb(bus->sdiodev,
2527+ SBSDIO_FUNC1_WFRAMEBCLO,
2528+ &err);
25642529 bus->f1regdata += 2;
25652530 if ((hi == 0) && (lo == 0))
25662531 break;
@@ -2587,10 +2552,8 @@ clkwait: · 20 unmodified lines
25872552 else await next interrupt */
25882553 /* On failed register access, all bets are off:
25892554 no resched or interrupts */
2590− if ((bus->sdiodev->bus_if->state == BRCMF_BUS_DOWN) ||
2591− brcmf_sdcard_regfail(bus->sdiodev)) {
2592− brcmf_dbg(ERROR, "failed backplane access over SDIO, halting operation %d\n",
2593− brcmf_sdcard_regfail(bus->sdiodev));
2555+ if ((bus->sdiodev->bus_if->state == BRCMF_BUS_DOWN) || (err != 0)) {
2556+ brcmf_dbg(ERROR, "failed backplane access over SDIO, halting operation\n");
25942557 bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN;
25952558 bus->intstatus = 0;
25962559 } else if (bus->clkstate == CLK_PENDING) {
@@ -2886,19 +2849,16 @@ static int brcmf_tx_frame(struct brcmf_sdio *bus, u8 *frame, u16 len) · 289 unmodified lines
28862849
28872850 brcmf_sdcard_abort(bus->sdiodev, SDIO_FUNC_2);
28882851
2889− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
2890− SBSDIO_FUNC1_FRAMECTRL,
2891− SFC_WF_TERM, NULL);
2852+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_FRAMECTRL,
2853+ SFC_WF_TERM, NULL);
28922854 bus->f1regdata++;
28932855
28942856 for (i = 0; i < 3; i++) {
28952857 u8 hi, lo;
2896− hi = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
2897− SBSDIO_FUNC1_WFRAMEBCHI,
2898− NULL);
2899− lo = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
2900− SBSDIO_FUNC1_WFRAMEBCLO,
2901− NULL);
2858+ hi = brcmf_sdio_regrb(bus->sdiodev,
2859+ SBSDIO_FUNC1_WFRAMEBCHI, NULL);
2860+ lo = brcmf_sdio_regrb(bus->sdiodev,
2861+ SBSDIO_FUNC1_WFRAMEBCLO, NULL);
29022862 bus->f1regdata += 2;
29032863 if (hi == 0 && lo == 0)
29042864 break;
@@ -3188,7 +3148,6 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus) · 283 unmodified lines
31883148
31893149 static int brcmf_sdbrcm_download_state(struct brcmf_sdio *bus, bool enter)
31903150 {
3191− uint retries;
31923151 int bcmerror = 0;
31933152 struct chip_info *ci = bus->ci;
31943153
@@ -3222,7 +3181,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_sdio *bus, bool enter) · 27 unmodified lines
32223181 }
32233182
32243183 w_sdreg32(bus, 0xFFFFFFFF,
3225− offsetof(struct sdpcmd_regs, intstatus), &retries);
3184+ offsetof(struct sdpcmd_regs, intstatus));
32263185
32273186 ci->resetcore(bus->sdiodev, ci, BCMA_CORE_ARM_CM3);
32283187
@@ -3444,7 +3403,6 @@ static int brcmf_sdbrcm_bus_init(struct device *dev) · 215 unmodified lines
34443403 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
34453404 struct brcmf_sdio *bus = sdiodev->bus;
34463405 unsigned long timeout;
3447− uint retries = 0;
34483406 u8 ready, enable;
34493407 int err, ret = 0;
34503408 u8 saveclk;
@@ -3472,13 +3430,11 @@ static int brcmf_sdbrcm_bus_init(struct device *dev) · 21 unmodified lines
34723430 goto exit;
34733431
34743432 /* Force clocks on backplane to be sure F2 interrupt propagates */
3475− saveclk =
3476− brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
3477− SBSDIO_FUNC1_CHIPCLKCSR, &err);
3433+ saveclk = brcmf_sdio_regrb(bus->sdiodev,
3434+ SBSDIO_FUNC1_CHIPCLKCSR, &err);
34783435 if (!err) {
3479− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
3480− SBSDIO_FUNC1_CHIPCLKCSR,
3481− (saveclk | SBSDIO_FORCE_HT), &err);
3436+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
3437+ (saveclk | SBSDIO_FORCE_HT), &err);
34823438 }
34833439 if (err) {
34843440 brcmf_dbg(ERROR, "Failed to force clock for F2: err %d\n", err);
@@ -3487,17 +3443,16 @@ static int brcmf_sdbrcm_bus_init(struct device *dev) · 2 unmodified lines
34873443
34883444 /* Enable function 2 (frame transfers) */
34893445 w_sdreg32(bus, SDPCM_PROT_VERSION << SMB_DATA_VERSION_SHIFT,
3490− offsetof(struct sdpcmd_regs, tosbmailboxdata), &retries);
3446+ offsetof(struct sdpcmd_regs, tosbmailboxdata));
34913447 enable = (SDIO_FUNC_ENABLE_1 | SDIO_FUNC_ENABLE_2);
34923448
3493− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx,
3494− enable, NULL);
3449+ brcmf_sdio_regwb(bus->sdiodev, SDIO_CCCR_IOEx, enable, NULL);
34953450
34963451 timeout = jiffies + msecs_to_jiffies(BRCMF_WAIT_F2RDY);
34973452 ready = 0;
34983453 while (enable != ready) {
3499− ready = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_0,
3500− SDIO_CCCR_IORx, NULL);
3454+ ready = brcmf_sdio_regrb(bus->sdiodev,
3455+ SDIO_CCCR_IORx, NULL);
35013456 if (time_after(jiffies, timeout))
35023457 break;
35033458 else if (time_after(jiffies, timeout - BRCMF_WAIT_F2RDY + 50))
@@ -3512,21 +3467,18 @@ static int brcmf_sdbrcm_bus_init(struct device *dev) · 8 unmodified lines
35123467 /* Set up the interrupt mask and enable interrupts */
35133468 bus->hostintmask = HOSTINTMASK;
35143469 w_sdreg32(bus, bus->hostintmask,
3515− offsetof(struct sdpcmd_regs, hostintmask), &retries);
3470+ offsetof(struct sdpcmd_regs, hostintmask));
35163471
3517− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
3518− SBSDIO_WATERMARK, 8, &err);
3472+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_WATERMARK, 8, &err);
35193473 } else {
35203474 /* Disable F2 again */
35213475 enable = SDIO_FUNC_ENABLE_1;
3522− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0,
3523− SDIO_CCCR_IOEx, enable, NULL);
3476+ brcmf_sdio_regwb(bus->sdiodev, SDIO_CCCR_IOEx, enable, NULL);
35243477 ret = -ENODEV;
35253478 }
35263479
35273480 /* Restore previous clock setting */
3528− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
3529− SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err);
3481+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err);
35303482
35313483 if (ret == 0) {
35323484 ret = brcmf_sdio_intr_register(bus->sdiodev);
@@ -3606,9 +3558,9 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus) · 73 unmodified lines
36063558
36073559 if (!bus->dpc_sched) {
36083560 u8 devpend;
3609− devpend = brcmf_sdcard_cfg_read(bus->sdiodev,
3610− SDIO_FUNC_0, SDIO_CCCR_INTx,
3611− NULL);
3561+ devpend = brcmf_sdio_regrb(bus->sdiodev,
3562+ SDIO_CCCR_INTx,
3563+ NULL);
36123564 intstatus =
36133565 devpend & (INTR_STATUS_FUNC1 |
36143566 INTR_STATUS_FUNC2);
@@ -3732,24 +3684,18 @@ brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva) · 117 unmodified lines
37323684
37333685 bus->alp_only = true;
37343686
3735− /* Return the window to backplane enumeration space for core access */
3736− if (brcmf_sdcard_set_sbaddr_window(bus->sdiodev, SI_ENUM_BASE))
3737− brcmf_dbg(ERROR, "FAILED to return to SI_ENUM_BASE\n");
3738−
37393687 pr_debug("F1 signature read @0x18000000=0x%4x\n",
3740− brcmf_sdcard_reg_read(bus->sdiodev, SI_ENUM_BASE, 4));
3688+ brcmf_sdio_regrl(bus->sdiodev, SI_ENUM_BASE, NULL));
37413689
37423690 /*
37433691 * Force PLL off until brcmf_sdio_chip_attach()
37443692 * programs PLL control regs
37453693 */
37463694
3747− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
3748− SBSDIO_FUNC1_CHIPCLKCSR,
3749− BRCMF_INIT_CLKCTL1, &err);
3695+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
3696+ BRCMF_INIT_CLKCTL1, &err);
37503697 if (!err)
3751− clkctl =
3752− brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1,
3698+ clkctl = brcmf_sdio_regrb(bus->sdiodev,
37533699 SBSDIO_FUNC1_CHIPCLKCSR, &err);
37543700
37553701 if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) {
@@ -3782,9 +3728,8 @@ brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva) · 26 unmodified lines
37823728 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV);
37833729 reg_addr = bus->ci->c_inf[idx].base +
37843730 offsetof(struct sdpcmd_regs, corecontrol);
3785− reg_val = brcmf_sdcard_reg_read(bus->sdiodev, reg_addr, sizeof(u32));
3786− brcmf_sdcard_reg_write(bus->sdiodev, reg_addr, sizeof(u32),
3787− reg_val | CC_BPRESEN);
3731+ reg_val = brcmf_sdio_regrl(bus->sdiodev, reg_addr, NULL);
3732+ brcmf_sdio_regwl(bus->sdiodev, reg_addr, reg_val | CC_BPRESEN, NULL);
37883733
37893734 brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN);
37903735
@@ -3809,16 +3754,15 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_sdio *bus) · 18 unmodified lines
38093754 brcmf_dbg(TRACE, "Enter\n");
38103755
38113756 /* Disable F2 to clear any intermediate frame state on the dongle */
3812− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx,
3813− SDIO_FUNC_ENABLE_1, NULL);
3757+ brcmf_sdio_regwb(bus->sdiodev, SDIO_CCCR_IOEx,
3758+ SDIO_FUNC_ENABLE_1, NULL);
38143759
38153760 bus->sdiodev->bus_if->state = BRCMF_BUS_DOWN;
38163761 bus->sleeping = false;
38173762 bus->rxflow = false;
38183763
38193764 /* Done with backplane-dependent accesses, can drop clock... */
3820− brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1,
3821− SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL);
3765+ brcmf_sdio_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL);
38223766
38233767 /* ...and initialize clock/power states */
38243768 bus->clkstate = CLK_SDONLY;
drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c+138−127
@@ -93,8 +93,9 @@ brcmf_sdio_sb_corerev(struct brcmf_sdio_dev *sdiodev, · 92 unmodified lines
9393
9494 idx = brcmf_sdio_chip_getinfidx(ci, coreid);
9595
96− regdata = brcmf_sdcard_reg_read(sdiodev,
97− CORE_SB(ci->c_inf[idx].base, sbidhigh), 4);
96+ regdata = brcmf_sdio_regrl(sdiodev,
97+ CORE_SB(ci->c_inf[idx].base, sbidhigh),
98+ NULL);
9899 return SBCOREREV(regdata);
99100 }
100101
@@ -118,8 +119,9 @@ brcmf_sdio_sb_iscoreup(struct brcmf_sdio_dev *sdiodev, · 17 unmodified lines
118119
119120 idx = brcmf_sdio_chip_getinfidx(ci, coreid);
120121
121− regdata = brcmf_sdcard_reg_read(sdiodev,
122− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4);
122+ regdata = brcmf_sdio_regrl(sdiodev,
123+ CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
124+ NULL);
123125 regdata &= (SSB_TMSLOW_RESET | SSB_TMSLOW_REJECT |
124126 SSB_IMSTATE_REJECT | SSB_TMSLOW_CLOCK);
125127 return (SSB_TMSLOW_CLOCK == regdata);
@@ -135,13 +137,13 @@ brcmf_sdio_ai_iscoreup(struct brcmf_sdio_dev *sdiodev, · 9 unmodified lines
135137
136138 idx = brcmf_sdio_chip_getinfidx(ci, coreid);
137139
138− regdata = brcmf_sdcard_reg_read(sdiodev,
139− ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4);
140+ regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
141+ NULL);
140142 ret = (regdata & (BCMA_IOCTL_FGC | BCMA_IOCTL_CLK)) == BCMA_IOCTL_CLK;
141143
142− regdata = brcmf_sdcard_reg_read(sdiodev,
143− ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
144− 4);
144+ regdata = brcmf_sdio_regrl(sdiodev,
145+ ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
146+ NULL);
145147 ret = ret && ((regdata & BCMA_RESET_CTL_RESET) == 0);
146148
147149 return ret;
@@ -151,84 +153,85 @@ static void · 3 unmodified lines
151153 brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev,
152154 struct chip_info *ci, u16 coreid)
153155 {
154− u32 regdata;
156+ u32 regdata, base;
155157 u8 idx;
156158
157159 idx = brcmf_sdio_chip_getinfidx(ci, coreid);
160+ base = ci->c_inf[idx].base;
158161
159− regdata = brcmf_sdcard_reg_read(sdiodev,
160− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4);
162+ regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow), NULL);
161163 if (regdata & SSB_TMSLOW_RESET)
162164 return;
163165
164− regdata = brcmf_sdcard_reg_read(sdiodev,
165− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4);
166+ regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow), NULL);
166167 if ((regdata & SSB_TMSLOW_CLOCK) != 0) {
167168 /*
168169 * set target reject and spin until busy is clear
169170 * (preserve core-specific bits)
170171 */
171− regdata = brcmf_sdcard_reg_read(sdiodev,
172− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4);
173− brcmf_sdcard_reg_write(sdiodev,
174− CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
175− 4, regdata | SSB_TMSLOW_REJECT);
176−
177− regdata = brcmf_sdcard_reg_read(sdiodev,
178− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4);
172+ regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
173+ NULL);
174+ brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
175+ regdata | SSB_TMSLOW_REJECT, NULL);
176+
177+ regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
178+ NULL);
179179 udelay(1);
180− SPINWAIT((brcmf_sdcard_reg_read(sdiodev,
181− CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4) &
180+ SPINWAIT((brcmf_sdio_regrl(sdiodev,
181+ CORE_SB(base, sbtmstatehigh),
182+ NULL) &
182183 SSB_TMSHIGH_BUSY), 100000);
183184
184− regdata = brcmf_sdcard_reg_read(sdiodev,
185− CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4);
185+ regdata = brcmf_sdio_regrl(sdiodev,
186+ CORE_SB(base, sbtmstatehigh),
187+ NULL);
186188 if (regdata & SSB_TMSHIGH_BUSY)
187189 brcmf_dbg(ERROR, "core state still busy\n");
188190
189− regdata = brcmf_sdcard_reg_read(sdiodev,
190− CORE_SB(ci->c_inf[idx].base, sbidlow), 4);
191+ regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbidlow),
192+ NULL);
191193 if (regdata & SSB_IDLOW_INITIATOR) {
192− regdata = brcmf_sdcard_reg_read(sdiodev,
193− CORE_SB(ci->c_inf[idx].base, sbimstate), 4) |
194− SSB_IMSTATE_REJECT;
195− brcmf_sdcard_reg_write(sdiodev,
196− CORE_SB(ci->c_inf[idx].base, sbimstate), 4,
197− regdata);
198− regdata = brcmf_sdcard_reg_read(sdiodev,
199− CORE_SB(ci->c_inf[idx].base, sbimstate), 4);
194+ regdata = brcmf_sdio_regrl(sdiodev,
195+ CORE_SB(base, sbimstate),
196+ NULL);
197+ regdata |= SSB_IMSTATE_REJECT;
198+ brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbimstate),
199+ regdata, NULL);
200+ regdata = brcmf_sdio_regrl(sdiodev,
201+ CORE_SB(base, sbimstate),
202+ NULL);
200203 udelay(1);
201− SPINWAIT((brcmf_sdcard_reg_read(sdiodev,
202− CORE_SB(ci->c_inf[idx].base, sbimstate), 4) &
204+ SPINWAIT((brcmf_sdio_regrl(sdiodev,
205+ CORE_SB(base, sbimstate),
206+ NULL) &
203207 SSB_IMSTATE_BUSY), 100000);
204208 }
205209
206210 /* set reset and reject while enabling the clocks */
207− brcmf_sdcard_reg_write(sdiodev,
208− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4,
209− (SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
210− SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET));
211− regdata = brcmf_sdcard_reg_read(sdiodev,
212− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4);
211+ regdata = SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
212+ SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET;
213+ brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
214+ regdata, NULL);
215+ regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbtmstatelow),
216+ NULL);
213217 udelay(10);
214218
215219 /* clear the initiator reject bit */
216− regdata = brcmf_sdcard_reg_read(sdiodev,
217− CORE_SB(ci->c_inf[idx].base, sbidlow), 4);
220+ regdata = brcmf_sdio_regrl(sdiodev, CORE_SB(base, sbidlow),
221+ NULL);
218222 if (regdata & SSB_IDLOW_INITIATOR) {
219− regdata = brcmf_sdcard_reg_read(sdiodev,
220− CORE_SB(ci->c_inf[idx].base, sbimstate), 4) &
221− ~SSB_IMSTATE_REJECT;
222− brcmf_sdcard_reg_write(sdiodev,
223− CORE_SB(ci->c_inf[idx].base, sbimstate), 4,
224− regdata);
223+ regdata = brcmf_sdio_regrl(sdiodev,
224+ CORE_SB(base, sbimstate),
225+ NULL);
226+ regdata &= ~SSB_IMSTATE_REJECT;
227+ brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbimstate),
228+ regdata, NULL);
225229 }
226230 }
227231
228232 /* leave reset and reject asserted */
229− brcmf_sdcard_reg_write(sdiodev,
230− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4,
231− (SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET));
233+ brcmf_sdio_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
234+ (SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET), NULL);
232235 udelay(1);
233236 }
234237
@@ -242,20 +245,19 @@ brcmf_sdio_ai_coredisable(struct brcmf_sdio_dev *sdiodev, · 7 unmodified lines
242245 idx = brcmf_sdio_chip_getinfidx(ci, coreid);
243246
244247 /* if core is already in reset, just return */
245− regdata = brcmf_sdcard_reg_read(sdiodev,
246− ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
247− 4);
248+ regdata = brcmf_sdio_regrl(sdiodev,
249+ ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
250+ NULL);
248251 if ((regdata & BCMA_RESET_CTL_RESET) != 0)
249252 return;
250253
251− brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
252− 4, 0);
253− regdata = brcmf_sdcard_reg_read(sdiodev,
254− ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4);
254+ brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL, 0, NULL);
255+ regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
256+ NULL);
255257 udelay(10);
256258
257− brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
258− 4, BCMA_RESET_CTL_RESET);
259+ brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
260+ BCMA_RESET_CTL_RESET, NULL);
259261 udelay(1);
260262 }
261263
@@ -279,41 +281,47 @@ brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev, · 17 unmodified lines
279281 * set reset while enabling the clock and
280282 * forcing them on throughout the core
281283 */
282− brcmf_sdcard_reg_write(sdiodev,
283− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4,
284− SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET);
285− regdata = brcmf_sdcard_reg_read(sdiodev,
286− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4);
284+ brcmf_sdio_regwl(sdiodev,
285+ CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
286+ SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET,
287+ NULL);
288+ regdata = brcmf_sdio_regrl(sdiodev,
289+ CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
290+ NULL);
287291 udelay(1);
288292
289293 /* clear any serror */
290− regdata = brcmf_sdcard_reg_read(sdiodev,
291− CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4);
294+ regdata = brcmf_sdio_regrl(sdiodev,
295+ CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
296+ NULL);
292297 if (regdata & SSB_TMSHIGH_SERR)
293− brcmf_sdcard_reg_write(sdiodev,
294− CORE_SB(ci->c_inf[idx].base, sbtmstatehigh), 4, 0);
298+ brcmf_sdio_regwl(sdiodev,
299+ CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
300+ 0, NULL);
295301
296− regdata = brcmf_sdcard_reg_read(sdiodev,
297− CORE_SB(ci->c_inf[idx].base, sbimstate), 4);
302+ regdata = brcmf_sdio_regrl(sdiodev,
303+ CORE_SB(ci->c_inf[idx].base, sbimstate),
304+ NULL);
298305 if (regdata & (SSB_IMSTATE_IBE | SSB_IMSTATE_TO))
299− brcmf_sdcard_reg_write(sdiodev,
300− CORE_SB(ci->c_inf[idx].base, sbimstate), 4,
301− regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO));
306+ brcmf_sdio_regwl(sdiodev,
307+ CORE_SB(ci->c_inf[idx].base, sbimstate),
308+ regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO),
309+ NULL);
302310
303311 /* clear reset and allow it to propagate throughout the core */
304− brcmf_sdcard_reg_write(sdiodev,
305− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4,
306− SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK);
307− regdata = brcmf_sdcard_reg_read(sdiodev,
308− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4);
312+ brcmf_sdio_regwl(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
313+ SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK, NULL);
314+ regdata = brcmf_sdio_regrl(sdiodev,
315+ CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
316+ NULL);
309317 udelay(1);
310318
311319 /* leave clock enabled */
312− brcmf_sdcard_reg_write(sdiodev,
313− CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
314− 4, SSB_TMSLOW_CLOCK);
315− regdata = brcmf_sdcard_reg_read(sdiodev,
316− CORE_SB(ci->c_inf[idx].base, sbtmstatelow), 4);
320+ brcmf_sdio_regwl(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
321+ SSB_TMSLOW_CLOCK, NULL);
322+ regdata = brcmf_sdio_regrl(sdiodev,
323+ CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
324+ NULL);
317325 udelay(1);
318326 }
319327
@@ -330,18 +338,18 @@ brcmf_sdio_ai_resetcore(struct brcmf_sdio_dev *sdiodev, · 10 unmodified lines
330338 brcmf_sdio_ai_coredisable(sdiodev, ci, coreid);
331339
332340 /* now do initialization sequence */
333− brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
334− 4, BCMA_IOCTL_FGC | BCMA_IOCTL_CLK);
335− regdata = brcmf_sdcard_reg_read(sdiodev,
336− ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4);
337− brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
338− 4, 0);
341+ brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
342+ BCMA_IOCTL_FGC | BCMA_IOCTL_CLK, NULL);
343+ regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
344+ NULL);
345+ brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
346+ 0, NULL);
339347 udelay(1);
340348
341− brcmf_sdcard_reg_write(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
342− 4, BCMA_IOCTL_CLK);
343− regdata = brcmf_sdcard_reg_read(sdiodev,
344− ci->c_inf[idx].wrapbase+BCMA_IOCTL, 4);
349+ brcmf_sdio_regwl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
350+ BCMA_IOCTL_CLK, NULL);
351+ regdata = brcmf_sdio_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
352+ NULL);
345353 udelay(1);
346354 }
347355
@@ -358,8 +366,9 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, · 10 unmodified lines
358366 */
359367 ci->c_inf[0].id = BCMA_CORE_CHIPCOMMON;
360368 ci->c_inf[0].base = regs;
361− regdata = brcmf_sdcard_reg_read(sdiodev,
362− CORE_CC_REG(ci->c_inf[0].base, chipid), 4);
369+ regdata = brcmf_sdio_regrl(sdiodev,
370+ CORE_CC_REG(ci->c_inf[0].base, chipid),
371+ NULL);
363372 ci->chip = regdata & CID_ID_MASK;
364373 ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT;
365374 ci->socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
@@ -428,8 +437,7 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev) · 62 unmodified lines
428437
429438 /* Try forcing SDIO core to do ALPAvail request only */
430439 clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ;
431− brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1,
432− SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err);
440+ brcmf_sdio_regwb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err);
433441 if (err) {
434442 brcmf_dbg(ERROR, "error writing for HT off\n");
435443 return err;
@@ -437,8 +445,8 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev) · 1 unmodified line
437445
438446 /* If register supported, wait for ALPAvail and then force ALP */
439447 /* This may take up to 15 milliseconds */
440− clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1,
441− SBSDIO_FUNC1_CHIPCLKCSR, NULL);
448+ clkval = brcmf_sdio_regrb(sdiodev,
449+ SBSDIO_FUNC1_CHIPCLKCSR, NULL);
442450
443451 if ((clkval & ~SBSDIO_AVBITS) != clkset) {
444452 brcmf_dbg(ERROR, "ChipClkCSR access: wrote 0x%02x read 0x%02x\n",
@@ -446,8 +454,8 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev) · 1 unmodified line
446454 return -EACCES;
447455 }
448456
449− SPINWAIT(((clkval = brcmf_sdcard_cfg_read(sdiodev, SDIO_FUNC_1,
450− SBSDIO_FUNC1_CHIPCLKCSR, NULL)),
457+ SPINWAIT(((clkval = brcmf_sdio_regrb(sdiodev,
458+ SBSDIO_FUNC1_CHIPCLKCSR, NULL)),
451459 !SBSDIO_ALPAV(clkval)),
452460 PMU_MAX_TRANSITION_DLY);
453461 if (!SBSDIO_ALPAV(clkval)) {
@@ -457,13 +465,11 @@ brcmf_sdio_chip_buscoreprep(struct brcmf_sdio_dev *sdiodev) · 3 unmodified lines
457465 }
458466
459467 clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_FORCE_ALP;
460− brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1,
461− SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err);
468+ brcmf_sdio_regwb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, clkset, &err);
462469 udelay(65);
463470
464471 /* Also, disable the extra SDIO pull-ups */
465− brcmf_sdcard_cfg_write(sdiodev, SDIO_FUNC_1,
466− SBSDIO_FUNC1_SDIOPULLUP, 0, NULL);
472+ brcmf_sdio_regwb(sdiodev, SBSDIO_FUNC1_SDIOPULLUP, 0, NULL);
467473
468474 return 0;
469475 }
@@ -472,18 +478,22 @@ static void · 2 unmodified lines
472478 brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev,
473479 struct chip_info *ci)
474480 {
481+ u32 base = ci->c_inf[0].base;
482+
475483 /* get chipcommon rev */
476484 ci->c_inf[0].rev = ci->corerev(sdiodev, ci, ci->c_inf[0].id);
477485
478486 /* get chipcommon capabilites */
479− ci->c_inf[0].caps =
480− brcmf_sdcard_reg_read(sdiodev,
481− CORE_CC_REG(ci->c_inf[0].base, capabilities), 4);
487+ ci->c_inf[0].caps = brcmf_sdio_regrl(sdiodev,
488+ CORE_CC_REG(base, capabilities),
489+ NULL);
482490
483491 /* get pmu caps & rev */
484492 if (ci->c_inf[0].caps & CC_CAP_PMU) {
485− ci->pmucaps = brcmf_sdcard_reg_read(sdiodev,
486− CORE_CC_REG(ci->c_inf[0].base, pmucapabilities), 4);
493+ ci->pmucaps =
494+ brcmf_sdio_regrl(sdiodev,
495+ CORE_CC_REG(base, pmucapabilities),
496+ NULL);
487497 ci->pmurev = ci->pmucaps & PCAP_REV_MASK;
488498 }
489499
@@ -523,10 +533,10 @@ int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev, · 33 unmodified lines
523533
524534 brcmf_sdio_chip_buscoresetup(sdiodev, ci);
525535
526− brcmf_sdcard_reg_write(sdiodev,
527− CORE_CC_REG(ci->c_inf[0].base, gpiopullup), 4, 0);
528− brcmf_sdcard_reg_write(sdiodev,
529− CORE_CC_REG(ci->c_inf[0].base, gpiopulldown), 4, 0);
536+ brcmf_sdio_regwl(sdiodev, CORE_CC_REG(ci->c_inf[0].base, gpiopullup),
537+ 0, NULL);
538+ brcmf_sdio_regwl(sdiodev, CORE_CC_REG(ci->c_inf[0].base, gpiopulldown),
539+ 0, NULL);
530540
531541 *ci_ptr = ci;
532542 return 0;
@@ -562,6 +572,7 @@ brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, · 29 unmodified lines
562572 u32 str_mask = 0;
563573 u32 str_shift = 0;
564574 char chn[8];
575+ u32 base = ci->c_inf[0].base;
565576
566577 if (!(ci->c_inf[0].caps & CC_CAP_PMU))
567578 return;
@@ -591,17 +602,17 @@ brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, · 23 unmodified lines
591602 }
592603 }
593604
594− brcmf_sdcard_reg_write(sdiodev,
595− CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr),
596− 4, 1);
597− cc_data_temp = brcmf_sdcard_reg_read(sdiodev,
598− CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr), 4);
605+ brcmf_sdio_regwl(sdiodev, CORE_CC_REG(base, chipcontrol_addr),
606+ 1, NULL);
607+ cc_data_temp =
608+ brcmf_sdio_regrl(sdiodev,
609+ CORE_CC_REG(base, chipcontrol_addr),
610+ NULL);
599611 cc_data_temp &= ~str_mask;
600612 drivestrength_sel <<= str_shift;
601613 cc_data_temp |= drivestrength_sel;
602− brcmf_sdcard_reg_write(sdiodev,
603− CORE_CC_REG(ci->c_inf[0].base, chipcontrol_addr),
604− 4, cc_data_temp);
614+ brcmf_sdio_regwl(sdiodev, CORE_CC_REG(base, chipcontrol_addr),
615+ cc_data_temp, NULL);
605616
606617 brcmf_dbg(INFO, "SDIO: %dmA drive strength selected, set to 0x%08x\n",
607618 drivestrength, cc_data_temp);
drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h+11−26
@@ -40,6 +40,10 @@ · 39 unmodified lines
4040 /* Maximum number of I/O funcs */
4141 #define SDIOD_MAX_IOFUNCS 7
4242
43+/* mask of register map */
44+#define REG_F0_REG_MASK 0x7FF
45+#define REG_F1_MISC_MASK 0x1FFFF
46+
4347 /* as of sdiod rev 0, supports 3 functions */
4448 #define SBSDIO_NUM_FUNCTION 3
4549
@@ -142,7 +146,6 @@ struct brcmf_sdio_dev { · 96 unmodified lines
142146 u8 num_funcs; /* Supported funcs on client */
143147 u32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
144148 u32 sbwad; /* Save backplane window address */
145− bool regfail; /* status of last reg_r/w call */
146149 void *bus;
147150 atomic_t suspend; /* suspend flag */
148151 wait_queue_head_t request_byte_wait;
@@ -164,31 +167,13 @@ struct brcmf_sdio_dev { · 15 unmodified lines
164167 extern int brcmf_sdio_intr_register(struct brcmf_sdio_dev *sdiodev);
165168 extern int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev);
166169
167−/* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface).
168− * fn: function number
169− * addr: unmodified SDIO-space address
170− * data: data byte to write
171− * err: pointer to error code (or NULL)
172− */
173−extern u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint func,
174− u32 addr, int *err);
175−extern void brcmf_sdcard_cfg_write(struct brcmf_sdio_dev *sdiodev, uint func,
176− u32 addr, u8 data, int *err);
177−
178−/* Synchronous access to device (client) core registers via CMD53 to F1.
179− * addr: backplane address (i.e. >= regsva from attach)
180− * size: register width in bytes (2 or 4)
181− * data: data for register write
182− */
183−extern u32
184−brcmf_sdcard_reg_read(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size);
185−
186−extern u32
187−brcmf_sdcard_reg_write(struct brcmf_sdio_dev *sdiodev, u32 addr, uint size,
188− u32 data);
189−
190−/* Indicate if last reg read/write failed */
191−extern bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev);
170+/* sdio device register access interface */
171+extern u8 brcmf_sdio_regrb(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
172+extern u32 brcmf_sdio_regrl(struct brcmf_sdio_dev *sdiodev, u32 addr, int *ret);
173+extern void brcmf_sdio_regwb(struct brcmf_sdio_dev *sdiodev, u32 addr,
174+ u8 data, int *ret);
175+extern void brcmf_sdio_regwl(struct brcmf_sdio_dev *sdiodev, u32 addr,
176+ u32 data, int *ret);
192177
193178 /* Buffer transfer to/from device (client) core via cmd53.
194179 * fn: function number
drivers/net/wireless/brcm80211/brcmsmac/Makefile+0−3
@@ -39,10 +39,7 @@ BRCMSMAC_OFILES := \ · 38 unmodified lines
3939 phy/phytbl_lcn.o \
4040 phy/phytbl_n.o \
4141 phy/phy_qmath.o \
42− otp.o \
43− srom.o \
4442 dma.o \
45− nicpci.o \
4643 brcms_trace_events.o
4744
4845 MODULEPFX := brcmsmac
drivers/net/wireless/brcm80211/brcmsmac/aiutils.c+39−440
@@ -19,7 +19,6 @@ · 18 unmodified lines
1919 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
2020
2121 #include <linux/delay.h>
22−#include <linux/pci.h>
2322
2423 #include <defs.h>
2524 #include <chipcommon.h>
@@ -29,8 +28,6 @@ · 3 unmodified lines
2928 #include "types.h"
3029 #include "pub.h"
3130 #include "pmu.h"
32−#include "srom.h"
33−#include "nicpci.h"
3431 #include "aiutils.h"
3532
3633 /* slow_clk_ctl */
@@ -321,7 +318,6 @@ · 284 unmodified lines
321318 #define IS_SIM(chippkg) \
322319 ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID))
323320
324−#define PCI(sih) (ai_get_buscoretype(sih) == PCI_CORE_ID)
325321 #define PCIE(sih) (ai_get_buscoretype(sih) == PCIE_CORE_ID)
326322
327323 #define PCI_FORCEHT(sih) (PCIE(sih) && (ai_get_chip_id(sih) == BCM4716_CHIP_ID))
@@ -454,36 +450,9 @@ struct aidmp { · 126 unmodified lines
454450 u32 componentid3; /* 0xffc */
455451 };
456452
457−/* return true if PCIE capability exists in the pci config space */
458−static bool ai_ispcie(struct si_info *sii)
459−{
460− u8 cap_ptr;
461−
462− cap_ptr =
463− pcicore_find_pci_capability(sii->pcibus, PCI_CAP_ID_EXP, NULL,
464− NULL);
465− if (!cap_ptr)
466− return false;
467−
468− return true;
469−}
470−
471−static bool ai_buscore_prep(struct si_info *sii)
472−{
473− /* kludge to enable the clock on the 4306 which lacks a slowclock */
474− if (!ai_ispcie(sii))
475− ai_clkctl_xtal(&sii->pub, XTAL | PLL, ON);
476− return true;
477−}
478−
479453 static bool
480454 ai_buscore_setup(struct si_info *sii, struct bcma_device *cc)
481455 {
482− struct bcma_device *pci = NULL;
483− struct bcma_device *pcie = NULL;
484− struct bcma_device *core;
485−
486−
487456 /* no cores found, bail out */
488457 if (cc->bus->nr_cores == 0)
489458 return false;
@@ -492,8 +461,7 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) · 2 unmodified lines
492461 sii->pub.ccrev = cc->id.rev;
493462
494463 /* get chipcommon chipstatus */
495− if (ai_get_ccrev(&sii->pub) >= 11)
496− sii->chipst = bcma_read32(cc, CHIPCREGOFFS(chipstatus));
464+ sii->chipst = bcma_read32(cc, CHIPCREGOFFS(chipstatus));
497465
498466 /* get chipcommon capabilites */
499467 sii->pub.cccaps = bcma_read32(cc, CHIPCREGOFFS(capabilities));
@@ -506,64 +474,18 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) · 6 unmodified lines
506474 }
507475
508476 /* figure out buscore */
509− list_for_each_entry(core, &cc->bus->cores, list) {
510− uint cid, crev;
511−
512− cid = core->id.id;
513− crev = core->id.rev;
514−
515− if (cid == PCI_CORE_ID) {
516− pci = core;
517− } else if (cid == PCIE_CORE_ID) {
518− pcie = core;
519− }
520− }
521−
522− if (pci && pcie) {
523− if (ai_ispcie(sii))
524− pci = NULL;
525− else
526− pcie = NULL;
527− }
528− if (pci) {
529− sii->buscore = pci;
530− } else if (pcie) {
531− sii->buscore = pcie;
532− }
533−
534− /* fixup necessary chip/core configurations */
535− if (!sii->pch) {
536− sii->pch = pcicore_init(&sii->pub, sii->icbus->drv_pci.core);
537− if (sii->pch == NULL)
538− return false;
539− }
540− if (ai_pci_fixcfg(&sii->pub))
541− return false;
477+ sii->buscore = ai_findcore(&sii->pub, PCIE_CORE_ID, 0);
542478
543479 return true;
544480 }
545481
546−/*
547− * get boardtype and boardrev
548− */
549−static __used void ai_nvram_process(struct si_info *sii)
550−{
551− uint w = 0;
552−
553− /* do a pci config read to get subsystem id and subvendor id */
554− pci_read_config_dword(sii->pcibus, PCI_SUBSYSTEM_VENDOR_ID, &w);
555−
556− sii->pub.boardvendor = w & 0xffff;
557− sii->pub.boardtype = (w >> 16) & 0xffff;
558−}
559−
560482 static struct si_info *ai_doattach(struct si_info *sii,
561483 struct bcma_bus *pbus)
562484 {
563485 struct si_pub *sih = &sii->pub;
564486 u32 w, savewin;
565487 struct bcma_device *cc;
566− uint socitype;
488+ struct ssb_sprom *sprom = &pbus->sprom;
567489
568490 savewin = 0;
569491
@@ -573,38 +495,15 @@ static struct si_info *ai_doattach(struct si_info *sii, · 3 unmodified lines
573495 /* switch to Chipcommon core */
574496 cc = pbus->drv_cc.core;
575497
576− /* bus/core/clk setup for register access */
577− if (!ai_buscore_prep(sii))
578− return NULL;
498+ sih->chip = pbus->chipinfo.id;
499+ sih->chiprev = pbus->chipinfo.rev;
500+ sih->chippkg = pbus->chipinfo.pkg;
501+ sih->boardvendor = pbus->boardinfo.vendor;
502+ sih->boardtype = pbus->boardinfo.type;
579503
580− /*
581− * ChipID recognition.
582− * We assume we can read chipid at offset 0 from the regs arg.
583− * If we add other chiptypes (or if we need to support old sdio
584− * hosts w/o chipcommon), some way of recognizing them needs to
585− * be added here.
586− */
587− w = bcma_read32(cc, CHIPCREGOFFS(chipid));
588− socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
589− /* Might as wll fill in chip id rev & pkg */
590− sih->chip = w & CID_ID_MASK;
591− sih->chiprev = (w & CID_REV_MASK) >> CID_REV_SHIFT;
592− sih->chippkg = (w & CID_PKG_MASK) >> CID_PKG_SHIFT;
593−
594− /* scan for cores */
595− if (socitype != SOCI_AI)
596− return NULL;
597−
598− SI_MSG("Found chip type AI (0x%08x)\n", w);
599504 if (!ai_buscore_setup(sii, cc))
600505 goto exit;
601506
602− /* Init nvram from sprom/otp if they exist */
603− if (srom_var_init(&sii->pub))
604− goto exit;
605−
606− ai_nvram_process(sii);
607−
608507 /* === NVRAM, clock is ready === */
609508 bcma_write32(cc, CHIPCREGOFFS(gpiopullup), 0);
610509 bcma_write32(cc, CHIPCREGOFFS(gpiopulldown), 0);
@@ -617,15 +516,13 @@ static struct si_info *ai_doattach(struct si_info *sii, · 6 unmodified lines
617516 }
618517
619518 /* setup the GPIO based LED powersave register */
620− w = getintvar(sih, BRCMS_SROM_LEDDC);
519+ w = (sprom->leddc_on_time << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
520+ (sprom->leddc_off_time << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT);
621521 if (w == 0)
622522 w = DEFAULT_GPIOTIMERVAL;
623523 ai_cc_reg(sih, offsetof(struct chipcregs, gpiotimerval),
624524 ~0, w);
625525
626− if (PCIE(sih))
627− pcicore_attach(sii->pch, SI_DOATTACH);
628−
629526 if (ai_get_chip_id(sih) == BCM43224_CHIP_ID) {
630527 /*
631528 * enable 12 mA drive strenth for 43224 and
@@ -659,9 +556,6 @@ static struct si_info *ai_doattach(struct si_info *sii, · 27 unmodified lines
659556 return sii;
660557
661558 exit:
662− if (sii->pch)
663− pcicore_deinit(sii->pch);
664− sii->pch = NULL;
665559
666560 return NULL;
667561 }
@@ -700,11 +594,6 @@ void ai_detach(struct si_pub *sih) · 32 unmodified lines
700594 if (sii == NULL)
701595 return;
702596
703− if (sii->pch)
704− pcicore_deinit(sii->pch);
705− sii->pch = NULL;
706−
707− srom_free_vars(sih);
708597 kfree(sii);
709598 }
710599
@@ -755,21 +644,7 @@ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val) · 44 unmodified lines
755644 /* return the slow clock source - LPO, XTAL, or PCI */
756645 static uint ai_slowclk_src(struct si_pub *sih, struct bcma_device *cc)
757646 {
758− struct si_info *sii;
759− u32 val;
760−
761− sii = (struct si_info *)sih;
762− if (ai_get_ccrev(&sii->pub) < 6) {
763− pci_read_config_dword(sii->pcibus, PCI_GPIO_OUT,
764− &val);
765− if (val & PCI_CFG_GPIO_SCS)
766− return SCC_SS_PCI;
767− return SCC_SS_XTAL;
768− } else if (ai_get_ccrev(&sii->pub) < 10) {
769− return bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl)) &
770− SCC_SS_MASK;
771− } else /* Insta-clock */
772− return SCC_SS_XTAL;
647+ return SCC_SS_XTAL;
773648 }
774649
775650 /*
@@ -779,36 +654,12 @@ static uint ai_slowclk_src(struct si_pub *sih, struct bcma_device *cc) · 3 unmodified lines
779654 static uint ai_slowclk_freq(struct si_pub *sih, bool max_freq,
780655 struct bcma_device *cc)
781656 {
782− u32 slowclk;
783657 uint div;
784658
785− slowclk = ai_slowclk_src(sih, cc);
786− if (ai_get_ccrev(sih) < 6) {
787− if (slowclk == SCC_SS_PCI)
788− return max_freq ? (PCIMAXFREQ / 64)
789− : (PCIMINFREQ / 64);
790− else
791− return max_freq ? (XTALMAXFREQ / 32)
792− : (XTALMINFREQ / 32);
793− } else if (ai_get_ccrev(sih) < 10) {
794− div = 4 *
795− (((bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl)) &
796− SCC_CD_MASK) >> SCC_CD_SHIFT) + 1);
797− if (slowclk == SCC_SS_LPO)
798− return max_freq ? LPOMAXFREQ : LPOMINFREQ;
799− else if (slowclk == SCC_SS_XTAL)
800− return max_freq ? (XTALMAXFREQ / div)
801− : (XTALMINFREQ / div);
802− else if (slowclk == SCC_SS_PCI)
803− return max_freq ? (PCIMAXFREQ / div)
804− : (PCIMINFREQ / div);
805− } else {
806− /* Chipc rev 10 is InstaClock */
807− div = bcma_read32(cc, CHIPCREGOFFS(system_clk_ctl));
808− div = 4 * ((div >> SYCC_CD_SHIFT) + 1);
809− return max_freq ? XTALMAXFREQ : (XTALMINFREQ / div);
810− }
811− return 0;
659+ /* Chipc rev 10 is InstaClock */
660+ div = bcma_read32(cc, CHIPCREGOFFS(system_clk_ctl));
661+ div = 4 * ((div >> SYCC_CD_SHIFT) + 1);
662+ return max_freq ? XTALMAXFREQ : (XTALMINFREQ / div);
812663 }
813664
814665 static void
@@ -831,8 +682,7 @@ ai_clkctl_setdelay(struct si_pub *sih, struct bcma_device *cc) · 16 unmodified lines
831682
832683 /* Starting with 4318 it is ILP that is used for the delays */
833684 slowmaxfreq =
834− ai_slowclk_freq(sih,
835− (ai_get_ccrev(sih) >= 10) ? false : true, cc);
685+ ai_slowclk_freq(sih, false, cc);
836686
837687 pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000;
838688 fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000;
@@ -854,9 +704,8 @@ void ai_clkctl_init(struct si_pub *sih) · 15 unmodified lines
854704 return;
855705
856706 /* set all Instaclk chip ILP to 1 MHz */
857− if (ai_get_ccrev(sih) >= 10)
858− bcma_maskset32(cc, CHIPCREGOFFS(system_clk_ctl), SYCC_CD_MASK,
859− (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
707+ bcma_maskset32(cc, CHIPCREGOFFS(system_clk_ctl), SYCC_CD_MASK,
708+ (ILP_DIV_1MHZ << SYCC_CD_SHIFT));
860709
861710 ai_clkctl_setdelay(sih, cc);
862711 }
@@ -891,140 +740,6 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) · 28 unmodified lines
891740 return fpdelay;
892741 }
893742
894−/* turn primary xtal and/or pll off/on */
895−int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on)
896−{
897− struct si_info *sii;
898− u32 in, out, outen;
899−
900− sii = (struct si_info *)sih;
901−
902− /* pcie core doesn't have any mapping to control the xtal pu */
903− if (PCIE(sih))
904− return -1;
905−
906− pci_read_config_dword(sii->pcibus, PCI_GPIO_IN, &in);
907− pci_read_config_dword(sii->pcibus, PCI_GPIO_OUT, &out);
908− pci_read_config_dword(sii->pcibus, PCI_GPIO_OUTEN, &outen);
909−
910− /*
911− * Avoid glitching the clock if GPRS is already using it.
912− * We can't actually read the state of the PLLPD so we infer it
913− * by the value of XTAL_PU which *is* readable via gpioin.
914− */
915− if (on && (in & PCI_CFG_GPIO_XTAL))
916− return 0;
917−
918− if (what & XTAL)
919− outen |= PCI_CFG_GPIO_XTAL;
920− if (what & PLL)
921− outen |= PCI_CFG_GPIO_PLL;
922−
923− if (on) {
924− /* turn primary xtal on */
925− if (what & XTAL) {
926− out |= PCI_CFG_GPIO_XTAL;
927− if (what & PLL)
928− out |= PCI_CFG_GPIO_PLL;
929− pci_write_config_dword(sii->pcibus,
930− PCI_GPIO_OUT, out);
931− pci_write_config_dword(sii->pcibus,
932− PCI_GPIO_OUTEN, outen);
933− udelay(XTAL_ON_DELAY);
934− }
935−
936− /* turn pll on */
937− if (what & PLL) {
938− out &= ~PCI_CFG_GPIO_PLL;
939− pci_write_config_dword(sii->pcibus,
940− PCI_GPIO_OUT, out);
941− mdelay(2);
942− }
943− } else {
944− if (what & XTAL)
945− out &= ~PCI_CFG_GPIO_XTAL;
946− if (what & PLL)
947− out |= PCI_CFG_GPIO_PLL;
948− pci_write_config_dword(sii->pcibus,
949− PCI_GPIO_OUT, out);
950− pci_write_config_dword(sii->pcibus,
951− PCI_GPIO_OUTEN, outen);
952− }
953−
954− return 0;
955−}
956−
957−/* clk control mechanism through chipcommon, no policy checking */
958−static bool _ai_clkctl_cc(struct si_info *sii, uint mode)
959−{
960− struct bcma_device *cc;
961− u32 scc;
962−
963− /* chipcommon cores prior to rev6 don't support dynamic clock control */
964− if (ai_get_ccrev(&sii->pub) < 6)
965− return false;
966−
967− cc = ai_findcore(&sii->pub, BCMA_CORE_CHIPCOMMON, 0);
968−
969− if (!(ai_get_cccaps(&sii->pub) & CC_CAP_PWR_CTL) &&
970− (ai_get_ccrev(&sii->pub) < 20))
971− return mode == CLK_FAST;
972−
973− switch (mode) {
974− case CLK_FAST: /* FORCEHT, fast (pll) clock */
975− if (ai_get_ccrev(&sii->pub) < 10) {
976− /*
977− * don't forget to force xtal back
978− * on before we clear SCC_DYN_XTAL..
979− */
980− ai_clkctl_xtal(&sii->pub, XTAL, ON);
981− bcma_maskset32(cc, CHIPCREGOFFS(slow_clk_ctl),
982− (SCC_XC | SCC_FS | SCC_IP), SCC_IP);
983− } else if (ai_get_ccrev(&sii->pub) < 20) {
984− bcma_set32(cc, CHIPCREGOFFS(system_clk_ctl), SYCC_HR);
985− } else {
986− bcma_set32(cc, CHIPCREGOFFS(clk_ctl_st), CCS_FORCEHT);
987− }
988−
989− /* wait for the PLL */
990− if (ai_get_cccaps(&sii->pub) & CC_CAP_PMU) {
991− u32 htavail = CCS_HTAVAIL;
992− SPINWAIT(((bcma_read32(cc, CHIPCREGOFFS(clk_ctl_st)) &
993− htavail) == 0), PMU_MAX_TRANSITION_DLY);
994− } else {
995− udelay(PLL_DELAY);
996− }
997− break;
998−
999− case CLK_DYNAMIC: /* enable dynamic clock control */
1000− if (ai_get_ccrev(&sii->pub) < 10) {
1001− scc = bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl));
1002− scc &= ~(SCC_FS | SCC_IP | SCC_XC);
1003− if ((scc & SCC_SS_MASK) != SCC_SS_XTAL)
1004− scc |= SCC_XC;
1005− bcma_write32(cc, CHIPCREGOFFS(slow_clk_ctl), scc);
1006−
1007− /*
1008− * for dynamic control, we have to
1009− * release our xtal_pu "force on"
1010− */
1011− if (scc & SCC_XC)
1012− ai_clkctl_xtal(&sii->pub, XTAL, OFF);
1013− } else if (ai_get_ccrev(&sii->pub) < 20) {
1014− /* Instaclock */
1015− bcma_mask32(cc, CHIPCREGOFFS(system_clk_ctl), ~SYCC_HR);
1016− } else {
1017− bcma_mask32(cc, CHIPCREGOFFS(clk_ctl_st), ~CCS_FORCEHT);
1018− }
1019− break;
1020−
1021− default:
1022− break;
1023− }
1024−
1025− return mode == CLK_FAST;
1026−}
1027−
1028743 /*
1029744 * clock control policy function throught chipcommon
1030745 *
@@ -1033,133 +748,53 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) · 2 unmodified lines
1033748 * this is a wrapper over the next internal function
1034749 * to allow flexible policy settings for outside caller
1035750 */
1036−bool ai_clkctl_cc(struct si_pub *sih, uint mode)
751+bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode)
1037752 {
1038753 struct si_info *sii;
754+ struct bcma_device *cc;
1039755
1040756 sii = (struct si_info *)sih;
1041757
1042− /* chipcommon cores prior to rev6 don't support dynamic clock control */
1043− if (ai_get_ccrev(sih) < 6)
1044− return false;
1045−
1046758 if (PCI_FORCEHT(sih))
1047− return mode == CLK_FAST;
759+ return mode == BCMA_CLKMODE_FAST;
1048760
1049− return _ai_clkctl_cc(sii, mode);
761+ cc = ai_findcore(&sii->pub, BCMA_CORE_CHIPCOMMON, 0);
762+ bcma_core_set_clockmode(cc, mode);
763+ return mode == BCMA_CLKMODE_FAST;
1050764 }
1051765
1052766 void ai_pci_up(struct si_pub *sih)
1053767 {
1054768 struct si_info *sii;
769+ struct bcma_device *cc;
1055770
1056771 sii = (struct si_info *)sih;
1057772
1058− if (PCI_FORCEHT(sih))
1059− _ai_clkctl_cc(sii, CLK_FAST);
773+ if (PCI_FORCEHT(sih)) {
774+ cc = ai_findcore(&sii->pub, BCMA_CORE_CHIPCOMMON, 0);
775+ bcma_core_set_clockmode(cc, BCMA_CLKMODE_FAST);
776+ }
1060777
1061778 if (PCIE(sih))
1062− pcicore_up(sii->pch, SI_PCIUP);
1063−
1064−}
1065−
1066−/* Unconfigure and/or apply various WARs when system is going to sleep mode */
1067−void ai_pci_sleep(struct si_pub *sih)
1068−{
1069− struct si_info *sii;
1070−
1071− sii = (struct si_info *)sih;
1072−
1073− pcicore_sleep(sii->pch);
779+ bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, true);
1074780 }
1075781
1076782 /* Unconfigure and/or apply various WARs when going down */
1077783 void ai_pci_down(struct si_pub *sih)
1078784 {
1079785 struct si_info *sii;
786+ struct bcma_device *cc;
1080787
1081788 sii = (struct si_info *)sih;
1082789
1083790 /* release FORCEHT since chip is going to "down" state */
1084− if (PCI_FORCEHT(sih))
1085− _ai_clkctl_cc(sii, CLK_DYNAMIC);
1086−
1087− pcicore_down(sii->pch, SI_PCIDOWN);
1088−}
1089−
1090−/*
1091− * Configure the pci core for pci client (NIC) action
1092− * coremask is the bitvec of cores by index to be enabled.
1093− */
1094−void ai_pci_setup(struct si_pub *sih, uint coremask)
1095−{
1096− struct si_info *sii;
1097− u32 w;
1098−
1099− sii = (struct si_info *)sih;
1100−
1101− /*
1102− * Enable sb->pci interrupts. Assume
1103− * PCI rev 2.3 support was added in pci core rev 6 and things changed..
1104− */
1105− if (PCIE(sih) || (PCI(sih) && (ai_get_buscorerev(sih) >= 6))) {
1106− /* pci config write to set this core bit in PCIIntMask */
1107− pci_read_config_dword(sii->pcibus, PCI_INT_MASK, &w);
1108− w |= (coremask << PCI_SBIM_SHIFT);
1109− pci_write_config_dword(sii->pcibus, PCI_INT_MASK, w);
1110− }
1111−
1112− if (PCI(sih)) {
1113− pcicore_pci_setup(sii->pch);
791+ if (PCI_FORCEHT(sih)) {
792+ cc = ai_findcore(&sii->pub, BCMA_CORE_CHIPCOMMON, 0);
793+ bcma_core_set_clockmode(cc, BCMA_CLKMODE_DYNAMIC);
1114794 }
1115−}
1116795
1117−/*
1118− * Fixup SROMless PCI device's configuration.
1119− * The current core may be changed upon return.
1120− */
1121−int ai_pci_fixcfg(struct si_pub *sih)
1122−{
1123− struct si_info *sii = (struct si_info *)sih;
1124−
1125− /* Fixup PI in SROM shadow area to enable the correct PCI core access */
1126− /* check 'pi' is correct and fix it if not */
1127− pcicore_fixcfg(sii->pch);
1128− pcicore_hwup(sii->pch);
1129− return 0;
1130−}
1131−
1132−/* mask&set gpiocontrol bits */
1133−u32 ai_gpiocontrol(struct si_pub *sih, u32 mask, u32 val, u8 priority)
1134−{
1135− uint regoff;
1136−
1137− regoff = offsetof(struct chipcregs, gpiocontrol);
1138− return ai_cc_reg(sih, regoff, mask, val);
1139−}
1140−
1141−void ai_chipcontrl_epa4331(struct si_pub *sih, bool on)
1142−{
1143− struct bcma_device *cc;
1144− u32 val;
1145−
1146− cc = ai_findcore(sih, CC_CORE_ID, 0);
1147−
1148− if (on) {
1149− if (ai_get_chippkg(sih) == 9 || ai_get_chippkg(sih) == 0xb)
1150− /* Ext PA Controls for 4331 12x9 Package */
1151− bcma_set32(cc, CHIPCREGOFFS(chipcontrol),
1152− CCTRL4331_EXTPA_EN |
1153− CCTRL4331_EXTPA_ON_GPIO2_5);
1154− else
1155− /* Ext PA Controls for 4331 12x12 Package */
1156− bcma_set32(cc, CHIPCREGOFFS(chipcontrol),
1157− CCTRL4331_EXTPA_EN);
1158− } else {
1159− val &= ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5);
1160− bcma_mask32(cc, CHIPCREGOFFS(chipcontrol),
1161− ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5));
1162− }
796+ if (PCIE(sih))
797+ bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, false);
1163798 }
1164799
1165800 /* Enable BT-COEX & Ex-PA for 4313 */
@@ -1181,6 +816,9 @@ bool ai_deviceremoved(struct si_pub *sih) · 15 unmodified lines
1181816
1182817 sii = (struct si_info *)sih;
1183818
819+ if (sii->icbus->hosttype != BCMA_HOSTTYPE_PCI)
820+ return false;
821+
1184822 pci_read_config_dword(sii->pcibus, PCI_VENDOR_ID, &w);
1185823 if ((w & 0xFFFF) != PCI_VENDOR_ID_BROADCOM)
1186824 return true;
@@ -1188,45 +826,6 @@ bool ai_deviceremoved(struct si_pub *sih) · 1 unmodified line
1188826 return false;
1189827 }
1190828
1191−bool ai_is_sprom_available(struct si_pub *sih)
1192−{
1193− struct si_info *sii = (struct si_info *)sih;
1194−
1195− if (ai_get_ccrev(sih) >= 31) {
1196− struct bcma_device *cc;
1197− u32 sromctrl;
1198−
1199− if ((ai_get_cccaps(sih) & CC_CAP_SROM) == 0)
1200− return false;
1201−
1202− cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);
1203− sromctrl = bcma_read32(cc, CHIPCREGOFFS(sromcontrol));
1204− return sromctrl & SRC_PRESENT;
1205− }
1206−
1207− switch (ai_get_chip_id(sih)) {
1208− case BCM4313_CHIP_ID:
1209− return (sii->chipst & CST4313_SPROM_PRESENT) != 0;
1210− default:
1211− return true;
1212− }
1213−}
1214−
1215−bool ai_is_otp_disabled(struct si_pub *sih)
1216−{
1217− struct si_info *sii = (struct si_info *)sih;
1218−
1219− switch (ai_get_chip_id(sih)) {
1220− case BCM4313_CHIP_ID:
1221− return (sii->chipst & CST4313_OTP_PRESENT) == 0;
1222− /* These chips always have their OTP on */
1223− case BCM43224_CHIP_ID:
1224− case BCM43225_CHIP_ID:
1225− default:
1226− return false;
1227− }
1228−}
1229−
1230829 uint ai_get_buscoretype(struct si_pub *sih)
1231830 {
1232831 struct si_info *sii = (struct si_info *)sih;
drivers/net/wireless/brcm80211/brcmsmac/aiutils.h+0−24
@@ -113,10 +113,6 @@ · 112 unmodified lines
113113 #define XTAL 0x1 /* primary crystal oscillator (2050) */
114114 #define PLL 0x2 /* main chip pll */
115115
116−/* clkctl clk mode */
117−#define CLK_FAST 0 /* force fast (pll) clock */
118−#define CLK_DYNAMIC 2 /* enable dynamic clock control */
119−
120116 /* GPIO usage priorities */
121117 #define GPIO_DRV_PRIORITY 0 /* Driver */
122118 #define GPIO_APP_PRIORITY 1 /* Application */
@@ -172,9 +168,7 @@ struct si_info { · 49 unmodified lines
172168 struct si_pub pub; /* back plane public state (must be first) */
173169 struct bcma_bus *icbus; /* handle to soc interconnect bus */
174170 struct pci_dev *pcibus; /* handle to pci bus */
175− struct pcicore_info *pch; /* PCI/E core handle */
176171 struct bcma_device *buscore;
177− struct list_head var_list; /* list of srom variables */
178172
179173 u32 chipst; /* chip status */
180174 };
@@ -197,38 +191,20 @@ extern u32 ai_core_cflags(struct bcma_device *core, u32 mask, u32 val); · 16 unmodified lines
197191 extern struct si_pub *ai_attach(struct bcma_bus *pbus);
198192 extern void ai_detach(struct si_pub *sih);
199193 extern uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val);
200−extern void ai_pci_setup(struct si_pub *sih, uint coremask);
201194 extern void ai_clkctl_init(struct si_pub *sih);
202195 extern u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih);
203196 extern bool ai_clkctl_cc(struct si_pub *sih, uint mode);
204−extern int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on);
205197 extern bool ai_deviceremoved(struct si_pub *sih);
206−extern u32 ai_gpiocontrol(struct si_pub *sih, u32 mask, u32 val,
207− u8 priority);
208−
209−/* OTP status */
210−extern bool ai_is_otp_disabled(struct si_pub *sih);
211−
212−/* SPROM availability */
213−extern bool ai_is_sprom_available(struct si_pub *sih);
214198
215−extern void ai_pci_sleep(struct si_pub *sih);
216199 extern void ai_pci_down(struct si_pub *sih);
217200 extern void ai_pci_up(struct si_pub *sih);
218−extern int ai_pci_fixcfg(struct si_pub *sih);
219201
220−extern void ai_chipcontrl_epa4331(struct si_pub *sih, bool on);
221202 /* Enable Ex-PA for 4313 */
222203 extern void ai_epa_4313war(struct si_pub *sih);
223204
224205 extern uint ai_get_buscoretype(struct si_pub *sih);
225206 extern uint ai_get_buscorerev(struct si_pub *sih);
226207
227−static inline int ai_get_ccrev(struct si_pub *sih)
228−{
229− return sih->ccrev;
230−}
231−
232208 static inline u32 ai_get_cccaps(struct si_pub *sih)
233209 {
234210 return sih->cccaps;
drivers/net/wireless/brcm80211/brcmsmac/antsel.c+8−8
@@ -108,7 +108,7 @@ brcms_c_antsel_init_cfg(struct antsel_info *asi, struct brcms_antselcfg *antsel, · 107 unmodified lines
108108 struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc)
109109 {
110110 struct antsel_info *asi;
111− struct si_pub *sih = wlc->hw->sih;
111+ struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom;
112112
113113 asi = kzalloc(sizeof(struct antsel_info), GFP_ATOMIC);
114114 if (!asi)
@@ -118,7 +118,7 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) · 3 unmodified lines
118118 asi->pub = wlc->pub;
119119 asi->antsel_type = ANTSEL_NA;
120120 asi->antsel_avail = false;
121− asi->antsel_antswitch = (u8) getintvar(sih, BRCMS_SROM_ANTSWITCH);
121+ asi->antsel_antswitch = sprom->antswitch;
122122
123123 if ((asi->pub->sromrev >= 4) && (asi->antsel_antswitch != 0)) {
124124 switch (asi->antsel_antswitch) {
@@ -128,12 +128,12 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) · 3 unmodified lines
128128 /* 4321/2 board with 2x3 switch logic */
129129 asi->antsel_type = ANTSEL_2x3;
130130 /* Antenna selection availability */
131− if (((u16) getintvar(sih, BRCMS_SROM_AA2G) == 7) ||
132− ((u16) getintvar(sih, BRCMS_SROM_AA5G) == 7)) {
131+ if ((sprom->ant_available_bg == 7) ||
132+ (sprom->ant_available_a == 7)) {
133133 asi->antsel_avail = true;
134134 } else if (
135− (u16) getintvar(sih, BRCMS_SROM_AA2G) == 3 ||
136− (u16) getintvar(sih, BRCMS_SROM_AA5G) == 3) {
135+ sprom->ant_available_bg == 3 ||
136+ sprom->ant_available_a == 3) {
137137 asi->antsel_avail = false;
138138 } else {
139139 asi->antsel_avail = false;
@@ -146,8 +146,8 @@ struct antsel_info *brcms_c_antsel_attach(struct brcms_c_info *wlc) · 6 unmodified lines
146146 break;
147147 }
148148 } else if ((asi->pub->sromrev == 4) &&
149− ((u16) getintvar(sih, BRCMS_SROM_AA2G) == 7) &&
150− ((u16) getintvar(sih, BRCMS_SROM_AA5G) == 0)) {
149+ (sprom->ant_available_bg == 7) &&
150+ (sprom->ant_available_a == 0)) {
151151 /* hack to match old 4321CB2 cards with 2of3 antenna switch */
152152 asi->antsel_type = ANTSEL_2x3;
153153 asi->antsel_avail = true;
drivers/net/wireless/brcm80211/brcmsmac/channel.c+3−4
@@ -1110,7 +1110,7 @@ struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc) · 1109 unmodified lines
11101110 char country_abbrev[BRCM_CNTRY_BUF_SZ];
11111111 const struct country_info *country;
11121112 struct brcms_pub *pub = wlc->pub;
1113− char *ccode;
1113+ struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom;
11141114
11151115 BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
11161116
@@ -1122,9 +1122,8 @@ struct brcms_cm_info *brcms_c_channel_mgr_attach(struct brcms_c_info *wlc) · 5 unmodified lines
11221122 wlc->cmi = wlc_cm;
11231123
11241124 /* store the country code for passing up as a regulatory hint */
1125− ccode = getvar(wlc->hw->sih, BRCMS_SROM_CCODE);
1126− if (ccode && brcms_c_country_valid(ccode))
1127− strncpy(wlc->pub->srom_ccode, ccode, BRCM_CNTRY_BUF_SZ - 1);
1125+ if (sprom->alpha2 && brcms_c_country_valid(sprom->alpha2))
1126+ strncpy(wlc->pub->srom_ccode, sprom->alpha2, sizeof(sprom->alpha2));
11281127
11291128 /*
11301129 * internal country information which must match
drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c+5−6
@@ -25,7 +25,6 @@ · 24 unmodified lines
2525 #include <linux/bcma/bcma.h>
2626 #include <net/mac80211.h>
2727 #include <defs.h>
28−#include "nicpci.h"
2928 #include "phy/phy_int.h"
3029 #include "d11.h"
3130 #include "channel.h"
@@ -770,7 +769,7 @@ void brcms_dpc(unsigned long data) · 738 unmodified lines
770769 * Precondition: Since this function is called in brcms_pci_probe() context,
771770 * no locking is required.
772771 */
773−static int brcms_request_fw(struct brcms_info *wl, struct pci_dev *pdev)
772+static int brcms_request_fw(struct brcms_info *wl, struct bcma_device *pdev)
774773 {
775774 int status;
776775 struct device *device = &pdev->dev;
@@ -1022,7 +1021,7 @@ static struct brcms_info *brcms_attach(struct bcma_device *pdev) · 245 unmodified lines
10221021 spin_lock_init(&wl->isr_lock);
10231022
10241023 /* prepare ucode */
1025− if (brcms_request_fw(wl, pdev->bus->host_pci) < 0) {
1024+ if (brcms_request_fw(wl, pdev) < 0) {
10261025 wiphy_err(wl->wiphy, "%s: Failed to find firmware usually in "
10271026 "%s\n", KBUILD_MODNAME, "/lib/firmware/brcm");
10281027 brcms_release_fw(wl);
@@ -1043,12 +1042,12 @@ static struct brcms_info *brcms_attach(struct bcma_device *pdev) · 14 unmodified lines
10431042 wl->pub->ieee_hw = hw;
10441043
10451044 /* register our interrupt handler */
1046− if (request_irq(pdev->bus->host_pci->irq, brcms_isr,
1045+ if (request_irq(pdev->irq, brcms_isr,
10471046 IRQF_SHARED, KBUILD_MODNAME, wl)) {
10481047 wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit);
10491048 goto fail;
10501049 }
1051− wl->irq = pdev->bus->host_pci->irq;
1050+ wl->irq = pdev->irq;
10521051
10531052 /* register module */
10541053 brcms_c_module_register(wl->pub, "linux", wl, NULL);
@@ -1098,7 +1097,7 @@ static int __devinit brcms_bcma_probe(struct bcma_device *pdev) · 43 unmodified lines
10981097
10991098 dev_info(&pdev->dev, "mfg %x core %x rev %d class %d irq %d\n",
11001099 pdev->id.manuf, pdev->id.id, pdev->id.rev, pdev->id.class,
1101− pdev->bus->host_pci->irq);
1100+ pdev->irq);
11021101
11031102 if ((pdev->id.manuf != BCMA_MANUF_BCM) ||
11041103 (pdev->id.id != BCMA_CORE_80211))
drivers/net/wireless/brcm80211/brcmsmac/main.c+60−82
@@ -1219,7 +1219,7 @@ static void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) · 1218 unmodified lines
12191219 }
12201220
12211221 /* control chip clock to save power, enable dynamic clock or force fast clock */
1222−static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode)
1222+static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, enum bcma_clkmode mode)
12231223 {
12241224 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) {
12251225 /* new chips with PMU, CCS_FORCEHT will distribute the HT clock
@@ -1229,7 +1229,7 @@ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) · 3 unmodified lines
12291229 */
12301230
12311231 if (wlc_hw->clk) {
1232− if (mode == CLK_FAST) {
1232+ if (mode == BCMA_CLKMODE_FAST) {
12331233 bcma_set32(wlc_hw->d11core,
12341234 D11REGOFFS(clk_ctl_st),
12351235 CCS_FORCEHT);
@@ -1260,7 +1260,7 @@ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) · 24 unmodified lines
12601260 ~CCS_FORCEHT);
12611261 }
12621262 }
1263− wlc_hw->forcefastclk = (mode == CLK_FAST);
1263+ wlc_hw->forcefastclk = (mode == BCMA_CLKMODE_FAST);
12641264 } else {
12651265
12661266 /* old chips w/o PMU, force HT through cc,
@@ -1567,7 +1567,7 @@ void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw) · 300 unmodified lines
15671567 /* request FAST clock if not on */
15681568 fastclk = wlc_hw->forcefastclk;
15691569 if (!fastclk)
1570− brcms_b_clkctl_clk(wlc_hw, CLK_FAST);
1570+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST);
15711571
15721572 wlc_phy_bw_state_set(wlc_hw->band->pi, bw);
15731573
@@ -1576,7 +1576,7 @@ void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw) · 2 unmodified lines
15761576
15771577 /* restore the clk */
15781578 if (!fastclk)
1579− brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC);
1579+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_DYNAMIC);
15801580 }
15811581
15821582 static void brcms_b_upd_synthpu(struct brcms_hardware *wlc_hw)
@@ -1882,27 +1882,20 @@ static bool brcms_c_validboardtype(struct brcms_hardware *wlc_hw) · 299 unmodified lines
18821882 return true;
18831883 }
18841884
1885−static char *brcms_c_get_macaddr(struct brcms_hardware *wlc_hw)
1885+static void brcms_c_get_macaddr(struct brcms_hardware *wlc_hw, u8 etheraddr[ETH_ALEN])
18861886 {
1887− enum brcms_srom_id var_id = BRCMS_SROM_MACADDR;
1888− char *macaddr;
1887+ struct ssb_sprom *sprom = &wlc_hw->d11core->bus->sprom;
18891888
18901889 /* If macaddr exists, use it (Sromrev4, CIS, ...). */
1891− macaddr = getvar(wlc_hw->sih, var_id);
1892− if (macaddr != NULL)
1893− return macaddr;
1890+ if (!is_zero_ether_addr(sprom->il0mac)) {
1891+ memcpy(etheraddr, sprom->il0mac, 6);
1892+ return;
1893+ }
18941894
18951895 if (wlc_hw->_nbands > 1)
1896− var_id = BRCMS_SROM_ET1MACADDR;
1896+ memcpy(etheraddr, sprom->et1mac, 6);
18971897 else
1898− var_id = BRCMS_SROM_IL0MACADDR;
1899−
1900− macaddr = getvar(wlc_hw->sih, var_id);
1901− if (macaddr == NULL)
1902− wiphy_err(wlc_hw->wlc->wiphy, "wl%d: wlc_get_macaddr: macaddr "
1903− "getvar(%d) not found\n", wlc_hw->unit, var_id);
1904−
1905− return macaddr;
1898+ memcpy(etheraddr, sprom->il0mac, 6);
19061899 }
19071900
19081901 /* power both the pll and external oscillator on/off */
@@ -1917,9 +1910,6 @@ static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) · 8 unmodified lines
19171910 if (!want && wlc_hw->pllreq)
19181911 return;
19191912
1920− if (wlc_hw->sih)
1921− ai_clkctl_xtal(wlc_hw->sih, XTAL | PLL, want);
1922−
19231913 wlc_hw->sbclk = want;
19241914 if (!wlc_hw->sbclk) {
19251915 wlc_hw->clk = false;
@@ -2004,7 +1994,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) · 78 unmodified lines
20041994 /* request FAST clock if not on */
20051995 fastclk = wlc_hw->forcefastclk;
20061996 if (!fastclk)
2007− brcms_b_clkctl_clk(wlc_hw, CLK_FAST);
1997+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST);
20081998
20091999 /* reset the dma engines except first time thru */
20102000 if (bcma_core_is_enabled(wlc_hw->d11core)) {
@@ -2053,7 +2043,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) · 42 unmodified lines
20532043 brcms_c_mctrl_reset(wlc_hw);
20542044
20552045 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU)
2056− brcms_b_clkctl_clk(wlc_hw, CLK_FAST);
2046+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST);
20572047
20582048 brcms_b_phy_reset(wlc_hw);
20592049
@@ -2065,7 +2055,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) · 5 unmodified lines
20652055
20662056 /* restore the clk setting */
20672057 if (!fastclk)
2068− brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC);
2058+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_DYNAMIC);
20692059 }
20702060
20712061 /* txfifo sizes needs to be modified(increased) since the newer cores
@@ -2218,7 +2208,7 @@ static void brcms_c_gpio_init(struct brcms_c_info *wlc) · 146 unmodified lines
22182208 gm |= gc |= BOARD_GPIO_PACTRL;
22192209
22202210 /* apply to gpiocontrol register */
2221− ai_gpiocontrol(wlc_hw->sih, gm, gc, GPIO_DRV_PRIORITY);
2211+ bcma_chipco_gpio_control(&wlc_hw->d11core->bus->drv_cc, gm, gc);
22222212 }
22232213
22242214 static void brcms_ucode_write(struct brcms_hardware *wlc_hw,
@@ -3371,7 +3361,7 @@ static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec) { · 1146 unmodified lines
33713361 /* request FAST clock if not on */
33723362 fastclk = wlc_hw->forcefastclk;
33733363 if (!fastclk)
3374− brcms_b_clkctl_clk(wlc_hw, CLK_FAST);
3364+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST);
33753365
33763366 /* disable interrupts */
33773367 macintmask = brcms_intrsoff(wlc->wl);
@@ -3405,7 +3395,7 @@ static brcms_b_init(struct brcms_hardware *wlc_hw, u16 chanspec) { · 27 unmodified lines
34053395
34063396 /* restore the clk */
34073397 if (!fastclk)
3408− brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC);
3398+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_DYNAMIC);
34093399 }
34103400
34113401 static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc,
@@ -4436,17 +4426,22 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, · 1024 unmodified lines
44364426 uint unit, bool piomode)
44374427 {
44384428 struct brcms_hardware *wlc_hw;
4439− char *macaddr = NULL;
44404429 uint err = 0;
44414430 uint j;
44424431 bool wme = false;
44434432 struct shared_phy_params sha_params;
44444433 struct wiphy *wiphy = wlc->wiphy;
44454434 struct pci_dev *pcidev = core->bus->host_pci;
4435+ struct ssb_sprom *sprom = &core->bus->sprom;
44464436
4447− BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit,
4448− pcidev->vendor,
4449− pcidev->device);
4437+ if (core->bus->hosttype == BCMA_HOSTTYPE_PCI)
4438+ BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit,
4439+ pcidev->vendor,
4440+ pcidev->device);
4441+ else
4442+ BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit,
4443+ core->bus->boardinfo.vendor,
4444+ core->bus->boardinfo.type);
44504445
44514446 wme = true;
44524447
@@ -4472,7 +4467,8 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, · 19 unmodified lines
44724467 }
44734468
44744469 /* verify again the device is supported */
4475− if (!brcms_c_chipmatch(pcidev->vendor, pcidev->device)) {
4470+ if (core->bus->hosttype == BCMA_HOSTTYPE_PCI &&
4471+ !brcms_c_chipmatch(pcidev->vendor, pcidev->device)) {
44764472 wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported "
44774473 "vendor/device (0x%x/0x%x)\n",
44784474 unit, pcidev->vendor, pcidev->device);
@@ -4480,8 +4476,13 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, · 1 unmodified line
44804476 goto fail;
44814477 }
44824478
4483− wlc_hw->vendorid = pcidev->vendor;
4484− wlc_hw->deviceid = pcidev->device;
4479+ if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) {
4480+ wlc_hw->vendorid = pcidev->vendor;
4481+ wlc_hw->deviceid = pcidev->device;
4482+ } else {
4483+ wlc_hw->vendorid = core->bus->boardinfo.vendor;
4484+ wlc_hw->deviceid = core->bus->boardinfo.type;
4485+ }
44854486
44864487 wlc_hw->d11core = core;
44874488 wlc_hw->corerev = core->id.rev;
@@ -4501,7 +4502,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, · 13 unmodified lines
45014502 * is still false; But it will be called again inside wlc_corereset,
45024503 * after d11 is out of reset.
45034504 */
4504− brcms_b_clkctl_clk(wlc_hw, CLK_FAST);
4505+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST);
45054506 brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS);
45064507
45074508 if (!brcms_b_validate_chip_access(wlc_hw)) {
@@ -4512,7 +4513,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, · 4 unmodified lines
45124513 }
45134514
45144515 /* get the board rev, used just below */
4515− j = getintvar(wlc_hw->sih, BRCMS_SROM_BOARDREV);
4516+ j = sprom->board_rev;
45164517 /* promote srom boardrev of 0xFF to 1 */
45174518 if (j == BOARDREV_PROMOTABLE)
45184519 j = BOARDREV_PROMOTED;
@@ -4525,11 +4526,9 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, · 6 unmodified lines
45254526 err = 15;
45264527 goto fail;
45274528 }
4528− wlc_hw->sromrev = (u8) getintvar(wlc_hw->sih, BRCMS_SROM_REV);
4529− wlc_hw->boardflags = (u32) getintvar(wlc_hw->sih,
4530− BRCMS_SROM_BOARDFLAGS);
4531− wlc_hw->boardflags2 = (u32) getintvar(wlc_hw->sih,
4532− BRCMS_SROM_BOARDFLAGS2);
4529+ wlc_hw->sromrev = sprom->revision;
4530+ wlc_hw->boardflags = sprom->boardflags_lo + (sprom->boardflags_hi << 16);
4531+ wlc_hw->boardflags2 = sprom->boardflags2_lo + (sprom->boardflags2_hi << 16);
45334532
45344533 if (wlc_hw->boardflags & BFL_NOPLLDOWN)
45354534 brcms_b_pllreq(wlc_hw, true, BRCMS_PLLREQ_SHARED);
@@ -4702,25 +4701,18 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, · 166 unmodified lines
47024701 */
47034702
47044703 /* init etheraddr state variables */
4705− macaddr = brcms_c_get_macaddr(wlc_hw);
4706− if (macaddr == NULL) {
4707− wiphy_err(wiphy, "wl%d: brcms_b_attach: macaddr not found\n",
4708− unit);
4709− err = 21;
4710− goto fail;
4711− }
4712− if (!mac_pton(macaddr, wlc_hw->etheraddr) ||
4713− is_broadcast_ether_addr(wlc_hw->etheraddr) ||
4704+ brcms_c_get_macaddr(wlc_hw, wlc_hw->etheraddr);
4705+
4706+ if (is_broadcast_ether_addr(wlc_hw->etheraddr) ||
47144707 is_zero_ether_addr(wlc_hw->etheraddr)) {
4715− wiphy_err(wiphy, "wl%d: brcms_b_attach: bad macaddr %s\n",
4716− unit, macaddr);
4708+ wiphy_err(wiphy, "wl%d: brcms_b_attach: bad macaddr\n",
4709+ unit);
47174710 err = 22;
47184711 goto fail;
47194712 }
47204713
4721− BCMMSG(wlc->wiphy, "deviceid 0x%x nbands %d board 0x%x macaddr: %s\n",
4722− wlc_hw->deviceid, wlc_hw->_nbands, ai_get_boardtype(wlc_hw->sih),
4723− macaddr);
4714+ BCMMSG(wlc->wiphy, "deviceid 0x%x nbands %d board 0x%x\n",
4715+ wlc_hw->deviceid, wlc_hw->_nbands, ai_get_boardtype(wlc_hw->sih));
47244716
47254717 return err;
47264718
@@ -4770,16 +4762,16 @@ static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) · 43 unmodified lines
47704762 int aa;
47714763 uint unit;
47724764 int bandtype;
4773− struct si_pub *sih = wlc->hw->sih;
4765+ struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom;
47744766
47754767 unit = wlc->pub->unit;
47764768 bandtype = wlc->band->bandtype;
47774769
47784770 /* get antennas available */
47794771 if (bandtype == BRCM_BAND_5G)
4780− aa = (s8) getintvar(sih, BRCMS_SROM_AA5G);
4772+ aa = sprom->ant_available_a;
47814773 else
4782− aa = (s8) getintvar(sih, BRCMS_SROM_AA2G);
4774+ aa = sprom->ant_available_bg;
47834775
47844776 if ((aa < 1) || (aa > 15)) {
47854777 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in"
@@ -4799,9 +4791,9 @@ static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) · 13 unmodified lines
47994791
48004792 /* Compute Antenna Gain */
48014793 if (bandtype == BRCM_BAND_5G)
4802− wlc->band->antgain = (s8) getintvar(sih, BRCMS_SROM_AG1);
4794+ wlc->band->antgain = sprom->antenna_gain.a1;
48034795 else
4804− wlc->band->antgain = (s8) getintvar(sih, BRCMS_SROM_AG0);
4796+ wlc->band->antgain = sprom->antenna_gain.a0;
48054797
48064798 brcms_c_attach_antgain_init(wlc);
48074799
@@ -4952,15 +4944,6 @@ static int brcms_b_detach(struct brcms_c_info *wlc) · 144 unmodified lines
49524944
49534945 callbacks = 0;
49544946
4955− if (wlc_hw->sih) {
4956− /*
4957− * detach interrupt sync mechanism since interrupt is disabled
4958− * and per-port interrupt object may has been freed. this must
4959− * be done before sb core switch
4960− */
4961− ai_pci_sleep(wlc_hw->sih);
4962− }
4963−
49644947 brcms_b_detach_dmapio(wlc_hw);
49654948
49664949 band = wlc_hw->band;
@@ -5047,9 +5030,7 @@ static void brcms_b_hw_up(struct brcms_hardware *wlc_hw) · 80 unmodified lines
50475030 */
50485031 brcms_b_xtal(wlc_hw, ON);
50495032 ai_clkctl_init(wlc_hw->sih);
5050− brcms_b_clkctl_clk(wlc_hw, CLK_FAST);
5051−
5052− ai_pci_fixcfg(wlc_hw->sih);
5033+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST);
50535034
50545035 /*
50555036 * TODO: test suspend/resume
@@ -5078,8 +5059,6 @@ static void brcms_b_hw_up(struct brcms_hardware *wlc_hw) · 22 unmodified lines
50785059
50795060 static int brcms_b_up_prep(struct brcms_hardware *wlc_hw)
50805061 {
5081− uint coremask;
5082−
50835062 BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
50845063
50855064 /*
@@ -5088,15 +5067,14 @@ static int brcms_b_up_prep(struct brcms_hardware *wlc_hw) · 2 unmodified lines
50885067 */
50895068 brcms_b_xtal(wlc_hw, ON);
50905069 ai_clkctl_init(wlc_hw->sih);
5091− brcms_b_clkctl_clk(wlc_hw, CLK_FAST);
5070+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST);
50925071
50935072 /*
50945073 * Configure pci/pcmcia here instead of in brcms_c_attach()
50955074 * to allow mfg hotswap: down, hotswap (chip power cycle), up.
50965075 */
5097− coremask = (1 << wlc_hw->wlc->core->coreidx);
5098−
5099− ai_pci_setup(wlc_hw->sih, coremask);
5076+ bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci, wlc_hw->d11core,
5077+ true);
51005078
51015079 /*
51025080 * Need to read the hwradio status here to cover the case where the
@@ -5126,7 +5104,7 @@ static int brcms_b_up_finish(struct brcms_hardware *wlc_hw) · 23 unmodified lines
51265104 wlc_phy_hw_state_upd(wlc_hw->band->pi, true);
51275105
51285106 /* FULLY enable dynamic power control and d11 core interrupt */
5129− brcms_b_clkctl_clk(wlc_hw, CLK_DYNAMIC);
5107+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_DYNAMIC);
51305108 brcms_intrson(wlc_hw->wlc->wl);
51315109 return 0;
51325110 }
@@ -5267,7 +5245,7 @@ static int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) · 134 unmodified lines
52675245 brcms_intrsoff(wlc_hw->wlc->wl);
52685246
52695247 /* ensure we're running on the pll clock again */
5270− brcms_b_clkctl_clk(wlc_hw, CLK_FAST);
5248+ brcms_b_clkctl_clk(wlc_hw, BCMA_CLKMODE_FAST);
52715249 }
52725250 /* down phy at the last of this stage */
52735251 callbacks += wlc_phy_down(wlc_hw->band->pi);
drivers/net/wireless/brcm80211/brcmsmac/nicpci.c+0−826
@@ -1,826 +0,0 @@
1−/*
2− * Copyright (c) 2010 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−#include <linux/slab.h>
18−#include <linux/delay.h>
19−#include <linux/pci.h>
20−
21−#include <defs.h>
22−#include <soc.h>
23−#include <chipcommon.h>
24−#include "aiutils.h"
25−#include "pub.h"
26−#include "nicpci.h"
27−
28−/* SPROM offsets */
29−#define SRSH_ASPM_OFFSET 4 /* word 4 */
30−#define SRSH_ASPM_ENB 0x18 /* bit 3, 4 */
31−#define SRSH_ASPM_L1_ENB 0x10 /* bit 4 */
32−#define SRSH_ASPM_L0s_ENB 0x8 /* bit 3 */
33−
34−#define SRSH_PCIE_MISC_CONFIG 5 /* word 5 */
35−#define SRSH_L23READY_EXIT_NOPERST 0x8000 /* bit 15 */
36−#define SRSH_CLKREQ_OFFSET_REV5 20 /* word 20 for srom rev <= 5 */
37−#define SRSH_CLKREQ_ENB 0x0800 /* bit 11 */
38−#define SRSH_BD_OFFSET 6 /* word 6 */
39−
40−/* chipcontrol */
41−#define CHIPCTRL_4321_PLL_DOWN 0x800000/* serdes PLL down override */
42−
43−/* MDIO control */
44−#define MDIOCTL_DIVISOR_MASK 0x7f /* clock to be used on MDIO */
45−#define MDIOCTL_DIVISOR_VAL 0x2
46−#define MDIOCTL_PREAM_EN 0x80 /* Enable preamble sequnce */
47−#define MDIOCTL_ACCESS_DONE 0x100 /* Transaction complete */
48−
49−/* MDIO Data */
50−#define MDIODATA_MASK 0x0000ffff /* data 2 bytes */
51−#define MDIODATA_TA 0x00020000 /* Turnaround */
52−
53−#define MDIODATA_REGADDR_SHF 18 /* Regaddr shift */
54−#define MDIODATA_REGADDR_MASK 0x007c0000 /* Regaddr Mask */
55−#define MDIODATA_DEVADDR_SHF 23 /* Physmedia devaddr shift */
56−#define MDIODATA_DEVADDR_MASK 0x0f800000
57− /* Physmedia devaddr Mask */
58−
59−/* MDIO Data for older revisions < 10 */
60−#define MDIODATA_REGADDR_SHF_OLD 18 /* Regaddr shift */
61−#define MDIODATA_REGADDR_MASK_OLD 0x003c0000
62− /* Regaddr Mask */
63−#define MDIODATA_DEVADDR_SHF_OLD 22 /* Physmedia devaddr shift */
64−#define MDIODATA_DEVADDR_MASK_OLD 0x0fc00000
65− /* Physmedia devaddr Mask */
66−
67−/* Transactions flags */
68−#define MDIODATA_WRITE 0x10000000
69−#define MDIODATA_READ 0x20000000
70−#define MDIODATA_START 0x40000000
71−
72−#define MDIODATA_DEV_ADDR 0x0 /* dev address for serdes */
73−#define MDIODATA_BLK_ADDR 0x1F /* blk address for serdes */
74−
75−/* serdes regs (rev < 10) */
76−#define MDIODATA_DEV_PLL 0x1d /* SERDES PLL Dev */
77−#define MDIODATA_DEV_TX 0x1e /* SERDES TX Dev */
78−#define MDIODATA_DEV_RX 0x1f /* SERDES RX Dev */
79−
80−/* SERDES RX registers */
81−#define SERDES_RX_CTRL 1 /* Rx cntrl */
82−#define SERDES_RX_TIMER1 2 /* Rx Timer1 */
83−#define SERDES_RX_CDR 6 /* CDR */
84−#define SERDES_RX_CDRBW 7 /* CDR BW */
85−/* SERDES RX control register */
86−#define SERDES_RX_CTRL_FORCE 0x80 /* rxpolarity_force */
87−#define SERDES_RX_CTRL_POLARITY 0x40 /* rxpolarity_value */
88−
89−/* SERDES PLL registers */
90−#define SERDES_PLL_CTRL 1 /* PLL control reg */
91−#define PLL_CTRL_FREQDET_EN 0x4000 /* bit 14 is FREQDET on */
92−
93−/* Linkcontrol reg offset in PCIE Cap */
94−#define PCIE_CAP_LINKCTRL_OFFSET 16 /* offset in pcie cap */
95−#define PCIE_CAP_LCREG_ASPML0s 0x01 /* ASPM L0s in linkctrl */
96−#define PCIE_CAP_LCREG_ASPML1 0x02 /* ASPM L1 in linkctrl */
97−#define PCIE_CLKREQ_ENAB 0x100 /* CLKREQ Enab in linkctrl */
98−
99−#define PCIE_ASPM_ENAB 3 /* ASPM L0s & L1 in linkctrl */
100−#define PCIE_ASPM_L1_ENAB 2 /* ASPM L0s & L1 in linkctrl */
101−#define PCIE_ASPM_L0s_ENAB 1 /* ASPM L0s & L1 in linkctrl */
102−#define PCIE_ASPM_DISAB 0 /* ASPM L0s & L1 in linkctrl */
103−
104−/* Power management threshold */
105−#define PCIE_L1THRESHOLDTIME_MASK 0xFF00 /* bits 8 - 15 */
106−#define PCIE_L1THRESHOLDTIME_SHIFT 8 /* PCIE_L1THRESHOLDTIME_SHIFT */
107−#define PCIE_L1THRESHOLD_WARVAL 0x72 /* WAR value */
108−#define PCIE_ASPMTIMER_EXTEND 0x01000000
109− /* > rev7:
110− * enable extend ASPM timer
111− */
112−
113−/* different register spaces to access thru pcie indirect access */
114−#define PCIE_CONFIGREGS 1 /* Access to config space */
115−#define PCIE_PCIEREGS 2 /* Access to pcie registers */
116−
117−/* PCIE protocol PHY diagnostic registers */
118−#define PCIE_PLP_STATUSREG 0x204 /* Status */
119−
120−/* Status reg PCIE_PLP_STATUSREG */
121−#define PCIE_PLP_POLARITYINV_STAT 0x10
122−
123−/* PCIE protocol DLLP diagnostic registers */
124−#define PCIE_DLLP_LCREG 0x100 /* Link Control */
125−#define PCIE_DLLP_PMTHRESHREG 0x128 /* Power Management Threshold */
126−
127−/* PCIE protocol TLP diagnostic registers */
128−#define PCIE_TLP_WORKAROUNDSREG 0x004 /* TLP Workarounds */
129−
130−/* Sonics to PCI translation types */
131−#define SBTOPCI_PREF 0x4 /* prefetch enable */
132−#define SBTOPCI_BURST 0x8 /* burst enable */
133−#define SBTOPCI_RC_READMULTI 0x20 /* memory read multiple */
134−
135−#define PCI_CLKRUN_DSBL 0x8000 /* Bit 15 forceClkrun */
136−
137−/* PCI core index in SROM shadow area */
138−#define SRSH_PI_OFFSET 0 /* first word */
139−#define SRSH_PI_MASK 0xf000 /* bit 15:12 */
140−#define SRSH_PI_SHIFT 12 /* bit 15:12 */
141−
142−#define PCIREGOFFS(field) offsetof(struct sbpciregs, field)
143−#define PCIEREGOFFS(field) offsetof(struct sbpcieregs, field)
144−
145−/* Sonics side: PCI core and host control registers */
146−struct sbpciregs {
147− u32 control; /* PCI control */
148− u32 PAD[3];
149− u32 arbcontrol; /* PCI arbiter control */
150− u32 clkrun; /* Clkrun Control (>=rev11) */
151− u32 PAD[2];
152− u32 intstatus; /* Interrupt status */
153− u32 intmask; /* Interrupt mask */
154− u32 sbtopcimailbox; /* Sonics to PCI mailbox */
155− u32 PAD[9];
156− u32 bcastaddr; /* Sonics broadcast address */
157− u32 bcastdata; /* Sonics broadcast data */
158− u32 PAD[2];
159− u32 gpioin; /* ro: gpio input (>=rev2) */
160− u32 gpioout; /* rw: gpio output (>=rev2) */
161− u32 gpioouten; /* rw: gpio output enable (>= rev2) */
162− u32 gpiocontrol; /* rw: gpio control (>= rev2) */
163− u32 PAD[36];
164− u32 sbtopci0; /* Sonics to PCI translation 0 */
165− u32 sbtopci1; /* Sonics to PCI translation 1 */
166− u32 sbtopci2; /* Sonics to PCI translation 2 */
167− u32 PAD[189];
168− u32 pcicfg[4][64]; /* 0x400 - 0x7FF, PCI Cfg Space (>=rev8) */
169− u16 sprom[36]; /* SPROM shadow Area */
170− u32 PAD[46];
171−};
172−
173−/* SB side: PCIE core and host control registers */
174−struct sbpcieregs {
175− u32 control; /* host mode only */
176− u32 PAD[2];
177− u32 biststatus; /* bist Status: 0x00C */
178− u32 gpiosel; /* PCIE gpio sel: 0x010 */
179− u32 gpioouten; /* PCIE gpio outen: 0x14 */
180− u32 PAD[2];
181− u32 intstatus; /* Interrupt status: 0x20 */
182− u32 intmask; /* Interrupt mask: 0x24 */
183− u32 sbtopcimailbox; /* sb to pcie mailbox: 0x028 */
184− u32 PAD[53];
185− u32 sbtopcie0; /* sb to pcie translation 0: 0x100 */
186− u32 sbtopcie1; /* sb to pcie translation 1: 0x104 */
187− u32 sbtopcie2; /* sb to pcie translation 2: 0x108 */
188− u32 PAD[5];
189−
190− /* pcie core supports in direct access to config space */
191− u32 configaddr; /* pcie config space access: Address field: 0x120 */
192− u32 configdata; /* pcie config space access: Data field: 0x124 */
193−
194− /* mdio access to serdes */
195− u32 mdiocontrol; /* controls the mdio access: 0x128 */
196− u32 mdiodata; /* Data to the mdio access: 0x12c */
197−
198− /* pcie protocol phy/dllp/tlp register indirect access mechanism */
199− u32 pcieindaddr; /* indirect access to
200− * the internal register: 0x130
201− */
202− u32 pcieinddata; /* Data to/from the internal regsiter: 0x134 */
203−
204− u32 clkreqenctrl; /* >= rev 6, Clkreq rdma control : 0x138 */
205− u32 PAD[177];
206− u32 pciecfg[4][64]; /* 0x400 - 0x7FF, PCIE Cfg Space */
207− u16 sprom[64]; /* SPROM shadow Area */
208−};
209−
210−struct pcicore_info {
211− struct bcma_device *core;
212− struct si_pub *sih; /* System interconnect handle */
213− struct pci_dev *dev;
214− u8 pciecap_lcreg_offset;/* PCIE capability LCreg offset
215− * in the config space
216− */
217− bool pcie_pr42767;
218− u8 pcie_polarity;
219− u8 pcie_war_aspm_ovr; /* Override ASPM/Clkreq settings */
220−
221− u8 pmecap_offset; /* PM Capability offset in the config space */
222− bool pmecap; /* Capable of generating PME */
223−};
224−
225−#define PCIE_ASPM(sih) \
226− ((ai_get_buscoretype(sih) == PCIE_CORE_ID) && \
227− ((ai_get_buscorerev(sih) >= 3) && \
228− (ai_get_buscorerev(sih) <= 5)))
229−
230−
231−/* delay needed between the mdio control/ mdiodata register data access */
232−static void pr28829_delay(void)
233−{
234− udelay(10);
235−}
236−
237−/* Initialize the PCI core.
238− * It's caller's responsibility to make sure that this is done only once
239− */
240−struct pcicore_info *pcicore_init(struct si_pub *sih, struct bcma_device *core)
241−{
242− struct pcicore_info *pi;
243−
244− /* alloc struct pcicore_info */
245− pi = kzalloc(sizeof(struct pcicore_info), GFP_ATOMIC);
246− if (pi == NULL)
247− return NULL;
248−
249− pi->sih = sih;
250− pi->dev = core->bus->host_pci;
251− pi->core = core;
252−
253− if (core->id.id == PCIE_CORE_ID) {
254− u8 cap_ptr;
255− cap_ptr = pcicore_find_pci_capability(pi->dev, PCI_CAP_ID_EXP,
256− NULL, NULL);
257− pi->pciecap_lcreg_offset = cap_ptr + PCIE_CAP_LINKCTRL_OFFSET;
258− }
259− return pi;
260−}
261−
262−void pcicore_deinit(struct pcicore_info *pch)
263−{
264− kfree(pch);
265−}
266−
267−/* return cap_offset if requested capability exists in the PCI config space */
268−/* Note that it's caller's responsibility to make sure it's a pci bus */
269−u8
270−pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id,
271− unsigned char *buf, u32 *buflen)
272−{
273− u8 cap_id;
274− u8 cap_ptr = 0;
275− u32 bufsize;
276− u8 byte_val;
277−
278− /* check for Header type 0 */
279− pci_read_config_byte(dev, PCI_HEADER_TYPE, &byte_val);
280− if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
281− goto end;
282−
283− /* check if the capability pointer field exists */
284− pci_read_config_byte(dev, PCI_STATUS, &byte_val);
285− if (!(byte_val & PCI_STATUS_CAP_LIST))
286− goto end;
287−
288− pci_read_config_byte(dev, PCI_CAPABILITY_LIST, &cap_ptr);
289− /* check if the capability pointer is 0x00 */
290− if (cap_ptr == 0x00)
291− goto end;
292−
293− /* loop thru the capability list
294− * and see if the pcie capability exists
295− */
296−
297− pci_read_config_byte(dev, cap_ptr, &cap_id);
298−
299− while (cap_id != req_cap_id) {
300− pci_read_config_byte(dev, cap_ptr + 1, &cap_ptr);
301− if (cap_ptr == 0x00)
302− break;
303− pci_read_config_byte(dev, cap_ptr, &cap_id);
304− }
305− if (cap_id != req_cap_id)
306− goto end;
307−
308− /* found the caller requested capability */
309− if (buf != NULL && buflen != NULL) {
310− u8 cap_data;
311−
312− bufsize = *buflen;
313− if (!bufsize)
314− goto end;
315− *buflen = 0;
316− /* copy the capability data excluding cap ID and next ptr */
317− cap_data = cap_ptr + 2;
318− if ((bufsize + cap_data) > PCI_SZPCR)
319− bufsize = PCI_SZPCR - cap_data;
320− *buflen = bufsize;
321− while (bufsize--) {
322− pci_read_config_byte(dev, cap_data, buf);
323− cap_data++;
324− buf++;
325− }
326− }
327−end:
328− return cap_ptr;
329−}
330−
331−/* ***** Register Access API */
332−static uint
333−pcie_readreg(struct bcma_device *core, uint addrtype, uint offset)
334−{
335− uint retval = 0xFFFFFFFF;
336−
337− switch (addrtype) {
338− case PCIE_CONFIGREGS:
339− bcma_write32(core, PCIEREGOFFS(configaddr), offset);
340− (void)bcma_read32(core, PCIEREGOFFS(configaddr));
341− retval = bcma_read32(core, PCIEREGOFFS(configdata));
342− break;
343− case PCIE_PCIEREGS:
344− bcma_write32(core, PCIEREGOFFS(pcieindaddr), offset);
345− (void)bcma_read32(core, PCIEREGOFFS(pcieindaddr));
346− retval = bcma_read32(core, PCIEREGOFFS(pcieinddata));
347− break;
348− }
349−
350− return retval;
351−}
352−
353−static uint pcie_writereg(struct bcma_device *core, uint addrtype,
354− uint offset, uint val)
355−{
356− switch (addrtype) {
357− case PCIE_CONFIGREGS:
358− bcma_write32(core, PCIEREGOFFS(configaddr), offset);
359− bcma_write32(core, PCIEREGOFFS(configdata), val);
360− break;
361− case PCIE_PCIEREGS:
362− bcma_write32(core, PCIEREGOFFS(pcieindaddr), offset);
363− bcma_write32(core, PCIEREGOFFS(pcieinddata), val);
364− break;
365− default:
366− break;
367− }
368− return 0;
369−}
370−
371−static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk)
372−{
373− uint mdiodata, i = 0;
374− uint pcie_serdes_spinwait = 200;
375−
376− mdiodata = (MDIODATA_START | MDIODATA_WRITE | MDIODATA_TA |
377− (MDIODATA_DEV_ADDR << MDIODATA_DEVADDR_SHF) |
378− (MDIODATA_BLK_ADDR << MDIODATA_REGADDR_SHF) |
379− (blk << 4));
380− bcma_write32(pi->core, PCIEREGOFFS(mdiodata), mdiodata);
381−
382− pr28829_delay();
383− /* retry till the transaction is complete */
384− while (i < pcie_serdes_spinwait) {
385− if (bcma_read32(pi->core, PCIEREGOFFS(mdiocontrol)) &
386− MDIOCTL_ACCESS_DONE)
387− break;
388−
389− udelay(1000);
390− i++;
391− }
392−
393− if (i >= pcie_serdes_spinwait)
394− return false;
395−
396− return true;
397−}
398−
399−static int
400−pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write,
401− uint *val)
402−{
403− uint mdiodata;
404− uint i = 0;
405− uint pcie_serdes_spinwait = 10;
406−
407− /* enable mdio access to SERDES */
408− bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol),
409− MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL);
410−
411− if (ai_get_buscorerev(pi->sih) >= 10) {
412− /* new serdes is slower in rw,
413− * using two layers of reg address mapping
414− */
415− if (!pcie_mdiosetblock(pi, physmedia))
416− return 1;
417− mdiodata = ((MDIODATA_DEV_ADDR << MDIODATA_DEVADDR_SHF) |
418− (regaddr << MDIODATA_REGADDR_SHF));
419− pcie_serdes_spinwait *= 20;
420− } else {
421− mdiodata = ((physmedia << MDIODATA_DEVADDR_SHF_OLD) |
422− (regaddr << MDIODATA_REGADDR_SHF_OLD));
423− }
424−
425− if (!write)
426− mdiodata |= (MDIODATA_START | MDIODATA_READ | MDIODATA_TA);
427− else
428− mdiodata |= (MDIODATA_START | MDIODATA_WRITE | MDIODATA_TA |
429− *val);
430−
431− bcma_write32(pi->core, PCIEREGOFFS(mdiodata), mdiodata);
432−
433− pr28829_delay();
434−
435− /* retry till the transaction is complete */
436− while (i < pcie_serdes_spinwait) {
437− if (bcma_read32(pi->core, PCIEREGOFFS(mdiocontrol)) &
438− MDIOCTL_ACCESS_DONE) {
439− if (!write) {
440− pr28829_delay();
441− *val = (bcma_read32(pi->core,
442− PCIEREGOFFS(mdiodata)) &
443− MDIODATA_MASK);
444− }
445− /* Disable mdio access to SERDES */
446− bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol), 0);
447− return 0;
448− }
449− udelay(1000);
450− i++;
451− }
452−
453− /* Timed out. Disable mdio access to SERDES. */
454− bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol), 0);
455− return 1;
456−}
457−
458−/* use the mdio interface to read from mdio slaves */
459−static int
460−pcie_mdioread(struct pcicore_info *pi, uint physmedia, uint regaddr,
461− uint *regval)
462−{
463− return pcie_mdioop(pi, physmedia, regaddr, false, regval);
464−}
465−
466−/* use the mdio interface to write to mdio slaves */
467−static int
468−pcie_mdiowrite(struct pcicore_info *pi, uint physmedia, uint regaddr, uint val)
469−{
470− return pcie_mdioop(pi, physmedia, regaddr, true, &val);
471−}
472−
473−/* ***** Support functions ***** */
474−static u8 pcie_clkreq(struct pcicore_info *pi, u32 mask, u32 val)
475−{
476− u32 reg_val;
477− u8 offset;
478−
479− offset = pi->pciecap_lcreg_offset;
480− if (!offset)
481− return 0;
482−
483− pci_read_config_dword(pi->dev, offset, &reg_val);
484− /* set operation */
485− if (mask) {
486− if (val)
487− reg_val |= PCIE_CLKREQ_ENAB;
488− else
489− reg_val &= ~PCIE_CLKREQ_ENAB;
490− pci_write_config_dword(pi->dev, offset, reg_val);
491− pci_read_config_dword(pi->dev, offset, &reg_val);
492− }
493− if (reg_val & PCIE_CLKREQ_ENAB)
494− return 1;
495− else
496− return 0;
497−}
498−
499−static void pcie_extendL1timer(struct pcicore_info *pi, bool extend)
500−{
501− u32 w;
502− struct si_pub *sih = pi->sih;
503−
504− if (ai_get_buscoretype(sih) != PCIE_CORE_ID ||
505− ai_get_buscorerev(sih) < 7)
506− return;
507−
508− w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG);
509− if (extend)
510− w |= PCIE_ASPMTIMER_EXTEND;
511− else
512− w &= ~PCIE_ASPMTIMER_EXTEND;
513− pcie_writereg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG, w);
514− w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG);
515−}
516−
517−/* centralized clkreq control policy */
518−static void pcie_clkreq_upd(struct pcicore_info *pi, uint state)
519−{
520− struct si_pub *sih = pi->sih;
521−
522− switch (state) {
523− case SI_DOATTACH:
524− if (PCIE_ASPM(sih))
525− pcie_clkreq(pi, 1, 0);
526− break;
527− case SI_PCIDOWN:
528− /* turn on serdes PLL down */
529− if (ai_get_buscorerev(sih) == 6) {
530− ai_cc_reg(sih,
531− offsetof(struct chipcregs, chipcontrol_addr),
532− ~0, 0);
533− ai_cc_reg(sih,
534− offsetof(struct chipcregs, chipcontrol_data),
535− ~0x40, 0);
536− } else if (pi->pcie_pr42767) {
537− pcie_clkreq(pi, 1, 1);
538− }
539− break;
540− case SI_PCIUP:
541− /* turn off serdes PLL down */
542− if (ai_get_buscorerev(sih) == 6) {
543− ai_cc_reg(sih,
544− offsetof(struct chipcregs, chipcontrol_addr),
545− ~0, 0);
546− ai_cc_reg(sih,
547− offsetof(struct chipcregs, chipcontrol_data),
548− ~0x40, 0x40);
549− } else if (PCIE_ASPM(sih)) { /* disable clkreq */
550− pcie_clkreq(pi, 1, 0);
551− }
552− break;
553− }
554−}
555−
556−/* ***** PCI core WARs ***** */
557−/* Done only once at attach time */
558−static void pcie_war_polarity(struct pcicore_info *pi)
559−{
560− u32 w;
561−
562− if (pi->pcie_polarity != 0)
563− return;
564−
565− w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_PLP_STATUSREG);
566−
567− /* Detect the current polarity at attach and force that polarity and
568− * disable changing the polarity
569− */
570− if ((w & PCIE_PLP_POLARITYINV_STAT) == 0)
571− pi->pcie_polarity = SERDES_RX_CTRL_FORCE;
572− else
573− pi->pcie_polarity = (SERDES_RX_CTRL_FORCE |
574− SERDES_RX_CTRL_POLARITY);
575−}
576−
577−/* enable ASPM and CLKREQ if srom doesn't have it */
578−/* Needs to happen when update to shadow SROM is needed
579− * : Coming out of 'standby'/'hibernate'
580− * : If pcie_war_aspm_ovr state changed
581− */
582−static void pcie_war_aspm_clkreq(struct pcicore_info *pi)
583−{
584− struct si_pub *sih = pi->sih;
585− u16 val16;
586− u32 w;
587−
588− if (!PCIE_ASPM(sih))
589− return;
590−
591− /* bypass this on QT or VSIM */
592− val16 = bcma_read16(pi->core, PCIEREGOFFS(sprom[SRSH_ASPM_OFFSET]));
593−
594− val16 &= ~SRSH_ASPM_ENB;
595− if (pi->pcie_war_aspm_ovr == PCIE_ASPM_ENAB)
596− val16 |= SRSH_ASPM_ENB;
597− else if (pi->pcie_war_aspm_ovr == PCIE_ASPM_L1_ENAB)
598− val16 |= SRSH_ASPM_L1_ENB;
599− else if (pi->pcie_war_aspm_ovr == PCIE_ASPM_L0s_ENAB)
600− val16 |= SRSH_ASPM_L0s_ENB;
601−
602− bcma_write16(pi->core, PCIEREGOFFS(sprom[SRSH_ASPM_OFFSET]), val16);
603−
604− pci_read_config_dword(pi->dev, pi->pciecap_lcreg_offset, &w);
605− w &= ~PCIE_ASPM_ENAB;
606− w |= pi->pcie_war_aspm_ovr;
607− pci_write_config_dword(pi->dev, pi->pciecap_lcreg_offset, w);
608−
609− val16 = bcma_read16(pi->core,
610− PCIEREGOFFS(sprom[SRSH_CLKREQ_OFFSET_REV5]));
611−
612− if (pi->pcie_war_aspm_ovr != PCIE_ASPM_DISAB) {
613− val16 |= SRSH_CLKREQ_ENB;
614− pi->pcie_pr42767 = true;
615− } else
616− val16 &= ~SRSH_CLKREQ_ENB;
617−
618− bcma_write16(pi->core, PCIEREGOFFS(sprom[SRSH_CLKREQ_OFFSET_REV5]),
619− val16);
620−}
621−
622−/* Apply the polarity determined at the start */
623−/* Needs to happen when coming out of 'standby'/'hibernate' */
624−static void pcie_war_serdes(struct pcicore_info *pi)
625−{
626− u32 w = 0;
627−
628− if (pi->pcie_polarity != 0)
629− pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CTRL,
630− pi->pcie_polarity);
631−
632− pcie_mdioread(pi, MDIODATA_DEV_PLL, SERDES_PLL_CTRL, &w);
633− if (w & PLL_CTRL_FREQDET_EN) {
634− w &= ~PLL_CTRL_FREQDET_EN;
635− pcie_mdiowrite(pi, MDIODATA_DEV_PLL, SERDES_PLL_CTRL, w);
636− }
637−}
638−
639−/* Fix MISC config to allow coming out of L2/L3-Ready state w/o PRST */
640−/* Needs to happen when coming out of 'standby'/'hibernate' */
641−static void pcie_misc_config_fixup(struct pcicore_info *pi)
642−{
643− u16 val16;
644−
645− val16 = bcma_read16(pi->core,
646− PCIEREGOFFS(sprom[SRSH_PCIE_MISC_CONFIG]));
647−
648− if ((val16 & SRSH_L23READY_EXIT_NOPERST) == 0) {
649− val16 |= SRSH_L23READY_EXIT_NOPERST;
650− bcma_write16(pi->core,
651− PCIEREGOFFS(sprom[SRSH_PCIE_MISC_CONFIG]), val16);
652− }
653−}
654−
655−/* quick hack for testing */
656−/* Needs to happen when coming out of 'standby'/'hibernate' */
657−static void pcie_war_noplldown(struct pcicore_info *pi)
658−{
659− /* turn off serdes PLL down */
660− ai_cc_reg(pi->sih, offsetof(struct chipcregs, chipcontrol),
661− CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN);
662−
663− /* clear srom shadow backdoor */
664− bcma_write16(pi->core, PCIEREGOFFS(sprom[SRSH_BD_OFFSET]), 0);
665−}
666−
667−/* Needs to happen when coming out of 'standby'/'hibernate' */
668−static void pcie_war_pci_setup(struct pcicore_info *pi)
669−{
670− struct si_pub *sih = pi->sih;
671− u32 w;
672−
673− if (ai_get_buscorerev(sih) == 0 || ai_get_buscorerev(sih) == 1) {
674− w = pcie_readreg(pi->core, PCIE_PCIEREGS,
675− PCIE_TLP_WORKAROUNDSREG);
676− w |= 0x8;
677− pcie_writereg(pi->core, PCIE_PCIEREGS,
678− PCIE_TLP_WORKAROUNDSREG, w);
679− }
680−
681− if (ai_get_buscorerev(sih) == 1) {
682− w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_LCREG);
683− w |= 0x40;
684− pcie_writereg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_LCREG, w);
685− }
686−
687− if (ai_get_buscorerev(sih) == 0) {
688− pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_TIMER1, 0x8128);
689− pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CDR, 0x0100);
690− pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466);
691− } else if (PCIE_ASPM(sih)) {
692− /* Change the L1 threshold for better performance */
693− w = pcie_readreg(pi->core, PCIE_PCIEREGS,
694− PCIE_DLLP_PMTHRESHREG);
695− w &= ~PCIE_L1THRESHOLDTIME_MASK;
696− w |= PCIE_L1THRESHOLD_WARVAL << PCIE_L1THRESHOLDTIME_SHIFT;
697− pcie_writereg(pi->core, PCIE_PCIEREGS,
698− PCIE_DLLP_PMTHRESHREG, w);
699−
700− pcie_war_serdes(pi);
701−
702− pcie_war_aspm_clkreq(pi);
703− } else if (ai_get_buscorerev(pi->sih) == 7)
704− pcie_war_noplldown(pi);
705−
706− /* Note that the fix is actually in the SROM,
707− * that's why this is open-ended
708− */
709− if (ai_get_buscorerev(pi->sih) >= 6)
710− pcie_misc_config_fixup(pi);
711−}
712−
713−/* ***** Functions called during driver state changes ***** */
714−void pcicore_attach(struct pcicore_info *pi, int state)
715−{
716− struct si_pub *sih = pi->sih;
717− u32 bfl2 = (u32)getintvar(sih, BRCMS_SROM_BOARDFLAGS2);
718−
719− /* Determine if this board needs override */
720− if (PCIE_ASPM(sih)) {
721− if (bfl2 & BFL2_PCIEWAR_OVR)
722− pi->pcie_war_aspm_ovr = PCIE_ASPM_DISAB;
723− else
724− pi->pcie_war_aspm_ovr = PCIE_ASPM_ENAB;
725− }
726−
727− /* These need to happen in this order only */
728− pcie_war_polarity(pi);
729−
730− pcie_war_serdes(pi);
731−
732− pcie_war_aspm_clkreq(pi);
733−
734− pcie_clkreq_upd(pi, state);
735−
736−}
737−
738−void pcicore_hwup(struct pcicore_info *pi)
739−{
740− if (!pi || ai_get_buscoretype(pi->sih) != PCIE_CORE_ID)
741− return;
742−
743− pcie_war_pci_setup(pi);
744−}
745−
746−void pcicore_up(struct pcicore_info *pi, int state)
747−{
748− if (!pi || ai_get_buscoretype(pi->sih) != PCIE_CORE_ID)
749− return;
750−
751− /* Restore L1 timer for better performance */
752− pcie_extendL1timer(pi, true);
753−
754− pcie_clkreq_upd(pi, state);
755−}
756−
757−/* When the device is going to enter D3 state
758− * (or the system is going to enter S3/S4 states)
759− */
760−void pcicore_sleep(struct pcicore_info *pi)
761−{
762− u32 w;
763−
764− if (!pi || !PCIE_ASPM(pi->sih))
765− return;
766−
767− pci_read_config_dword(pi->dev, pi->pciecap_lcreg_offset, &w);
768− w &= ~PCIE_CAP_LCREG_ASPML1;
769− pci_write_config_dword(pi->dev, pi->pciecap_lcreg_offset, w);
770−
771− pi->pcie_pr42767 = false;
772−}
773−
774−void pcicore_down(struct pcicore_info *pi, int state)
775−{
776− if (!pi || ai_get_buscoretype(pi->sih) != PCIE_CORE_ID)
777− return;
778−
779− pcie_clkreq_upd(pi, state);
780−
781− /* Reduce L1 timer for better power savings */
782− pcie_extendL1timer(pi, false);
783−}
784−
785−void pcicore_fixcfg(struct pcicore_info *pi)
786−{
787− struct bcma_device *core = pi->core;
788− u16 val16;
789− uint regoff;
790−
791− switch (pi->core->id.id) {
792− case BCMA_CORE_PCI:
793− regoff = PCIREGOFFS(sprom[SRSH_PI_OFFSET]);
794− break;
795−
796− case BCMA_CORE_PCIE:
797− regoff = PCIEREGOFFS(sprom[SRSH_PI_OFFSET]);
798− break;
799−
800− default:
801− return;
802− }
803−
804− val16 = bcma_read16(pi->core, regoff);
805− if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) !=
806− (u16)core->core_index) {
807− val16 = ((u16)core->core_index << SRSH_PI_SHIFT) |
808− (val16 & ~SRSH_PI_MASK);
809− bcma_write16(pi->core, regoff, val16);
810− }
811−}
812−
813−/* precondition: current core is pci core */
814−void
815−pcicore_pci_setup(struct pcicore_info *pi)
816−{
817− bcma_set32(pi->core, PCIREGOFFS(sbtopci2),
818− SBTOPCI_PREF | SBTOPCI_BURST);
819−
820− if (pi->core->id.rev >= 11) {
821− bcma_set32(pi->core, PCIREGOFFS(sbtopci2),
822− SBTOPCI_RC_READMULTI);
823− bcma_set32(pi->core, PCIREGOFFS(clkrun), PCI_CLKRUN_DSBL);
824− (void)bcma_read32(pi->core, PCIREGOFFS(clkrun));
825− }
826−}
drivers/net/wireless/brcm80211/brcmsmac/nicpci.h+0−77
@@ -1,77 +0,0 @@
1−/*
2− * Copyright (c) 2010 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 _BRCM_NICPCI_H_
18−#define _BRCM_NICPCI_H_
19−
20−#include "types.h"
21−
22−/* PCI configuration address space size */
23−#define PCI_SZPCR 256
24−
25−/* Brcm PCI configuration registers */
26−/* backplane address space accessed by BAR0 */
27−#define PCI_BAR0_WIN 0x80
28−/* sprom property control */
29−#define PCI_SPROM_CONTROL 0x88
30−/* mask of PCI and other cores interrupts */
31−#define PCI_INT_MASK 0x94
32−/* backplane core interrupt mask bits offset */
33−#define PCI_SBIM_SHIFT 8
34−/* backplane address space accessed by second 4KB of BAR0 */
35−#define PCI_BAR0_WIN2 0xac
36−/* pci config space gpio input (>=rev3) */
37−#define PCI_GPIO_IN 0xb0
38−/* pci config space gpio output (>=rev3) */
39−#define PCI_GPIO_OUT 0xb4
40−/* pci config space gpio output enable (>=rev3) */
41−#define PCI_GPIO_OUTEN 0xb8
42−
43−/* bar0 + 4K accesses external sprom */
44−#define PCI_BAR0_SPROM_OFFSET (4 * 1024)
45−/* bar0 + 6K accesses pci core registers */
46−#define PCI_BAR0_PCIREGS_OFFSET (6 * 1024)
47−/*
48− * pci core SB registers are at the end of the
49− * 8KB window, so their address is the "regular"
50− * address plus 4K
51− */
52−#define PCI_BAR0_PCISBR_OFFSET (4 * 1024)
53−/* bar0 window size Match with corerev 13 */
54−#define PCI_BAR0_WINSZ (16 * 1024)
55−/* On pci corerev >= 13 and all pcie, the bar0 is now 16KB and it maps: */
56−/* bar0 + 8K accesses pci/pcie core registers */
57−#define PCI_16KB0_PCIREGS_OFFSET (8 * 1024)
58−/* bar0 + 12K accesses chipc core registers */
59−#define PCI_16KB0_CCREGS_OFFSET (12 * 1024)
60−
61−struct sbpciregs;
62−struct sbpcieregs;
63−
64−extern struct pcicore_info *pcicore_init(struct si_pub *sih,
65− struct bcma_device *core);
66−extern void pcicore_deinit(struct pcicore_info *pch);
67−extern void pcicore_attach(struct pcicore_info *pch, int state);
68−extern void pcicore_hwup(struct pcicore_info *pch);
69−extern void pcicore_up(struct pcicore_info *pch, int state);
70−extern void pcicore_sleep(struct pcicore_info *pch);
71−extern void pcicore_down(struct pcicore_info *pch, int state);
72−extern u8 pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id,
73− unsigned char *buf, u32 *buflen);
74−extern void pcicore_fixcfg(struct pcicore_info *pch);
75−extern void pcicore_pci_setup(struct pcicore_info *pch);
76−
77−#endif /* _BRCM_NICPCI_H_ */
drivers/net/wireless/brcm80211/brcmsmac/otp.c+0−410
@@ -1,410 +0,0 @@
1−/*
2− * Copyright (c) 2010 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−#include <linux/io.h>
18−#include <linux/errno.h>
19−#include <linux/string.h>
20−
21−#include <brcm_hw_ids.h>
22−#include <chipcommon.h>
23−#include "aiutils.h"
24−#include "otp.h"
25−
26−#define OTPS_GUP_MASK 0x00000f00
27−#define OTPS_GUP_SHIFT 8
28−/* h/w subregion is programmed */
29−#define OTPS_GUP_HW 0x00000100
30−/* s/w subregion is programmed */
31−#define OTPS_GUP_SW 0x00000200
32−/* chipid/pkgopt subregion is programmed */
33−#define OTPS_GUP_CI 0x00000400
34−/* fuse subregion is programmed */
35−#define OTPS_GUP_FUSE 0x00000800
36−
37−/* Fields in otpprog in rev >= 21 */
38−#define OTPP_COL_MASK 0x000000ff
39−#define OTPP_COL_SHIFT 0
40−#define OTPP_ROW_MASK 0x0000ff00
41−#define OTPP_ROW_SHIFT 8
42−#define OTPP_OC_MASK 0x0f000000
43−#define OTPP_OC_SHIFT 24
44−#define OTPP_READERR 0x10000000
45−#define OTPP_VALUE_MASK 0x20000000
46−#define OTPP_VALUE_SHIFT 29
47−#define OTPP_START_BUSY 0x80000000
48−#define OTPP_READ 0x40000000
49−
50−/* Opcodes for OTPP_OC field */
51−#define OTPPOC_READ 0
52−#define OTPPOC_BIT_PROG 1
53−#define OTPPOC_VERIFY 3
54−#define OTPPOC_INIT 4
55−#define OTPPOC_SET 5
56−#define OTPPOC_RESET 6
57−#define OTPPOC_OCST 7
58−#define OTPPOC_ROW_LOCK 8
59−#define OTPPOC_PRESCN_TEST 9
60−
61−#define OTPTYPE_IPX(ccrev) ((ccrev) == 21 || (ccrev) >= 23)
62−
63−#define OTPP_TRIES 10000000 /* # of tries for OTPP */
64−
65−#define MAXNUMRDES 9 /* Maximum OTP redundancy entries */
66−
67−/* Fixed size subregions sizes in words */
68−#define OTPGU_CI_SZ 2
69−
70−struct otpinfo;
71−
72−/* OTP function struct */
73−struct otp_fn_s {
74− int (*init)(struct si_pub *sih, struct otpinfo *oi);
75− int (*read_region)(struct otpinfo *oi, int region, u16 *data,
76− uint *wlen);
77−};
78−
79−struct otpinfo {
80− struct bcma_device *core; /* chipc core */
81− const struct otp_fn_s *fn; /* OTP functions */
82− struct si_pub *sih; /* Saved sb handle */
83−
84− /* IPX OTP section */
85− u16 wsize; /* Size of otp in words */
86− u16 rows; /* Geometry */
87− u16 cols; /* Geometry */
88− u32 status; /* Flag bits (lock/prog/rv).
89− * (Reflected only when OTP is power cycled)
90− */
91− u16 hwbase; /* hardware subregion offset */
92− u16 hwlim; /* hardware subregion boundary */
93− u16 swbase; /* software subregion offset */
94− u16 swlim; /* software subregion boundary */
95− u16 fbase; /* fuse subregion offset */
96− u16 flim; /* fuse subregion boundary */
97− int otpgu_base; /* offset to General Use Region */
98−};
99−
100−/* OTP layout */
101−/* CC revs 21, 24 and 27 OTP General Use Region word offset */
102−#define REVA4_OTPGU_BASE 12
103−
104−/* CC revs 23, 25, 26, 28 and above OTP General Use Region word offset */
105−#define REVB8_OTPGU_BASE 20
106−
107−/* CC rev 36 OTP General Use Region word offset */
108−#define REV36_OTPGU_BASE 12
109−
110−/* Subregion word offsets in General Use region */
111−#define OTPGU_HSB_OFF 0
112−#define OTPGU_SFB_OFF 1
113−#define OTPGU_CI_OFF 2
114−#define OTPGU_P_OFF 3
115−#define OTPGU_SROM_OFF 4
116−
117−/* Flag bit offsets in General Use region */
118−#define OTPGU_HWP_OFF 60
119−#define OTPGU_SWP_OFF 61
120−#define OTPGU_CIP_OFF 62
121−#define OTPGU_FUSEP_OFF 63
122−#define OTPGU_CIP_MSK 0x4000
123−#define OTPGU_P_MSK 0xf000
124−#define OTPGU_P_SHIFT (OTPGU_HWP_OFF % 16)
125−
126−/* OTP Size */
127−#define OTP_SZ_FU_324 ((roundup(324, 8))/8) /* 324 bits */
128−#define OTP_SZ_FU_288 (288/8) /* 288 bits */
129−#define OTP_SZ_FU_216 (216/8) /* 216 bits */
130−#define OTP_SZ_FU_72 (72/8) /* 72 bits */
131−#define OTP_SZ_CHECKSUM (16/8) /* 16 bits */
132−#define OTP4315_SWREG_SZ 178 /* 178 bytes */
133−#define OTP_SZ_FU_144 (144/8) /* 144 bits */
134−
135−static u16
136−ipxotp_otpr(struct otpinfo *oi, uint wn)
137−{
138− return bcma_read16(oi->core,
139− CHIPCREGOFFS(sromotp[wn]));
140−}
141−
142−/*
143− * Calculate max HW/SW region byte size by subtracting fuse region
144− * and checksum size, osizew is oi->wsize (OTP size - GU size) in words
145− */
146−static int ipxotp_max_rgnsz(struct si_pub *sih, int osizew)
147−{
148− int ret = 0;
149−
150− switch (ai_get_chip_id(sih)) {
151− case BCM43224_CHIP_ID:
152− case BCM43225_CHIP_ID:
153− ret = osizew * 2 - OTP_SZ_FU_72 - OTP_SZ_CHECKSUM;
154− break;
155− case BCM4313_CHIP_ID:
156− ret = osizew * 2 - OTP_SZ_FU_72 - OTP_SZ_CHECKSUM;
157− break;
158− default:
159− break; /* Don't know about this chip */
160− }
161−
162− return ret;
163−}
164−
165−static void _ipxotp_init(struct otpinfo *oi)
166−{
167− uint k;
168− u32 otpp, st;
169− int ccrev = ai_get_ccrev(oi->sih);
170−
171−
172− /*
173− * record word offset of General Use Region
174− * for various chipcommon revs
175− */
176− if (ccrev == 21 || ccrev == 24
177− || ccrev == 27) {
178− oi->otpgu_base = REVA4_OTPGU_BASE;
179− } else if (ccrev == 36) {
180− /*
181− * OTP size greater than equal to 2KB (128 words),
182− * otpgu_base is similar to rev23
183− */
184− if (oi->wsize >= 128)
185− oi->otpgu_base = REVB8_OTPGU_BASE;
186− else
187− oi->otpgu_base = REV36_OTPGU_BASE;
188− } else if (ccrev == 23 || ccrev >= 25) {
189− oi->otpgu_base = REVB8_OTPGU_BASE;
190− }
191−
192− /* First issue an init command so the status is up to date */
193− otpp =
194− OTPP_START_BUSY | ((OTPPOC_INIT << OTPP_OC_SHIFT) & OTPP_OC_MASK);
195−
196− bcma_write32(oi->core, CHIPCREGOFFS(otpprog), otpp);
197− st = bcma_read32(oi->core, CHIPCREGOFFS(otpprog));
198− for (k = 0; (st & OTPP_START_BUSY) && (k < OTPP_TRIES); k++)
199− st = bcma_read32(oi->core, CHIPCREGOFFS(otpprog));
200− if (k >= OTPP_TRIES)
201− return;
202−
203− /* Read OTP lock bits and subregion programmed indication bits */
204− oi->status = bcma_read32(oi->core, CHIPCREGOFFS(otpstatus));
205−
206− if ((ai_get_chip_id(oi->sih) == BCM43224_CHIP_ID)
207− || (ai_get_chip_id(oi->sih) == BCM43225_CHIP_ID)) {
208− u32 p_bits;
209− p_bits = (ipxotp_otpr(oi, oi->otpgu_base + OTPGU_P_OFF) &
210− OTPGU_P_MSK) >> OTPGU_P_SHIFT;
211− oi->status |= (p_bits << OTPS_GUP_SHIFT);
212− }
213−
214− /*
215− * h/w region base and fuse region limit are fixed to
216− * the top and the bottom of the general use region.
217− * Everything else can be flexible.
218− */
219− oi->hwbase = oi->otpgu_base + OTPGU_SROM_OFF;
220− oi->hwlim = oi->wsize;
221− if (oi->status & OTPS_GUP_HW) {
222− oi->hwlim =
223− ipxotp_otpr(oi, oi->otpgu_base + OTPGU_HSB_OFF) / 16;
224− oi->swbase = oi->hwlim;
225− } else
226− oi->swbase = oi->hwbase;
227−
228− /* subtract fuse and checksum from beginning */
229− oi->swlim = ipxotp_max_rgnsz(oi->sih, oi->wsize) / 2;
230−
231− if (oi->status & OTPS_GUP_SW) {
232− oi->swlim =
233− ipxotp_otpr(oi, oi->otpgu_base + OTPGU_SFB_OFF) / 16;
234− oi->fbase = oi->swlim;
235− } else
236− oi->fbase = oi->swbase;
237−
238− oi->flim = oi->wsize;
239−}
240−
241−static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi)
242−{
243− /* Make sure we're running IPX OTP */
244− if (!OTPTYPE_IPX(ai_get_ccrev(sih)))
245− return -EBADE;
246−
247− /* Make sure OTP is not disabled */
248− if (ai_is_otp_disabled(sih))
249− return -EBADE;
250−
251− /* Check for otp size */
252− switch ((ai_get_cccaps(sih) & CC_CAP_OTPSIZE) >> CC_CAP_OTPSIZE_SHIFT) {
253− case 0:
254− /* Nothing there */
255− return -EBADE;
256− case 1: /* 32x64 */
257− oi->rows = 32;
258− oi->cols = 64;
259− oi->wsize = 128;
260− break;
261− case 2: /* 64x64 */
262− oi->rows = 64;
263− oi->cols = 64;
264− oi->wsize = 256;
265− break;
266− case 5: /* 96x64 */
267− oi->rows = 96;
268− oi->cols = 64;
269− oi->wsize = 384;
270− break;
271− case 7: /* 16x64 *//* 1024 bits */
272− oi->rows = 16;
273− oi->cols = 64;
274− oi->wsize = 64;
275− break;
276− default:
277− /* Don't know the geometry */
278− return -EBADE;
279− }
280−
281− /* Retrieve OTP region info */
282− _ipxotp_init(oi);
283− return 0;
284−}
285−
286−static int
287−ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen)
288−{
289− uint base, i, sz;
290−
291− /* Validate region selection */
292− switch (region) {
293− case OTP_HW_RGN:
294− sz = (uint) oi->hwlim - oi->hwbase;
295− if (!(oi->status & OTPS_GUP_HW)) {
296− *wlen = sz;
297− return -ENODATA;
298− }
299− if (*wlen < sz) {
300− *wlen = sz;
301− return -EOVERFLOW;
302− }
303− base = oi->hwbase;
304− break;
305− case OTP_SW_RGN:
306− sz = ((uint) oi->swlim - oi->swbase);
307− if (!(oi->status & OTPS_GUP_SW)) {
308− *wlen = sz;
309− return -ENODATA;
310− }
311− if (*wlen < sz) {
312− *wlen = sz;
313− return -EOVERFLOW;
314− }
315− base = oi->swbase;
316− break;
317− case OTP_CI_RGN:
318− sz = OTPGU_CI_SZ;
319− if (!(oi->status & OTPS_GUP_CI)) {
320− *wlen = sz;
321− return -ENODATA;
322− }
323− if (*wlen < sz) {
324− *wlen = sz;
325− return -EOVERFLOW;
326− }
327− base = oi->otpgu_base + OTPGU_CI_OFF;
328− break;
329− case OTP_FUSE_RGN:
330− sz = (uint) oi->flim - oi->fbase;
331− if (!(oi->status & OTPS_GUP_FUSE)) {
332− *wlen = sz;
333− return -ENODATA;
334− }
335− if (*wlen < sz) {
336− *wlen = sz;
337− return -EOVERFLOW;
338− }
339− base = oi->fbase;
340− break;
341− case OTP_ALL_RGN:
342− sz = ((uint) oi->flim - oi->hwbase);
343− if (!(oi->status & (OTPS_GUP_HW | OTPS_GUP_SW))) {
344− *wlen = sz;
345− return -ENODATA;
346− }
347− if (*wlen < sz) {
348− *wlen = sz;
349− return -EOVERFLOW;
350− }
351− base = oi->hwbase;
352− break;
353− default:
354− return -EINVAL;
355− }
356−
357− /* Read the data */
358− for (i = 0; i < sz; i++)
359− data[i] = ipxotp_otpr(oi, base + i);
360−
361− *wlen = sz;
362− return 0;
363−}
364−
365−static const struct otp_fn_s ipxotp_fn = {
366− (int (*)(struct si_pub *, struct otpinfo *)) ipxotp_init,
367− (int (*)(struct otpinfo *, int, u16 *, uint *)) ipxotp_read_region,
368−};
369−
370−static int otp_init(struct si_pub *sih, struct otpinfo *oi)
371−{
372− int ret;
373−
374− memset(oi, 0, sizeof(struct otpinfo));
375−
376− oi->core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);
377−
378− if (OTPTYPE_IPX(ai_get_ccrev(sih)))
379− oi->fn = &ipxotp_fn;
380−
381− if (oi->fn == NULL)
382− return -EBADE;
383−
384− oi->sih = sih;
385−
386− ret = (oi->fn->init)(sih, oi);
387−
388− return ret;
389−}
390−
391−int
392−otp_read_region(struct si_pub *sih, int region, u16 *data, uint *wlen) {
393− struct otpinfo otpinfo;
394− struct otpinfo *oi = &otpinfo;
395− int err = 0;
396−
397− if (ai_is_otp_disabled(sih)) {
398− err = -EPERM;
399− goto out;
400− }
401−
402− err = otp_init(sih, oi);
403− if (err)
404− goto out;
405−
406− err = ((oi)->fn->read_region)(oi, region, data, wlen);
407−
408− out:
409− return err;
410−}
drivers/net/wireless/brcm80211/brcmsmac/otp.h+0−36
@@ -1,36 +0,0 @@
1−/*
2− * Copyright (c) 2010 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 _BRCM_OTP_H_
18−#define _BRCM_OTP_H_
19−
20−#include "types.h"
21−
22−/* OTP regions */
23−#define OTP_HW_RGN 1
24−#define OTP_SW_RGN 2
25−#define OTP_CI_RGN 4
26−#define OTP_FUSE_RGN 8
27−/* From h/w region to end of OTP including checksum */
28−#define OTP_ALL_RGN 0xf
29−
30−/* OTP Size */
31−#define OTP_SZ_MAX (6144/8) /* maximum bytes in one CIS */
32−
33−extern int otp_read_region(struct si_pub *sih, int region, u16 *data,
34− uint *wlen);
35−
36−#endif /* _BRCM_OTP_H_ */
drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c+25−42
@@ -4817,28 +4817,23 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) · 4816 unmodified lines
48174817 s8 txpwr = 0;
48184818 int i;
48194819 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy;
4820− struct phy_shim_info *shim = pi->sh->physhim;
4820+ struct ssb_sprom *sprom = &pi->d11core->bus->sprom;
48214821
48224822 if (CHSPEC_IS2G(pi->radio_chanspec)) {
48234823 u16 cckpo = 0;
48244824 u32 offset_ofdm, offset_mcs;
48254825
4826− pi_lcn->lcnphy_tr_isolation_mid =
4827− (u8)wlapi_getintvar(shim, BRCMS_SROM_TRISO2G);
4826+ pi_lcn->lcnphy_tr_isolation_mid = sprom->fem.ghz2.tr_iso;
48284827
4829− pi_lcn->lcnphy_rx_power_offset =
4830− (u8)wlapi_getintvar(shim, BRCMS_SROM_RXPO2G);
4828+ pi_lcn->lcnphy_rx_power_offset = sprom->rxpo2g;
48314829
4832− pi->txpa_2g[0] = (s16)wlapi_getintvar(shim, BRCMS_SROM_PA0B0);
4833− pi->txpa_2g[1] = (s16)wlapi_getintvar(shim, BRCMS_SROM_PA0B1);
4834− pi->txpa_2g[2] = (s16)wlapi_getintvar(shim, BRCMS_SROM_PA0B2);
4830+ pi->txpa_2g[0] = sprom->pa0b0;
4831+ pi->txpa_2g[1] = sprom->pa0b1;
4832+ pi->txpa_2g[2] = sprom->pa0b2;
48354833
4836− pi_lcn->lcnphy_rssi_vf =
4837− (u8)wlapi_getintvar(shim, BRCMS_SROM_RSSISMF2G);
4838− pi_lcn->lcnphy_rssi_vc =
4839− (u8)wlapi_getintvar(shim, BRCMS_SROM_RSSISMC2G);
4840− pi_lcn->lcnphy_rssi_gs =
4841− (u8)wlapi_getintvar(shim, BRCMS_SROM_RSSISAV2G);
4834+ pi_lcn->lcnphy_rssi_vf = sprom->rssismf2g;
4835+ pi_lcn->lcnphy_rssi_vc = sprom->rssismc2g;
4836+ pi_lcn->lcnphy_rssi_gs = sprom->rssisav2g;
48424837
48434838 pi_lcn->lcnphy_rssi_vf_lowtemp = pi_lcn->lcnphy_rssi_vf;
48444839 pi_lcn->lcnphy_rssi_vc_lowtemp = pi_lcn->lcnphy_rssi_vc;
@@ -4848,7 +4843,7 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) · 3 unmodified lines
48484843 pi_lcn->lcnphy_rssi_vc_hightemp = pi_lcn->lcnphy_rssi_vc;
48494844 pi_lcn->lcnphy_rssi_gs_hightemp = pi_lcn->lcnphy_rssi_gs;
48504845
4851− txpwr = (s8)wlapi_getintvar(shim, BRCMS_SROM_MAXP2GA0);
4846+ txpwr = sprom->core_pwr_info[0].maxpwr_2g;
48524847 pi->tx_srom_max_2g = txpwr;
48534848
48544849 for (i = 0; i < PWRTBL_NUM_COEFF; i++) {
@@ -4856,8 +4851,8 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) · 1 unmodified line
48564851 pi->txpa_2g_high_temp[i] = pi->txpa_2g[i];
48574852 }
48584853
4859− cckpo = (u16)wlapi_getintvar(shim, BRCMS_SROM_CCK2GPO);
4860− offset_ofdm = (u32)wlapi_getintvar(shim, BRCMS_SROM_OFDM2GPO);
4854+ cckpo = sprom->cck2gpo;
4855+ offset_ofdm = sprom->ofdm2gpo;
48614856 if (cckpo) {
48624857 uint max_pwr_chan = txpwr;
48634858
@@ -4876,7 +4871,7 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) · 12 unmodified lines
48764871 } else {
48774872 u8 opo = 0;
48784873
4879− opo = (u8)wlapi_getintvar(shim, BRCMS_SROM_OPO);
4874+ opo = sprom->opo;
48804875
48814876 for (i = TXP_FIRST_CCK; i <= TXP_LAST_CCK; i++)
48824877 pi->tx_srom_max_rate_2g[i] = txpwr;
@@ -4886,12 +4881,8 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) · 3 unmodified lines
48864881 ((offset_ofdm & 0xf) * 2);
48874882 offset_ofdm >>= 4;
48884883 }
4889− offset_mcs =
4890− wlapi_getintvar(shim,
4891− BRCMS_SROM_MCS2GPO1) << 16;
4892− offset_mcs |=
4893− (u16) wlapi_getintvar(shim,
4894− BRCMS_SROM_MCS2GPO0);
4884+ offset_mcs = sprom->mcs2gpo[1] << 16;
4885+ offset_mcs |= sprom->mcs2gpo[0];
48954886 pi_lcn->lcnphy_mcs20_po = offset_mcs;
48964887 for (i = TXP_FIRST_SISO_MCS_20;
48974888 i <= TXP_LAST_SISO_MCS_20; i++) {
@@ -4901,25 +4892,17 @@ static bool wlc_phy_txpwr_srom_read_lcnphy(struct brcms_phy *pi) · 3 unmodified lines
49014892 }
49024893 }
49034894
4904− pi_lcn->lcnphy_rawtempsense =
4905− (u16)wlapi_getintvar(shim, BRCMS_SROM_RAWTEMPSENSE);
4906− pi_lcn->lcnphy_measPower =
4907− (u8)wlapi_getintvar(shim, BRCMS_SROM_MEASPOWER);
4908− pi_lcn->lcnphy_tempsense_slope =
4909− (u8)wlapi_getintvar(shim, BRCMS_SROM_TEMPSENSE_SLOPE);
4910− pi_lcn->lcnphy_hw_iqcal_en =
4911− (bool)wlapi_getintvar(shim, BRCMS_SROM_HW_IQCAL_EN);
4912− pi_lcn->lcnphy_iqcal_swp_dis =
4913− (bool)wlapi_getintvar(shim, BRCMS_SROM_IQCAL_SWP_DIS);
4914− pi_lcn->lcnphy_tempcorrx =
4915− (u8)wlapi_getintvar(shim, BRCMS_SROM_TEMPCORRX);
4916− pi_lcn->lcnphy_tempsense_option =
4917− (u8)wlapi_getintvar(shim, BRCMS_SROM_TEMPSENSE_OPTION);
4918− pi_lcn->lcnphy_freqoffset_corr =
4919− (u8)wlapi_getintvar(shim, BRCMS_SROM_FREQOFFSET_CORR);
4920− if ((u8)wlapi_getintvar(shim, BRCMS_SROM_AA2G) > 1)
4895+ pi_lcn->lcnphy_rawtempsense = sprom->rawtempsense;
4896+ pi_lcn->lcnphy_measPower = sprom->measpower;
4897+ pi_lcn->lcnphy_tempsense_slope = sprom->tempsense_slope;
4898+ pi_lcn->lcnphy_hw_iqcal_en = sprom->hw_iqcal_en;
4899+ pi_lcn->lcnphy_iqcal_swp_dis = sprom->iqcal_swp_dis;
4900+ pi_lcn->lcnphy_tempcorrx = sprom->tempcorrx;
4901+ pi_lcn->lcnphy_tempsense_option = sprom->tempsense_option;
4902+ pi_lcn->lcnphy_freqoffset_corr = sprom->freqoffset_corr;
4903+ if (sprom->ant_available_bg > 1)
49214904 wlc_phy_ant_rxdiv_set((struct brcms_phy_pub *) pi,
4922− (u8) wlapi_getintvar(shim, BRCMS_SROM_AA2G));
4905+ sprom->ant_available_bg);
49234906 }
49244907 pi_lcn->lcnphy_cck_dig_filt_type = -1;
49254908
drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c+108−225
@@ -14386,30 +14386,30 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) · 14385 unmodified lines
1438614386 {
1438714387 u16 bw40po, cddpo, stbcpo, bwduppo;
1438814388 uint band_num;
14389− struct phy_shim_info *shim = pi->sh->physhim;
14389+ struct ssb_sprom *sprom = &pi->d11core->bus->sprom;
1439014390
1439114391 if (pi->sh->sromrev >= 9)
1439214392 return;
1439314393
14394− bw40po = (u16) wlapi_getintvar(shim, BRCMS_SROM_BW40PO);
14394+ bw40po = sprom->bw40po;
1439514395 pi->bw402gpo = bw40po & 0xf;
1439614396 pi->bw405gpo = (bw40po & 0xf0) >> 4;
1439714397 pi->bw405glpo = (bw40po & 0xf00) >> 8;
1439814398 pi->bw405ghpo = (bw40po & 0xf000) >> 12;
1439914399
14400− cddpo = (u16) wlapi_getintvar(shim, BRCMS_SROM_CDDPO);
14400+ cddpo = sprom->cddpo;
1440114401 pi->cdd2gpo = cddpo & 0xf;
1440214402 pi->cdd5gpo = (cddpo & 0xf0) >> 4;
1440314403 pi->cdd5glpo = (cddpo & 0xf00) >> 8;
1440414404 pi->cdd5ghpo = (cddpo & 0xf000) >> 12;
1440514405
14406− stbcpo = (u16) wlapi_getintvar(shim, BRCMS_SROM_STBCPO);
14406+ stbcpo = sprom->stbcpo;
1440714407 pi->stbc2gpo = stbcpo & 0xf;
1440814408 pi->stbc5gpo = (stbcpo & 0xf0) >> 4;
1440914409 pi->stbc5glpo = (stbcpo & 0xf00) >> 8;
1441014410 pi->stbc5ghpo = (stbcpo & 0xf000) >> 12;
1441114411
14412− bwduppo = (u16) wlapi_getintvar(shim, BRCMS_SROM_BWDUPPO);
14412+ bwduppo = sprom->bwduppo;
1441314413 pi->bwdup2gpo = bwduppo & 0xf;
1441414414 pi->bwdup5gpo = (bwduppo & 0xf0) >> 4;
1441514415 pi->bwdup5glpo = (bwduppo & 0xf00) >> 8;
@@ -14419,242 +14419,137 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) · 3 unmodified lines
1441914419 band_num++) {
1442014420 switch (band_num) {
1442114421 case 0:
14422−
1442314422 pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_2g =
14424− (s8) wlapi_getintvar(shim,
14425− BRCMS_SROM_MAXP2GA0);
14423+ sprom->core_pwr_info[0].maxpwr_2g;
1442614424 pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_2g =
14427− (s8) wlapi_getintvar(shim,
14428− BRCMS_SROM_MAXP2GA1);
14425+ sprom->core_pwr_info[1].maxpwr_2g;
1442914426 pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_a1 =
14430− (s16) wlapi_getintvar(shim,
14431− BRCMS_SROM_PA2GW0A0);
14427+ sprom->core_pwr_info[0].pa_2g[0];
1443214428 pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_a1 =
14433− (s16) wlapi_getintvar(shim,
14434− BRCMS_SROM_PA2GW0A1);
14429+ sprom->core_pwr_info[1].pa_2g[0];
1443514430 pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b0 =
14436− (s16) wlapi_getintvar(shim,
14437− BRCMS_SROM_PA2GW1A0);
14431+ sprom->core_pwr_info[0].pa_2g[1];
1443814432 pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b0 =
14439− (s16) wlapi_getintvar(shim,
14440− BRCMS_SROM_PA2GW1A1);
14433+ sprom->core_pwr_info[1].pa_2g[1];
1444114434 pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_2g_b1 =
14442− (s16) wlapi_getintvar(shim,
14443− BRCMS_SROM_PA2GW2A0);
14435+ sprom->core_pwr_info[0].pa_2g[2];
1444414436 pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_2g_b1 =
14445− (s16) wlapi_getintvar(shim,
14446− BRCMS_SROM_PA2GW2A1);
14437+ sprom->core_pwr_info[1].pa_2g[2];
1444714438 pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_2g =
14448− (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT2GA0);
14439+ sprom->core_pwr_info[0].itssi_2g;
1444914440 pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_2g =
14450− (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT2GA1);
14451−
14452− pi->cck2gpo = (u16) wlapi_getintvar(shim,
14453− BRCMS_SROM_CCK2GPO);
14454−
14455− pi->ofdm2gpo =
14456− (u32) wlapi_getintvar(shim,
14457− BRCMS_SROM_OFDM2GPO);
14458−
14459− pi->mcs2gpo[0] =
14460− (u16) wlapi_getintvar(shim,
14461− BRCMS_SROM_MCS2GPO0);
14462− pi->mcs2gpo[1] =
14463− (u16) wlapi_getintvar(shim,
14464− BRCMS_SROM_MCS2GPO1);
14465− pi->mcs2gpo[2] =
14466− (u16) wlapi_getintvar(shim,
14467− BRCMS_SROM_MCS2GPO2);
14468− pi->mcs2gpo[3] =
14469− (u16) wlapi_getintvar(shim,
14470− BRCMS_SROM_MCS2GPO3);
14471− pi->mcs2gpo[4] =
14472− (u16) wlapi_getintvar(shim,
14473− BRCMS_SROM_MCS2GPO4);
14474− pi->mcs2gpo[5] =
14475− (u16) wlapi_getintvar(shim,
14476− BRCMS_SROM_MCS2GPO5);
14477− pi->mcs2gpo[6] =
14478− (u16) wlapi_getintvar(shim,
14479− BRCMS_SROM_MCS2GPO6);
14480− pi->mcs2gpo[7] =
14481− (u16) wlapi_getintvar(shim,
14482− BRCMS_SROM_MCS2GPO7);
14441+ sprom->core_pwr_info[1].itssi_2g;
14442+
14443+ pi->cck2gpo = sprom->cck2gpo;
14444+
14445+ pi->ofdm2gpo = sprom->ofdm2gpo;
14446+
14447+ pi->mcs2gpo[0] = sprom->mcs2gpo[0];
14448+ pi->mcs2gpo[1] = sprom->mcs2gpo[1];
14449+ pi->mcs2gpo[2] = sprom->mcs2gpo[2];
14450+ pi->mcs2gpo[3] = sprom->mcs2gpo[3];
14451+ pi->mcs2gpo[4] = sprom->mcs2gpo[4];
14452+ pi->mcs2gpo[5] = sprom->mcs2gpo[5];
14453+ pi->mcs2gpo[6] = sprom->mcs2gpo[6];
14454+ pi->mcs2gpo[7] = sprom->mcs2gpo[7];
1448314455 break;
1448414456 case 1:
1448514457
1448614458 pi->nphy_pwrctrl_info[PHY_CORE_0].max_pwr_5gm =
14487− (s8) wlapi_getintvar(shim, BRCMS_SROM_MAXP5GA0);
14459+ sprom->core_pwr_info[0].maxpwr_5g;
1448814460 pi->nphy_pwrctrl_info[PHY_CORE_1].max_pwr_5gm =
14489− (s8) wlapi_getintvar(shim,
14490− BRCMS_SROM_MAXP5GA1);
14461+ sprom->core_pwr_info[1].maxpwr_5g;
1449114462 pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_a1 =
14492− (s16) wlapi_getintvar(shim,
14493− BRCMS_SROM_PA5GW0A0);
14463+ sprom->core_pwr_info[0].pa_5g[0];
1449414464 pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_a1 =
14495− (s16) wlapi_getintvar(shim,
14496− BRCMS_SROM_PA5GW0A1);
14465+ sprom->core_pwr_info[1].pa_5g[0];
1449714466 pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b0 =
14498− (s16) wlapi_getintvar(shim,
14499− BRCMS_SROM_PA5GW1A0);
14467+ sprom->core_pwr_info[0].pa_5g[1];
1450014468 pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b0 =
14501− (s16) wlapi_getintvar(shim,
14502− BRCMS_SROM_PA5GW1A1);
14469+ sprom->core_pwr_info[1].pa_5g[1];
1450314470 pi->nphy_pwrctrl_info[PHY_CORE_0].pwrdet_5gm_b1 =
14504− (s16) wlapi_getintvar(shim,
14505− BRCMS_SROM_PA5GW2A0);
14471+ sprom->core_pwr_info[0].pa_5g[2];
1450614472 pi->nphy_pwrctrl_info[PHY_CORE_1].pwrdet_5gm_b1 =
14507− (s16) wlapi_getintvar(shim,
14508− BRCMS_SROM_PA5GW2A1);
14473+ sprom->core_pwr_info[1].pa_5g[2];
1450914474 pi->nphy_pwrctrl_info[PHY_CORE_0].idle_targ_5gm =
14510− (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT5GA0);
14475+ sprom->core_pwr_info[0].itssi_5g;
1451114476 pi->nphy_pwrctrl_info[PHY_CORE_1].idle_targ_5gm =
14512− (s8) wlapi_getintvar(shim, BRCMS_SROM_ITT5GA1);
14513−
14514− pi->ofdm5gpo =
14515− (u32) wlapi_getintvar(shim,
14516− BRCMS_SROM_OFDM5GPO);
14517−
14518− pi->mcs5gpo[0] =
14519− (u16) wlapi_getintvar(shim,
14520− BRCMS_SROM_MCS5GPO0);
14521− pi->mcs5gpo[1] =
14522− (u16) wlapi_getintvar(shim,
14523− BRCMS_SROM_MCS5GPO1);
14524− pi->mcs5gpo[2] =
14525− (u16) wlapi_getintvar(shim,
14526− BRCMS_SROM_MCS5GPO2);
14527− pi->mcs5gpo[3] =
14528− (u16) wlapi_getintvar(shim,
14529− BRCMS_SROM_MCS5GPO3);
14530− pi->mcs5gpo[4] =
14531− (u16) wlapi_getintvar(shim,
14532− BRCMS_SROM_MCS5GPO4);
14533− pi->mcs5gpo[5] =
14534− (u16) wlapi_getintvar(shim,
14535− BRCMS_SROM_MCS5GPO5);
14536− pi->mcs5gpo[6] =
14537− (u16) wlapi_getintvar(shim,
14538− BRCMS_SROM_MCS5GPO6);
14539− pi->mcs5gpo[7] =
14540− (u16) wlapi_getintvar(shim,
14541− BRCMS_SROM_MCS5GPO7);
14477+ sprom->core_pwr_info[1].itssi_5g;
14478+
14479+ pi->ofdm5gpo = sprom->ofdm5gpo;
14480+
14481+ pi->mcs5gpo[0] = sprom->mcs5gpo[0];
14482+ pi->mcs5gpo[1] = sprom->mcs5gpo[1];
14483+ pi->mcs5gpo[2] = sprom->mcs5gpo[2];
14484+ pi->mcs5gpo[3] = sprom->mcs5gpo[3];
14485+ pi->mcs5gpo[4] = sprom->mcs5gpo[4];
14486+ pi->mcs5gpo[5] = sprom->mcs5gpo[5];
14487+ pi->mcs5gpo[6] = sprom->mcs5gpo[6];
14488+ pi->mcs5gpo[7] = sprom->mcs5gpo[7];
1454214489 break;
1454314490 case 2:
1454414491
1454514492 pi->nphy_pwrctrl_info[0].max_pwr_5gl =
14546− (s8) wlapi_getintvar(shim,
14547− BRCMS_SROM_MAXP5GLA0);
14493+ sprom->core_pwr_info[0].maxpwr_5gl;
1454814494 pi->nphy_pwrctrl_info[1].max_pwr_5gl =
14549− (s8) wlapi_getintvar(shim,
14550− BRCMS_SROM_MAXP5GLA1);
14495+ sprom->core_pwr_info[1].maxpwr_5gl;
1455114496 pi->nphy_pwrctrl_info[0].pwrdet_5gl_a1 =
14552− (s16) wlapi_getintvar(shim,
14553− BRCMS_SROM_PA5GLW0A0);
14497+ sprom->core_pwr_info[0].pa_5gl[0];
1455414498 pi->nphy_pwrctrl_info[1].pwrdet_5gl_a1 =
14555− (s16) wlapi_getintvar(shim,
14556− BRCMS_SROM_PA5GLW0A1);
14499+ sprom->core_pwr_info[1].pa_5gl[0];
1455714500 pi->nphy_pwrctrl_info[0].pwrdet_5gl_b0 =
14558− (s16) wlapi_getintvar(shim,
14559− BRCMS_SROM_PA5GLW1A0);
14501+ sprom->core_pwr_info[0].pa_5gl[1];
1456014502 pi->nphy_pwrctrl_info[1].pwrdet_5gl_b0 =
14561− (s16) wlapi_getintvar(shim,
14562− BRCMS_SROM_PA5GLW1A1);
14503+ sprom->core_pwr_info[1].pa_5gl[1];
1456314504 pi->nphy_pwrctrl_info[0].pwrdet_5gl_b1 =
14564− (s16) wlapi_getintvar(shim,
14565− BRCMS_SROM_PA5GLW2A0);
14505+ sprom->core_pwr_info[0].pa_5gl[2];
1456614506 pi->nphy_pwrctrl_info[1].pwrdet_5gl_b1 =
14567− (s16) wlapi_getintvar(shim,
14568− BRCMS_SROM_PA5GLW2A1);
14507+ sprom->core_pwr_info[1].pa_5gl[2];
1456914508 pi->nphy_pwrctrl_info[0].idle_targ_5gl = 0;
1457014509 pi->nphy_pwrctrl_info[1].idle_targ_5gl = 0;
1457114510
14572− pi->ofdm5glpo =
14573− (u32) wlapi_getintvar(shim,
14574− BRCMS_SROM_OFDM5GLPO);
14575−
14576− pi->mcs5glpo[0] =
14577− (u16) wlapi_getintvar(shim,
14578− BRCMS_SROM_MCS5GLPO0);
14579− pi->mcs5glpo[1] =
14580− (u16) wlapi_getintvar(shim,
14581− BRCMS_SROM_MCS5GLPO1);
14582− pi->mcs5glpo[2] =
14583− (u16) wlapi_getintvar(shim,
14584− BRCMS_SROM_MCS5GLPO2);
14585− pi->mcs5glpo[3] =
14586− (u16) wlapi_getintvar(shim,
14587− BRCMS_SROM_MCS5GLPO3);
14588− pi->mcs5glpo[4] =
14589− (u16) wlapi_getintvar(shim,
14590− BRCMS_SROM_MCS5GLPO4);
14591− pi->mcs5glpo[5] =
14592− (u16) wlapi_getintvar(shim,
14593− BRCMS_SROM_MCS5GLPO5);
14594− pi->mcs5glpo[6] =
14595− (u16) wlapi_getintvar(shim,
14596− BRCMS_SROM_MCS5GLPO6);
14597− pi->mcs5glpo[7] =
14598− (u16) wlapi_getintvar(shim,
14599− BRCMS_SROM_MCS5GLPO7);
14511+ pi->ofdm5glpo = sprom->ofdm5glpo;
14512+
14513+ pi->mcs5glpo[0] = sprom->mcs5glpo[0];
14514+ pi->mcs5glpo[1] = sprom->mcs5glpo[1];
14515+ pi->mcs5glpo[2] = sprom->mcs5glpo[2];
14516+ pi->mcs5glpo[3] = sprom->mcs5glpo[3];
14517+ pi->mcs5glpo[4] = sprom->mcs5glpo[4];
14518+ pi->mcs5glpo[5] = sprom->mcs5glpo[5];
14519+ pi->mcs5glpo[6] = sprom->mcs5glpo[6];
14520+ pi->mcs5glpo[7] = sprom->mcs5glpo[7];
1460014521 break;
1460114522 case 3:
1460214523
1460314524 pi->nphy_pwrctrl_info[0].max_pwr_5gh =
14604− (s8) wlapi_getintvar(shim,
14605− BRCMS_SROM_MAXP5GHA0);
14525+ sprom->core_pwr_info[0].maxpwr_5gh;
1460614526 pi->nphy_pwrctrl_info[1].max_pwr_5gh =
14607− (s8) wlapi_getintvar(shim,
14608− BRCMS_SROM_MAXP5GHA1);
14527+ sprom->core_pwr_info[1].maxpwr_5gh;
1460914528 pi->nphy_pwrctrl_info[0].pwrdet_5gh_a1 =
14610− (s16) wlapi_getintvar(shim,
14611− BRCMS_SROM_PA5GHW0A0);
14529+ sprom->core_pwr_info[0].pa_5gh[0];
1461214530 pi->nphy_pwrctrl_info[1].pwrdet_5gh_a1 =
14613− (s16) wlapi_getintvar(shim,
14614− BRCMS_SROM_PA5GHW0A1);
14531+ sprom->core_pwr_info[1].pa_5gh[0];
1461514532 pi->nphy_pwrctrl_info[0].pwrdet_5gh_b0 =
14616− (s16) wlapi_getintvar(shim,
14617− BRCMS_SROM_PA5GHW1A0);
14533+ sprom->core_pwr_info[0].pa_5gh[1];
1461814534 pi->nphy_pwrctrl_info[1].pwrdet_5gh_b0 =
14619− (s16) wlapi_getintvar(shim,
14620− BRCMS_SROM_PA5GHW1A1);
14535+ sprom->core_pwr_info[1].pa_5gh[1];
1462114536 pi->nphy_pwrctrl_info[0].pwrdet_5gh_b1 =
14622− (s16) wlapi_getintvar(shim,
14623− BRCMS_SROM_PA5GHW2A0);
14537+ sprom->core_pwr_info[0].pa_5gh[2];
1462414538 pi->nphy_pwrctrl_info[1].pwrdet_5gh_b1 =
14625− (s16) wlapi_getintvar(shim,
14626− BRCMS_SROM_PA5GHW2A1);
14539+ sprom->core_pwr_info[1].pa_5gh[2];
1462714540 pi->nphy_pwrctrl_info[0].idle_targ_5gh = 0;
1462814541 pi->nphy_pwrctrl_info[1].idle_targ_5gh = 0;
1462914542
14630− pi->ofdm5ghpo =
14631− (u32) wlapi_getintvar(shim,
14632− BRCMS_SROM_OFDM5GHPO);
14633−
14634− pi->mcs5ghpo[0] =
14635− (u16) wlapi_getintvar(shim,
14636− BRCMS_SROM_MCS5GHPO0);
14637− pi->mcs5ghpo[1] =
14638− (u16) wlapi_getintvar(shim,
14639− BRCMS_SROM_MCS5GHPO1);
14640− pi->mcs5ghpo[2] =
14641− (u16) wlapi_getintvar(shim,
14642− BRCMS_SROM_MCS5GHPO2);
14643− pi->mcs5ghpo[3] =
14644− (u16) wlapi_getintvar(shim,
14645− BRCMS_SROM_MCS5GHPO3);
14646− pi->mcs5ghpo[4] =
14647− (u16) wlapi_getintvar(shim,
14648− BRCMS_SROM_MCS5GHPO4);
14649− pi->mcs5ghpo[5] =
14650− (u16) wlapi_getintvar(shim,
14651− BRCMS_SROM_MCS5GHPO5);
14652− pi->mcs5ghpo[6] =
14653− (u16) wlapi_getintvar(shim,
14654− BRCMS_SROM_MCS5GHPO6);
14655− pi->mcs5ghpo[7] =
14656− (u16) wlapi_getintvar(shim,
14657− BRCMS_SROM_MCS5GHPO7);
14543+ pi->ofdm5ghpo = sprom->ofdm5ghpo;
14544+
14545+ pi->mcs5ghpo[0] = sprom->mcs5ghpo[0];
14546+ pi->mcs5ghpo[1] = sprom->mcs5ghpo[1];
14547+ pi->mcs5ghpo[2] = sprom->mcs5ghpo[2];
14548+ pi->mcs5ghpo[3] = sprom->mcs5ghpo[3];
14549+ pi->mcs5ghpo[4] = sprom->mcs5ghpo[4];
14550+ pi->mcs5ghpo[5] = sprom->mcs5ghpo[5];
14551+ pi->mcs5ghpo[6] = sprom->mcs5ghpo[6];
14552+ pi->mcs5ghpo[7] = sprom->mcs5ghpo[7];
1465814553 break;
1465914554 }
1466014555 }
@@ -14664,45 +14559,34 @@ static void wlc_phy_txpwr_srom_read_ppr_nphy(struct brcms_phy *pi) · 3 unmodified lines
1466414559
1466514560 static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi)
1466614561 {
14667− struct phy_shim_info *shim = pi->sh->physhim;
14668−
14669− pi->antswitch = (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWITCH);
14670− pi->aa2g = (u8) wlapi_getintvar(shim, BRCMS_SROM_AA2G);
14671− pi->aa5g = (u8) wlapi_getintvar(shim, BRCMS_SROM_AA5G);
14672−
14673− pi->srom_fem2g.tssipos = (u8) wlapi_getintvar(shim,
14674− BRCMS_SROM_TSSIPOS2G);
14675− pi->srom_fem2g.extpagain = (u8) wlapi_getintvar(shim,
14676− BRCMS_SROM_EXTPAGAIN2G);
14677− pi->srom_fem2g.pdetrange = (u8) wlapi_getintvar(shim,
14678− BRCMS_SROM_PDETRANGE2G);
14679− pi->srom_fem2g.triso = (u8) wlapi_getintvar(shim, BRCMS_SROM_TRISO2G);
14680− pi->srom_fem2g.antswctrllut =
14681− (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWCTL2G);
14682−
14683− pi->srom_fem5g.tssipos = (u8) wlapi_getintvar(shim,
14684− BRCMS_SROM_TSSIPOS5G);
14685− pi->srom_fem5g.extpagain = (u8) wlapi_getintvar(shim,
14686− BRCMS_SROM_EXTPAGAIN5G);
14687− pi->srom_fem5g.pdetrange = (u8) wlapi_getintvar(shim,
14688− BRCMS_SROM_PDETRANGE5G);
14689− pi->srom_fem5g.triso = (u8) wlapi_getintvar(shim, BRCMS_SROM_TRISO5G);
14690− if (wlapi_getvar(shim, BRCMS_SROM_ANTSWCTL5G))
14691− pi->srom_fem5g.antswctrllut =
14692− (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWCTL5G);
14562+ struct ssb_sprom *sprom = &pi->d11core->bus->sprom;
14563+
14564+ pi->antswitch = sprom->antswitch;
14565+ pi->aa2g = sprom->ant_available_bg;
14566+ pi->aa5g = sprom->ant_available_a;
14567+
14568+ pi->srom_fem2g.tssipos = sprom->fem.ghz2.tssipos;
14569+ pi->srom_fem2g.extpagain = sprom->fem.ghz2.extpa_gain;
14570+ pi->srom_fem2g.pdetrange = sprom->fem.ghz2.pdet_range;
14571+ pi->srom_fem2g.triso = sprom->fem.ghz2.tr_iso;
14572+ pi->srom_fem2g.antswctrllut = sprom->fem.ghz2.antswlut;
14573+
14574+ pi->srom_fem5g.tssipos = sprom->fem.ghz5.tssipos;
14575+ pi->srom_fem5g.extpagain = sprom->fem.ghz5.extpa_gain;
14576+ pi->srom_fem5g.pdetrange = sprom->fem.ghz5.pdet_range;
14577+ pi->srom_fem5g.triso = sprom->fem.ghz5.tr_iso;
14578+ if (sprom->fem.ghz5.antswlut)
14579+ pi->srom_fem5g.antswctrllut = sprom->fem.ghz5.antswlut;
1469314580 else
14694− pi->srom_fem5g.antswctrllut =
14695− (u8) wlapi_getintvar(shim, BRCMS_SROM_ANTSWCTL2G);
14581+ pi->srom_fem5g.antswctrllut = sprom->fem.ghz2.antswlut;
1469614582
1469714583 wlc_phy_txpower_ipa_upd(pi);
1469814584
14699− pi->phy_txcore_disable_temp =
14700− (s16) wlapi_getintvar(shim, BRCMS_SROM_TEMPTHRESH);
14585+ pi->phy_txcore_disable_temp = sprom->tempthresh;
1470114586 if (pi->phy_txcore_disable_temp == 0)
1470214587 pi->phy_txcore_disable_temp = PHY_CHAIN_TX_DISABLE_TEMP;
1470314588
14704− pi->phy_tempsense_offset = (s8) wlapi_getintvar(shim,
14705− BRCMS_SROM_TEMPOFFSET);
14589+ pi->phy_tempsense_offset = sprom->tempoffset;
1470614590 if (pi->phy_tempsense_offset != 0) {
1470714591 if (pi->phy_tempsense_offset >
1470814592 (NPHY_SROM_TEMPSHIFT + NPHY_SROM_MAXTEMPOFFSET))
@@ -14717,8 +14601,7 @@ static bool wlc_phy_txpwr_srom_read_nphy(struct brcms_phy *pi) · 8 unmodified lines
1471714601 pi->phy_txcore_enable_temp =
1471814602 pi->phy_txcore_disable_temp - PHY_HYSTERESIS_DELTATEMP;
1471914603
14720− pi->phycal_tempdelta =
14721− (u8) wlapi_getintvar(shim, BRCMS_SROM_PHYCAL_TEMPDELTA);
14604+ pi->phycal_tempdelta = sprom->phycal_tempdelta;
1472214605 if (pi->phycal_tempdelta > NPHY_CAL_MAXTEMPDELTA)
1472314606 pi->phycal_tempdelta = 0;
1472414607
@@ -21460,7 +21343,7 @@ void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init) · 6735 unmodified lines
2146021343 write_phy_reg(pi, 0xc8, 0x0);
2146121344 write_phy_reg(pi, 0xc9, 0x0);
2146221345
21463− ai_gpiocontrol(pi->sh->sih, mask, mask, GPIO_DRV_PRIORITY);
21346+ bcma_chipco_gpio_control(&pi->d11core->bus->drv_cc, mask, mask);
2146421347
2146521348 mc = bcma_read32(pi->d11core, D11REGOFFS(maccontrol));
2146621349 mc &= ~MCTL_GPOUT_SEL_MASK;
drivers/net/wireless/brcm80211/brcmsmac/phy_shim.c+0−9
@@ -214,12 +214,3 @@ wlapi_copyto_objmem(struct phy_shim_info *physhim, uint offset, const void *buf, · 213 unmodified lines
214214 {
215215 brcms_b_copyto_objmem(physhim->wlc_hw, offset, buf, l, sel);
216216 }
217−
218−char *wlapi_getvar(struct phy_shim_info *physhim, enum brcms_srom_id id)
219−{
220− return getvar(physhim->wlc_hw->sih, id);
221−}
222−int wlapi_getintvar(struct phy_shim_info *physhim, enum brcms_srom_id id)
223−{
224− return getintvar(physhim->wlc_hw->sih, id);
225−}
drivers/net/wireless/brcm80211/brcmsmac/phy_shim.h+0−3
@@ -175,8 +175,5 @@ extern void wlapi_copyto_objmem(struct phy_shim_info *physhim, uint, · 174 unmodified lines
175175 extern void wlapi_high_update_phy_mode(struct phy_shim_info *physhim,
176176 u32 phy_mode);
177177 extern u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim);
178−extern char *wlapi_getvar(struct phy_shim_info *physhim, enum brcms_srom_id id);
179−extern int wlapi_getintvar(struct phy_shim_info *physhim,
180− enum brcms_srom_id id);
181178
182179 #endif /* _BRCM_PHY_SHIM_H_ */
drivers/net/wireless/brcm80211/brcmsmac/pub.h+0−228
@@ -22,232 +22,6 @@ · 21 unmodified lines
2222 #include "types.h"
2323 #include "defs.h"
2424
25−enum brcms_srom_id {
26− BRCMS_SROM_NULL,
27− BRCMS_SROM_CONT,
28− BRCMS_SROM_AA2G,
29− BRCMS_SROM_AA5G,
30− BRCMS_SROM_AG0,
31− BRCMS_SROM_AG1,
32− BRCMS_SROM_AG2,
33− BRCMS_SROM_AG3,
34− BRCMS_SROM_ANTSWCTL2G,
35− BRCMS_SROM_ANTSWCTL5G,
36− BRCMS_SROM_ANTSWITCH,
37− BRCMS_SROM_BOARDFLAGS2,
38− BRCMS_SROM_BOARDFLAGS,
39− BRCMS_SROM_BOARDNUM,
40− BRCMS_SROM_BOARDREV,
41− BRCMS_SROM_BOARDTYPE,
42− BRCMS_SROM_BW40PO,
43− BRCMS_SROM_BWDUPPO,
44− BRCMS_SROM_BXA2G,
45− BRCMS_SROM_BXA5G,
46− BRCMS_SROM_CC,
47− BRCMS_SROM_CCK2GPO,
48− BRCMS_SROM_CCKBW202GPO,
49− BRCMS_SROM_CCKBW20UL2GPO,
50− BRCMS_SROM_CCODE,
51− BRCMS_SROM_CDDPO,
52− BRCMS_SROM_DEVID,
53− BRCMS_SROM_ET1MACADDR,
54− BRCMS_SROM_EXTPAGAIN2G,
55− BRCMS_SROM_EXTPAGAIN5G,
56− BRCMS_SROM_FREQOFFSET_CORR,
57− BRCMS_SROM_HW_IQCAL_EN,
58− BRCMS_SROM_IL0MACADDR,
59− BRCMS_SROM_IQCAL_SWP_DIS,
60− BRCMS_SROM_LEDBH0,
61− BRCMS_SROM_LEDBH1,
62− BRCMS_SROM_LEDBH2,
63− BRCMS_SROM_LEDBH3,
64− BRCMS_SROM_LEDDC,
65− BRCMS_SROM_LEGOFDM40DUPPO,
66− BRCMS_SROM_LEGOFDMBW202GPO,
67− BRCMS_SROM_LEGOFDMBW205GHPO,
68− BRCMS_SROM_LEGOFDMBW205GLPO,
69− BRCMS_SROM_LEGOFDMBW205GMPO,
70− BRCMS_SROM_LEGOFDMBW20UL2GPO,
71− BRCMS_SROM_LEGOFDMBW20UL5GHPO,
72− BRCMS_SROM_LEGOFDMBW20UL5GLPO,
73− BRCMS_SROM_LEGOFDMBW20UL5GMPO,
74− BRCMS_SROM_MACADDR,
75− BRCMS_SROM_MCS2GPO0,
76− BRCMS_SROM_MCS2GPO1,
77− BRCMS_SROM_MCS2GPO2,
78− BRCMS_SROM_MCS2GPO3,
79− BRCMS_SROM_MCS2GPO4,
80− BRCMS_SROM_MCS2GPO5,
81− BRCMS_SROM_MCS2GPO6,
82− BRCMS_SROM_MCS2GPO7,
83− BRCMS_SROM_MCS32PO,
84− BRCMS_SROM_MCS5GHPO0,
85− BRCMS_SROM_MCS5GHPO1,
86− BRCMS_SROM_MCS5GHPO2,
87− BRCMS_SROM_MCS5GHPO3,
88− BRCMS_SROM_MCS5GHPO4,
89− BRCMS_SROM_MCS5GHPO5,
90− BRCMS_SROM_MCS5GHPO6,
91− BRCMS_SROM_MCS5GHPO7,
92− BRCMS_SROM_MCS5GLPO0,
93− BRCMS_SROM_MCS5GLPO1,
94− BRCMS_SROM_MCS5GLPO2,
95− BRCMS_SROM_MCS5GLPO3,
96− BRCMS_SROM_MCS5GLPO4,
97− BRCMS_SROM_MCS5GLPO5,
98− BRCMS_SROM_MCS5GLPO6,
99− BRCMS_SROM_MCS5GLPO7,
100− BRCMS_SROM_MCS5GPO0,
101− BRCMS_SROM_MCS5GPO1,
102− BRCMS_SROM_MCS5GPO2,
103− BRCMS_SROM_MCS5GPO3,
104− BRCMS_SROM_MCS5GPO4,
105− BRCMS_SROM_MCS5GPO5,
106− BRCMS_SROM_MCS5GPO6,
107− BRCMS_SROM_MCS5GPO7,
108− BRCMS_SROM_MCSBW202GPO,
109− BRCMS_SROM_MCSBW205GHPO,
110− BRCMS_SROM_MCSBW205GLPO,
111− BRCMS_SROM_MCSBW205GMPO,
112− BRCMS_SROM_MCSBW20UL2GPO,
113− BRCMS_SROM_MCSBW20UL5GHPO,
114− BRCMS_SROM_MCSBW20UL5GLPO,
115− BRCMS_SROM_MCSBW20UL5GMPO,
116− BRCMS_SROM_MCSBW402GPO,
117− BRCMS_SROM_MCSBW405GHPO,
118− BRCMS_SROM_MCSBW405GLPO,
119− BRCMS_SROM_MCSBW405GMPO,
120− BRCMS_SROM_MEASPOWER,
121− BRCMS_SROM_OFDM2GPO,
122− BRCMS_SROM_OFDM5GHPO,
123− BRCMS_SROM_OFDM5GLPO,
124− BRCMS_SROM_OFDM5GPO,
125− BRCMS_SROM_OPO,
126− BRCMS_SROM_PA0B0,
127− BRCMS_SROM_PA0B1,
128− BRCMS_SROM_PA0B2,
129− BRCMS_SROM_PA0ITSSIT,
130− BRCMS_SROM_PA0MAXPWR,
131− BRCMS_SROM_PA1B0,
132− BRCMS_SROM_PA1B1,
133− BRCMS_SROM_PA1B2,
134− BRCMS_SROM_PA1HIB0,
135− BRCMS_SROM_PA1HIB1,
136− BRCMS_SROM_PA1HIB2,
137− BRCMS_SROM_PA1HIMAXPWR,
138− BRCMS_SROM_PA1ITSSIT,
139− BRCMS_SROM_PA1LOB0,
140− BRCMS_SROM_PA1LOB1,
141− BRCMS_SROM_PA1LOB2,
142− BRCMS_SROM_PA1LOMAXPWR,
143− BRCMS_SROM_PA1MAXPWR,
144− BRCMS_SROM_PDETRANGE2G,
145− BRCMS_SROM_PDETRANGE5G,
146− BRCMS_SROM_PHYCAL_TEMPDELTA,
147− BRCMS_SROM_RAWTEMPSENSE,
148− BRCMS_SROM_REGREV,
149− BRCMS_SROM_REV,
150− BRCMS_SROM_RSSISAV2G,
151− BRCMS_SROM_RSSISAV5G,
152− BRCMS_SROM_RSSISMC2G,
153− BRCMS_SROM_RSSISMC5G,
154− BRCMS_SROM_RSSISMF2G,
155− BRCMS_SROM_RSSISMF5G,
156− BRCMS_SROM_RXCHAIN,
157− BRCMS_SROM_RXPO2G,
158− BRCMS_SROM_RXPO5G,
159− BRCMS_SROM_STBCPO,
160− BRCMS_SROM_TEMPCORRX,
161− BRCMS_SROM_TEMPOFFSET,
162− BRCMS_SROM_TEMPSENSE_OPTION,
163− BRCMS_SROM_TEMPSENSE_SLOPE,
164− BRCMS_SROM_TEMPTHRESH,
165− BRCMS_SROM_TRI2G,
166− BRCMS_SROM_TRI5GH,
167− BRCMS_SROM_TRI5GL,
168− BRCMS_SROM_TRI5G,
169− BRCMS_SROM_TRISO2G,
170− BRCMS_SROM_TRISO5G,
171− BRCMS_SROM_TSSIPOS2G,
172− BRCMS_SROM_TSSIPOS5G,
173− BRCMS_SROM_TXCHAIN,
174− /*
175− * per-path identifiers (see srom.c)
176− */
177− BRCMS_SROM_ITT2GA0,
178− BRCMS_SROM_ITT2GA1,
179− BRCMS_SROM_ITT2GA2,
180− BRCMS_SROM_ITT2GA3,
181− BRCMS_SROM_ITT5GA0,
182− BRCMS_SROM_ITT5GA1,
183− BRCMS_SROM_ITT5GA2,
184− BRCMS_SROM_ITT5GA3,
185− BRCMS_SROM_MAXP2GA0,
186− BRCMS_SROM_MAXP2GA1,
187− BRCMS_SROM_MAXP2GA2,
188− BRCMS_SROM_MAXP2GA3,
189− BRCMS_SROM_MAXP5GA0,
190− BRCMS_SROM_MAXP5GA1,
191− BRCMS_SROM_MAXP5GA2,
192− BRCMS_SROM_MAXP5GA3,
193− BRCMS_SROM_MAXP5GHA0,
194− BRCMS_SROM_MAXP5GHA1,
195− BRCMS_SROM_MAXP5GHA2,
196− BRCMS_SROM_MAXP5GHA3,
197− BRCMS_SROM_MAXP5GLA0,
198− BRCMS_SROM_MAXP5GLA1,
199− BRCMS_SROM_MAXP5GLA2,
200− BRCMS_SROM_MAXP5GLA3,
201− BRCMS_SROM_PA2GW0A0,
202− BRCMS_SROM_PA2GW0A1,
203− BRCMS_SROM_PA2GW0A2,
204− BRCMS_SROM_PA2GW0A3,
205− BRCMS_SROM_PA2GW1A0,
206− BRCMS_SROM_PA2GW1A1,
207− BRCMS_SROM_PA2GW1A2,
208− BRCMS_SROM_PA2GW1A3,
209− BRCMS_SROM_PA2GW2A0,
210− BRCMS_SROM_PA2GW2A1,
211− BRCMS_SROM_PA2GW2A2,
212− BRCMS_SROM_PA2GW2A3,
213− BRCMS_SROM_PA5GHW0A0,
214− BRCMS_SROM_PA5GHW0A1,
215− BRCMS_SROM_PA5GHW0A2,
216− BRCMS_SROM_PA5GHW0A3,
217− BRCMS_SROM_PA5GHW1A0,
218− BRCMS_SROM_PA5GHW1A1,
219− BRCMS_SROM_PA5GHW1A2,
220− BRCMS_SROM_PA5GHW1A3,
221− BRCMS_SROM_PA5GHW2A0,
222− BRCMS_SROM_PA5GHW2A1,
223− BRCMS_SROM_PA5GHW2A2,
224− BRCMS_SROM_PA5GHW2A3,
225− BRCMS_SROM_PA5GLW0A0,
226− BRCMS_SROM_PA5GLW0A1,
227− BRCMS_SROM_PA5GLW0A2,
228− BRCMS_SROM_PA5GLW0A3,
229− BRCMS_SROM_PA5GLW1A0,
230− BRCMS_SROM_PA5GLW1A1,
231− BRCMS_SROM_PA5GLW1A2,
232− BRCMS_SROM_PA5GLW1A3,
233− BRCMS_SROM_PA5GLW2A0,
234− BRCMS_SROM_PA5GLW2A1,
235− BRCMS_SROM_PA5GLW2A2,
236− BRCMS_SROM_PA5GLW2A3,
237− BRCMS_SROM_PA5GW0A0,
238− BRCMS_SROM_PA5GW0A1,
239− BRCMS_SROM_PA5GW0A2,
240− BRCMS_SROM_PA5GW0A3,
241− BRCMS_SROM_PA5GW1A0,
242− BRCMS_SROM_PA5GW1A1,
243− BRCMS_SROM_PA5GW1A2,
244− BRCMS_SROM_PA5GW1A3,
245− BRCMS_SROM_PA5GW2A0,
246− BRCMS_SROM_PA5GW2A1,
247− BRCMS_SROM_PA5GW2A2,
248− BRCMS_SROM_PA5GW2A3,
249−};
250−
25125 #define BRCMS_NUMRATES 16 /* max # of rates in a rateset */
25226
25327 /* phy types */
@@ -565,8 +339,6 @@ extern void brcms_c_ampdu_flush(struct brcms_c_info *wlc, · 311 unmodified lines
565339 struct ieee80211_sta *sta, u16 tid);
566340 extern void brcms_c_ampdu_tx_operational(struct brcms_c_info *wlc, u8 tid,
567341 u8 ba_wsize, uint max_rx_ampdu_bytes);
568−extern char *getvar(struct si_pub *sih, enum brcms_srom_id id);
569−extern int getintvar(struct si_pub *sih, enum brcms_srom_id id);
570342 extern int brcms_c_module_register(struct brcms_pub *pub,
571343 const char *name, struct brcms_info *hdl,
572344 int (*down_fn)(void *handle));
drivers/net/wireless/brcm80211/brcmsmac/srom.c+0−980
@@ -1,980 +0,0 @@
1−/*
2− * Copyright (c) 2010 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−#include <linux/kernel.h>
18−#include <linux/string.h>
19−#include <linux/io.h>
20−#include <linux/etherdevice.h>
21−#include <linux/crc8.h>
22−#include <stdarg.h>
23−
24−#include <chipcommon.h>
25−#include <brcmu_utils.h>
26−#include "pub.h"
27−#include "nicpci.h"
28−#include "aiutils.h"
29−#include "otp.h"
30−#include "srom.h"
31−#include "soc.h"
32−
33−/*
34− * SROM CRC8 polynomial value:
35− *
36− * x^8 + x^7 +x^6 + x^4 + x^2 + 1
37− */
38−#define SROM_CRC8_POLY 0xAB
39−
40−/* Maximum srom: 6 Kilobits == 768 bytes */
41−#define SROM_MAX 768
42−
43−/* PCI fields */
44−#define PCI_F0DEVID 48
45−
46−#define SROM_WORDS 64
47−
48−#define SROM_SSID 2
49−
50−#define SROM_WL1LHMAXP 29
51−
52−#define SROM_WL1LPAB0 30
53−#define SROM_WL1LPAB1 31
54−#define SROM_WL1LPAB2 32
55−
56−#define SROM_WL1HPAB0 33
57−#define SROM_WL1HPAB1 34
58−#define SROM_WL1HPAB2 35
59−
60−#define SROM_MACHI_IL0 36
61−#define SROM_MACMID_IL0 37
62−#define SROM_MACLO_IL0 38
63−#define SROM_MACHI_ET1 42
64−#define SROM_MACMID_ET1 43
65−#define SROM_MACLO_ET1 44
66−
67−#define SROM_BXARSSI2G 40
68−#define SROM_BXARSSI5G 41
69−
70−#define SROM_TRI52G 42
71−#define SROM_TRI5GHL 43
72−
73−#define SROM_RXPO52G 45
74−
75−#define SROM_AABREV 46
76−/* Fields in AABREV */
77−#define SROM_BR_MASK 0x00ff
78−#define SROM_CC_MASK 0x0f00
79−#define SROM_CC_SHIFT 8
80−#define SROM_AA0_MASK 0x3000
81−#define SROM_AA0_SHIFT 12
82−#define SROM_AA1_MASK 0xc000
83−#define SROM_AA1_SHIFT 14
84−
85−#define SROM_WL0PAB0 47
86−#define SROM_WL0PAB1 48
87−#define SROM_WL0PAB2 49
88−
89−#define SROM_LEDBH10 50
90−#define SROM_LEDBH32 51
91−
92−#define SROM_WL10MAXP 52
93−
94−#define SROM_WL1PAB0 53
95−#define SROM_WL1PAB1 54
96−#define SROM_WL1PAB2 55
97−
98−#define SROM_ITT 56
99−
100−#define SROM_BFL 57
101−#define SROM_BFL2 28
102−
103−#define SROM_AG10 58
104−
105−#define SROM_CCODE 59
106−
107−#define SROM_OPO 60
108−
109−#define SROM_CRCREV 63
110−
111−#define SROM4_WORDS 220
112−
113−#define SROM4_TXCHAIN_MASK 0x000f
114−#define SROM4_RXCHAIN_MASK 0x00f0
115−#define SROM4_SWITCH_MASK 0xff00
116−
117−/* Per-path fields */
118−#define MAX_PATH_SROM 4
119−
120−#define SROM4_CRCREV 219
121−
122−/* SROM Rev 8: Make space for a 48word hardware header for PCIe rev >= 6.
123− * This is acombined srom for both MIMO and SISO boards, usable in
124− * the .130 4Kilobit OTP with hardware redundancy.
125− */
126−#define SROM8_BREV 65
127−
128−#define SROM8_BFL0 66
129−#define SROM8_BFL1 67
130−#define SROM8_BFL2 68
131−#define SROM8_BFL3 69
132−
133−#define SROM8_MACHI 70
134−#define SROM8_MACMID 71
135−#define SROM8_MACLO 72
136−
137−#define SROM8_CCODE 73
138−#define SROM8_REGREV 74
139−
140−#define SROM8_LEDBH10 75
141−#define SROM8_LEDBH32 76
142−
143−#define SROM8_LEDDC 77
144−
145−#define SROM8_AA 78
146−
147−#define SROM8_AG10 79
148−#define SROM8_AG32 80
149−
150−#define SROM8_TXRXC 81
151−
152−#define SROM8_BXARSSI2G 82
153−#define SROM8_BXARSSI5G 83
154−#define SROM8_TRI52G 84
155−#define SROM8_TRI5GHL 85
156−#define SROM8_RXPO52G 86
157−
158−#define SROM8_FEM2G 87
159−#define SROM8_FEM5G 88
160−#define SROM8_FEM_ANTSWLUT_MASK 0xf800
161−#define SROM8_FEM_ANTSWLUT_SHIFT 11
162−#define SROM8_FEM_TR_ISO_MASK 0x0700
163−#define SROM8_FEM_TR_ISO_SHIFT 8
164−#define SROM8_FEM_PDET_RANGE_MASK 0x00f8
165−#define SROM8_FEM_PDET_RANGE_SHIFT 3
166−#define SROM8_FEM_EXTPA_GAIN_MASK 0x0006
167−#define SROM8_FEM_EXTPA_GAIN_SHIFT 1
168−#define SROM8_FEM_TSSIPOS_MASK 0x0001
169−#define SROM8_FEM_TSSIPOS_SHIFT 0
170−
171−#define SROM8_THERMAL 89
172−
173−/* Temp sense related entries */
174−#define SROM8_MPWR_RAWTS 90
175−#define SROM8_TS_SLP_OPT_CORRX 91
176−/* FOC: freiquency offset correction, HWIQ: H/W IOCAL enable,
177− * IQSWP: IQ CAL swap disable */
178−#define SROM8_FOC_HWIQ_IQSWP 92
179−
180−/* Temperature delta for PHY calibration */
181−#define SROM8_PHYCAL_TEMPDELTA 93
182−
183−/* Per-path offsets & fields */
184−#define SROM8_PATH0 96
185−#define SROM8_PATH1 112
186−#define SROM8_PATH2 128
187−#define SROM8_PATH3 144
188−
189−#define SROM8_2G_ITT_MAXP 0
190−#define SROM8_2G_PA 1
191−#define SROM8_5G_ITT_MAXP 4
192−#define SROM8_5GLH_MAXP 5
193−#define SROM8_5G_PA 6
194−#define SROM8_5GL_PA 9
195−#define SROM8_5GH_PA 12
196−
197−/* All the miriad power offsets */
198−#define SROM8_2G_CCKPO 160
199−
200−#define SROM8_2G_OFDMPO 161
201−#define SROM8_5G_OFDMPO 163
202−#define SROM8_5GL_OFDMPO 165
203−#define SROM8_5GH_OFDMPO 167
204−
205−#define SROM8_2G_MCSPO 169
206−#define SROM8_5G_MCSPO 177
207−#define SROM8_5GL_MCSPO 185
208−#define SROM8_5GH_MCSPO 193
209−
210−#define SROM8_CDDPO 201
211−#define SROM8_STBCPO 202
212−#define SROM8_BW40PO 203
213−#define SROM8_BWDUPPO 204
214−
215−/* SISO PA parameters are in the path0 spaces */
216−#define SROM8_SISO 96
217−
218−/* Legacy names for SISO PA paramters */
219−#define SROM8_W0_ITTMAXP (SROM8_SISO + SROM8_2G_ITT_MAXP)
220−#define SROM8_W0_PAB0 (SROM8_SISO + SROM8_2G_PA)
221−#define SROM8_W0_PAB1 (SROM8_SISO + SROM8_2G_PA + 1)
222−#define SROM8_W0_PAB2 (SROM8_SISO + SROM8_2G_PA + 2)
223−#define SROM8_W1_ITTMAXP (SROM8_SISO + SROM8_5G_ITT_MAXP)
224−#define SROM8_W1_MAXP_LCHC (SROM8_SISO + SROM8_5GLH_MAXP)
225−#define SROM8_W1_PAB0 (SROM8_SISO + SROM8_5G_PA)
226−#define SROM8_W1_PAB1 (SROM8_SISO + SROM8_5G_PA + 1)
227−#define SROM8_W1_PAB2 (SROM8_SISO + SROM8_5G_PA + 2)
228−#define SROM8_W1_PAB0_LC (SROM8_SISO + SROM8_5GL_PA)
229−#define SROM8_W1_PAB1_LC (SROM8_SISO + SROM8_5GL_PA + 1)
230−#define SROM8_W1_PAB2_LC (SROM8_SISO + SROM8_5GL_PA + 2)
231−#define SROM8_W1_PAB0_HC (SROM8_SISO + SROM8_5GH_PA)
232−#define SROM8_W1_PAB1_HC (SROM8_SISO + SROM8_5GH_PA + 1)
233−#define SROM8_W1_PAB2_HC (SROM8_SISO + SROM8_5GH_PA + 2)
234−
235−/* SROM REV 9 */
236−#define SROM9_2GPO_CCKBW20 160
237−#define SROM9_2GPO_CCKBW20UL 161
238−#define SROM9_2GPO_LOFDMBW20 162
239−#define SROM9_2GPO_LOFDMBW20UL 164
240−
241−#define SROM9_5GLPO_LOFDMBW20 166
242−#define SROM9_5GLPO_LOFDMBW20UL 168
243−#define SROM9_5GMPO_LOFDMBW20 170
244−#define SROM9_5GMPO_LOFDMBW20UL 172
245−#define SROM9_5GHPO_LOFDMBW20 174
246−#define SROM9_5GHPO_LOFDMBW20UL 176
247−
248−#define SROM9_2GPO_MCSBW20 178
249−#define SROM9_2GPO_MCSBW20UL 180
250−#define SROM9_2GPO_MCSBW40 182
251−
252−#define SROM9_5GLPO_MCSBW20 184
253−#define SROM9_5GLPO_MCSBW20UL 186
254−#define SROM9_5GLPO_MCSBW40 188
255−#define SROM9_5GMPO_MCSBW20 190
256−#define SROM9_5GMPO_MCSBW20UL 192
257−#define SROM9_5GMPO_MCSBW40 194
258−#define SROM9_5GHPO_MCSBW20 196
259−#define SROM9_5GHPO_MCSBW20UL 198
260−#define SROM9_5GHPO_MCSBW40 200
261−
262−#define SROM9_PO_MCS32 202
263−#define SROM9_PO_LOFDM40DUP 203
264−
265−/* SROM flags (see sromvar_t) */
266−
267−/* value continues as described by the next entry */
268−#define SRFL_MORE 1
269−#define SRFL_NOFFS 2 /* value bits can't be all one's */
270−#define SRFL_PRHEX 4 /* value is in hexdecimal format */
271−#define SRFL_PRSIGN 8 /* value is in signed decimal format */
272−#define SRFL_CCODE 0x10 /* value is in country code format */
273−#define SRFL_ETHADDR 0x20 /* value is an Ethernet address */
274−#define SRFL_LEDDC 0x40 /* value is an LED duty cycle */
275−/* do not generate a nvram param, entry is for mfgc */
276−#define SRFL_NOVAR 0x80
277−
278−/* Max. nvram variable table size */
279−#define MAXSZ_NVRAM_VARS 4096
280−
281−/*
282− * indicates type of value.
283− */
284−enum brcms_srom_var_type {
285− BRCMS_SROM_STRING,
286− BRCMS_SROM_SNUMBER,
287− BRCMS_SROM_UNUMBER
288−};
289−
290−/*
291− * storage type for srom variable.
292− *
293− * var_list: for linked list operations.
294− * varid: identifier of the variable.
295− * var_type: type of variable.
296− * buf: variable value when var_type == BRCMS_SROM_STRING.
297− * uval: unsigned variable value when var_type == BRCMS_SROM_UNUMBER.
298− * sval: signed variable value when var_type == BRCMS_SROM_SNUMBER.
299− */
300−struct brcms_srom_list_head {
301− struct list_head var_list;
302− enum brcms_srom_id varid;
303− enum brcms_srom_var_type var_type;
304− union {
305− char buf[0];
306− u32 uval;
307− s32 sval;
308− };
309−};
310−
311−struct brcms_sromvar {
312− enum brcms_srom_id varid;
313− u32 revmask;
314− u32 flags;
315− u16 off;
316− u16 mask;
317−};
318−
319−struct brcms_varbuf {
320− char *base; /* pointer to buffer base */
321− char *buf; /* pointer to current position */
322− unsigned int size; /* current (residual) size in bytes */
323−};
324−
325−/*
326− * Assumptions:
327− * - Ethernet address spans across 3 consecutive words
328− *
329− * Table rules:
330− * - Add multiple entries next to each other if a value spans across multiple
331− * words (even multiple fields in the same word) with each entry except the
332− * last having it's SRFL_MORE bit set.
333− * - Ethernet address entry does not follow above rule and must not have
334− * SRFL_MORE bit set. Its SRFL_ETHADDR bit implies it takes multiple words.
335− * - The last entry's name field must be NULL to indicate the end of the table.
336− * Other entries must have non-NULL name.
337− */
338−static const struct brcms_sromvar pci_sromvars[] = {
339− {BRCMS_SROM_DEVID, 0xffffff00, SRFL_PRHEX | SRFL_NOVAR, PCI_F0DEVID,
340− 0xffff},
341− {BRCMS_SROM_BOARDREV, 0xffffff00, SRFL_PRHEX, SROM8_BREV, 0xffff},
342− {BRCMS_SROM_BOARDFLAGS, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL0,
343− 0xffff},
344− {BRCMS_SROM_CONT, 0, 0, SROM8_BFL1, 0xffff},
345− {BRCMS_SROM_BOARDFLAGS2, 0xffffff00, SRFL_PRHEX | SRFL_MORE, SROM8_BFL2,
346− 0xffff},
347− {BRCMS_SROM_CONT, 0, 0, SROM8_BFL3, 0xffff},
348− {BRCMS_SROM_BOARDTYPE, 0xfffffffc, SRFL_PRHEX, SROM_SSID, 0xffff},
349− {BRCMS_SROM_BOARDNUM, 0xffffff00, 0, SROM8_MACLO, 0xffff},
350− {BRCMS_SROM_REGREV, 0xffffff00, 0, SROM8_REGREV, 0x00ff},
351− {BRCMS_SROM_LEDBH0, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0x00ff},
352− {BRCMS_SROM_LEDBH1, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH10, 0xff00},
353− {BRCMS_SROM_LEDBH2, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0x00ff},
354− {BRCMS_SROM_LEDBH3, 0xffffff00, SRFL_NOFFS, SROM8_LEDBH32, 0xff00},
355− {BRCMS_SROM_PA0B0, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB0, 0xffff},
356− {BRCMS_SROM_PA0B1, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB1, 0xffff},
357− {BRCMS_SROM_PA0B2, 0xffffff00, SRFL_PRHEX, SROM8_W0_PAB2, 0xffff},
358− {BRCMS_SROM_PA0ITSSIT, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0xff00},
359− {BRCMS_SROM_PA0MAXPWR, 0xffffff00, 0, SROM8_W0_ITTMAXP, 0x00ff},
360− {BRCMS_SROM_OPO, 0xffffff00, 0, SROM8_2G_OFDMPO, 0x00ff},
361− {BRCMS_SROM_AA2G, 0xffffff00, 0, SROM8_AA, 0x00ff},
362− {BRCMS_SROM_AA5G, 0xffffff00, 0, SROM8_AA, 0xff00},
363− {BRCMS_SROM_AG0, 0xffffff00, 0, SROM8_AG10, 0x00ff},
364− {BRCMS_SROM_AG1, 0xffffff00, 0, SROM8_AG10, 0xff00},
365− {BRCMS_SROM_AG2, 0xffffff00, 0, SROM8_AG32, 0x00ff},
366− {BRCMS_SROM_AG3, 0xffffff00, 0, SROM8_AG32, 0xff00},
367− {BRCMS_SROM_PA1B0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0, 0xffff},
368− {BRCMS_SROM_PA1B1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1, 0xffff},
369− {BRCMS_SROM_PA1B2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2, 0xffff},
370− {BRCMS_SROM_PA1LOB0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0_LC, 0xffff},
371− {BRCMS_SROM_PA1LOB1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1_LC, 0xffff},
372− {BRCMS_SROM_PA1LOB2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2_LC, 0xffff},
373− {BRCMS_SROM_PA1HIB0, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB0_HC, 0xffff},
374− {BRCMS_SROM_PA1HIB1, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB1_HC, 0xffff},
375− {BRCMS_SROM_PA1HIB2, 0xffffff00, SRFL_PRHEX, SROM8_W1_PAB2_HC, 0xffff},
376− {BRCMS_SROM_PA1ITSSIT, 0xffffff00, 0, SROM8_W1_ITTMAXP, 0xff00},
377− {BRCMS_SROM_PA1MAXPWR, 0xffffff00, 0, SROM8_W1_ITTMAXP, 0x00ff},
378− {BRCMS_SROM_PA1LOMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0xff00},
379− {BRCMS_SROM_PA1HIMAXPWR, 0xffffff00, 0, SROM8_W1_MAXP_LCHC, 0x00ff},
380− {BRCMS_SROM_BXA2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x1800},
381− {BRCMS_SROM_RSSISAV2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x0700},
382− {BRCMS_SROM_RSSISMC2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x00f0},
383− {BRCMS_SROM_RSSISMF2G, 0xffffff00, 0, SROM8_BXARSSI2G, 0x000f},
384− {BRCMS_SROM_BXA5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x1800},
385− {BRCMS_SROM_RSSISAV5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x0700},
386− {BRCMS_SROM_RSSISMC5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x00f0},
387− {BRCMS_SROM_RSSISMF5G, 0xffffff00, 0, SROM8_BXARSSI5G, 0x000f},
388− {BRCMS_SROM_TRI2G, 0xffffff00, 0, SROM8_TRI52G, 0x00ff},
389− {BRCMS_SROM_TRI5G, 0xffffff00, 0, SROM8_TRI52G, 0xff00},
390− {BRCMS_SROM_TRI5GL, 0xffffff00, 0, SROM8_TRI5GHL, 0x00ff},
391− {BRCMS_SROM_TRI5GH, 0xffffff00, 0, SROM8_TRI5GHL, 0xff00},
392− {BRCMS_SROM_RXPO2G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0x00ff},
393− {BRCMS_SROM_RXPO5G, 0xffffff00, SRFL_PRSIGN, SROM8_RXPO52G, 0xff00},
394− {BRCMS_SROM_TXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC,
395− SROM4_TXCHAIN_MASK},
396− {BRCMS_SROM_RXCHAIN, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC,
397− SROM4_RXCHAIN_MASK},
398− {BRCMS_SROM_ANTSWITCH, 0xffffff00, SRFL_NOFFS, SROM8_TXRXC,
399− SROM4_SWITCH_MASK},
400− {BRCMS_SROM_TSSIPOS2G, 0xffffff00, 0, SROM8_FEM2G,
401− SROM8_FEM_TSSIPOS_MASK},
402− {BRCMS_SROM_EXTPAGAIN2G, 0xffffff00, 0, SROM8_FEM2G,
403− SROM8_FEM_EXTPA_GAIN_MASK},
404− {BRCMS_SROM_PDETRANGE2G, 0xffffff00, 0, SROM8_FEM2G,
405− SROM8_FEM_PDET_RANGE_MASK},
406− {BRCMS_SROM_TRISO2G, 0xffffff00, 0, SROM8_FEM2G, SROM8_FEM_TR_ISO_MASK},
407− {BRCMS_SROM_ANTSWCTL2G, 0xffffff00, 0, SROM8_FEM2G,
408− SROM8_FEM_ANTSWLUT_MASK},
409− {BRCMS_SROM_TSSIPOS5G, 0xffffff00, 0, SROM8_FEM5G,
410− SROM8_FEM_TSSIPOS_MASK},
411− {BRCMS_SROM_EXTPAGAIN5G, 0xffffff00, 0, SROM8_FEM5G,
412− SROM8_FEM_EXTPA_GAIN_MASK},
413− {BRCMS_SROM_PDETRANGE5G, 0xffffff00, 0, SROM8_FEM5G,
414− SROM8_FEM_PDET_RANGE_MASK},
415− {BRCMS_SROM_TRISO5G, 0xffffff00, 0, SROM8_FEM5G, SROM8_FEM_TR_ISO_MASK},
416− {BRCMS_SROM_ANTSWCTL5G, 0xffffff00, 0, SROM8_FEM5G,
417− SROM8_FEM_ANTSWLUT_MASK},
418− {BRCMS_SROM_TEMPTHRESH, 0xffffff00, 0, SROM8_THERMAL, 0xff00},
419− {BRCMS_SROM_TEMPOFFSET, 0xffffff00, 0, SROM8_THERMAL, 0x00ff},
420−
421− {BRCMS_SROM_CCODE, 0xffffff00, SRFL_CCODE, SROM8_CCODE, 0xffff},
422− {BRCMS_SROM_MACADDR, 0xffffff00, SRFL_ETHADDR, SROM8_MACHI, 0xffff},
423− {BRCMS_SROM_LEDDC, 0xffffff00, SRFL_NOFFS | SRFL_LEDDC, SROM8_LEDDC,
424− 0xffff},
425− {BRCMS_SROM_RAWTEMPSENSE, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS,
426− 0x01ff},
427− {BRCMS_SROM_MEASPOWER, 0xffffff00, SRFL_PRHEX, SROM8_MPWR_RAWTS,
428− 0xfe00},
429− {BRCMS_SROM_TEMPSENSE_SLOPE, 0xffffff00, SRFL_PRHEX,
430− SROM8_TS_SLP_OPT_CORRX, 0x00ff},
431− {BRCMS_SROM_TEMPCORRX, 0xffffff00, SRFL_PRHEX, SROM8_TS_SLP_OPT_CORRX,
432− 0xfc00},
433− {BRCMS_SROM_TEMPSENSE_OPTION, 0xffffff00, SRFL_PRHEX,
434− SROM8_TS_SLP_OPT_CORRX, 0x0300},
435− {BRCMS_SROM_FREQOFFSET_CORR, 0xffffff00, SRFL_PRHEX,
436− SROM8_FOC_HWIQ_IQSWP, 0x000f},
437− {BRCMS_SROM_IQCAL_SWP_DIS, 0xffffff00, SRFL_PRHEX, SROM8_FOC_HWIQ_IQSWP,
438− 0x0010},
439− {BRCMS_SROM_HW_IQCAL_EN, 0xffffff00, SRFL_PRHEX, SROM8_FOC_HWIQ_IQSWP,
440− 0x0020},
441− {BRCMS_SROM_PHYCAL_TEMPDELTA, 0xffffff00, 0, SROM8_PHYCAL_TEMPDELTA,
442− 0x00ff},
443−
444− {BRCMS_SROM_CCK2GPO, 0x00000100, 0, SROM8_2G_CCKPO, 0xffff},
445− {BRCMS_SROM_OFDM2GPO, 0x00000100, SRFL_MORE, SROM8_2G_OFDMPO, 0xffff},
446− {BRCMS_SROM_CONT, 0, 0, SROM8_2G_OFDMPO + 1, 0xffff},
447− {BRCMS_SROM_OFDM5GPO, 0x00000100, SRFL_MORE, SROM8_5G_OFDMPO, 0xffff},
448− {BRCMS_SROM_CONT, 0, 0, SROM8_5G_OFDMPO + 1, 0xffff},
449− {BRCMS_SROM_OFDM5GLPO, 0x00000100, SRFL_MORE, SROM8_5GL_OFDMPO, 0xffff},
450− {BRCMS_SROM_CONT, 0, 0, SROM8_5GL_OFDMPO + 1, 0xffff},
451− {BRCMS_SROM_OFDM5GHPO, 0x00000100, SRFL_MORE, SROM8_5GH_OFDMPO, 0xffff},
452− {BRCMS_SROM_CONT, 0, 0, SROM8_5GH_OFDMPO + 1, 0xffff},
453− {BRCMS_SROM_MCS2GPO0, 0x00000100, 0, SROM8_2G_MCSPO, 0xffff},
454− {BRCMS_SROM_MCS2GPO1, 0x00000100, 0, SROM8_2G_MCSPO + 1, 0xffff},
455− {BRCMS_SROM_MCS2GPO2, 0x00000100, 0, SROM8_2G_MCSPO + 2, 0xffff},
456− {BRCMS_SROM_MCS2GPO3, 0x00000100, 0, SROM8_2G_MCSPO + 3, 0xffff},
457− {BRCMS_SROM_MCS2GPO4, 0x00000100, 0, SROM8_2G_MCSPO + 4, 0xffff},
458− {BRCMS_SROM_MCS2GPO5, 0x00000100, 0, SROM8_2G_MCSPO + 5, 0xffff},
459− {BRCMS_SROM_MCS2GPO6, 0x00000100, 0, SROM8_2G_MCSPO + 6, 0xffff},
460− {BRCMS_SROM_MCS2GPO7, 0x00000100, 0, SROM8_2G_MCSPO + 7, 0xffff},
461− {BRCMS_SROM_MCS5GPO0, 0x00000100, 0, SROM8_5G_MCSPO, 0xffff},
462− {BRCMS_SROM_MCS5GPO1, 0x00000100, 0, SROM8_5G_MCSPO + 1, 0xffff},
463− {BRCMS_SROM_MCS5GPO2, 0x00000100, 0, SROM8_5G_MCSPO + 2, 0xffff},
464− {BRCMS_SROM_MCS5GPO3, 0x00000100, 0, SROM8_5G_MCSPO + 3, 0xffff},
465− {BRCMS_SROM_MCS5GPO4, 0x00000100, 0, SROM8_5G_MCSPO + 4, 0xffff},
466− {BRCMS_SROM_MCS5GPO5, 0x00000100, 0, SROM8_5G_MCSPO + 5, 0xffff},
467− {BRCMS_SROM_MCS5GPO6, 0x00000100, 0, SROM8_5G_MCSPO + 6, 0xffff},
468− {BRCMS_SROM_MCS5GPO7, 0x00000100, 0, SROM8_5G_MCSPO + 7, 0xffff},
469− {BRCMS_SROM_MCS5GLPO0, 0x00000100, 0, SROM8_5GL_MCSPO, 0xffff},
470− {BRCMS_SROM_MCS5GLPO1, 0x00000100, 0, SROM8_5GL_MCSPO + 1, 0xffff},
471− {BRCMS_SROM_MCS5GLPO2, 0x00000100, 0, SROM8_5GL_MCSPO + 2, 0xffff},
472− {BRCMS_SROM_MCS5GLPO3, 0x00000100, 0, SROM8_5GL_MCSPO + 3, 0xffff},
473− {BRCMS_SROM_MCS5GLPO4, 0x00000100, 0, SROM8_5GL_MCSPO + 4, 0xffff},
474− {BRCMS_SROM_MCS5GLPO5, 0x00000100, 0, SROM8_5GL_MCSPO + 5, 0xffff},
475− {BRCMS_SROM_MCS5GLPO6, 0x00000100, 0, SROM8_5GL_MCSPO + 6, 0xffff},
476− {BRCMS_SROM_MCS5GLPO7, 0x00000100, 0, SROM8_5GL_MCSPO + 7, 0xffff},
477− {BRCMS_SROM_MCS5GHPO0, 0x00000100, 0, SROM8_5GH_MCSPO, 0xffff},
478− {BRCMS_SROM_MCS5GHPO1, 0x00000100, 0, SROM8_5GH_MCSPO + 1, 0xffff},
479− {BRCMS_SROM_MCS5GHPO2, 0x00000100, 0, SROM8_5GH_MCSPO + 2, 0xffff},
480− {BRCMS_SROM_MCS5GHPO3, 0x00000100, 0, SROM8_5GH_MCSPO + 3, 0xffff},
481− {BRCMS_SROM_MCS5GHPO4, 0x00000100, 0, SROM8_5GH_MCSPO + 4, 0xffff},
482− {BRCMS_SROM_MCS5GHPO5, 0x00000100, 0, SROM8_5GH_MCSPO + 5, 0xffff},
483− {BRCMS_SROM_MCS5GHPO6, 0x00000100, 0, SROM8_5GH_MCSPO + 6, 0xffff},
484− {BRCMS_SROM_MCS5GHPO7, 0x00000100, 0, SROM8_5GH_MCSPO + 7, 0xffff},
485− {BRCMS_SROM_CDDPO, 0x00000100, 0, SROM8_CDDPO, 0xffff},
486− {BRCMS_SROM_STBCPO, 0x00000100, 0, SROM8_STBCPO, 0xffff},
487− {BRCMS_SROM_BW40PO, 0x00000100, 0, SROM8_BW40PO, 0xffff},
488− {BRCMS_SROM_BWDUPPO, 0x00000100, 0, SROM8_BWDUPPO, 0xffff},
489−
490− /* power per rate from sromrev 9 */
491− {BRCMS_SROM_CCKBW202GPO, 0xfffffe00, 0, SROM9_2GPO_CCKBW20, 0xffff},
492− {BRCMS_SROM_CCKBW20UL2GPO, 0xfffffe00, 0, SROM9_2GPO_CCKBW20UL, 0xffff},
493− {BRCMS_SROM_LEGOFDMBW202GPO, 0xfffffe00, SRFL_MORE,
494− SROM9_2GPO_LOFDMBW20, 0xffff},
495− {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_LOFDMBW20 + 1, 0xffff},
496− {BRCMS_SROM_LEGOFDMBW20UL2GPO, 0xfffffe00, SRFL_MORE,
497− SROM9_2GPO_LOFDMBW20UL, 0xffff},
498− {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_LOFDMBW20UL + 1, 0xffff},
499− {BRCMS_SROM_LEGOFDMBW205GLPO, 0xfffffe00, SRFL_MORE,
500− SROM9_5GLPO_LOFDMBW20, 0xffff},
501− {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_LOFDMBW20 + 1, 0xffff},
502− {BRCMS_SROM_LEGOFDMBW20UL5GLPO, 0xfffffe00, SRFL_MORE,
503− SROM9_5GLPO_LOFDMBW20UL, 0xffff},
504− {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_LOFDMBW20UL + 1, 0xffff},
505− {BRCMS_SROM_LEGOFDMBW205GMPO, 0xfffffe00, SRFL_MORE,
506− SROM9_5GMPO_LOFDMBW20, 0xffff},
507− {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_LOFDMBW20 + 1, 0xffff},
508− {BRCMS_SROM_LEGOFDMBW20UL5GMPO, 0xfffffe00, SRFL_MORE,
509− SROM9_5GMPO_LOFDMBW20UL, 0xffff},
510− {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_LOFDMBW20UL + 1, 0xffff},
511− {BRCMS_SROM_LEGOFDMBW205GHPO, 0xfffffe00, SRFL_MORE,
512− SROM9_5GHPO_LOFDMBW20, 0xffff},
513− {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_LOFDMBW20 + 1, 0xffff},
514− {BRCMS_SROM_LEGOFDMBW20UL5GHPO, 0xfffffe00, SRFL_MORE,
515− SROM9_5GHPO_LOFDMBW20UL, 0xffff},
516− {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_LOFDMBW20UL + 1, 0xffff},
517− {BRCMS_SROM_MCSBW202GPO, 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW20,
518− 0xffff},
519− {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_MCSBW20 + 1, 0xffff},
520− {BRCMS_SROM_MCSBW20UL2GPO, 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW20UL,
521− 0xffff},
522− {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_MCSBW20UL + 1, 0xffff},
523− {BRCMS_SROM_MCSBW402GPO, 0xfffffe00, SRFL_MORE, SROM9_2GPO_MCSBW40,
524− 0xffff},
525− {BRCMS_SROM_CONT, 0, 0, SROM9_2GPO_MCSBW40 + 1, 0xffff},
526− {BRCMS_SROM_MCSBW205GLPO, 0xfffffe00, SRFL_MORE, SROM9_5GLPO_MCSBW20,
527− 0xffff},
528− {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_MCSBW20 + 1, 0xffff},
529− {BRCMS_SROM_MCSBW20UL5GLPO, 0xfffffe00, SRFL_MORE,
530− SROM9_5GLPO_MCSBW20UL, 0xffff},
531− {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_MCSBW20UL + 1, 0xffff},
532− {BRCMS_SROM_MCSBW405GLPO, 0xfffffe00, SRFL_MORE, SROM9_5GLPO_MCSBW40,
533− 0xffff},
534− {BRCMS_SROM_CONT, 0, 0, SROM9_5GLPO_MCSBW40 + 1, 0xffff},
535− {BRCMS_SROM_MCSBW205GMPO, 0xfffffe00, SRFL_MORE, SROM9_5GMPO_MCSBW20,
536− 0xffff},
537− {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_MCSBW20 + 1, 0xffff},
538− {BRCMS_SROM_MCSBW20UL5GMPO, 0xfffffe00, SRFL_MORE,
539− SROM9_5GMPO_MCSBW20UL, 0xffff},
540− {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_MCSBW20UL + 1, 0xffff},
541− {BRCMS_SROM_MCSBW405GMPO, 0xfffffe00, SRFL_MORE, SROM9_5GMPO_MCSBW40,
542− 0xffff},
543− {BRCMS_SROM_CONT, 0, 0, SROM9_5GMPO_MCSBW40 + 1, 0xffff},
544− {BRCMS_SROM_MCSBW205GHPO, 0xfffffe00, SRFL_MORE, SROM9_5GHPO_MCSBW20,
545− 0xffff},
546− {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_MCSBW20 + 1, 0xffff},
547− {BRCMS_SROM_MCSBW20UL5GHPO, 0xfffffe00, SRFL_MORE,
548− SROM9_5GHPO_MCSBW20UL, 0xffff},
549− {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_MCSBW20UL + 1, 0xffff},
550− {BRCMS_SROM_MCSBW405GHPO, 0xfffffe00, SRFL_MORE, SROM9_5GHPO_MCSBW40,
551− 0xffff},
552− {BRCMS_SROM_CONT, 0, 0, SROM9_5GHPO_MCSBW40 + 1, 0xffff},
553− {BRCMS_SROM_MCS32PO, 0xfffffe00, 0, SROM9_PO_MCS32, 0xffff},
554− {BRCMS_SROM_LEGOFDM40DUPPO, 0xfffffe00, 0, SROM9_PO_LOFDM40DUP, 0xffff},
555−
556− {BRCMS_SROM_NULL, 0, 0, 0, 0}
557−};
558−
559−static const struct brcms_sromvar perpath_pci_sromvars[] = {
560− {BRCMS_SROM_MAXP2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0x00ff},
561− {BRCMS_SROM_ITT2GA0, 0xffffff00, 0, SROM8_2G_ITT_MAXP, 0xff00},
562− {BRCMS_SROM_ITT5GA0, 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0xff00},
563− {BRCMS_SROM_PA2GW0A0, 0xffffff00, SRFL_PRHEX, SROM8_2G_PA, 0xffff},
564− {BRCMS_SROM_PA2GW1A0, 0xffffff00, SRFL_PRHEX, SROM8_2G_PA + 1, 0xffff},
565− {BRCMS_SROM_PA2GW2A0, 0xffffff00, SRFL_PRHEX, SROM8_2G_PA + 2, 0xffff},
566− {BRCMS_SROM_MAXP5GA0, 0xffffff00, 0, SROM8_5G_ITT_MAXP, 0x00ff},
567− {BRCMS_SROM_MAXP5GHA0, 0xffffff00, 0, SROM8_5GLH_MAXP, 0x00ff},
568− {BRCMS_SROM_MAXP5GLA0, 0xffffff00, 0, SROM8_5GLH_MAXP, 0xff00},
569− {BRCMS_SROM_PA5GW0A0, 0xffffff00, SRFL_PRHEX, SROM8_5G_PA, 0xffff},
570− {BRCMS_SROM_PA5GW1A0, 0xffffff00, SRFL_PRHEX, SROM8_5G_PA + 1, 0xffff},
571− {BRCMS_SROM_PA5GW2A0, 0xffffff00, SRFL_PRHEX, SROM8_5G_PA + 2, 0xffff},
572− {BRCMS_SROM_PA5GLW0A0, 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA, 0xffff},
573− {BRCMS_SROM_PA5GLW1A0, 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA + 1,
574− 0xffff},
575− {BRCMS_SROM_PA5GLW2A0, 0xffffff00, SRFL_PRHEX, SROM8_5GL_PA + 2,
576− 0xffff},
577− {BRCMS_SROM_PA5GHW0A0, 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA, 0xffff},
578− {BRCMS_SROM_PA5GHW1A0, 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA + 1,
579− 0xffff},
580− {BRCMS_SROM_PA5GHW2A0, 0xffffff00, SRFL_PRHEX, SROM8_5GH_PA + 2,
581− 0xffff},
582− {BRCMS_SROM_NULL, 0, 0, 0, 0}
583−};
584−
585−/* crc table has the same contents for every device instance, so it can be
586− * shared between devices. */
587−static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE];
588−
589−static uint mask_shift(u16 mask)
590−{
591− uint i;
592− for (i = 0; i < (sizeof(mask) << 3); i++) {
593− if (mask & (1 << i))
594− return i;
595− }
596− return 0;
597−}
598−
599−static uint mask_width(u16 mask)
600−{
601− int i;
602− for (i = (sizeof(mask) << 3) - 1; i >= 0; i--) {
603− if (mask & (1 << i))
604− return (uint) (i - mask_shift(mask) + 1);
605− }
606− return 0;
607−}
608−
609−static inline void le16_to_cpu_buf(u16 *buf, uint nwords)
610−{
611− while (nwords--)
612− *(buf + nwords) = le16_to_cpu(*(__le16 *)(buf + nwords));
613−}
614−
615−static inline void cpu_to_le16_buf(u16 *buf, uint nwords)
616−{
617− while (nwords--)
618− *(__le16 *)(buf + nwords) = cpu_to_le16(*(buf + nwords));
619−}
620−
621−/*
622− * convert binary srom data into linked list of srom variable items.
623− */
624−static int
625−_initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list)
626−{
627− struct brcms_srom_list_head *entry;
628− enum brcms_srom_id id;
629− u16 w;
630− u32 val = 0;
631− const struct brcms_sromvar *srv;
632− uint width;
633− uint flags;
634− u32 sr = (1 << sromrev);
635− uint p;
636− uint pb = SROM8_PATH0;
637− const uint psz = SROM8_PATH1 - SROM8_PATH0;
638−
639− /* first store the srom revision */
640− entry = kzalloc(sizeof(struct brcms_srom_list_head), GFP_KERNEL);
641− if (!entry)
642− return -ENOMEM;
643−
644− entry->varid = BRCMS_SROM_REV;
645− entry->var_type = BRCMS_SROM_UNUMBER;
646− entry->uval = sromrev;
647− list_add(&entry->var_list, var_list);
648−
649− for (srv = pci_sromvars; srv->varid != BRCMS_SROM_NULL; srv++) {
650− enum brcms_srom_var_type type;
651− u8 ea[ETH_ALEN];
652− u8 extra_space = 0;
653−
654− if ((srv->revmask & sr) == 0)
655− continue;
656−
657− flags = srv->flags;
658− id = srv->varid;
659−
660− /* This entry is for mfgc only. Don't generate param for it, */
661− if (flags & SRFL_NOVAR)
662− continue;
663−
664− if (flags & SRFL_ETHADDR) {
665− /*
666− * stored in string format XX:XX:XX:XX:XX:XX (17 chars)
667− */
668− ea[0] = (srom[srv->off] >> 8) & 0xff;
669− ea[1] = srom[srv->off] & 0xff;
670− ea[2] = (srom[srv->off + 1] >> 8) & 0xff;
671− ea[3] = srom[srv->off + 1] & 0xff;
672− ea[4] = (srom[srv->off + 2] >> 8) & 0xff;
673− ea[5] = srom[srv->off + 2] & 0xff;
674− /* 17 characters + string terminator - union size */
675− extra_space = 18 - sizeof(s32);
676− type = BRCMS_SROM_STRING;
677− } else {
678− w = srom[srv->off];
679− val = (w & srv->mask) >> mask_shift(srv->mask);
680− width = mask_width(srv->mask);
681−
682− while (srv->flags & SRFL_MORE) {
683− srv++;
684− if (srv->off == 0)
685− continue;
686−
687− w = srom[srv->off];
688− val +=
689− ((w & srv->mask) >> mask_shift(srv->
690− mask)) <<
691− width;
692− width += mask_width(srv->mask);
693− }
694−
695− if ((flags & SRFL_NOFFS)
696− && ((int)val == (1 << width) - 1))
697− continue;
698−
699− if (flags & SRFL_CCODE) {
700− type = BRCMS_SROM_STRING;
701− } else if (flags & SRFL_LEDDC) {
702− /* LED Powersave duty cycle has to be scaled:
703− *(oncount >> 24) (offcount >> 8)
704− */
705− u32 w32 = /* oncount */
706− (((val >> 8) & 0xff) << 24) |
707− /* offcount */
708− (((val & 0xff)) << 8);
709− type = BRCMS_SROM_UNUMBER;
710− val = w32;
711− } else if ((flags & SRFL_PRSIGN)
712− && (val & (1 << (width - 1)))) {
713− type = BRCMS_SROM_SNUMBER;
714− val |= ~0 << width;
715− } else
716− type = BRCMS_SROM_UNUMBER;
717− }
718−
719− entry = kzalloc(sizeof(struct brcms_srom_list_head) +
720− extra_space, GFP_KERNEL);
721− if (!entry)
722− return -ENOMEM;
723− entry->varid = id;
724− entry->var_type = type;
725− if (flags & SRFL_ETHADDR) {
726− snprintf(entry->buf, 18, "%pM", ea);
727− } else if (flags & SRFL_CCODE) {
728− if (val == 0)
729− entry->buf[0] = '\0';
730− else
731− snprintf(entry->buf, 3, "%c%c",
732− (val >> 8), (val & 0xff));
733− } else {
734− entry->uval = val;
735− }
736−
737− list_add(&entry->var_list, var_list);
738− }
739−
740− for (p = 0; p < MAX_PATH_SROM; p++) {
741− for (srv = perpath_pci_sromvars;
742− srv->varid != BRCMS_SROM_NULL; srv++) {
743− if ((srv->revmask & sr) == 0)
744− continue;
745−
746− if (srv->flags & SRFL_NOVAR)
747− continue;
748−
749− w = srom[pb + srv->off];
750− val = (w & srv->mask) >> mask_shift(srv->mask);
751− width = mask_width(srv->mask);
752−
753− /* Cheating: no per-path var is more than
754− * 1 word */
755− if ((srv->flags & SRFL_NOFFS)
756− && ((int)val == (1 << width) - 1))
757− continue;
758−
759− entry =
760− kzalloc(sizeof(struct brcms_srom_list_head),
761− GFP_KERNEL);
762− if (!entry)
763− return -ENOMEM;
764− entry->varid = srv->varid+p;
765− entry->var_type = BRCMS_SROM_UNUMBER;
766− entry->uval = val;
767− list_add(&entry->var_list, var_list);
768− }
769− pb += psz;
770− }
771− return 0;
772−}
773−
774−/*
775− * The crc check is done on a little-endian array, we need
776− * to switch the bytes around before checking crc (and
777− * then switch it back).
778− */
779−static int do_crc_check(u16 *buf, unsigned nwords)
780−{
781− u8 crc;
782−
783− cpu_to_le16_buf(buf, nwords);
784− crc = crc8(brcms_srom_crc8_table, (void *)buf, nwords << 1, CRC8_INIT_VALUE);
785− le16_to_cpu_buf(buf, nwords);
786−
787− return crc == CRC8_GOOD_VALUE(brcms_srom_crc8_table);
788−}
789−
790−/*
791− * Read in and validate sprom.
792− * Return 0 on success, nonzero on error.
793− */
794−static int
795−sprom_read_pci(struct si_pub *sih, u16 *buf, uint nwords, bool check_crc)
796−{
797− int err = 0;
798− uint i;
799− struct bcma_device *core;
800− uint sprom_offset;
801−
802− /* determine core to read */
803− if (ai_get_ccrev(sih) < 32) {
804− core = ai_findcore(sih, BCMA_CORE_80211, 0);
805− sprom_offset = PCI_BAR0_SPROM_OFFSET;
806− } else {
807− core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);
808− sprom_offset = CHIPCREGOFFS(sromotp);
809− }
810−
811− /* read the sprom */
812− for (i = 0; i < nwords; i++)
813− buf[i] = bcma_read16(core, sprom_offset+i*2);
814−
815− if (buf[0] == 0xffff)
816− /*
817− * The hardware thinks that an srom that starts with
818− * 0xffff is blank, regardless of the rest of the
819− * content, so declare it bad.
820− */
821− return -ENODATA;
822−
823− if (check_crc && !do_crc_check(buf, nwords))
824− err = -EIO;
825−
826− return err;
827−}
828−
829−static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords)
830−{
831− u8 *otp;
832− uint sz = OTP_SZ_MAX / 2; /* size in words */
833− int err = 0;
834−
835− otp = kzalloc(OTP_SZ_MAX, GFP_ATOMIC);
836− if (otp == NULL)
837− return -ENOMEM;
838−
839− err = otp_read_region(sih, OTP_HW_RGN, (u16 *) otp, &sz);
840−
841− sz = min_t(uint, sz, nwords);
842− memcpy(buf, otp, sz * 2);
843−
844− kfree(otp);
845−
846− /* Check CRC */
847− if (buf[0] == 0xffff)
848− /* The hardware thinks that an srom that starts with 0xffff
849− * is blank, regardless of the rest of the content, so declare
850− * it bad.
851− */
852− return -ENODATA;
853−
854− /* fixup the endianness so crc8 will pass */
855− cpu_to_le16_buf(buf, sz);
856− if (crc8(brcms_srom_crc8_table, (u8 *) buf, sz * 2,
857− CRC8_INIT_VALUE) != CRC8_GOOD_VALUE(brcms_srom_crc8_table))
858− err = -EIO;
859− else
860− /* now correct the endianness of the byte array */
861− le16_to_cpu_buf(buf, sz);
862−
863− return err;
864−}
865−
866−/*
867− * Initialize nonvolatile variable table from sprom.
868− * Return 0 on success, nonzero on error.
869− */
870−int srom_var_init(struct si_pub *sih)
871−{
872− u16 *srom;
873− u8 sromrev = 0;
874− u32 sr;
875− int err = 0;
876−
877− /*
878− * Apply CRC over SROM content regardless SROM is present or not.
879− */
880− srom = kmalloc(SROM_MAX, GFP_ATOMIC);
881− if (!srom)
882− return -ENOMEM;
883−
884− crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY);
885− if (ai_is_sprom_available(sih)) {
886− err = sprom_read_pci(sih, srom, SROM4_WORDS, true);
887−
888− if (err == 0)
889− /* srom read and passed crc */
890− /* top word of sprom contains version and crc8 */
891− sromrev = srom[SROM4_CRCREV] & 0xff;
892− } else {
893− /* Use OTP if SPROM not available */
894− err = otp_read_pci(sih, srom, SROM4_WORDS);
895− if (err == 0)
896− /* OTP only contain SROM rev8/rev9 for now */
897− sromrev = srom[SROM4_CRCREV] & 0xff;
898− }
899−
900− if (!err) {
901− struct si_info *sii = (struct si_info *)sih;
902−
903− /* Bitmask for the sromrev */
904− sr = 1 << sromrev;
905−
906− /*
907− * srom version check: Current valid versions: 8, 9
908− */
909− if ((sr & 0x300) == 0) {
910− err = -EINVAL;
911− goto errout;
912− }
913−
914− INIT_LIST_HEAD(&sii->var_list);
915−
916− /* parse SROM into name=value pairs. */
917− err = _initvars_srom_pci(sromrev, srom, &sii->var_list);
918− if (err)
919− srom_free_vars(sih);
920− }
921−
922−errout:
923− kfree(srom);
924− return err;
925−}
926−
927−void srom_free_vars(struct si_pub *sih)
928−{
929− struct si_info *sii;
930− struct brcms_srom_list_head *entry, *next;
931−
932− sii = (struct si_info *)sih;
933− list_for_each_entry_safe(entry, next, &sii->var_list, var_list) {
934− list_del(&entry->var_list);
935− kfree(entry);
936− }
937−}
938−
939−/*
940− * Search the name=value vars for a specific one and return its value.
941− * Returns NULL if not found.
942− */
943−char *getvar(struct si_pub *sih, enum brcms_srom_id id)
944−{
945− struct si_info *sii;
946− struct brcms_srom_list_head *entry;
947−
948− sii = (struct si_info *)sih;
949−
950− list_for_each_entry(entry, &sii->var_list, var_list)
951− if (entry->varid == id)
952− return &entry->buf[0];
953−
954− /* nothing found */
955− return NULL;
956−}
957−
958−/*
959− * Search the vars for a specific one and return its value as
960− * an integer. Returns 0 if not found.-
961− */
962−int getintvar(struct si_pub *sih, enum brcms_srom_id id)
963−{
964− struct si_info *sii;
965− struct brcms_srom_list_head *entry;
966− unsigned long res;
967−
968− sii = (struct si_info *)sih;
969−
970− list_for_each_entry(entry, &sii->var_list, var_list)
971− if (entry->varid == id) {
972− if (entry->var_type == BRCMS_SROM_SNUMBER ||
973− entry->var_type == BRCMS_SROM_UNUMBER)
974− return (int)entry->sval;
975− else if (!kstrtoul(&entry->buf[0], 0, &res))
976− return (int)res;
977− }
978−
979− return 0;
980−}
drivers/net/wireless/brcm80211/brcmsmac/srom.h+0−29
@@ -1,29 +0,0 @@
1−/*
2− * Copyright (c) 2010 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 _BRCM_SROM_H_
18−#define _BRCM_SROM_H_
19−
20−#include "types.h"
21−
22−/* Prototypes */
23−extern int srom_var_init(struct si_pub *sih);
24−extern void srom_free_vars(struct si_pub *sih);
25−
26−extern int srom_read(struct si_pub *sih, uint bus, void *curmap,
27− uint byteoff, uint nbytes, u16 *buf, bool check_crc);
28−
29−#endif /* _BRCM_SROM_H_ */
drivers/net/wireless/brcm80211/brcmsmac/stf.c+4−2
@@ -370,9 +370,11 @@ void brcms_c_stf_phy_txant_upd(struct brcms_c_info *wlc) · 369 unmodified lines
370370
371371 void brcms_c_stf_phy_chain_calc(struct brcms_c_info *wlc)
372372 {
373+ struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom;
374+
373375 /* get available rx/tx chains */
374− wlc->stf->hw_txchain = (u8) getintvar(wlc->hw->sih, BRCMS_SROM_TXCHAIN);
375− wlc->stf->hw_rxchain = (u8) getintvar(wlc->hw->sih, BRCMS_SROM_RXCHAIN);
376+ wlc->stf->hw_txchain = sprom->txchain;
377+ wlc->stf->hw_rxchain = sprom->rxchain;
376378
377379 /* these parameter are intended to be used for all PHY types */
378380 if (wlc->stf->hw_txchain == 0 || wlc->stf->hw_txchain == 0xf) {
drivers/net/wireless/iwlwifi/iwl-agn-lib.c+33−2
@@ -31,6 +31,7 @@ · 30 unmodified lines
3131 #include <linux/module.h>
3232 #include <linux/init.h>
3333 #include <linux/sched.h>
34+#include <net/mac80211.h>
3435
3536 #include "iwl-dev.h"
3637 #include "iwl-io.h"
@@ -273,9 +274,20 @@ void iwlagn_send_advance_bt_config(struct iwl_priv *priv) · 236 unmodified lines
273274 return;
274275 }
275276
277+ /*
278+ * Possible situations when BT needs to take over for receive,
279+ * at the same time where STA needs to response to AP's frame(s),
280+ * reduce the tx power of the required response frames, by that,
281+ * allow the concurrent BT receive & WiFi transmit
282+ * (BT - ANT A, WiFi -ANT B), without interference to one another
283+ *
284+ * Reduced tx power apply to control frames only (ACK/Back/CTS)
285+ * when indicated by the BT config command
286+ */
276287 basic.kill_ack_mask = priv->kill_ack_mask;
277288 basic.kill_cts_mask = priv->kill_cts_mask;
278− basic.reduce_txpower = priv->reduced_txpower;
289+ if (priv->reduced_txpower)
290+ basic.reduce_txpower = IWLAGN_BT_REDUCED_TX_PWR;
279291 basic.valid = priv->bt_valid;
280292
281293 /*
@@ -589,13 +601,31 @@ static bool iwlagn_set_kill_msk(struct iwl_priv *priv, · 307 unmodified lines
589601 return need_update;
590602 }
591603
604+/*
605+ * Upon RSSI changes, sends a bt config command with following changes
606+ * 1. enable/disable "reduced control frames tx power
607+ * 2. update the "kill)ack_mask" and "kill_cts_mask"
608+ *
609+ * If "reduced tx power" is enabled, uCode shall
610+ * 1. ACK/Back/CTS rate shall reduced to 6Mbps
611+ * 2. not use duplciate 20/40MHz mode
612+ */
592613 static bool iwlagn_fill_txpower_mode(struct iwl_priv *priv,
593614 struct iwl_bt_uart_msg *uart_msg)
594615 {
595616 bool need_update = false;
617+ struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
618+ int ave_rssi;
596619
620+ ave_rssi = ieee80211_ave_rssi(ctx->vif);
621+ if (!ave_rssi) {
622+ /* no rssi data, no changes to reduce tx power */
623+ IWL_DEBUG_COEX(priv, "no rssi data available\n");
624+ return need_update;
625+ }
597626 if (!priv->reduced_txpower &&
598627 !iwl_is_associated(priv, IWL_RXON_CTX_PAN) &&
628+ (ave_rssi > BT_ENABLE_REDUCED_TXPOWER_THRESHOLD) &&
599629 (uart_msg->frame3 & (BT_UART_MSG_FRAME3ACL_MSK |
600630 BT_UART_MSG_FRAME3OBEX_MSK)) &&
601631 !(uart_msg->frame3 & (BT_UART_MSG_FRAME3SCOESCO_MSK |
@@ -606,13 +636,14 @@ static bool iwlagn_fill_txpower_mode(struct iwl_priv *priv, · 4 unmodified lines
606636 need_update = true;
607637 } else if (priv->reduced_txpower &&
608638 (iwl_is_associated(priv, IWL_RXON_CTX_PAN) ||
639+ (ave_rssi < BT_DISABLE_REDUCED_TXPOWER_THRESHOLD) ||
609640 (uart_msg->frame3 & (BT_UART_MSG_FRAME3SCOESCO_MSK |
610641 BT_UART_MSG_FRAME3SNIFF_MSK | BT_UART_MSG_FRAME3A2DP_MSK)) ||
611642 !(uart_msg->frame3 & (BT_UART_MSG_FRAME3ACL_MSK |
612643 BT_UART_MSG_FRAME3OBEX_MSK)))) {
613644 /* disable reduced tx power */
614645 priv->reduced_txpower = false;
615− priv->bt_valid &= ~IWLAGN_BT_VALID_REDUCED_TX_PWR;
646+ priv->bt_valid |= IWLAGN_BT_VALID_REDUCED_TX_PWR;
616647 need_update = true;
617648 }
618649
drivers/net/wireless/iwlwifi/iwl-agn-rxon.c+4−0
@@ -61,6 +61,10 @@ void iwl_connection_init_rx_config(struct iwl_priv *priv, · 60 unmodified lines
6161 RXON_FILTER_ACCEPT_GRP_MSK;
6262 break;
6363
64+ case NL80211_IFTYPE_MONITOR:
65+ ctx->staging.dev_type = RXON_DEV_TYPE_SNIFFER;
66+ break;
67+
6468 default:
6569 IWL_ERR(priv, "Unsupported interface type %d\n",
6670 ctx->vif->type);
drivers/net/wireless/iwlwifi/iwl-agn-tx.c+12−7
@@ -590,11 +590,17 @@ turn_off: · 589 unmodified lines
590590 spin_unlock_bh(&priv->sta_lock);
591591
592592 if (test_bit(txq_id, priv->agg_q_alloc)) {
593− /* If the transport didn't know that we wanted to start
594− * agreggation, don't tell it that we want to stop them
593+ /*
594+ * If the transport didn't know that we wanted to start
595+ * agreggation, don't tell it that we want to stop them.
596+ * This can happen when we don't get the addBA response on
597+ * time, or we hadn't time to drain the AC queues.
595598 */
596− if (agg_state != IWL_AGG_STARTING)
599+ if (agg_state == IWL_AGG_ON)
597600 iwl_trans_tx_agg_disable(priv->trans, txq_id);
601+ else
602+ IWL_DEBUG_TX_QUEUES(priv, "Don't disable tx agg: %d\n",
603+ agg_state);
598604 iwlagn_dealloc_agg_txq(priv, txq_id);
599605 }
600606
@@ -1300,10 +1306,11 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, · 699 unmodified lines
13001306 (u8 *) &ba_resp->sta_addr_lo32,
13011307 ba_resp->sta_id);
13021308 IWL_DEBUG_TX_REPLY(priv, "TID = %d, SeqCtl = %d, bitmap = 0x%llx, "
1303− "scd_flow = %d, scd_ssn = %d\n",
1309+ "scd_flow = %d, scd_ssn = %d sent:%d, acked:%d\n",
13041310 ba_resp->tid, le16_to_cpu(ba_resp->seq_ctl),
13051311 (unsigned long long)le64_to_cpu(ba_resp->bitmap),
1306− scd_flow, ba_resp_scd_ssn);
1312+ scd_flow, ba_resp_scd_ssn, ba_resp->txed,
1313+ ba_resp->txed_2_done);
13071314
13081315 /* Mark that the expected block-ack response arrived */
13091316 agg->wait_for_ba = false;
@@ -1319,8 +1326,6 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, · 9 unmodified lines
13191326 */
13201327 ba_resp->txed = ba_resp->txed_2_done;
13211328 }
1322− IWL_DEBUG_HT(priv, "agg frames sent:%d, acked:%d\n",
1323− ba_resp->txed, ba_resp->txed_2_done);
13241329
13251330 priv->tid_data[sta_id][tid].next_reclaimed = ba_resp_scd_ssn;
13261331
drivers/net/wireless/iwlwifi/iwl-agn.c+1−1
@@ -603,7 +603,7 @@ void iwl_init_context(struct iwl_priv *priv, u32 ucode_flags) · 602 unmodified lines
603603 priv->contexts[IWL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY;
604604 priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
605605 priv->contexts[IWL_RXON_CTX_BSS].exclusive_interface_modes =
606− BIT(NL80211_IFTYPE_ADHOC);
606+ BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_MONITOR);
607607 priv->contexts[IWL_RXON_CTX_BSS].interface_modes =
608608 BIT(NL80211_IFTYPE_STATION);
609609 priv->contexts[IWL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP;
drivers/net/wireless/iwlwifi/iwl-commands.h+6−1
@@ -1910,6 +1910,8 @@ enum iwl_bt_kill_idx { · 1909 unmodified lines
19101910 IWLAGN_BT_VALID_REDUCED_TX_PWR | \
19111911 IWLAGN_BT_VALID_3W_LUT)
19121912
1913+#define IWLAGN_BT_REDUCED_TX_PWR BIT(0)
1914+
19131915 #define IWLAGN_BT_DECISION_LUT_SIZE 12
19141916
19151917 struct iwl_basic_bt_cmd {
@@ -1923,6 +1925,10 @@ struct iwl_basic_bt_cmd { · 7 unmodified lines
19231925 u8 bt3_timer_t2_value;
19241926 __le16 bt4_reaction_time; /* unused */
19251927 __le32 bt3_lookup_table[IWLAGN_BT_DECISION_LUT_SIZE];
1928+ /*
1929+ * bit 0: use reduced tx power for control frame
1930+ * bit 1 - 7: reserved
1931+ */
19261932 u8 reduce_txpower;
19271933 u8 reserved;
19281934 __le16 valid;
@@ -2272,7 +2278,6 @@ struct iwl_ssid_ie { · 343 unmodified lines
22722278 #define IWL_GOOD_CRC_TH_DISABLED 0
22732279 #define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
22742280 #define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
2275−#define IWL_MAX_SCAN_SIZE 1024
22762281 #define IWL_MAX_CMD_SIZE 4096
22772282
22782283 /*
drivers/net/wireless/iwlwifi/iwl-mac80211.c+3−2
@@ -150,6 +150,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, · 149 unmodified lines
150150 IEEE80211_HW_QUEUE_CONTROL |
151151 IEEE80211_HW_SUPPORTS_PS |
152152 IEEE80211_HW_SUPPORTS_DYNAMIC_PS |
153+ IEEE80211_HW_WANT_MONITOR_VIF |
153154 IEEE80211_HW_SCAN_WHILE_IDLE;
154155
155156 hw->offchannel_tx_hw_queue = IWL_AUX_QUEUE;
@@ -223,8 +224,8 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv, · 67 unmodified lines
223224 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
224225
225226 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
226− /* we create the 802.11 header and a zero-length SSID element */
227− hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 2;
227+ /* we create the 802.11 header and a max-length SSID element */
228+ hw->wiphy->max_scan_ie_len = capa->max_probe_length - 24 - 34;
228229
229230 /*
230231 * We don't use all queues: 4 and 9 are unused and any
drivers/net/wireless/iwlwifi/iwl-power.c+6−2
@@ -253,6 +253,8 @@ static void iwl_static_sleep_cmd(struct iwl_priv *priv, · 252 unmodified lines
253253
254254 IWL_DEBUG_POWER(priv, "numSkipDtim = %u, dtimPeriod = %d\n",
255255 skip, period);
256+ /* The power level here is 0-4 (used as array index), but user expects
257+ to see 1-5 (according to spec). */
256258 IWL_DEBUG_POWER(priv, "Sleep command for index %d\n", lvl + 1);
257259 }
258260
@@ -308,10 +310,12 @@ static void iwl_power_build_cmd(struct iwl_priv *priv, · 49 unmodified lines
308310 priv->power_data.debug_sleep_level_override,
309311 dtimper);
310312 else {
313+ /* Note that the user parameter is 1-5 (according to spec),
314+ but we pass 0-4 because it acts as an array index. */
311315 if (iwlwifi_mod_params.power_level > IWL_POWER_INDEX_1 &&
312− iwlwifi_mod_params.power_level <= IWL_POWER_INDEX_5)
316+ iwlwifi_mod_params.power_level <= IWL_POWER_NUM)
313317 iwl_static_sleep_cmd(priv, cmd,
314− iwlwifi_mod_params.power_level, dtimper);
318+ iwlwifi_mod_params.power_level - 1, dtimper);
315319 else
316320 iwl_static_sleep_cmd(priv, cmd,
317321 IWL_POWER_INDEX_1, dtimper);
drivers/net/wireless/iwlwifi/iwl-scan.c+38−14
@@ -52,6 +52,7 @@ · 51 unmodified lines
5252 #define IWL_PASSIVE_DWELL_TIME_52 (10)
5353 #define IWL_PASSIVE_DWELL_BASE (100)
5454 #define IWL_CHANNEL_TUNE_TIME 5
55+#define MAX_SCAN_CHANNEL 50
5556
5657 static int iwl_send_scan_abort(struct iwl_priv *priv)
5758 {
@@ -616,7 +617,8 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv, · 558 unmodified lines
616617 */
617618
618619 static u16 iwl_fill_probe_req(struct ieee80211_mgmt *frame, const u8 *ta,
619− const u8 *ies, int ie_len, int left)
620+ const u8 *ies, int ie_len, const u8 *ssid,
621+ u8 ssid_len, int left)
620622 {
621623 int len = 0;
622624 u8 *pos = NULL;
@@ -638,14 +640,18 @@ static u16 iwl_fill_probe_req(struct ieee80211_mgmt *frame, const u8 *ta, · 15 unmodified lines
638640 /* ...next IE... */
639641 pos = &frame->u.probe_req.variable[0];
640642
641− /* fill in our indirect SSID IE */
642− left -= 2;
643+ /* fill in our SSID IE */
644+ left -= ssid_len + 2;
643645 if (left < 0)
644646 return 0;
645647 *pos++ = WLAN_EID_SSID;
646− *pos++ = 0;
648+ *pos++ = ssid_len;
649+ if (ssid && ssid_len) {
650+ memcpy(pos, ssid, ssid_len);
651+ pos += ssid_len;
652+ }
647653
648− len += 2;
654+ len += ssid_len + 2;
649655
650656 if (WARN_ON(left < ie_len))
651657 return len;
@@ -679,6 +685,15 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) · 27 unmodified lines
679685 u8 active_chains;
680686 u8 scan_tx_antennas = priv->hw_params.valid_tx_ant;
681687 int ret;
688+ int scan_cmd_size = sizeof(struct iwl_scan_cmd) +
689+ MAX_SCAN_CHANNEL * sizeof(struct iwl_scan_channel) +
690+ priv->fw->ucode_capa.max_probe_length;
691+ const u8 *ssid = NULL;
692+ u8 ssid_len = 0;
693+
694+ if (WARN_ON_ONCE(priv->scan_request &&
695+ priv->scan_request->n_channels > MAX_SCAN_CHANNEL))
696+ return -EINVAL;
682697
683698 lockdep_assert_held(&priv->mutex);
684699
@@ -686,8 +701,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) · 1 unmodified line
686701 ctx = iwl_rxon_ctx_from_vif(vif);
687702
688703 if (!priv->scan_cmd) {
689− priv->scan_cmd = kmalloc(sizeof(struct iwl_scan_cmd) +
690− IWL_MAX_SCAN_SIZE, GFP_KERNEL);
704+ priv->scan_cmd = kmalloc(scan_cmd_size, GFP_KERNEL);
691705 if (!priv->scan_cmd) {
692706 IWL_DEBUG_SCAN(priv,
693707 "fail to allocate memory for scan\n");
@@ -695,7 +709,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) · 1 unmodified line
695709 }
696710 }
697711 scan = priv->scan_cmd;
698− memset(scan, 0, sizeof(struct iwl_scan_cmd) + IWL_MAX_SCAN_SIZE);
712+ memset(scan, 0, scan_cmd_size);
699713
700714 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
701715 scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
@@ -746,10 +760,18 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) · 44 unmodified lines
746760 if (priv->scan_request->n_ssids) {
747761 int i, p = 0;
748762 IWL_DEBUG_SCAN(priv, "Kicking off active scan\n");
749− for (i = 0; i < priv->scan_request->n_ssids; i++) {
750− /* always does wildcard anyway */
751− if (!priv->scan_request->ssids[i].ssid_len)
752− continue;
763+ /*
764+ * The highest priority SSID is inserted to the
765+ * probe request template.
766+ */
767+ ssid_len = priv->scan_request->ssids[0].ssid_len;
768+ ssid = priv->scan_request->ssids[0].ssid;
769+
770+ /*
771+ * Invert the order of ssids, the firmware will invert
772+ * it back.
773+ */
774+ for (i = priv->scan_request->n_ssids - 1; i >= 1; i--) {
753775 scan->direct_scan[p].id = WLAN_EID_SSID;
754776 scan->direct_scan[p].len =
755777 priv->scan_request->ssids[i].ssid_len;
@@ -883,7 +905,8 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) · 127 unmodified lines
883905 vif->addr,
884906 priv->scan_request->ie,
885907 priv->scan_request->ie_len,
886− IWL_MAX_SCAN_SIZE - sizeof(*scan));
908+ ssid, ssid_len,
909+ scan_cmd_size - sizeof(*scan));
887910 break;
888911 case IWL_SCAN_RADIO_RESET:
889912 case IWL_SCAN_ROC:
@@ -891,7 +914,8 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) · 1 unmodified line
891914 cmd_len = iwl_fill_probe_req(
892915 (struct ieee80211_mgmt *)scan->data,
893916 iwl_bcast_addr, NULL, 0,
894− IWL_MAX_SCAN_SIZE - sizeof(*scan));
917+ NULL, 0,
918+ scan_cmd_size - sizeof(*scan));
895919 break;
896920 default:
897921 BUG();
drivers/net/wireless/mac80211_hwsim.c+5−0
@@ -746,6 +746,11 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) · 745 unmodified lines
746746 hwsim_check_sta_magic(txi->control.sta);
747747
748748 ieee80211_tx_info_clear_status(txi);
749+
750+ /* frame was transmitted at most favorable rate at first attempt */
751+ txi->control.rates[0].count = 1;
752+ txi->control.rates[1].idx = -1;
753+
749754 if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) && ack)
750755 txi->flags |= IEEE80211_TX_STAT_ACK;
751756 ieee80211_tx_status_irqsafe(hw, skb);
drivers/net/wireless/mwifiex/Makefile+2−0
@@ -29,6 +29,8 @@ mwifiex-y += scan.o · 28 unmodified lines
2929 mwifiex-y += join.o
3030 mwifiex-y += sta_ioctl.o
3131 mwifiex-y += sta_cmd.o
32+mwifiex-y += uap_cmd.o
33+mwifiex-y += ie.o
3234 mwifiex-y += sta_cmdresp.o
3335 mwifiex-y += sta_event.o
3436 mwifiex-y += sta_tx.o
drivers/net/wireless/mwifiex/cfg80211.c+351−147
@@ -20,6 +20,23 @@ · 19 unmodified lines
2020 #include "cfg80211.h"
2121 #include "main.h"
2222
23+static const struct ieee80211_iface_limit mwifiex_ap_sta_limits[] = {
24+ {
25+ .max = 1, .types = BIT(NL80211_IFTYPE_STATION),
26+ },
27+ {
28+ .max = 1, .types = BIT(NL80211_IFTYPE_AP),
29+ },
30+};
31+
32+static const struct ieee80211_iface_combination mwifiex_iface_comb_ap_sta = {
33+ .limits = mwifiex_ap_sta_limits,
34+ .num_different_channels = 1,
35+ .n_limits = ARRAY_SIZE(mwifiex_ap_sta_limits),
36+ .max_interfaces = MWIFIEX_MAX_BSS_NUM,
37+ .beacon_int_infra_match = true,
38+};
39+
2340 /*
2441 * This function maps the nl802.11 channel type into driver channel type.
2542 *
@@ -67,7 +84,7 @@ mwifiex_is_alg_wep(u32 cipher) · 41 unmodified lines
6784 /*
6885 * This function retrieves the private structure from kernel wiphy structure.
6986 */
70−static void *mwifiex_cfg80211_get_priv(struct wiphy *wiphy)
87+static void *mwifiex_cfg80211_get_adapter(struct wiphy *wiphy)
7188 {
7289 return (void *) (*(unsigned long *) wiphy_priv(wiphy));
7390 }
@@ -80,8 +97,10 @@ mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev, · 6 unmodified lines
8097 u8 key_index, bool pairwise, const u8 *mac_addr)
8198 {
8299 struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
100+ const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
101+ const u8 *peer_mac = pairwise ? mac_addr : bc_mac;
83102
84− if (mwifiex_set_encode(priv, NULL, 0, key_index, 1)) {
103+ if (mwifiex_set_encode(priv, NULL, 0, key_index, peer_mac, 1)) {
85104 wiphy_err(wiphy, "deleting the crypto keys\n");
86105 return -EFAULT;
87106 }
@@ -98,7 +117,8 @@ mwifiex_cfg80211_set_tx_power(struct wiphy *wiphy, · 10 unmodified lines
98117 enum nl80211_tx_power_setting type,
99118 int mbm)
100119 {
101− struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
120+ struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy);
121+ struct mwifiex_private *priv;
102122 struct mwifiex_power_cfg power_cfg;
103123 int dbm = MBM_TO_DBM(mbm);
104124
@@ -109,6 +129,8 @@ mwifiex_cfg80211_set_tx_power(struct wiphy *wiphy, · 4 unmodified lines
109129 power_cfg.is_power_auto = 1;
110130 }
111131
132+ priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
133+
112134 return mwifiex_set_tx_power(priv, &power_cfg);
113135 }
114136
@@ -148,7 +170,7 @@ mwifiex_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *netdev, · 33 unmodified lines
148170 if (!priv->sec_info.wep_enabled)
149171 return 0;
150172
151− if (mwifiex_set_encode(priv, NULL, 0, key_index, 0)) {
173+ if (mwifiex_set_encode(priv, NULL, 0, key_index, NULL, 0)) {
152174 wiphy_err(wiphy, "set default Tx key index\n");
153175 return -EFAULT;
154176 }
@@ -165,9 +187,11 @@ mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev, · 10 unmodified lines
165187 struct key_params *params)
166188 {
167189 struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
190+ const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
191+ const u8 *peer_mac = pairwise ? mac_addr : bc_mac;
168192
169193 if (mwifiex_set_encode(priv, params->key, params->key_len,
170− key_index, 0)) {
194+ key_index, peer_mac, 0)) {
171195 wiphy_err(wiphy, "crypto keys added\n");
172196 return -EFAULT;
173197 }
@@ -192,13 +216,13 @@ static int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy) · 18 unmodified lines
192216 enum ieee80211_band band;
193217 struct ieee80211_supported_band *sband;
194218 struct ieee80211_channel *ch;
195− struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
196− struct mwifiex_adapter *adapter = priv->adapter;
219+ struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy);
220+ struct mwifiex_private *priv;
197221 struct mwifiex_802_11d_domain_reg *domain_info = &adapter->domain_reg;
198222
199223 /* Set country code */
200− domain_info->country_code[0] = priv->country_code[0];
201− domain_info->country_code[1] = priv->country_code[1];
224+ domain_info->country_code[0] = adapter->country_code[0];
225+ domain_info->country_code[1] = adapter->country_code[1];
202226 domain_info->country_code[2] = ' ';
203227
204228 band = mwifiex_band_to_radio_type(adapter->config_bands);
@@ -250,6 +274,8 @@ static int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy) · 45 unmodified lines
250274
251275 domain_info->no_of_triplet = no_of_triplet;
252276
277+ priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
278+
253279 if (mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11D_DOMAIN_INFO,
254280 HostCmd_ACT_GEN_SET, 0, NULL)) {
255281 wiphy_err(wiphy, "11D: setting domain info in FW\n");
@@ -272,12 +298,12 @@ static int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy) · 16 unmodified lines
272298 static int mwifiex_reg_notifier(struct wiphy *wiphy,
273299 struct regulatory_request *request)
274300 {
275− struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
301+ struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy);
276302
277− wiphy_dbg(wiphy, "info: cfg80211 regulatory domain callback for domain"
278− " %c%c\n", request->alpha2[0], request->alpha2[1]);
303+ wiphy_dbg(wiphy, "info: cfg80211 regulatory domain callback for %c%c\n",
304+ request->alpha2[0], request->alpha2[1]);
279305
280− memcpy(priv->country_code, request->alpha2, sizeof(request->alpha2));
306+ memcpy(adapter->country_code, request->alpha2, sizeof(request->alpha2));
281307
282308 switch (request->initiator) {
283309 case NL80211_REGDOM_SET_BY_DRIVER:
@@ -361,33 +387,10 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv, · 77 unmodified lines
361387 if (mwifiex_bss_set_channel(priv, &cfp))
362388 return -EFAULT;
363389
364− return mwifiex_drv_change_adhoc_chan(priv, cfp.channel);
365−}
366−
367−/*
368− * CFG802.11 operation handler to set channel.
369− *
370− * This function can only be used when station is not connected.
371− */
372−static int
373−mwifiex_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev,
374− struct ieee80211_channel *chan,
375− enum nl80211_channel_type channel_type)
376−{
377− struct mwifiex_private *priv;
378−
379− if (dev)
380− priv = mwifiex_netdev_get_priv(dev);
390+ if (priv->bss_type == MWIFIEX_BSS_TYPE_STA)
391+ return mwifiex_drv_change_adhoc_chan(priv, cfp.channel);
381392 else
382− priv = mwifiex_cfg80211_get_priv(wiphy);
383−
384− if (priv->media_connected) {
385− wiphy_err(wiphy, "This setting is valid only when station "
386− "is not connected\n");
387− return -EINVAL;
388− }
389−
390− return mwifiex_set_rf_channel(priv, chan, channel_type);
393+ return mwifiex_uap_set_channel(priv, cfp.channel);
391394 }
392395
393396 /*
@@ -399,18 +402,13 @@ mwifiex_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev, · 5 unmodified lines
399402 static int
400403 mwifiex_set_frag(struct mwifiex_private *priv, u32 frag_thr)
401404 {
402− int ret;
403−
404405 if (frag_thr < MWIFIEX_FRAG_MIN_VALUE ||
405406 frag_thr > MWIFIEX_FRAG_MAX_VALUE)
406− return -EINVAL;
407−
408− /* Send request to firmware */
409− ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB,
410− HostCmd_ACT_GEN_SET, FRAG_THRESH_I,
411− &frag_thr);
407+ frag_thr = MWIFIEX_FRAG_MAX_VALUE;
412408
413− return ret;
409+ return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB,
410+ HostCmd_ACT_GEN_SET, FRAG_THRESH_I,
411+ &frag_thr);
414412 }
415413
416414 /*
@@ -439,19 +437,85 @@ mwifiex_set_rts(struct mwifiex_private *priv, u32 rts_thr) · 22 unmodified lines
439437 static int
440438 mwifiex_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
441439 {
442− struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
443− int ret = 0;
440+ struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy);
441+ struct mwifiex_private *priv;
442+ struct mwifiex_uap_bss_param *bss_cfg;
443+ int ret, bss_started, i;
444+
445+ for (i = 0; i < adapter->priv_num; i++) {
446+ priv = adapter->priv[i];
447+
448+ switch (priv->bss_role) {
449+ case MWIFIEX_BSS_ROLE_UAP:
450+ bss_cfg = kzalloc(sizeof(struct mwifiex_uap_bss_param),
451+ GFP_KERNEL);
452+ if (!bss_cfg)
453+ return -ENOMEM;
454+
455+ mwifiex_set_sys_config_invalid_data(bss_cfg);
456+
457+ if (changed & WIPHY_PARAM_RTS_THRESHOLD)
458+ bss_cfg->rts_threshold = wiphy->rts_threshold;
459+ if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
460+ bss_cfg->frag_threshold = wiphy->frag_threshold;
461+ if (changed & WIPHY_PARAM_RETRY_LONG)
462+ bss_cfg->retry_limit = wiphy->retry_long;
463+
464+ bss_started = priv->bss_started;
465+
466+ ret = mwifiex_send_cmd_sync(priv,
467+ HostCmd_CMD_UAP_BSS_STOP,
468+ HostCmd_ACT_GEN_SET, 0,
469+ NULL);
470+ if (ret) {
471+ wiphy_err(wiphy, "Failed to stop the BSS\n");
472+ kfree(bss_cfg);
473+ return ret;
474+ }
444475
445− if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
446− ret = mwifiex_set_rts(priv, wiphy->rts_threshold);
447− if (ret)
448− return ret;
449− }
476+ ret = mwifiex_send_cmd_async(priv,
477+ HostCmd_CMD_UAP_SYS_CONFIG,
478+ HostCmd_ACT_GEN_SET,
479+ UAP_BSS_PARAMS_I, bss_cfg);
450480
451− if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
452− ret = mwifiex_set_frag(priv, wiphy->frag_threshold);
481+ kfree(bss_cfg);
453482
454− return ret;
483+ if (ret) {
484+ wiphy_err(wiphy, "Failed to set bss config\n");
485+ return ret;
486+ }
487+
488+ if (!bss_started)
489+ break;
490+
491+ ret = mwifiex_send_cmd_async(priv,
492+ HostCmd_CMD_UAP_BSS_START,
493+ HostCmd_ACT_GEN_SET, 0,
494+ NULL);
495+ if (ret) {
496+ wiphy_err(wiphy, "Failed to start BSS\n");
497+ return ret;
498+ }
499+
500+ break;
501+ case MWIFIEX_BSS_ROLE_STA:
502+ if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
503+ ret = mwifiex_set_rts(priv,
504+ wiphy->rts_threshold);
505+ if (ret)
506+ return ret;
507+ }
508+ if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
509+ ret = mwifiex_set_frag(priv,
510+ wiphy->frag_threshold);
511+ if (ret)
512+ return ret;
513+ }
514+ break;
515+ }
516+ }
517+
518+ return 0;
455519 }
456520
457521 /*
@@ -466,31 +530,59 @@ mwifiex_cfg80211_change_virtual_intf(struct wiphy *wiphy, · 8 unmodified lines
466530 int ret;
467531 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
468532
469− if (priv->bss_mode == type) {
470− wiphy_warn(wiphy, "already set to required type\n");
471− return 0;
472− }
473−
474− priv->bss_mode = type;
475−
476− switch (type) {
533+ switch (dev->ieee80211_ptr->iftype) {
477534 case NL80211_IFTYPE_ADHOC:
478− dev->ieee80211_ptr->iftype = NL80211_IFTYPE_ADHOC;
479− wiphy_dbg(wiphy, "info: setting interface type to adhoc\n");
535+ switch (type) {
536+ case NL80211_IFTYPE_STATION:
537+ break;
538+ case NL80211_IFTYPE_UNSPECIFIED:
539+ wiphy_warn(wiphy, "%s: kept type as IBSS\n", dev->name);
540+ case NL80211_IFTYPE_ADHOC: /* This shouldn't happen */
541+ return 0;
542+ case NL80211_IFTYPE_AP:
543+ default:
544+ wiphy_err(wiphy, "%s: changing to %d not supported\n",
545+ dev->name, type);
546+ return -EOPNOTSUPP;
547+ }
480548 break;
481549 case NL80211_IFTYPE_STATION:
482− dev->ieee80211_ptr->iftype = NL80211_IFTYPE_STATION;
483− wiphy_dbg(wiphy, "info: setting interface type to managed\n");
550+ switch (type) {
551+ case NL80211_IFTYPE_ADHOC:
552+ break;
553+ case NL80211_IFTYPE_UNSPECIFIED:
554+ wiphy_warn(wiphy, "%s: kept type as STA\n", dev->name);
555+ case NL80211_IFTYPE_STATION: /* This shouldn't happen */
556+ return 0;
557+ case NL80211_IFTYPE_AP:
558+ default:
559+ wiphy_err(wiphy, "%s: changing to %d not supported\n",
560+ dev->name, type);
561+ return -EOPNOTSUPP;
562+ }
563+ break;
564+ case NL80211_IFTYPE_AP:
565+ switch (type) {
566+ case NL80211_IFTYPE_UNSPECIFIED:
567+ wiphy_warn(wiphy, "%s: kept type as AP\n", dev->name);
568+ case NL80211_IFTYPE_AP: /* This shouldn't happen */
569+ return 0;
570+ case NL80211_IFTYPE_ADHOC:
571+ case NL80211_IFTYPE_STATION:
572+ default:
573+ wiphy_err(wiphy, "%s: changing to %d not supported\n",
574+ dev->name, type);
575+ return -EOPNOTSUPP;
576+ }
484577 break;
485− case NL80211_IFTYPE_UNSPECIFIED:
486− dev->ieee80211_ptr->iftype = NL80211_IFTYPE_STATION;
487− wiphy_dbg(wiphy, "info: setting interface type to auto\n");
488− return 0;
489578 default:
490− wiphy_err(wiphy, "unknown interface type: %d\n", type);
491− return -EINVAL;
579+ wiphy_err(wiphy, "%s: unknown iftype: %d\n",
580+ dev->name, dev->ieee80211_ptr->iftype);
581+ return -EOPNOTSUPP;
492582 }
493583
584+ dev->ieee80211_ptr->iftype = type;
585+ priv->bss_mode = type;
494586 mwifiex_deauthenticate(priv, NULL);
495587
496588 priv->sec_info.authentication_mode = NL80211_AUTHTYPE_OPEN_SYSTEM;
@@ -804,6 +896,90 @@ static int mwifiex_cfg80211_set_cqm_rssi_config(struct wiphy *wiphy, · 307 unmodified lines
804896 return 0;
805897 }
806898
899+/* cfg80211 operation handler for stop ap.
900+ * Function stops BSS running at uAP interface.
901+ */
902+static int mwifiex_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
903+{
904+ struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
905+
906+ if (mwifiex_del_mgmt_ies(priv))
907+ wiphy_err(wiphy, "Failed to delete mgmt IEs!\n");
908+
909+ if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_UAP_BSS_STOP,
910+ HostCmd_ACT_GEN_SET, 0, NULL)) {
911+ wiphy_err(wiphy, "Failed to stop the BSS\n");
912+ return -1;
913+ }
914+
915+ return 0;
916+}
917+
918+/* cfg80211 operation handler for start_ap.
919+ * Function sets beacon period, DTIM period, SSID and security into
920+ * AP config structure.
921+ * AP is configured with these settings and BSS is started.
922+ */
923+static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
924+ struct net_device *dev,
925+ struct cfg80211_ap_settings *params)
926+{
927+ struct mwifiex_uap_bss_param *bss_cfg;
928+ struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
929+
930+ if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP)
931+ return -1;
932+ if (mwifiex_set_mgmt_ies(priv, params))
933+ return -1;
934+
935+ bss_cfg = kzalloc(sizeof(struct mwifiex_uap_bss_param), GFP_KERNEL);
936+ if (!bss_cfg)
937+ return -ENOMEM;
938+
939+ mwifiex_set_sys_config_invalid_data(bss_cfg);
940+
941+ if (params->beacon_interval)
942+ bss_cfg->beacon_period = params->beacon_interval;
943+ if (params->dtim_period)
944+ bss_cfg->dtim_period = params->dtim_period;
945+
946+ if (params->ssid && params->ssid_len) {
947+ memcpy(bss_cfg->ssid.ssid, params->ssid, params->ssid_len);
948+ bss_cfg->ssid.ssid_len = params->ssid_len;
949+ }
950+
951+ if (mwifiex_set_secure_params(priv, bss_cfg, params)) {
952+ kfree(bss_cfg);
953+ wiphy_err(wiphy, "Failed to parse secuirty parameters!\n");
954+ return -1;
955+ }
956+
957+ if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_UAP_BSS_STOP,
958+ HostCmd_ACT_GEN_SET, 0, NULL)) {
959+ wiphy_err(wiphy, "Failed to stop the BSS\n");
960+ kfree(bss_cfg);
961+ return -1;
962+ }
963+
964+ if (mwifiex_send_cmd_async(priv, HostCmd_CMD_UAP_SYS_CONFIG,
965+ HostCmd_ACT_GEN_SET,
966+ UAP_BSS_PARAMS_I, bss_cfg)) {
967+ wiphy_err(wiphy, "Failed to set the SSID\n");
968+ kfree(bss_cfg);
969+ return -1;
970+ }
971+
972+ kfree(bss_cfg);
973+
974+ if (mwifiex_send_cmd_async(priv, HostCmd_CMD_UAP_BSS_START,
975+ HostCmd_ACT_GEN_SET, 0, NULL)) {
976+ wiphy_err(wiphy, "Failed to start the BSS\n");
977+ return -1;
978+ }
979+
980+ return 0;
981+}
982+
807983 /*
808984 * CFG802.11 operation handler for disconnection request.
809985 *
@@ -923,7 +1099,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid, · 113 unmodified lines
9231099 priv->wep_key_curr_index = 0;
9241100 priv->sec_info.encryption_mode = 0;
9251101 priv->sec_info.is_authtype_auto = 0;
926− ret = mwifiex_set_encode(priv, NULL, 0, 0, 1);
1102+ ret = mwifiex_set_encode(priv, NULL, 0, 0, NULL, 1);
9271103
9281104 if (mode == NL80211_IFTYPE_ADHOC) {
9291105 /* "privacy" is set only for ad-hoc mode */
@@ -971,7 +1147,7 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid, · 41 unmodified lines
9711147 " with key len %d\n", sme->key_len);
9721148 priv->wep_key_curr_index = sme->key_idx;
9731149 ret = mwifiex_set_encode(priv, sme->key, sme->key_len,
974− sme->key_idx, 0);
1150+ sme->key_idx, NULL, 0);
9751151 }
9761152 }
9771153 done:
@@ -1050,6 +1226,11 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, · 72 unmodified lines
10501226 goto done;
10511227 }
10521228
1229+ if (priv->bss_mode == NL80211_IFTYPE_AP) {
1230+ wiphy_err(wiphy, "skip association request for AP interface\n");
1231+ goto done;
1232+ }
1233+
10531234 wiphy_dbg(wiphy, "info: Trying to associate to %s and bssid %pM\n",
10541235 (char *) sme->ssid, sme->bssid);
10551236
@@ -1283,15 +1464,12 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy, · 227 unmodified lines
12831464 u32 *flags,
12841465 struct vif_params *params)
12851466 {
1286− struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
1287− struct mwifiex_adapter *adapter;
1467+ struct mwifiex_adapter *adapter = mwifiex_cfg80211_get_adapter(wiphy);
1468+ struct mwifiex_private *priv;
12881469 struct net_device *dev;
12891470 void *mdev_priv;
1471+ struct wireless_dev *wdev;
12901472
1291− if (!priv)
1292− return NULL;
1293−
1294− adapter = priv->adapter;
12951473 if (!adapter)
12961474 return NULL;
12971475
@@ -1299,12 +1477,21 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy, · 1 unmodified line
12991477 case NL80211_IFTYPE_UNSPECIFIED:
13001478 case NL80211_IFTYPE_STATION:
13011479 case NL80211_IFTYPE_ADHOC:
1480+ priv = adapter->priv[MWIFIEX_BSS_TYPE_STA];
13021481 if (priv->bss_mode) {
1303− wiphy_err(wiphy, "cannot create multiple"
1304− " station/adhoc interfaces\n");
1482+ wiphy_err(wiphy,
1483+ "cannot create multiple sta/adhoc ifaces\n");
13051484 return NULL;
13061485 }
13071486
1487+ wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
1488+ if (!wdev)
1489+ return NULL;
1490+
1491+ wdev->wiphy = wiphy;
1492+ priv->wdev = wdev;
1493+ wdev->iftype = NL80211_IFTYPE_STATION;
1494+
13081495 if (type == NL80211_IFTYPE_UNSPECIFIED)
13091496 priv->bss_mode = NL80211_IFTYPE_STATION;
13101497 else
@@ -1312,10 +1499,35 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy, · 1 unmodified line
13121499
13131500 priv->bss_type = MWIFIEX_BSS_TYPE_STA;
13141501 priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II;
1315− priv->bss_priority = 0;
1502+ priv->bss_priority = MWIFIEX_BSS_ROLE_STA;
13161503 priv->bss_role = MWIFIEX_BSS_ROLE_STA;
13171504 priv->bss_num = 0;
13181505
1506+ break;
1507+ case NL80211_IFTYPE_AP:
1508+ priv = adapter->priv[MWIFIEX_BSS_TYPE_UAP];
1509+
1510+ if (priv->bss_mode) {
1511+ wiphy_err(wiphy, "Can't create multiple AP interfaces");
1512+ return NULL;
1513+ }
1514+
1515+ wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
1516+ if (!wdev)
1517+ return NULL;
1518+
1519+ priv->wdev = wdev;
1520+ wdev->wiphy = wiphy;
1521+ wdev->iftype = NL80211_IFTYPE_AP;
1522+
1523+ priv->bss_type = MWIFIEX_BSS_TYPE_UAP;
1524+ priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II;
1525+ priv->bss_priority = MWIFIEX_BSS_ROLE_UAP;
1526+ priv->bss_role = MWIFIEX_BSS_ROLE_UAP;
1527+ priv->bss_started = 0;
1528+ priv->bss_num = 0;
1529+ priv->bss_mode = type;
1530+
13191531 break;
13201532 default:
13211533 wiphy_err(wiphy, "type not supported\n");
@@ -1329,6 +1541,15 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy, · 7 unmodified lines
13291541 goto error;
13301542 }
13311543
1544+ mwifiex_init_priv_params(priv, dev);
1545+ priv->netdev = dev;
1546+
1547+ mwifiex_setup_ht_caps(&wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap, priv);
1548+
1549+ if (adapter->config_bands & BAND_A)
1550+ mwifiex_setup_ht_caps(
1551+ &wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap, priv);
1552+
13321553 dev_net_set(dev, wiphy_net(wiphy));
13331554 dev->ieee80211_ptr = priv->wdev;
13341555 dev->ieee80211_ptr->iftype = priv->bss_mode;
@@ -1343,9 +1564,6 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy, · 8 unmodified lines
13431564 mdev_priv = netdev_priv(dev);
13441565 *((unsigned long *) mdev_priv) = (unsigned long) priv;
13451566
1346− priv->netdev = dev;
1347− mwifiex_init_priv_params(priv, dev);
1348−
13491567 SET_NETDEV_DEV(dev, adapter->dev);
13501568
13511569 /* Register network device */
@@ -1417,7 +1635,6 @@ static struct cfg80211_ops mwifiex_cfg80211_ops = { · 65 unmodified lines
14171635 .get_station = mwifiex_cfg80211_get_station,
14181636 .dump_station = mwifiex_cfg80211_dump_station,
14191637 .set_wiphy_params = mwifiex_cfg80211_set_wiphy_params,
1420− .set_channel = mwifiex_cfg80211_set_channel,
14211638 .join_ibss = mwifiex_cfg80211_join_ibss,
14221639 .leave_ibss = mwifiex_cfg80211_leave_ibss,
14231640 .add_key = mwifiex_cfg80211_add_key,
@@ -1426,6 +1643,8 @@ static struct cfg80211_ops mwifiex_cfg80211_ops = { · 2 unmodified lines
14261643 .set_power_mgmt = mwifiex_cfg80211_set_power_mgmt,
14271644 .set_tx_power = mwifiex_cfg80211_set_tx_power,
14281645 .set_bitrate_mask = mwifiex_cfg80211_set_bitrate_mask,
1646+ .start_ap = mwifiex_cfg80211_start_ap,
1647+ .stop_ap = mwifiex_cfg80211_stop_ap,
14291648 .set_cqm_rssi_config = mwifiex_cfg80211_set_cqm_rssi_config,
14301649 };
14311650
@@ -1436,82 +1655,67 @@ static struct cfg80211_ops mwifiex_cfg80211_ops = { · 4 unmodified lines
14361655 * default parameters and handler function pointers, and finally
14371656 * registers the device.
14381657 */
1439−int mwifiex_register_cfg80211(struct mwifiex_private *priv)
1658+
1659+int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
14401660 {
14411661 int ret;
14421662 void *wdev_priv;
1443− struct wireless_dev *wdev;
1444− struct ieee80211_sta_ht_cap *ht_info;
1663+ struct wiphy *wiphy;
1664+ struct mwifiex_private *priv = adapter->priv[MWIFIEX_BSS_TYPE_STA];
14451665 u8 *country_code;
14461666
1447− wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
1448− if (!wdev) {
1449− dev_err(priv->adapter->dev, "%s: allocating wireless device\n",
1450− __func__);
1451− return -ENOMEM;
1452− }
1453− wdev->wiphy =
1454− wiphy_new(&mwifiex_cfg80211_ops,
1455− sizeof(struct mwifiex_private *));
1456− if (!wdev->wiphy) {
1457− kfree(wdev);
1667+ /* create a new wiphy for use with cfg80211 */
1668+ wiphy = wiphy_new(&mwifiex_cfg80211_ops,
1669+ sizeof(struct mwifiex_adapter *));
1670+ if (!wiphy) {
1671+ dev_err(adapter->dev, "%s: creating new wiphy\n", __func__);
14581672 return -ENOMEM;
14591673 }
1460− wdev->iftype = NL80211_IFTYPE_STATION;
1461− wdev->wiphy->max_scan_ssids = 10;
1462− wdev->wiphy->max_scan_ie_len = MWIFIEX_MAX_VSIE_LEN;
1463− wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
1464− BIT(NL80211_IFTYPE_ADHOC);
1465−
1466− wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &mwifiex_band_2ghz;
1467− ht_info = &wdev->wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap;
1468− mwifiex_setup_ht_caps(ht_info, priv);
1469−
1470− if (priv->adapter->config_bands & BAND_A) {
1471− wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = &mwifiex_band_5ghz;
1472− ht_info = &wdev->wiphy->bands[IEEE80211_BAND_5GHZ]->ht_cap;
1473− mwifiex_setup_ht_caps(ht_info, priv);
1474− } else {
1475− wdev->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
1476− }
1674+ wiphy->max_scan_ssids = MWIFIEX_MAX_SSID_LIST_LENGTH;
1675+ wiphy->max_scan_ie_len = MWIFIEX_MAX_VSIE_LEN;
1676+ wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
1677+ BIT(NL80211_IFTYPE_ADHOC) |
1678+ BIT(NL80211_IFTYPE_AP);
1679+
1680+ wiphy->bands[IEEE80211_BAND_2GHZ] = &mwifiex_band_2ghz;
1681+ if (adapter->config_bands & BAND_A)
1682+ wiphy->bands[IEEE80211_BAND_5GHZ] = &mwifiex_band_5ghz;
1683+ else
1684+ wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
1685+
1686+ wiphy->iface_combinations = &mwifiex_iface_comb_ap_sta;
1687+ wiphy->n_iface_combinations = 1;
14771688
14781689 /* Initialize cipher suits */
1479− wdev->wiphy->cipher_suites = mwifiex_cipher_suites;
1480− wdev->wiphy->n_cipher_suites = ARRAY_SIZE(mwifiex_cipher_suites);
1690+ wiphy->cipher_suites = mwifiex_cipher_suites;
1691+ wiphy->n_cipher_suites = ARRAY_SIZE(mwifiex_cipher_suites);
14811692
1482− memcpy(wdev->wiphy->perm_addr, priv->curr_addr, ETH_ALEN);
1483− wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
1693+ memcpy(wiphy->perm_addr, priv->curr_addr, ETH_ALEN);
1694+ wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
1695+ wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME | WIPHY_FLAG_CUSTOM_REGULATORY;
14841696
14851697 /* Reserve space for mwifiex specific private data for BSS */
1486− wdev->wiphy->bss_priv_size = sizeof(struct mwifiex_bss_priv);
1487−
1488− wdev->wiphy->reg_notifier = mwifiex_reg_notifier;
1698+ wiphy->bss_priv_size = sizeof(struct mwifiex_bss_priv);
14891699
1490− /* Set struct mwifiex_private pointer in wiphy_priv */
1491− wdev_priv = wiphy_priv(wdev->wiphy);
1700+ wiphy->reg_notifier = mwifiex_reg_notifier;
14921701
1493− *(unsigned long *) wdev_priv = (unsigned long) priv;
1702+ /* Set struct mwifiex_adapter pointer in wiphy_priv */
1703+ wdev_priv = wiphy_priv(wiphy);
1704+ *(unsigned long *)wdev_priv = (unsigned long)adapter;
14941705
1495− set_wiphy_dev(wdev->wiphy, (struct device *) priv->adapter->dev);
1706+ set_wiphy_dev(wiphy, (struct device *)priv->adapter->dev);
14961707
1497− ret = wiphy_register(wdev->wiphy);
1708+ ret = wiphy_register(wiphy);
14981709 if (ret < 0) {
1499− dev_err(priv->adapter->dev, "%s: registering cfg80211 device\n",
1500− __func__);
1501− wiphy_free(wdev->wiphy);
1502− kfree(wdev);
1710+ dev_err(adapter->dev,
1711+ "%s: wiphy_register failed: %d\n", __func__, ret);
1712+ wiphy_free(wiphy);
15031713 return ret;
1504− } else {
1505− dev_dbg(priv->adapter->dev,
1506− "info: successfully registered wiphy device\n");
15071714 }
1508−
15091715 country_code = mwifiex_11d_code_2_region(priv->adapter->region_code);
1510− if (country_code && regulatory_hint(wdev->wiphy, country_code))
1511− dev_err(priv->adapter->dev,
1512− "%s: regulatory_hint failed\n", __func__);
1513−
1514− priv->wdev = wdev;
1716+ if (country_code && regulatory_hint(wiphy, country_code))
1717+ dev_err(adapter->dev, "regulatory_hint() failed\n");
15151718
1719+ adapter->wiphy = wiphy;
15161720 return ret;
15171721 }
drivers/net/wireless/mwifiex/cfg80211.h+1−1
@@ -24,6 +24,6 @@ · 23 unmodified lines
2424
2525 #include "main.h"
2626
27−int mwifiex_register_cfg80211(struct mwifiex_private *);
27+int mwifiex_register_cfg80211(struct mwifiex_adapter *);
2828
2929 #endif
drivers/net/wireless/mwifiex/cmdevt.c+19−2
@@ -440,6 +440,11 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter) · 439 unmodified lines
440440 do_gettimeofday(&tstamp);
441441 dev_dbg(adapter->dev, "event: %lu.%lu: cause: %#x\n",
442442 tstamp.tv_sec, tstamp.tv_usec, eventcause);
443+ } else {
444+ /* Handle PS_SLEEP/AWAKE events on STA */
445+ priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA);
446+ if (!priv)
447+ priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
443448 }
444449
445450 ret = mwifiex_process_sta_event(priv);
@@ -540,8 +545,20 @@ int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no, · 94 unmodified lines
540545
541546 /* Prepare command */
542547 if (cmd_no) {
543− ret = mwifiex_sta_prepare_cmd(priv, cmd_no, cmd_action,
544− cmd_oid, data_buf, cmd_ptr);
548+ switch (cmd_no) {
549+ case HostCmd_CMD_UAP_SYS_CONFIG:
550+ case HostCmd_CMD_UAP_BSS_START:
551+ case HostCmd_CMD_UAP_BSS_STOP:
552+ ret = mwifiex_uap_prepare_cmd(priv, cmd_no, cmd_action,
553+ cmd_oid, data_buf,
554+ cmd_ptr);
555+ break;
556+ default:
557+ ret = mwifiex_sta_prepare_cmd(priv, cmd_no, cmd_action,
558+ cmd_oid, data_buf,
559+ cmd_ptr);
560+ break;
561+ }
545562 } else {
546563 ret = mwifiex_cmd_host_cmd(priv, cmd_ptr, data_buf);
547564 cmd_node->cmd_flag |= CMD_F_HOSTCMD;
drivers/net/wireless/mwifiex/decl.h+12−1
@@ -28,7 +28,7 @@ · 27 unmodified lines
2828 #include <linux/ieee80211.h>
2929
3030
31−#define MWIFIEX_MAX_BSS_NUM (1)
31+#define MWIFIEX_MAX_BSS_NUM (2)
3232
3333 #define MWIFIEX_MIN_DATA_HEADER_LEN 36 /* sizeof(mwifiex_txpd)
3434 * + 4 byte alignment
@@ -55,11 +55,17 @@ · 20 unmodified lines
5555 #define MWIFIEX_RX_DATA_BUF_SIZE (4 * 1024)
5656 #define MWIFIEX_RX_CMD_BUF_SIZE (2 * 1024)
5757
58+#define MAX_BEACON_PERIOD (4000)
59+#define MIN_BEACON_PERIOD (50)
60+#define MAX_DTIM_PERIOD (100)
61+#define MIN_DTIM_PERIOD (1)
62+
5863 #define MWIFIEX_RTS_MIN_VALUE (0)
5964 #define MWIFIEX_RTS_MAX_VALUE (2347)
6065 #define MWIFIEX_FRAG_MIN_VALUE (256)
6166 #define MWIFIEX_FRAG_MAX_VALUE (2346)
6267
68+#define MWIFIEX_RETRY_LIMIT 14
6369 #define MWIFIEX_SDIO_BLOCK_SIZE 256
6470
6571 #define MWIFIEX_BUF_FLAG_REQUEUED_PKT BIT(0)
@@ -92,6 +98,11 @@ struct mwifiex_fw_image { · 26 unmodified lines
9298 u32 fw_len;
9399 };
94100
101+struct mwifiex_802_11_ssid {
102+ u32 ssid_len;
103+ u8 ssid[IEEE80211_MAX_SSID_LEN];
104+};
105+
95106 struct mwifiex_wait_queue {
96107 wait_queue_head_t wait;
97108 int status;
drivers/net/wireless/mwifiex/fw.h+158−1
@@ -93,6 +93,20 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { · 92 unmodified lines
9393
9494 #define CAL_SNR(RSSI, NF) ((s16)((s16)(RSSI)-(s16)(NF)))
9595
96+#define UAP_BSS_PARAMS_I 0
97+#define UAP_CUSTOM_IE_I 1
98+#define MWIFIEX_AUTO_IDX_MASK 0xffff
99+#define MWIFIEX_DELETE_MASK 0x0000
100+#define MGMT_MASK_ASSOC_REQ 0x01
101+#define MGMT_MASK_REASSOC_REQ 0x04
102+#define MGMT_MASK_ASSOC_RESP 0x02
103+#define MGMT_MASK_REASSOC_RESP 0x08
104+#define MGMT_MASK_PROBE_REQ 0x10
105+#define MGMT_MASK_PROBE_RESP 0x20
106+#define MGMT_MASK_BEACON 0x100
107+
108+#define TLV_TYPE_UAP_SSID 0x0000
109+
96110 #define PROPRIETARY_TLV_BASE_ID 0x0100
97111 #define TLV_TYPE_KEY_MATERIAL (PROPRIETARY_TLV_BASE_ID + 0)
98112 #define TLV_TYPE_CHANLIST (PROPRIETARY_TLV_BASE_ID + 1)
@@ -104,14 +118,26 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { · 5 unmodified lines
104118 #define TLV_TYPE_TSFTIMESTAMP (PROPRIETARY_TLV_BASE_ID + 19)
105119 #define TLV_TYPE_RSSI_HIGH (PROPRIETARY_TLV_BASE_ID + 22)
106120 #define TLV_TYPE_AUTH_TYPE (PROPRIETARY_TLV_BASE_ID + 31)
121+#define TLV_TYPE_STA_MAC_ADDR (PROPRIETARY_TLV_BASE_ID + 32)
107122 #define TLV_TYPE_CHANNELBANDLIST (PROPRIETARY_TLV_BASE_ID + 42)
123+#define TLV_TYPE_UAP_BEACON_PERIOD (PROPRIETARY_TLV_BASE_ID + 44)
124+#define TLV_TYPE_UAP_DTIM_PERIOD (PROPRIETARY_TLV_BASE_ID + 45)
125+#define TLV_TYPE_UAP_RTS_THRESHOLD (PROPRIETARY_TLV_BASE_ID + 51)
126+#define TLV_TYPE_UAP_WPA_PASSPHRASE (PROPRIETARY_TLV_BASE_ID + 60)
127+#define TLV_TYPE_UAP_ENCRY_PROTOCOL (PROPRIETARY_TLV_BASE_ID + 64)
128+#define TLV_TYPE_UAP_AKMP (PROPRIETARY_TLV_BASE_ID + 65)
129+#define TLV_TYPE_UAP_FRAG_THRESHOLD (PROPRIETARY_TLV_BASE_ID + 70)
108130 #define TLV_TYPE_RATE_DROP_CONTROL (PROPRIETARY_TLV_BASE_ID + 82)
109131 #define TLV_TYPE_RATE_SCOPE (PROPRIETARY_TLV_BASE_ID + 83)
110132 #define TLV_TYPE_POWER_GROUP (PROPRIETARY_TLV_BASE_ID + 84)
133+#define TLV_TYPE_UAP_RETRY_LIMIT (PROPRIETARY_TLV_BASE_ID + 93)
111134 #define TLV_TYPE_WAPI_IE (PROPRIETARY_TLV_BASE_ID + 94)
135+#define TLV_TYPE_UAP_MGMT_FRAME (PROPRIETARY_TLV_BASE_ID + 104)
112136 #define TLV_TYPE_MGMT_IE (PROPRIETARY_TLV_BASE_ID + 105)
113137 #define TLV_TYPE_AUTO_DS_PARAM (PROPRIETARY_TLV_BASE_ID + 113)
114138 #define TLV_TYPE_PS_PARAM (PROPRIETARY_TLV_BASE_ID + 114)
139+#define TLV_TYPE_PWK_CIPHER (PROPRIETARY_TLV_BASE_ID + 145)
140+#define TLV_TYPE_GWK_CIPHER (PROPRIETARY_TLV_BASE_ID + 146)
115141
116142 #define MWIFIEX_TX_DATA_BUF_SIZE_2K 2048
117143
@@ -209,6 +235,9 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { · 91 unmodified lines
209235 #define HostCmd_CMD_RSSI_INFO 0x00a4
210236 #define HostCmd_CMD_FUNC_INIT 0x00a9
211237 #define HostCmd_CMD_FUNC_SHUTDOWN 0x00aa
238+#define HostCmd_CMD_UAP_SYS_CONFIG 0x00b0
239+#define HostCmd_CMD_UAP_BSS_START 0x00b1
240+#define HostCmd_CMD_UAP_BSS_STOP 0x00b2
212241 #define HostCmd_CMD_11N_CFG 0x00cd
213242 #define HostCmd_CMD_11N_ADDBA_REQ 0x00ce
214243 #define HostCmd_CMD_11N_ADDBA_RSP 0x00cf
@@ -223,6 +252,19 @@ enum MWIFIEX_802_11_PRIVACY_FILTER { · 8 unmodified lines
223252 #define HostCmd_CMD_SET_BSS_MODE 0x00f7
224253 #define HostCmd_CMD_PCIE_DESC_DETAILS 0x00fa
225254
255+#define PROTOCOL_NO_SECURITY 0x01
256+#define PROTOCOL_STATIC_WEP 0x02
257+#define PROTOCOL_WPA 0x08
258+#define PROTOCOL_WPA2 0x20
259+#define PROTOCOL_WPA2_MIXED 0x28
260+#define PROTOCOL_EAP 0x40
261+#define KEY_MGMT_NONE 0x04
262+#define KEY_MGMT_PSK 0x02
263+#define KEY_MGMT_EAP 0x01
264+#define CIPHER_TKIP 0x04
265+#define CIPHER_AES_CCMP 0x08
266+#define VALID_CIPHER_BITMAP 0x0c
267+
226268 enum ENH_PS_MODES {
227269 EN_PS = 1,
228270 DIS_PS = 2,
@@ -313,15 +355,20 @@ enum ENH_PS_MODES { · 84 unmodified lines
313355 #define EVENT_DATA_SNR_HIGH 0x00000027
314356 #define EVENT_LINK_QUALITY 0x00000028
315357 #define EVENT_PORT_RELEASE 0x0000002b
358+#define EVENT_UAP_STA_DEAUTH 0x0000002c
359+#define EVENT_UAP_STA_ASSOC 0x0000002d
360+#define EVENT_UAP_BSS_START 0x0000002e
316361 #define EVENT_PRE_BEACON_LOST 0x00000031
317362 #define EVENT_ADDBA 0x00000033
318363 #define EVENT_DELBA 0x00000034
319364 #define EVENT_BA_STREAM_TIEMOUT 0x00000037
320365 #define EVENT_AMSDU_AGGR_CTRL 0x00000042
366+#define EVENT_UAP_BSS_IDLE 0x00000043
367+#define EVENT_UAP_BSS_ACTIVE 0x00000044
321368 #define EVENT_WEP_ICV_ERR 0x00000046
322369 #define EVENT_HS_ACT_REQ 0x00000047
323370 #define EVENT_BW_CHANGE 0x00000048
324−
371+#define EVENT_UAP_MIC_COUNTERMEASURES 0x0000004c
325372 #define EVENT_HOSTWAKE_STAIE 0x0000004d
326373
327374 #define EVENT_ID_MASK 0xffff
@@ -1103,6 +1150,101 @@ struct host_cmd_ds_802_11_eeprom_access { · 775 unmodified lines
11031150 u8 value;
11041151 } __packed;
11051152
1153+struct host_cmd_tlv {
1154+ __le16 type;
1155+ __le16 len;
1156+} __packed;
1157+
1158+struct mwifiex_assoc_event {
1159+ u8 sta_addr[ETH_ALEN];
1160+ __le16 type;
1161+ __le16 len;
1162+ __le16 frame_control;
1163+ __le16 cap_info;
1164+ __le16 listen_interval;
1165+ u8 data[0];
1166+} __packed;
1167+
1168+struct host_cmd_ds_sys_config {
1169+ __le16 action;
1170+ u8 tlv[0];
1171+};
1172+
1173+struct host_cmd_tlv_akmp {
1174+ struct host_cmd_tlv tlv;
1175+ __le16 key_mgmt;
1176+ __le16 key_mgmt_operation;
1177+} __packed;
1178+
1179+struct host_cmd_tlv_pwk_cipher {
1180+ struct host_cmd_tlv tlv;
1181+ __le16 proto;
1182+ u8 cipher;
1183+ u8 reserved;
1184+} __packed;
1185+
1186+struct host_cmd_tlv_gwk_cipher {
1187+ struct host_cmd_tlv tlv;
1188+ u8 cipher;
1189+ u8 reserved;
1190+} __packed;
1191+
1192+struct host_cmd_tlv_passphrase {
1193+ struct host_cmd_tlv tlv;
1194+ u8 passphrase[0];
1195+} __packed;
1196+
1197+struct host_cmd_tlv_auth_type {
1198+ struct host_cmd_tlv tlv;
1199+ u8 auth_type;
1200+} __packed;
1201+
1202+struct host_cmd_tlv_encrypt_protocol {
1203+ struct host_cmd_tlv tlv;
1204+ __le16 proto;
1205+} __packed;
1206+
1207+struct host_cmd_tlv_ssid {
1208+ struct host_cmd_tlv tlv;
1209+ u8 ssid[0];
1210+} __packed;
1211+
1212+struct host_cmd_tlv_beacon_period {
1213+ struct host_cmd_tlv tlv;
1214+ __le16 period;
1215+} __packed;
1216+
1217+struct host_cmd_tlv_dtim_period {
1218+ struct host_cmd_tlv tlv;
1219+ u8 period;
1220+} __packed;
1221+
1222+struct host_cmd_tlv_frag_threshold {
1223+ struct host_cmd_tlv tlv;
1224+ __le16 frag_thr;
1225+} __packed;
1226+
1227+struct host_cmd_tlv_rts_threshold {
1228+ struct host_cmd_tlv tlv;
1229+ __le16 rts_thr;
1230+} __packed;
1231+
1232+struct host_cmd_tlv_retry_limit {
1233+ struct host_cmd_tlv tlv;
1234+ u8 limit;
1235+} __packed;
1236+
1237+struct host_cmd_tlv_mac_addr {
1238+ struct host_cmd_tlv tlv;
1239+ u8 mac_addr[ETH_ALEN];
1240+} __packed;
1241+
1242+struct host_cmd_tlv_channel_band {
1243+ struct host_cmd_tlv tlv;
1244+ u8 band_config;
1245+ u8 channel;
1246+} __packed;
1247+
11061248 struct host_cmd_ds_802_11_rf_channel {
11071249 __le16 action;
11081250 __le16 current_channel;
@@ -1167,6 +1309,20 @@ struct host_cmd_ds_802_11_subsc_evt { · 58 unmodified lines
11671309 __le16 events;
11681310 } __packed;
11691311
1312+struct mwifiex_ie {
1313+ __le16 ie_index;
1314+ __le16 mgmt_subtype_mask;
1315+ __le16 ie_length;
1316+ u8 ie_buffer[IEEE_MAX_IE_SIZE];
1317+} __packed;
1318+
1319+#define MAX_MGMT_IE_INDEX 16
1320+struct mwifiex_ie_list {
1321+ __le16 type;
1322+ __le16 len;
1323+ struct mwifiex_ie ie_list[MAX_MGMT_IE_INDEX];
1324+} __packed;
1325+
11701326 struct host_cmd_ds_command {
11711327 __le16 command;
11721328 __le16 size;
@@ -1217,6 +1373,7 @@ struct host_cmd_ds_command { · 44 unmodified lines
12171373 struct host_cmd_ds_pcie_details pcie_host_spec;
12181374 struct host_cmd_ds_802_11_eeprom_access eeprom;
12191375 struct host_cmd_ds_802_11_subsc_evt subsc_evt;
1376+ struct host_cmd_ds_sys_config uap_sys_config;
12201377 } params;
12211378 } __packed;
12221379
drivers/net/wireless/mwifiex/ie.c+396−0
@@ -0,0 +1,396 @@
1+/*
2+ * Marvell Wireless LAN device driver: management IE handling- setting and
3+ * deleting IE.
4+ *
5+ * Copyright (C) 2012, Marvell International Ltd.
6+ *
7+ * This software file (the "File") is distributed by Marvell International
8+ * Ltd. under the terms of the GNU General Public License Version 2, June 1991
9+ * (the "License"). You may use, redistribute and/or modify this File in
10+ * accordance with the terms and conditions of the License, a copy of which
11+ * is available by writing to the Free Software Foundation, Inc.,
12+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
13+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14+ *
15+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
16+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
17+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
18+ * this warranty disclaimer.
19+ */
20+
21+#include "main.h"
22+
23+/* This function checks if current IE index is used by any on other interface.
24+ * Return: -1: yes, current IE index is used by someone else.
25+ * 0: no, current IE index is NOT used by other interface.
26+ */
27+static int
28+mwifiex_ie_index_used_by_other_intf(struct mwifiex_private *priv, u16 idx)
29+{
30+ int i;
31+ struct mwifiex_adapter *adapter = priv->adapter;
32+ struct mwifiex_ie *ie;
33+
34+ for (i = 0; i < adapter->priv_num; i++) {
35+ if (adapter->priv[i] != priv) {
36+ ie = &adapter->priv[i]->mgmt_ie[idx];
37+ if (ie->mgmt_subtype_mask && ie->ie_length)
38+ return -1;
39+ }
40+ }
41+
42+ return 0;
43+}
44+
45+/* Get unused IE index. This index will be used for setting new IE */
46+static int
47+mwifiex_ie_get_autoidx(struct mwifiex_private *priv, u16 subtype_mask,
48+ struct mwifiex_ie *ie, u16 *index)
49+{
50+ u16 mask, len, i;
51+
52+ for (i = 0; i < priv->adapter->max_mgmt_ie_index; i++) {
53+ mask = le16_to_cpu(priv->mgmt_ie[i].mgmt_subtype_mask);
54+ len = le16_to_cpu(priv->mgmt_ie[i].ie_length) +
55+ le16_to_cpu(ie->ie_length);
56+
57+ if (mask == MWIFIEX_AUTO_IDX_MASK)
58+ continue;
59+
60+ if (mask == subtype_mask) {
61+ if (len > IEEE_MAX_IE_SIZE)
62+ continue;
63+
64+ *index = i;
65+ return 0;
66+ }
67+
68+ if (!priv->mgmt_ie[i].ie_length) {
69+ if (mwifiex_ie_index_used_by_other_intf(priv, i))
70+ continue;
71+
72+ *index = i;
73+ return 0;
74+ }
75+ }
76+
77+ return -1;
78+}
79+
80+/* This function prepares IE data buffer for command to be sent to FW */
81+static int
82+mwifiex_update_autoindex_ies(struct mwifiex_private *priv,
83+ struct mwifiex_ie_list *ie_list)
84+{
85+ u16 travel_len, index, mask;
86+ s16 input_len;
87+ struct mwifiex_ie *ie;
88+ u8 *tmp;
89+
90+ input_len = le16_to_cpu(ie_list->len);
91+ travel_len = sizeof(struct host_cmd_tlv);
92+
93+ ie_list->len = 0;
94+
95+ while (input_len > 0) {
96+ ie = (struct mwifiex_ie *)(((u8 *)ie_list) + travel_len);
97+ input_len -= le16_to_cpu(ie->ie_length) + MWIFIEX_IE_HDR_SIZE;
98+ travel_len += le16_to_cpu(ie->ie_length) + MWIFIEX_IE_HDR_SIZE;
99+
100+ index = le16_to_cpu(ie->ie_index);
101+ mask = le16_to_cpu(ie->mgmt_subtype_mask);
102+
103+ if (index == MWIFIEX_AUTO_IDX_MASK) {
104+ /* automatic addition */
105+ if (mwifiex_ie_get_autoidx(priv, mask, ie, &index))
106+ return -1;
107+ if (index == MWIFIEX_AUTO_IDX_MASK)
108+ return -1;
109+
110+ tmp = (u8 *)&priv->mgmt_ie[index].ie_buffer;
111+ tmp += le16_to_cpu(priv->mgmt_ie[index].ie_length);
112+ memcpy(tmp, &ie->ie_buffer, le16_to_cpu(ie->ie_length));
113+ le16_add_cpu(&priv->mgmt_ie[index].ie_length,
114+ le16_to_cpu(ie->ie_length));
115+ priv->mgmt_ie[index].ie_index = cpu_to_le16(index);
116+ priv->mgmt_ie[index].mgmt_subtype_mask =
117+ cpu_to_le16(mask);
118+
119+ ie->ie_index = cpu_to_le16(index);
120+ ie->ie_length = priv->mgmt_ie[index].ie_length;
121+ memcpy(&ie->ie_buffer, &priv->mgmt_ie[index].ie_buffer,
122+ le16_to_cpu(priv->mgmt_ie[index].ie_length));
123+ } else {
124+ if (mask != MWIFIEX_DELETE_MASK)
125+ return -1;
126+ /*
127+ * Check if this index is being used on any
128+ * other interface.
129+ */
130+ if (mwifiex_ie_index_used_by_other_intf(priv, index))
131+ return -1;
132+
133+ ie->ie_length = 0;
134+ memcpy(&priv->mgmt_ie[index], ie,
135+ sizeof(struct mwifiex_ie));
136+ }
137+
138+ le16_add_cpu(&ie_list->len,
139+ le16_to_cpu(priv->mgmt_ie[index].ie_length) +
140+ MWIFIEX_IE_HDR_SIZE);
141+ }
142+
143+ if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP)
144+ return mwifiex_send_cmd_async(priv, HostCmd_CMD_UAP_SYS_CONFIG,
145+ HostCmd_ACT_GEN_SET,
146+ UAP_CUSTOM_IE_I, ie_list);
147+
148+ return 0;
149+}
150+
151+/* Copy individual custom IEs for beacon, probe response and assoc response
152+ * and prepare single structure for IE setting.
153+ * This function also updates allocated IE indices from driver.
154+ */
155+static int
156+mwifiex_update_uap_custom_ie(struct mwifiex_private *priv,
157+ struct mwifiex_ie *beacon_ie, u16 *beacon_idx,
158+ struct mwifiex_ie *pr_ie, u16 *probe_idx,
159+ struct mwifiex_ie *ar_ie, u16 *assoc_idx)
160+{
161+ struct mwifiex_ie_list *ap_custom_ie;
162+ u8 *pos;
163+ u16 len;
164+ int ret;
165+
166+ ap_custom_ie = kzalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
167+ if (!ap_custom_ie)
168+ return -ENOMEM;
169+
170+ ap_custom_ie->type = cpu_to_le16(TLV_TYPE_MGMT_IE);
171+ pos = (u8 *)ap_custom_ie->ie_list;
172+
173+ if (beacon_ie) {
174+ len = sizeof(struct mwifiex_ie) - IEEE_MAX_IE_SIZE +
175+ le16_to_cpu(beacon_ie->ie_length);
176+ memcpy(pos, beacon_ie, len);
177+ pos += len;
178+ le16_add_cpu(&ap_custom_ie->len, len);
179+ }
180+ if (pr_ie) {
181+ len = sizeof(struct mwifiex_ie) - IEEE_MAX_IE_SIZE +
182+ le16_to_cpu(pr_ie->ie_length);
183+ memcpy(pos, pr_ie, len);
184+ pos += len;
185+ le16_add_cpu(&ap_custom_ie->len, len);
186+ }
187+ if (ar_ie) {
188+ len = sizeof(struct mwifiex_ie) - IEEE_MAX_IE_SIZE +
189+ le16_to_cpu(ar_ie->ie_length);
190+ memcpy(pos, ar_ie, len);
191+ pos += len;
192+ le16_add_cpu(&ap_custom_ie->len, len);
193+ }
194+
195+ ret = mwifiex_update_autoindex_ies(priv, ap_custom_ie);
196+
197+ pos = (u8 *)(&ap_custom_ie->ie_list[0].ie_index);
198+ if (beacon_ie && *beacon_idx == MWIFIEX_AUTO_IDX_MASK) {
199+ /* save beacon ie index after auto-indexing */
200+ *beacon_idx = le16_to_cpu(ap_custom_ie->ie_list[0].ie_index);
201+ len = sizeof(*beacon_ie) - IEEE_MAX_IE_SIZE +
202+ le16_to_cpu(beacon_ie->ie_length);
203+ pos += len;
204+ }
205+ if (pr_ie && le16_to_cpu(pr_ie->ie_index) == MWIFIEX_AUTO_IDX_MASK) {
206+ /* save probe resp ie index after auto-indexing */
207+ *probe_idx = *((u16 *)pos);
208+ len = sizeof(*pr_ie) - IEEE_MAX_IE_SIZE +
209+ le16_to_cpu(pr_ie->ie_length);
210+ pos += len;
211+ }
212+ if (ar_ie && le16_to_cpu(ar_ie->ie_index) == MWIFIEX_AUTO_IDX_MASK)
213+ /* save assoc resp ie index after auto-indexing */
214+ *assoc_idx = *((u16 *)pos);
215+
216+ return ret;
217+}
218+
219+/* This function parses different IEs- Tail IEs, beacon IEs, probe response IEs,
220+ * association response IEs from cfg80211_ap_settings function and sets these IE
221+ * to FW.
222+ */
223+int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
224+ struct cfg80211_ap_settings *params)
225+{
226+ struct mwifiex_ie *beacon_ie = NULL, *pr_ie = NULL;
227+ struct mwifiex_ie *ar_ie = NULL, *rsn_ie = NULL;
228+ struct ieee_types_header *ie = NULL;
229+ u16 beacon_idx = MWIFIEX_AUTO_IDX_MASK, pr_idx = MWIFIEX_AUTO_IDX_MASK;
230+ u16 ar_idx = MWIFIEX_AUTO_IDX_MASK, rsn_idx = MWIFIEX_AUTO_IDX_MASK;
231+ u16 mask;
232+ int ret = 0;
233+
234+ if (params->beacon.tail && params->beacon.tail_len) {
235+ ie = (void *)cfg80211_find_ie(WLAN_EID_RSN, params->beacon.tail,
236+ params->beacon.tail_len);
237+ if (ie) {
238+ rsn_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
239+ if (!rsn_ie)
240+ return -ENOMEM;
241+
242+ rsn_ie->ie_index = cpu_to_le16(rsn_idx);
243+ mask = MGMT_MASK_BEACON | MGMT_MASK_PROBE_RESP |
244+ MGMT_MASK_ASSOC_RESP;
245+ rsn_ie->mgmt_subtype_mask = cpu_to_le16(mask);
246+ rsn_ie->ie_length = cpu_to_le16(ie->len + 2);
247+ memcpy(rsn_ie->ie_buffer, ie, ie->len + 2);
248+
249+ if (mwifiex_update_uap_custom_ie(priv, rsn_ie, &rsn_idx,
250+ NULL, NULL,
251+ NULL, NULL)) {
252+ ret = -1;
253+ goto done;
254+ }
255+
256+ priv->rsn_idx = rsn_idx;
257+ }
258+ }
259+
260+ if (params->beacon.beacon_ies && params->beacon.beacon_ies_len) {
261+ beacon_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
262+ if (!beacon_ie) {
263+ ret = -ENOMEM;
264+ goto done;
265+ }
266+
267+ beacon_ie->ie_index = cpu_to_le16(beacon_idx);
268+ beacon_ie->mgmt_subtype_mask = cpu_to_le16(MGMT_MASK_BEACON);
269+ beacon_ie->ie_length =
270+ cpu_to_le16(params->beacon.beacon_ies_len);
271+ memcpy(beacon_ie->ie_buffer, params->beacon.beacon_ies,
272+ params->beacon.beacon_ies_len);
273+ }
274+
275+ if (params->beacon.proberesp_ies && params->beacon.proberesp_ies_len) {
276+ pr_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
277+ if (!pr_ie) {
278+ ret = -ENOMEM;
279+ goto done;
280+ }
281+
282+ pr_ie->ie_index = cpu_to_le16(pr_idx);
283+ pr_ie->mgmt_subtype_mask = cpu_to_le16(MGMT_MASK_PROBE_RESP);
284+ pr_ie->ie_length =
285+ cpu_to_le16(params->beacon.proberesp_ies_len);
286+ memcpy(pr_ie->ie_buffer, params->beacon.proberesp_ies,
287+ params->beacon.proberesp_ies_len);
288+ }
289+
290+ if (params->beacon.assocresp_ies && params->beacon.assocresp_ies_len) {
291+ ar_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
292+ if (!ar_ie) {
293+ ret = -ENOMEM;
294+ goto done;
295+ }
296+
297+ ar_ie->ie_index = cpu_to_le16(ar_idx);
298+ mask = MGMT_MASK_ASSOC_RESP | MGMT_MASK_REASSOC_RESP;
299+ ar_ie->mgmt_subtype_mask = cpu_to_le16(mask);
300+ ar_ie->ie_length =
301+ cpu_to_le16(params->beacon.assocresp_ies_len);
302+ memcpy(ar_ie->ie_buffer, params->beacon.assocresp_ies,
303+ params->beacon.assocresp_ies_len);
304+ }
305+
306+ if (beacon_ie || pr_ie || ar_ie) {
307+ ret = mwifiex_update_uap_custom_ie(priv, beacon_ie,
308+ &beacon_idx, pr_ie,
309+ &pr_idx, ar_ie, &ar_idx);
310+ if (ret)
311+ goto done;
312+ }
313+
314+ priv->beacon_idx = beacon_idx;
315+ priv->proberesp_idx = pr_idx;
316+ priv->assocresp_idx = ar_idx;
317+
318+done:
319+ kfree(beacon_ie);
320+ kfree(pr_ie);
321+ kfree(ar_ie);
322+ kfree(rsn_ie);
323+
324+ return ret;
325+}
326+
327+/* This function removes management IE set */
328+int mwifiex_del_mgmt_ies(struct mwifiex_private *priv)
329+{
330+ struct mwifiex_ie *beacon_ie = NULL, *pr_ie = NULL;
331+ struct mwifiex_ie *ar_ie = NULL, *rsn_ie = NULL;
332+ int ret = 0;
333+
334+ if (priv->rsn_idx != MWIFIEX_AUTO_IDX_MASK) {
335+ rsn_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
336+ if (!rsn_ie)
337+ return -ENOMEM;
338+
339+ rsn_ie->ie_index = cpu_to_le16(priv->rsn_idx);
340+ rsn_ie->mgmt_subtype_mask = cpu_to_le16(MWIFIEX_DELETE_MASK);
341+ rsn_ie->ie_length = 0;
342+ if (mwifiex_update_uap_custom_ie(priv, rsn_ie, &priv->rsn_idx,
343+ NULL, &priv->proberesp_idx,
344+ NULL, &priv->assocresp_idx)) {
345+ ret = -1;
346+ goto done;
347+ }
348+
349+ priv->rsn_idx = MWIFIEX_AUTO_IDX_MASK;
350+ }
351+
352+ if (priv->beacon_idx != MWIFIEX_AUTO_IDX_MASK) {
353+ beacon_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
354+ if (!beacon_ie) {
355+ ret = -ENOMEM;
356+ goto done;
357+ }
358+ beacon_ie->ie_index = cpu_to_le16(priv->beacon_idx);
359+ beacon_ie->mgmt_subtype_mask = cpu_to_le16(MWIFIEX_DELETE_MASK);
360+ beacon_ie->ie_length = 0;
361+ }
362+ if (priv->proberesp_idx != MWIFIEX_AUTO_IDX_MASK) {
363+ pr_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
364+ if (!pr_ie) {
365+ ret = -ENOMEM;
366+ goto done;
367+ }
368+ pr_ie->ie_index = cpu_to_le16(priv->proberesp_idx);
369+ pr_ie->mgmt_subtype_mask = cpu_to_le16(MWIFIEX_DELETE_MASK);
370+ pr_ie->ie_length = 0;
371+ }
372+ if (priv->assocresp_idx != MWIFIEX_AUTO_IDX_MASK) {
373+ ar_ie = kmalloc(sizeof(struct mwifiex_ie), GFP_KERNEL);
374+ if (!ar_ie) {
375+ ret = -ENOMEM;
376+ goto done;
377+ }
378+ ar_ie->ie_index = cpu_to_le16(priv->assocresp_idx);
379+ ar_ie->mgmt_subtype_mask = cpu_to_le16(MWIFIEX_DELETE_MASK);
380+ ar_ie->ie_length = 0;
381+ }
382+
383+ if (beacon_ie || pr_ie || ar_ie)
384+ ret = mwifiex_update_uap_custom_ie(priv,
385+ beacon_ie, &priv->beacon_idx,
386+ pr_ie, &priv->proberesp_idx,
387+ ar_ie, &priv->assocresp_idx);
388+
389+done:
390+ kfree(beacon_ie);
391+ kfree(pr_ie);
392+ kfree(ar_ie);
393+ kfree(rsn_ie);
394+
395+ return ret;
396+}
drivers/net/wireless/mwifiex/init.c+1−0
@@ -279,6 +279,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) · 278 unmodified lines
279279 memset(&adapter->arp_filter, 0, sizeof(adapter->arp_filter));
280280 adapter->arp_filter_size = 0;
281281 adapter->channel_type = NL80211_CHAN_HT20;
282+ adapter->max_mgmt_ie_index = MAX_MGMT_IE_INDEX;
282283 }
283284
284285 /*
drivers/net/wireless/mwifiex/ioctl.h+32−0
@@ -62,6 +62,36 @@ enum { · 61 unmodified lines
6262 BAND_AN = 16,
6363 };
6464
65+#define MWIFIEX_WPA_PASSHPHRASE_LEN 64
66+struct wpa_param {
67+ u8 pairwise_cipher_wpa;
68+ u8 pairwise_cipher_wpa2;
69+ u8 group_cipher;
70+ u32 length;
71+ u8 passphrase[MWIFIEX_WPA_PASSHPHRASE_LEN];
72+};
73+
74+#define KEY_MGMT_ON_HOST 0x03
75+#define MWIFIEX_AUTH_MODE_AUTO 0xFF
76+#define BAND_CONFIG_MANUAL 0x00
77+struct mwifiex_uap_bss_param {
78+ u8 channel;
79+ u8 band_cfg;
80+ u16 rts_threshold;
81+ u16 frag_threshold;
82+ u8 retry_limit;
83+ struct mwifiex_802_11_ssid ssid;
84+ u8 bcast_ssid_ctl;
85+ u8 radio_ctl;
86+ u8 dtim_period;
87+ u16 beacon_period;
88+ u16 auth_mode;
89+ u16 protocol;
90+ u16 key_mgmt;
91+ u16 key_mgmt_operation;
92+ struct wpa_param wpa_cfg;
93+};
94+
6595 enum {
6696 ADHOC_IDLE,
6797 ADHOC_STARTED,
@@ -269,6 +299,8 @@ struct mwifiex_ds_read_eeprom { · 201 unmodified lines
269299
270300 #define IEEE_MAX_IE_SIZE 256
271301
302+#define MWIFIEX_IE_HDR_SIZE (sizeof(struct mwifiex_ie) - IEEE_MAX_IE_SIZE)
303+
272304 struct mwifiex_ds_misc_gen_ie {
273305 u32 type;
274306 u32 len;
drivers/net/wireless/mwifiex/join.c+16−10
@@ -1374,22 +1374,28 @@ static int mwifiex_deauthenticate_infra(struct mwifiex_private *priv, u8 *mac) · 1373 unmodified lines
13741374 *
13751375 * In case of infra made, it sends deauthentication request, and
13761376 * in case of ad-hoc mode, a stop network request is sent to the firmware.
1377+ * In AP mode, a command to stop bss is sent to firmware.
13771378 */
13781379 int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac)
13791380 {
1380− int ret = 0;
1381+ if (!priv->media_connected)
1382+ return 0;
13811383
1382− if (priv->media_connected) {
1383− if (priv->bss_mode == NL80211_IFTYPE_STATION) {
1384− ret = mwifiex_deauthenticate_infra(priv, mac);
1385− } else if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
1386− ret = mwifiex_send_cmd_sync(priv,
1387− HostCmd_CMD_802_11_AD_HOC_STOP,
1388− HostCmd_ACT_GEN_SET, 0, NULL);
1389− }
1384+ switch (priv->bss_mode) {
1385+ case NL80211_IFTYPE_STATION:
1386+ return mwifiex_deauthenticate_infra(priv, mac);
1387+ case NL80211_IFTYPE_ADHOC:
1388+ return mwifiex_send_cmd_sync(priv,
1389+ HostCmd_CMD_802_11_AD_HOC_STOP,
1390+ HostCmd_ACT_GEN_SET, 0, NULL);
1391+ case NL80211_IFTYPE_AP:
1392+ return mwifiex_send_cmd_sync(priv, HostCmd_CMD_UAP_BSS_STOP,
1393+ HostCmd_ACT_GEN_SET, 0, NULL);
1394+ default:
1395+ break;
13901396 }
13911397
1392− return ret;
1398+ return 0;
13931399 }
13941400 EXPORT_SYMBOL_GPL(mwifiex_deauthenticate);
13951401
drivers/net/wireless/mwifiex/main.c+36−21
@@ -64,17 +64,17 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops, · 63 unmodified lines
6464
6565 adapter->priv_num = 0;
6666
67− /* Allocate memory for private structure */
68− adapter->priv[0] = kzalloc(sizeof(struct mwifiex_private), GFP_KERNEL);
69− if (!adapter->priv[0]) {
70− dev_err(adapter->dev,
71− "%s: failed to alloc priv[0]\n", __func__);
72− goto error;
73− }
74−
75− adapter->priv_num++;
67+ for (i = 0; i < MWIFIEX_MAX_BSS_NUM; i++) {
68+ /* Allocate memory for private structure */
69+ adapter->priv[i] =
70+ kzalloc(sizeof(struct mwifiex_private), GFP_KERNEL);
71+ if (!adapter->priv[i])
72+ goto error;
7673
77− adapter->priv[0]->adapter = adapter;
74+ adapter->priv[i]->adapter = adapter;
75+ adapter->priv[i]->bss_priority = i;
76+ adapter->priv_num++;
77+ }
7878 mwifiex_init_lock_list(adapter);
7979
8080 init_timer(&adapter->cmd_timer);
@@ -349,19 +349,26 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) · 268 unmodified lines
349349 if (adapter->hw_status != MWIFIEX_HW_STATUS_READY)
350350 goto done;
351351
352− priv = adapter->priv[0];
353− if (mwifiex_register_cfg80211(priv) != 0) {
352+ priv = adapter->priv[MWIFIEX_BSS_ROLE_STA];
353+ if (mwifiex_register_cfg80211(adapter)) {
354354 dev_err(adapter->dev, "cannot register with cfg80211\n");
355355 goto err_init_fw;
356356 }
357357
358358 rtnl_lock();
359359 /* Create station interface by default */
360− if (!mwifiex_add_virtual_intf(priv->wdev->wiphy, "mlan%d",
360+ if (!mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d",
361361 NL80211_IFTYPE_STATION, NULL, NULL)) {
362362 dev_err(adapter->dev, "cannot create default STA interface\n");
363363 goto err_add_intf;
364364 }
365+
366+ /* Create AP interface by default */
367+ if (!mwifiex_add_virtual_intf(adapter->wiphy, "uap%d",
368+ NL80211_IFTYPE_AP, NULL, NULL)) {
369+ dev_err(adapter->dev, "cannot create default AP interface\n");
370+ goto err_add_intf;
371+ }
365372 rtnl_unlock();
366373
367374 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1);
@@ -369,7 +376,7 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) · 1 unmodified line
369376 goto done;
370377
371378 err_add_intf:
372− mwifiex_del_virtual_intf(priv->wdev->wiphy, priv->netdev);
379+ mwifiex_del_virtual_intf(adapter->wiphy, priv->netdev);
373380 rtnl_unlock();
374381 err_init_fw:
375382 pr_debug("info: %s: unregister device\n", __func__);
@@ -633,6 +640,12 @@ void mwifiex_init_priv_params(struct mwifiex_private *priv, · 257 unmodified lines
633640 priv->current_key_index = 0;
634641 priv->media_connected = false;
635642 memset(&priv->nick_name, 0, sizeof(priv->nick_name));
643+ memset(priv->mgmt_ie, 0,
644+ sizeof(struct mwifiex_ie) * MAX_MGMT_IE_INDEX);
645+ priv->beacon_idx = MWIFIEX_AUTO_IDX_MASK;
646+ priv->proberesp_idx = MWIFIEX_AUTO_IDX_MASK;
647+ priv->assocresp_idx = MWIFIEX_AUTO_IDX_MASK;
648+ priv->rsn_idx = MWIFIEX_AUTO_IDX_MASK;
636649 priv->num_tx_timeout = 0;
637650 memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN);
638651 }
@@ -830,19 +843,21 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem) · 191 unmodified lines
830843
831844 rtnl_lock();
832845 if (priv->wdev && priv->netdev)
833− mwifiex_del_virtual_intf(priv->wdev->wiphy,
834− priv->netdev);
846+ mwifiex_del_virtual_intf(adapter->wiphy, priv->netdev);
835847 rtnl_unlock();
836848 }
837849
838850 priv = adapter->priv[0];
839− if (!priv)
851+ if (!priv || !priv->wdev)
840852 goto exit_remove;
841853
842− if (priv->wdev) {
843− wiphy_unregister(priv->wdev->wiphy);
844− wiphy_free(priv->wdev->wiphy);
845− kfree(priv->wdev);
854+ wiphy_unregister(priv->wdev->wiphy);
855+ wiphy_free(priv->wdev->wiphy);
856+
857+ for (i = 0; i < adapter->priv_num; i++) {
858+ priv = adapter->priv[i];
859+ if (priv)
860+ kfree(priv->wdev);
846861 }
847862
848863 mwifiex_terminate_workqueue(adapter);
drivers/net/wireless/mwifiex/main.h+24−2
@@ -116,6 +116,7 @@ enum { · 115 unmodified lines
116116 #define MAX_FREQUENCY_BAND_BG 2484
117117
118118 #define MWIFIEX_EVENT_HEADER_LEN 4
119+#define MWIFIEX_UAP_EVENT_EXTRA_HEADER 2
119120
120121 #define MWIFIEX_TYPE_LEN 4
121122 #define MWIFIEX_USB_TYPE_CMD 0xF00DFACE
@@ -370,6 +371,7 @@ struct mwifiex_private { · 248 unmodified lines
370371 u8 bss_role;
371372 u8 bss_priority;
372373 u8 bss_num;
374+ u8 bss_started;
373375 u8 frame_type;
374376 u8 curr_addr[ETH_ALEN];
375377 u8 media_connected;
@@ -470,12 +472,16 @@ struct mwifiex_private { · 94 unmodified lines
470472 struct cfg80211_scan_request *scan_request;
471473 struct mwifiex_user_scan_cfg *user_scan_cfg;
472474 u8 cfg_bssid[6];
473− u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
474475 struct wps wps;
475476 u8 scan_block;
476477 s32 cqm_rssi_thold;
477478 u32 cqm_rssi_hyst;
478479 u8 subsc_evt_rssi_state;
480+ struct mwifiex_ie mgmt_ie[MAX_MGMT_IE_INDEX];
481+ u16 beacon_idx;
482+ u16 proberesp_idx;
483+ u16 assocresp_idx;
484+ u16 rsn_idx;
479485 };
480486
481487 enum mwifiex_ba_status {
@@ -571,6 +577,7 @@ struct mwifiex_adapter { · 89 unmodified lines
571577 char fw_name[32];
572578 int winner;
573579 struct device *dev;
580+ struct wiphy *wiphy;
574581 bool surprise_removed;
575582 u32 fw_release_number;
576583 u16 init_wait_q_woken;
@@ -677,6 +684,8 @@ struct mwifiex_adapter { · 100 unmodified lines
677684 struct cmd_ctrl_node *cmd_queued;
678685 spinlock_t queue_lock; /* lock for tx queues */
679686 struct completion fw_load;
687+ u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
688+ u16 max_mgmt_ie_index;
680689 };
681690
682691 int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
@@ -760,6 +769,9 @@ int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter, · 77 unmodified lines
760769 int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
761770 u16 cmd_action, u32 cmd_oid,
762771 void *data_buf, void *cmd_buf);
772+int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
773+ u16 cmd_action, u32 cmd_oid,
774+ void *data_buf, void *cmd_buf);
763775 int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
764776 struct host_cmd_ds_command *resp);
765777 int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *,
@@ -820,6 +832,9 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv, · 54 unmodified lines
820832 int is_command_pending(struct mwifiex_adapter *adapter);
821833 void mwifiex_init_priv_params(struct mwifiex_private *priv,
822834 struct net_device *dev);
835+int mwifiex_set_secure_params(struct mwifiex_private *priv,
836+ struct mwifiex_uap_bss_param *bss_config,
837+ struct cfg80211_ap_settings *params);
823838
824839 /*
825840 * This function checks if the queuing is RA based or not.
@@ -933,7 +948,8 @@ int mwifiex_set_radio(struct mwifiex_private *priv, u8 option); · 107 unmodified lines
933948 int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel);
934949
935950 int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
936− int key_len, u8 key_index, int disable);
951+ int key_len, u8 key_index, const u8 *mac_addr,
952+ int disable);
937953
938954 int mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len);
939955
@@ -969,6 +985,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv, · 29 unmodified lines
969985
970986 int mwifiex_main_process(struct mwifiex_adapter *);
971987
988+int mwifiex_uap_set_channel(struct mwifiex_private *priv, int channel);
972989 int mwifiex_bss_set_channel(struct mwifiex_private *,
973990 struct mwifiex_chan_freq_power *cfp);
974991 int mwifiex_get_bss_info(struct mwifiex_private *,
@@ -986,6 +1003,11 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy, · 11 unmodified lines
9861003 u32 *flags, struct vif_params *params);
9871004 int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev);
9881005
1006+void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config);
1007+
1008+int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
1009+ struct cfg80211_ap_settings *params);
1010+int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
9891011 u8 *mwifiex_11d_code_2_region(u8 code);
9901012
9911013 #ifdef CONFIG_DEBUG_FS
drivers/net/wireless/mwifiex/sta_cmd.c+47−22
@@ -498,7 +498,8 @@ mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, · 497 unmodified lines
498498 {
499499 struct host_cmd_ds_802_11_key_material *key_material =
500500 &cmd->params.key_material;
501− u16 key_param_len = 0;
501+ struct host_cmd_tlv_mac_addr *tlv_mac;
502+ u16 key_param_len = 0, cmd_size;
502503 int ret = 0;
503504 const u8 bc_mac[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
504505
@@ -614,11 +615,26 @@ mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, · 109 unmodified lines
614615 cpu_to_le16((u16) enc_key->key_len +
615616 KEYPARAMSET_FIXED_LEN);
616617
617− key_param_len = (u16) (enc_key->key_len + KEYPARAMSET_FIXED_LEN)
618+ key_param_len = (u16)(enc_key->key_len + KEYPARAMSET_FIXED_LEN)
618619 + sizeof(struct mwifiex_ie_types_header);
619620
620621 cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN
621622 + key_param_len);
623+
624+ if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) {
625+ tlv_mac = (void *)((u8 *)&key_material->key_param_set +
626+ key_param_len);
627+ tlv_mac->tlv.type = cpu_to_le16(TLV_TYPE_STA_MAC_ADDR);
628+ tlv_mac->tlv.len = cpu_to_le16(ETH_ALEN);
629+ memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN);
630+ cmd_size = key_param_len + S_DS_GEN +
631+ sizeof(key_material->action) +
632+ sizeof(struct host_cmd_tlv_mac_addr);
633+ } else {
634+ cmd_size = key_param_len + S_DS_GEN +
635+ sizeof(key_material->action);
636+ }
637+ cmd->size = cpu_to_le16(cmd_size);
622638 }
623639
624640 return ret;
@@ -1248,13 +1264,15 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta) · 623 unmodified lines
12481264 if (ret)
12491265 return -1;
12501266
1251− /* Enable IEEE PS by default */
1252− priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
1253− ret = mwifiex_send_cmd_async(priv,
1254− HostCmd_CMD_802_11_PS_MODE_ENH,
1255− EN_AUTO_PS, BITMAP_STA_PS, NULL);
1256− if (ret)
1257− return -1;
1267+ if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
1268+ /* Enable IEEE PS by default */
1269+ priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
1270+ ret = mwifiex_send_cmd_async(
1271+ priv, HostCmd_CMD_802_11_PS_MODE_ENH,
1272+ EN_AUTO_PS, BITMAP_STA_PS, NULL);
1273+ if (ret)
1274+ return -1;
1275+ }
12581276 }
12591277
12601278 /* get tx rate */
@@ -1270,12 +1288,14 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta) · 9 unmodified lines
12701288 if (ret)
12711289 return -1;
12721290
1273− /* set ibss coalescing_status */
1274− ret = mwifiex_send_cmd_async(priv,
1275− HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
1276− HostCmd_ACT_GEN_SET, 0, &enable);
1277− if (ret)
1278− return -1;
1291+ if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) {
1292+ /* set ibss coalescing_status */
1293+ ret = mwifiex_send_cmd_async(
1294+ priv, HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
1295+ HostCmd_ACT_GEN_SET, 0, &enable);
1296+ if (ret)
1297+ return -1;
1298+ }
12791299
12801300 memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl));
12811301 amsdu_aggr_ctrl.enable = true;
@@ -1293,7 +1313,8 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta) · 11 unmodified lines
12931313 if (ret)
12941314 return -1;
12951315
1296− if (first_sta && (priv->adapter->iface_type != MWIFIEX_USB)) {
1316+ if (first_sta && priv->adapter->iface_type != MWIFIEX_USB &&
1317+ priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
12971318 /* Enable auto deep sleep */
12981319 auto_ds.auto_ds = DEEP_SLEEP_ON;
12991320 auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME;
@@ -1305,12 +1326,16 @@ int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta) · 5 unmodified lines
13051326 return -1;
13061327 }
13071328
1308− /* Send cmd to FW to enable/disable 11D function */
1309− state_11d = ENABLE_11D;
1310− ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SNMP_MIB,
1311− HostCmd_ACT_GEN_SET, DOT11D_I, &state_11d);
1312− if (ret)
1313− dev_err(priv->adapter->dev, "11D: failed to enable 11D\n");
1329+ if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
1330+ /* Send cmd to FW to enable/disable 11D function */
1331+ state_11d = ENABLE_11D;
1332+ ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SNMP_MIB,
1333+ HostCmd_ACT_GEN_SET, DOT11D_I,
1334+ &state_11d);
1335+ if (ret)
1336+ dev_err(priv->adapter->dev,
1337+ "11D: failed to enable 11D\n");
1338+ }
13141339
13151340 /* Send cmd to FW to configure 11n specific configuration
13161341 * (Short GI, Channel BW, Green field support etc.) for transmit
drivers/net/wireless/mwifiex/sta_cmdresp.c+8−0
@@ -944,6 +944,14 @@ int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no, · 943 unmodified lines
944944 case HostCmd_CMD_802_11_SUBSCRIBE_EVENT:
945945 ret = mwifiex_ret_subsc_evt(priv, resp, data_buf);
946946 break;
947+ case HostCmd_CMD_UAP_SYS_CONFIG:
948+ break;
949+ case HostCmd_CMD_UAP_BSS_START:
950+ priv->bss_started = 1;
951+ break;
952+ case HostCmd_CMD_UAP_BSS_STOP:
953+ priv->bss_started = 0;
954+ break;
947955 default:
948956 dev_err(adapter->dev, "CMD_RESP: unknown cmd response %#x\n",
949957 resp->command);
drivers/net/wireless/mwifiex/sta_event.c+50−1
@@ -184,8 +184,10 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv) · 183 unmodified lines
184184 int mwifiex_process_sta_event(struct mwifiex_private *priv)
185185 {
186186 struct mwifiex_adapter *adapter = priv->adapter;
187− int ret = 0;
187+ int len, ret = 0;
188188 u32 eventcause = adapter->event_cause;
189+ struct station_info sinfo;
190+ struct mwifiex_assoc_event *event;
189191
190192 switch (eventcause) {
191193 case EVENT_DUMMY_HOST_WAKEUP_SIGNAL:
@@ -402,6 +404,53 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) · 210 unmodified lines
402404 case EVENT_HOSTWAKE_STAIE:
403405 dev_dbg(adapter->dev, "event: HOSTWAKE_STAIE %d\n", eventcause);
404406 break;
407+
408+ case EVENT_UAP_STA_ASSOC:
409+ skb_pull(adapter->event_skb, MWIFIEX_UAP_EVENT_EXTRA_HEADER);
410+ memset(&sinfo, 0, sizeof(sinfo));
411+ event = (struct mwifiex_assoc_event *)adapter->event_skb->data;
412+ if (le16_to_cpu(event->type) == TLV_TYPE_UAP_MGMT_FRAME) {
413+ len = -1;
414+
415+ if (ieee80211_is_assoc_req(event->frame_control))
416+ len = 0;
417+ else if (ieee80211_is_reassoc_req(event->frame_control))
418+ /* There will be ETH_ALEN bytes of
419+ * current_ap_addr before the re-assoc ies.
420+ */
421+ len = ETH_ALEN;
422+
423+ if (len != -1) {
424+ sinfo.filled = STATION_INFO_ASSOC_REQ_IES;
425+ sinfo.assoc_req_ies = (u8 *)&event->data[len];
426+ len = (u8 *)sinfo.assoc_req_ies -
427+ (u8 *)&event->frame_control;
428+ sinfo.assoc_req_ies_len =
429+ le16_to_cpu(event->len) - (u16)len;
430+ }
431+ }
432+ cfg80211_new_sta(priv->netdev, event->sta_addr, &sinfo,
433+ GFP_KERNEL);
434+ break;
435+ case EVENT_UAP_STA_DEAUTH:
436+ skb_pull(adapter->event_skb, MWIFIEX_UAP_EVENT_EXTRA_HEADER);
437+ cfg80211_del_sta(priv->netdev, adapter->event_skb->data,
438+ GFP_KERNEL);
439+ break;
440+ case EVENT_UAP_BSS_IDLE:
441+ priv->media_connected = false;
442+ break;
443+ case EVENT_UAP_BSS_ACTIVE:
444+ priv->media_connected = true;
445+ break;
446+ case EVENT_UAP_BSS_START:
447+ dev_dbg(adapter->dev, "AP EVENT: event id: %#x\n", eventcause);
448+ memcpy(priv->netdev->dev_addr, adapter->event_body+2, ETH_ALEN);
449+ break;
450+ case EVENT_UAP_MIC_COUNTERMEASURES:
451+ /* For future development */
452+ dev_dbg(adapter->dev, "AP EVENT: event id: %#x\n", eventcause);
453+ break;
405454 default:
406455 dev_dbg(adapter->dev, "event: unknown event id: %#x\n",
407456 eventcause);
drivers/net/wireless/mwifiex/sta_ioctl.c+7−2
@@ -462,7 +462,7 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv, · 461 unmodified lines
462462
463463 info->bss_chan = bss_desc->channel;
464464
465− memcpy(info->country_code, priv->country_code,
465+ memcpy(info->country_code, adapter->country_code,
466466 IEEE80211_COUNTRY_STRING_LEN);
467467
468468 info->media_connected = priv->media_connected;
@@ -1219,7 +1219,8 @@ mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version, · 750 unmodified lines
12191219 * with requisite parameters and calls the IOCTL handler.
12201220 */
12211221 int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1222− int key_len, u8 key_index, int disable)
1222+ int key_len, u8 key_index,
1223+ const u8 *mac_addr, int disable)
12231224 {
12241225 struct mwifiex_ds_encrypt_key encrypt_key;
12251226
@@ -1229,8 +1230,12 @@ int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key, · 3 unmodified lines
12291230 encrypt_key.key_index = key_index;
12301231 if (key_len)
12311232 memcpy(encrypt_key.key_material, key, key_len);
1233+ if (mac_addr)
1234+ memcpy(encrypt_key.mac_addr, mac_addr, ETH_ALEN);
12321235 } else {
12331236 encrypt_key.key_disable = true;
1237+ if (mac_addr)
1238+ memcpy(encrypt_key.mac_addr, mac_addr, ETH_ALEN);
12341239 }
12351240
12361241 return mwifiex_sec_ioctl_encrypt_key(priv, &encrypt_key);
drivers/net/wireless/mwifiex/uap_cmd.c+432−0
@@ -0,0 +1,432 @@
1+/*
2+ * Marvell Wireless LAN device driver: AP specific command handling
3+ *
4+ * Copyright (C) 2012, Marvell International Ltd.
5+ *
6+ * This software file (the "File") is distributed by Marvell International
7+ * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8+ * (the "License"). You may use, redistribute and/or modify this File in
9+ * accordance with the terms and conditions of the License, a copy of which
10+ * is available by writing to the Free Software Foundation, Inc.,
11+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12+ * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13+ *
14+ * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15+ * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16+ * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17+ * this warranty disclaimer.
18+ */
19+
20+#include "main.h"
21+
22+/* This function parses security related parameters from cfg80211_ap_settings
23+ * and sets into FW understandable bss_config structure.
24+ */
25+int mwifiex_set_secure_params(struct mwifiex_private *priv,
26+ struct mwifiex_uap_bss_param *bss_config,
27+ struct cfg80211_ap_settings *params) {
28+ int i;
29+
30+ switch (params->auth_type) {
31+ case NL80211_AUTHTYPE_OPEN_SYSTEM:
32+ bss_config->auth_mode = WLAN_AUTH_OPEN;
33+ break;
34+ case NL80211_AUTHTYPE_SHARED_KEY:
35+ bss_config->auth_mode = WLAN_AUTH_SHARED_KEY;
36+ break;
37+ case NL80211_AUTHTYPE_NETWORK_EAP:
38+ bss_config->auth_mode = WLAN_AUTH_LEAP;
39+ break;
40+ default:
41+ bss_config->auth_mode = MWIFIEX_AUTH_MODE_AUTO;
42+ break;
43+ }
44+
45+ bss_config->key_mgmt_operation |= KEY_MGMT_ON_HOST;
46+
47+ for (i = 0; i < params->crypto.n_akm_suites; i++) {
48+ switch (params->crypto.akm_suites[i]) {
49+ case WLAN_AKM_SUITE_8021X:
50+ if (params->crypto.wpa_versions &
51+ NL80211_WPA_VERSION_1) {
52+ bss_config->protocol = PROTOCOL_WPA;
53+ bss_config->key_mgmt = KEY_MGMT_EAP;
54+ }
55+ if (params->crypto.wpa_versions &
56+ NL80211_WPA_VERSION_2) {
57+ bss_config->protocol = PROTOCOL_WPA2;
58+ bss_config->key_mgmt = KEY_MGMT_EAP;
59+ }
60+ break;
61+ case WLAN_AKM_SUITE_PSK:
62+ if (params->crypto.wpa_versions &
63+ NL80211_WPA_VERSION_1) {
64+ bss_config->protocol = PROTOCOL_WPA;
65+ bss_config->key_mgmt = KEY_MGMT_PSK;
66+ }
67+ if (params->crypto.wpa_versions &
68+ NL80211_WPA_VERSION_2) {
69+ bss_config->protocol = PROTOCOL_WPA2;
70+ bss_config->key_mgmt = KEY_MGMT_PSK;
71+ }
72+ break;
73+ default:
74+ break;
75+ }
76+ }
77+ for (i = 0; i < params->crypto.n_ciphers_pairwise; i++) {
78+ switch (params->crypto.ciphers_pairwise[i]) {
79+ case WLAN_CIPHER_SUITE_WEP40:
80+ case WLAN_CIPHER_SUITE_WEP104:
81+ break;
82+ case WLAN_CIPHER_SUITE_TKIP:
83+ bss_config->wpa_cfg.pairwise_cipher_wpa = CIPHER_TKIP;
84+ break;
85+ case WLAN_CIPHER_SUITE_CCMP:
86+ bss_config->wpa_cfg.pairwise_cipher_wpa2 =
87+ CIPHER_AES_CCMP;
88+ default:
89+ break;
90+ }
91+ }
92+
93+ switch (params->crypto.cipher_group) {
94+ case WLAN_CIPHER_SUITE_WEP40:
95+ case WLAN_CIPHER_SUITE_WEP104:
96+ break;
97+ case WLAN_CIPHER_SUITE_TKIP:
98+ bss_config->wpa_cfg.group_cipher = CIPHER_TKIP;
99+ break;
100+ case WLAN_CIPHER_SUITE_CCMP:
101+ bss_config->wpa_cfg.group_cipher = CIPHER_AES_CCMP;
102+ break;
103+ default:
104+ break;
105+ }
106+
107+ return 0;
108+}
109+
110+/* This function initializes some of mwifiex_uap_bss_param variables.
111+ * This helps FW in ignoring invalid values. These values may or may not
112+ * be get updated to valid ones at later stage.
113+ */
114+void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config)
115+{
116+ config->bcast_ssid_ctl = 0x7F;
117+ config->radio_ctl = 0x7F;
118+ config->dtim_period = 0x7F;
119+ config->beacon_period = 0x7FFF;
120+ config->auth_mode = 0x7F;
121+ config->rts_threshold = 0x7FFF;
122+ config->frag_threshold = 0x7FFF;
123+ config->retry_limit = 0x7F;
124+}
125+
126+/* This function parses BSS related parameters from structure
127+ * and prepares TLVs. These TLVs are appended to command buffer.
128+*/
129+static int
130+mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
131+{
132+ struct host_cmd_tlv_dtim_period *dtim_period;
133+ struct host_cmd_tlv_beacon_period *beacon_period;
134+ struct host_cmd_tlv_ssid *ssid;
135+ struct host_cmd_tlv_channel_band *chan_band;
136+ struct host_cmd_tlv_frag_threshold *frag_threshold;
137+ struct host_cmd_tlv_rts_threshold *rts_threshold;
138+ struct host_cmd_tlv_retry_limit *retry_limit;
139+ struct host_cmd_tlv_pwk_cipher *pwk_cipher;
140+ struct host_cmd_tlv_gwk_cipher *gwk_cipher;
141+ struct host_cmd_tlv_encrypt_protocol *encrypt_protocol;
142+ struct host_cmd_tlv_auth_type *auth_type;
143+ struct host_cmd_tlv_passphrase *passphrase;
144+ struct host_cmd_tlv_akmp *tlv_akmp;
145+ struct mwifiex_uap_bss_param *bss_cfg = cmd_buf;
146+ u16 cmd_size = *param_size;
147+
148+ if (bss_cfg->ssid.ssid_len) {
149+ ssid = (struct host_cmd_tlv_ssid *)tlv;
150+ ssid->tlv.type = cpu_to_le16(TLV_TYPE_UAP_SSID);
151+ ssid->tlv.len = cpu_to_le16((u16)bss_cfg->ssid.ssid_len);
152+ memcpy(ssid->ssid, bss_cfg->ssid.ssid, bss_cfg->ssid.ssid_len);
153+ cmd_size += sizeof(struct host_cmd_tlv) +
154+ bss_cfg->ssid.ssid_len;
155+ tlv += sizeof(struct host_cmd_tlv) + bss_cfg->ssid.ssid_len;
156+ }
157+ if (bss_cfg->channel && bss_cfg->channel <= MAX_CHANNEL_BAND_BG) {
158+ chan_band = (struct host_cmd_tlv_channel_band *)tlv;
159+ chan_band->tlv.type = cpu_to_le16(TLV_TYPE_CHANNELBANDLIST);
160+ chan_band->tlv.len =
161+ cpu_to_le16(sizeof(struct host_cmd_tlv_channel_band) -
162+ sizeof(struct host_cmd_tlv));
163+ chan_band->band_config = bss_cfg->band_cfg;
164+ chan_band->channel = bss_cfg->channel;
165+ cmd_size += sizeof(struct host_cmd_tlv_channel_band);
166+ tlv += sizeof(struct host_cmd_tlv_channel_band);
167+ }
168+ if (bss_cfg->beacon_period >= MIN_BEACON_PERIOD &&
169+ bss_cfg->beacon_period <= MAX_BEACON_PERIOD) {
170+ beacon_period = (struct host_cmd_tlv_beacon_period *)tlv;
171+ beacon_period->tlv.type =
172+ cpu_to_le16(TLV_TYPE_UAP_BEACON_PERIOD);
173+ beacon_period->tlv.len =
174+ cpu_to_le16(sizeof(struct host_cmd_tlv_beacon_period) -
175+ sizeof(struct host_cmd_tlv));
176+ beacon_period->period = cpu_to_le16(bss_cfg->beacon_period);
177+ cmd_size += sizeof(struct host_cmd_tlv_beacon_period);
178+ tlv += sizeof(struct host_cmd_tlv_beacon_period);
179+ }
180+ if (bss_cfg->dtim_period >= MIN_DTIM_PERIOD &&
181+ bss_cfg->dtim_period <= MAX_DTIM_PERIOD) {
182+ dtim_period = (struct host_cmd_tlv_dtim_period *)tlv;
183+ dtim_period->tlv.type = cpu_to_le16(TLV_TYPE_UAP_DTIM_PERIOD);
184+ dtim_period->tlv.len =
185+ cpu_to_le16(sizeof(struct host_cmd_tlv_dtim_period) -
186+ sizeof(struct host_cmd_tlv));
187+ dtim_period->period = bss_cfg->dtim_period;
188+ cmd_size += sizeof(struct host_cmd_tlv_dtim_period);
189+ tlv += sizeof(struct host_cmd_tlv_dtim_period);
190+ }
191+ if (bss_cfg->rts_threshold <= MWIFIEX_RTS_MAX_VALUE) {
192+ rts_threshold = (struct host_cmd_tlv_rts_threshold *)tlv;
193+ rts_threshold->tlv.type =
194+ cpu_to_le16(TLV_TYPE_UAP_RTS_THRESHOLD);
195+ rts_threshold->tlv.len =
196+ cpu_to_le16(sizeof(struct host_cmd_tlv_rts_threshold) -
197+ sizeof(struct host_cmd_tlv));
198+ rts_threshold->rts_thr = cpu_to_le16(bss_cfg->rts_threshold);
199+ cmd_size += sizeof(struct host_cmd_tlv_frag_threshold);
200+ tlv += sizeof(struct host_cmd_tlv_frag_threshold);
201+ }
202+ if ((bss_cfg->frag_threshold >= MWIFIEX_FRAG_MIN_VALUE) &&
203+ (bss_cfg->frag_threshold <= MWIFIEX_FRAG_MAX_VALUE)) {
204+ frag_threshold = (struct host_cmd_tlv_frag_threshold *)tlv;
205+ frag_threshold->tlv.type =
206+ cpu_to_le16(TLV_TYPE_UAP_FRAG_THRESHOLD);
207+ frag_threshold->tlv.len =
208+ cpu_to_le16(sizeof(struct host_cmd_tlv_frag_threshold) -
209+ sizeof(struct host_cmd_tlv));
210+ frag_threshold->frag_thr = cpu_to_le16(bss_cfg->frag_threshold);
211+ cmd_size += sizeof(struct host_cmd_tlv_frag_threshold);
212+ tlv += sizeof(struct host_cmd_tlv_frag_threshold);
213+ }
214+ if (bss_cfg->retry_limit <= MWIFIEX_RETRY_LIMIT) {
215+ retry_limit = (struct host_cmd_tlv_retry_limit *)tlv;
216+ retry_limit->tlv.type = cpu_to_le16(TLV_TYPE_UAP_RETRY_LIMIT);
217+ retry_limit->tlv.len =
218+ cpu_to_le16(sizeof(struct host_cmd_tlv_retry_limit) -
219+ sizeof(struct host_cmd_tlv));
220+ retry_limit->limit = (u8)bss_cfg->retry_limit;
221+ cmd_size += sizeof(struct host_cmd_tlv_retry_limit);
222+ tlv += sizeof(struct host_cmd_tlv_retry_limit);
223+ }
224+ if ((bss_cfg->protocol & PROTOCOL_WPA) ||
225+ (bss_cfg->protocol & PROTOCOL_WPA2) ||
226+ (bss_cfg->protocol & PROTOCOL_EAP)) {
227+ tlv_akmp = (struct host_cmd_tlv_akmp *)tlv;
228+ tlv_akmp->tlv.type = cpu_to_le16(TLV_TYPE_UAP_AKMP);
229+ tlv_akmp->tlv.len =
230+ cpu_to_le16(sizeof(struct host_cmd_tlv_akmp) -
231+ sizeof(struct host_cmd_tlv));
232+ tlv_akmp->key_mgmt_operation =
233+ cpu_to_le16(bss_cfg->key_mgmt_operation);
234+ tlv_akmp->key_mgmt = cpu_to_le16(bss_cfg->key_mgmt);
235+ cmd_size += sizeof(struct host_cmd_tlv_akmp);
236+ tlv += sizeof(struct host_cmd_tlv_akmp);
237+
238+ if (bss_cfg->wpa_cfg.pairwise_cipher_wpa &
239+ VALID_CIPHER_BITMAP) {
240+ pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv;
241+ pwk_cipher->tlv.type =
242+ cpu_to_le16(TLV_TYPE_PWK_CIPHER);
243+ pwk_cipher->tlv.len = cpu_to_le16(
244+ sizeof(struct host_cmd_tlv_pwk_cipher) -
245+ sizeof(struct host_cmd_tlv));
246+ pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA);
247+ pwk_cipher->cipher =
248+ bss_cfg->wpa_cfg.pairwise_cipher_wpa;
249+ cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher);
250+ tlv += sizeof(struct host_cmd_tlv_pwk_cipher);
251+ }
252+ if (bss_cfg->wpa_cfg.pairwise_cipher_wpa2 &
253+ VALID_CIPHER_BITMAP) {
254+ pwk_cipher = (struct host_cmd_tlv_pwk_cipher *)tlv;
255+ pwk_cipher->tlv.type = cpu_to_le16(TLV_TYPE_PWK_CIPHER);
256+ pwk_cipher->tlv.len = cpu_to_le16(
257+ sizeof(struct host_cmd_tlv_pwk_cipher) -
258+ sizeof(struct host_cmd_tlv));
259+ pwk_cipher->proto = cpu_to_le16(PROTOCOL_WPA2);
260+ pwk_cipher->cipher =
261+ bss_cfg->wpa_cfg.pairwise_cipher_wpa2;
262+ cmd_size += sizeof(struct host_cmd_tlv_pwk_cipher);
263+ tlv += sizeof(struct host_cmd_tlv_pwk_cipher);
264+ }
265+ if (bss_cfg->wpa_cfg.group_cipher & VALID_CIPHER_BITMAP) {
266+ gwk_cipher = (struct host_cmd_tlv_gwk_cipher *)tlv;
267+ gwk_cipher->tlv.type = cpu_to_le16(TLV_TYPE_GWK_CIPHER);
268+ gwk_cipher->tlv.len = cpu_to_le16(
269+ sizeof(struct host_cmd_tlv_gwk_cipher) -
270+ sizeof(struct host_cmd_tlv));
271+ gwk_cipher->cipher = bss_cfg->wpa_cfg.group_cipher;
272+ cmd_size += sizeof(struct host_cmd_tlv_gwk_cipher);
273+ tlv += sizeof(struct host_cmd_tlv_gwk_cipher);
274+ }
275+ if (bss_cfg->wpa_cfg.length) {
276+ passphrase = (struct host_cmd_tlv_passphrase *)tlv;
277+ passphrase->tlv.type =
278+ cpu_to_le16(TLV_TYPE_UAP_WPA_PASSPHRASE);
279+ passphrase->tlv.len =
280+ cpu_to_le16(bss_cfg->wpa_cfg.length);
281+ memcpy(passphrase->passphrase,
282+ bss_cfg->wpa_cfg.passphrase,
283+ bss_cfg->wpa_cfg.length);
284+ cmd_size += sizeof(struct host_cmd_tlv) +
285+ bss_cfg->wpa_cfg.length;
286+ tlv += sizeof(struct host_cmd_tlv) +
287+ bss_cfg->wpa_cfg.length;
288+ }
289+ }
290+ if ((bss_cfg->auth_mode <= WLAN_AUTH_SHARED_KEY) ||
291+ (bss_cfg->auth_mode == MWIFIEX_AUTH_MODE_AUTO)) {
292+ auth_type = (struct host_cmd_tlv_auth_type *)tlv;
293+ auth_type->tlv.type = cpu_to_le16(TLV_TYPE_AUTH_TYPE);
294+ auth_type->tlv.len =
295+ cpu_to_le16(sizeof(struct host_cmd_tlv_auth_type) -
296+ sizeof(struct host_cmd_tlv));
297+ auth_type->auth_type = (u8)bss_cfg->auth_mode;
298+ cmd_size += sizeof(struct host_cmd_tlv_auth_type);
299+ tlv += sizeof(struct host_cmd_tlv_auth_type);
300+ }
301+ if (bss_cfg->protocol) {
302+ encrypt_protocol = (struct host_cmd_tlv_encrypt_protocol *)tlv;
303+ encrypt_protocol->tlv.type =
304+ cpu_to_le16(TLV_TYPE_UAP_ENCRY_PROTOCOL);
305+ encrypt_protocol->tlv.len =
306+ cpu_to_le16(sizeof(struct host_cmd_tlv_encrypt_protocol)
307+ - sizeof(struct host_cmd_tlv));
308+ encrypt_protocol->proto = cpu_to_le16(bss_cfg->protocol);
309+ cmd_size += sizeof(struct host_cmd_tlv_encrypt_protocol);
310+ tlv += sizeof(struct host_cmd_tlv_encrypt_protocol);
311+ }
312+
313+ *param_size = cmd_size;
314+
315+ return 0;
316+}
317+
318+/* This function parses custom IEs from IE list and prepares command buffer */
319+static int mwifiex_uap_custom_ie_prepare(u8 *tlv, void *cmd_buf, u16 *ie_size)
320+{
321+ struct mwifiex_ie_list *ap_ie = cmd_buf;
322+ struct host_cmd_tlv *tlv_ie = (struct host_cmd_tlv *)tlv;
323+
324+ if (!ap_ie || !ap_ie->len || !ap_ie->ie_list)
325+ return -1;
326+
327+ *ie_size += le16_to_cpu(ap_ie->len) + sizeof(struct host_cmd_tlv);
328+
329+ tlv_ie->type = cpu_to_le16(TLV_TYPE_MGMT_IE);
330+ tlv_ie->len = ap_ie->len;
331+ tlv += sizeof(struct host_cmd_tlv);
332+
333+ memcpy(tlv, ap_ie->ie_list, le16_to_cpu(ap_ie->len));
334+
335+ return 0;
336+}
337+
338+/* Parse AP config structure and prepare TLV based command structure
339+ * to be sent to FW for uAP configuration
340+ */
341+static int
342+mwifiex_cmd_uap_sys_config(struct host_cmd_ds_command *cmd, u16 cmd_action,
343+ u32 type, void *cmd_buf)
344+{
345+ u8 *tlv;
346+ u16 cmd_size, param_size, ie_size;
347+ struct host_cmd_ds_sys_config *sys_cfg;
348+
349+ cmd->command = cpu_to_le16(HostCmd_CMD_UAP_SYS_CONFIG);
350+ cmd_size = (u16)(sizeof(struct host_cmd_ds_sys_config) + S_DS_GEN);
351+ sys_cfg = (struct host_cmd_ds_sys_config *)&cmd->params.uap_sys_config;
352+ sys_cfg->action = cpu_to_le16(cmd_action);
353+ tlv = sys_cfg->tlv;
354+
355+ switch (type) {
356+ case UAP_BSS_PARAMS_I:
357+ param_size = cmd_size;
358+ if (mwifiex_uap_bss_param_prepare(tlv, cmd_buf, &param_size))
359+ return -1;
360+ cmd->size = cpu_to_le16(param_size);
361+ break;
362+ case UAP_CUSTOM_IE_I:
363+ ie_size = cmd_size;
364+ if (mwifiex_uap_custom_ie_prepare(tlv, cmd_buf, &ie_size))
365+ return -1;
366+ cmd->size = cpu_to_le16(ie_size);
367+ break;
368+ default:
369+ return -1;
370+ }
371+
372+ return 0;
373+}
374+
375+/* This function prepares the AP specific commands before sending them
376+ * to the firmware.
377+ * This is a generic function which calls specific command preparation
378+ * routines based upon the command number.
379+ */
380+int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, u16 cmd_no,
381+ u16 cmd_action, u32 type,
382+ void *data_buf, void *cmd_buf)
383+{
384+ struct host_cmd_ds_command *cmd = cmd_buf;
385+
386+ switch (cmd_no) {
387+ case HostCmd_CMD_UAP_SYS_CONFIG:
388+ if (mwifiex_cmd_uap_sys_config(cmd, cmd_action, type, data_buf))
389+ return -1;
390+ break;
391+ case HostCmd_CMD_UAP_BSS_START:
392+ case HostCmd_CMD_UAP_BSS_STOP:
393+ cmd->command = cpu_to_le16(cmd_no);
394+ cmd->size = cpu_to_le16(S_DS_GEN);
395+ break;
396+ default:
397+ dev_err(priv->adapter->dev,
398+ "PREP_CMD: unknown cmd %#x\n", cmd_no);
399+ return -1;
400+ }
401+
402+ return 0;
403+}
404+
405+/* This function sets the RF channel for AP.
406+ *
407+ * This function populates channel information in AP config structure
408+ * and sends command to configure channel information in AP.
409+ */
410+int mwifiex_uap_set_channel(struct mwifiex_private *priv, int channel)
411+{
412+ struct mwifiex_uap_bss_param *bss_cfg;
413+ struct wiphy *wiphy = priv->wdev->wiphy;
414+
415+ bss_cfg = kzalloc(sizeof(struct mwifiex_uap_bss_param), GFP_KERNEL);
416+ if (!bss_cfg)
417+ return -ENOMEM;
418+
419+ bss_cfg->band_cfg = BAND_CONFIG_MANUAL;
420+ bss_cfg->channel = channel;
421+
422+ if (mwifiex_send_cmd_async(priv, HostCmd_CMD_UAP_SYS_CONFIG,
423+ HostCmd_ACT_GEN_SET,
424+ UAP_BSS_PARAMS_I, bss_cfg)) {
425+ wiphy_err(wiphy, "Failed to set the uAP channel\n");
426+ kfree(bss_cfg);
427+ return -1;
428+ }
429+
430+ kfree(bss_cfg);
431+ return 0;
432+}
drivers/net/wireless/mwifiex/wmm.c+4−0
@@ -885,6 +885,10 @@ mwifiex_wmm_get_highest_priolist_ptr(struct mwifiex_adapter *adapter, · 884 unmodified lines
885885 tid_ptr = &(priv_tmp)->wmm.
886886 tid_tbl_ptr[tos_to_tid[i]];
887887
888+ /* For non-STA ra_list_curr may be NULL */
889+ if (!tid_ptr->ra_list_curr)
890+ continue;
891+
888892 spin_lock_irqsave(&tid_ptr->tid_tbl_lock,
889893 flags);
890894 is_list_empty =
drivers/net/wireless/rndis_wlan.c+0−14
@@ -505,9 +505,6 @@ static int rndis_join_ibss(struct wiphy *wiphy, struct net_device *dev, · 504 unmodified lines
505505
506506 static int rndis_leave_ibss(struct wiphy *wiphy, struct net_device *dev);
507507
508−static int rndis_set_channel(struct wiphy *wiphy, struct net_device *dev,
509− struct ieee80211_channel *chan, enum nl80211_channel_type channel_type);
510−
511508 static int rndis_add_key(struct wiphy *wiphy, struct net_device *netdev,
512509 u8 key_index, bool pairwise, const u8 *mac_addr,
513510 struct key_params *params);
@@ -549,7 +546,6 @@ static const struct cfg80211_ops rndis_config_ops = { · 35 unmodified lines
549546 .disconnect = rndis_disconnect,
550547 .join_ibss = rndis_join_ibss,
551548 .leave_ibss = rndis_leave_ibss,
552− .set_channel = rndis_set_channel,
553549 .add_key = rndis_add_key,
554550 .del_key = rndis_del_key,
555551 .set_default_key = rndis_set_default_key,
@@ -2398,16 +2394,6 @@ static int rndis_leave_ibss(struct wiphy *wiphy, struct net_device *dev) · 1842 unmodified lines
23982394 return deauthenticate(usbdev);
23992395 }
24002396
2401−static int rndis_set_channel(struct wiphy *wiphy, struct net_device *netdev,
2402− struct ieee80211_channel *chan, enum nl80211_channel_type channel_type)
2403−{
2404− struct rndis_wlan_private *priv = wiphy_priv(wiphy);
2405− struct usbnet *usbdev = priv->usbdev;
2406−
2407− return set_channel(usbdev,
2408− ieee80211_frequency_to_channel(chan->center_freq));
2409−}
2410−
24112397 static int rndis_add_key(struct wiphy *wiphy, struct net_device *netdev,
24122398 u8 key_index, bool pairwise, const u8 *mac_addr,
24132399 struct key_params *params)
drivers/net/wireless/rt2x00/rt2800pci.c+1−0
@@ -1192,6 +1192,7 @@ static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = { · 1191 unmodified lines
11921192 { PCI_DEVICE(0x1814, 0x5390) },
11931193 { PCI_DEVICE(0x1814, 0x5392) },
11941194 { PCI_DEVICE(0x1814, 0x539a) },
1195+ { PCI_DEVICE(0x1814, 0x539b) },
11951196 { PCI_DEVICE(0x1814, 0x539f) },
11961197 #endif
11971198 { 0, }
drivers/net/wireless/ti/wl12xx/Kconfig+1−0
@@ -1,5 +1,6 @@
11 config WL12XX
22 tristate "TI wl12xx support"
3+ depends on MAC80211
34 select WLCORE
45 ---help---
56 This module adds support for wireless adapters based on TI wl1271,
drivers/net/wireless/ti/wlcore/Kconfig+1−1
@@ -1,6 +1,6 @@
11 config WLCORE
22 tristate "TI wlcore support"
3− depends on WL_TI && GENERIC_HARDIRQS
3+ depends on WL_TI && GENERIC_HARDIRQS && MAC80211
44 depends on INET
55 select FW_LOADER
66 ---help---
drivers/net/wireless/ti/wlcore/acx.c+80−0
@@ -1714,3 +1714,83 @@ out: · 1713 unmodified lines
17141714 return ret;
17151715
17161716 }
1717+
1718+/* Set the global behaviour of RX filters - On/Off + default action */
1719+int wl1271_acx_default_rx_filter_enable(struct wl1271 *wl, bool enable,
1720+ enum rx_filter_action action)
1721+{
1722+ struct acx_default_rx_filter *acx;
1723+ int ret;
1724+
1725+ wl1271_debug(DEBUG_ACX, "acx default rx filter en: %d act: %d",
1726+ enable, action);
1727+
1728+ acx = kzalloc(sizeof(*acx), GFP_KERNEL);
1729+ if (!acx)
1730+ return -ENOMEM;
1731+
1732+ acx->enable = enable;
1733+ acx->default_action = action;
1734+
1735+ ret = wl1271_cmd_configure(wl, ACX_ENABLE_RX_DATA_FILTER, acx,
1736+ sizeof(*acx));
1737+ if (ret < 0) {
1738+ wl1271_warning("acx default rx filter enable failed: %d", ret);
1739+ goto out;
1740+ }
1741+
1742+out:
1743+ kfree(acx);
1744+ return ret;
1745+}
1746+
1747+/* Configure or disable a specific RX filter pattern */
1748+int wl1271_acx_set_rx_filter(struct wl1271 *wl, u8 index, bool enable,
1749+ struct wl12xx_rx_filter *filter)
1750+{
1751+ struct acx_rx_filter_cfg *acx;
1752+ int fields_size = 0;
1753+ int acx_size;
1754+ int ret;
1755+
1756+ WARN_ON(enable && !filter);
1757+ WARN_ON(index >= WL1271_MAX_RX_FILTERS);
1758+
1759+ wl1271_debug(DEBUG_ACX,
1760+ "acx set rx filter idx: %d enable: %d filter: %p",
1761+ index, enable, filter);
1762+
1763+ if (enable) {
1764+ fields_size = wl1271_rx_filter_get_fields_size(filter);
1765+
1766+ wl1271_debug(DEBUG_ACX, "act: %d num_fields: %d field_size: %d",
1767+ filter->action, filter->num_fields, fields_size);
1768+ }
1769+
1770+ acx_size = ALIGN(sizeof(*acx) + fields_size, 4);
1771+ acx = kzalloc(acx_size, GFP_KERNEL);
1772+
1773+ if (!acx)
1774+ return -ENOMEM;
1775+
1776+ acx->enable = enable;
1777+ acx->index = index;
1778+
1779+ if (enable) {
1780+ acx->num_fields = filter->num_fields;
1781+ acx->action = filter->action;
1782+ wl1271_rx_filter_flatten_fields(filter, acx->fields);
1783+ }
1784+
1785+ wl1271_dump(DEBUG_ACX, "RX_FILTER: ", acx, acx_size);
1786+
1787+ ret = wl1271_cmd_configure(wl, ACX_SET_RX_DATA_FILTER, acx, acx_size);
1788+ if (ret < 0) {
1789+ wl1271_warning("setting rx filter failed: %d", ret);
1790+ goto out;
1791+ }
1792+
1793+out:
1794+ kfree(acx);
1795+ return ret;
1796+}
drivers/net/wireless/ti/wlcore/acx.h+30−0
@@ -1147,6 +1147,32 @@ struct wl12xx_acx_config_hangover { · 1146 unmodified lines
11471147 u8 padding[2];
11481148 } __packed;
11491149
1150+
1151+struct acx_default_rx_filter {
1152+ struct acx_header header;
1153+ u8 enable;
1154+
1155+ /* action of type FILTER_XXX */
1156+ u8 default_action;
1157+
1158+ u8 pad[2];
1159+} __packed;
1160+
1161+
1162+struct acx_rx_filter_cfg {
1163+ struct acx_header header;
1164+
1165+ u8 enable;
1166+
1167+ /* 0 - WL1271_MAX_RX_FILTERS-1 */
1168+ u8 index;
1169+
1170+ u8 action;
1171+
1172+ u8 num_fields;
1173+ u8 fields[0];
1174+} __packed;
1175+
11501176 enum {
11511177 ACX_WAKE_UP_CONDITIONS = 0x0000,
11521178 ACX_MEM_CFG = 0x0001,
@@ -1304,5 +1330,9 @@ int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr); · 151 unmodified lines
13041330 int wl1271_acx_fm_coex(struct wl1271 *wl);
13051331 int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl);
13061332 int wl12xx_acx_config_hangover(struct wl1271 *wl);
1333+int wl1271_acx_default_rx_filter_enable(struct wl1271 *wl, bool enable,
1334+ enum rx_filter_action action);
1335+int wl1271_acx_set_rx_filter(struct wl1271 *wl, u8 index, bool enable,
1336+ struct wl12xx_rx_filter *filter);
13071337
13081338 #endif /* __WL1271_ACX_H__ */
drivers/net/wireless/ti/wlcore/boot.c+2−1
@@ -72,7 +72,7 @@ static int wlcore_boot_fw_version(struct wl1271 *wl) · 71 unmodified lines
7272 struct wl1271_static_data *static_data;
7373 int ret;
7474
75− static_data = kmalloc(sizeof(*static_data), GFP_DMA);
75+ static_data = kmalloc(sizeof(*static_data), GFP_KERNEL | GFP_DMA);
7676 if (!static_data) {
7777 wl1271_error("Couldn't allocate memory for static data!");
7878 return -ENOMEM;
@@ -413,6 +413,7 @@ int wlcore_boot_run_firmware(struct wl1271 *wl) · 334 unmodified lines
413413
414414 /* unmask required mbox events */
415415 wl->event_mask = BSS_LOSE_EVENT_ID |
416+ REGAINED_BSS_EVENT_ID |
416417 SCAN_COMPLETE_EVENT_ID |
417418 ROLE_STOP_COMPLETE_EVENT_ID |
418419 RSSI_SNR_TRIGGER_0_EVENT_ID |
drivers/net/wireless/ti/wlcore/cmd.c+5−3
@@ -123,7 +123,9 @@ static int wl1271_cmd_wait_for_event_or_timeout(struct wl1271 *wl, u32 mask) · 122 unmodified lines
123123 unsigned long timeout;
124124 int ret = 0;
125125
126− events_vector = kmalloc(sizeof(*events_vector), GFP_DMA);
126+ events_vector = kmalloc(sizeof(*events_vector), GFP_KERNEL | GFP_DMA);
127+ if (!events_vector)
128+ return -ENOMEM;
127129
128130 timeout = jiffies + msecs_to_jiffies(WL1271_EVENT_TIMEOUT);
129131
@@ -1034,7 +1036,7 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif) · 904 unmodified lines
10341036 skb_reserve(skb, sizeof(*hdr) + WL1271_EXTRA_SPACE_MAX);
10351037
10361038 tmpl = (struct wl12xx_arp_rsp_template *)skb_put(skb, sizeof(*tmpl));
1037− memset(tmpl, 0, sizeof(tmpl));
1039+ memset(tmpl, 0, sizeof(*tmpl));
10381040
10391041 /* llc layer */
10401042 memcpy(tmpl->llc_hdr, rfc1042_header, sizeof(rfc1042_header));
@@ -1083,7 +1085,7 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif) · 42 unmodified lines
10831085
10841086 /* mac80211 header */
10851087 hdr = (struct ieee80211_hdr_3addr *)skb_push(skb, sizeof(*hdr));
1086− memset(hdr, 0, sizeof(hdr));
1088+ memset(hdr, 0, sizeof(*hdr));
10871089 fc = IEEE80211_FTYPE_DATA | IEEE80211_FCTL_TODS;
10881090 if (wlvif->sta.qos)
10891091 fc |= IEEE80211_STYPE_QOS_DATA;
drivers/net/wireless/ti/wlcore/event.c+12−17
@@ -103,7 +103,6 @@ static int wl1271_event_process(struct wl1271 *wl) · 102 unmodified lines
103103 struct ieee80211_vif *vif;
104104 struct wl12xx_vif *wlvif;
105105 u32 vector;
106− bool beacon_loss = false;
107106 bool disconnect_sta = false;
108107 unsigned long sta_bitmap = 0;
109108
@@ -141,20 +140,23 @@ static int wl1271_event_process(struct wl1271 *wl) · 31 unmodified lines
141140 mbox->soft_gemini_sense_info);
142141
143142 /*
144− * The BSS_LOSE_EVENT_ID is only needed while psm (and hence beacon
145− * filtering) is enabled. Without PSM, the stack will receive all
146− * beacons and can detect beacon loss by itself.
147− *
148− * As there's possibility that the driver disables PSM before receiving
149− * BSS_LOSE_EVENT, beacon loss has to be reported to the stack.
150− *
143+ * We are HW_MONITOR device. On beacon loss - queue
144+ * connection loss work. Cancel it on REGAINED event.
151145 */
152146 if (vector & BSS_LOSE_EVENT_ID) {
153147 /* TODO: check for multi-role */
148+ int delay = wl->conf.conn.synch_fail_thold *
149+ wl->conf.conn.bss_lose_timeout;
154150 wl1271_info("Beacon loss detected.");
151+ cancel_delayed_work_sync(&wl->connection_loss_work);
152+ ieee80211_queue_delayed_work(wl->hw, &wl->connection_loss_work,
153+ msecs_to_jiffies(delay));
154+ }
155155
156− /* indicate to the stack, that beacons have been lost */
157− beacon_loss = true;
156+ if (vector & REGAINED_BSS_EVENT_ID) {
157+ /* TODO: check for multi-role */
158+ wl1271_info("Beacon regained.");
159+ cancel_delayed_work_sync(&wl->connection_loss_work);
158160 }
159161
160162 if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID) {
@@ -257,13 +259,6 @@ static int wl1271_event_process(struct wl1271 *wl) · 96 unmodified lines
257259 rcu_read_unlock();
258260 }
259261 }
260−
261− if (beacon_loss)
262− wl12xx_for_each_wlvif_sta(wl, wlvif) {
263− vif = wl12xx_wlvif_to_vif(wlvif);
264− ieee80211_connection_loss(vif);
265− }
266−
267262 return 0;
268263 }
269264
drivers/net/wireless/ti/wlcore/main.c+315−8
@@ -1120,6 +1120,7 @@ int wl1271_plt_stop(struct wl1271 *wl) · 1119 unmodified lines
11201120 cancel_work_sync(&wl->recovery_work);
11211121 cancel_delayed_work_sync(&wl->elp_work);
11221122 cancel_delayed_work_sync(&wl->tx_watchdog_work);
1123+ cancel_delayed_work_sync(&wl->connection_loss_work);
11231124
11241125 mutex_lock(&wl->mutex);
11251126 wl1271_power_off(wl);
@@ -1261,8 +1262,270 @@ static struct sk_buff *wl12xx_alloc_dummy_packet(struct wl1271 *wl) · 135 unmodified lines
12611262
12621263
12631264 #ifdef CONFIG_PM
1265+static int
1266+wl1271_validate_wowlan_pattern(struct cfg80211_wowlan_trig_pkt_pattern *p)
1267+{
1268+ int num_fields = 0, in_field = 0, fields_size = 0;
1269+ int i, pattern_len = 0;
1270+
1271+ if (!p->mask) {
1272+ wl1271_warning("No mask in WoWLAN pattern");
1273+ return -EINVAL;
1274+ }
1275+
1276+ /*
1277+ * The pattern is broken up into segments of bytes at different offsets
1278+ * that need to be checked by the FW filter. Each segment is called
1279+ * a field in the FW API. We verify that the total number of fields
1280+ * required for this pattern won't exceed FW limits (8)
1281+ * as well as the total fields buffer won't exceed the FW limit.
1282+ * Note that if there's a pattern which crosses Ethernet/IP header
1283+ * boundary a new field is required.
1284+ */
1285+ for (i = 0; i < p->pattern_len; i++) {
1286+ if (test_bit(i, (unsigned long *)p->mask)) {
1287+ if (!in_field) {
1288+ in_field = 1;
1289+ pattern_len = 1;
1290+ } else {
1291+ if (i == WL1271_RX_FILTER_ETH_HEADER_SIZE) {
1292+ num_fields++;
1293+ fields_size += pattern_len +
1294+ RX_FILTER_FIELD_OVERHEAD;
1295+ pattern_len = 1;
1296+ } else
1297+ pattern_len++;
1298+ }
1299+ } else {
1300+ if (in_field) {
1301+ in_field = 0;
1302+ fields_size += pattern_len +
1303+ RX_FILTER_FIELD_OVERHEAD;
1304+ num_fields++;
1305+ }
1306+ }
1307+ }
1308+
1309+ if (in_field) {
1310+ fields_size += pattern_len + RX_FILTER_FIELD_OVERHEAD;
1311+ num_fields++;
1312+ }
1313+
1314+ if (num_fields > WL1271_RX_FILTER_MAX_FIELDS) {
1315+ wl1271_warning("RX Filter too complex. Too many segments");
1316+ return -EINVAL;
1317+ }
1318+
1319+ if (fields_size > WL1271_RX_FILTER_MAX_FIELDS_SIZE) {
1320+ wl1271_warning("RX filter pattern is too big");
1321+ return -E2BIG;
1322+ }
1323+
1324+ return 0;
1325+}
1326+
1327+struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void)
1328+{
1329+ return kzalloc(sizeof(struct wl12xx_rx_filter), GFP_KERNEL);
1330+}
1331+
1332+void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter)
1333+{
1334+ int i;
1335+
1336+ if (filter == NULL)
1337+ return;
1338+
1339+ for (i = 0; i < filter->num_fields; i++)
1340+ kfree(filter->fields[i].pattern);
1341+
1342+ kfree(filter);
1343+}
1344+
1345+int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter,
1346+ u16 offset, u8 flags,
1347+ u8 *pattern, u8 len)
1348+{
1349+ struct wl12xx_rx_filter_field *field;
1350+
1351+ if (filter->num_fields == WL1271_RX_FILTER_MAX_FIELDS) {
1352+ wl1271_warning("Max fields per RX filter. can't alloc another");
1353+ return -EINVAL;
1354+ }
1355+
1356+ field = &filter->fields[filter->num_fields];
1357+
1358+ field->pattern = kzalloc(len, GFP_KERNEL);
1359+ if (!field->pattern) {
1360+ wl1271_warning("Failed to allocate RX filter pattern");
1361+ return -ENOMEM;
1362+ }
1363+
1364+ filter->num_fields++;
1365+
1366+ field->offset = cpu_to_le16(offset);
1367+ field->flags = flags;
1368+ field->len = len;
1369+ memcpy(field->pattern, pattern, len);
1370+
1371+ return 0;
1372+}
1373+
1374+int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter)
1375+{
1376+ int i, fields_size = 0;
1377+
1378+ for (i = 0; i < filter->num_fields; i++)
1379+ fields_size += filter->fields[i].len +
1380+ sizeof(struct wl12xx_rx_filter_field) -
1381+ sizeof(u8 *);
1382+
1383+ return fields_size;
1384+}
1385+
1386+void wl1271_rx_filter_flatten_fields(struct wl12xx_rx_filter *filter,
1387+ u8 *buf)
1388+{
1389+ int i;
1390+ struct wl12xx_rx_filter_field *field;
1391+
1392+ for (i = 0; i < filter->num_fields; i++) {
1393+ field = (struct wl12xx_rx_filter_field *)buf;
1394+
1395+ field->offset = filter->fields[i].offset;
1396+ field->flags = filter->fields[i].flags;
1397+ field->len = filter->fields[i].len;
1398+
1399+ memcpy(&field->pattern, filter->fields[i].pattern, field->len);
1400+ buf += sizeof(struct wl12xx_rx_filter_field) -
1401+ sizeof(u8 *) + field->len;
1402+ }
1403+}
1404+
1405+/*
1406+ * Allocates an RX filter returned through f
1407+ * which needs to be freed using rx_filter_free()
1408+ */
1409+static int wl1271_convert_wowlan_pattern_to_rx_filter(
1410+ struct cfg80211_wowlan_trig_pkt_pattern *p,
1411+ struct wl12xx_rx_filter **f)
1412+{
1413+ int i, j, ret = 0;
1414+ struct wl12xx_rx_filter *filter;
1415+ u16 offset;
1416+ u8 flags, len;
1417+
1418+ filter = wl1271_rx_filter_alloc();
1419+ if (!filter) {
1420+ wl1271_warning("Failed to alloc rx filter");
1421+ ret = -ENOMEM;
1422+ goto err;
1423+ }
1424+
1425+ i = 0;
1426+ while (i < p->pattern_len) {
1427+ if (!test_bit(i, (unsigned long *)p->mask)) {
1428+ i++;
1429+ continue;
1430+ }
1431+
1432+ for (j = i; j < p->pattern_len; j++) {
1433+ if (!test_bit(j, (unsigned long *)p->mask))
1434+ break;
1435+
1436+ if (i < WL1271_RX_FILTER_ETH_HEADER_SIZE &&
1437+ j >= WL1271_RX_FILTER_ETH_HEADER_SIZE)
1438+ break;
1439+ }
1440+
1441+ if (i < WL1271_RX_FILTER_ETH_HEADER_SIZE) {
1442+ offset = i;
1443+ flags = WL1271_RX_FILTER_FLAG_ETHERNET_HEADER;
1444+ } else {
1445+ offset = i - WL1271_RX_FILTER_ETH_HEADER_SIZE;
1446+ flags = WL1271_RX_FILTER_FLAG_IP_HEADER;
1447+ }
1448+
1449+ len = j - i;
1450+
1451+ ret = wl1271_rx_filter_alloc_field(filter,
1452+ offset,
1453+ flags,
1454+ &p->pattern[i], len);
1455+ if (ret)
1456+ goto err;
1457+
1458+ i = j;
1459+ }
1460+
1461+ filter->action = FILTER_SIGNAL;
1462+
1463+ *f = filter;
1464+ return 0;
1465+
1466+err:
1467+ wl1271_rx_filter_free(filter);
1468+ *f = NULL;
1469+
1470+ return ret;
1471+}
1472+
1473+static int wl1271_configure_wowlan(struct wl1271 *wl,
1474+ struct cfg80211_wowlan *wow)
1475+{
1476+ int i, ret;
1477+
1478+ if (!wow || wow->any || !wow->n_patterns) {
1479+ wl1271_acx_default_rx_filter_enable(wl, 0, FILTER_SIGNAL);
1480+ wl1271_rx_filter_clear_all(wl);
1481+ return 0;
1482+ }
1483+
1484+ if (WARN_ON(wow->n_patterns > WL1271_MAX_RX_FILTERS))
1485+ return -EINVAL;
1486+
1487+ /* Validate all incoming patterns before clearing current FW state */
1488+ for (i = 0; i < wow->n_patterns; i++) {
1489+ ret = wl1271_validate_wowlan_pattern(&wow->patterns[i]);
1490+ if (ret) {
1491+ wl1271_warning("Bad wowlan pattern %d", i);
1492+ return ret;
1493+ }
1494+ }
1495+
1496+ wl1271_acx_default_rx_filter_enable(wl, 0, FILTER_SIGNAL);
1497+ wl1271_rx_filter_clear_all(wl);
1498+
1499+ /* Translate WoWLAN patterns into filters */
1500+ for (i = 0; i < wow->n_patterns; i++) {
1501+ struct cfg80211_wowlan_trig_pkt_pattern *p;
1502+ struct wl12xx_rx_filter *filter = NULL;
1503+
1504+ p = &wow->patterns[i];
1505+
1506+ ret = wl1271_convert_wowlan_pattern_to_rx_filter(p, &filter);
1507+ if (ret) {
1508+ wl1271_warning("Failed to create an RX filter from "
1509+ "wowlan pattern %d", i);
1510+ goto out;
1511+ }
1512+
1513+ ret = wl1271_rx_filter_enable(wl, i, 1, filter);
1514+
1515+ wl1271_rx_filter_free(filter);
1516+ if (ret)
1517+ goto out;
1518+ }
1519+
1520+ ret = wl1271_acx_default_rx_filter_enable(wl, 1, FILTER_DROP);
1521+
1522+out:
1523+ return ret;
1524+}
1525+
12641526 static int wl1271_configure_suspend_sta(struct wl1271 *wl,
1265− struct wl12xx_vif *wlvif)
1527+ struct wl12xx_vif *wlvif,
1528+ struct cfg80211_wowlan *wow)
12661529 {
12671530 int ret = 0;
12681531
@@ -1273,6 +1536,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl, · 4 unmodified lines
12731536 if (ret < 0)
12741537 goto out;
12751538
1539+ wl1271_configure_wowlan(wl, wow);
12761540 ret = wl1271_acx_wake_up_conditions(wl, wlvif,
12771541 wl->conf.conn.suspend_wake_up_event,
12781542 wl->conf.conn.suspend_listen_interval);
@@ -1308,10 +1572,11 @@ out: · 29 unmodified lines
13081572 }
13091573
13101574 static int wl1271_configure_suspend(struct wl1271 *wl,
1311− struct wl12xx_vif *wlvif)
1575+ struct wl12xx_vif *wlvif,
1576+ struct cfg80211_wowlan *wow)
13121577 {
13131578 if (wlvif->bss_type == BSS_TYPE_STA_BSS)
1314− return wl1271_configure_suspend_sta(wl, wlvif);
1579+ return wl1271_configure_suspend_sta(wl, wlvif, wow);
13151580 if (wlvif->bss_type == BSS_TYPE_AP_BSS)
13161581 return wl1271_configure_suspend_ap(wl, wlvif);
13171582 return 0;
@@ -1332,6 +1597,8 @@ static void wl1271_configure_resume(struct wl1271 *wl, · 14 unmodified lines
13321597 return;
13331598
13341599 if (is_sta) {
1600+ wl1271_configure_wowlan(wl, NULL);
1601+
13351602 ret = wl1271_acx_wake_up_conditions(wl, wlvif,
13361603 wl->conf.conn.wake_up_event,
13371604 wl->conf.conn.listen_interval);
@@ -1355,15 +1622,16 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, · 17 unmodified lines
13551622 int ret;
13561623
13571624 wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow);
1358− WARN_ON(!wow || !wow->any);
1625+ WARN_ON(!wow);
13591626
13601627 wl1271_tx_flush(wl);
13611628
13621629 mutex_lock(&wl->mutex);
13631630 wl->wow_enabled = true;
13641631 wl12xx_for_each_wlvif(wl, wlvif) {
1365− ret = wl1271_configure_suspend(wl, wlvif);
1632+ ret = wl1271_configure_suspend(wl, wlvif, wow);
13661633 if (ret < 0) {
1634+ mutex_unlock(&wl->mutex);
13671635 wl1271_warning("couldn't prepare device to suspend");
13681636 return ret;
13691637 }
@@ -1487,6 +1755,7 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) · 117 unmodified lines
14871755 cancel_work_sync(&wl->tx_work);
14881756 cancel_delayed_work_sync(&wl->elp_work);
14891757 cancel_delayed_work_sync(&wl->tx_watchdog_work);
1758+ cancel_delayed_work_sync(&wl->connection_loss_work);
14901759
14911760 /* let's notify MAC80211 about the remaining pending TX frames */
14921761 wl12xx_tx_reset(wl, true);
@@ -3439,6 +3708,9 @@ sta_not_found: · 1946 unmodified lines
34393708 do_join = true;
34403709 set_assoc = true;
34413710
3711+ /* Cancel connection_loss_work */
3712+ cancel_delayed_work_sync(&wl->connection_loss_work);
3713+
34423714 /*
34433715 * use basic rates from AP, and determine lowest rate
34443716 * to use with control frames.
@@ -4549,6 +4821,34 @@ static struct bin_attribute fwlog_attr = { · 1104 unmodified lines
45494821 .read = wl1271_sysfs_read_fwlog,
45504822 };
45514823
4824+static void wl1271_connection_loss_work(struct work_struct *work)
4825+{
4826+ struct delayed_work *dwork;
4827+ struct wl1271 *wl;
4828+ struct ieee80211_vif *vif;
4829+ struct wl12xx_vif *wlvif;
4830+
4831+ dwork = container_of(work, struct delayed_work, work);
4832+ wl = container_of(dwork, struct wl1271, connection_loss_work);
4833+
4834+ wl1271_info("Connection loss work.");
4835+
4836+ mutex_lock(&wl->mutex);
4837+
4838+ if (unlikely(wl->state == WL1271_STATE_OFF))
4839+ goto out;
4840+
4841+ /* Call mac80211 connection loss */
4842+ wl12xx_for_each_wlvif_sta(wl, wlvif) {
4843+ if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
4844+ goto out;
4845+ vif = wl12xx_wlvif_to_vif(wlvif);
4846+ ieee80211_connection_loss(vif);
4847+ }
4848+out:
4849+ mutex_unlock(&wl->mutex);
4850+}
4851+
45524852 static void wl12xx_derive_mac_addresses(struct wl1271 *wl,
45534853 u32 oui, u32 nic, int n)
45544854 {
@@ -4804,6 +5104,8 @@ struct ieee80211_hw *wlcore_alloc_hw(size_t priv_size) · 249 unmodified lines
48045104 INIT_WORK(&wl->recovery_work, wl1271_recovery_work);
48055105 INIT_DELAYED_WORK(&wl->scan_complete_work, wl1271_scan_complete_work);
48065106 INIT_DELAYED_WORK(&wl->tx_watchdog_work, wl12xx_tx_watchdog_work);
5107+ INIT_DELAYED_WORK(&wl->connection_loss_work,
5108+ wl1271_connection_loss_work);
48075109
48085110 wl->freezable_wq = create_freezable_workqueue("wl12xx_wq");
48095111 if (!wl->freezable_wq) {
@@ -4861,7 +5163,7 @@ struct ieee80211_hw *wlcore_alloc_hw(size_t priv_size) · 51 unmodified lines
48615163 goto err_dummy_packet;
48625164 }
48635165
4864− wl->mbox = kmalloc(sizeof(*wl->mbox), GFP_DMA);
5166+ wl->mbox = kmalloc(sizeof(*wl->mbox), GFP_KERNEL | GFP_DMA);
48655167 if (!wl->mbox) {
48665168 ret = -ENOMEM;
48675169 goto err_fwlog;
@@ -5003,9 +5305,14 @@ int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev) · 135 unmodified lines
50035305 if (!ret) {
50045306 wl->irq_wake_enabled = true;
50055307 device_init_wakeup(wl->dev, 1);
5006− if (pdata->pwr_in_suspend)
5308+ if (pdata->pwr_in_suspend) {
50075309 wl->hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY;
5008−
5310+ wl->hw->wiphy->wowlan.n_patterns =
5311+ WL1271_MAX_RX_FILTERS;
5312+ wl->hw->wiphy->wowlan.pattern_min_len = 1;
5313+ wl->hw->wiphy->wowlan.pattern_max_len =
5314+ WL1271_RX_FILTER_MAX_PATTERN_SIZE;
5315+ }
50095316 }
50105317 disable_irq(wl->irq);
50115318
drivers/net/wireless/ti/wlcore/rx.c+36−0
@@ -278,3 +278,39 @@ void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status *status) · 277 unmodified lines
278278
279279 wl12xx_rearm_rx_streaming(wl, active_hlids);
280280 }
281+
282+int wl1271_rx_filter_enable(struct wl1271 *wl,
283+ int index, bool enable,
284+ struct wl12xx_rx_filter *filter)
285+{
286+ int ret;
287+
288+ if (wl->rx_filter_enabled[index] == enable) {
289+ wl1271_warning("Request to enable an already "
290+ "enabled rx filter %d", index);
291+ return 0;
292+ }
293+
294+ ret = wl1271_acx_set_rx_filter(wl, index, enable, filter);
295+
296+ if (ret) {
297+ wl1271_error("Failed to %s rx data filter %d (err=%d)",
298+ enable ? "enable" : "disable", index, ret);
299+ return ret;
300+ }
301+
302+ wl->rx_filter_enabled[index] = enable;
303+
304+ return 0;
305+}
306+
307+void wl1271_rx_filter_clear_all(struct wl1271 *wl)
308+{
309+ int i;
310+
311+ for (i = 0; i < WL1271_MAX_RX_FILTERS; i++) {
312+ if (!wl->rx_filter_enabled[i])
313+ continue;
314+ wl1271_rx_filter_enable(wl, i, 0, NULL);
315+ }
316+}
drivers/net/wireless/ti/wlcore/rx.h+4−0
@@ -138,5 +138,9 @@ struct wl1271_rx_descriptor { · 137 unmodified lines
138138
139139 void wl12xx_rx(struct wl1271 *wl, struct wl_fw_status *status);
140140 u8 wl1271_rate_to_idx(int rate, enum ieee80211_band band);
141+int wl1271_rx_filter_enable(struct wl1271 *wl,
142+ int index, bool enable,
143+ struct wl12xx_rx_filter *filter);
144+void wl1271_rx_filter_clear_all(struct wl1271 *wl);
141145
142146 #endif
drivers/net/wireless/ti/wlcore/wl12xx.h+41−0
@@ -279,6 +279,39 @@ struct wl1271_link { · 278 unmodified lines
279279 u8 ba_bitmap;
280280 };
281281
282+#define WL1271_MAX_RX_FILTERS 5
283+#define WL1271_RX_FILTER_MAX_FIELDS 8
284+
285+#define WL1271_RX_FILTER_ETH_HEADER_SIZE 14
286+#define WL1271_RX_FILTER_MAX_FIELDS_SIZE 95
287+#define RX_FILTER_FIELD_OVERHEAD \
288+ (sizeof(struct wl12xx_rx_filter_field) - sizeof(u8 *))
289+#define WL1271_RX_FILTER_MAX_PATTERN_SIZE \
290+ (WL1271_RX_FILTER_MAX_FIELDS_SIZE - RX_FILTER_FIELD_OVERHEAD)
291+
292+#define WL1271_RX_FILTER_FLAG_MASK BIT(0)
293+#define WL1271_RX_FILTER_FLAG_IP_HEADER 0
294+#define WL1271_RX_FILTER_FLAG_ETHERNET_HEADER BIT(1)
295+
296+enum rx_filter_action {
297+ FILTER_DROP = 0,
298+ FILTER_SIGNAL = 1,
299+ FILTER_FW_HANDLE = 2
300+};
301+
302+struct wl12xx_rx_filter_field {
303+ __le16 offset;
304+ u8 len;
305+ u8 flags;
306+ u8 *pattern;
307+} __packed;
308+
309+struct wl12xx_rx_filter {
310+ u8 action;
311+ int num_fields;
312+ struct wl12xx_rx_filter_field fields[WL1271_RX_FILTER_MAX_FIELDS];
313+};
314+
282315 struct wl1271_station {
283316 u8 hlid;
284317 };
@@ -439,6 +472,14 @@ int wl1271_plt_stop(struct wl1271 *wl); · 154 unmodified lines
439472 int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif);
440473 void wl12xx_queue_recovery_work(struct wl1271 *wl);
441474 size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen);
475+int wl1271_rx_filter_alloc_field(struct wl12xx_rx_filter *filter,
476+ u16 offset, u8 flags,
477+ u8 *pattern, u8 len);
478+void wl1271_rx_filter_free(struct wl12xx_rx_filter *filter);
479+struct wl12xx_rx_filter *wl1271_rx_filter_alloc(void);
480+int wl1271_rx_filter_get_fields_size(struct wl12xx_rx_filter *filter);
481+void wl1271_rx_filter_flatten_fields(struct wl12xx_rx_filter *filter,
482+ u8 *buf);
442483
443484 #define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */
444485
drivers/net/wireless/ti/wlcore/wlcore.h+6−0
@@ -243,6 +243,9 @@ struct wl1271 { · 242 unmodified lines
243243 struct wl1271_scan scan;
244244 struct delayed_work scan_complete_work;
245245
246+ /* Connection loss work */
247+ struct delayed_work connection_loss_work;
248+
246249 bool sched_scanning;
247250
248251 /* The current band */
@@ -349,6 +352,9 @@ struct wl1271 { · 100 unmodified lines
349352
350353 /* size of the private FW status data */
351354 size_t fw_status_priv_len;
355+
356+ /* RX Data filter rule state - enabled/disabled */
357+ bool rx_filter_enabled[WL1271_MAX_RX_FILTERS];
352358 };
353359
354360 int __devinit wlcore_probe(struct wl1271 *wl, struct platform_device *pdev);
drivers/net/xen-netfront.c+0−6
@@ -1962,9 +1962,6 @@ static int __init netif_init(void) · 1961 unmodified lines
19621962 if (!xen_domain())
19631963 return -ENODEV;
19641964
1965− if (xen_initial_domain())
1966− return 0;
1967−
19681965 if (xen_hvm_domain() && !xen_platform_pci_unplug)
19691966 return -ENODEV;
19701967
@@ -1977,9 +1974,6 @@ module_init(netif_init); · 6 unmodified lines
19771974
19781975 static void __exit netif_exit(void)
19791976 {
1980− if (xen_initial_domain())
1981− return;
1982−
19831977 xenbus_unregister_driver(&netfront_driver);
19841978 }
19851979 module_exit(netif_exit);
drivers/nfc/Kconfig+13−0
@@ -17,6 +17,19 @@ config PN544_NFC · 16 unmodified lines
1717 To compile this driver as a module, choose m here. The module will
1818 be called pn544.
1919
20+config PN544_HCI_NFC
21+ tristate "HCI PN544 NFC driver"
22+ depends on I2C && NFC_SHDLC
23+ select CRC_CCITT
24+ default n
25+ ---help---
26+ NXP PN544 i2c driver.
27+ This is a driver based on the SHDLC and HCI NFC kernel layers and
28+ will thus not work with NXP libnfc library.
29+
30+ To compile this driver as a module, choose m here. The module will
31+ be called pn544_hci.
32+
2033 config NFC_PN533
2134 tristate "NXP PN533 USB driver"
2235 depends on USB
drivers/nfc/Makefile+1−0
@@ -3,6 +3,7 @@ · 2 unmodified lines
33 #
44
55 obj-$(CONFIG_PN544_NFC) += pn544.o
6+obj-$(CONFIG_PN544_HCI_NFC) += pn544_hci.o
67 obj-$(CONFIG_NFC_PN533) += pn533.o
78 obj-$(CONFIG_NFC_WILINK) += nfcwilink.o
89
drivers/nfc/pn533.c+8−11
@@ -394,9 +394,6 @@ static void pn533_wq_cmd_complete(struct work_struct *work) · 393 unmodified lines
394394 struct pn533_frame *in_frame;
395395 int rc;
396396
397− if (dev == NULL)
398− return;
399−
400397 in_frame = dev->wq_in_frame;
401398
402399 if (dev->wq_in_error)
@@ -1194,8 +1191,8 @@ static int pn533_activate_target_nfcdep(struct pn533 *dev) · 791 unmodified lines
11941191 return rc;
11951192 }
11961193
1197−static int pn533_activate_target(struct nfc_dev *nfc_dev, u32 target_idx,
1198− u32 protocol)
1194+static int pn533_activate_target(struct nfc_dev *nfc_dev,
1195+ struct nfc_target *target, u32 protocol)
11991196 {
12001197 struct pn533 *dev = nfc_get_drvdata(nfc_dev);
12011198 int rc;
@@ -1243,7 +1240,8 @@ static int pn533_activate_target(struct nfc_dev *nfc_dev, u32 target_idx, · 41 unmodified lines
12431240 return 0;
12441241 }
12451242
1246−static void pn533_deactivate_target(struct nfc_dev *nfc_dev, u32 target_idx)
1243+static void pn533_deactivate_target(struct nfc_dev *nfc_dev,
1244+ struct nfc_target *target)
12471245 {
12481246 struct pn533 *dev = nfc_get_drvdata(nfc_dev);
12491247 u8 tg;
@@ -1351,7 +1349,7 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg, · 101 unmodified lines
13511349 return 0;
13521350 }
13531351
1354−static int pn533_dep_link_up(struct nfc_dev *nfc_dev, int target_idx,
1352+static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
13551353 u8 comm_mode, u8* gb, size_t gb_len)
13561354 {
13571355 struct pn533 *dev = nfc_get_drvdata(nfc_dev);
@@ -1552,10 +1550,9 @@ error: · 194 unmodified lines
15521550 return 0;
15531551 }
15541552
1555−static int pn533_data_exchange(struct nfc_dev *nfc_dev, u32 target_idx,
1556− struct sk_buff *skb,
1557− data_exchange_cb_t cb,
1558− void *cb_context)
1553+static int pn533_data_exchange(struct nfc_dev *nfc_dev,
1554+ struct nfc_target *target, struct sk_buff *skb,
1555+ data_exchange_cb_t cb, void *cb_context)
15591556 {
15601557 struct pn533 *dev = nfc_get_drvdata(nfc_dev);
15611558 struct pn533_frame *out_frame, *in_frame;
drivers/nfc/pn544_hci.c+947−0
@@ -0,0 +1,947 @@
1+/*
2+ * HCI based Driver for NXP PN544 NFC Chip
3+ *
4+ * Copyright (C) 2012 Intel Corporation. All rights reserved.
5+ *
6+ * This program is free software; you can redistribute it and/or modify it
7+ * under the terms and conditions of the GNU General Public License,
8+ * version 2, as published by the Free Software Foundation.
9+ *
10+ * This program is distributed in the hope that it will be useful,
11+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+ * GNU General Public License for more details.
14+ *
15+ * You should have received a copy of the GNU General Public License
16+ * along with this program; if not, write to the
17+ * Free Software Foundation, Inc.,
18+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19+ */
20+
21+#include <linux/crc-ccitt.h>
22+#include <linux/module.h>
23+#include <linux/delay.h>
24+#include <linux/slab.h>
25+#include <linux/miscdevice.h>
26+#include <linux/interrupt.h>
27+#include <linux/gpio.h>
28+#include <linux/i2c.h>
29+
30+#include <linux/nfc.h>
31+#include <net/nfc/hci.h>
32+#include <net/nfc/shdlc.h>
33+
34+#include <linux/nfc/pn544.h>
35+
36+#define DRIVER_DESC "HCI NFC driver for PN544"
37+
38+#define PN544_HCI_DRIVER_NAME "pn544_hci"
39+
40+/* Timing restrictions (ms) */
41+#define PN544_HCI_RESETVEN_TIME 30
42+
43+static struct i2c_device_id pn544_hci_id_table[] = {
44+ {"pn544", 0},
45+ {}
46+};
47+
48+MODULE_DEVICE_TABLE(i2c, pn544_hci_id_table);
49+
50+#define HCI_MODE 0
51+#define FW_MODE 1
52+
53+/* framing in HCI mode */
54+#define PN544_HCI_LLC_LEN 1
55+#define PN544_HCI_LLC_CRC 2
56+#define PN544_HCI_LLC_LEN_CRC (PN544_HCI_LLC_LEN + PN544_HCI_LLC_CRC)
57+#define PN544_HCI_LLC_MIN_SIZE (1 + PN544_HCI_LLC_LEN_CRC)
58+#define PN544_HCI_LLC_MAX_PAYLOAD 29
59+#define PN544_HCI_LLC_MAX_SIZE (PN544_HCI_LLC_LEN_CRC + 1 + \
60+ PN544_HCI_LLC_MAX_PAYLOAD)
61+
62+enum pn544_state {
63+ PN544_ST_COLD,
64+ PN544_ST_FW_READY,
65+ PN544_ST_READY,
66+};
67+
68+#define FULL_VERSION_LEN 11
69+
70+/* Proprietary commands */
71+#define PN544_WRITE 0x3f
72+
73+/* Proprietary gates, events, commands and registers */
74+
75+/* NFC_HCI_RF_READER_A_GATE additional registers and commands */
76+#define PN544_RF_READER_A_AUTO_ACTIVATION 0x10
77+#define PN544_RF_READER_A_CMD_CONTINUE_ACTIVATION 0x12
78+#define PN544_MIFARE_CMD 0x21
79+
80+/* Commands that apply to all RF readers */
81+#define PN544_RF_READER_CMD_PRESENCE_CHECK 0x30
82+#define PN544_RF_READER_CMD_ACTIVATE_NEXT 0x32
83+
84+/* NFC_HCI_ID_MGMT_GATE additional registers */
85+#define PN544_ID_MGMT_FULL_VERSION_SW 0x10
86+
87+#define PN544_RF_READER_ISO15693_GATE 0x12
88+
89+#define PN544_RF_READER_F_GATE 0x14
90+#define PN544_FELICA_ID 0x04
91+#define PN544_FELICA_RAW 0x20
92+
93+#define PN544_RF_READER_JEWEL_GATE 0x15
94+#define PN544_JEWEL_RAW_CMD 0x23
95+
96+#define PN544_RF_READER_NFCIP1_INITIATOR_GATE 0x30
97+#define PN544_RF_READER_NFCIP1_TARGET_GATE 0x31
98+
99+#define PN544_SYS_MGMT_GATE 0x90
100+#define PN544_SYS_MGMT_INFO_NOTIFICATION 0x02
101+
102+#define PN544_POLLING_LOOP_MGMT_GATE 0x94
103+#define PN544_PL_RDPHASES 0x06
104+#define PN544_PL_EMULATION 0x07
105+#define PN544_PL_NFCT_DEACTIVATED 0x09
106+
107+#define PN544_SWP_MGMT_GATE 0xA0
108+
109+#define PN544_NFC_WI_MGMT_GATE 0xA1
110+
111+static u8 pn544_custom_gates[] = {
112+ PN544_SYS_MGMT_GATE,
113+ PN544_SWP_MGMT_GATE,
114+ PN544_POLLING_LOOP_MGMT_GATE,
115+ PN544_NFC_WI_MGMT_GATE,
116+ PN544_RF_READER_F_GATE,
117+ PN544_RF_READER_JEWEL_GATE,
118+ PN544_RF_READER_ISO15693_GATE,
119+ PN544_RF_READER_NFCIP1_INITIATOR_GATE,
120+ PN544_RF_READER_NFCIP1_TARGET_GATE
121+};
122+
123+/* Largest headroom needed for outgoing custom commands */
124+#define PN544_CMDS_HEADROOM 2
125+
126+struct pn544_hci_info {
127+ struct i2c_client *i2c_dev;
128+ struct nfc_shdlc *shdlc;
129+
130+ enum pn544_state state;
131+
132+ struct mutex info_lock;
133+
134+ unsigned int gpio_en;
135+ unsigned int gpio_irq;
136+ unsigned int gpio_fw;
137+ unsigned int en_polarity;
138+
139+ int hard_fault; /*
140+ * < 0 if hardware error occured (e.g. i2c err)
141+ * and prevents normal operation.
142+ */
143+};
144+
145+static void pn544_hci_platform_init(struct pn544_hci_info *info)
146+{
147+ int polarity, retry, ret;
148+ char rset_cmd[] = { 0x05, 0xF9, 0x04, 0x00, 0xC3, 0xE5 };
149+ int count = sizeof(rset_cmd);
150+
151+ pr_info(DRIVER_DESC ": %s\n", __func__);
152+ dev_info(&info->i2c_dev->dev, "Detecting nfc_en polarity\n");
153+
154+ /* Disable fw download */
155+ gpio_set_value(info->gpio_fw, 0);
156+
157+ for (polarity = 0; polarity < 2; polarity++) {
158+ info->en_polarity = polarity;
159+ retry = 3;
160+ while (retry--) {
161+ /* power off */
162+ gpio_set_value(info->gpio_en, !info->en_polarity);
163+ usleep_range(10000, 15000);
164+
165+ /* power on */
166+ gpio_set_value(info->gpio_en, info->en_polarity);
167+ usleep_range(10000, 15000);
168+
169+ /* send reset */
170+ dev_dbg(&info->i2c_dev->dev, "Sending reset cmd\n");
171+ ret = i2c_master_send(info->i2c_dev, rset_cmd, count);
172+ if (ret == count) {
173+ dev_info(&info->i2c_dev->dev,
174+ "nfc_en polarity : active %s\n",
175+ (polarity == 0 ? "low" : "high"));
176+ goto out;
177+ }
178+ }
179+ }
180+
181+ dev_err(&info->i2c_dev->dev,
182+ "Could not detect nfc_en polarity, fallback to active high\n");
183+
184+out:
185+ gpio_set_value(info->gpio_en, !info->en_polarity);
186+}
187+
188+static int pn544_hci_enable(struct pn544_hci_info *info, int mode)
189+{
190+ pr_info(DRIVER_DESC ": %s\n", __func__);
191+
192+ gpio_set_value(info->gpio_fw, 0);
193+ gpio_set_value(info->gpio_en, info->en_polarity);
194+ usleep_range(10000, 15000);
195+
196+ return 0;
197+}
198+
199+static void pn544_hci_disable(struct pn544_hci_info *info)
200+{
201+ pr_info(DRIVER_DESC ": %s\n", __func__);
202+
203+ gpio_set_value(info->gpio_fw, 0);
204+ gpio_set_value(info->gpio_en, !info->en_polarity);
205+ usleep_range(10000, 15000);
206+
207+ gpio_set_value(info->gpio_en, info->en_polarity);
208+ usleep_range(10000, 15000);
209+
210+ gpio_set_value(info->gpio_en, !info->en_polarity);
211+ usleep_range(10000, 15000);
212+}
213+
214+static int pn544_hci_i2c_write(struct i2c_client *client, u8 *buf, int len)
215+{
216+ int r;
217+
218+ usleep_range(3000, 6000);
219+
220+ r = i2c_master_send(client, buf, len);
221+
222+ if (r == -EREMOTEIO) { /* Retry, chip was in standby */
223+ usleep_range(6000, 10000);
224+ r = i2c_master_send(client, buf, len);
225+ }
226+
227+ if (r >= 0 && r != len)
228+ r = -EREMOTEIO;
229+
230+ return r;
231+}
232+
233+static int check_crc(u8 *buf, int buflen)
234+{
235+ u8 len;
236+ u16 crc;
237+
238+ len = buf[0] + 1;
239+ crc = crc_ccitt(0xffff, buf, len - 2);
240+ crc = ~crc;
241+
242+ if (buf[len - 2] != (crc & 0xff) || buf[len - 1] != (crc >> 8)) {
243+ pr_err(PN544_HCI_DRIVER_NAME ": CRC error 0x%x != 0x%x 0x%x\n",
244+ crc, buf[len - 1], buf[len - 2]);
245+
246+ pr_info(DRIVER_DESC ": %s : BAD CRC\n", __func__);
247+ print_hex_dump(KERN_DEBUG, "crc: ", DUMP_PREFIX_NONE,
248+ 16, 2, buf, buflen, false);
249+ return -EPERM;
250+ }
251+ return 0;
252+}
253+
254+/*
255+ * Reads an shdlc frame and returns it in a newly allocated sk_buff. Guarantees
256+ * that i2c bus will be flushed and that next read will start on a new frame.
257+ * returned skb contains only LLC header and payload.
258+ * returns:
259+ * -EREMOTEIO : i2c read error (fatal)
260+ * -EBADMSG : frame was incorrect and discarded
261+ * -ENOMEM : cannot allocate skb, frame dropped
262+ */
263+static int pn544_hci_i2c_read(struct i2c_client *client, struct sk_buff **skb)
264+{
265+ int r;
266+ u8 len;
267+ u8 tmp[PN544_HCI_LLC_MAX_SIZE - 1];
268+
269+ r = i2c_master_recv(client, &len, 1);
270+ if (r != 1) {
271+ dev_err(&client->dev, "cannot read len byte\n");
272+ return -EREMOTEIO;
273+ }
274+
275+ if ((len < (PN544_HCI_LLC_MIN_SIZE - 1)) ||
276+ (len > (PN544_HCI_LLC_MAX_SIZE - 1))) {
277+ dev_err(&client->dev, "invalid len byte\n");
278+ r = -EBADMSG;
279+ goto flush;
280+ }
281+
282+ *skb = alloc_skb(1 + len, GFP_KERNEL);
283+ if (*skb == NULL) {
284+ r = -ENOMEM;
285+ goto flush;
286+ }
287+
288+ *skb_put(*skb, 1) = len;
289+
290+ r = i2c_master_recv(client, skb_put(*skb, len), len);
291+ if (r != len) {
292+ kfree_skb(*skb);
293+ return -EREMOTEIO;
294+ }
295+
296+ r = check_crc((*skb)->data, (*skb)->len);
297+ if (r != 0) {
298+ kfree_skb(*skb);
299+ r = -EBADMSG;
300+ goto flush;
301+ }
302+
303+ skb_pull(*skb, 1);
304+ skb_trim(*skb, (*skb)->len - 2);
305+
306+ usleep_range(3000, 6000);
307+
308+ return 0;
309+
310+flush:
311+ if (i2c_master_recv(client, tmp, sizeof(tmp)) < 0)
312+ r = -EREMOTEIO;
313+
314+ usleep_range(3000, 6000);
315+
316+ return r;
317+}
318+
319+/*
320+ * Reads an shdlc frame from the chip. This is not as straightforward as it
321+ * seems. There are cases where we could loose the frame start synchronization.
322+ * The frame format is len-data-crc, and corruption can occur anywhere while
323+ * transiting on i2c bus, such that we could read an invalid len.
324+ * In order to recover synchronization with the next frame, we must be sure
325+ * to read the real amount of data without using the len byte. We do this by
326+ * assuming the following:
327+ * - the chip will always present only one single complete frame on the bus
328+ * before triggering the interrupt
329+ * - the chip will not present a new frame until we have completely read
330+ * the previous one (or until we have handled the interrupt).
331+ * The tricky case is when we read a corrupted len that is less than the real
332+ * len. We must detect this here in order to determine that we need to flush
333+ * the bus. This is the reason why we check the crc here.
334+ */
335+static irqreturn_t pn544_hci_irq_thread_fn(int irq, void *dev_id)
336+{
337+ struct pn544_hci_info *info = dev_id;
338+ struct i2c_client *client = info->i2c_dev;
339+ struct sk_buff *skb = NULL;
340+ int r;
341+
342+ BUG_ON(!info);
343+ BUG_ON(irq != info->i2c_dev->irq);
344+
345+ dev_dbg(&client->dev, "IRQ\n");
346+
347+ if (info->hard_fault != 0)
348+ return IRQ_HANDLED;
349+
350+ r = pn544_hci_i2c_read(client, &skb);
351+ if (r == -EREMOTEIO) {
352+ info->hard_fault = r;
353+
354+ nfc_shdlc_recv_frame(info->shdlc, NULL);
355+
356+ return IRQ_HANDLED;
357+ } else if ((r == -ENOMEM) || (r == -EBADMSG)) {
358+ return IRQ_HANDLED;
359+ }
360+
361+ nfc_shdlc_recv_frame(info->shdlc, skb);
362+
363+ return IRQ_HANDLED;
364+}
365+
366+static int pn544_hci_open(struct nfc_shdlc *shdlc)
367+{
368+ struct pn544_hci_info *info = nfc_shdlc_get_clientdata(shdlc);
369+ int r = 0;
370+
371+ mutex_lock(&info->info_lock);
372+
373+ if (info->state != PN544_ST_COLD) {
374+ r = -EBUSY;
375+ goto out;
376+ }
377+
378+ r = pn544_hci_enable(info, HCI_MODE);
379+
380+out:
381+ mutex_unlock(&info->info_lock);
382+ return r;
383+}
384+
385+static void pn544_hci_close(struct nfc_shdlc *shdlc)
386+{
387+ struct pn544_hci_info *info = nfc_shdlc_get_clientdata(shdlc);
388+
389+ mutex_lock(&info->info_lock);
390+
391+ if (info->state == PN544_ST_COLD)
392+ goto out;
393+
394+ pn544_hci_disable(info);
395+
396+out:
397+ mutex_unlock(&info->info_lock);
398+}
399+
400+static int pn544_hci_ready(struct nfc_shdlc *shdlc)
401+{
402+ struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
403+ struct sk_buff *skb;
404+ static struct hw_config {
405+ u8 adr[2];
406+ u8 value;
407+ } hw_config[] = {
408+ {{0x9f, 0x9a}, 0x00},
409+
410+ {{0x98, 0x10}, 0xbc},
411+
412+ {{0x9e, 0x71}, 0x00},
413+
414+ {{0x98, 0x09}, 0x00},
415+
416+ {{0x9e, 0xb4}, 0x00},
417+
418+ {{0x9e, 0xd9}, 0xff},
419+ {{0x9e, 0xda}, 0xff},
420+ {{0x9e, 0xdb}, 0x23},
421+ {{0x9e, 0xdc}, 0x21},
422+ {{0x9e, 0xdd}, 0x22},
423+ {{0x9e, 0xde}, 0x24},
424+
425+ {{0x9c, 0x01}, 0x08},
426+
427+ {{0x9e, 0xaa}, 0x01},
428+
429+ {{0x9b, 0xd1}, 0x0d},
430+ {{0x9b, 0xd2}, 0x24},
431+ {{0x9b, 0xd3}, 0x0a},
432+ {{0x9b, 0xd4}, 0x22},
433+ {{0x9b, 0xd5}, 0x08},
434+ {{0x9b, 0xd6}, 0x1e},
435+ {{0x9b, 0xdd}, 0x1c},
436+
437+ {{0x9b, 0x84}, 0x13},
438+ {{0x99, 0x81}, 0x7f},
439+ {{0x99, 0x31}, 0x70},
440+
441+ {{0x98, 0x00}, 0x3f},
442+
443+ {{0x9f, 0x09}, 0x00},
444+
445+ {{0x9f, 0x0a}, 0x05},
446+
447+ {{0x9e, 0xd1}, 0xa1},
448+ {{0x99, 0x23}, 0x00},
449+
450+ {{0x9e, 0x74}, 0x80},
451+
452+ {{0x9f, 0x28}, 0x10},
453+
454+ {{0x9f, 0x35}, 0x14},
455+
456+ {{0x9f, 0x36}, 0x60},
457+
458+ {{0x9c, 0x31}, 0x00},
459+
460+ {{0x9c, 0x32}, 0xc8},
461+
462+ {{0x9c, 0x19}, 0x40},
463+
464+ {{0x9c, 0x1a}, 0x40},
465+
466+ {{0x9c, 0x0c}, 0x00},
467+
468+ {{0x9c, 0x0d}, 0x00},
469+
470+ {{0x9c, 0x12}, 0x00},
471+
472+ {{0x9c, 0x13}, 0x00},
473+
474+ {{0x98, 0xa2}, 0x0e},
475+
476+ {{0x98, 0x93}, 0x40},
477+
478+ {{0x98, 0x7d}, 0x02},
479+ {{0x98, 0x7e}, 0x00},
480+ {{0x9f, 0xc8}, 0x01},
481+ };
482+ struct hw_config *p = hw_config;
483+ int count = ARRAY_SIZE(hw_config);
484+ struct sk_buff *res_skb;
485+ u8 param[4];
486+ int r;
487+
488+ param[0] = 0;
489+ while (count--) {
490+ param[1] = p->adr[0];
491+ param[2] = p->adr[1];
492+ param[3] = p->value;
493+
494+ r = nfc_hci_send_cmd(hdev, PN544_SYS_MGMT_GATE, PN544_WRITE,
495+ param, 4, &res_skb);
496+ if (r < 0)
497+ return r;
498+
499+ if (res_skb->len != 1) {
500+ kfree_skb(res_skb);
501+ return -EPROTO;
502+ }
503+
504+ if (res_skb->data[0] != p->value) {
505+ kfree_skb(res_skb);
506+ return -EIO;
507+ }
508+
509+ kfree_skb(res_skb);
510+
511+ p++;
512+ }
513+
514+ param[0] = NFC_HCI_UICC_HOST_ID;
515+ r = nfc_hci_set_param(hdev, NFC_HCI_ADMIN_GATE,
516+ NFC_HCI_ADMIN_WHITELIST, param, 1);
517+ if (r < 0)
518+ return r;
519+
520+ param[0] = 0x3d;
521+ r = nfc_hci_set_param(hdev, PN544_SYS_MGMT_GATE,
522+ PN544_SYS_MGMT_INFO_NOTIFICATION, param, 1);
523+ if (r < 0)
524+ return r;
525+
526+ param[0] = 0x0;
527+ r = nfc_hci_set_param(hdev, NFC_HCI_RF_READER_A_GATE,
528+ PN544_RF_READER_A_AUTO_ACTIVATION, param, 1);
529+ if (r < 0)
530+ return r;
531+
532+ r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
533+ NFC_HCI_EVT_END_OPERATION, NULL, 0);
534+ if (r < 0)
535+ return r;
536+
537+ param[0] = 0x1;
538+ r = nfc_hci_set_param(hdev, PN544_POLLING_LOOP_MGMT_GATE,
539+ PN544_PL_NFCT_DEACTIVATED, param, 1);
540+ if (r < 0)
541+ return r;
542+
543+ param[0] = 0x0;
544+ r = nfc_hci_set_param(hdev, PN544_POLLING_LOOP_MGMT_GATE,
545+ PN544_PL_RDPHASES, param, 1);
546+ if (r < 0)
547+ return r;
548+
549+ r = nfc_hci_get_param(hdev, NFC_HCI_ID_MGMT_GATE,
550+ PN544_ID_MGMT_FULL_VERSION_SW, &skb);
551+ if (r < 0)
552+ return r;
553+
554+ if (skb->len != FULL_VERSION_LEN) {
555+ kfree_skb(skb);
556+ return -EINVAL;
557+ }
558+
559+ print_hex_dump(KERN_DEBUG, "FULL VERSION SOFTWARE INFO: ",
560+ DUMP_PREFIX_NONE, 16, 1,
561+ skb->data, FULL_VERSION_LEN, false);
562+
563+ kfree_skb(skb);
564+
565+ return 0;
566+}
567+
568+static int pn544_hci_xmit(struct nfc_shdlc *shdlc, struct sk_buff *skb)
569+{
570+ struct pn544_hci_info *info = nfc_shdlc_get_clientdata(shdlc);
571+ struct i2c_client *client = info->i2c_dev;
572+
573+ if (info->hard_fault != 0)
574+ return info->hard_fault;
575+
576+ return pn544_hci_i2c_write(client, skb->data, skb->len);
577+}
578+
579+static int pn544_hci_start_poll(struct nfc_shdlc *shdlc, u32 protocols)
580+{
581+ struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
582+ u8 phases = 0;
583+ int r;
584+ u8 duration[2];
585+ u8 activated;
586+
587+ pr_info(DRIVER_DESC ": %s protocols = %d\n", __func__, protocols);
588+
589+ r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
590+ NFC_HCI_EVT_END_OPERATION, NULL, 0);
591+ if (r < 0)
592+ return r;
593+
594+ duration[0] = 0x18;
595+ duration[1] = 0x6a;
596+ r = nfc_hci_set_param(hdev, PN544_POLLING_LOOP_MGMT_GATE,
597+ PN544_PL_EMULATION, duration, 2);
598+ if (r < 0)
599+ return r;
600+
601+ activated = 0;
602+ r = nfc_hci_set_param(hdev, PN544_POLLING_LOOP_MGMT_GATE,
603+ PN544_PL_NFCT_DEACTIVATED, &activated, 1);
604+ if (r < 0)
605+ return r;
606+
607+ if (protocols & (NFC_PROTO_ISO14443_MASK | NFC_PROTO_MIFARE_MASK |
608+ NFC_PROTO_JEWEL_MASK))
609+ phases |= 1; /* Type A */
610+ if (protocols & NFC_PROTO_FELICA_MASK) {
611+ phases |= (1 << 2); /* Type F 212 */
612+ phases |= (1 << 3); /* Type F 424 */
613+ }
614+
615+ phases |= (1 << 5); /* NFC active */
616+
617+ r = nfc_hci_set_param(hdev, PN544_POLLING_LOOP_MGMT_GATE,
618+ PN544_PL_RDPHASES, &phases, 1);
619+ if (r < 0)
620+ return r;
621+
622+ r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
623+ NFC_HCI_EVT_READER_REQUESTED, NULL, 0);
624+ if (r < 0)
625+ nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
626+ NFC_HCI_EVT_END_OPERATION, NULL, 0);
627+
628+ return r;
629+}
630+
631+static int pn544_hci_target_from_gate(struct nfc_shdlc *shdlc, u8 gate,
632+ struct nfc_target *target)
633+{
634+ switch (gate) {
635+ case PN544_RF_READER_F_GATE:
636+ target->supported_protocols = NFC_PROTO_FELICA_MASK;
637+ break;
638+ case PN544_RF_READER_JEWEL_GATE:
639+ target->supported_protocols = NFC_PROTO_JEWEL_MASK;
640+ target->sens_res = 0x0c00;
641+ break;
642+ default:
643+ return -EPROTO;
644+ }
645+
646+ return 0;
647+}
648+
649+static int pn544_hci_complete_target_discovered(struct nfc_shdlc *shdlc,
650+ u8 gate,
651+ struct nfc_target *target)
652+{
653+ struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
654+ struct sk_buff *uid_skb;
655+ int r = 0;
656+
657+ if (target->supported_protocols & NFC_PROTO_MIFARE_MASK) {
658+ if (target->nfcid1_len != 4 && target->nfcid1_len != 7 &&
659+ target->nfcid1_len != 10)
660+ return -EPROTO;
661+
662+ r = nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE,
663+ PN544_RF_READER_CMD_ACTIVATE_NEXT,
664+ target->nfcid1, target->nfcid1_len, NULL);
665+ } else if (target->supported_protocols & NFC_PROTO_FELICA_MASK) {
666+ r = nfc_hci_get_param(hdev, PN544_RF_READER_F_GATE,
667+ PN544_FELICA_ID, &uid_skb);
668+ if (r < 0)
669+ return r;
670+
671+ if (uid_skb->len != 8) {
672+ kfree_skb(uid_skb);
673+ return -EPROTO;
674+ }
675+
676+ r = nfc_hci_send_cmd(hdev, PN544_RF_READER_F_GATE,
677+ PN544_RF_READER_CMD_ACTIVATE_NEXT,
678+ uid_skb->data, uid_skb->len, NULL);
679+ kfree_skb(uid_skb);
680+ } else if (target->supported_protocols & NFC_PROTO_ISO14443_MASK) {
681+ /*
682+ * TODO: maybe other ISO 14443 require some kind of continue
683+ * activation, but for now we've seen only this one below.
684+ */
685+ if (target->sens_res == 0x4403) /* Type 4 Mifare DESFire */
686+ r = nfc_hci_send_cmd(hdev, NFC_HCI_RF_READER_A_GATE,
687+ PN544_RF_READER_A_CMD_CONTINUE_ACTIVATION,
688+ NULL, 0, NULL);
689+ }
690+
691+ return r;
692+}
693+
694+#define MIFARE_CMD_AUTH_KEY_A 0x60
695+#define MIFARE_CMD_AUTH_KEY_B 0x61
696+#define MIFARE_CMD_HEADER 2
697+#define MIFARE_UID_LEN 4
698+#define MIFARE_KEY_LEN 6
699+#define MIFARE_CMD_LEN 12
700+/*
701+ * Returns:
702+ * <= 0: driver handled the data exchange
703+ * 1: driver doesn't especially handle, please do standard processing
704+ */
705+static int pn544_hci_data_exchange(struct nfc_shdlc *shdlc,
706+ struct nfc_target *target,
707+ struct sk_buff *skb,
708+ struct sk_buff **res_skb)
709+{
710+ struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
711+ int r;
712+
713+ pr_info(DRIVER_DESC ": %s for gate=%d\n", __func__,
714+ target->hci_reader_gate);
715+
716+ switch (target->hci_reader_gate) {
717+ case NFC_HCI_RF_READER_A_GATE:
718+ if (target->supported_protocols & NFC_PROTO_MIFARE_MASK) {
719+ /*
720+ * It seems that pn544 is inverting key and UID for
721+ * MIFARE authentication commands.
722+ */
723+ if (skb->len == MIFARE_CMD_LEN &&
724+ (skb->data[0] == MIFARE_CMD_AUTH_KEY_A ||
725+ skb->data[0] == MIFARE_CMD_AUTH_KEY_B)) {
726+ u8 uid[MIFARE_UID_LEN];
727+ u8 *data = skb->data + MIFARE_CMD_HEADER;
728+
729+ memcpy(uid, data + MIFARE_KEY_LEN,
730+ MIFARE_UID_LEN);
731+ memmove(data + MIFARE_UID_LEN, data,
732+ MIFARE_KEY_LEN);
733+ memcpy(data, uid, MIFARE_UID_LEN);
734+ }
735+
736+ return nfc_hci_send_cmd(hdev, target->hci_reader_gate,
737+ PN544_MIFARE_CMD,
738+ skb->data, skb->len, res_skb);
739+ } else
740+ return 1;
741+ case PN544_RF_READER_F_GATE:
742+ *skb_push(skb, 1) = 0;
743+ *skb_push(skb, 1) = 0;
744+
745+ r = nfc_hci_send_cmd(hdev, target->hci_reader_gate,
746+ PN544_FELICA_RAW,
747+ skb->data, skb->len, res_skb);
748+ if (r == 0)
749+ skb_pull(*res_skb, 1);
750+ return r;
751+ case PN544_RF_READER_JEWEL_GATE:
752+ return nfc_hci_send_cmd(hdev, target->hci_reader_gate,
753+ PN544_JEWEL_RAW_CMD,
754+ skb->data, skb->len, res_skb);
755+ default:
756+ return 1;
757+ }
758+}
759+
760+static int pn544_hci_check_presence(struct nfc_shdlc *shdlc,
761+ struct nfc_target *target)
762+{
763+ struct nfc_hci_dev *hdev = nfc_shdlc_get_hci_dev(shdlc);
764+
765+ return nfc_hci_send_cmd(hdev, target->hci_reader_gate,
766+ PN544_RF_READER_CMD_PRESENCE_CHECK,
767+ NULL, 0, NULL);
768+}
769+
770+static struct nfc_shdlc_ops pn544_shdlc_ops = {
771+ .open = pn544_hci_open,
772+ .close = pn544_hci_close,
773+ .hci_ready = pn544_hci_ready,
774+ .xmit = pn544_hci_xmit,
775+ .start_poll = pn544_hci_start_poll,
776+ .target_from_gate = pn544_hci_target_from_gate,
777+ .complete_target_discovered = pn544_hci_complete_target_discovered,
778+ .data_exchange = pn544_hci_data_exchange,
779+ .check_presence = pn544_hci_check_presence,
780+};
781+
782+static int __devinit pn544_hci_probe(struct i2c_client *client,
783+ const struct i2c_device_id *id)
784+{
785+ struct pn544_hci_info *info;
786+ struct pn544_nfc_platform_data *pdata;
787+ int r = 0;
788+ u32 protocols;
789+ struct nfc_hci_init_data init_data;
790+
791+ dev_dbg(&client->dev, "%s\n", __func__);
792+ dev_dbg(&client->dev, "IRQ: %d\n", client->irq);
793+
794+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
795+ dev_err(&client->dev, "Need I2C_FUNC_I2C\n");
796+ return -ENODEV;
797+ }
798+
799+ info = kzalloc(sizeof(struct pn544_hci_info), GFP_KERNEL);
800+ if (!info) {
801+ dev_err(&client->dev,
802+ "Cannot allocate memory for pn544_hci_info.\n");
803+ r = -ENOMEM;
804+ goto err_info_alloc;
805+ }
806+
807+ info->i2c_dev = client;
808+ info->state = PN544_ST_COLD;
809+ mutex_init(&info->info_lock);
810+ i2c_set_clientdata(client, info);
811+
812+ pdata = client->dev.platform_data;
813+ if (pdata == NULL) {
814+ dev_err(&client->dev, "No platform data\n");
815+ r = -EINVAL;
816+ goto err_pdata;
817+ }
818+
819+ if (pdata->request_resources == NULL) {
820+ dev_err(&client->dev, "request_resources() missing\n");
821+ r = -EINVAL;
822+ goto err_pdata;
823+ }
824+
825+ r = pdata->request_resources(client);
826+ if (r) {
827+ dev_err(&client->dev, "Cannot get platform resources\n");
828+ goto err_pdata;
829+ }
830+
831+ info->gpio_en = pdata->get_gpio(NFC_GPIO_ENABLE);
832+ info->gpio_fw = pdata->get_gpio(NFC_GPIO_FW_RESET);
833+ info->gpio_irq = pdata->get_gpio(NFC_GPIO_IRQ);
834+
835+ pn544_hci_platform_init(info);
836+
837+ r = request_threaded_irq(client->irq, NULL, pn544_hci_irq_thread_fn,
838+ IRQF_TRIGGER_RISING, PN544_HCI_DRIVER_NAME,
839+ info);
840+ if (r < 0) {
841+ dev_err(&client->dev, "Unable to register IRQ handler\n");
842+ goto err_rti;
843+ }
844+
845+ init_data.gate_count = ARRAY_SIZE(pn544_custom_gates);
846+
847+ memcpy(init_data.gates, pn544_custom_gates,
848+ ARRAY_SIZE(pn544_custom_gates));
849+
850+ /*
851+ * TODO: Session id must include the driver name + some bus addr
852+ * persistent info to discriminate 2 identical chips
853+ */
854+ strcpy(init_data.session_id, "ID544HCI");
855+
856+ protocols = NFC_PROTO_JEWEL_MASK |
857+ NFC_PROTO_MIFARE_MASK |
858+ NFC_PROTO_FELICA_MASK |
859+ NFC_PROTO_ISO14443_MASK |
860+ NFC_PROTO_NFC_DEP_MASK;
861+
862+ info->shdlc = nfc_shdlc_allocate(&pn544_shdlc_ops,
863+ &init_data, protocols,
864+ PN544_CMDS_HEADROOM, 0,
865+ PN544_HCI_LLC_MAX_PAYLOAD,
866+ dev_name(&client->dev));
867+ if (!info->shdlc) {
868+ dev_err(&client->dev, "Cannot allocate nfc shdlc.\n");
869+ r = -ENOMEM;
870+ goto err_allocshdlc;
871+ }
872+
873+ nfc_shdlc_set_clientdata(info->shdlc, info);
874+
875+ return 0;
876+
877+err_allocshdlc:
878+ free_irq(client->irq, info);
879+
880+err_rti:
881+ if (pdata->free_resources != NULL)
882+ pdata->free_resources();
883+
884+err_pdata:
885+ kfree(info);
886+
887+err_info_alloc:
888+ return r;
889+}
890+
891+static __devexit int pn544_hci_remove(struct i2c_client *client)
892+{
893+ struct pn544_hci_info *info = i2c_get_clientdata(client);
894+ struct pn544_nfc_platform_data *pdata = client->dev.platform_data;
895+
896+ dev_dbg(&client->dev, "%s\n", __func__);
897+
898+ nfc_shdlc_free(info->shdlc);
899+
900+ if (info->state != PN544_ST_COLD) {
901+ if (pdata->disable)
902+ pdata->disable();
903+ }
904+
905+ free_irq(client->irq, info);
906+ if (pdata->free_resources)
907+ pdata->free_resources();
908+
909+ kfree(info);
910+
911+ return 0;
912+}
913+
914+static struct i2c_driver pn544_hci_driver = {
915+ .driver = {
916+ .name = PN544_HCI_DRIVER_NAME,
917+ },
918+ .probe = pn544_hci_probe,
919+ .id_table = pn544_hci_id_table,
920+ .remove = __devexit_p(pn544_hci_remove),
921+};
922+
923+static int __init pn544_hci_init(void)
924+{
925+ int r;
926+
927+ pr_debug(DRIVER_DESC ": %s\n", __func__);
928+
929+ r = i2c_add_driver(&pn544_hci_driver);
930+ if (r) {
931+ pr_err(PN544_HCI_DRIVER_NAME ": driver registration failed\n");
932+ return r;
933+ }
934+
935+ return 0;
936+}
937+
938+static void __exit pn544_hci_exit(void)
939+{
940+ i2c_del_driver(&pn544_hci_driver);
941+}
942+
943+module_init(pn544_hci_init);
944+module_exit(pn544_hci_exit);
945+
946+MODULE_LICENSE("GPL");
947+MODULE_DESCRIPTION(DRIVER_DESC);
drivers/ssb/b43_pci_bridge.c+2−0
@@ -29,6 +29,8 @@ static const struct pci_device_id b43_pci_bridge_tbl[] = { · 28 unmodified lines
2929 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4319) },
3030 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4320) },
3131 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4321) },
32+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4322) },
33+ { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43222) },
3234 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4324) },
3335 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4325) },
3436 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4328) },
drivers/ssb/pci.c+82−6
@@ -178,6 +178,18 @@ err_pci: · 177 unmodified lines
178178 #define SPEX(_outvar, _offset, _mask, _shift) \
179179 SPEX16(_outvar, _offset, _mask, _shift)
180180
181+#define SPEX_ARRAY8(_field, _offset, _mask, _shift) \
182+ do { \
183+ SPEX(_field[0], _offset + 0, _mask, _shift); \
184+ SPEX(_field[1], _offset + 2, _mask, _shift); \
185+ SPEX(_field[2], _offset + 4, _mask, _shift); \
186+ SPEX(_field[3], _offset + 6, _mask, _shift); \
187+ SPEX(_field[4], _offset + 8, _mask, _shift); \
188+ SPEX(_field[5], _offset + 10, _mask, _shift); \
189+ SPEX(_field[6], _offset + 12, _mask, _shift); \
190+ SPEX(_field[7], _offset + 14, _mask, _shift); \
191+ } while (0)
192+
181193
182194 static inline u8 ssb_crc8(u8 crc, u8 data)
183195 {
@@ -360,8 +372,9 @@ static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in) · 176 unmodified lines
360372 SPEX(et0mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0M, 14);
361373 SPEX(et1mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1M, 15);
362374 SPEX(board_rev, SSB_SPROM1_BINF, SSB_SPROM1_BINF_BREV, 0);
363− SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,
364− SSB_SPROM1_BINF_CCODE_SHIFT);
375+ if (out->revision == 1)
376+ SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,
377+ SSB_SPROM1_BINF_CCODE_SHIFT);
365378 SPEX(ant_available_a, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTA,
366379 SSB_SPROM1_BINF_ANTA_SHIFT);
367380 SPEX(ant_available_bg, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTBG,
@@ -387,6 +400,8 @@ static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in) · 19 unmodified lines
387400 SPEX(boardflags_lo, SSB_SPROM1_BFLLO, 0xFFFF, 0);
388401 if (out->revision >= 2)
389402 SPEX(boardflags_hi, SSB_SPROM2_BFLHI, 0xFFFF, 0);
403+ SPEX(alpha2[0], SSB_SPROM1_CCODE, 0xff00, 8);
404+ SPEX(alpha2[1], SSB_SPROM1_CCODE, 0x00ff, 0);
390405
391406 /* Extract the antenna gain values. */
392407 out->antenna_gain.a0 = r123_extract_antgain(out->revision, in,
@@ -455,14 +470,17 @@ static void sprom_extract_r45(struct ssb_sprom *out, const u16 *in) · 62 unmodified lines
455470 SPEX(et0phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET0A, 0);
456471 SPEX(et1phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET1A,
457472 SSB_SPROM4_ETHPHY_ET1A_SHIFT);
473+ SPEX(board_rev, SSB_SPROM4_BOARDREV, 0xFFFF, 0);
458474 if (out->revision == 4) {
459− SPEX(country_code, SSB_SPROM4_CCODE, 0xFFFF, 0);
475+ SPEX(alpha2[0], SSB_SPROM4_CCODE, 0xff00, 8);
476+ SPEX(alpha2[1], SSB_SPROM4_CCODE, 0x00ff, 0);
460477 SPEX(boardflags_lo, SSB_SPROM4_BFLLO, 0xFFFF, 0);
461478 SPEX(boardflags_hi, SSB_SPROM4_BFLHI, 0xFFFF, 0);
462479 SPEX(boardflags2_lo, SSB_SPROM4_BFL2LO, 0xFFFF, 0);
463480 SPEX(boardflags2_hi, SSB_SPROM4_BFL2HI, 0xFFFF, 0);
464481 } else {
465− SPEX(country_code, SSB_SPROM5_CCODE, 0xFFFF, 0);
482+ SPEX(alpha2[0], SSB_SPROM5_CCODE, 0xff00, 8);
483+ SPEX(alpha2[1], SSB_SPROM5_CCODE, 0x00ff, 0);
466484 SPEX(boardflags_lo, SSB_SPROM5_BFLLO, 0xFFFF, 0);
467485 SPEX(boardflags_hi, SSB_SPROM5_BFLHI, 0xFFFF, 0);
468486 SPEX(boardflags2_lo, SSB_SPROM5_BFL2LO, 0xFFFF, 0);
@@ -525,7 +543,9 @@ static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in) · 56 unmodified lines
525543 v = in[SPOFF(SSB_SPROM8_IL0MAC) + i];
526544 *(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
527545 }
528− SPEX(country_code, SSB_SPROM8_CCODE, 0xFFFF, 0);
546+ SPEX(board_rev, SSB_SPROM8_BOARDREV, 0xFFFF, 0);
547+ SPEX(alpha2[0], SSB_SPROM8_CCODE, 0xff00, 8);
548+ SPEX(alpha2[1], SSB_SPROM8_CCODE, 0x00ff, 0);
529549 SPEX(boardflags_lo, SSB_SPROM8_BFLLO, 0xFFFF, 0);
530550 SPEX(boardflags_hi, SSB_SPROM8_BFLHI, 0xFFFF, 0);
531551 SPEX(boardflags2_lo, SSB_SPROM8_BFL2LO, 0xFFFF, 0);
@@ -655,6 +675,63 @@ static void sprom_extract_r8(struct ssb_sprom *out, const u16 *in) · 123 unmodified lines
655675 SPEX(fem.ghz5.antswlut, SSB_SPROM8_FEM5G,
656676 SSB_SROM8_FEM_ANTSWLUT, SSB_SROM8_FEM_ANTSWLUT_SHIFT);
657677
678+ SPEX(leddc_on_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_ON,
679+ SSB_SPROM8_LEDDC_ON_SHIFT);
680+ SPEX(leddc_off_time, SSB_SPROM8_LEDDC, SSB_SPROM8_LEDDC_OFF,
681+ SSB_SPROM8_LEDDC_OFF_SHIFT);
682+
683+ SPEX(txchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_TXCHAIN,
684+ SSB_SPROM8_TXRXC_TXCHAIN_SHIFT);
685+ SPEX(rxchain, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_RXCHAIN,
686+ SSB_SPROM8_TXRXC_RXCHAIN_SHIFT);
687+ SPEX(antswitch, SSB_SPROM8_TXRXC, SSB_SPROM8_TXRXC_SWITCH,
688+ SSB_SPROM8_TXRXC_SWITCH_SHIFT);
689+
690+ SPEX(opo, SSB_SPROM8_OFDM2GPO, 0x00ff, 0);
691+
692+ SPEX_ARRAY8(mcs2gpo, SSB_SPROM8_2G_MCSPO, ~0, 0);
693+ SPEX_ARRAY8(mcs5gpo, SSB_SPROM8_5G_MCSPO, ~0, 0);
694+ SPEX_ARRAY8(mcs5glpo, SSB_SPROM8_5GL_MCSPO, ~0, 0);
695+ SPEX_ARRAY8(mcs5ghpo, SSB_SPROM8_5GH_MCSPO, ~0, 0);
696+
697+ SPEX(rawtempsense, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_RAWTEMP,
698+ SSB_SPROM8_RAWTS_RAWTEMP_SHIFT);
699+ SPEX(measpower, SSB_SPROM8_RAWTS, SSB_SPROM8_RAWTS_MEASPOWER,
700+ SSB_SPROM8_RAWTS_MEASPOWER_SHIFT);
701+ SPEX(tempsense_slope, SSB_SPROM8_OPT_CORRX,
702+ SSB_SPROM8_OPT_CORRX_TEMP_SLOPE,
703+ SSB_SPROM8_OPT_CORRX_TEMP_SLOPE_SHIFT);
704+ SPEX(tempcorrx, SSB_SPROM8_OPT_CORRX, SSB_SPROM8_OPT_CORRX_TEMPCORRX,
705+ SSB_SPROM8_OPT_CORRX_TEMPCORRX_SHIFT);
706+ SPEX(tempsense_option, SSB_SPROM8_OPT_CORRX,
707+ SSB_SPROM8_OPT_CORRX_TEMP_OPTION,
708+ SSB_SPROM8_OPT_CORRX_TEMP_OPTION_SHIFT);
709+ SPEX(freqoffset_corr, SSB_SPROM8_HWIQ_IQSWP,
710+ SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR,
711+ SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR_SHIFT);
712+ SPEX(iqcal_swp_dis, SSB_SPROM8_HWIQ_IQSWP,
713+ SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP,
714+ SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP_SHIFT);
715+ SPEX(hw_iqcal_en, SSB_SPROM8_HWIQ_IQSWP, SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL,
716+ SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL_SHIFT);
717+
718+ SPEX(bw40po, SSB_SPROM8_BW40PO, ~0, 0);
719+ SPEX(cddpo, SSB_SPROM8_CDDPO, ~0, 0);
720+ SPEX(stbcpo, SSB_SPROM8_STBCPO, ~0, 0);
721+ SPEX(bwduppo, SSB_SPROM8_BWDUPPO, ~0, 0);
722+
723+ SPEX(tempthresh, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_TRESH,
724+ SSB_SPROM8_THERMAL_TRESH_SHIFT);
725+ SPEX(tempoffset, SSB_SPROM8_THERMAL, SSB_SPROM8_THERMAL_OFFSET,
726+ SSB_SPROM8_THERMAL_OFFSET_SHIFT);
727+ SPEX(phycal_tempdelta, SSB_SPROM8_TEMPDELTA,
728+ SSB_SPROM8_TEMPDELTA_PHYCAL,
729+ SSB_SPROM8_TEMPDELTA_PHYCAL_SHIFT);
730+ SPEX(temps_period, SSB_SPROM8_TEMPDELTA, SSB_SPROM8_TEMPDELTA_PERIOD,
731+ SSB_SPROM8_TEMPDELTA_PERIOD_SHIFT);
732+ SPEX(temps_hysteresis, SSB_SPROM8_TEMPDELTA,
733+ SSB_SPROM8_TEMPDELTA_HYSTERESIS,
734+ SSB_SPROM8_TEMPDELTA_HYSTERESIS_SHIFT);
658735 sprom_extract_r458(out, in);
659736
660737 /* TODO - get remaining rev 8 stuff needed */
@@ -784,7 +861,6 @@ static void ssb_pci_get_boardinfo(struct ssb_bus *bus, · 123 unmodified lines
784861 {
785862 bi->vendor = bus->host_pci->subsystem_vendor;
786863 bi->type = bus->host_pci->subsystem_device;
787− bi->rev = bus->host_pci->revision;
788864 }
789865
790866 int ssb_pci_get_invariants(struct ssb_bus *bus,
fs/dcache.c+2−0
@@ -3093,6 +3093,7 @@ static void __init dcache_init_early(void) · 3092 unmodified lines
30933093 HASH_EARLY,
30943094 &d_hash_shift,
30953095 &d_hash_mask,
3096+ 0,
30963097 0);
30973098
30983099 for (loop = 0; loop < (1U << d_hash_shift); loop++)
@@ -3123,6 +3124,7 @@ static void __init dcache_init(void) · 24 unmodified lines
31233124 0,
31243125 &d_hash_shift,
31253126 &d_hash_mask,
3127+ 0,
31263128 0);
31273129
31283130 for (loop = 0; loop < (1U << d_hash_shift); loop++)
fs/inode.c+2−0
@@ -1647,6 +1647,7 @@ void __init inode_init_early(void) · 1646 unmodified lines
16471647 HASH_EARLY,
16481648 &i_hash_shift,
16491649 &i_hash_mask,
1650+ 0,
16501651 0);
16511652
16521653 for (loop = 0; loop < (1U << i_hash_shift); loop++)
@@ -1677,6 +1678,7 @@ void __init inode_init(void) · 24 unmodified lines
16771678 0,
16781679 &i_hash_shift,
16791680 &i_hash_mask,
1681+ 0,
16801682 0);
16811683
16821684 for (loop = 0; loop < (1U << i_hash_shift); loop++)
include/linux/Kbuild+1−0
@@ -270,6 +270,7 @@ header-y += netfilter_ipv4.h · 269 unmodified lines
270270 header-y += netfilter_ipv6.h
271271 header-y += netlink.h
272272 header-y += netrom.h
273+header-y += nfc.h
273274 header-y += nfs.h
274275 header-y += nfs2.h
275276 header-y += nfs3.h
include/linux/bcma/bcma.h+7−0
@@ -26,6 +26,11 @@ struct bcma_chipinfo { · 25 unmodified lines
2626 u8 pkg;
2727 };
2828
29+struct bcma_boardinfo {
30+ u16 vendor;
31+ u16 type;
32+};
33+
2934 enum bcma_clkmode {
3035 BCMA_CLKMODE_FAST,
3136 BCMA_CLKMODE_DYNAMIC,
@@ -199,6 +204,8 @@ struct bcma_bus { · 167 unmodified lines
199204
200205 struct bcma_chipinfo chipinfo;
201206
207+ struct bcma_boardinfo boardinfo;
208+
202209 struct bcma_device *mapped_core;
203210 struct list_head cores;
204211 u8 nr_cores;
include/linux/bcma/bcma_driver_pci.h+11−0
@@ -87,6 +87,13 @@ struct pci_dev; · 86 unmodified lines
8787 #define BCMA_CORE_PCI_PCICFG2 0x0600 /* PCI config space 2 (rev >= 8) */
8888 #define BCMA_CORE_PCI_PCICFG3 0x0700 /* PCI config space 3 (rev >= 8) */
8989 #define BCMA_CORE_PCI_SPROM(wordoffset) (0x0800 + ((wordoffset) * 2)) /* SPROM shadow area (72 bytes) */
90+#define BCMA_CORE_PCI_SPROM_PI_OFFSET 0 /* first word */
91+#define BCMA_CORE_PCI_SPROM_PI_MASK 0xf000 /* bit 15:12 */
92+#define BCMA_CORE_PCI_SPROM_PI_SHIFT 12 /* bit 15:12 */
93+#define BCMA_CORE_PCI_SPROM_MISC_CONFIG 5 /* word 5 */
94+#define BCMA_CORE_PCI_SPROM_L23READY_EXIT_NOPERST 0x8000 /* bit 15 */
95+#define BCMA_CORE_PCI_SPROM_CLKREQ_OFFSET_REV5 20 /* word 20 for srom rev <= 5 */
96+#define BCMA_CORE_PCI_SPROM_CLKREQ_ENB 0x0800 /* bit 11 */
9097
9198 /* SBtoPCIx */
9299 #define BCMA_CORE_PCI_SBTOPCI_MEM 0x00000000
@@ -133,6 +140,7 @@ struct pci_dev; · 40 unmodified lines
133140 #define BCMA_CORE_PCI_DLLP_LRREG 0x120 /* Link Replay */
134141 #define BCMA_CORE_PCI_DLLP_LACKTOREG 0x124 /* Link Ack Timeout */
135142 #define BCMA_CORE_PCI_DLLP_PMTHRESHREG 0x128 /* Power Management Threshold */
143+#define BCMA_CORE_PCI_ASPMTIMER_EXTEND 0x01000000 /* > rev7: enable extend ASPM timer */
136144 #define BCMA_CORE_PCI_DLLP_RTRYWPREG 0x12C /* Retry buffer write ptr */
137145 #define BCMA_CORE_PCI_DLLP_RTRYRPREG 0x130 /* Retry buffer Read ptr */
138146 #define BCMA_CORE_PCI_DLLP_RTRYPPREG 0x134 /* Retry buffer Purged ptr */
@@ -201,12 +209,15 @@ struct bcma_drv_pci { · 62 unmodified lines
201209 };
202210
203211 /* Register access */
212+#define pcicore_read16(pc, offset) bcma_read16((pc)->core, offset)
204213 #define pcicore_read32(pc, offset) bcma_read32((pc)->core, offset)
214+#define pcicore_write16(pc, offset, val) bcma_write16((pc)->core, offset, val)
205215 #define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val)
206216
207217 extern void __devinit bcma_core_pci_init(struct bcma_drv_pci *pc);
208218 extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
209219 struct bcma_device *core, bool enable);
220+extern void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend);
210221
211222 extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
212223 extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
include/linux/bootmem.h+2−1
@@ -154,7 +154,8 @@ extern void *alloc_large_system_hash(const char *tablename, · 153 unmodified lines
154154 int flags,
155155 unsigned int *_hash_shift,
156156 unsigned int *_hash_mask,
157− unsigned long limit);
157+ unsigned long low_limit,
158+ unsigned long high_limit);
158159
159160 #define HASH_EARLY 0x00000001 /* Allocating during early boot? */
160161 #define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min
include/linux/if_arp.h+1−1
@@ -82,7 +82,7 @@ · 81 unmodified lines
8282 #define ARPHRD_FCPL 786 /* Fibrechannel public loop */
8383 #define ARPHRD_FCFABRIC 787 /* Fibrechannel fabric */
8484 /* 787->799 reserved for fibrechannel media types */
85−/* 800 used to be used for token ring */
85+#define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR */
8686 #define ARPHRD_IEEE80211 801 /* IEEE 802.11 */
8787 #define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header */
8888 #define ARPHRD_IEEE80211_RADIOTAP 803 /* IEEE 802.11 + radiotap header */
include/linux/ipx.h+1−1
@@ -38,7 +38,7 @@ struct ipx_interface_definition { · 37 unmodified lines
3838 #define IPX_FRAME_8022 2
3939 #define IPX_FRAME_ETHERII 3
4040 #define IPX_FRAME_8023 4
41−/* obsolete token ring was 5 */
41+#define IPX_FRAME_TR_8022 5 /* obsolete */
4242 unsigned char ipx_special;
4343 #define IPX_SPECIAL_NONE 0
4444 #define IPX_PRIMARY 1
include/linux/micrel_phy.h+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
33
44 #define MICREL_PHY_ID_MASK 0x00fffff0
55
6−#define PHY_ID_KSZ9021 0x00221611
6+#define PHY_ID_KSZ9021 0x00221610
77 #define PHY_ID_KS8737 0x00221720
88 #define PHY_ID_KS8041 0x00221510
99 #define PHY_ID_KS8051 0x00221550
include/linux/nfc/pn544.h+7−0
@@ -84,6 +84,12 @@ struct pn544_fw_packet { · 83 unmodified lines
8484 };
8585
8686 #ifdef __KERNEL__
87+enum {
88+ NFC_GPIO_ENABLE,
89+ NFC_GPIO_FW_RESET,
90+ NFC_GPIO_IRQ
91+};
92+
8793 /* board config */
8894 struct pn544_nfc_platform_data {
8995 int (*request_resources) (struct i2c_client *client);
@@ -91,6 +97,7 @@ struct pn544_nfc_platform_data { · 1 unmodified line
9197 void (*enable) (int fw);
9298 int (*test) (void);
9399 void (*disable) (void);
100+ int (*get_gpio)(int type);
94101 };
95102 #endif /* __KERNEL__ */
96103
include/linux/nl80211.h+5−3
@@ -1594,6 +1594,8 @@ enum nl80211_sta_flags { · 1593 unmodified lines
15941594 NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
15951595 };
15961596
1597+#define NL80211_STA_FLAG_MAX_OLD_API NL80211_STA_FLAG_TDLS_PEER
1598+
15971599 /**
15981600 * struct nl80211_sta_flag_update - station flags mask/set
15991601 * @mask: mask of station flags to set
@@ -1994,9 +1996,9 @@ enum nl80211_reg_rule_flags { · 394 unmodified lines
19941996 * enum nl80211_dfs_regions - regulatory DFS regions
19951997 *
19961998 * @NL80211_DFS_UNSET: Country has no DFS master region specified
1997− * @NL80211_DFS_FCC_: Country follows DFS master rules from FCC
1998− * @NL80211_DFS_FCC_: Country follows DFS master rules from ETSI
1999− * @NL80211_DFS_JP_: Country follows DFS master rules from JP/MKK/Telec
1999+ * @NL80211_DFS_FCC: Country follows DFS master rules from FCC
2000+ * @NL80211_DFS_ETSI: Country follows DFS master rules from ETSI
2001+ * @NL80211_DFS_JP: Country follows DFS master rules from JP/MKK/Telec
20002002 */
20012003 enum nl80211_dfs_regions {
20022004 NL80211_DFS_UNSET = 0,
include/linux/ssb/ssb.h+0−1
@@ -188,7 +188,6 @@ struct ssb_sprom { · 187 unmodified lines
188188 struct ssb_boardinfo {
189189 u16 vendor;
190190 u16 type;
191− u8 rev;
192191 };
193192
194193
include/linux/ssb/ssb_regs.h+57−4
@@ -228,6 +228,7 @@ · 227 unmodified lines
228228 #define SSB_SPROM1_AGAIN_BG_SHIFT 0
229229 #define SSB_SPROM1_AGAIN_A 0xFF00 /* A-PHY */
230230 #define SSB_SPROM1_AGAIN_A_SHIFT 8
231+#define SSB_SPROM1_CCODE 0x0076
231232
232233 /* SPROM Revision 2 (inherits from rev 1) */
233234 #define SSB_SPROM2_BFLHI 0x0038 /* Boardflags (high 16 bits) */
@@ -267,6 +268,7 @@ · 33 unmodified lines
267268 #define SSB_SPROM3_OFDMGPO 0x107A /* G-PHY OFDM Power Offset (4 bytes, BigEndian) */
268269
269270 /* SPROM Revision 4 */
271+#define SSB_SPROM4_BOARDREV 0x0042 /* Board revision */
270272 #define SSB_SPROM4_BFLLO 0x0044 /* Boardflags (low 16 bits) */
271273 #define SSB_SPROM4_BFLHI 0x0046 /* Board Flags Hi */
272274 #define SSB_SPROM4_BFL2LO 0x0048 /* Board flags 2 (low 16 bits) */
@@ -389,6 +391,11 @@ · 116 unmodified lines
389391 #define SSB_SPROM8_GPIOB_P2 0x00FF /* Pin 2 */
390392 #define SSB_SPROM8_GPIOB_P3 0xFF00 /* Pin 3 */
391393 #define SSB_SPROM8_GPIOB_P3_SHIFT 8
394+#define SSB_SPROM8_LEDDC 0x009A
395+#define SSB_SPROM8_LEDDC_ON 0xFF00 /* oncount */
396+#define SSB_SPROM8_LEDDC_ON_SHIFT 8
397+#define SSB_SPROM8_LEDDC_OFF 0x00FF /* offcount */
398+#define SSB_SPROM8_LEDDC_OFF_SHIFT 0
392399 #define SSB_SPROM8_ANTAVAIL 0x009C /* Antenna available bitfields*/
393400 #define SSB_SPROM8_ANTAVAIL_A 0xFF00 /* A-PHY bitfield */
394401 #define SSB_SPROM8_ANTAVAIL_A_SHIFT 8
@@ -404,6 +411,13 @@ · 9 unmodified lines
404411 #define SSB_SPROM8_AGAIN2_SHIFT 0
405412 #define SSB_SPROM8_AGAIN3 0xFF00 /* Antenna 3 */
406413 #define SSB_SPROM8_AGAIN3_SHIFT 8
414+#define SSB_SPROM8_TXRXC 0x00A2
415+#define SSB_SPROM8_TXRXC_TXCHAIN 0x000f
416+#define SSB_SPROM8_TXRXC_TXCHAIN_SHIFT 0
417+#define SSB_SPROM8_TXRXC_RXCHAIN 0x00f0
418+#define SSB_SPROM8_TXRXC_RXCHAIN_SHIFT 4
419+#define SSB_SPROM8_TXRXC_SWITCH 0xff00
420+#define SSB_SPROM8_TXRXC_SWITCH_SHIFT 8
407421 #define SSB_SPROM8_RSSIPARM2G 0x00A4 /* RSSI params for 2GHz */
408422 #define SSB_SPROM8_RSSISMF2G 0x000F
409423 #define SSB_SPROM8_RSSISMC2G 0x00F0
@@ -430,6 +444,7 @@ · 20 unmodified lines
430444 #define SSB_SPROM8_TRI5GH_SHIFT 8
431445 #define SSB_SPROM8_RXPO 0x00AC /* RX power offsets */
432446 #define SSB_SPROM8_RXPO2G 0x00FF /* 2GHz RX power offset */
447+#define SSB_SPROM8_RXPO2G_SHIFT 0
433448 #define SSB_SPROM8_RXPO5G 0xFF00 /* 5GHz RX power offset */
434449 #define SSB_SPROM8_RXPO5G_SHIFT 8
435450 #define SSB_SPROM8_FEM2G 0x00AE
@@ -445,10 +460,38 @@ · 9 unmodified lines
445460 #define SSB_SROM8_FEM_ANTSWLUT 0xF800
446461 #define SSB_SROM8_FEM_ANTSWLUT_SHIFT 11
447462 #define SSB_SPROM8_THERMAL 0x00B2
448−#define SSB_SPROM8_MPWR_RAWTS 0x00B4
449−#define SSB_SPROM8_TS_SLP_OPT_CORRX 0x00B6
450−#define SSB_SPROM8_FOC_HWIQ_IQSWP 0x00B8
451−#define SSB_SPROM8_PHYCAL_TEMPDELTA 0x00BA
463+#define SSB_SPROM8_THERMAL_OFFSET 0x00ff
464+#define SSB_SPROM8_THERMAL_OFFSET_SHIFT 0
465+#define SSB_SPROM8_THERMAL_TRESH 0xff00
466+#define SSB_SPROM8_THERMAL_TRESH_SHIFT 8
467+/* Temp sense related entries */
468+#define SSB_SPROM8_RAWTS 0x00B4
469+#define SSB_SPROM8_RAWTS_RAWTEMP 0x01ff
470+#define SSB_SPROM8_RAWTS_RAWTEMP_SHIFT 0
471+#define SSB_SPROM8_RAWTS_MEASPOWER 0xfe00
472+#define SSB_SPROM8_RAWTS_MEASPOWER_SHIFT 9
473+#define SSB_SPROM8_OPT_CORRX 0x00B6
474+#define SSB_SPROM8_OPT_CORRX_TEMP_SLOPE 0x00ff
475+#define SSB_SPROM8_OPT_CORRX_TEMP_SLOPE_SHIFT 0
476+#define SSB_SPROM8_OPT_CORRX_TEMPCORRX 0xfc00
477+#define SSB_SPROM8_OPT_CORRX_TEMPCORRX_SHIFT 10
478+#define SSB_SPROM8_OPT_CORRX_TEMP_OPTION 0x0300
479+#define SSB_SPROM8_OPT_CORRX_TEMP_OPTION_SHIFT 8
480+/* FOC: freiquency offset correction, HWIQ: H/W IOCAL enable, IQSWP: IQ CAL swap disable */
481+#define SSB_SPROM8_HWIQ_IQSWP 0x00B8
482+#define SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR 0x000f
483+#define SSB_SPROM8_HWIQ_IQSWP_FREQ_CORR_SHIFT 0
484+#define SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP 0x0010
485+#define SSB_SPROM8_HWIQ_IQSWP_IQCAL_SWP_SHIFT 4
486+#define SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL 0x0020
487+#define SSB_SPROM8_HWIQ_IQSWP_HW_IQCAL_SHIFT 5
488+#define SSB_SPROM8_TEMPDELTA 0x00BA
489+#define SSB_SPROM8_TEMPDELTA_PHYCAL 0x00ff
490+#define SSB_SPROM8_TEMPDELTA_PHYCAL_SHIFT 0
491+#define SSB_SPROM8_TEMPDELTA_PERIOD 0x0f00
492+#define SSB_SPROM8_TEMPDELTA_PERIOD_SHIFT 8
493+#define SSB_SPROM8_TEMPDELTA_HYSTERESIS 0xf000
494+#define SSB_SPROM8_TEMPDELTA_HYSTERESIS_SHIFT 12
452495
453496 /* There are 4 blocks with power info sharing the same layout */
454497 #define SSB_SROM8_PWR_INFO_CORE0 0x00C0
@@ -513,6 +556,16 @@ · 58 unmodified lines
513556 #define SSB_SPROM8_OFDM5GLPO 0x014A /* 5.2GHz OFDM power offset */
514557 #define SSB_SPROM8_OFDM5GHPO 0x014E /* 5.8GHz OFDM power offset */
515558
559+#define SSB_SPROM8_2G_MCSPO 0x0152
560+#define SSB_SPROM8_5G_MCSPO 0x0162
561+#define SSB_SPROM8_5GL_MCSPO 0x0172
562+#define SSB_SPROM8_5GH_MCSPO 0x0182
563+
564+#define SSB_SPROM8_CDDPO 0x0192
565+#define SSB_SPROM8_STBCPO 0x0194
566+#define SSB_SPROM8_BW40PO 0x0196
567+#define SSB_SPROM8_BWDUPPO 0x0198
568+
516569 /* Values for boardflags_lo read from SPROM */
517570 #define SSB_BFL_BTCOEXIST 0x0001 /* implements Bluetooth coexistance */
518571 #define SSB_BFL_PACTRL 0x0002 /* GPIO 9 controlling the PA */
include/net/bluetooth/bluetooth.h+24−8
@@ -163,6 +163,11 @@ typedef struct { · 162 unmodified lines
163163 __u8 b[6];
164164 } __packed bdaddr_t;
165165
166+/* BD Address type */
167+#define BDADDR_BREDR 0x00
168+#define BDADDR_LE_PUBLIC 0x01
169+#define BDADDR_LE_RANDOM 0x02
170+
166171 #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}})
167172 #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}})
168173
@@ -178,7 +183,6 @@ static inline void bacpy(bdaddr_t *dst, bdaddr_t *src) · 9 unmodified lines
178183
179184 void baswap(bdaddr_t *dst, bdaddr_t *src);
180185 char *batostr(bdaddr_t *ba);
181−bdaddr_t *strtoba(char *str);
182186
183187 /* Common socket structures and functions */
184188
@@ -190,8 +194,12 @@ struct bt_sock { · 5 unmodified lines
190194 bdaddr_t dst;
191195 struct list_head accept_q;
192196 struct sock *parent;
193− u32 defer_setup;
194− bool suspended;
197+ unsigned long flags;
198+};
199+
200+enum {
201+ BT_SK_DEFER_SETUP,
202+ BT_SK_SUSPEND,
195203 };
196204
197205 struct bt_sock_list {
@@ -216,14 +224,24 @@ void bt_accept_unlink(struct sock *sk); · 18 unmodified lines
216224 struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock);
217225
218226 /* Skb helpers */
227+struct l2cap_ctrl {
228+ unsigned int sframe : 1,
229+ poll : 1,
230+ final : 1,
231+ fcs : 1,
232+ sar : 2,
233+ super : 2;
234+ __u16 reqseq;
235+ __u16 txseq;
236+ __u8 retries;
237+};
238+
219239 struct bt_skb_cb {
220240 __u8 pkt_type;
221241 __u8 incoming;
222242 __u16 expect;
223− __u16 tx_seq;
224− __u8 retries;
225− __u8 sar;
226243 __u8 force_active;
244+ struct l2cap_ctrl control;
227245 };
228246 #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
229247
@@ -243,12 +261,10 @@ static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, · 13 unmodified lines
243261 {
244262 struct sk_buff *skb;
245263
246− release_sock(sk);
247264 if ((skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err))) {
248265 skb_reserve(skb, BT_SKB_RESERVE);
249266 bt_cb(skb)->incoming = 0;
250267 }
251− lock_sock(sk);
252268
253269 if (!skb && *err)
254270 return NULL;
include/net/bluetooth/hci.h+7−1
@@ -102,6 +102,7 @@ enum { · 101 unmodified lines
102102 HCI_DISCOVERABLE,
103103 HCI_LINK_SECURITY,
104104 HCI_PENDING_CLASS,
105+ HCI_PERIODIC_INQ,
105106 };
106107
107108 /* HCI ioctl defines */
@@ -324,6 +325,8 @@ struct hci_cp_inquiry { · 216 unmodified lines
324325
325326 #define HCI_OP_INQUIRY_CANCEL 0x0402
326327
328+#define HCI_OP_PERIODIC_INQ 0x0403
329+
327330 #define HCI_OP_EXIT_PERIODIC_INQ 0x0404
328331
329332 #define HCI_OP_CREATE_CONN 0x0405
@@ -717,6 +720,10 @@ struct hci_rp_read_local_oob_data { · 387 unmodified lines
717720 } __packed;
718721
719722 #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
723+struct hci_rp_read_inq_rsp_tx_power {
724+ __u8 status;
725+ __s8 tx_power;
726+} __packed;
720727
721728 #define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66
722729 struct hci_rp_read_flow_control_mode {
@@ -1431,6 +1438,5 @@ struct hci_inquiry_req { · 708 unmodified lines
14311438 #define IREQ_CACHE_FLUSH 0x0001
14321439
14331440 extern bool enable_hs;
1434−extern bool enable_le;
14351441
14361442 #endif /* __HCI_H */
include/net/bluetooth/hci_core.h+36−31
@@ -155,9 +155,14 @@ struct hci_dev { · 154 unmodified lines
155155 __u16 hci_rev;
156156 __u8 lmp_ver;
157157 __u16 manufacturer;
158− __le16 lmp_subver;
158+ __u16 lmp_subver;
159159 __u16 voice_setting;
160160 __u8 io_capability;
161+ __s8 inq_tx_power;
162+ __u16 devid_source;
163+ __u16 devid_vendor;
164+ __u16 devid_product;
165+ __u16 devid_version;
161166
162167 __u16 pkt_type;
163168 __u16 esco_type;
@@ -250,9 +255,6 @@ struct hci_dev { · 86 unmodified lines
250255
251256 struct list_head remote_oob_data;
252257
253− struct list_head adv_entries;
254− struct delayed_work adv_work;
255−
256258 struct hci_dev_stats stat;
257259
258260 struct sk_buff_head driver_init;
@@ -263,7 +265,6 @@ struct hci_dev { · 4 unmodified lines
263265
264266 struct dentry *debugfs;
265267
266− struct device *parent;
267268 struct device dev;
268269
269270 struct rfkill *rfkill;
@@ -571,7 +572,7 @@ int hci_chan_del(struct hci_chan *chan); · 301 unmodified lines
571572 void hci_chan_list_flush(struct hci_conn *conn);
572573
573574 struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
574− __u8 sec_level, __u8 auth_type);
575+ __u8 dst_type, __u8 sec_level, __u8 auth_type);
575576 int hci_conn_check_link_mode(struct hci_conn *conn);
576577 int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level);
577578 int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type);
@@ -673,8 +674,8 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, · 95 unmodified lines
673674 bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len);
674675 struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]);
675676 int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
676− int new_key, u8 authenticated, u8 tk[16], u8 enc_size, u16 ediv,
677− u8 rand[8]);
677+ int new_key, u8 authenticated, u8 tk[16], u8 enc_size,
678+ __le16 ediv, u8 rand[8]);
678679 struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr,
679680 u8 addr_type);
680681 int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr);
@@ -688,14 +689,6 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, · 7 unmodified lines
688689 u8 *randomizer);
689690 int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
690691
691−#define ADV_CLEAR_TIMEOUT (3*60*HZ) /* Three minutes */
692−int hci_adv_entries_clear(struct hci_dev *hdev);
693−struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr);
694−int hci_add_adv_entry(struct hci_dev *hdev,
695− struct hci_ev_le_advertising_info *ev);
696−
697−void hci_del_off_timer(struct hci_dev *hdev);
698−
699692 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
700693
701694 int hci_recv_frame(struct sk_buff *skb);
@@ -709,7 +702,7 @@ void hci_conn_init_sysfs(struct hci_conn *conn); · 7 unmodified lines
709702 void hci_conn_add_sysfs(struct hci_conn *conn);
710703 void hci_conn_del_sysfs(struct hci_conn *conn);
711704
712−#define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->parent = (pdev))
705+#define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev))
713706
714707 /* ----- LMP capabilities ----- */
715708 #define lmp_rswitch_capable(dev) ((dev)->features[0] & LMP_RSWITCH)
@@ -933,6 +926,23 @@ static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) · 217 unmodified lines
933926 return false;
934927 }
935928
929+static inline size_t eir_get_length(u8 *eir, size_t eir_len)
930+{
931+ size_t parsed = 0;
932+
933+ while (parsed < eir_len) {
934+ u8 field_len = eir[0];
935+
936+ if (field_len == 0)
937+ return parsed;
938+
939+ parsed += field_len + 1;
940+ eir += field_len + 1;
941+ }
942+
943+ return eir_len;
944+}
945+
936946 static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data,
937947 u8 data_len)
938948 {
@@ -961,17 +971,12 @@ void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb); · 22 unmodified lines
961971 void hci_sock_dev_event(struct hci_dev *hdev, int event);
962972
963973 /* Management interface */
964−#define MGMT_ADDR_BREDR 0x00
965−#define MGMT_ADDR_LE_PUBLIC 0x01
966−#define MGMT_ADDR_LE_RANDOM 0x02
967−#define MGMT_ADDR_INVALID 0xff
968−
969−#define DISCOV_TYPE_BREDR (BIT(MGMT_ADDR_BREDR))
970−#define DISCOV_TYPE_LE (BIT(MGMT_ADDR_LE_PUBLIC) | \
971− BIT(MGMT_ADDR_LE_RANDOM))
972−#define DISCOV_TYPE_INTERLEAVED (BIT(MGMT_ADDR_BREDR) | \
973− BIT(MGMT_ADDR_LE_PUBLIC) | \
974− BIT(MGMT_ADDR_LE_RANDOM))
974+#define DISCOV_TYPE_BREDR (BIT(BDADDR_BREDR))
975+#define DISCOV_TYPE_LE (BIT(BDADDR_LE_PUBLIC) | \
976+ BIT(BDADDR_LE_RANDOM))
977+#define DISCOV_TYPE_INTERLEAVED (BIT(BDADDR_BREDR) | \
978+ BIT(BDADDR_LE_PUBLIC) | \
979+ BIT(BDADDR_LE_RANDOM))
975980
976981 int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len);
977982 int mgmt_index_added(struct hci_dev *hdev);
@@ -1067,12 +1072,12 @@ void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, · 89 unmodified lines
10671072 u16 latency, u16 to_multiplier);
10681073 void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
10691074 __u8 ltk[16]);
1070−void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]);
1071−void hci_le_ltk_neg_reply(struct hci_conn *conn);
1072−
10731075 int hci_do_inquiry(struct hci_dev *hdev, u8 length);
10741076 int hci_cancel_inquiry(struct hci_dev *hdev);
10751077 int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window,
10761078 int timeout);
1079+int hci_cancel_le_scan(struct hci_dev *hdev);
1080+
1081+u8 bdaddr_to_le(u8 bdaddr_type);
10771082
10781083 #endif /* __HCI_CORE_H */
include/net/bluetooth/l2cap.h+79−14
@@ -44,6 +44,7 @@ · 43 unmodified lines
4444 #define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF
4545 #define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF
4646 #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF
47+#define L2CAP_BREDR_MAX_PAYLOAD 1019 /* 3-DH5 packet */
4748
4849 #define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100)
4950 #define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000)
@@ -57,6 +58,7 @@ struct sockaddr_l2 { · 7 unmodified lines
5758 __le16 l2_psm;
5859 bdaddr_t l2_bdaddr;
5960 __le16 l2_cid;
61+ __u8 l2_bdaddr_type;
6062 };
6163
6264 /* L2CAP socket options */
@@ -139,6 +141,8 @@ struct l2cap_conninfo { · 76 unmodified lines
139141
140142 #define L2CAP_CTRL_TXSEQ_SHIFT 1
141143 #define L2CAP_CTRL_SUPER_SHIFT 2
144+#define L2CAP_CTRL_POLL_SHIFT 4
145+#define L2CAP_CTRL_FINAL_SHIFT 7
142146 #define L2CAP_CTRL_REQSEQ_SHIFT 8
143147 #define L2CAP_CTRL_SAR_SHIFT 14
144148
@@ -152,9 +156,11 @@ struct l2cap_conninfo { · 7 unmodified lines
152156 #define L2CAP_EXT_CTRL_FINAL 0x00000002
153157 #define L2CAP_EXT_CTRL_FRAME_TYPE 0x00000001 /* I- or S-Frame */
154158
159+#define L2CAP_EXT_CTRL_FINAL_SHIFT 1
155160 #define L2CAP_EXT_CTRL_REQSEQ_SHIFT 2
156161 #define L2CAP_EXT_CTRL_SAR_SHIFT 16
157162 #define L2CAP_EXT_CTRL_SUPER_SHIFT 16
163+#define L2CAP_EXT_CTRL_POLL_SHIFT 18
158164 #define L2CAP_EXT_CTRL_TXSEQ_SHIFT 18
159165
160166 /* L2CAP Supervisory Function */
@@ -186,6 +192,8 @@ struct l2cap_hdr { · 25 unmodified lines
186192 #define L2CAP_FCS_SIZE 2
187193 #define L2CAP_SDULEN_SIZE 2
188194 #define L2CAP_PSMLEN_SIZE 2
195+#define L2CAP_ENH_CTRL_SIZE 2
196+#define L2CAP_EXT_CTRL_SIZE 4
189197
190198 struct l2cap_cmd_hdr {
191199 __u8 code;
@@ -401,6 +409,16 @@ struct l2cap_conn_param_update_rsp { · 209 unmodified lines
401409 #define L2CAP_CONN_PARAM_REJECTED 0x0001
402410
403411 /* ----- L2CAP channels and connections ----- */
412+struct l2cap_seq_list {
413+ __u16 head;
414+ __u16 tail;
415+ __u16 mask;
416+ __u16 *list;
417+};
418+
419+#define L2CAP_SEQ_LIST_CLEAR 0xFFFF
420+#define L2CAP_SEQ_LIST_TAIL 0x8000
421+
404422 struct srej_list {
405423 __u16 tx_seq;
406424 struct list_head list;
@@ -446,6 +464,9 @@ struct l2cap_chan { · 39 unmodified lines
446464 __u16 monitor_timeout;
447465 __u16 mps;
448466
467+ __u8 tx_state;
468+ __u8 rx_state;
469+
449470 unsigned long conf_state;
450471 unsigned long conn_state;
451472 unsigned long flags;
@@ -456,9 +477,11 @@ struct l2cap_chan { · 4 unmodified lines
456477 __u16 buffer_seq;
457478 __u16 buffer_seq_srej;
458479 __u16 srej_save_reqseq;
480+ __u16 last_acked_seq;
459481 __u16 frames_sent;
460482 __u16 unacked_frames;
461483 __u8 retry_count;
484+ __u16 srej_queue_next;
462485 __u8 num_acked;
463486 __u16 sdu_len;
464487 struct sk_buff *sdu;
@@ -490,6 +513,8 @@ struct l2cap_chan { · 25 unmodified lines
490513 struct sk_buff *tx_send_head;
491514 struct sk_buff_head tx_q;
492515 struct sk_buff_head srej_q;
516+ struct l2cap_seq_list srej_list;
517+ struct l2cap_seq_list retrans_list;
493518 struct list_head srej_l;
494519
495520 struct list_head list;
@@ -508,8 +533,7 @@ struct l2cap_ops { · 12 unmodified lines
508533 void (*close) (void *data);
509534 void (*state_change) (void *data, int state);
510535 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
511− unsigned long len, int nb, int *err);
512−
536+ unsigned long len, int nb);
513537 };
514538
515539 struct l2cap_conn {
@@ -600,6 +624,44 @@ enum { · 84 unmodified lines
600624 FLAG_EFS_ENABLE,
601625 };
602626
627+enum {
628+ L2CAP_TX_STATE_XMIT,
629+ L2CAP_TX_STATE_WAIT_F,
630+};
631+
632+enum {
633+ L2CAP_RX_STATE_RECV,
634+ L2CAP_RX_STATE_SREJ_SENT,
635+};
636+
637+enum {
638+ L2CAP_TXSEQ_EXPECTED,
639+ L2CAP_TXSEQ_EXPECTED_SREJ,
640+ L2CAP_TXSEQ_UNEXPECTED,
641+ L2CAP_TXSEQ_UNEXPECTED_SREJ,
642+ L2CAP_TXSEQ_DUPLICATE,
643+ L2CAP_TXSEQ_DUPLICATE_SREJ,
644+ L2CAP_TXSEQ_INVALID,
645+ L2CAP_TXSEQ_INVALID_IGNORE,
646+};
647+
648+enum {
649+ L2CAP_EV_DATA_REQUEST,
650+ L2CAP_EV_LOCAL_BUSY_DETECTED,
651+ L2CAP_EV_LOCAL_BUSY_CLEAR,
652+ L2CAP_EV_RECV_REQSEQ_AND_FBIT,
653+ L2CAP_EV_RECV_FBIT,
654+ L2CAP_EV_RETRANS_TO,
655+ L2CAP_EV_MONITOR_TO,
656+ L2CAP_EV_EXPLICIT_POLL,
657+ L2CAP_EV_RECV_IFRAME,
658+ L2CAP_EV_RECV_RR,
659+ L2CAP_EV_RECV_REJ,
660+ L2CAP_EV_RECV_RNR,
661+ L2CAP_EV_RECV_SREJ,
662+ L2CAP_EV_RECV_FRAME,
663+};
664+
603665 static inline void l2cap_chan_hold(struct l2cap_chan *c)
604666 {
605667 atomic_inc(&c->refcnt);
@@ -622,21 +684,26 @@ static inline void l2cap_chan_unlock(struct l2cap_chan *chan) · 16 unmodified lines
622684 }
623685
624686 static inline void l2cap_set_timer(struct l2cap_chan *chan,
625− struct delayed_work *work, long timeout)
687+ struct delayed_work *work, long timeout)
626688 {
627689 BT_DBG("chan %p state %s timeout %ld", chan,
628− state_to_string(chan->state), timeout);
690+ state_to_string(chan->state), timeout);
629691
692+ /* If delayed work cancelled do not hold(chan)
693+ since it is already done with previous set_timer */
630694 if (!cancel_delayed_work(work))
631695 l2cap_chan_hold(chan);
696+
632697 schedule_delayed_work(work, timeout);
633698 }
634699
635700 static inline bool l2cap_clear_timer(struct l2cap_chan *chan,
636− struct delayed_work *work)
701+ struct delayed_work *work)
637702 {
638703 bool ret;
639704
705+ /* put(chan) if delayed work cancelled otherwise it
706+ is done in delayed work function */
640707 ret = cancel_delayed_work(work);
641708 if (ret)
642709 l2cap_chan_put(chan);
@@ -658,13 +725,10 @@ static inline bool l2cap_clear_timer(struct l2cap_chan *chan, · 15 unmodified lines
658725
659726 static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2)
660727 {
661− int offset;
662−
663− offset = (seq1 - seq2) % (chan->tx_win_max + 1);
664− if (offset < 0)
665− offset += (chan->tx_win_max + 1);
666−
667− return offset;
728+ if (seq1 >= seq2)
729+ return seq1 - seq2;
730+ else
731+ return chan->tx_win_max + 1 - seq2 + seq1;
668732 }
669733
670734 static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq)
@@ -852,14 +916,15 @@ int __l2cap_wait_ack(struct sock *sk); · 181 unmodified lines
852916 int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
853917 int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid);
854918
855−struct l2cap_chan *l2cap_chan_create(struct sock *sk);
919+struct l2cap_chan *l2cap_chan_create(void);
856920 void l2cap_chan_close(struct l2cap_chan *chan, int reason);
857921 void l2cap_chan_destroy(struct l2cap_chan *chan);
858922 int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
859− bdaddr_t *dst);
923+ bdaddr_t *dst, u8 dst_type);
860924 int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
861925 u32 priority);
862926 void l2cap_chan_busy(struct l2cap_chan *chan, int busy);
863927 int l2cap_chan_check_security(struct l2cap_chan *chan);
928+void l2cap_chan_set_defaults(struct l2cap_chan *chan);
864929
865930 #endif /* __L2CAP_H */
include/net/bluetooth/mgmt.h+9−0
@@ -341,6 +341,15 @@ struct mgmt_cp_unblock_device { · 340 unmodified lines
341341 } __packed;
342342 #define MGMT_UNBLOCK_DEVICE_SIZE MGMT_ADDR_INFO_SIZE
343343
344+#define MGMT_OP_SET_DEVICE_ID 0x0028
345+struct mgmt_cp_set_device_id {
346+ __le16 source;
347+ __le16 vendor;
348+ __le16 product;
349+ __le16 version;
350+} __packed;
351+#define MGMT_SET_DEVICE_ID_SIZE 8
352+
344353 #define MGMT_EV_CMD_COMPLETE 0x0001
345354 struct mgmt_ev_cmd_complete {
346355 __le16 opcode;
include/net/bluetooth/smp.h+1−1
@@ -77,7 +77,7 @@ struct smp_cmd_encrypt_info { · 76 unmodified lines
7777
7878 #define SMP_CMD_MASTER_IDENT 0x07
7979 struct smp_cmd_master_ident {
80− __u16 ediv;
80+ __le16 ediv;
8181 __u8 rand[8];
8282 } __packed;
8383
include/net/cfg80211.h+3−3
@@ -3365,9 +3365,9 @@ void cfg80211_report_obss_beacon(struct wiphy *wiphy, · 3364 unmodified lines
33653365 * @chan: main channel
33663366 * @channel_type: HT mode
33673367 */
3368−int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
3369− struct ieee80211_channel *chan,
3370− enum nl80211_channel_type channel_type);
3368+bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
3369+ struct ieee80211_channel *chan,
3370+ enum nl80211_channel_type channel_type);
33713371
33723372 /*
33733373 * cfg80211_ch_switch_notify - update wdev channel and notify userspace
include/net/mac80211.h+11−1
@@ -667,6 +667,9 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info) · 666 unmodified lines
667667 * @RX_FLAG_SHORT_GI: Short guard interval was used
668668 * @RX_FLAG_NO_SIGNAL_VAL: The signal strength value is not present.
669669 * Valid only for data frames (mainly A-MPDU)
670+ * @RX_FLAG_HT_GF: This frame was received in a HT-greenfield transmission, if
671+ * the driver fills this value it should add %IEEE80211_RADIOTAP_MCS_HAVE_FMT
672+ * to hw.radiotap_mcs_details to advertise that fact
670673 */
671674 enum mac80211_rx_flags {
672675 RX_FLAG_MMIC_ERROR = 1<<0,
@@ -681,6 +684,7 @@ enum mac80211_rx_flags { · 8 unmodified lines
681684 RX_FLAG_40MHZ = 1<<10,
682685 RX_FLAG_SHORT_GI = 1<<11,
683686 RX_FLAG_NO_SIGNAL_VAL = 1<<12,
687+ RX_FLAG_HT_GF = 1<<13,
684688 };
685689
686690 /**
@@ -939,7 +943,7 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif) · 252 unmodified lines
939943 * CCMP key if it requires CCMP encryption of management frames (MFP) to
940944 * be done in software.
941945 * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver
942− * for a CCMP key if space should be prepared for the IV, but the IV
946+ * if space should be prepared for the IV, but the IV
943947 * itself should not be generated. Do not set together with
944948 * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key.
945949 */
@@ -1288,6 +1292,11 @@ enum ieee80211_hw_flags { · 342 unmodified lines
12881292 *
12891293 * @offchannel_tx_hw_queue: HW queue ID to use for offchannel TX
12901294 * (if %IEEE80211_HW_QUEUE_CONTROL is set)
1295+ *
1296+ * @radiotap_mcs_details: lists which MCS information can the HW
1297+ * reports, by default it is set to _MCS, _GI and _BW but doesn't
1298+ * include _FMT. Use %IEEE80211_RADIOTAP_MCS_HAVE_* values, only
1299+ * adding _BW is supported today.
12911300 */
12921301 struct ieee80211_hw {
12931302 struct ieee80211_conf conf;
@@ -1309,6 +1318,7 @@ struct ieee80211_hw { · 15 unmodified lines
13091318 u8 max_rx_aggregation_subframes;
13101319 u8 max_tx_aggregation_subframes;
13111320 u8 offchannel_tx_hw_queue;
1321+ u8 radiotap_mcs_details;
13121322 };
13131323
13141324 /**
include/net/nfc/hci.h+2−4
@@ -39,6 +39,8 @@ struct nfc_hci_ops { · 38 unmodified lines
3939 int (*data_exchange) (struct nfc_hci_dev *hdev,
4040 struct nfc_target *target,
4141 struct sk_buff *skb, struct sk_buff **res_skb);
42+ int (*check_presence)(struct nfc_hci_dev *hdev,
43+ struct nfc_target *target);
4244 };
4345
4446 #define NFC_HCI_MAX_CUSTOM_GATES 15
@@ -82,10 +84,6 @@ struct nfc_hci_dev { · 37 unmodified lines
8284
8385 u8 gate2pipe[NFC_HCI_MAX_GATES];
8486
85− bool poll_started;
86− struct nfc_target *targets;
87− int target_count;
88−
8987 u8 sw_romlib;
9088 u8 sw_patch;
9189 u8 sw_flashlib_major;
include/net/nfc/nfc.h+10−9
@@ -48,26 +48,28 @@ struct nfc_dev; · 47 unmodified lines
4848 typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb,
4949 int err);
5050
51+struct nfc_target;
52+
5153 struct nfc_ops {
5254 int (*dev_up)(struct nfc_dev *dev);
5355 int (*dev_down)(struct nfc_dev *dev);
5456 int (*start_poll)(struct nfc_dev *dev, u32 protocols);
5557 void (*stop_poll)(struct nfc_dev *dev);
56− int (*dep_link_up)(struct nfc_dev *dev, int target_idx, u8 comm_mode,
57− u8 *gb, size_t gb_len);
58+ int (*dep_link_up)(struct nfc_dev *dev, struct nfc_target *target,
59+ u8 comm_mode, u8 *gb, size_t gb_len);
5860 int (*dep_link_down)(struct nfc_dev *dev);
59− int (*activate_target)(struct nfc_dev *dev, u32 target_idx,
61+ int (*activate_target)(struct nfc_dev *dev, struct nfc_target *target,
6062 u32 protocol);
61− void (*deactivate_target)(struct nfc_dev *dev, u32 target_idx);
62− int (*data_exchange)(struct nfc_dev *dev, u32 target_idx,
63+ void (*deactivate_target)(struct nfc_dev *dev,
64+ struct nfc_target *target);
65+ int (*data_exchange)(struct nfc_dev *dev, struct nfc_target *target,
6366 struct sk_buff *skb, data_exchange_cb_t cb,
6467 void *cb_context);
65− int (*check_presence)(struct nfc_dev *dev, u32 target_idx);
68+ int (*check_presence)(struct nfc_dev *dev, struct nfc_target *target);
6669 };
6770
6871 #define NFC_TARGET_IDX_ANY -1
6972 #define NFC_MAX_GT_LEN 48
70−#define NFC_TARGET_IDX_NONE 0xffffffff
7173
7274 struct nfc_target {
7375 u32 idx;
@@ -95,11 +97,10 @@ struct nfc_dev { · 21 unmodified lines
9597 struct nfc_target *targets;
9698 int n_targets;
9799 int targets_generation;
98− spinlock_t targets_lock;
99100 struct device dev;
100101 bool dev_up;
101102 bool polling;
102− u32 activated_target_idx;
103+ struct nfc_target *active_target;
103104 bool dep_link_up;
104105 u32 dep_rf_mode;
105106 struct nfc_genl_data genl_data;
include/net/nfc/shdlc.h+2−0
@@ -35,6 +35,8 @@ struct nfc_shdlc_ops { · 34 unmodified lines
3535 int (*data_exchange) (struct nfc_shdlc *shdlc,
3636 struct nfc_target *target,
3737 struct sk_buff *skb, struct sk_buff **res_skb);
38+ int (*check_presence)(struct nfc_shdlc *shdlc,
39+ struct nfc_target *target);
3840 };
3941
4042 enum shdlc_state {
kernel/pid.c+2−1
@@ -547,7 +547,8 @@ void __init pidhash_init(void) · 546 unmodified lines
547547
548548 pid_hash = alloc_large_system_hash("PID", sizeof(*pid_hash), 0, 18,
549549 HASH_EARLY | HASH_SMALL,
550− &pidhash_shift, NULL, 4096);
550+ &pidhash_shift, NULL,
551+ 0, 4096);
551552 pidhash_size = 1U << pidhash_shift;
552553
553554 for (i = 0; i < pidhash_size; i++)
mm/page_alloc.c+5−2
@@ -5242,9 +5242,10 @@ void *__init alloc_large_system_hash(const char *tablename, · 5241 unmodified lines
52425242 int flags,
52435243 unsigned int *_hash_shift,
52445244 unsigned int *_hash_mask,
5245− unsigned long limit)
5245+ unsigned long low_limit,
5246+ unsigned long high_limit)
52465247 {
5247− unsigned long long max = limit;
5248+ unsigned long long max = high_limit;
52485249 unsigned long log2qty, size;
52495250 void *table = NULL;
52505251
@@ -5282,6 +5283,8 @@ void *__init alloc_large_system_hash(const char *tablename, · 31 unmodified lines
52825283 }
52835284 max = min(max, 0x80000000ULL);
52845285
5286+ if (numentries < low_limit)
5287+ numentries = low_limit;
52855288 if (numentries > max)
52865289 numentries = max;
52875290
net/bluetooth/af_bluetooth.c+4−4
@@ -210,7 +210,7 @@ struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock) · 209 unmodified lines
210210 }
211211
212212 if (sk->sk_state == BT_CONNECTED || !newsock ||
213− bt_sk(parent)->defer_setup) {
213+ test_bit(BT_DEFER_SETUP, &bt_sk(parent)->flags)) {
214214 bt_accept_unlink(sk);
215215 if (newsock)
216216 sock_graft(sk, newsock);
@@ -410,8 +410,8 @@ static inline unsigned int bt_accept_poll(struct sock *parent) · 193 unmodified lines
410410 list_for_each_safe(p, n, &bt_sk(parent)->accept_q) {
411411 sk = (struct sock *) list_entry(p, struct bt_sock, accept_q);
412412 if (sk->sk_state == BT_CONNECTED ||
413− (bt_sk(parent)->defer_setup &&
414− sk->sk_state == BT_CONNECT2))
413+ (test_bit(BT_SK_DEFER_SETUP, &bt_sk(parent)->flags) &&
414+ sk->sk_state == BT_CONNECT2))
415415 return POLLIN | POLLRDNORM;
416416 }
417417
@@ -450,7 +450,7 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock, poll_table *wa · 32 unmodified lines
450450 sk->sk_state == BT_CONFIG)
451451 return mask;
452452
453− if (!bt_sk(sk)->suspended && sock_writeable(sk))
453+ if (!test_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags) && sock_writeable(sk))
454454 mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
455455 else
456456 set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
net/bluetooth/bnep/core.c+1−1
@@ -340,7 +340,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb) · 339 unmodified lines
340340 }
341341
342342 /* Strip 802.1p header */
343− if (ntohs(s->eh.h_proto) == 0x8100) {
343+ if (ntohs(s->eh.h_proto) == ETH_P_8021Q) {
344344 if (!skb_pull(skb, 4))
345345 goto badframe;
346346 s->eh.h_proto = get_unaligned((__be16 *) (skb->data - 2));
net/bluetooth/hci_conn.c+11−45
@@ -223,36 +223,6 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], · 222 unmodified lines
223223 }
224224 EXPORT_SYMBOL(hci_le_start_enc);
225225
226−void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16])
227−{
228− struct hci_dev *hdev = conn->hdev;
229− struct hci_cp_le_ltk_reply cp;
230−
231− BT_DBG("%p", conn);
232−
233− memset(&cp, 0, sizeof(cp));
234−
235− cp.handle = cpu_to_le16(conn->handle);
236− memcpy(cp.ltk, ltk, sizeof(ltk));
237−
238− hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp);
239−}
240−EXPORT_SYMBOL(hci_le_ltk_reply);
241−
242−void hci_le_ltk_neg_reply(struct hci_conn *conn)
243−{
244− struct hci_dev *hdev = conn->hdev;
245− struct hci_cp_le_ltk_neg_reply cp;
246−
247− BT_DBG("%p", conn);
248−
249− memset(&cp, 0, sizeof(cp));
250−
251− cp.handle = cpu_to_le16(conn->handle);
252−
253− hci_send_cmd(hdev, HCI_OP_LE_LTK_NEG_REPLY, sizeof(cp), &cp);
254−}
255−
256226 /* Device _must_ be locked */
257227 void hci_sco_setup(struct hci_conn *conn, __u8 status)
258228 {
@@ -513,7 +483,8 @@ EXPORT_SYMBOL(hci_get_route); · 254 unmodified lines
513483
514484 /* Create SCO, ACL or LE connection.
515485 * Device _must_ be locked */
516−struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type)
486+struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
487+ __u8 dst_type, __u8 sec_level, __u8 auth_type)
517488 {
518489 struct hci_conn *acl;
519490 struct hci_conn *sco;
@@ -522,23 +493,18 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 · 2 unmodified lines
522493 BT_DBG("%s dst %s", hdev->name, batostr(dst));
523494
524495 if (type == LE_LINK) {
525− struct adv_entry *entry;
526−
527496 le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
528− if (le)
529− return ERR_PTR(-EBUSY);
530−
531− entry = hci_find_adv_entry(hdev, dst);
532− if (!entry)
533− return ERR_PTR(-EHOSTUNREACH);
497+ if (!le) {
498+ le = hci_conn_add(hdev, LE_LINK, dst);
499+ if (!le)
500+ return ERR_PTR(-ENOMEM);
534501
535− le = hci_conn_add(hdev, LE_LINK, dst);
536− if (!le)
537− return ERR_PTR(-ENOMEM);
538−
539− le->dst_type = entry->bdaddr_type;
502+ le->dst_type = bdaddr_to_le(dst_type);
503+ hci_le_connect(le);
504+ }
540505
541− hci_le_connect(le);
506+ le->pending_sec_level = sec_level;
507+ le->auth_type = auth_type;
542508
543509 hci_conn_hold(le);
544510
net/bluetooth/hci_core.c+107−160
@@ -83,6 +83,7 @@ void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result) · 82 unmodified lines
8383 */
8484 if (test_bit(HCI_INIT, &hdev->flags) && hdev->init_last_cmd != cmd) {
8585 struct hci_command_hdr *sent = (void *) hdev->sent_cmd->data;
86+ u16 opcode = __le16_to_cpu(sent->opcode);
8687 struct sk_buff *skb;
8788
8889 /* Some CSR based controllers generate a spontaneous
@@ -92,7 +93,7 @@ void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result) · 3 unmodified lines
9293 * command.
9394 */
9495
95− if (cmd != HCI_OP_RESET || sent->opcode == HCI_OP_RESET)
96+ if (cmd != HCI_OP_RESET || opcode == HCI_OP_RESET)
9697 return;
9798
9899 skb = skb_clone(hdev->sent_cmd, GFP_ATOMIC);
@@ -251,6 +252,9 @@ static void amp_init(struct hci_dev *hdev) · 152 unmodified lines
251252
252253 /* Read Local Version */
253254 hci_send_cmd(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL);
255+
256+ /* Read Local AMP Info */
257+ hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL);
254258 }
255259
256260 static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
@@ -384,7 +388,6 @@ void hci_discovery_set_state(struct hci_dev *hdev, int state) · 127 unmodified lines
384388 case DISCOVERY_STOPPED:
385389 if (hdev->discovery.state != DISCOVERY_STARTING)
386390 mgmt_discovering(hdev, 0);
387− hdev->discovery.type = 0;
388391 break;
389392 case DISCOVERY_STARTING:
390393 break;
@@ -1089,32 +1092,6 @@ static const struct rfkill_ops hci_rfkill_ops = { · 698 unmodified lines
10891092 .set_block = hci_rfkill_set_block,
10901093 };
10911094
1092−/* Alloc HCI device */
1093−struct hci_dev *hci_alloc_dev(void)
1094−{
1095− struct hci_dev *hdev;
1096−
1097− hdev = kzalloc(sizeof(struct hci_dev), GFP_KERNEL);
1098− if (!hdev)
1099− return NULL;
1100−
1101− hci_init_sysfs(hdev);
1102− skb_queue_head_init(&hdev->driver_init);
1103−
1104− return hdev;
1105−}
1106−EXPORT_SYMBOL(hci_alloc_dev);
1107−
1108−/* Free HCI device */
1109−void hci_free_dev(struct hci_dev *hdev)
1110−{
1111− skb_queue_purge(&hdev->driver_init);
1112−
1113− /* will free via device release */
1114− put_device(&hdev->dev);
1115−}
1116−EXPORT_SYMBOL(hci_free_dev);
1117−
11181095 static void hci_power_on(struct work_struct *work)
11191096 {
11201097 struct hci_dev *hdev = container_of(work, struct hci_dev, power_on);
@@ -1336,7 +1313,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, · 215 unmodified lines
13361313 }
13371314
13381315 int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
1339− int new_key, u8 authenticated, u8 tk[16], u8 enc_size, u16
1316+ int new_key, u8 authenticated, u8 tk[16], u8 enc_size, __le16
13401317 ediv, u8 rand[8])
13411318 {
13421319 struct smp_ltk *key, *old_key;
@@ -1544,75 +1521,6 @@ int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) · 201 unmodified lines
15441521 return mgmt_device_unblocked(hdev, bdaddr, type);
15451522 }
15461523
1547−static void hci_clear_adv_cache(struct work_struct *work)
1548−{
1549− struct hci_dev *hdev = container_of(work, struct hci_dev,
1550− adv_work.work);
1551−
1552− hci_dev_lock(hdev);
1553−
1554− hci_adv_entries_clear(hdev);
1555−
1556− hci_dev_unlock(hdev);
1557−}
1558−
1559−int hci_adv_entries_clear(struct hci_dev *hdev)
1560−{
1561− struct adv_entry *entry, *tmp;
1562−
1563− list_for_each_entry_safe(entry, tmp, &hdev->adv_entries, list) {
1564− list_del(&entry->list);
1565− kfree(entry);
1566− }
1567−
1568− BT_DBG("%s adv cache cleared", hdev->name);
1569−
1570− return 0;
1571−}
1572−
1573−struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr)
1574−{
1575− struct adv_entry *entry;
1576−
1577− list_for_each_entry(entry, &hdev->adv_entries, list)
1578− if (bacmp(bdaddr, &entry->bdaddr) == 0)
1579− return entry;
1580−
1581− return NULL;
1582−}
1583−
1584−static inline int is_connectable_adv(u8 evt_type)
1585−{
1586− if (evt_type == ADV_IND || evt_type == ADV_DIRECT_IND)
1587− return 1;
1588−
1589− return 0;
1590−}
1591−
1592−int hci_add_adv_entry(struct hci_dev *hdev,
1593− struct hci_ev_le_advertising_info *ev) { struct adv_entry *entry; if (!is_connectable_adv(ev->evt_type))
1594− return -EINVAL;
1595−
1596− /* Only new entries should be added to adv_entries. So, if
1597− * bdaddr was found, don't add it. */
1598− if (hci_find_adv_entry(hdev, &ev->bdaddr))
1599− return 0;
1600−
1601− entry = kzalloc(sizeof(*entry), GFP_KERNEL);
1602− if (!entry)
1603− return -ENOMEM;
1604−
1605− bacpy(&entry->bdaddr, &ev->bdaddr);
1606− entry->bdaddr_type = ev->bdaddr_type;
1607−
1608− list_add(&entry->list, &hdev->adv_entries);
1609−
1610− BT_DBG("%s adv entry added: address %s type %u", hdev->name,
1611− batostr(&entry->bdaddr), entry->bdaddr_type);
1612−
1613− return 0;
1614−}
1615−
16161524 static void le_scan_param_req(struct hci_dev *hdev, unsigned long opt)
16171525 {
16181526 struct le_scan_params *param = (struct le_scan_params *) opt;
@@ -1670,6 +1578,24 @@ static int hci_do_le_scan(struct hci_dev *hdev, u8 type, u16 interval, · 51 unmodified lines
16701578 return 0;
16711579 }
16721580
1581+int hci_cancel_le_scan(struct hci_dev *hdev)
1582+{
1583+ BT_DBG("%s", hdev->name);
1584+
1585+ if (!test_bit(HCI_LE_SCAN, &hdev->dev_flags))
1586+ return -EALREADY;
1587+
1588+ if (cancel_delayed_work(&hdev->le_scan_disable)) {
1589+ struct hci_cp_le_set_scan_enable cp;
1590+
1591+ /* Send HCI command to disable LE Scan */
1592+ memset(&cp, 0, sizeof(cp));
1593+ hci_send_cmd(hdev, HCI_OP_LE_SET_SCAN_ENABLE, sizeof(cp), &cp);
1594+ }
1595+
1596+ return 0;
1597+}
1598+
16731599 static void le_scan_disable_work(struct work_struct *work)
16741600 {
16751601 struct hci_dev *hdev = container_of(work, struct hci_dev,
@@ -1714,95 +1640,103 @@ int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window, · 38 unmodified lines
17141640 return 0;
17151641 }
17161642
1717−/* Register HCI device */
1718−int hci_register_dev(struct hci_dev *hdev)
1643+/* Alloc HCI device */
1644+struct hci_dev *hci_alloc_dev(void)
17191645 {
1720− struct list_head *head = &hci_dev_list, *p;
1721− int i, id, error;
1722−
1723− BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
1724−
1725− if (!hdev->open || !hdev->close)
1726− return -EINVAL;
1727−
1728− /* Do not allow HCI_AMP devices to register at index 0,
1729− * so the index can be used as the AMP controller ID.
1730− */
1731− id = (hdev->dev_type == HCI_BREDR) ? 0 : 1;
1732−
1733− write_lock(&hci_dev_list_lock);
1734−
1735− /* Find first available device id */
1736− list_for_each(p, &hci_dev_list) {
1737− if (list_entry(p, struct hci_dev, list)->id != id)
1738− break;
1739− head = p; id++;
1740− }
1741−
1742− sprintf(hdev->name, "hci%d", id);
1743− hdev->id = id;
1744− list_add_tail(&hdev->list, head);
1646+ struct hci_dev *hdev;
17451647
1746− mutex_init(&hdev->lock);
1648+ hdev = kzalloc(sizeof(struct hci_dev), GFP_KERNEL);
1649+ if (!hdev)
1650+ return NULL;
17471651
1748− hdev->flags = 0;
1749− hdev->dev_flags = 0;
17501652 hdev->pkt_type = (HCI_DM1 | HCI_DH1 | HCI_HV1);
17511653 hdev->esco_type = (ESCO_HV1);
17521654 hdev->link_mode = (HCI_LM_ACCEPT);
17531655 hdev->io_capability = 0x03; /* No Input No Output */
17541656
1755− hdev->idle_timeout = 0;
17561657 hdev->sniff_max_interval = 800;
17571658 hdev->sniff_min_interval = 80;
17581659
1660+ mutex_init(&hdev->lock);
1661+ mutex_init(&hdev->req_lock);
1662+
1663+ INIT_LIST_HEAD(&hdev->mgmt_pending);
1664+ INIT_LIST_HEAD(&hdev->blacklist);
1665+ INIT_LIST_HEAD(&hdev->uuids);
1666+ INIT_LIST_HEAD(&hdev->link_keys);
1667+ INIT_LIST_HEAD(&hdev->long_term_keys);
1668+ INIT_LIST_HEAD(&hdev->remote_oob_data);
1669+
17591670 INIT_WORK(&hdev->rx_work, hci_rx_work);
17601671 INIT_WORK(&hdev->cmd_work, hci_cmd_work);
17611672 INIT_WORK(&hdev->tx_work, hci_tx_work);
1673+ INIT_WORK(&hdev->power_on, hci_power_on);
1674+ INIT_WORK(&hdev->le_scan, le_scan_work);
17621675
1676+ INIT_DELAYED_WORK(&hdev->power_off, hci_power_off);
1677+ INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off);
1678+ INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work);
17631679
1680+ skb_queue_head_init(&hdev->driver_init);
17641681 skb_queue_head_init(&hdev->rx_q);
17651682 skb_queue_head_init(&hdev->cmd_q);
17661683 skb_queue_head_init(&hdev->raw_q);
17671684
1768− setup_timer(&hdev->cmd_timer, hci_cmd_timer, (unsigned long) hdev);
1769−
1770− for (i = 0; i < NUM_REASSEMBLY; i++)
1771− hdev->reassembly[i] = NULL;
1772−
17731685 init_waitqueue_head(&hdev->req_wait_q);
1774− mutex_init(&hdev->req_lock);
17751686
1776− discovery_init(hdev);
1687+ setup_timer(&hdev->cmd_timer, hci_cmd_timer, (unsigned long) hdev);
17771688
1689+ hci_init_sysfs(hdev);
1690+ discovery_init(hdev);
17781691 hci_conn_hash_init(hdev);
17791692
1780− INIT_LIST_HEAD(&hdev->mgmt_pending);
1781−
1782− INIT_LIST_HEAD(&hdev->blacklist);
1693+ return hdev;
1694+}
1695+EXPORT_SYMBOL(hci_alloc_dev);
17831696
1784− INIT_LIST_HEAD(&hdev->uuids);
1697+/* Free HCI device */
1698+void hci_free_dev(struct hci_dev *hdev)
1699+{
1700+ skb_queue_purge(&hdev->driver_init);
17851701
1786− INIT_LIST_HEAD(&hdev->link_keys);
1787− INIT_LIST_HEAD(&hdev->long_term_keys);
1702+ /* will free via device release */
1703+ put_device(&hdev->dev);
1704+}
1705+EXPORT_SYMBOL(hci_free_dev);
17881706
1789− INIT_LIST_HEAD(&hdev->remote_oob_data);
1707+/* Register HCI device */
1708+int hci_register_dev(struct hci_dev *hdev)
1709+{
1710+ struct list_head *head, *p;
1711+ int id, error;
17901712
1791− INIT_LIST_HEAD(&hdev->adv_entries);
1713+ if (!hdev->open || !hdev->close)
1714+ return -EINVAL;
17921715
1793− INIT_DELAYED_WORK(&hdev->adv_work, hci_clear_adv_cache);
1794− INIT_WORK(&hdev->power_on, hci_power_on);
1795− INIT_DELAYED_WORK(&hdev->power_off, hci_power_off);
1716+ write_lock(&hci_dev_list_lock);
17961717
1797− INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off);
1718+ /* Do not allow HCI_AMP devices to register at index 0,
1719+ * so the index can be used as the AMP controller ID.
1720+ */
1721+ id = (hdev->dev_type == HCI_BREDR) ? 0 : 1;
1722+ head = &hci_dev_list;
17981723
1799− memset(&hdev->stat, 0, sizeof(struct hci_dev_stats));
1724+ /* Find first available device id */
1725+ list_for_each(p, &hci_dev_list) {
1726+ int nid = list_entry(p, struct hci_dev, list)->id;
1727+ if (nid > id)
1728+ break;
1729+ if (nid == id)
1730+ id++;
1731+ head = p;
1732+ }
18001733
1801− atomic_set(&hdev->promisc, 0);
1734+ sprintf(hdev->name, "hci%d", id);
1735+ hdev->id = id;
18021736
1803− INIT_WORK(&hdev->le_scan, le_scan_work);
1737+ BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
18041738
1805− INIT_DELAYED_WORK(&hdev->le_scan_disable, le_scan_disable_work);
1739+ list_add(&hdev->list, head);
18061740
18071741 write_unlock(&hci_dev_list_lock);
18081742
@@ -1884,8 +1818,6 @@ void hci_unregister_dev(struct hci_dev *hdev) · 75 unmodified lines
18841818
18851819 hci_del_sysfs(hdev);
18861820
1887− cancel_delayed_work_sync(&hdev->adv_work);
1888−
18891821 destroy_workqueue(hdev->workqueue);
18901822
18911823 hci_dev_lock(hdev);
@@ -1894,7 +1826,6 @@ void hci_unregister_dev(struct hci_dev *hdev) · 2 unmodified lines
18941826 hci_link_keys_clear(hdev);
18951827 hci_smp_ltks_clear(hdev);
18961828 hci_remote_oob_data_clear(hdev);
1897− hci_adv_entries_clear(hdev);
18981829 hci_dev_unlock(hdev);
18991830
19001831 hci_dev_put(hdev);
@@ -2231,6 +2162,12 @@ static void hci_queue_acl(struct hci_conn *conn, struct sk_buff_head *queue, · 330 unmodified lines
22312162 struct hci_dev *hdev = conn->hdev;
22322163 struct sk_buff *list;
22332164
2165+ skb->len = skb_headlen(skb);
2166+ skb->data_len = 0;
2167+
2168+ bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
2169+ hci_add_acl_hdr(skb, conn->handle, flags);
2170+
22342171 list = skb_shinfo(skb)->frag_list;
22352172 if (!list) {
22362173 /* Non fragmented */
@@ -2274,8 +2211,6 @@ void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags) · 37 unmodified lines
22742211 BT_DBG("%s chan %p flags 0x%x", hdev->name, chan, flags);
22752212
22762213 skb->dev = (void *) hdev;
2277− bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
2278− hci_add_acl_hdr(skb, conn->handle, flags);
22792214
22802215 hci_queue_acl(conn, &chan->data_q, skb, flags);
22812216
@@ -2313,7 +2248,7 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int · 31 unmodified lines
23132248 {
23142249 struct hci_conn_hash *h = &hdev->conn_hash;
23152250 struct hci_conn *conn = NULL, *c;
2316− int num = 0, min = ~0;
2251+ unsigned int num = 0, min = ~0;
23172252
23182253 /* We don't have to lock device here. Connections are always
23192254 * added and removed with TX task disabled. */
@@ -2394,7 +2329,7 @@ static inline struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type, · 74 unmodified lines
23942329 {
23952330 struct hci_conn_hash *h = &hdev->conn_hash;
23962331 struct hci_chan *chan = NULL;
2397− int num = 0, min = ~0, cur_prio = 0;
2332+ unsigned int num = 0, min = ~0, cur_prio = 0;
23982333 struct hci_conn *conn;
23992334 int cnt, q, conn_num = 0;
24002335
@@ -2945,7 +2880,19 @@ int hci_cancel_inquiry(struct hci_dev *hdev) · 544 unmodified lines
29452880 BT_DBG("%s", hdev->name);
29462881
29472882 if (!test_bit(HCI_INQUIRY, &hdev->flags))
2948− return -EPERM;
2883+ return -EALREADY;
29492884
29502885 return hci_send_cmd(hdev, HCI_OP_INQUIRY_CANCEL, 0, NULL);
29512886 }
2887+
2888+u8 bdaddr_to_le(u8 bdaddr_type)
2889+{
2890+ switch (bdaddr_type) {
2891+ case BDADDR_LE_PUBLIC:
2892+ return ADDR_LE_DEV_PUBLIC;
2893+
2894+ default:
2895+ /* Fallback to LE Random address type */
2896+ return ADDR_LE_DEV_RANDOM;
2897+ }
2898+}
net/bluetooth/hci_event.c+54−21
@@ -69,6 +69,18 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb) · 68 unmodified lines
6969 hci_conn_check_pending(hdev);
7070 }
7171
72+static void hci_cc_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
73+{
74+ __u8 status = *((__u8 *) skb->data);
75+
76+ BT_DBG("%s status 0x%x", hdev->name, status);
77+
78+ if (status)
79+ return;
80+
81+ set_bit(HCI_PERIODIC_INQ, &hdev->dev_flags);
82+}
83+
7284 static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
7385 {
7486 __u8 status = *((__u8 *) skb->data);
@@ -78,6 +90,8 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb) · 3 unmodified lines
7890 if (status)
7991 return;
8092
93+ clear_bit(HCI_PERIODIC_INQ, &hdev->dev_flags);
94+
8195 hci_conn_check_pending(hdev);
8296 }
8397
@@ -192,7 +206,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) · 108 unmodified lines
192206 hci_req_complete(hdev, HCI_OP_RESET, status);
193207
194208 /* Reset all non-persistent flags */
195− hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS));
209+ hdev->dev_flags &= ~(BIT(HCI_LE_SCAN) | BIT(HCI_PENDING_CLASS) |
210+ BIT(HCI_PERIODIC_INQ));
196211
197212 hdev->discovery.state = DISCOVERY_STOPPED;
198213 }
@@ -505,7 +520,7 @@ static void hci_setup_event_mask(struct hci_dev *hdev) · 306 unmodified lines
505520 events[5] |= 0x10; /* Synchronous Connection Changed */
506521
507522 if (hdev->features[3] & LMP_RSSI_INQ)
508− events[4] |= 0x04; /* Inquiry Result with RSSI */
523+ events[4] |= 0x02; /* Inquiry Result with RSSI */
509524
510525 if (hdev->features[5] & LMP_SNIFF_SUBR)
511526 events[5] |= 0x20; /* Sniff Subrating */
@@ -615,6 +630,7 @@ done: · 103 unmodified lines
615630
616631 static void hci_setup_link_policy(struct hci_dev *hdev)
617632 {
633+ struct hci_cp_write_def_link_policy cp;
618634 u16 link_policy = 0;
619635
620636 if (hdev->features[0] & LMP_RSWITCH)
@@ -626,9 +642,8 @@ static void hci_setup_link_policy(struct hci_dev *hdev) · 5 unmodified lines
626642 if (hdev->features[1] & LMP_PARK)
627643 link_policy |= HCI_LP_PARK;
628644
629− link_policy = cpu_to_le16(link_policy);
630− hci_send_cmd(hdev, HCI_OP_WRITE_DEF_LINK_POLICY, sizeof(link_policy),
631− &link_policy);
645+ cp.policy = cpu_to_le16(link_policy);
646+ hci_send_cmd(hdev, HCI_OP_WRITE_DEF_LINK_POLICY, sizeof(cp), &cp);
632647 }
633648
634649 static void hci_cc_read_local_commands(struct hci_dev *hdev, struct sk_buff *skb)
@@ -710,7 +725,7 @@ static void hci_set_le_support(struct hci_dev *hdev) · 75 unmodified lines
710725
711726 memset(&cp, 0, sizeof(cp));
712727
713− if (enable_le && test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
728+ if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
714729 cp.le = 1;
715730 cp.simul = !!(hdev->features[6] & LMP_SIMUL_LE_BR);
716731 }
@@ -887,11 +902,14 @@ static void hci_cc_write_inquiry_mode(struct hci_dev *hdev, · 170 unmodified lines
887902 static void hci_cc_read_inq_rsp_tx_power(struct hci_dev *hdev,
888903 struct sk_buff *skb)
889904 {
890− __u8 status = *((__u8 *) skb->data);
905+ struct hci_rp_read_inq_rsp_tx_power *rp = (void *) skb->data;
891906
892− BT_DBG("%s status 0x%x", hdev->name, status);
907+ BT_DBG("%s status 0x%x", hdev->name, rp->status);
908+
909+ if (!rp->status)
910+ hdev->inq_tx_power = rp->tx_power;
893911
894− hci_req_complete(hdev, HCI_OP_READ_INQ_RSP_TX_POWER, status);
912+ hci_req_complete(hdev, HCI_OP_READ_INQ_RSP_TX_POWER, rp->status);
895913 }
896914
897915 static void hci_cc_set_event_flt(struct hci_dev *hdev, struct sk_buff *skb)
@@ -1082,23 +1100,23 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev, · 184 unmodified lines
10821100
10831101 set_bit(HCI_LE_SCAN, &hdev->dev_flags);
10841102
1085− cancel_delayed_work_sync(&hdev->adv_work);
1086−
10871103 hci_dev_lock(hdev);
1088− hci_adv_entries_clear(hdev);
10891104 hci_discovery_set_state(hdev, DISCOVERY_FINDING);
10901105 hci_dev_unlock(hdev);
10911106 break;
10921107
10931108 case LE_SCANNING_DISABLED:
1094− if (status)
1109+ if (status) {
1110+ hci_dev_lock(hdev);
1111+ mgmt_stop_discovery_failed(hdev, status);
1112+ hci_dev_unlock(hdev);
10951113 return;
1114+ }
10961115
10971116 clear_bit(HCI_LE_SCAN, &hdev->dev_flags);
10981117
1099− schedule_delayed_work(&hdev->adv_work, ADV_CLEAR_TIMEOUT);
1100−
1101− if (hdev->discovery.type == DISCOV_TYPE_INTERLEAVED) {
1118+ if (hdev->discovery.type == DISCOV_TYPE_INTERLEAVED &&
1119+ hdev->discovery.state == DISCOVERY_FINDING) {
11021120 mgmt_interleaved_discovery(hdev);
11031121 } else {
11041122 hci_dev_lock(hdev);
@@ -1625,6 +1643,8 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status) · 520 unmodified lines
16251643 if (status) {
16261644 if (conn && conn->state == BT_CONNECT) {
16271645 conn->state = BT_CLOSED;
1646+ mgmt_connect_failed(hdev, &cp->peer_addr, conn->type,
1647+ conn->dst_type, status);
16281648 hci_proto_connect_cfm(conn, status);
16291649 hci_conn_del(conn);
16301650 }
@@ -1699,6 +1719,9 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * · 68 unmodified lines
16991719 if (!num_rsp)
17001720 return;
17011721
1722+ if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags))
1723+ return;
1724+
17021725 hci_dev_lock(hdev);
17031726
17041727 for (; num_rsp; num_rsp--, info++) {
@@ -2040,7 +2063,7 @@ static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff * · 335 unmodified lines
20402063 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
20412064
20422065 if (ev->status && conn->state == BT_CONNECTED) {
2043− hci_acl_disconn(conn, 0x13);
2066+ hci_acl_disconn(conn, HCI_ERROR_AUTH_FAILURE);
20442067 hci_conn_put(conn);
20452068 goto unlock;
20462069 }
@@ -2154,6 +2177,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk · 107 unmodified lines
21542177 hci_cc_inquiry_cancel(hdev, skb);
21552178 break;
21562179
2180+ case HCI_OP_PERIODIC_INQ:
2181+ hci_cc_periodic_inq(hdev, skb);
2182+ break;
2183+
21572184 case HCI_OP_EXIT_PERIODIC_INQ:
21582185 hci_cc_exit_periodic_inq(hdev, skb);
21592186 break;
@@ -2806,6 +2833,9 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct · 646 unmodified lines
28062833 if (!num_rsp)
28072834 return;
28082835
2836+ if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags))
2837+ return;
2838+
28092839 hci_dev_lock(hdev);
28102840
28112841 if ((skb->len - 1) / num_rsp != sizeof(struct inquiry_info_with_rssi)) {
@@ -2971,12 +3001,16 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct · 159 unmodified lines
29713001 struct inquiry_data data;
29723002 struct extended_inquiry_info *info = (void *) (skb->data + 1);
29733003 int num_rsp = *((__u8 *) skb->data);
3004+ size_t eir_len;
29743005
29753006 BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
29763007
29773008 if (!num_rsp)
29783009 return;
29793010
3011+ if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags))
3012+ return;
3013+
29803014 hci_dev_lock(hdev);
29813015
29823016 for (; num_rsp; num_rsp--, info++) {
@@ -3000,9 +3034,10 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct · 17 unmodified lines
30003034
30013035 name_known = hci_inquiry_cache_update(hdev, &data, name_known,
30023036 &ssp);
3037+ eir_len = eir_get_length(info->data, sizeof(info->data));
30033038 mgmt_device_found(hdev, &info->bdaddr, ACL_LINK, 0x00,
30043039 info->dev_class, info->rssi, !name_known,
3005− ssp, info->data, sizeof(info->data));
3040+ ssp, info->data, eir_len);
30063041 }
30073042
30083043 hci_dev_unlock(hdev);
@@ -3322,8 +3357,6 @@ static inline void hci_le_adv_report_evt(struct hci_dev *hdev, · 313 unmodified lines
33223357 while (num_reports--) {
33233358 struct hci_ev_le_advertising_info *ev = ptr;
33243359
3325− hci_add_adv_entry(hdev, ev);
3326−
33273360 rssi = ev->data[ev->length];
33283361 mgmt_device_found(hdev, &ev->bdaddr, LE_LINK, ev->bdaddr_type,
33293362 NULL, rssi, 0, 1, ev->data, ev->length);
@@ -3343,7 +3376,7 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev, · 13 unmodified lines
33433376 struct hci_conn *conn;
33443377 struct smp_ltk *ltk;
33453378
3346− BT_DBG("%s handle %d", hdev->name, cpu_to_le16(ev->handle));
3379+ BT_DBG("%s handle %d", hdev->name, __le16_to_cpu(ev->handle));
33473380
33483381 hci_dev_lock(hdev);
33493382
net/bluetooth/hci_sysfs.c+2−3
@@ -444,8 +444,8 @@ static const struct file_operations blacklist_fops = { · 443 unmodified lines
444444
445445 static void print_bt_uuid(struct seq_file *f, u8 *uuid)
446446 {
447− u32 data0, data4;
448− u16 data1, data2, data3, data5;
447+ __be32 data0, data4;
448+ __be16 data1, data2, data3, data5;
449449
450450 memcpy(&data0, &uuid[0], 4);
451451 memcpy(&data1, &uuid[4], 2);
@@ -533,7 +533,6 @@ int hci_add_sysfs(struct hci_dev *hdev) · 81 unmodified lines
533533
534534 BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
535535
536− dev->parent = hdev->parent;
537536 dev_set_name(dev, "%s", hdev->name);
538537
539538 err = device_add(dev);
net/bluetooth/l2cap_core.c+538−224
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org>
55 Copyright (C) 2010 Google Inc.
66 Copyright (C) 2011 ProFUSION Embedded Systems
7+ Copyright (c) 2012 Code Aurora Forum. All rights reserved.
78
89 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
910
@@ -70,7 +71,7 @@ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, · 60 unmodified lines
7071 void *data);
7172 static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data);
7273 static void l2cap_send_disconn_req(struct l2cap_conn *conn,
73− struct l2cap_chan *chan, int err);
74+ struct l2cap_chan *chan, int err);
7475
7576 /* ---- L2CAP channels ---- */
7677
@@ -97,13 +98,15 @@ static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 · 20 unmodified lines
9798 }
9899
99100 /* Find channel with given SCID.
100− * Returns locked socket */
101+ * Returns locked channel. */
101102 static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid)
102103 {
103104 struct l2cap_chan *c;
104105
105106 mutex_lock(&conn->chan_lock);
106107 c = __l2cap_get_chan_by_scid(conn, cid);
108+ if (c)
109+ l2cap_chan_lock(c);
107110 mutex_unlock(&conn->chan_lock);
108111
109112 return c;
@@ -120,17 +123,6 @@ static struct l2cap_chan *__l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8 · 10 unmodified lines
120123 return NULL;
121124 }
122125
123−static inline struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn, u8 ident)
124−{
125− struct l2cap_chan *c;
126−
127− mutex_lock(&conn->chan_lock);
128− c = __l2cap_get_chan_by_ident(conn, ident);
129− mutex_unlock(&conn->chan_lock);
130−
131− return c;
132−}
133−
134126 static struct l2cap_chan *__l2cap_global_chan_by_addr(__le16 psm, bdaddr_t *src)
135127 {
136128 struct l2cap_chan *c;
@@ -232,6 +224,124 @@ static inline void l2cap_chan_set_err(struct l2cap_chan *chan, int err) · 95 unmodified lines
232224 release_sock(sk);
233225 }
234226
227+/* ---- L2CAP sequence number lists ---- */
228+
229+/* For ERTM, ordered lists of sequence numbers must be tracked for
230+ * SREJ requests that are received and for frames that are to be
231+ * retransmitted. These seq_list functions implement a singly-linked
232+ * list in an array, where membership in the list can also be checked
233+ * in constant time. Items can also be added to the tail of the list
234+ * and removed from the head in constant time, without further memory
235+ * allocs or frees.
236+ */
237+
238+static int l2cap_seq_list_init(struct l2cap_seq_list *seq_list, u16 size)
239+{
240+ size_t alloc_size, i;
241+
242+ /* Allocated size is a power of 2 to map sequence numbers
243+ * (which may be up to 14 bits) in to a smaller array that is
244+ * sized for the negotiated ERTM transmit windows.
245+ */
246+ alloc_size = roundup_pow_of_two(size);
247+
248+ seq_list->list = kmalloc(sizeof(u16) * alloc_size, GFP_KERNEL);
249+ if (!seq_list->list)
250+ return -ENOMEM;
251+
252+ seq_list->mask = alloc_size - 1;
253+ seq_list->head = L2CAP_SEQ_LIST_CLEAR;
254+ seq_list->tail = L2CAP_SEQ_LIST_CLEAR;
255+ for (i = 0; i < alloc_size; i++)
256+ seq_list->list[i] = L2CAP_SEQ_LIST_CLEAR;
257+
258+ return 0;
259+}
260+
261+static inline void l2cap_seq_list_free(struct l2cap_seq_list *seq_list)
262+{
263+ kfree(seq_list->list);
264+}
265+
266+static inline bool l2cap_seq_list_contains(struct l2cap_seq_list *seq_list,
267+ u16 seq)
268+{
269+ /* Constant-time check for list membership */
270+ return seq_list->list[seq & seq_list->mask] != L2CAP_SEQ_LIST_CLEAR;
271+}
272+
273+static u16 l2cap_seq_list_remove(struct l2cap_seq_list *seq_list, u16 seq)
274+{
275+ u16 mask = seq_list->mask;
276+
277+ if (seq_list->head == L2CAP_SEQ_LIST_CLEAR) {
278+ /* In case someone tries to pop the head of an empty list */
279+ return L2CAP_SEQ_LIST_CLEAR;
280+ } else if (seq_list->head == seq) {
281+ /* Head can be removed in constant time */
282+ seq_list->head = seq_list->list[seq & mask];
283+ seq_list->list[seq & mask] = L2CAP_SEQ_LIST_CLEAR;
284+
285+ if (seq_list->head == L2CAP_SEQ_LIST_TAIL) {
286+ seq_list->head = L2CAP_SEQ_LIST_CLEAR;
287+ seq_list->tail = L2CAP_SEQ_LIST_CLEAR;
288+ }
289+ } else {
290+ /* Walk the list to find the sequence number */
291+ u16 prev = seq_list->head;
292+ while (seq_list->list[prev & mask] != seq) {
293+ prev = seq_list->list[prev & mask];
294+ if (prev == L2CAP_SEQ_LIST_TAIL)
295+ return L2CAP_SEQ_LIST_CLEAR;
296+ }
297+
298+ /* Unlink the number from the list and clear it */
299+ seq_list->list[prev & mask] = seq_list->list[seq & mask];
300+ seq_list->list[seq & mask] = L2CAP_SEQ_LIST_CLEAR;
301+ if (seq_list->tail == seq)
302+ seq_list->tail = prev;
303+ }
304+ return seq;
305+}
306+
307+static inline u16 l2cap_seq_list_pop(struct l2cap_seq_list *seq_list)
308+{
309+ /* Remove the head in constant time */
310+ return l2cap_seq_list_remove(seq_list, seq_list->head);
311+}
312+
313+static void l2cap_seq_list_clear(struct l2cap_seq_list *seq_list)
314+{
315+ u16 i;
316+
317+ if (seq_list->head == L2CAP_SEQ_LIST_CLEAR)
318+ return;
319+
320+ for (i = 0; i <= seq_list->mask; i++)
321+ seq_list->list[i] = L2CAP_SEQ_LIST_CLEAR;
322+
323+ seq_list->head = L2CAP_SEQ_LIST_CLEAR;
324+ seq_list->tail = L2CAP_SEQ_LIST_CLEAR;
325+}
326+
327+static void l2cap_seq_list_append(struct l2cap_seq_list *seq_list, u16 seq)
328+{
329+ u16 mask = seq_list->mask;
330+
331+ /* All appends happen in constant time */
332+
333+ if (seq_list->list[seq & mask] != L2CAP_SEQ_LIST_CLEAR)
334+ return;
335+
336+ if (seq_list->tail == L2CAP_SEQ_LIST_CLEAR)
337+ seq_list->head = seq;
338+ else
339+ seq_list->list[seq_list->tail & mask] = seq;
340+
341+ seq_list->tail = seq;
342+ seq_list->list[seq & mask] = L2CAP_SEQ_LIST_TAIL;
343+}
344+
235345 static void l2cap_chan_timeout(struct work_struct *work)
236346 {
237347 struct l2cap_chan *chan = container_of(work, struct l2cap_chan,
@@ -262,7 +372,7 @@ static void l2cap_chan_timeout(struct work_struct *work) · 24 unmodified lines
262372 l2cap_chan_put(chan);
263373 }
264374
265−struct l2cap_chan *l2cap_chan_create(struct sock *sk)
375+struct l2cap_chan *l2cap_chan_create(void)
266376 {
267377 struct l2cap_chan *chan;
268378
@@ -272,8 +382,6 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk) · 3 unmodified lines
272382
273383 mutex_init(&chan->lock);
274384
275− chan->sk = sk;
276−
277385 write_lock(&chan_list_lock);
278386 list_add(&chan->global_l, &chan_list);
279387 write_unlock(&chan_list_lock);
@@ -284,7 +392,7 @@ struct l2cap_chan *l2cap_chan_create(struct sock *sk) · 4 unmodified lines
284392
285393 atomic_set(&chan->refcnt, 1);
286394
287− BT_DBG("sk %p chan %p", sk, chan);
395+ BT_DBG("chan %p", chan);
288396
289397 return chan;
290398 }
@@ -298,10 +406,21 @@ void l2cap_chan_destroy(struct l2cap_chan *chan) · 7 unmodified lines
298406 l2cap_chan_put(chan);
299407 }
300408
301−void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
409+void l2cap_chan_set_defaults(struct l2cap_chan *chan)
410+{
411+ chan->fcs = L2CAP_FCS_CRC16;
412+ chan->max_tx = L2CAP_DEFAULT_MAX_TX;
413+ chan->tx_win = L2CAP_DEFAULT_TX_WINDOW;
414+ chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW;
415+ chan->sec_level = BT_SECURITY_LOW;
416+
417+ set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
418+}
419+
420+static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
302421 {
303422 BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn,
304− chan->psm, chan->dcid);
423+ __le16_to_cpu(chan->psm), chan->dcid);
305424
306425 conn->disc_reason = HCI_ERROR_REMOTE_USER_TERM;
307426
@@ -347,7 +466,7 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan) · 39 unmodified lines
347466 list_add(&chan->list, &conn->chan_l);
348467 }
349468
350−void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
469+static void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
351470 {
352471 mutex_lock(&conn->chan_lock);
353472 __l2cap_chan_add(conn, chan);
@@ -405,6 +524,8 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err) · 51 unmodified lines
405524
406525 skb_queue_purge(&chan->srej_q);
407526
527+ l2cap_seq_list_free(&chan->srej_list);
528+ l2cap_seq_list_free(&chan->retrans_list);
408529 list_for_each_entry_safe(l, tmp, &chan->srej_l, list) {
409530 list_del(&l->list);
410531 kfree(l);
@@ -453,7 +574,6 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) · 42 unmodified lines
453574 case BT_CONFIG:
454575 if (chan->chan_type == L2CAP_CHAN_CONN_ORIENTED &&
455576 conn->hcon->type == ACL_LINK) {
456− __clear_chan_timer(chan);
457577 __set_chan_timer(chan, sk->sk_sndtimeo);
458578 l2cap_send_disconn_req(conn, chan, reason);
459579 } else
@@ -466,7 +586,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason) · 6 unmodified lines
466586 struct l2cap_conn_rsp rsp;
467587 __u16 result;
468588
469− if (bt_sk(sk)->defer_setup)
589+ if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags))
470590 result = L2CAP_CR_SEC_BLOCK;
471591 else
472592 result = L2CAP_CR_BAD_PSM;
@@ -599,6 +719,117 @@ static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb) · 126 unmodified lines
599719 hci_send_acl(chan->conn->hchan, skb, flags);
600720 }
601721
722+static void __unpack_enhanced_control(u16 enh, struct l2cap_ctrl *control)
723+{
724+ control->reqseq = (enh & L2CAP_CTRL_REQSEQ) >> L2CAP_CTRL_REQSEQ_SHIFT;
725+ control->final = (enh & L2CAP_CTRL_FINAL) >> L2CAP_CTRL_FINAL_SHIFT;
726+
727+ if (enh & L2CAP_CTRL_FRAME_TYPE) {
728+ /* S-Frame */
729+ control->sframe = 1;
730+ control->poll = (enh & L2CAP_CTRL_POLL) >> L2CAP_CTRL_POLL_SHIFT;
731+ control->super = (enh & L2CAP_CTRL_SUPERVISE) >> L2CAP_CTRL_SUPER_SHIFT;
732+
733+ control->sar = 0;
734+ control->txseq = 0;
735+ } else {
736+ /* I-Frame */
737+ control->sframe = 0;
738+ control->sar = (enh & L2CAP_CTRL_SAR) >> L2CAP_CTRL_SAR_SHIFT;
739+ control->txseq = (enh & L2CAP_CTRL_TXSEQ) >> L2CAP_CTRL_TXSEQ_SHIFT;
740+
741+ control->poll = 0;
742+ control->super = 0;
743+ }
744+}
745+
746+static void __unpack_extended_control(u32 ext, struct l2cap_ctrl *control)
747+{
748+ control->reqseq = (ext & L2CAP_EXT_CTRL_REQSEQ) >> L2CAP_EXT_CTRL_REQSEQ_SHIFT;
749+ control->final = (ext & L2CAP_EXT_CTRL_FINAL) >> L2CAP_EXT_CTRL_FINAL_SHIFT;
750+
751+ if (ext & L2CAP_EXT_CTRL_FRAME_TYPE) {
752+ /* S-Frame */
753+ control->sframe = 1;
754+ control->poll = (ext & L2CAP_EXT_CTRL_POLL) >> L2CAP_EXT_CTRL_POLL_SHIFT;
755+ control->super = (ext & L2CAP_EXT_CTRL_SUPERVISE) >> L2CAP_EXT_CTRL_SUPER_SHIFT;
756+
757+ control->sar = 0;
758+ control->txseq = 0;
759+ } else {
760+ /* I-Frame */
761+ control->sframe = 0;
762+ control->sar = (ext & L2CAP_EXT_CTRL_SAR) >> L2CAP_EXT_CTRL_SAR_SHIFT;
763+ control->txseq = (ext & L2CAP_EXT_CTRL_TXSEQ) >> L2CAP_EXT_CTRL_TXSEQ_SHIFT;
764+
765+ control->poll = 0;
766+ control->super = 0;
767+ }
768+}
769+
770+static inline void __unpack_control(struct l2cap_chan *chan,
771+ struct sk_buff *skb)
772+{
773+ if (test_bit(FLAG_EXT_CTRL, &chan->flags)) {
774+ __unpack_extended_control(get_unaligned_le32(skb->data),
775+ &bt_cb(skb)->control);
776+ } else {
777+ __unpack_enhanced_control(get_unaligned_le16(skb->data),
778+ &bt_cb(skb)->control);
779+ }
780+}
781+
782+static u32 __pack_extended_control(struct l2cap_ctrl *control)
783+{
784+ u32 packed;
785+
786+ packed = control->reqseq << L2CAP_EXT_CTRL_REQSEQ_SHIFT;
787+ packed |= control->final << L2CAP_EXT_CTRL_FINAL_SHIFT;
788+
789+ if (control->sframe) {
790+ packed |= control->poll << L2CAP_EXT_CTRL_POLL_SHIFT;
791+ packed |= control->super << L2CAP_EXT_CTRL_SUPER_SHIFT;
792+ packed |= L2CAP_EXT_CTRL_FRAME_TYPE;
793+ } else {
794+ packed |= control->sar << L2CAP_EXT_CTRL_SAR_SHIFT;
795+ packed |= control->txseq << L2CAP_EXT_CTRL_TXSEQ_SHIFT;
796+ }
797+
798+ return packed;
799+}
800+
801+static u16 __pack_enhanced_control(struct l2cap_ctrl *control)
802+{
803+ u16 packed;
804+
805+ packed = control->reqseq << L2CAP_CTRL_REQSEQ_SHIFT;
806+ packed |= control->final << L2CAP_CTRL_FINAL_SHIFT;
807+
808+ if (control->sframe) {
809+ packed |= control->poll << L2CAP_CTRL_POLL_SHIFT;
810+ packed |= control->super << L2CAP_CTRL_SUPER_SHIFT;
811+ packed |= L2CAP_CTRL_FRAME_TYPE;
812+ } else {
813+ packed |= control->sar << L2CAP_CTRL_SAR_SHIFT;
814+ packed |= control->txseq << L2CAP_CTRL_TXSEQ_SHIFT;
815+ }
816+
817+ return packed;
818+}
819+
820+static inline void __pack_control(struct l2cap_chan *chan,
821+ struct l2cap_ctrl *control,
822+ struct sk_buff *skb)
823+{
824+ if (test_bit(FLAG_EXT_CTRL, &chan->flags)) {
825+ put_unaligned_le32(__pack_extended_control(control),
826+ skb->data + L2CAP_HDR_SIZE);
827+ } else {
828+ put_unaligned_le16(__pack_enhanced_control(control),
829+ skb->data + L2CAP_HDR_SIZE);
830+ }
831+}
832+
602833 static inline void l2cap_send_sframe(struct l2cap_chan *chan, u32 control)
603834 {
604835 struct sk_buff *skb;
@@ -681,10 +912,38 @@ static void l2cap_send_conn_req(struct l2cap_chan *chan) · 76 unmodified lines
681912 l2cap_send_cmd(conn, chan->ident, L2CAP_CONN_REQ, sizeof(req), &req);
682913 }
683914
915+static void l2cap_chan_ready(struct l2cap_chan *chan)
916+{
917+ struct sock *sk = chan->sk;
918+ struct sock *parent;
919+
920+ lock_sock(sk);
921+
922+ parent = bt_sk(sk)->parent;
923+
924+ BT_DBG("sk %p, parent %p", sk, parent);
925+
926+ chan->conf_state = 0;
927+ __clear_chan_timer(chan);
928+
929+ __l2cap_state_change(chan, BT_CONNECTED);
930+ sk->sk_state_change(sk);
931+
932+ if (parent)
933+ parent->sk_data_ready(parent, 0);
934+
935+ release_sock(sk);
936+}
937+
684938 static void l2cap_do_start(struct l2cap_chan *chan)
685939 {
686940 struct l2cap_conn *conn = chan->conn;
687941
942+ if (conn->hcon->type == LE_LINK) {
943+ l2cap_chan_ready(chan);
944+ return;
945+ }
946+
688947 if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT) {
689948 if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE))
690949 return;
@@ -791,7 +1050,8 @@ static void l2cap_conn_start(struct l2cap_conn *conn) · 100 unmodified lines
7911050
7921051 if (l2cap_chan_check_security(chan)) {
7931052 lock_sock(sk);
794− if (bt_sk(sk)->defer_setup) {
1053+ if (test_bit(BT_SK_DEFER_SETUP,
1054+ &bt_sk(sk)->flags)) {
7951055 struct sock *parent = bt_sk(sk)->parent;
7961056 rsp.result = cpu_to_le16(L2CAP_CR_PEND);
7971057 rsp.status = cpu_to_le16(L2CAP_CS_AUTHOR_PEND);
@@ -830,10 +1090,12 @@ static void l2cap_conn_start(struct l2cap_conn *conn) · 32 unmodified lines
8301090 mutex_unlock(&conn->chan_lock);
8311091 }
8321092
833−/* Find socket with cid and source bdaddr.
1093+/* Find socket with cid and source/destination bdaddr.
8341094 * Returns closest match, locked.
8351095 */
836−static struct l2cap_chan *l2cap_global_chan_by_scid(int state, __le16 cid, bdaddr_t *src)
1096+static struct l2cap_chan *l2cap_global_chan_by_scid(int state, u16 cid,
1097+ bdaddr_t *src,
1098+ bdaddr_t *dst)
8371099 {
8381100 struct l2cap_chan *c, *c1 = NULL;
8391101
@@ -846,14 +1108,22 @@ static struct l2cap_chan *l2cap_global_chan_by_scid(int state, __le16 cid, bdadd · 6 unmodified lines
8461108 continue;
8471109
8481110 if (c->scid == cid) {
1111+ int src_match, dst_match;
1112+ int src_any, dst_any;
1113+
8491114 /* Exact match. */
850− if (!bacmp(&bt_sk(sk)->src, src)) {
1115+ src_match = !bacmp(&bt_sk(sk)->src, src);
1116+ dst_match = !bacmp(&bt_sk(sk)->dst, dst);
1117+ if (src_match && dst_match) {
8511118 read_unlock(&chan_list_lock);
8521119 return c;
8531120 }
8541121
8551122 /* Closest match */
856− if (!bacmp(&bt_sk(sk)->src, BDADDR_ANY))
1123+ src_any = !bacmp(&bt_sk(sk)->src, BDADDR_ANY);
1124+ dst_any = !bacmp(&bt_sk(sk)->dst, BDADDR_ANY);
1125+ if ((src_match && dst_any) || (src_any && dst_match) ||
1126+ (src_any && dst_any))
8571127 c1 = c;
8581128 }
8591129 }
@@ -872,7 +1142,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) · 12 unmodified lines
8721142
8731143 /* Check if we have socket listening on cid */
8741144 pchan = l2cap_global_chan_by_scid(BT_LISTEN, L2CAP_CID_LE_DATA,
875− conn->src);
1145+ conn->src, conn->dst);
8761146 if (!pchan)
8771147 return;
8781148
@@ -910,29 +1180,6 @@ clean: · 31 unmodified lines
9101180 release_sock(parent);
9111181 }
9121182
913−static void l2cap_chan_ready(struct l2cap_chan *chan)
914−{
915− struct sock *sk = chan->sk;
916− struct sock *parent;
917−
918− lock_sock(sk);
919−
920− parent = bt_sk(sk)->parent;
921−
922− BT_DBG("sk %p, parent %p", sk, parent);
923−
924− chan->conf_state = 0;
925− __clear_chan_timer(chan);
926−
927− __l2cap_state_change(chan, BT_CONNECTED);
928− sk->sk_state_change(sk);
929−
930− if (parent)
931− parent->sk_data_ready(parent, 0);
932−
933− release_sock(sk);
934−}
935−
9361183 static void l2cap_conn_ready(struct l2cap_conn *conn)
9371184 {
9381185 struct l2cap_chan *chan;
@@ -1016,6 +1263,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) · 77 unmodified lines
10161263
10171264 /* Kill channels */
10181265 list_for_each_entry_safe(chan, l, &conn->chan_l, list) {
1266+ l2cap_chan_hold(chan);
10191267 l2cap_chan_lock(chan);
10201268
10211269 l2cap_chan_del(chan, err);
@@ -1023,6 +1271,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) · 1 unmodified line
10231271 l2cap_chan_unlock(chan);
10241272
10251273 chan->ops->close(chan->data);
1274+ l2cap_chan_put(chan);
10261275 }
10271276
10281277 mutex_unlock(&conn->chan_lock);
@@ -1100,10 +1349,12 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status) · 71 unmodified lines
11001349
11011350 /* ---- Socket interface ---- */
11021351
1103−/* Find socket with psm and source bdaddr.
1352+/* Find socket with psm and source / destination bdaddr.
11041353 * Returns closest match.
11051354 */
1106−static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, bdaddr_t *src)
1355+static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm,
1356+ bdaddr_t *src,
1357+ bdaddr_t *dst)
11071358 {
11081359 struct l2cap_chan *c, *c1 = NULL;
11091360
@@ -1116,14 +1367,22 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, bdaddr · 6 unmodified lines
11161367 continue;
11171368
11181369 if (c->psm == psm) {
1370+ int src_match, dst_match;
1371+ int src_any, dst_any;
1372+
11191373 /* Exact match. */
1120− if (!bacmp(&bt_sk(sk)->src, src)) {
1374+ src_match = !bacmp(&bt_sk(sk)->src, src);
1375+ dst_match = !bacmp(&bt_sk(sk)->dst, dst);
1376+ if (src_match && dst_match) {
11211377 read_unlock(&chan_list_lock);
11221378 return c;
11231379 }
11241380
11251381 /* Closest match */
1126− if (!bacmp(&bt_sk(sk)->src, BDADDR_ANY))
1382+ src_any = !bacmp(&bt_sk(sk)->src, BDADDR_ANY);
1383+ dst_any = !bacmp(&bt_sk(sk)->dst, BDADDR_ANY);
1384+ if ((src_match && dst_any) || (src_any && dst_match) ||
1385+ (src_any && dst_any))
11271386 c1 = c;
11281387 }
11291388 }
@@ -1133,7 +1392,8 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, bdaddr · 3 unmodified lines
11331392 return c1;
11341393 }
11351394
1136−int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *dst)
1395+int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
1396+ bdaddr_t *dst, u8 dst_type)
11371397 {
11381398 struct sock *sk = chan->sk;
11391399 bdaddr_t *src = &bt_sk(sk)->src;
@@ -1143,8 +1403,8 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d · 3 unmodified lines
11431403 __u8 auth_type;
11441404 int err;
11451405
1146− BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst),
1147− chan->psm);
1406+ BT_DBG("%s -> %s (type %u) psm 0x%2.2x", batostr(src), batostr(dst),
1407+ dst_type, __le16_to_cpu(chan->psm));
11481408
11491409 hdev = hci_get_route(dst, src);
11501410 if (!hdev)
@@ -1218,11 +1478,11 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d · 67 unmodified lines
12181478 auth_type = l2cap_get_auth_type(chan);
12191479
12201480 if (chan->dcid == L2CAP_CID_LE_DATA)
1221− hcon = hci_connect(hdev, LE_LINK, dst,
1222− chan->sec_level, auth_type);
1481+ hcon = hci_connect(hdev, LE_LINK, dst, dst_type,
1482+ chan->sec_level, auth_type);
12231483 else
1224− hcon = hci_connect(hdev, ACL_LINK, dst,
1225− chan->sec_level, auth_type);
1484+ hcon = hci_connect(hdev, ACL_LINK, dst, dst_type,
1485+ chan->sec_level, auth_type);
12261486
12271487 if (IS_ERR(hcon)) {
12281488 err = PTR_ERR(hcon);
@@ -1236,6 +1496,18 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, bdaddr_t *d · 7 unmodified lines
12361496 goto done;
12371497 }
12381498
1499+ if (hcon->type == LE_LINK) {
1500+ err = 0;
1501+
1502+ if (!list_empty(&conn->chan_l)) {
1503+ err = -EBUSY;
1504+ hci_conn_put(hcon);
1505+ }
1506+
1507+ if (err)
1508+ goto done;
1509+ }
1510+
12391511 /* Update source addr of the socket */
12401512 bacpy(src, conn->src);
12411513
@@ -1346,7 +1618,7 @@ static void l2cap_drop_acked_frames(struct l2cap_chan *chan) · 104 unmodified lines
13461618
13471619 while ((skb = skb_peek(&chan->tx_q)) &&
13481620 chan->unacked_frames) {
1349− if (bt_cb(skb)->tx_seq == chan->expected_ack_seq)
1621+ if (bt_cb(skb)->control.txseq == chan->expected_ack_seq)
13501622 break;
13511623
13521624 skb = skb_dequeue(&chan->tx_q);
@@ -1368,6 +1640,7 @@ static void l2cap_streaming_send(struct l2cap_chan *chan) · 15 unmodified lines
13681640 while ((skb = skb_dequeue(&chan->tx_q))) {
13691641 control = __get_control(chan, skb->data + L2CAP_HDR_SIZE);
13701642 control |= __set_txseq(chan, chan->next_tx_seq);
1643+ control |= __set_ctrl_sar(chan, bt_cb(skb)->control.sar);
13711644 __put_control(chan, control, skb->data + L2CAP_HDR_SIZE);
13721645
13731646 if (chan->fcs == L2CAP_FCS_CRC16) {
@@ -1393,21 +1666,21 @@ static void l2cap_retransmit_one_frame(struct l2cap_chan *chan, u16 tx_seq) · 19 unmodified lines
13931666 if (!skb)
13941667 return;
13951668
1396− while (bt_cb(skb)->tx_seq != tx_seq) {
1669+ while (bt_cb(skb)->control.txseq != tx_seq) {
13971670 if (skb_queue_is_last(&chan->tx_q, skb))
13981671 return;
13991672
14001673 skb = skb_queue_next(&chan->tx_q, skb);
14011674 }
14021675
1403− if (chan->remote_max_tx &&
1404− bt_cb(skb)->retries == chan->remote_max_tx) {
1676+ if (bt_cb(skb)->control.retries == chan->remote_max_tx &&
1677+ chan->remote_max_tx) {
14051678 l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED);
14061679 return;
14071680 }
14081681
14091682 tx_skb = skb_clone(skb, GFP_ATOMIC);
1410− bt_cb(skb)->retries++;
1683+ bt_cb(skb)->control.retries++;
14111684
14121685 control = __get_control(chan, tx_skb->data + L2CAP_HDR_SIZE);
14131686 control &= __get_sar_mask(chan);
@@ -1440,17 +1713,20 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) · 26 unmodified lines
14401713 if (chan->state != BT_CONNECTED)
14411714 return -ENOTCONN;
14421715
1716+ if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state))
1717+ return 0;
1718+
14431719 while ((skb = chan->tx_send_head) && (!l2cap_tx_window_full(chan))) {
14441720
1445− if (chan->remote_max_tx &&
1446− bt_cb(skb)->retries == chan->remote_max_tx) {
1721+ if (bt_cb(skb)->control.retries == chan->remote_max_tx &&
1722+ chan->remote_max_tx) {
14471723 l2cap_send_disconn_req(chan->conn, chan, ECONNABORTED);
14481724 break;
14491725 }
14501726
14511727 tx_skb = skb_clone(skb, GFP_ATOMIC);
14521728
1453− bt_cb(skb)->retries++;
1729+ bt_cb(skb)->control.retries++;
14541730
14551731 control = __get_control(chan, tx_skb->data + L2CAP_HDR_SIZE);
14561732 control &= __get_sar_mask(chan);
@@ -1460,6 +1736,7 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) · 3 unmodified lines
14601736
14611737 control |= __set_reqseq(chan, chan->buffer_seq);
14621738 control |= __set_txseq(chan, chan->next_tx_seq);
1739+ control |= __set_ctrl_sar(chan, bt_cb(skb)->control.sar);
14631740
14641741 __put_control(chan, control, tx_skb->data + L2CAP_HDR_SIZE);
14651742
@@ -1474,11 +1751,11 @@ static int l2cap_ertm_send(struct l2cap_chan *chan) · 8 unmodified lines
14741751
14751752 __set_retrans_timer(chan);
14761753
1477− bt_cb(skb)->tx_seq = chan->next_tx_seq;
1754+ bt_cb(skb)->control.txseq = chan->next_tx_seq;
14781755
14791756 chan->next_tx_seq = __next_seq(chan, chan->next_tx_seq);
14801757
1481− if (bt_cb(skb)->retries == 1) {
1758+ if (bt_cb(skb)->control.retries == 1) {
14821759 chan->unacked_frames++;
14831760
14841761 if (!nsent++)
@@ -1554,7 +1831,7 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, · 69 unmodified lines
15541831 {
15551832 struct l2cap_conn *conn = chan->conn;
15561833 struct sk_buff **frag;
1557− int err, sent = 0;
1834+ int sent = 0;
15581835
15591836 if (memcpy_fromiovec(skb_put(skb, count), msg->msg_iov, count))
15601837 return -EFAULT;
@@ -1565,14 +1842,17 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, · 4 unmodified lines
15651842 /* Continuation fragments (no L2CAP header) */
15661843 frag = &skb_shinfo(skb)->frag_list;
15671844 while (len) {
1845+ struct sk_buff *tmp;
1846+
15681847 count = min_t(unsigned int, conn->mtu, len);
15691848
1570− *frag = chan->ops->alloc_skb(chan, count,
1571− msg->msg_flags & MSG_DONTWAIT,
1572− &err);
1849+ tmp = chan->ops->alloc_skb(chan, count,
1850+ msg->msg_flags & MSG_DONTWAIT);
1851+ if (IS_ERR(tmp))
1852+ return PTR_ERR(tmp);
1853+
1854+ *frag = tmp;
15731855
1574− if (!*frag)
1575− return err;
15761856 if (memcpy_fromiovec(skb_put(*frag, count), msg->msg_iov, count))
15771857 return -EFAULT;
15781858
@@ -1581,6 +1861,9 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, · 2 unmodified lines
15811861 sent += count;
15821862 len -= count;
15831863
1864+ skb->len += (*frag)->len;
1865+ skb->data_len += (*frag)->len;
1866+
15841867 frag = &(*frag)->next;
15851868 }
15861869
@@ -1601,18 +1884,17 @@ static struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, · 14 unmodified lines
16011884 count = min_t(unsigned int, (conn->mtu - hlen), len);
16021885
16031886 skb = chan->ops->alloc_skb(chan, count + hlen,
1604− msg->msg_flags & MSG_DONTWAIT, &err);
1605−
1606− if (!skb)
1607− return ERR_PTR(err);
1887+ msg->msg_flags & MSG_DONTWAIT);
1888+ if (IS_ERR(skb))
1889+ return skb;
16081890
16091891 skb->priority = priority;
16101892
16111893 /* Create L2CAP header */
16121894 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
16131895 lh->cid = cpu_to_le16(chan->dcid);
1614− lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE));
1615− put_unaligned_le16(chan->psm, skb_put(skb, 2));
1896+ lh->len = cpu_to_le16(len + L2CAP_PSMLEN_SIZE);
1897+ put_unaligned(chan->psm, skb_put(skb, L2CAP_PSMLEN_SIZE));
16161898
16171899 err = l2cap_skbuff_fromiovec(chan, msg, len, count, skb);
16181900 if (unlikely(err < 0)) {
@@ -1628,25 +1910,24 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, · 9 unmodified lines
16281910 {
16291911 struct l2cap_conn *conn = chan->conn;
16301912 struct sk_buff *skb;
1631− int err, count, hlen = L2CAP_HDR_SIZE;
1913+ int err, count;
16321914 struct l2cap_hdr *lh;
16331915
16341916 BT_DBG("chan %p len %d", chan, (int)len);
16351917
1636− count = min_t(unsigned int, (conn->mtu - hlen), len);
1918+ count = min_t(unsigned int, (conn->mtu - L2CAP_HDR_SIZE), len);
16371919
1638− skb = chan->ops->alloc_skb(chan, count + hlen,
1639− msg->msg_flags & MSG_DONTWAIT, &err);
1640−
1641− if (!skb)
1642− return ERR_PTR(err);
1920+ skb = chan->ops->alloc_skb(chan, count + L2CAP_HDR_SIZE,
1921+ msg->msg_flags & MSG_DONTWAIT);
1922+ if (IS_ERR(skb))
1923+ return skb;
16431924
16441925 skb->priority = priority;
16451926
16461927 /* Create L2CAP header */
16471928 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
16481929 lh->cid = cpu_to_le16(chan->dcid);
1649− lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE));
1930+ lh->len = cpu_to_le16(len);
16501931
16511932 err = l2cap_skbuff_fromiovec(chan, msg, len, count, skb);
16521933 if (unlikely(err < 0)) {
@@ -1658,7 +1939,7 @@ static struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, · 5 unmodified lines
16581939
16591940 static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan,
16601941 struct msghdr *msg, size_t len,
1661− u32 control, u16 sdulen)
1942+ u16 sdulen)
16621943 {
16631944 struct l2cap_conn *conn = chan->conn;
16641945 struct sk_buff *skb;
@@ -1684,17 +1965,16 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, · 19 unmodified lines
16841965 count = min_t(unsigned int, (conn->mtu - hlen), len);
16851966
16861967 skb = chan->ops->alloc_skb(chan, count + hlen,
1687− msg->msg_flags & MSG_DONTWAIT, &err);
1688−
1689− if (!skb)
1690− return ERR_PTR(err);
1968+ msg->msg_flags & MSG_DONTWAIT);
1969+ if (IS_ERR(skb))
1970+ return skb;
16911971
16921972 /* Create L2CAP header */
16931973 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
16941974 lh->cid = cpu_to_le16(chan->dcid);
16951975 lh->len = cpu_to_le16(len + (hlen - L2CAP_HDR_SIZE));
16961976
1697− __put_control(chan, control, skb_put(skb, __ctrl_size(chan)));
1977+ __put_control(chan, 0, skb_put(skb, __ctrl_size(chan)));
16981978
16991979 if (sdulen)
17001980 put_unaligned_le16(sdulen, skb_put(skb, L2CAP_SDULEN_SIZE));
@@ -1708,61 +1988,82 @@ static struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, · 7 unmodified lines
17081988 if (chan->fcs == L2CAP_FCS_CRC16)
17091989 put_unaligned_le16(0, skb_put(skb, L2CAP_FCS_SIZE));
17101990
1711− bt_cb(skb)->retries = 0;
1991+ bt_cb(skb)->control.retries = 0;
17121992 return skb;
17131993 }
17141994
1715−static int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
1995+static int l2cap_segment_sdu(struct l2cap_chan *chan,
1996+ struct sk_buff_head *seg_queue,
1997+ struct msghdr *msg, size_t len)
17161998 {
17171999 struct sk_buff *skb;
1718− struct sk_buff_head sar_queue;
1719− u32 control;
1720− size_t size = 0;
2000+ u16 sdu_len;
2001+ size_t pdu_len;
2002+ int err = 0;
2003+ u8 sar;
17212004
1722− skb_queue_head_init(&sar_queue);
1723− control = __set_ctrl_sar(chan, L2CAP_SAR_START);
1724− skb = l2cap_create_iframe_pdu(chan, msg, chan->remote_mps, control, len);
1725− if (IS_ERR(skb))
1726− return PTR_ERR(skb);
2005+ BT_DBG("chan %p, msg %p, len %d", chan, msg, (int)len);
17272006
1728− __skb_queue_tail(&sar_queue, skb);
1729− len -= chan->remote_mps;
1730− size += chan->remote_mps;
2007+ /* It is critical that ERTM PDUs fit in a single HCI fragment,
2008+ * so fragmented skbs are not used. The HCI layer's handling
2009+ * of fragmented skbs is not compatible with ERTM's queueing.
2010+ */
17312011
1732− while (len > 0) {
1733− size_t buflen;
2012+ /* PDU size is derived from the HCI MTU */
2013+ pdu_len = chan->conn->mtu;
17342014
1735− if (len > chan->remote_mps) {
1736− control = __set_ctrl_sar(chan, L2CAP_SAR_CONTINUE);
1737− buflen = chan->remote_mps;
1738− } else {
1739− control = __set_ctrl_sar(chan, L2CAP_SAR_END);
1740− buflen = len;
1741− }
2015+ pdu_len = min_t(size_t, pdu_len, L2CAP_BREDR_MAX_PAYLOAD);
2016+
2017+ /* Adjust for largest possible L2CAP overhead. */
2018+ pdu_len -= L2CAP_EXT_HDR_SIZE + L2CAP_FCS_SIZE;
2019+
2020+ /* Remote device may have requested smaller PDUs */
2021+ pdu_len = min_t(size_t, pdu_len, chan->remote_mps);
2022+
2023+ if (len <= pdu_len) {
2024+ sar = L2CAP_SAR_UNSEGMENTED;
2025+ sdu_len = 0;
2026+ pdu_len = len;
2027+ } else {
2028+ sar = L2CAP_SAR_START;
2029+ sdu_len = len;
2030+ pdu_len -= L2CAP_SDULEN_SIZE;
2031+ }
2032+
2033+ while (len > 0) {
2034+ skb = l2cap_create_iframe_pdu(chan, msg, pdu_len, sdu_len);
17422035
1743− skb = l2cap_create_iframe_pdu(chan, msg, buflen, control, 0);
17442036 if (IS_ERR(skb)) {
1745− skb_queue_purge(&sar_queue);
2037+ __skb_queue_purge(seg_queue);
17462038 return PTR_ERR(skb);
17472039 }
17482040
1749− __skb_queue_tail(&sar_queue, skb);
1750− len -= buflen;
1751− size += buflen;
2041+ bt_cb(skb)->control.sar = sar;
2042+ __skb_queue_tail(seg_queue, skb);
2043+
2044+ len -= pdu_len;
2045+ if (sdu_len) {
2046+ sdu_len = 0;
2047+ pdu_len += L2CAP_SDULEN_SIZE;
2048+ }
2049+
2050+ if (len <= pdu_len) {
2051+ sar = L2CAP_SAR_END;
2052+ pdu_len = len;
2053+ } else {
2054+ sar = L2CAP_SAR_CONTINUE;
2055+ }
17522056 }
1753− skb_queue_splice_tail(&sar_queue, &chan->tx_q);
1754− if (chan->tx_send_head == NULL)
1755− chan->tx_send_head = sar_queue.next;
17562057
1757− return size;
2058+ return err;
17582059 }
17592060
17602061 int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
17612062 u32 priority)
17622063 {
17632064 struct sk_buff *skb;
1764− u32 control;
17652065 int err;
2066+ struct sk_buff_head seg_queue;
17662067
17672068 /* Connectionless channel */
17682069 if (chan->chan_type == L2CAP_CHAN_CONN_LESS) {
@@ -1791,42 +2092,47 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, · 22 unmodified lines
17912092
17922093 case L2CAP_MODE_ERTM:
17932094 case L2CAP_MODE_STREAMING:
1794− /* Entire SDU fits into one PDU */
1795− if (len <= chan->remote_mps) {
1796− control = __set_ctrl_sar(chan, L2CAP_SAR_UNSEGMENTED);
1797− skb = l2cap_create_iframe_pdu(chan, msg, len, control,
1798− 0);
1799− if (IS_ERR(skb))
1800− return PTR_ERR(skb);
2095+ /* Check outgoing MTU */
2096+ if (len > chan->omtu) {
2097+ err = -EMSGSIZE;
2098+ break;
2099+ }
18012100
1802− __skb_queue_tail(&chan->tx_q, skb);
2101+ __skb_queue_head_init(&seg_queue);
18032102
1804− if (chan->tx_send_head == NULL)
1805− chan->tx_send_head = skb;
2103+ /* Do segmentation before calling in to the state machine,
2104+ * since it's possible to block while waiting for memory
2105+ * allocation.
2106+ */
2107+ err = l2cap_segment_sdu(chan, &seg_queue, msg, len);
18062108
1807− } else {
1808− /* Segment SDU into multiples PDUs */
1809− err = l2cap_sar_segment_sdu(chan, msg, len);
1810− if (err < 0)
1811− return err;
2109+ /* The channel could have been closed while segmenting,
2110+ * check that it is still connected.
2111+ */
2112+ if (chan->state != BT_CONNECTED) {
2113+ __skb_queue_purge(&seg_queue);
2114+ err = -ENOTCONN;
18122115 }
18132116
1814− if (chan->mode == L2CAP_MODE_STREAMING) {
1815− l2cap_streaming_send(chan);
1816− err = len;
2117+ if (err)
18172118 break;
1818− }
18192119
1820− if (test_bit(CONN_REMOTE_BUSY, &chan->conn_state) &&
1821− test_bit(CONN_WAIT_F, &chan->conn_state)) {
1822− err = len;
1823− break;
1824− }
2120+ if (chan->mode == L2CAP_MODE_ERTM && chan->tx_send_head == NULL)
2121+ chan->tx_send_head = seg_queue.next;
2122+ skb_queue_splice_tail_init(&seg_queue, &chan->tx_q);
2123+
2124+ if (chan->mode == L2CAP_MODE_ERTM)
2125+ err = l2cap_ertm_send(chan);
2126+ else
2127+ l2cap_streaming_send(chan);
18252128
1826− err = l2cap_ertm_send(chan);
18272129 if (err >= 0)
18282130 err = len;
18292131
2132+ /* If the skbs were not queued for sending, they'll still be in
2133+ * seg_queue and need to be purged.
2134+ */
2135+ __skb_queue_purge(&seg_queue);
18302136 break;
18312137
18322138 default:
@@ -2040,13 +2346,29 @@ static void l2cap_ack_timeout(struct work_struct *work) · 207 unmodified lines
20402346 l2cap_chan_put(chan);
20412347 }
20422348
2043−static inline void l2cap_ertm_init(struct l2cap_chan *chan)
2349+static inline int l2cap_ertm_init(struct l2cap_chan *chan)
20442350 {
2351+ int err;
2352+
2353+ chan->next_tx_seq = 0;
2354+ chan->expected_tx_seq = 0;
20452355 chan->expected_ack_seq = 0;
20462356 chan->unacked_frames = 0;
20472357 chan->buffer_seq = 0;
20482358 chan->num_acked = 0;
20492359 chan->frames_sent = 0;
2360+ chan->last_acked_seq = 0;
2361+ chan->sdu = NULL;
2362+ chan->sdu_last_frag = NULL;
2363+ chan->sdu_len = 0;
2364+
2365+ skb_queue_head_init(&chan->tx_q);
2366+
2367+ if (chan->mode != L2CAP_MODE_ERTM)
2368+ return 0;
2369+
2370+ chan->rx_state = L2CAP_RX_STATE_RECV;
2371+ chan->tx_state = L2CAP_TX_STATE_XMIT;
20502372
20512373 INIT_DELAYED_WORK(&chan->retrans_timer, l2cap_retrans_timeout);
20522374 INIT_DELAYED_WORK(&chan->monitor_timer, l2cap_monitor_timeout);
@@ -2055,6 +2377,11 @@ static inline void l2cap_ertm_init(struct l2cap_chan *chan) · 2 unmodified lines
20552377 skb_queue_head_init(&chan->srej_q);
20562378
20572379 INIT_LIST_HEAD(&chan->srej_l);
2380+ err = l2cap_seq_list_init(&chan->srej_list, chan->tx_win);
2381+ if (err < 0)
2382+ return err;
2383+
2384+ return l2cap_seq_list_init(&chan->retrans_list, chan->remote_tx_win);
20582385 }
20592386
20602387 static inline __u8 l2cap_select_mode(__u8 mode, __u16 remote_feat_mask)
@@ -2378,9 +2705,9 @@ done: · 317 unmodified lines
23782705 chan->remote_mps = size;
23792706
23802707 rfc.retrans_timeout =
2381− le16_to_cpu(L2CAP_DEFAULT_RETRANS_TO);
2708+ __constant_cpu_to_le16(L2CAP_DEFAULT_RETRANS_TO);
23822709 rfc.monitor_timeout =
2383− le16_to_cpu(L2CAP_DEFAULT_MONITOR_TO);
2710+ __constant_cpu_to_le16(L2CAP_DEFAULT_MONITOR_TO);
23842711
23852712 set_bit(CONF_MODE_DONE, &chan->conf_state);
23862713
@@ -2644,10 +2971,10 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd · 257 unmodified lines
26442971 u16 dcid = 0, scid = __le16_to_cpu(req->scid);
26452972 __le16 psm = req->psm;
26462973
2647− BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid);
2974+ BT_DBG("psm 0x%2.2x scid 0x%4.4x", __le16_to_cpu(psm), scid);
26482975
26492976 /* Check if we have socket listening on psm */
2650− pchan = l2cap_global_chan_by_psm(BT_LISTEN, psm, conn->src);
2977+ pchan = l2cap_global_chan_by_psm(BT_LISTEN, psm, conn->src, conn->dst);
26512978 if (!pchan) {
26522979 result = L2CAP_CR_BAD_PSM;
26532980 goto sendresp;
@@ -2706,7 +3033,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd · 52 unmodified lines
27063033
27073034 if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) {
27083035 if (l2cap_chan_check_security(chan)) {
2709− if (bt_sk(sk)->defer_setup) {
3036+ if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) {
27103037 __l2cap_state_change(chan, BT_CONNECT2);
27113038 result = L2CAP_CR_PEND;
27123039 status = L2CAP_CS_AUTHOR_PEND;
@@ -2848,7 +3175,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr · 135 unmodified lines
28483175 u16 dcid, flags;
28493176 u8 rsp[64];
28503177 struct l2cap_chan *chan;
2851− int len;
3178+ int len, err = 0;
28523179
28533180 dcid = __le16_to_cpu(req->dcid);
28543181 flags = __le16_to_cpu(req->flags);
@@ -2859,8 +3186,6 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr · 4 unmodified lines
28593186 if (!chan)
28603187 return -ENOENT;
28613188
2862− l2cap_chan_lock(chan);
2863−
28643189 if (chan->state != BT_CONFIG && chan->state != BT_CONNECT2) {
28653190 struct l2cap_cmd_rej_cid rej;
28663191
@@ -2915,13 +3240,15 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr · 48 unmodified lines
29153240
29163241 l2cap_state_change(chan, BT_CONNECTED);
29173242
2918− chan->next_tx_seq = 0;
2919− chan->expected_tx_seq = 0;
2920− skb_queue_head_init(&chan->tx_q);
2921− if (chan->mode == L2CAP_MODE_ERTM)
2922− l2cap_ertm_init(chan);
3243+ if (chan->mode == L2CAP_MODE_ERTM ||
3244+ chan->mode == L2CAP_MODE_STREAMING)
3245+ err = l2cap_ertm_init(chan);
3246+
3247+ if (err < 0)
3248+ l2cap_send_disconn_req(chan->conn, chan, -err);
3249+ else
3250+ l2cap_chan_ready(chan);
29233251
2924− l2cap_chan_ready(chan);
29253252 goto unlock;
29263253 }
29273254
@@ -2949,7 +3276,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr · 21 unmodified lines
29493276
29503277 unlock:
29513278 l2cap_chan_unlock(chan);
2952− return 0;
3279+ return err;
29533280 }
29543281
29553282 static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
@@ -2957,21 +3284,20 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr · 1 unmodified line
29573284 struct l2cap_conf_rsp *rsp = (struct l2cap_conf_rsp *)data;
29583285 u16 scid, flags, result;
29593286 struct l2cap_chan *chan;
2960− int len = cmd->len - sizeof(*rsp);
3287+ int len = le16_to_cpu(cmd->len) - sizeof(*rsp);
3288+ int err = 0;
29613289
29623290 scid = __le16_to_cpu(rsp->scid);
29633291 flags = __le16_to_cpu(rsp->flags);
29643292 result = __le16_to_cpu(rsp->result);
29653293
2966− BT_DBG("scid 0x%4.4x flags 0x%2.2x result 0x%2.2x",
2967− scid, flags, result);
3294+ BT_DBG("scid 0x%4.4x flags 0x%2.2x result 0x%2.2x len %d", scid, flags,
3295+ result, len);
29683296
29693297 chan = l2cap_get_chan_by_scid(conn, scid);
29703298 if (!chan)
29713299 return 0;
29723300
2973− l2cap_chan_lock(chan);
2974−
29753301 switch (result) {
29763302 case L2CAP_CONF_SUCCESS:
29773303 l2cap_conf_rfc_get(chan, rsp->data, len);
@@ -3045,18 +3371,19 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr · 67 unmodified lines
30453371 set_default_fcs(chan);
30463372
30473373 l2cap_state_change(chan, BT_CONNECTED);
3048− chan->next_tx_seq = 0;
3049− chan->expected_tx_seq = 0;
3050− skb_queue_head_init(&chan->tx_q);
3051− if (chan->mode == L2CAP_MODE_ERTM)
3052− l2cap_ertm_init(chan);
3374+ if (chan->mode == L2CAP_MODE_ERTM ||
3375+ chan->mode == L2CAP_MODE_STREAMING)
3376+ err = l2cap_ertm_init(chan);
30533377
3054− l2cap_chan_ready(chan);
3378+ if (err < 0)
3379+ l2cap_send_disconn_req(chan->conn, chan, -err);
3380+ else
3381+ l2cap_chan_ready(chan);
30553382 }
30563383
30573384 done:
30583385 l2cap_chan_unlock(chan);
3059− return 0;
3386+ return err;
30603387 }
30613388
30623389 static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
@@ -3092,11 +3419,13 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd · 29 unmodified lines
30923419 sk->sk_shutdown = SHUTDOWN_MASK;
30933420 release_sock(sk);
30943421
3422+ l2cap_chan_hold(chan);
30953423 l2cap_chan_del(chan, ECONNRESET);
30963424
30973425 l2cap_chan_unlock(chan);
30983426
30993427 chan->ops->close(chan->data);
3428+ l2cap_chan_put(chan);
31003429
31013430 mutex_unlock(&conn->chan_lock);
31023431
@@ -3124,11 +3453,13 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd · 21 unmodified lines
31243453
31253454 l2cap_chan_lock(chan);
31263455
3456+ l2cap_chan_hold(chan);
31273457 l2cap_chan_del(chan, 0);
31283458
31293459 l2cap_chan_unlock(chan);
31303460
31313461 chan->ops->close(chan->data);
3462+ l2cap_chan_put(chan);
31323463
31333464 mutex_unlock(&conn->chan_lock);
31343465
@@ -3265,8 +3596,8 @@ static inline int l2cap_create_channel_req(struct l2cap_conn *conn, · 130 unmodified lines
32653596 /* Placeholder: Always reject */
32663597 rsp.dcid = 0;
32673598 rsp.scid = cpu_to_le16(scid);
3268− rsp.result = L2CAP_CR_NO_MEM;
3269− rsp.status = L2CAP_CS_NO_INFO;
3599+ rsp.result = __constant_cpu_to_le16(L2CAP_CR_NO_MEM);
3600+ rsp.status = __constant_cpu_to_le16(L2CAP_CS_NO_INFO);
32703601
32713602 l2cap_send_cmd(conn, cmd->ident, L2CAP_CREATE_CHAN_RSP,
32723603 sizeof(rsp), &rsp);
@@ -3665,19 +3996,19 @@ static int l2cap_add_to_srej_queue(struct l2cap_chan *chan, struct sk_buff *skb, · 392 unmodified lines
36653996 struct sk_buff *next_skb;
36663997 int tx_seq_offset, next_tx_seq_offset;
36673998
3668− bt_cb(skb)->tx_seq = tx_seq;
3669− bt_cb(skb)->sar = sar;
3999+ bt_cb(skb)->control.txseq = tx_seq;
4000+ bt_cb(skb)->control.sar = sar;
36704001
36714002 next_skb = skb_peek(&chan->srej_q);
36724003
36734004 tx_seq_offset = __seq_offset(chan, tx_seq, chan->buffer_seq);
36744005
36754006 while (next_skb) {
3676− if (bt_cb(next_skb)->tx_seq == tx_seq)
4007+ if (bt_cb(next_skb)->control.txseq == tx_seq)
36774008 return -EINVAL;
36784009
36794010 next_tx_seq_offset = __seq_offset(chan,
3680− bt_cb(next_skb)->tx_seq, chan->buffer_seq);
4011+ bt_cb(next_skb)->control.txseq, chan->buffer_seq);
36814012
36824013 if (next_tx_seq_offset > tx_seq_offset) {
36834014 __skb_queue_before(&chan->srej_q, next_skb, skb);
@@ -3800,6 +4131,7 @@ static void l2cap_ertm_enter_local_busy(struct l2cap_chan *chan) · 116 unmodified lines
38004131 BT_DBG("chan %p, Enter local busy", chan);
38014132
38024133 set_bit(CONN_LOCAL_BUSY, &chan->conn_state);
4134+ l2cap_seq_list_clear(&chan->srej_list);
38034135
38044136 __set_ack_timer(chan);
38054137 }
@@ -3848,11 +4180,11 @@ static void l2cap_check_srej_gap(struct l2cap_chan *chan, u16 tx_seq) · 42 unmodified lines
38484180 !test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) {
38494181 int err;
38504182
3851− if (bt_cb(skb)->tx_seq != tx_seq)
4183+ if (bt_cb(skb)->control.txseq != tx_seq)
38524184 break;
38534185
38544186 skb = skb_dequeue(&chan->srej_q);
3855− control = __set_ctrl_sar(chan, bt_cb(skb)->sar);
4187+ control = __set_ctrl_sar(chan, bt_cb(skb)->control.sar);
38564188 err = l2cap_reassemble_sdu(chan, skb, control);
38574189
38584190 if (err < 0) {
@@ -3892,6 +4224,7 @@ static int l2cap_send_srejframe(struct l2cap_chan *chan, u16 tx_seq) · 33 unmodified lines
38924224 while (tx_seq != chan->expected_tx_seq) {
38934225 control = __set_ctrl_super(chan, L2CAP_SUPER_SREJ);
38944226 control |= __set_reqseq(chan, chan->expected_tx_seq);
4227+ l2cap_seq_list_append(&chan->srej_list, chan->expected_tx_seq);
38954228 l2cap_send_sframe(chan, control);
38964229
38974230 new = kzalloc(sizeof(struct srej_list), GFP_ATOMIC);
@@ -4022,8 +4355,8 @@ expected: · 124 unmodified lines
40224355 chan->expected_tx_seq = __next_seq(chan, chan->expected_tx_seq);
40234356
40244357 if (test_bit(CONN_SREJ_SENT, &chan->conn_state)) {
4025− bt_cb(skb)->tx_seq = tx_seq;
4026− bt_cb(skb)->sar = sar;
4358+ bt_cb(skb)->control.txseq = tx_seq;
4359+ bt_cb(skb)->control.sar = sar;
40274360 __skb_queue_tail(&chan->srej_q, skb);
40284361 return 0;
40294362 }
@@ -4220,6 +4553,8 @@ static int l2cap_ertm_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) · 190 unmodified lines
42204553 u16 req_seq;
42214554 int len, next_tx_seq_offset, req_seq_offset;
42224555
4556+ __unpack_control(chan, skb);
4557+
42234558 control = __get_control(chan, skb->data);
42244559 skb_pull(skb, __ctrl_size(chan));
42254560 len = skb->len;
@@ -4295,8 +4630,6 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk · 69 unmodified lines
42954630 return 0;
42964631 }
42974632
4298− l2cap_chan_lock(chan);
4299−
43004633 BT_DBG("chan %p, len %d", chan, skb->len);
43014634
43024635 if (chan->state != BT_CONNECTED)
@@ -4375,7 +4708,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str · 72 unmodified lines
43754708 {
43764709 struct l2cap_chan *chan;
43774710
4378− chan = l2cap_global_chan_by_psm(0, psm, conn->src);
4711+ chan = l2cap_global_chan_by_psm(0, psm, conn->src, conn->dst);
43794712 if (!chan)
43804713 goto drop;
43814714
@@ -4396,11 +4729,12 @@ drop: · 14 unmodified lines
43964729 return 0;
43974730 }
43984731
4399−static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct sk_buff *skb)
4732+static inline int l2cap_att_channel(struct l2cap_conn *conn, u16 cid,
4733+ struct sk_buff *skb)
44004734 {
44014735 struct l2cap_chan *chan;
44024736
4403− chan = l2cap_global_chan_by_scid(0, cid, conn->src);
4737+ chan = l2cap_global_chan_by_scid(0, cid, conn->src, conn->dst);
44044738 if (!chan)
44054739 goto drop;
44064740
@@ -4445,7 +4779,7 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb) · 38 unmodified lines
44454779 break;
44464780
44474781 case L2CAP_CID_CONN_LESS:
4448− psm = get_unaligned_le16(skb->data);
4782+ psm = get_unaligned((__le16 *) skb->data);
44494783 skb_pull(skb, 2);
44504784 l2cap_conless_channel(conn, psm, skb);
44514785 break;
@@ -4540,7 +4874,6 @@ static inline void l2cap_check_encryption(struct l2cap_chan *chan, u8 encrypt) · 88 unmodified lines
45404874
45414875 if (encrypt == 0x00) {
45424876 if (chan->sec_level == BT_SECURITY_MEDIUM) {
4543− __clear_chan_timer(chan);
45444877 __set_chan_timer(chan, L2CAP_ENC_TIMEOUT);
45454878 } else if (chan->sec_level == BT_SECURITY_HIGH)
45464879 l2cap_chan_close(chan, ECONNREFUSED);
@@ -4561,7 +4894,8 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) · 14 unmodified lines
45614894 BT_DBG("conn %p", conn);
45624895
45634896 if (hcon->type == LE_LINK) {
4564− smp_distribute_keys(conn, 0);
4897+ if (!status && encrypt)
4898+ smp_distribute_keys(conn, 0);
45654899 cancel_delayed_work(&conn->security_timer);
45664900 }
45674901
@@ -4591,7 +4925,7 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) · 23 unmodified lines
45914925 chan->state == BT_CONFIG)) {
45924926 struct sock *sk = chan->sk;
45934927
4594− bt_sk(sk)->suspended = false;
4928+ clear_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags);
45954929 sk->sk_state_change(sk);
45964930
45974931 l2cap_check_encryption(chan, encrypt);
@@ -4603,7 +4937,6 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) · 5 unmodified lines
46034937 if (!status) {
46044938 l2cap_send_conn_req(chan);
46054939 } else {
4606− __clear_chan_timer(chan);
46074940 __set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
46084941 }
46094942 } else if (chan->state == BT_CONNECT2) {
@@ -4614,7 +4947,8 @@ int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) · 4 unmodified lines
46144947 lock_sock(sk);
46154948
46164949 if (!status) {
4617− if (bt_sk(sk)->defer_setup) {
4950+ if (test_bit(BT_SK_DEFER_SETUP,
4951+ &bt_sk(sk)->flags)) {
46184952 struct sock *parent = bt_sk(sk)->parent;
46194953 res = L2CAP_CR_PEND;
46204954 stat = L2CAP_CS_AUTHOR_PEND;
@@ -4664,8 +4998,6 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) · 43 unmodified lines
46644998
46654999 if (!(flags & ACL_CONT)) {
46665000 struct l2cap_hdr *hdr;
4667− struct l2cap_chan *chan;
4668− u16 cid;
46695001 int len;
46705002
46715003 if (conn->rx_len) {
@@ -4685,7 +5017,6 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) · 13 unmodified lines
46855017
46865018 hdr = (struct l2cap_hdr *) skb->data;
46875019 len = __le16_to_cpu(hdr->len) + L2CAP_HDR_SIZE;
4688− cid = __le16_to_cpu(hdr->cid);
46895020
46905021 if (len == skb->len) {
46915022 /* Complete frame received */
@@ -4702,23 +5033,6 @@ int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 flags) · 10 unmodified lines
47025033 goto drop;
47035034 }
47045035
4705− chan = l2cap_get_chan_by_scid(conn, cid);
4706−
4707− if (chan && chan->sk) {
4708− struct sock *sk = chan->sk;
4709− lock_sock(sk);
4710−
4711− if (chan->imtu < len - L2CAP_HDR_SIZE) {
4712− BT_ERR("Frame exceeding recv MTU (len %d, "
4713− "MTU %d)", len,
4714− chan->imtu);
4715− release_sock(sk);
4716− l2cap_conn_unreliable(conn, ECOMM);
4717− goto drop;
4718− }
4719− release_sock(sk);
4720− }
4721−
47225036 /* Allocate skb for the complete frame (with header) */
47235037 conn->rx_skb = bt_skb_alloc(len, GFP_ATOMIC);
47245038 if (!conn->rx_skb)
net/bluetooth/l2cap_sock.c+46−30
@@ -124,7 +124,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al · 123 unmodified lines
124124 return -EINVAL;
125125
126126 err = l2cap_chan_connect(chan, la.l2_psm, __le16_to_cpu(la.l2_cid),
127− &la.l2_bdaddr);
127+ &la.l2_bdaddr, la.l2_bdaddr_type);
128128 if (err)
129129 return err;
130130
@@ -148,12 +148,16 @@ static int l2cap_sock_listen(struct socket *sock, int backlog) · 17 unmodified lines
148148
149149 lock_sock(sk);
150150
151− if ((sock->type != SOCK_SEQPACKET && sock->type != SOCK_STREAM)
152− || sk->sk_state != BT_BOUND) {
151+ if (sk->sk_state != BT_BOUND) {
153152 err = -EBADFD;
154153 goto done;
155154 }
156155
156+ if (sk->sk_type != SOCK_SEQPACKET && sk->sk_type != SOCK_STREAM) {
157+ err = -EINVAL;
158+ goto done;
159+ }
160+
157161 switch (chan->mode) {
158162 case L2CAP_MODE_BASIC:
159163 break;
@@ -320,8 +324,8 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us · 160 unmodified lines
320324
321325 case L2CAP_CONNINFO:
322326 if (sk->sk_state != BT_CONNECTED &&
323− !(sk->sk_state == BT_CONNECT2 &&
324− bt_sk(sk)->defer_setup)) {
327+ !(sk->sk_state == BT_CONNECT2 &&
328+ test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags))) {
325329 err = -ENOTCONN;
326330 break;
327331 }
@@ -375,7 +379,10 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch · 47 unmodified lines
375379 }
376380
377381 memset(&sec, 0, sizeof(sec));
378− sec.level = chan->sec_level;
382+ if (chan->conn)
383+ sec.level = chan->conn->hcon->sec_level;
384+ else
385+ sec.level = chan->sec_level;
379386
380387 if (sk->sk_state == BT_CONNECTED)
381388 sec.key_size = chan->conn->hcon->enc_key_size;
@@ -392,7 +399,8 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch · 10 unmodified lines
392399 break;
393400 }
394401
395− if (put_user(bt_sk(sk)->defer_setup, (u32 __user *) optval))
402+ if (put_user(test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags),
403+ (u32 __user *) optval))
396404 err = -EFAULT;
397405
398406 break;
@@ -594,10 +602,10 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch · 195 unmodified lines
594602
595603 /* or for ACL link */
596604 } else if ((sk->sk_state == BT_CONNECT2 &&
597− bt_sk(sk)->defer_setup) ||
605+ test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) ||
598606 sk->sk_state == BT_CONNECTED) {
599607 if (!l2cap_chan_check_security(chan))
600− bt_sk(sk)->suspended = true;
608+ set_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags);
601609 else
602610 sk->sk_state_change(sk);
603611 } else {
@@ -616,7 +624,10 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch · 12 unmodified lines
616624 break;
617625 }
618626
619− bt_sk(sk)->defer_setup = opt;
627+ if (opt)
628+ set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
629+ else
630+ clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
620631 break;
621632
622633 case BT_FLUSHABLE:
@@ -716,16 +727,13 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms · 93 unmodified lines
716727 if (msg->msg_flags & MSG_OOB)
717728 return -EOPNOTSUPP;
718729
719− lock_sock(sk);
720−
721− if (sk->sk_state != BT_CONNECTED) {
722− release_sock(sk);
730+ if (sk->sk_state != BT_CONNECTED)
723731 return -ENOTCONN;
724− }
725732
733+ l2cap_chan_lock(chan);
726734 err = l2cap_chan_send(chan, msg, len, sk->sk_priority);
735+ l2cap_chan_unlock(chan);
727736
728− release_sock(sk);
729737 return err;
730738 }
731739
@@ -737,7 +745,8 @@ static int l2cap_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct ms · 5 unmodified lines
737745
738746 lock_sock(sk);
739747
740− if (sk->sk_state == BT_CONNECT2 && bt_sk(sk)->defer_setup) {
748+ if (sk->sk_state == BT_CONNECT2 && test_bit(BT_SK_DEFER_SETUP,
749+ &bt_sk(sk)->flags)) {
741750 sk->sk_state = BT_CONFIG;
742751 pi->chan->state = BT_CONFIG;
743752
@@ -931,12 +940,19 @@ static void l2cap_sock_state_change_cb(void *data, int state) · 187 unmodified lines
931940 }
932941
933942 static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
934− unsigned long len, int nb,
935− int *err)
943+ unsigned long len, int nb)
936944 {
937− struct sock *sk = chan->sk;
945+ struct sk_buff *skb;
946+ int err;
947+
948+ l2cap_chan_unlock(chan);
949+ skb = bt_skb_send_alloc(chan->sk, len, nb, &err);
950+ l2cap_chan_lock(chan);
951+
952+ if (!skb)
953+ return ERR_PTR(err);
938954
939− return bt_skb_send_alloc(sk, len, nb, err);
955+ return skb;
940956 }
941957
942958 static struct l2cap_ops l2cap_chan_ops = {
@@ -952,6 +968,7 @@ static void l2cap_sock_destruct(struct sock *sk) · 9 unmodified lines
952968 {
953969 BT_DBG("sk %p", sk);
954970
971+ l2cap_chan_put(l2cap_pi(sk)->chan);
955972 if (l2cap_pi(sk)->rx_busy_skb) {
956973 kfree_skb(l2cap_pi(sk)->rx_busy_skb);
957974 l2cap_pi(sk)->rx_busy_skb = NULL;
@@ -972,7 +989,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) · 14 unmodified lines
972989 struct l2cap_chan *pchan = l2cap_pi(parent)->chan;
973990
974991 sk->sk_type = parent->sk_type;
975− bt_sk(sk)->defer_setup = bt_sk(parent)->defer_setup;
992+ bt_sk(sk)->flags = bt_sk(parent)->flags;
976993
977994 chan->chan_type = pchan->chan_type;
978995 chan->imtu = pchan->imtu;
@@ -1010,13 +1027,8 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent) · 31 unmodified lines
10101027 } else {
10111028 chan->mode = L2CAP_MODE_BASIC;
10121029 }
1013− chan->max_tx = L2CAP_DEFAULT_MAX_TX;
1014− chan->fcs = L2CAP_FCS_CRC16;
1015− chan->tx_win = L2CAP_DEFAULT_TX_WINDOW;
1016− chan->tx_win_max = L2CAP_DEFAULT_TX_WINDOW;
1017− chan->sec_level = BT_SECURITY_LOW;
1018− chan->flags = 0;
1019− set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
1030+
1031+ l2cap_chan_set_defaults(chan);
10201032 }
10211033
10221034 /* Default config options */
@@ -1052,12 +1064,16 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, int p · 29 unmodified lines
10521064 sk->sk_protocol = proto;
10531065 sk->sk_state = BT_OPEN;
10541066
1055− chan = l2cap_chan_create(sk);
1067+ chan = l2cap_chan_create();
10561068 if (!chan) {
10571069 l2cap_sock_kill(sk);
10581070 return NULL;
10591071 }
10601072
1073+ l2cap_chan_hold(chan);
1074+
1075+ chan->sk = sk;
1076+
10611077 l2cap_pi(sk)->chan = chan;
10621078
10631079 return sk;
net/bluetooth/mgmt.c+172−114
@@ -35,10 +35,9 @@ · 34 unmodified lines
3535 #include <net/bluetooth/smp.h>
3636
3737 bool enable_hs;
38−bool enable_le;
3938
4039 #define MGMT_VERSION 1
41−#define MGMT_REVISION 0
40+#define MGMT_REVISION 1
4241
4342 static const u16 mgmt_commands[] = {
4443 MGMT_OP_READ_INDEX_LIST,
@@ -78,6 +77,7 @@ static const u16 mgmt_commands[] = { · 33 unmodified lines
7877 MGMT_OP_CONFIRM_NAME,
7978 MGMT_OP_BLOCK_DEVICE,
8079 MGMT_OP_UNBLOCK_DEVICE,
80+ MGMT_OP_SET_DEVICE_ID,
8181 };
8282
8383 static const u16 mgmt_events[] = {
@@ -224,7 +224,7 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status) · 140 unmodified lines
224224
225225 ev = (void *) skb_put(skb, sizeof(*ev));
226226 ev->status = status;
227− put_unaligned_le16(cmd, &ev->opcode);
227+ ev->opcode = cpu_to_le16(cmd);
228228
229229 err = sock_queue_rcv_skb(sk, skb);
230230 if (err < 0)
@@ -254,7 +254,7 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, u8 status, · 23 unmodified lines
254254 hdr->len = cpu_to_le16(sizeof(*ev) + rp_len);
255255
256256 ev = (void *) skb_put(skb, sizeof(*ev) + rp_len);
257− put_unaligned_le16(cmd, &ev->opcode);
257+ ev->opcode = cpu_to_le16(cmd);
258258 ev->status = status;
259259
260260 if (rp)
@@ -275,7 +275,7 @@ static int read_version(struct sock *sk, struct hci_dev *hdev, void *data, · 14 unmodified lines
275275 BT_DBG("sock %p", sk);
276276
277277 rp.version = MGMT_VERSION;
278− put_unaligned_le16(MGMT_REVISION, &rp.revision);
278+ rp.revision = __constant_cpu_to_le16(MGMT_REVISION);
279279
280280 return cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_VERSION, 0, &rp,
281281 sizeof(rp));
@@ -285,9 +285,9 @@ static int read_commands(struct sock *sk, struct hci_dev *hdev, void *data, · 3 unmodified lines
285285 u16 data_len)
286286 {
287287 struct mgmt_rp_read_commands *rp;
288− u16 num_commands = ARRAY_SIZE(mgmt_commands);
289− u16 num_events = ARRAY_SIZE(mgmt_events);
290− u16 *opcode;
288+ const u16 num_commands = ARRAY_SIZE(mgmt_commands);
289+ const u16 num_events = ARRAY_SIZE(mgmt_events);
290+ __le16 *opcode;
291291 size_t rp_size;
292292 int i, err;
293293
@@ -299,8 +299,8 @@ static int read_commands(struct sock *sk, struct hci_dev *hdev, void *data, · 5 unmodified lines
299299 if (!rp)
300300 return -ENOMEM;
301301
302− put_unaligned_le16(num_commands, &rp->num_commands);
303− put_unaligned_le16(num_events, &rp->num_events);
302+ rp->num_commands = __constant_cpu_to_le16(num_commands);
303+ rp->num_events = __constant_cpu_to_le16(num_events);
304304
305305 for (i = 0, opcode = rp->opcodes; i < num_commands; i++, opcode++)
306306 put_unaligned_le16(mgmt_commands[i], opcode);
@@ -341,14 +341,14 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data, · 34 unmodified lines
341341 return -ENOMEM;
342342 }
343343
344− put_unaligned_le16(count, &rp->num_controllers);
344+ rp->num_controllers = cpu_to_le16(count);
345345
346346 i = 0;
347347 list_for_each_entry(d, &hci_dev_list, list) {
348348 if (test_bit(HCI_SETUP, &d->dev_flags))
349349 continue;
350350
351− put_unaligned_le16(d->id, &rp->index[i++]);
351+ rp->index[i++] = cpu_to_le16(d->id);
352352 BT_DBG("Added hci%u", d->id);
353353 }
354354
@@ -383,10 +383,8 @@ static u32 get_supported_settings(struct hci_dev *hdev) · 28 unmodified lines
383383 if (enable_hs)
384384 settings |= MGMT_SETTING_HS;
385385
386− if (enable_le) {
387− if (hdev->features[4] & LMP_LE)
388− settings |= MGMT_SETTING_LE;
389− }
386+ if (hdev->features[4] & LMP_LE)
387+ settings |= MGMT_SETTING_LE;
390388
391389 return settings;
392390 }
@@ -442,9 +440,7 @@ static u16 get_uuid16(u8 *uuid128) · 49 unmodified lines
442440 return 0;
443441 }
444442
445− memcpy(&val, &uuid128[12], 4);
446−
447− val = le32_to_cpu(val);
443+ val = get_unaligned_le32(&uuid128[12]);
448444 if (val > 0xffff)
449445 return 0;
450446
@@ -479,6 +475,28 @@ static void create_eir(struct hci_dev *hdev, u8 *data) · 28 unmodified lines
479475 ptr += (name_len + 2);
480476 }
481477
478+ if (hdev->inq_tx_power) {
479+ ptr[0] = 2;
480+ ptr[1] = EIR_TX_POWER;
481+ ptr[2] = (u8) hdev->inq_tx_power;
482+
483+ eir_len += 3;
484+ ptr += 3;
485+ }
486+
487+ if (hdev->devid_source > 0) {
488+ ptr[0] = 9;
489+ ptr[1] = EIR_DEVICE_ID;
490+
491+ put_unaligned_le16(hdev->devid_source, ptr + 2);
492+ put_unaligned_le16(hdev->devid_vendor, ptr + 4);
493+ put_unaligned_le16(hdev->devid_product, ptr + 6);
494+ put_unaligned_le16(hdev->devid_version, ptr + 8);
495+
496+ eir_len += 10;
497+ ptr += 10;
498+ }
499+
482500 memset(uuid16_list, 0, sizeof(uuid16_list));
483501
484502 /* Group all UUID16 types */
@@ -642,8 +660,7 @@ static int read_controller_info(struct sock *sk, struct hci_dev *hdev, · 157 unmodified lines
642660 bacpy(&rp.bdaddr, &hdev->bdaddr);
643661
644662 rp.version = hdev->hci_ver;
645−
646− put_unaligned_le16(hdev->manufacturer, &rp.manufacturer);
663+ rp.manufacturer = cpu_to_le16(hdev->manufacturer);
647664
648665 rp.supported_settings = cpu_to_le32(get_supported_settings(hdev));
649666 rp.current_settings = cpu_to_le32(get_current_settings(hdev));
@@ -840,7 +857,7 @@ static int set_discoverable(struct sock *sk, struct hci_dev *hdev, void *data, · 190 unmodified lines
840857
841858 BT_DBG("request for %s", hdev->name);
842859
843− timeout = get_unaligned_le16(&cp->timeout);
860+ timeout = __le16_to_cpu(cp->timeout);
844861 if (!cp->val && timeout > 0)
845862 return cmd_status(sk, hdev->id, MGMT_OP_SET_DISCOVERABLE,
846863 MGMT_STATUS_INVALID_PARAMS);
@@ -1122,8 +1139,8 @@ static int set_ssp(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) · 275 unmodified lines
11221139 }
11231140
11241141 if (mgmt_pending_find(MGMT_OP_SET_SSP, hdev)) {
1125− err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
1126− MGMT_STATUS_BUSY);
1142+ err = cmd_status(sk, hdev->id, MGMT_OP_SET_SSP,
1143+ MGMT_STATUS_BUSY);
11271144 goto failed;
11281145 }
11291146
@@ -1179,7 +1196,7 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) · 49 unmodified lines
11791196
11801197 hci_dev_lock(hdev);
11811198
1182− if (!enable_le || !(hdev->features[4] & LMP_LE)) {
1199+ if (!(hdev->features[4] & LMP_LE)) {
11831200 err = cmd_status(sk, hdev->id, MGMT_OP_SET_LE,
11841201 MGMT_STATUS_NOT_SUPPORTED);
11851202 goto unlock;
@@ -1227,10 +1244,8 @@ static int set_le(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) · 41 unmodified lines
12271244
12281245 err = hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(hci_cp),
12291246 &hci_cp);
1230− if (err < 0) {
1247+ if (err < 0)
12311248 mgmt_pending_remove(cmd);
1232− goto unlock;
1233− }
12341249
12351250 unlock:
12361251 hci_dev_unlock(hdev);
@@ -1280,10 +1295,8 @@ static int add_uuid(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) · 43 unmodified lines
12801295 }
12811296
12821297 cmd = mgmt_pending_add(sk, MGMT_OP_ADD_UUID, hdev, data, len);
1283− if (!cmd) {
1298+ if (!cmd)
12841299 err = -ENOMEM;
1285− goto failed;
1286− }
12871300
12881301 failed:
12891302 hci_dev_unlock(hdev);
@@ -1368,10 +1381,8 @@ update_class: · 78 unmodified lines
13681381 }
13691382
13701383 cmd = mgmt_pending_add(sk, MGMT_OP_REMOVE_UUID, hdev, data, len);
1371− if (!cmd) {
1384+ if (!cmd)
13721385 err = -ENOMEM;
1373− goto unlock;
1374− }
13751386
13761387 unlock:
13771388 hci_dev_unlock(hdev);
@@ -1422,10 +1433,8 @@ static int set_dev_class(struct sock *sk, struct hci_dev *hdev, void *data, · 44 unmodified lines
14221433 }
14231434
14241435 cmd = mgmt_pending_add(sk, MGMT_OP_SET_DEV_CLASS, hdev, data, len);
1425− if (!cmd) {
1436+ if (!cmd)
14261437 err = -ENOMEM;
1427− goto unlock;
1428− }
14291438
14301439 unlock:
14311440 hci_dev_unlock(hdev);
@@ -1439,7 +1448,7 @@ static int load_link_keys(struct sock *sk, struct hci_dev *hdev, void *data, · 7 unmodified lines
14391448 u16 key_count, expected_len;
14401449 int i;
14411450
1442− key_count = get_unaligned_le16(&cp->key_count);
1451+ key_count = __le16_to_cpu(cp->key_count);
14431452
14441453 expected_len = sizeof(*cp) + key_count *
14451454 sizeof(struct mgmt_link_key_info);
@@ -1512,7 +1521,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, · 66 unmodified lines
15121521 goto unlock;
15131522 }
15141523
1515− if (cp->addr.type == MGMT_ADDR_BREDR)
1524+ if (cp->addr.type == BDADDR_BREDR)
15161525 err = hci_remove_link_key(hdev, &cp->addr.bdaddr);
15171526 else
15181527 err = hci_remove_ltk(hdev, &cp->addr.bdaddr);
@@ -1524,7 +1533,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, · 5 unmodified lines
15241533 }
15251534
15261535 if (cp->disconnect) {
1527− if (cp->addr.type == MGMT_ADDR_BREDR)
1536+ if (cp->addr.type == BDADDR_BREDR)
15281537 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK,
15291538 &cp->addr.bdaddr);
15301539 else
@@ -1548,7 +1557,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, · 17 unmodified lines
15481557 goto unlock;
15491558 }
15501559
1551− put_unaligned_le16(conn->handle, &dc.handle);
1560+ dc.handle = cpu_to_le16(conn->handle);
15521561 dc.reason = 0x13; /* Remote User Terminated Connection */
15531562 err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc);
15541563 if (err < 0)
@@ -1584,7 +1593,7 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, · 29 unmodified lines
15841593 goto failed;
15851594 }
15861595
1587− if (cp->addr.type == MGMT_ADDR_BREDR)
1596+ if (cp->addr.type == BDADDR_BREDR)
15881597 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->addr.bdaddr);
15891598 else
15901599 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->addr.bdaddr);
@@ -1601,7 +1610,7 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, · 10 unmodified lines
16011610 goto failed;
16021611 }
16031612
1604− put_unaligned_le16(conn->handle, &dc.handle);
1613+ dc.handle = cpu_to_le16(conn->handle);
16051614 dc.reason = 0x13; /* Remote User Terminated Connection */
16061615
16071616 err = hci_send_cmd(hdev, HCI_OP_DISCONNECT, sizeof(dc), &dc);
@@ -1613,22 +1622,22 @@ failed: · 5 unmodified lines
16131622 return err;
16141623 }
16151624
1616−static u8 link_to_mgmt(u8 link_type, u8 addr_type)
1625+static u8 link_to_bdaddr(u8 link_type, u8 addr_type)
16171626 {
16181627 switch (link_type) {
16191628 case LE_LINK:
16201629 switch (addr_type) {
16211630 case ADDR_LE_DEV_PUBLIC:
1622− return MGMT_ADDR_LE_PUBLIC;
1623− case ADDR_LE_DEV_RANDOM:
1624− return MGMT_ADDR_LE_RANDOM;
1631+ return BDADDR_LE_PUBLIC;
1632+
16251633 default:
1626− return MGMT_ADDR_INVALID;
1634+ /* Fallback to LE Random address type */
1635+ return BDADDR_LE_RANDOM;
16271636 }
1628− case ACL_LINK:
1629− return MGMT_ADDR_BREDR;
1637+
16301638 default:
1631− return MGMT_ADDR_INVALID;
1639+ /* Fallback to BR/EDR type */
1640+ return BDADDR_BREDR;
16321641 }
16331642 }
16341643
@@ -1669,13 +1678,13 @@ static int get_connections(struct sock *sk, struct hci_dev *hdev, void *data, · 34 unmodified lines
16691678 if (!test_bit(HCI_CONN_MGMT_CONNECTED, &c->flags))
16701679 continue;
16711680 bacpy(&rp->addr[i].bdaddr, &c->dst);
1672− rp->addr[i].type = link_to_mgmt(c->type, c->dst_type);
1673− if (rp->addr[i].type == MGMT_ADDR_INVALID)
1681+ rp->addr[i].type = link_to_bdaddr(c->type, c->dst_type);
1682+ if (c->type == SCO_LINK || c->type == ESCO_LINK)
16741683 continue;
16751684 i++;
16761685 }
16771686
1678− put_unaligned_le16(i, &rp->conn_count);
1687+ rp->conn_count = cpu_to_le16(i);
16791688
16801689 /* Recalculate length in case of filtered SCO connections, etc */
16811690 rp_len = sizeof(*rp) + (i * sizeof(struct mgmt_addr_info));
@@ -1836,7 +1845,7 @@ static void pairing_complete(struct pending_cmd *cmd, u8 status) · 154 unmodified lines
18361845 struct hci_conn *conn = cmd->user_data;
18371846
18381847 bacpy(&rp.addr.bdaddr, &conn->dst);
1839− rp.addr.type = link_to_mgmt(conn->type, conn->dst_type);
1848+ rp.addr.type = link_to_bdaddr(conn->type, conn->dst_type);
18401849
18411850 cmd_complete(cmd->sk, cmd->index, MGMT_OP_PAIR_DEVICE, status,
18421851 &rp, sizeof(rp));
@@ -1890,12 +1899,12 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, · 47 unmodified lines
18901899 else
18911900 auth_type = HCI_AT_DEDICATED_BONDING_MITM;
18921901
1893− if (cp->addr.type == MGMT_ADDR_BREDR)
1894− conn = hci_connect(hdev, ACL_LINK, &cp->addr.bdaddr, sec_level,
1895− auth_type);
1902+ if (cp->addr.type == BDADDR_BREDR)
1903+ conn = hci_connect(hdev, ACL_LINK, &cp->addr.bdaddr,
1904+ cp->addr.type, sec_level, auth_type);
18961905 else
1897− conn = hci_connect(hdev, LE_LINK, &cp->addr.bdaddr, sec_level,
1898− auth_type);
1906+ conn = hci_connect(hdev, LE_LINK, &cp->addr.bdaddr,
1907+ cp->addr.type, sec_level, auth_type);
18991908
19001909 memset(&rp, 0, sizeof(rp));
19011910 bacpy(&rp.addr.bdaddr, &cp->addr.bdaddr);
@@ -1923,7 +1932,7 @@ static int pair_device(struct sock *sk, struct hci_dev *hdev, void *data, · 21 unmodified lines
19231932 }
19241933
19251934 /* For LE, just connecting isn't a proof that the pairing finished */
1926− if (cp->addr.type == MGMT_ADDR_BREDR)
1935+ if (cp->addr.type == BDADDR_BREDR)
19271936 conn->connect_cfm_cb = pairing_complete_cb;
19281937
19291938 conn->security_cfm_cb = pairing_complete_cb;
@@ -2000,7 +2009,7 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev, · 70 unmodified lines
20002009 goto done;
20012010 }
20022011
2003− if (type == MGMT_ADDR_BREDR)
2012+ if (type == BDADDR_BREDR)
20042013 conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, bdaddr);
20052014 else
20062015 conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr);
@@ -2011,7 +2020,7 @@ static int user_pairing_resp(struct sock *sk, struct hci_dev *hdev, · 4 unmodified lines
20112020 goto done;
20122021 }
20132022
2014− if (type == MGMT_ADDR_LE_PUBLIC || type == MGMT_ADDR_LE_RANDOM) {
2023+ if (type == BDADDR_LE_PUBLIC || type == BDADDR_LE_RANDOM) {
20152024 /* Continue with pairing via SMP */
20162025 err = smp_user_confirm_reply(conn, mgmt_op, passkey);
20172026
@@ -2295,6 +2304,12 @@ static int start_discovery(struct sock *sk, struct hci_dev *hdev, · 277 unmodified lines
22952304 goto failed;
22962305 }
22972306
2307+ if (test_bit(HCI_PERIODIC_INQ, &hdev->dev_flags)) {
2308+ err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
2309+ MGMT_STATUS_BUSY);
2310+ goto failed;
2311+ }
2312+
22982313 if (hdev->discovery.state != DISCOVERY_STOPPED) {
22992314 err = cmd_status(sk, hdev->id, MGMT_OP_START_DISCOVERY,
23002315 MGMT_STATUS_BUSY);
@@ -2381,27 +2396,39 @@ static int stop_discovery(struct sock *sk, struct hci_dev *hdev, void *data, · 80 unmodified lines
23812396 goto unlock;
23822397 }
23832398
2384− if (hdev->discovery.state == DISCOVERY_FINDING) {
2385− err = hci_cancel_inquiry(hdev);
2386− if (err < 0)
2387− mgmt_pending_remove(cmd);
2399+ switch (hdev->discovery.state) {
2400+ case DISCOVERY_FINDING:
2401+ if (test_bit(HCI_INQUIRY, &hdev->flags))
2402+ err = hci_cancel_inquiry(hdev);
23882403 else
2389− hci_discovery_set_state(hdev, DISCOVERY_STOPPING);
2390− goto unlock;
2391− }
2404+ err = hci_cancel_le_scan(hdev);
23922405
2393− e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY, NAME_PENDING);
2394− if (!e) {
2395− mgmt_pending_remove(cmd);
2396− err = cmd_complete(sk, hdev->id, MGMT_OP_STOP_DISCOVERY, 0,
2397− &mgmt_cp->type, sizeof(mgmt_cp->type));
2398− hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
2399− goto unlock;
2406+ break;
2407+
2408+ case DISCOVERY_RESOLVING:
2409+ e = hci_inquiry_cache_lookup_resolve(hdev, BDADDR_ANY,
2410+ NAME_PENDING);
2411+ if (!e) {
2412+ mgmt_pending_remove(cmd);
2413+ err = cmd_complete(sk, hdev->id,
2414+ MGMT_OP_STOP_DISCOVERY, 0,
2415+ &mgmt_cp->type,
2416+ sizeof(mgmt_cp->type));
2417+ hci_discovery_set_state(hdev, DISCOVERY_STOPPED);
2418+ goto unlock;
2419+ }
2420+
2421+ bacpy(&cp.bdaddr, &e->data.bdaddr);
2422+ err = hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ_CANCEL,
2423+ sizeof(cp), &cp);
2424+
2425+ break;
2426+
2427+ default:
2428+ BT_DBG("unknown discovery state %u", hdev->discovery.state);
2429+ err = -EFAULT;
24002430 }
24012431
2402− bacpy(&cp.bdaddr, &e->data.bdaddr);
2403− err = hci_send_cmd(hdev, HCI_OP_REMOTE_NAME_REQ_CANCEL, sizeof(cp),
2404− &cp);
24052432 if (err < 0)
24062433 mgmt_pending_remove(cmd);
24072434 else
@@ -2501,6 +2528,37 @@ static int unblock_device(struct sock *sk, struct hci_dev *hdev, void *data, · 93 unmodified lines
25012528 return err;
25022529 }
25032530
2531+static int set_device_id(struct sock *sk, struct hci_dev *hdev, void *data,
2532+ u16 len)
2533+{
2534+ struct mgmt_cp_set_device_id *cp = data;
2535+ int err;
2536+ __u16 source;
2537+
2538+ BT_DBG("%s", hdev->name);
2539+
2540+ source = __le16_to_cpu(cp->source);
2541+
2542+ if (source > 0x0002)
2543+ return cmd_status(sk, hdev->id, MGMT_OP_SET_DEVICE_ID,
2544+ MGMT_STATUS_INVALID_PARAMS);
2545+
2546+ hci_dev_lock(hdev);
2547+
2548+ hdev->devid_source = source;
2549+ hdev->devid_vendor = __le16_to_cpu(cp->vendor);
2550+ hdev->devid_product = __le16_to_cpu(cp->product);
2551+ hdev->devid_version = __le16_to_cpu(cp->version);
2552+
2553+ err = cmd_complete(sk, hdev->id, MGMT_OP_SET_DEVICE_ID, 0, NULL, 0);
2554+
2555+ update_eir(hdev);
2556+
2557+ hci_dev_unlock(hdev);
2558+
2559+ return err;
2560+}
2561+
25042562 static int set_fast_connectable(struct sock *sk, struct hci_dev *hdev,
25052563 void *data, u16 len)
25062564 {
@@ -2565,7 +2623,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, · 58 unmodified lines
25652623 u16 key_count, expected_len;
25662624 int i;
25672625
2568− key_count = get_unaligned_le16(&cp->key_count);
2626+ key_count = __le16_to_cpu(cp->key_count);
25692627
25702628 expected_len = sizeof(*cp) + key_count *
25712629 sizeof(struct mgmt_ltk_info);
@@ -2591,7 +2649,8 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, · 19 unmodified lines
25912649 else
25922650 type = HCI_SMP_LTK_SLAVE;
25932651
2594− hci_add_ltk(hdev, &key->addr.bdaddr, key->addr.type,
2652+ hci_add_ltk(hdev, &key->addr.bdaddr,
2653+ bdaddr_to_le(key->addr.type),
25952654 type, 0, key->authenticated, key->val,
25962655 key->enc_size, key->ediv, key->rand);
25972656 }
@@ -2601,7 +2660,7 @@ static int load_long_term_keys(struct sock *sk, struct hci_dev *hdev, · 3 unmodified lines
26012660 return 0;
26022661 }
26032662
2604−struct mgmt_handler {
2663+static const struct mgmt_handler {
26052664 int (*func) (struct sock *sk, struct hci_dev *hdev, void *data,
26062665 u16 data_len);
26072666 bool var_len;
@@ -2647,6 +2706,7 @@ struct mgmt_handler { · 39 unmodified lines
26472706 { confirm_name, false, MGMT_CONFIRM_NAME_SIZE },
26482707 { block_device, false, MGMT_BLOCK_DEVICE_SIZE },
26492708 { unblock_device, false, MGMT_UNBLOCK_DEVICE_SIZE },
2709+ { set_device_id, false, MGMT_SET_DEVICE_ID_SIZE },
26502710 };
26512711
26522712
@@ -2657,7 +2717,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) · 4 unmodified lines
26572717 struct mgmt_hdr *hdr;
26582718 u16 opcode, index, len;
26592719 struct hci_dev *hdev = NULL;
2660− struct mgmt_handler *handler;
2720+ const struct mgmt_handler *handler;
26612721 int err;
26622722
26632723 BT_DBG("got %zu bytes", msglen);
@@ -2675,9 +2735,9 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen) · 11 unmodified lines
26752735 }
26762736
26772737 hdr = buf;
2678− opcode = get_unaligned_le16(&hdr->opcode);
2679− index = get_unaligned_le16(&hdr->index);
2680− len = get_unaligned_le16(&hdr->len);
2738+ opcode = __le16_to_cpu(hdr->opcode);
2739+ index = __le16_to_cpu(hdr->index);
2740+ len = __le16_to_cpu(hdr->len);
26812741
26822742 if (len != msglen - sizeof(*hdr)) {
26832743 err = -EINVAL;
@@ -2884,7 +2944,8 @@ int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status) · 200 unmodified lines
28842944 return 0;
28852945 }
28862946
2887−int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, bool persistent)
2947+int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key,
2948+ bool persistent)
28882949 {
28892950 struct mgmt_ev_new_link_key ev;
28902951
@@ -2892,7 +2953,7 @@ int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, bool persisten · 1 unmodified line
28922953
28932954 ev.store_hint = persistent;
28942955 bacpy(&ev.key.addr.bdaddr, &key->bdaddr);
2895− ev.key.addr.type = MGMT_ADDR_BREDR;
2956+ ev.key.addr.type = BDADDR_BREDR;
28962957 ev.key.type = key->type;
28972958 memcpy(ev.key.val, key->val, 16);
28982959 ev.key.pin_len = key->pin_len;
@@ -2908,7 +2969,7 @@ int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent) · 9 unmodified lines
29082969
29092970 ev.store_hint = persistent;
29102971 bacpy(&ev.key.addr.bdaddr, &key->bdaddr);
2911− ev.key.addr.type = key->bdaddr_type;
2972+ ev.key.addr.type = link_to_bdaddr(LE_LINK, key->bdaddr_type);
29122973 ev.key.authenticated = key->authenticated;
29132974 ev.key.enc_size = key->enc_size;
29142975 ev.key.ediv = key->ediv;
@@ -2932,7 +2993,7 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, · 17 unmodified lines
29322993 u16 eir_len = 0;
29332994
29342995 bacpy(&ev->addr.bdaddr, bdaddr);
2935− ev->addr.type = link_to_mgmt(link_type, addr_type);
2996+ ev->addr.type = link_to_bdaddr(link_type, addr_type);
29362997
29372998 ev->flags = __cpu_to_le32(flags);
29382999
@@ -2944,7 +3005,7 @@ int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, · 5 unmodified lines
29443005 eir_len = eir_append_data(ev->eir, eir_len,
29453006 EIR_CLASS_OF_DEV, dev_class, 3);
29463007
2947− put_unaligned_le16(eir_len, &ev->eir_len);
3008+ ev->eir_len = cpu_to_le16(eir_len);
29483009
29493010 return mgmt_event(MGMT_EV_DEVICE_CONNECTED, hdev, buf,
29503011 sizeof(*ev) + eir_len, NULL);
@@ -2995,13 +3056,13 @@ int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, · 44 unmodified lines
29953056 mgmt_pending_foreach(MGMT_OP_DISCONNECT, hdev, disconnect_rsp, &sk);
29963057
29973058 bacpy(&ev.bdaddr, bdaddr);
2998− ev.type = link_to_mgmt(link_type, addr_type);
3059+ ev.type = link_to_bdaddr(link_type, addr_type);
29993060
30003061 err = mgmt_event(MGMT_EV_DEVICE_DISCONNECTED, hdev, &ev, sizeof(ev),
30013062 sk);
30023063
30033064 if (sk)
3004− sock_put(sk);
3065+ sock_put(sk);
30053066
30063067 mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp,
30073068 hdev);
@@ -3021,7 +3082,7 @@ int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, · 13 unmodified lines
30213082 return -ENOENT;
30223083
30233084 bacpy(&rp.addr.bdaddr, bdaddr);
3024− rp.addr.type = link_to_mgmt(link_type, addr_type);
3085+ rp.addr.type = link_to_bdaddr(link_type, addr_type);
30253086
30263087 err = cmd_complete(cmd->sk, cmd->index, MGMT_OP_DISCONNECT,
30273088 mgmt_status(status), &rp, sizeof(rp));
@@ -3039,7 +3100,7 @@ int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, · 11 unmodified lines
30393100 struct mgmt_ev_connect_failed ev;
30403101
30413102 bacpy(&ev.addr.bdaddr, bdaddr);
3042− ev.addr.type = link_to_mgmt(link_type, addr_type);
3103+ ev.addr.type = link_to_bdaddr(link_type, addr_type);
30433104 ev.status = mgmt_status(status);
30443105
30453106 return mgmt_event(MGMT_EV_CONNECT_FAILED, hdev, &ev, sizeof(ev), NULL);
@@ -3050,7 +3111,7 @@ int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure) · 4 unmodified lines
30503111 struct mgmt_ev_pin_code_request ev;
30513112
30523113 bacpy(&ev.addr.bdaddr, bdaddr);
3053− ev.addr.type = MGMT_ADDR_BREDR;
3114+ ev.addr.type = BDADDR_BREDR;
30543115 ev.secure = secure;
30553116
30563117 return mgmt_event(MGMT_EV_PIN_CODE_REQUEST, hdev, &ev, sizeof(ev),
@@ -3069,7 +3130,7 @@ int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, · 12 unmodified lines
30693130 return -ENOENT;
30703131
30713132 bacpy(&rp.addr.bdaddr, bdaddr);
3072− rp.addr.type = MGMT_ADDR_BREDR;
3133+ rp.addr.type = BDADDR_BREDR;
30733134
30743135 err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_REPLY,
30753136 mgmt_status(status), &rp, sizeof(rp));
@@ -3091,7 +3152,7 @@ int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, · 15 unmodified lines
30913152 return -ENOENT;
30923153
30933154 bacpy(&rp.addr.bdaddr, bdaddr);
3094− rp.addr.type = MGMT_ADDR_BREDR;
3155+ rp.addr.type = BDADDR_BREDR;
30953156
30963157 err = cmd_complete(cmd->sk, hdev->id, MGMT_OP_PIN_CODE_NEG_REPLY,
30973158 mgmt_status(status), &rp, sizeof(rp));
@@ -3110,9 +3171,9 @@ int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, · 12 unmodified lines
31103171 BT_DBG("%s", hdev->name);
31113172
31123173 bacpy(&ev.addr.bdaddr, bdaddr);
3113− ev.addr.type = link_to_mgmt(link_type, addr_type);
3174+ ev.addr.type = link_to_bdaddr(link_type, addr_type);
31143175 ev.confirm_hint = confirm_hint;
3115− put_unaligned_le32(value, &ev.value);
3176+ ev.value = value;
31163177
31173178 return mgmt_event(MGMT_EV_USER_CONFIRM_REQUEST, hdev, &ev, sizeof(ev),
31183179 NULL);
@@ -3126,7 +3187,7 @@ int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr, · 7 unmodified lines
31263187 BT_DBG("%s", hdev->name);
31273188
31283189 bacpy(&ev.addr.bdaddr, bdaddr);
3129− ev.addr.type = link_to_mgmt(link_type, addr_type);
3190+ ev.addr.type = link_to_bdaddr(link_type, addr_type);
31303191
31313192 return mgmt_event(MGMT_EV_USER_PASSKEY_REQUEST, hdev, &ev, sizeof(ev),
31323193 NULL);
@@ -3145,7 +3206,7 @@ static int user_pairing_resp_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, · 12 unmodified lines
31453206 return -ENOENT;
31463207
31473208 bacpy(&rp.addr.bdaddr, bdaddr);
3148− rp.addr.type = link_to_mgmt(link_type, addr_type);
3209+ rp.addr.type = link_to_bdaddr(link_type, addr_type);
31493210 err = cmd_complete(cmd->sk, hdev->id, opcode, mgmt_status(status),
31503211 &rp, sizeof(rp));
31513212
@@ -3188,7 +3249,7 @@ int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, · 36 unmodified lines
31883249 struct mgmt_ev_auth_failed ev;
31893250
31903251 bacpy(&ev.addr.bdaddr, bdaddr);
3191− ev.addr.type = link_to_mgmt(link_type, addr_type);
3252+ ev.addr.type = link_to_bdaddr(link_type, addr_type);
31923253 ev.status = mgmt_status(status);
31933254
31943255 return mgmt_event(MGMT_EV_AUTH_FAILED, hdev, &ev, sizeof(ev), NULL);
@@ -3413,10 +3474,10 @@ int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status) · 218 unmodified lines
34133474
34143475 if (enable && test_and_clear_bit(HCI_LE_ENABLED,
34153476 &hdev->dev_flags))
3416− err = new_settings(hdev, NULL);
3477+ err = new_settings(hdev, NULL);
34173478
3418− mgmt_pending_foreach(MGMT_OP_SET_LE, hdev,
3419− cmd_status_rsp, &mgmt_err);
3479+ mgmt_pending_foreach(MGMT_OP_SET_LE, hdev, cmd_status_rsp,
3480+ &mgmt_err);
34203481
34213482 return err;
34223483 }
@@ -3455,7 +3516,7 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, · 32 unmodified lines
34553516 memset(buf, 0, sizeof(buf));
34563517
34573518 bacpy(&ev->addr.bdaddr, bdaddr);
3458− ev->addr.type = link_to_mgmt(link_type, addr_type);
3519+ ev->addr.type = link_to_bdaddr(link_type, addr_type);
34593520 ev->rssi = rssi;
34603521 if (cfm_name)
34613522 ev->flags[0] |= MGMT_DEV_FOUND_CONFIRM_NAME;
@@ -3469,7 +3530,7 @@ int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, · 7 unmodified lines
34693530 eir_len = eir_append_data(ev->eir, eir_len, EIR_CLASS_OF_DEV,
34703531 dev_class, 3);
34713532
3472− put_unaligned_le16(eir_len, &ev->eir_len);
3533+ ev->eir_len = cpu_to_le16(eir_len);
34733534
34743535 ev_size = sizeof(*ev) + eir_len;
34753536
@@ -3488,13 +3549,13 @@ int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, · 12 unmodified lines
34883549 memset(buf, 0, sizeof(buf));
34893550
34903551 bacpy(&ev->addr.bdaddr, bdaddr);
3491− ev->addr.type = link_to_mgmt(link_type, addr_type);
3552+ ev->addr.type = link_to_bdaddr(link_type, addr_type);
34923553 ev->rssi = rssi;
34933554
34943555 eir_len = eir_append_data(ev->eir, 0, EIR_NAME_COMPLETE, name,
34953556 name_len);
34963557
3497− put_unaligned_le16(eir_len, &ev->eir_len);
3558+ ev->eir_len = cpu_to_le16(eir_len);
34983559
34993560 return mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev,
35003561 sizeof(*ev) + eir_len, NULL);
@@ -3594,6 +3655,3 @@ int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type) · 93 unmodified lines
35943655
35953656 module_param(enable_hs, bool, 0644);
35963657 MODULE_PARM_DESC(enable_hs, "Enable High Speed support");
3597−
3598−module_param(enable_le, bool, 0644);
3599−MODULE_PARM_DESC(enable_le, "Enable Low Energy support");
net/bluetooth/rfcomm/sock.c+10−4
@@ -260,7 +260,8 @@ static void rfcomm_sock_init(struct sock *sk, struct sock *parent) · 259 unmodified lines
260260
261261 if (parent) {
262262 sk->sk_type = parent->sk_type;
263− pi->dlc->defer_setup = bt_sk(parent)->defer_setup;
263+ pi->dlc->defer_setup = test_bit(BT_SK_DEFER_SETUP,
264+ &bt_sk(parent)->flags);
264265
265266 pi->sec_level = rfcomm_pi(parent)->sec_level;
266267 pi->role_switch = rfcomm_pi(parent)->role_switch;
@@ -731,7 +732,11 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c · 464 unmodified lines
731732 break;
732733 }
733734
734− bt_sk(sk)->defer_setup = opt;
735+ if (opt)
736+ set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
737+ else
738+ clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags);
739+
735740 break;
736741
737742 default:
@@ -849,7 +854,8 @@ static int rfcomm_sock_getsockopt(struct socket *sock, int level, int optname, c · 111 unmodified lines
849854 break;
850855 }
851856
852− if (put_user(bt_sk(sk)->defer_setup, (u32 __user *) optval))
857+ if (put_user(test_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags),
858+ (u32 __user *) optval))
853859 err = -EFAULT;
854860
855861 break;
@@ -972,7 +978,7 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc * · 116 unmodified lines
972978 done:
973979 bh_unlock_sock(parent);
974980
975− if (bt_sk(parent)->defer_setup)
981+ if (test_bit(BT_SK_DEFER_SETUP, &bt_sk(parent)->flags))
976982 parent->sk_state_change(parent);
977983
978984 return result;
net/bluetooth/sco.c+44−31
@@ -61,8 +61,6 @@ static struct bt_sock_list sco_sk_list = { · 60 unmodified lines
6161 static void __sco_chan_add(struct sco_conn *conn, struct sock *sk, struct sock *parent);
6262 static void sco_chan_del(struct sock *sk, int err);
6363
64−static int sco_conn_del(struct hci_conn *conn, int err);
65−
6664 static void sco_sock_close(struct sock *sk);
6765 static void sco_sock_kill(struct sock *sk);
6866
@@ -95,12 +93,12 @@ static void sco_sock_clear_timer(struct sock *sk) · 26 unmodified lines
9593 }
9694
9795 /* ---- SCO connections ---- */
98−static struct sco_conn *sco_conn_add(struct hci_conn *hcon, __u8 status)
96+static struct sco_conn *sco_conn_add(struct hci_conn *hcon)
9997 {
10098 struct hci_dev *hdev = hcon->hdev;
10199 struct sco_conn *conn = hcon->sco_data;
102100
103− if (conn || status)
101+ if (conn)
104102 return conn;
105103
106104 conn = kzalloc(sizeof(struct sco_conn), GFP_ATOMIC);
@@ -195,13 +193,14 @@ static int sco_connect(struct sock *sk) · 88 unmodified lines
195193 else
196194 type = SCO_LINK;
197195
198− hcon = hci_connect(hdev, type, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING);
196+ hcon = hci_connect(hdev, type, dst, BDADDR_BREDR, BT_SECURITY_LOW,
197+ HCI_AT_NO_BONDING);
199198 if (IS_ERR(hcon)) {
200199 err = PTR_ERR(hcon);
201200 goto done;
202201 }
203202
204− conn = sco_conn_add(hcon, 0);
203+ conn = sco_conn_add(hcon);
205204 if (!conn) {
206205 hci_conn_put(hcon);
207206 err = -ENOMEM;
@@ -233,7 +232,7 @@ static inline int sco_send_frame(struct sock *sk, struct msghdr *msg, int len) · 25 unmodified lines
233232 {
234233 struct sco_conn *conn = sco_pi(sk)->conn;
235234 struct sk_buff *skb;
236− int err, count;
235+ int err;
237236
238237 /* Check outgoing MTU */
239238 if (len > conn->mtu)
@@ -241,20 +240,18 @@ static inline int sco_send_frame(struct sock *sk, struct msghdr *msg, int len) · 1 unmodified line
241240
242241 BT_DBG("sk %p len %d", sk, len);
243242
244− count = min_t(unsigned int, conn->mtu, len);
245− skb = bt_skb_send_alloc(sk, count,
246− msg->msg_flags & MSG_DONTWAIT, &err);
243+ skb = bt_skb_send_alloc(sk, len, msg->msg_flags & MSG_DONTWAIT, &err);
247244 if (!skb)
248245 return err;
249246
250− if (memcpy_fromiovec(skb_put(skb, count), msg->msg_iov, count)) {
247+ if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
251248 kfree_skb(skb);
252249 return -EFAULT;
253250 }
254251
255252 hci_send_sco(conn->hcon, skb);
256253
257− return count;
254+ return len;
258255 }
259256
260257 static inline void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb)
@@ -277,17 +274,20 @@ drop: · 16 unmodified lines
277274 }
278275
279276 /* -------- Socket interface ---------- */
280−static struct sock *__sco_get_sock_by_addr(bdaddr_t *ba)
277+static struct sock *__sco_get_sock_listen_by_addr(bdaddr_t *ba)
281278 {
282− struct sock *sk;
283279 struct hlist_node *node;
280+ struct sock *sk;
281+
282+ sk_for_each(sk, node, &sco_sk_list.head) {
283+ if (sk->sk_state != BT_LISTEN)
284+ continue;
284285
285− sk_for_each(sk, node, &sco_sk_list.head)
286286 if (!bacmp(&bt_sk(sk)->src, ba))
287− goto found;
288− sk = NULL;
289−found:
290− return sk;
287+ return sk;
288+ }
289+
290+ return NULL;
291291 }
292292
293293 /* Find socket listening on source bdaddr.
@@ -466,7 +466,6 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le · 172 unmodified lines
466466 {
467467 struct sockaddr_sco *sa = (struct sockaddr_sco *) addr;
468468 struct sock *sk = sock->sk;
469− bdaddr_t *src = &sa->sco_bdaddr;
470469 int err = 0;
471470
472471 BT_DBG("sk %p %s", sk, batostr(&sa->sco_bdaddr));
@@ -481,17 +480,14 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le · 8 unmodified lines
481480 goto done;
482481 }
483482
484− write_lock(&sco_sk_list.lock);
485−
486− if (bacmp(src, BDADDR_ANY) && __sco_get_sock_by_addr(src)) {
487− err = -EADDRINUSE;
488− } else {
489− /* Save source address */
490− bacpy(&bt_sk(sk)->src, &sa->sco_bdaddr);
491− sk->sk_state = BT_BOUND;
483+ if (sk->sk_type != SOCK_SEQPACKET) {
484+ err = -EINVAL;
485+ goto done;
492486 }
493487
494− write_unlock(&sco_sk_list.lock);
488+ bacpy(&bt_sk(sk)->src, &sa->sco_bdaddr);
489+
490+ sk->sk_state = BT_BOUND;
495491
496492 done:
497493 release_sock(sk);
@@ -537,21 +533,38 @@ done: · 39 unmodified lines
537533 static int sco_sock_listen(struct socket *sock, int backlog)
538534 {
539535 struct sock *sk = sock->sk;
536+ bdaddr_t *src = &bt_sk(sk)->src;
540537 int err = 0;
541538
542539 BT_DBG("sk %p backlog %d", sk, backlog);
543540
544541 lock_sock(sk);
545542
546− if (sk->sk_state != BT_BOUND || sock->type != SOCK_SEQPACKET) {
543+ if (sk->sk_state != BT_BOUND) {
547544 err = -EBADFD;
548545 goto done;
549546 }
550547
548+ if (sk->sk_type != SOCK_SEQPACKET) {
549+ err = -EINVAL;
550+ goto done;
551+ }
552+
553+ write_lock(&sco_sk_list.lock);
554+
555+ if (__sco_get_sock_listen_by_addr(src)) {
556+ err = -EADDRINUSE;
557+ goto unlock;
558+ }
559+
551560 sk->sk_max_ack_backlog = backlog;
552561 sk->sk_ack_backlog = 0;
562+
553563 sk->sk_state = BT_LISTEN;
554564
565+unlock:
566+ write_unlock(&sco_sk_list.lock);
567+
555568 done:
556569 release_sock(sk);
557570 return err;
@@ -923,7 +936,7 @@ int sco_connect_cfm(struct hci_conn *hcon, __u8 status) · 365 unmodified lines
923936 if (!status) {
924937 struct sco_conn *conn;
925938
926− conn = sco_conn_add(hcon, status);
939+ conn = sco_conn_add(hcon);
927940 if (conn)
928941 sco_conn_ready(conn);
929942 } else
net/bluetooth/smp.c+1−1
@@ -956,7 +956,7 @@ int smp_distribute_keys(struct l2cap_conn *conn, __u8 force) · 955 unmodified lines
956956 HCI_SMP_LTK_SLAVE, 1, authenticated,
957957 enc.ltk, smp->enc_key_size, ediv, ident.rand);
958958
959− ident.ediv = cpu_to_le16(ediv);
959+ ident.ediv = ediv;
960960
961961 smp_send_cmd(conn, SMP_CMD_MASTER_IDENT, sizeof(ident), &ident);
962962
net/ipv4/fib_semantics.c+6−6
@@ -145,6 +145,12 @@ static void free_fib_info_rcu(struct rcu_head *head) · 144 unmodified lines
145145 {
146146 struct fib_info *fi = container_of(head, struct fib_info, rcu);
147147
148+ change_nexthops(fi) {
149+ if (nexthop_nh->nh_dev)
150+ dev_put(nexthop_nh->nh_dev);
151+ } endfor_nexthops(fi);
152+
153+ release_net(fi->fib_net);
148154 if (fi->fib_metrics != (u32 *) dst_default_metrics)
149155 kfree(fi->fib_metrics);
150156 kfree(fi);
@@ -156,13 +162,7 @@ void free_fib_info(struct fib_info *fi) · 5 unmodified lines
156162 pr_warn("Freeing alive fib_info %p\n", fi);
157163 return;
158164 }
159− change_nexthops(fi) {
160− if (nexthop_nh->nh_dev)
161− dev_put(nexthop_nh->nh_dev);
162− nexthop_nh->nh_dev = NULL;
163− } endfor_nexthops(fi);
164165 fib_info_cnt--;
165− release_net(fi->fib_net);
166166 call_rcu(&fi->rcu, free_fib_info_rcu);
167167 }
168168
net/ipv4/route.c+1−0
@@ -3452,6 +3452,7 @@ int __init ip_rt_init(void) · 3451 unmodified lines
34523452 0,
34533453 &rt_hash_log,
34543454 &rt_hash_mask,
3455+ 0,
34553456 rhash_entries ? 0 : 512 * 1024);
34563457 memset(rt_hash_table, 0, (rt_hash_mask + 1) * sizeof(struct rt_hash_bucket));
34573458 rt_hash_lock_init();
net/ipv4/tcp.c+2−0
@@ -3514,6 +3514,7 @@ void __init tcp_init(void) · 3513 unmodified lines
35143514 0,
35153515 NULL,
35163516 &tcp_hashinfo.ehash_mask,
3517+ 0,
35173518 thash_entries ? 0 : 512 * 1024);
35183519 for (i = 0; i <= tcp_hashinfo.ehash_mask; i++) {
35193520 INIT_HLIST_NULLS_HEAD(&tcp_hashinfo.ehash[i].chain, i);
@@ -3530,6 +3531,7 @@ void __init tcp_init(void) · 10 unmodified lines
35303531 0,
35313532 &tcp_hashinfo.bhash_size,
35323533 NULL,
3534+ 0,
35333535 64 * 1024);
35343536 tcp_hashinfo.bhash_size = 1U << tcp_hashinfo.bhash_size;
35353537 for (i = 0; i < tcp_hashinfo.bhash_size; i++) {
net/ipv4/tcp_input.c+5−0
@@ -4555,6 +4555,11 @@ static bool tcp_try_coalesce(struct sock *sk, · 4554 unmodified lines
45554555
45564556 if (tcp_hdr(from)->fin)
45574557 return false;
4558+
4559+ /* Its possible this segment overlaps with prior segment in queue */
4560+ if (TCP_SKB_CB(from)->seq != TCP_SKB_CB(to)->end_seq)
4561+ return false;
4562+
45584563 if (!skb_try_coalesce(to, from, fragstolen, &delta))
45594564 return false;
45604565
net/ipv4/udp.c+10−20
@@ -2192,26 +2192,16 @@ void __init udp_table_init(struct udp_table *table, const char *name) · 2191 unmodified lines
21922192 {
21932193 unsigned int i;
21942194
2195− if (!CONFIG_BASE_SMALL)
2196− table->hash = alloc_large_system_hash(name,
2197− 2 * sizeof(struct udp_hslot),
2198− uhash_entries,
2199− 21, /* one slot per 2 MB */
2200− 0,
2201− &table->log,
2202− &table->mask,
2203− 64 * 1024);
2204− /*
2205− * Make sure hash table has the minimum size
2206− */
2207− if (CONFIG_BASE_SMALL || table->mask < UDP_HTABLE_SIZE_MIN - 1) {
2208− table->hash = kmalloc(UDP_HTABLE_SIZE_MIN *
2209− 2 * sizeof(struct udp_hslot), GFP_KERNEL);
2210− if (!table->hash)
2211− panic(name);
2212− table->log = ilog2(UDP_HTABLE_SIZE_MIN);
2213− table->mask = UDP_HTABLE_SIZE_MIN - 1;
2214− }
2195+ table->hash = alloc_large_system_hash(name,
2196+ 2 * sizeof(struct udp_hslot),
2197+ uhash_entries,
2198+ 21, /* one slot per 2 MB */
2199+ 0,
2200+ &table->log,
2201+ &table->mask,
2202+ UDP_HTABLE_SIZE_MIN,
2203+ 64 * 1024);
2204+
22152205 table->hash2 = table->hash + (table->mask + 1);
22162206 for (i = 0; i <= table->mask; i++) {
22172207 INIT_HLIST_NULLS_HEAD(&table->hash[i].head, i);
net/mac80211/agg-tx.c+8−2
@@ -421,16 +421,22 @@ static void sta_tx_agg_session_timer_expired(unsigned long data) · 420 unmodified lines
421421 struct tid_ampdu_tx *tid_tx;
422422 unsigned long timeout;
423423
424− tid_tx = rcu_dereference_protected_tid_tx(sta, *ptid);
425− if (!tid_tx)
424+ rcu_read_lock();
425+ tid_tx = rcu_dereference(sta->ampdu_mlme.tid_tx[*ptid]);
426+ if (!tid_tx || test_bit(HT_AGG_STATE_STOPPING, &tid_tx->state)) {
427+ rcu_read_unlock();
426428 return;
429+ }
427430
428431 timeout = tid_tx->last_tx + TU_TO_JIFFIES(tid_tx->timeout);
429432 if (time_is_after_jiffies(timeout)) {
430433 mod_timer(&tid_tx->session_timer, timeout);
434+ rcu_read_unlock();
431435 return;
432436 }
433437
438+ rcu_read_unlock();
439+
434440 #ifdef CONFIG_MAC80211_HT_DEBUG
435441 printk(KERN_DEBUG "tx session timer expired on tid %d\n", (u16)*ptid);
436442 #endif
net/mac80211/debugfs_netdev.c+2−0
@@ -509,6 +509,7 @@ IEEE80211_IF_FILE(dot11MeshHWMPRannInterval, · 508 unmodified lines
509509 u.mesh.mshcfg.dot11MeshHWMPRannInterval, DEC);
510510 IEEE80211_IF_FILE(dot11MeshForwarding, u.mesh.mshcfg.dot11MeshForwarding, DEC);
511511 IEEE80211_IF_FILE(rssi_threshold, u.mesh.mshcfg.rssi_threshold, DEC);
512+IEEE80211_IF_FILE(ht_opmode, u.mesh.mshcfg.ht_opmode, DEC);
512513 #endif
513514
514515 #define DEBUGFS_ADD_MODE(name, mode) \
@@ -608,6 +609,7 @@ static void add_mesh_config(struct ieee80211_sub_if_data *sdata) · 93 unmodified lines
608609 MESHPARAMS_ADD(dot11MeshHWMPRannInterval);
609610 MESHPARAMS_ADD(dot11MeshGateAnnouncementProtocol);
610611 MESHPARAMS_ADD(rssi_threshold);
612+ MESHPARAMS_ADD(ht_opmode);
611613 #undef MESHPARAMS_ADD
612614 }
613615 #endif
net/mac80211/ibss.c+5−0
@@ -163,6 +163,11 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, · 162 unmodified lines
163163 sizeof(struct ieee80211_ht_operation));
164164 pos = ieee80211_ie_build_ht_cap(pos, &sband->ht_cap,
165165 sband->ht_cap.cap);
166+ /*
167+ * Note: According to 802.11n-2009 9.13.3.1, HT Protection
168+ * field and RIFS Mode are reserved in IBSS mode, therefore
169+ * keep them at 0
170+ */
166171 pos = ieee80211_ie_build_ht_oper(pos, &sband->ht_cap,
167172 chan, channel_type, 0);
168173 }
net/mac80211/iface.c+3−1
@@ -206,8 +206,10 @@ static void ieee80211_set_default_queues(struct ieee80211_sub_if_data *sdata) · 205 unmodified lines
206206 for (i = 0; i < IEEE80211_NUM_ACS; i++) {
207207 if (local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)
208208 sdata->vif.hw_queue[i] = IEEE80211_INVAL_HW_QUEUE;
209− else
209+ else if (local->hw.queues >= IEEE80211_NUM_ACS)
210210 sdata->vif.hw_queue[i] = i;
211+ else
212+ sdata->vif.hw_queue[i] = 0;
211213 }
212214 sdata->vif.cab_queue = IEEE80211_INVAL_HW_QUEUE;
213215 }
net/mac80211/main.c+3−0
@@ -596,6 +596,9 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, · 595 unmodified lines
596596 local->hw.offchannel_tx_hw_queue = IEEE80211_INVAL_HW_QUEUE;
597597 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
598598 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
599+ local->hw.radiotap_mcs_details = IEEE80211_RADIOTAP_MCS_HAVE_MCS |
600+ IEEE80211_RADIOTAP_MCS_HAVE_GI |
601+ IEEE80211_RADIOTAP_MCS_HAVE_BW;
599602 local->user_power_level = -1;
600603 wiphy->ht_capa_mod_mask = &mac80211_ht_capa_mod_mask;
601604
net/mac80211/mesh.c+4−2
@@ -109,8 +109,10 @@ bool mesh_matches_local(struct ieee80211_sub_if_data *sdata, · 108 unmodified lines
109109
110110 /* Disallow HT40+/- mismatch */
111111 if (ie->ht_operation &&
112− local->_oper_channel_type > NL80211_CHAN_HT20 &&
113− sta_channel_type > NL80211_CHAN_HT20 &&
112+ (local->_oper_channel_type == NL80211_CHAN_HT40MINUS ||
113+ local->_oper_channel_type == NL80211_CHAN_HT40PLUS) &&
114+ (sta_channel_type == NL80211_CHAN_HT40MINUS ||
115+ sta_channel_type == NL80211_CHAN_HT40PLUS) &&
114116 local->_oper_channel_type != sta_channel_type)
115117 goto mismatch;
116118
net/mac80211/mesh_hwmp.c+4−1
@@ -603,7 +603,10 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata, · 602 unmodified lines
603603 hopcount, ttl, cpu_to_le32(lifetime),
604604 cpu_to_le32(metric), cpu_to_le32(preq_id),
605605 sdata);
606− ifmsh->mshstats.fwded_mcast++;
606+ if (!is_multicast_ether_addr(da))
607+ ifmsh->mshstats.fwded_unicast++;
608+ else
609+ ifmsh->mshstats.fwded_mcast++;
607610 ifmsh->mshstats.fwded_frames++;
608611 }
609612 }
net/mac80211/mesh_plink.c+33−32
@@ -105,15 +105,15 @@ static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata, · 104 unmodified lines
105105 return sta;
106106 }
107107
108−/** mesh_set_ht_prot_mode - set correct HT protection mode
108+/*
109+ * mesh_set_ht_prot_mode - set correct HT protection mode
109110 *
110− * Section 9.23.3.5 of IEEE 80211s standard describes the protection rules for
111− * HT mesh STA in a MBSS. Three HT protection modes are supported for now,
112− * non-HT mixed mode, 20MHz-protection and no-protection mode. non-HT mixed
113− * mode is selected if any non-HT peers are present in our MBSS.
114− * 20MHz-protection mode is selected if all peers in our 20/40MHz MBSS support
115− * HT and atleast one HT20 peer is present. Otherwise no-protection mode is
116− * selected.
111+ * Section 9.23.3.5 of IEEE 80211-2012 describes the protection rules for HT
112+ * mesh STA in a MBSS. Three HT protection modes are supported for now, non-HT
113+ * mixed mode, 20MHz-protection and no-protection mode. non-HT mixed mode is
114+ * selected if any non-HT peers are present in our MBSS. 20MHz-protection mode
115+ * is selected if all peers in our 20/40MHz MBSS support HT and atleast one
116+ * HT20 peer is present. Otherwise no-protection mode is selected.
117117 */
118118 static u32 mesh_set_ht_prot_mode(struct ieee80211_sub_if_data *sdata)
119119 {
@@ -128,21 +128,22 @@ static u32 mesh_set_ht_prot_mode(struct ieee80211_sub_if_data *sdata) · 8 unmodified lines
128128
129129 rcu_read_lock();
130130 list_for_each_entry_rcu(sta, &local->sta_list, list) {
131− if (sdata == sta->sdata &&
132− sta->plink_state == NL80211_PLINK_ESTAB) {
133− switch (sta->ch_type) {
134− case NL80211_CHAN_NO_HT:
135− mpl_dbg("mesh_plink %pM: nonHT sta (%pM) is present",
136− sdata->vif.addr, sta->sta.addr);
137− non_ht_sta = true;
138− goto out;
139− case NL80211_CHAN_HT20:
140− mpl_dbg("mesh_plink %pM: HT20 sta (%pM) is present",
141− sdata->vif.addr, sta->sta.addr);
142− ht20_sta = true;
143− default:
144− break;
145− }
131+ if (sdata != sta->sdata ||
132+ sta->plink_state != NL80211_PLINK_ESTAB)
133+ continue;
134+
135+ switch (sta->ch_type) {
136+ case NL80211_CHAN_NO_HT:
137+ mpl_dbg("mesh_plink %pM: nonHT sta (%pM) is present",
138+ sdata->vif.addr, sta->sta.addr);
139+ non_ht_sta = true;
140+ goto out;
141+ case NL80211_CHAN_HT20:
142+ mpl_dbg("mesh_plink %pM: HT20 sta (%pM) is present",
143+ sdata->vif.addr, sta->sta.addr);
144+ ht20_sta = true;
145+ default:
146+ break;
146147 }
147148 }
148149 out:
@@ -346,6 +347,15 @@ static struct sta_info *mesh_peer_init(struct ieee80211_sub_if_data *sdata, · 197 unmodified lines
346347
347348 sta = sta_info_get(sdata, addr);
348349 if (!sta) {
350+ /* Userspace handles peer allocation when security is enabled */
351+ if (sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED) {
352+ cfg80211_notify_new_peer_candidate(sdata->dev, addr,
353+ elems->ie_start,
354+ elems->total_len,
355+ GFP_ATOMIC);
356+ return NULL;
357+ }
358+
349359 sta = mesh_plink_alloc(sdata, addr);
350360 if (!sta)
351361 return NULL;
@@ -387,15 +397,6 @@ void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata, · 35 unmodified lines
387397 {
388398 struct sta_info *sta;
389399
390− /* Userspace handles peer allocation when security is enabled */
391− if (sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED) {
392− cfg80211_notify_new_peer_candidate(sdata->dev, hw_addr,
393− elems->ie_start,
394− elems->total_len,
395− GFP_KERNEL);
396− return;
397− }
398−
399400 rcu_read_lock();
400401 sta = mesh_peer_init(sdata, hw_addr, elems);
401402 if (!sta)
net/mac80211/rx.c+3−3
@@ -204,14 +204,14 @@ ieee80211_add_rx_radiotap_header(struct ieee80211_local *local, · 203 unmodified lines
204204
205205 if (status->flag & RX_FLAG_HT) {
206206 rthdr->it_present |= cpu_to_le32(1 << IEEE80211_RADIOTAP_MCS);
207− *pos++ = IEEE80211_RADIOTAP_MCS_HAVE_MCS |
208− IEEE80211_RADIOTAP_MCS_HAVE_GI |
209− IEEE80211_RADIOTAP_MCS_HAVE_BW;
207+ *pos++ = local->hw.radiotap_mcs_details;
210208 *pos = 0;
211209 if (status->flag & RX_FLAG_SHORT_GI)
212210 *pos |= IEEE80211_RADIOTAP_MCS_SGI;
213211 if (status->flag & RX_FLAG_40MHZ)
214212 *pos |= IEEE80211_RADIOTAP_MCS_BW_40;
213+ if (status->flag & RX_FLAG_HT_GF)
214+ *pos |= IEEE80211_RADIOTAP_MCS_FMT_GF;
215215 pos++;
216216 *pos++ = status->rate_idx;
217217 }
net/mac80211/wep.c+12−3
@@ -92,6 +92,7 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, · 91 unmodified lines
9292 int keylen, int keyidx)
9393 {
9494 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
95+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
9596 unsigned int hdrlen;
9697 u8 *newhdr;
9798
@@ -104,6 +105,13 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, · 6 unmodified lines
104105 hdrlen = ieee80211_hdrlen(hdr->frame_control);
105106 newhdr = skb_push(skb, WEP_IV_LEN);
106107 memmove(newhdr, newhdr + WEP_IV_LEN, hdrlen);
108+
109+ /* the HW only needs room for the IV, but not the actual IV */
110+ if (info->control.hw_key &&
111+ (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE))
112+ return newhdr + hdrlen;
113+
114+ skb_set_network_header(skb, skb_network_offset(skb) + WEP_IV_LEN);
107115 ieee80211_wep_get_iv(local, keylen, keyidx, newhdr + hdrlen);
108116 return newhdr + hdrlen;
109117 }
@@ -313,14 +321,15 @@ ieee80211_crypto_wep_decrypt(struct ieee80211_rx_data *rx) · 203 unmodified lines
313321 static int wep_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb)
314322 {
315323 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
324+ struct ieee80211_key_conf *hw_key = info->control.hw_key;
316325
317− if (!info->control.hw_key) {
326+ if (!hw_key) {
318327 if (ieee80211_wep_encrypt(tx->local, skb, tx->key->conf.key,
319328 tx->key->conf.keylen,
320329 tx->key->conf.keyidx))
321330 return -1;
322− } else if (info->control.hw_key->flags &
323− IEEE80211_KEY_FLAG_GENERATE_IV) {
331+ } else if ((hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) ||
332+ (hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) {
324333 if (!ieee80211_wep_add_iv(tx->local, skb,
325334 tx->key->conf.keylen,
326335 tx->key->conf.keyidx))
net/mac80211/wpa.c+9−1
@@ -183,7 +183,8 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) · 182 unmodified lines
183183 u8 *pos;
184184
185185 if (info->control.hw_key &&
186− !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV)) {
186+ !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_GENERATE_IV) &&
187+ !(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) {
187188 /* hwaccel - with no need for software-generated IV */
188189 return 0;
189190 }
@@ -202,8 +203,14 @@ static int tkip_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) · 12 unmodified lines
202203
203204 pos = skb_push(skb, TKIP_IV_LEN);
204205 memmove(pos, pos + TKIP_IV_LEN, hdrlen);
206+ skb_set_network_header(skb, skb_network_offset(skb) + TKIP_IV_LEN);
205207 pos += hdrlen;
206208
209+ /* the HW only needs room for the IV, but not the actual IV */
210+ if (info->control.hw_key &&
211+ (info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE))
212+ return 0;
213+
207214 /* Increase IV for the frame */
208215 spin_lock_irqsave(&key->u.tkip.txlock, flags);
209216 key->u.tkip.tx.iv16++;
@@ -422,6 +429,7 @@ static int ccmp_encrypt_skb(struct ieee80211_tx_data *tx, struct sk_buff *skb) · 212 unmodified lines
422429
423430 pos = skb_push(skb, CCMP_HDR_LEN);
424431 memmove(pos, pos + CCMP_HDR_LEN, hdrlen);
432+ skb_set_network_header(skb, skb_network_offset(skb) + CCMP_HDR_LEN);
425433
426434 /* the HW only needs room for the IV, but not the actual IV */
427435 if (info->control.hw_key &&
net/nfc/core.c+85−27
@@ -97,7 +97,7 @@ int nfc_dev_down(struct nfc_dev *dev) · 96 unmodified lines
9797 goto error;
9898 }
9999
100− if (dev->polling || dev->activated_target_idx != NFC_TARGET_IDX_NONE) {
100+ if (dev->polling || dev->active_target) {
101101 rc = -EBUSY;
102102 goto error;
103103 }
@@ -183,11 +183,27 @@ error: · 79 unmodified lines
183183 return rc;
184184 }
185185
186+static struct nfc_target *nfc_find_target(struct nfc_dev *dev, u32 target_idx)
187+{
188+ int i;
189+
190+ if (dev->n_targets == 0)
191+ return NULL;
192+
193+ for (i = 0; i < dev->n_targets ; i++) {
194+ if (dev->targets[i].idx == target_idx)
195+ return &dev->targets[i];
196+ }
197+
198+ return NULL;
199+}
200+
186201 int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode)
187202 {
188203 int rc = 0;
189204 u8 *gb;
190205 size_t gb_len;
206+ struct nfc_target *target;
191207
192208 pr_debug("dev_name=%s comm %d\n", dev_name(&dev->dev), comm_mode);
193209
@@ -212,9 +228,15 @@ int nfc_dep_link_up(struct nfc_dev *dev, int target_index, u8 comm_mode) · 18 unmodified lines
212228 goto error;
213229 }
214230
215− rc = dev->ops->dep_link_up(dev, target_index, comm_mode, gb, gb_len);
231+ target = nfc_find_target(dev, target_index);
232+ if (target == NULL) {
233+ rc = -ENOTCONN;
234+ goto error;
235+ }
236+
237+ rc = dev->ops->dep_link_up(dev, target, comm_mode, gb, gb_len);
216238 if (!rc)
217− dev->activated_target_idx = target_index;
239+ dev->active_target = target;
218240
219241 error:
220242 device_unlock(&dev->dev);
@@ -250,7 +272,7 @@ int nfc_dep_link_down(struct nfc_dev *dev) · 29 unmodified lines
250272 rc = dev->ops->dep_link_down(dev);
251273 if (!rc) {
252274 dev->dep_link_up = false;
253− dev->activated_target_idx = NFC_TARGET_IDX_NONE;
275+ dev->active_target = NULL;
254276 nfc_llcp_mac_is_down(dev);
255277 nfc_genl_dep_link_down_event(dev);
256278 }
@@ -282,6 +304,7 @@ EXPORT_SYMBOL(nfc_dep_link_is_up); · 25 unmodified lines
282304 int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol)
283305 {
284306 int rc;
307+ struct nfc_target *target;
285308
286309 pr_debug("dev_name=%s target_idx=%u protocol=%u\n",
287310 dev_name(&dev->dev), target_idx, protocol);
@@ -293,9 +316,20 @@ int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol) · 5 unmodified lines
293316 goto error;
294317 }
295318
296− rc = dev->ops->activate_target(dev, target_idx, protocol);
319+ if (dev->active_target) {
320+ rc = -EBUSY;
321+ goto error;
322+ }
323+
324+ target = nfc_find_target(dev, target_idx);
325+ if (target == NULL) {
326+ rc = -ENOTCONN;
327+ goto error;
328+ }
329+
330+ rc = dev->ops->activate_target(dev, target, protocol);
297331 if (!rc) {
298− dev->activated_target_idx = target_idx;
332+ dev->active_target = target;
299333
300334 if (dev->ops->check_presence)
301335 mod_timer(&dev->check_pres_timer, jiffies +
@@ -327,11 +361,21 @@ int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx) · 25 unmodified lines
327361 goto error;
328362 }
329363
364+ if (dev->active_target == NULL) {
365+ rc = -ENOTCONN;
366+ goto error;
367+ }
368+
369+ if (dev->active_target->idx != target_idx) {
370+ rc = -ENOTCONN;
371+ goto error;
372+ }
373+
330374 if (dev->ops->check_presence)
331375 del_timer_sync(&dev->check_pres_timer);
332376
333− dev->ops->deactivate_target(dev, target_idx);
334− dev->activated_target_idx = NFC_TARGET_IDX_NONE;
377+ dev->ops->deactivate_target(dev, dev->active_target);
378+ dev->active_target = NULL;
335379
336380 error:
337381 device_unlock(&dev->dev);
@@ -365,13 +409,13 @@ int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, · 27 unmodified lines
365409 goto error;
366410 }
367411
368− if (dev->activated_target_idx == NFC_TARGET_IDX_NONE) {
412+ if (dev->active_target == NULL) {
369413 rc = -ENOTCONN;
370414 kfree_skb(skb);
371415 goto error;
372416 }
373417
374− if (target_idx != dev->activated_target_idx) {
418+ if (dev->active_target->idx != target_idx) {
375419 rc = -EADDRNOTAVAIL;
376420 kfree_skb(skb);
377421 goto error;
@@ -380,7 +424,8 @@ int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx, struct sk_buff *skb, · 2 unmodified lines
380424 if (dev->ops->check_presence)
381425 del_timer_sync(&dev->check_pres_timer);
382426
383− rc = dev->ops->data_exchange(dev, target_idx, skb, cb, cb_context);
427+ rc = dev->ops->data_exchange(dev, dev->active_target, skb, cb,
428+ cb_context);
384429
385430 if (!rc && dev->ops->check_presence)
386431 mod_timer(&dev->check_pres_timer, jiffies +
@@ -456,6 +501,9 @@ EXPORT_SYMBOL(nfc_alloc_recv_skb); · 69 unmodified lines
456501 * The device driver must call this function when one or many nfc targets
457502 * are found. After calling this function, the device driver must stop
458503 * polling for targets.
504+ * IMPORTANT: this function must not be called from an atomic context.
505+ * In addition, it must also not be called from a context that would prevent
506+ * the NFC Core to call other nfc ops entry point concurrently.
459507 */
460508 int nfc_targets_found(struct nfc_dev *dev,
461509 struct nfc_target *targets, int n_targets)
@@ -469,7 +517,7 @@ int nfc_targets_found(struct nfc_dev *dev, · 7 unmodified lines
469517 for (i = 0; i < n_targets; i++)
470518 targets[i].idx = dev->target_next_idx++;
471519
472− spin_lock_bh(&dev->targets_lock);
520+ device_lock(&dev->dev);
473521
474522 dev->targets_generation++;
475523
@@ -479,12 +527,12 @@ int nfc_targets_found(struct nfc_dev *dev, · 3 unmodified lines
479527
480528 if (!dev->targets) {
481529 dev->n_targets = 0;
482− spin_unlock_bh(&dev->targets_lock);
530+ device_unlock(&dev->dev);
483531 return -ENOMEM;
484532 }
485533
486534 dev->n_targets = n_targets;
487− spin_unlock_bh(&dev->targets_lock);
535+ device_unlock(&dev->dev);
488536
489537 nfc_genl_targets_found(dev);
490538
@@ -492,6 +540,18 @@ int nfc_targets_found(struct nfc_dev *dev, · 1 unmodified line
492540 }
493541 EXPORT_SYMBOL(nfc_targets_found);
494542
543+/**
544+ * nfc_target_lost - inform that an activated target went out of field
545+ *
546+ * @dev: The nfc device that had the activated target in field
547+ * @target_idx: the nfc index of the target
548+ *
549+ * The device driver must call this function when the activated target
550+ * goes out of the field.
551+ * IMPORTANT: this function must not be called from an atomic context.
552+ * In addition, it must also not be called from a context that would prevent
553+ * the NFC Core to call other nfc ops entry point concurrently.
554+ */
495555 int nfc_target_lost(struct nfc_dev *dev, u32 target_idx)
496556 {
497557 struct nfc_target *tg;
@@ -499,7 +559,7 @@ int nfc_target_lost(struct nfc_dev *dev, u32 target_idx) · 1 unmodified line
499559
500560 pr_debug("dev_name %s n_target %d\n", dev_name(&dev->dev), target_idx);
501561
502− spin_lock_bh(&dev->targets_lock);
562+ device_lock(&dev->dev);
503563
504564 for (i = 0; i < dev->n_targets; i++) {
505565 tg = &dev->targets[i];
@@ -508,13 +568,13 @@ int nfc_target_lost(struct nfc_dev *dev, u32 target_idx) · 2 unmodified lines
508568 }
509569
510570 if (i == dev->n_targets) {
511− spin_unlock_bh(&dev->targets_lock);
571+ device_unlock(&dev->dev);
512572 return -EINVAL;
513573 }
514574
515575 dev->targets_generation++;
516576 dev->n_targets--;
517− dev->activated_target_idx = NFC_TARGET_IDX_NONE;
577+ dev->active_target = NULL;
518578
519579 if (dev->n_targets) {
520580 memcpy(&dev->targets[i], &dev->targets[i + 1],
@@ -524,7 +584,7 @@ int nfc_target_lost(struct nfc_dev *dev, u32 target_idx) · 3 unmodified lines
524584 dev->targets = NULL;
525585 }
526586
527− spin_unlock_bh(&dev->targets_lock);
587+ device_unlock(&dev->dev);
528588
529589 nfc_genl_target_lost(dev, target_idx);
530590
@@ -556,15 +616,16 @@ static void nfc_check_pres_work(struct work_struct *work) · 25 unmodified lines
556616
557617 device_lock(&dev->dev);
558618
559− if (dev->activated_target_idx != NFC_TARGET_IDX_NONE &&
560− timer_pending(&dev->check_pres_timer) == 0) {
561− rc = dev->ops->check_presence(dev, dev->activated_target_idx);
619+ if (dev->active_target && timer_pending(&dev->check_pres_timer) == 0) {
620+ rc = dev->ops->check_presence(dev, dev->active_target);
562621 if (!rc) {
563622 mod_timer(&dev->check_pres_timer, jiffies +
564623 msecs_to_jiffies(NFC_CHECK_PRES_FREQ_MS));
565624 } else {
566− nfc_target_lost(dev, dev->activated_target_idx);
567− dev->activated_target_idx = NFC_TARGET_IDX_NONE;
625+ u32 active_target_idx = dev->active_target->idx;
626+ device_unlock(&dev->dev);
627+ nfc_target_lost(dev, active_target_idx);
628+ return;
568629 }
569630 }
570631
@@ -637,14 +698,12 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, · 66 unmodified lines
637698 dev->tx_headroom = tx_headroom;
638699 dev->tx_tailroom = tx_tailroom;
639700
640− spin_lock_init(&dev->targets_lock);
641701 nfc_genl_data_init(&dev->genl_data);
642702
703+
643704 /* first generation must not be 0 */
644705 dev->targets_generation = 1;
645706
646− dev->activated_target_idx = NFC_TARGET_IDX_NONE;
647−
648707 if (ops->check_presence) {
649708 char name[32];
650709 init_timer(&dev->check_pres_timer);
@@ -662,7 +721,6 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, · 11 unmodified lines
662721 }
663722 }
664723
665−
666724 return dev;
667725 }
668726 EXPORT_SYMBOL(nfc_allocate_device);
net/nfc/hci/Kconfig+1−0
@@ -9,6 +9,7 @@ config NFC_HCI · 8 unmodified lines
99
1010 config NFC_SHDLC
1111 depends on NFC_HCI
12+ select CRC_CCITT
1213 bool "SHDLC link layer for HCI based NFC drivers"
1314 default n
1415 ---help---
net/nfc/hci/core.c+23−55
@@ -235,13 +235,6 @@ static int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate) · 234 unmodified lines
235235 targets->hci_reader_gate = gate;
236236
237237 r = nfc_targets_found(hdev->ndev, targets, 1);
238− if (r < 0)
239− goto exit;
240−
241− kfree(hdev->targets);
242− hdev->targets = targets;
243− targets = NULL;
244− hdev->target_count = 1;
245238
246239 exit:
247240 kfree(targets);
@@ -258,11 +251,6 @@ void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, · 10 unmodified lines
258251
259252 switch (event) {
260253 case NFC_HCI_EVT_TARGET_DISCOVERED:
261− if (hdev->poll_started == false) {
262− r = -EPROTO;
263− goto exit;
264− }
265−
266254 if (skb->len < 1) { /* no status data? */
267255 r = -EPROTO;
268256 goto exit;
@@ -496,74 +484,42 @@ static int hci_dev_down(struct nfc_dev *nfc_dev) · 227 unmodified lines
496484 static int hci_start_poll(struct nfc_dev *nfc_dev, u32 protocols)
497485 {
498486 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
499− int r;
500487
501488 if (hdev->ops->start_poll)
502− r = hdev->ops->start_poll(hdev, protocols);
489+ return hdev->ops->start_poll(hdev, protocols);
503490 else
504− r = nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
491+ return nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
505492 NFC_HCI_EVT_READER_REQUESTED, NULL, 0);
506− if (r == 0)
507− hdev->poll_started = true;
508−
509− return r;
510493 }
511494
512495 static void hci_stop_poll(struct nfc_dev *nfc_dev)
513496 {
514497 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
515498
516− if (hdev->poll_started) {
517− nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
518− NFC_HCI_EVT_END_OPERATION, NULL, 0);
519− hdev->poll_started = false;
520− }
521−}
522−
523−static struct nfc_target *hci_find_target(struct nfc_hci_dev *hdev,
524− u32 target_idx)
525−{
526− int i;
527− if (hdev->poll_started == false || hdev->targets == NULL)
528− return NULL;
529−
530− for (i = 0; i < hdev->target_count; i++) {
531− if (hdev->targets[i].idx == target_idx)
532− return &hdev->targets[i];
533− }
534−
535− return NULL;
499+ nfc_hci_send_event(hdev, NFC_HCI_RF_READER_A_GATE,
500+ NFC_HCI_EVT_END_OPERATION, NULL, 0);
536501 }
537502
538−static int hci_activate_target(struct nfc_dev *nfc_dev, u32 target_idx,
539− u32 protocol)
503+static int hci_activate_target(struct nfc_dev *nfc_dev,
504+ struct nfc_target *target, u32 protocol)
540505 {
541− struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
542−
543− if (hci_find_target(hdev, target_idx) == NULL)
544− return -ENOMEDIUM;
545−
546506 return 0;
547507 }
548508
549−static void hci_deactivate_target(struct nfc_dev *nfc_dev, u32 target_idx)
509+static void hci_deactivate_target(struct nfc_dev *nfc_dev,
510+ struct nfc_target *target)
550511 {
551512 }
552513
553−static int hci_data_exchange(struct nfc_dev *nfc_dev, u32 target_idx,
514+static int hci_data_exchange(struct nfc_dev *nfc_dev, struct nfc_target *target,
554515 struct sk_buff *skb, data_exchange_cb_t cb,
555516 void *cb_context)
556517 {
557518 struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
558519 int r;
559− struct nfc_target *target;
560520 struct sk_buff *res_skb = NULL;
561521
562− pr_debug("target_idx=%d\n", target_idx);
563−
564− target = hci_find_target(hdev, target_idx);
565− if (target == NULL)
566− return -ENOMEDIUM;
522+ pr_debug("target_idx=%d\n", target->idx);
567523
568524 switch (target->hci_reader_gate) {
569525 case NFC_HCI_RF_READER_A_GATE:
@@ -605,7 +561,18 @@ static int hci_data_exchange(struct nfc_dev *nfc_dev, u32 target_idx, · 35 unmodified lines
605561 return 0;
606562 }
607563
608−struct nfc_ops hci_nfc_ops = {
564+static int hci_check_presence(struct nfc_dev *nfc_dev,
565+ struct nfc_target *target)
566+{
567+ struct nfc_hci_dev *hdev = nfc_get_drvdata(nfc_dev);
568+
569+ if (hdev->ops->check_presence)
570+ return hdev->ops->check_presence(hdev, target);
571+
572+ return 0;
573+}
574+
575+static struct nfc_ops hci_nfc_ops = {
609576 .dev_up = hci_dev_up,
610577 .dev_down = hci_dev_down,
611578 .start_poll = hci_start_poll,
@@ -613,6 +580,7 @@ struct nfc_ops hci_nfc_ops = { · 1 unmodified line
613580 .activate_target = hci_activate_target,
614581 .deactivate_target = hci_deactivate_target,
615582 .data_exchange = hci_data_exchange,
583+ .check_presence = hci_check_presence,
616584 };
617585
618586 struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops,
net/nfc/hci/shdlc.c+12−0
@@ -816,6 +816,17 @@ static int nfc_shdlc_data_exchange(struct nfc_hci_dev *hdev, · 815 unmodified lines
816816 return -EPERM;
817817 }
818818
819+static int nfc_shdlc_check_presence(struct nfc_hci_dev *hdev,
820+ struct nfc_target *target)
821+{
822+ struct nfc_shdlc *shdlc = nfc_hci_get_clientdata(hdev);
823+
824+ if (shdlc->ops->check_presence)
825+ return shdlc->ops->check_presence(shdlc, target);
826+
827+ return 0;
828+}
829+
819830 static struct nfc_hci_ops shdlc_ops = {
820831 .open = nfc_shdlc_open,
821832 .close = nfc_shdlc_close,
@@ -825,6 +836,7 @@ static struct nfc_hci_ops shdlc_ops = { · 3 unmodified lines
825836 .target_from_gate = nfc_shdlc_target_from_gate,
826837 .complete_target_discovered = nfc_shdlc_complete_target_discovered,
827838 .data_exchange = nfc_shdlc_data_exchange,
839+ .check_presence = nfc_shdlc_check_presence,
828840 };
829841
830842 struct nfc_shdlc *nfc_shdlc_allocate(struct nfc_shdlc_ops *ops,
net/nfc/llcp/commands.c+2−2
@@ -488,7 +488,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, · 487 unmodified lines
488488
489489 memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
490490
491− skb_queue_head(&sock->tx_queue, pdu);
491+ skb_queue_tail(&sock->tx_queue, pdu);
492492
493493 lock_sock(sk);
494494
@@ -502,7 +502,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, · 7 unmodified lines
502502
503503 kfree(msg_data);
504504
505− return 0;
505+ return len;
506506 }
507507
508508 int nfc_llcp_send_rr(struct nfc_llcp_sock *sock)
net/nfc/llcp/llcp.c+7−0
@@ -448,6 +448,8 @@ static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, · 447 unmodified lines
448448 {
449449 struct nfc_llcp_sock *sock, *llcp_sock, *n;
450450
451+ pr_debug("ssap dsap %d %d\n", ssap, dsap);
452+
451453 if (ssap == 0 && dsap == 0)
452454 return NULL;
453455
@@ -783,6 +785,7 @@ static void nfc_llcp_recv_disc(struct nfc_llcp_local *local, · 329 unmodified lines
783785 static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, struct sk_buff *skb)
784786 {
785787 struct nfc_llcp_sock *llcp_sock;
788+ struct sock *sk;
786789 u8 dsap, ssap;
787790
788791 dsap = nfc_llcp_dsap(skb);
@@ -801,10 +804,14 @@ static void nfc_llcp_recv_cc(struct nfc_llcp_local *local, struct sk_buff *skb) · 12 unmodified lines
801804 }
802805
803806 llcp_sock->dsap = ssap;
807+ sk = &llcp_sock->sk;
804808
805809 nfc_llcp_parse_tlv(local, &skb->data[LLCP_HEADER_SIZE],
806810 skb->len - LLCP_HEADER_SIZE);
807811
812+ sk->sk_state = LLCP_CONNECTED;
813+ sk->sk_state_change(sk);
814+
808815 nfc_llcp_sock_put(llcp_sock);
809816 }
810817
net/nfc/llcp/sock.c+55−2
@@ -27,6 +27,42 @@ · 26 unmodified lines
2727 #include "../nfc.h"
2828 #include "llcp.h"
2929
30+static int sock_wait_state(struct sock *sk, int state, unsigned long timeo)
31+{
32+ DECLARE_WAITQUEUE(wait, current);
33+ int err = 0;
34+
35+ pr_debug("sk %p", sk);
36+
37+ add_wait_queue(sk_sleep(sk), &wait);
38+ set_current_state(TASK_INTERRUPTIBLE);
39+
40+ while (sk->sk_state != state) {
41+ if (!timeo) {
42+ err = -EINPROGRESS;
43+ break;
44+ }
45+
46+ if (signal_pending(current)) {
47+ err = sock_intr_errno(timeo);
48+ break;
49+ }
50+
51+ release_sock(sk);
52+ timeo = schedule_timeout(timeo);
53+ lock_sock(sk);
54+ set_current_state(TASK_INTERRUPTIBLE);
55+
56+ err = sock_error(sk);
57+ if (err)
58+ break;
59+ }
60+
61+ __set_current_state(TASK_RUNNING);
62+ remove_wait_queue(sk_sleep(sk), &wait);
63+ return err;
64+}
65+
3066 static struct proto llcp_sock_proto = {
3167 .name = "NFC_LLCP",
3268 .owner = THIS_MODULE,
@@ -304,11 +340,24 @@ static unsigned int llcp_sock_poll(struct file *file, struct socket *sock, · 271 unmodified lines
304340 mask |= POLLERR;
305341
306342 if (!skb_queue_empty(&sk->sk_receive_queue))
307− mask |= POLLIN;
343+ mask |= POLLIN | POLLRDNORM;
308344
309345 if (sk->sk_state == LLCP_CLOSED)
310346 mask |= POLLHUP;
311347
348+ if (sk->sk_shutdown & RCV_SHUTDOWN)
349+ mask |= POLLRDHUP | POLLIN | POLLRDNORM;
350+
351+ if (sk->sk_shutdown == SHUTDOWN_MASK)
352+ mask |= POLLHUP;
353+
354+ if (sock_writeable(sk))
355+ mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
356+ else
357+ set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
358+
359+ pr_debug("mask 0x%x\n", mask);
360+
312361 return mask;
313362 }
314363
@@ -462,9 +511,13 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr, · 147 unmodified lines
462511 if (ret)
463512 goto put_dev;
464513
465− sk->sk_state = LLCP_CONNECTED;
514+ ret = sock_wait_state(sk, LLCP_CONNECTED,
515+ sock_sndtimeo(sk, flags & O_NONBLOCK));
516+ if (ret)
517+ goto put_dev;
466518
467519 release_sock(sk);
520+
468521 return 0;
469522
470523 put_dev:
net/nfc/nci/core.c+14−13
@@ -436,16 +436,16 @@ static void nci_stop_poll(struct nfc_dev *nfc_dev) · 435 unmodified lines
436436 msecs_to_jiffies(NCI_RF_DEACTIVATE_TIMEOUT));
437437 }
438438
439−static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx,
440− __u32 protocol)
439+static int nci_activate_target(struct nfc_dev *nfc_dev,
440+ struct nfc_target *target, __u32 protocol)
441441 {
442442 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
443443 struct nci_rf_discover_select_param param;
444− struct nfc_target *target = NULL;
444+ struct nfc_target *nci_target = NULL;
445445 int i;
446446 int rc = 0;
447447
448− pr_debug("target_idx %d, protocol 0x%x\n", target_idx, protocol);
448+ pr_debug("target_idx %d, protocol 0x%x\n", target->idx, protocol);
449449
450450 if ((atomic_read(&ndev->state) != NCI_W4_HOST_SELECT) &&
451451 (atomic_read(&ndev->state) != NCI_POLL_ACTIVE)) {
@@ -459,25 +459,25 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, · 7 unmodified lines
459459 }
460460
461461 for (i = 0; i < ndev->n_targets; i++) {
462− if (ndev->targets[i].idx == target_idx) {
463− target = &ndev->targets[i];
462+ if (ndev->targets[i].idx == target->idx) {
463+ nci_target = &ndev->targets[i];
464464 break;
465465 }
466466 }
467467
468− if (!target) {
468+ if (!nci_target) {
469469 pr_err("unable to find the selected target\n");
470470 return -EINVAL;
471471 }
472472
473− if (!(target->supported_protocols & (1 << protocol))) {
473+ if (!(nci_target->supported_protocols & (1 << protocol))) {
474474 pr_err("target does not support the requested protocol 0x%x\n",
475475 protocol);
476476 return -EINVAL;
477477 }
478478
479479 if (atomic_read(&ndev->state) == NCI_W4_HOST_SELECT) {
480− param.rf_discovery_id = target->logical_idx;
480+ param.rf_discovery_id = nci_target->logical_idx;
481481
482482 if (protocol == NFC_PROTO_JEWEL)
483483 param.rf_protocol = NCI_RF_PROTOCOL_T1T;
@@ -501,11 +501,12 @@ static int nci_activate_target(struct nfc_dev *nfc_dev, __u32 target_idx, · 17 unmodified lines
501501 return rc;
502502 }
503503
504−static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx)
504+static void nci_deactivate_target(struct nfc_dev *nfc_dev,
505+ struct nfc_target *target)
505506 {
506507 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
507508
508− pr_debug("target_idx %d\n", target_idx);
509+ pr_debug("target_idx %d\n", target->idx);
509510
510511 if (!ndev->target_active_prot) {
511512 pr_err("unable to deactivate target, no active target\n");
@@ -520,14 +521,14 @@ static void nci_deactivate_target(struct nfc_dev *nfc_dev, __u32 target_idx) · 8 unmodified lines
520521 }
521522 }
522523
523−static int nci_data_exchange(struct nfc_dev *nfc_dev, __u32 target_idx,
524+static int nci_data_exchange(struct nfc_dev *nfc_dev, struct nfc_target *target,
524525 struct sk_buff *skb,
525526 data_exchange_cb_t cb, void *cb_context)
526527 {
527528 struct nci_dev *ndev = nfc_get_drvdata(nfc_dev);
528529 int rc;
529530
530− pr_debug("target_idx %d, len %d\n", target_idx, skb->len);
531+ pr_debug("target_idx %d, len %d\n", target->idx, skb->len);
531532
532533 if (!ndev->target_active_prot) {
533534 pr_err("unable to exchange data, no active target\n");
net/nfc/nci/data.c+4−4
@@ -49,7 +49,7 @@ void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb, · 48 unmodified lines
4949
5050 if (cb) {
5151 ndev->data_exchange_cb = NULL;
52− ndev->data_exchange_cb_context = 0;
52+ ndev->data_exchange_cb_context = NULL;
5353
5454 /* forward skb to nfc core */
5555 cb(cb_context, skb, err);
@@ -200,10 +200,10 @@ static void nci_add_rx_data_frag(struct nci_dev *ndev, · 144 unmodified lines
200200 pr_err("error adding room for accumulated rx data\n");
201201
202202 kfree_skb(skb);
203− skb = 0;
203+ skb = NULL;
204204
205205 kfree_skb(ndev->rx_data_reassembly);
206− ndev->rx_data_reassembly = 0;
206+ ndev->rx_data_reassembly = NULL;
207207
208208 err = -ENOMEM;
209209 goto exit;
@@ -216,7 +216,7 @@ static void nci_add_rx_data_frag(struct nci_dev *ndev, · 6 unmodified lines
216216
217217 /* third, free old reassembly */
218218 kfree_skb(ndev->rx_data_reassembly);
219− ndev->rx_data_reassembly = 0;
219+ ndev->rx_data_reassembly = NULL;
220220 }
221221
222222 if (pbf == NCI_PBF_CONT) {
net/nfc/nci/lib.c+1−0
@@ -31,6 +31,7 @@ · 30 unmodified lines
3131 #include <linux/errno.h>
3232
3333 #include <net/nfc/nci.h>
34+#include <net/nfc/nci_core.h>
3435
3536 /* NCI status codes to Unix errno mapping */
3637 int nci_to_errno(__u8 code)
net/nfc/nci/ntf.c+1−1
@@ -497,7 +497,7 @@ static void nci_rf_deactivate_ntf_packet(struct nci_dev *ndev, · 496 unmodified lines
497497 /* drop partial rx data packet */
498498 if (ndev->rx_data_reassembly) {
499499 kfree_skb(ndev->rx_data_reassembly);
500− ndev->rx_data_reassembly = 0;
500+ ndev->rx_data_reassembly = NULL;
501501 }
502502
503503 /* complete the data exchange transaction, if exists */
net/nfc/netlink.c+3−3
@@ -33,7 +33,7 @@ static struct genl_multicast_group nfc_genl_event_mcgrp = { · 32 unmodified lines
3333 .name = NFC_GENL_MCAST_EVENT_NAME,
3434 };
3535
36−struct genl_family nfc_genl_family = {
36+static struct genl_family nfc_genl_family = {
3737 .id = GENL_ID_GENERATE,
3838 .hdrsize = 0,
3939 .name = NFC_GENL_NAME,
@@ -128,7 +128,7 @@ static int nfc_genl_dump_targets(struct sk_buff *skb, · 88 unmodified lines
128128 cb->args[1] = (long) dev;
129129 }
130130
131− spin_lock_bh(&dev->targets_lock);
131+ device_lock(&dev->dev);
132132
133133 cb->seq = dev->targets_generation;
134134
@@ -141,7 +141,7 @@ static int nfc_genl_dump_targets(struct sk_buff *skb, · 6 unmodified lines
141141 i++;
142142 }
143143
144− spin_unlock_bh(&dev->targets_lock);
144+ device_unlock(&dev->dev);
145145
146146 cb->args[0] = i;
147147
net/nfc/nfc.h+1−1
@@ -84,7 +84,7 @@ static inline int nfc_llcp_set_remote_gb(struct nfc_dev *dev, · 83 unmodified lines
8484 return 0;
8585 }
8686
87−static inline u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, u8 *gb_len)
87+static inline u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *gb_len)
8888 {
8989 *gb_len = 0;
9090 return NULL;
net/wireless/chan.c+1−1
@@ -45,7 +45,7 @@ rdev_freq_to_chan(struct cfg80211_registered_device *rdev, · 44 unmodified lines
4545 return chan;
4646 }
4747
48−int cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
48+bool cfg80211_can_beacon_sec_chan(struct wiphy *wiphy,
4949 struct ieee80211_channel *chan,
5050 enum nl80211_channel_type channel_type)
5151 {
net/wireless/core.c+2−2
@@ -664,7 +664,7 @@ void wiphy_unregister(struct wiphy *wiphy) · 663 unmodified lines
664664 mutex_lock(&rdev->devlist_mtx);
665665 __count = rdev->opencount;
666666 mutex_unlock(&rdev->devlist_mtx);
667− __count == 0;}));
667+ __count == 0; }));
668668
669669 mutex_lock(&rdev->devlist_mtx);
670670 BUG_ON(!list_empty(&rdev->netdev_list));
@@ -776,7 +776,7 @@ static struct device_type wiphy_type = { · 105 unmodified lines
776776 .name = "wlan",
777777 };
778778
779−static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
779+static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
780780 unsigned long state,
781781 void *ndev)
782782 {
net/wireless/core.h+0−2
@@ -445,8 +445,6 @@ int cfg80211_set_freq(struct cfg80211_registered_device *rdev, · 444 unmodified lines
445445 struct wireless_dev *wdev, int freq,
446446 enum nl80211_channel_type channel_type);
447447
448−u16 cfg80211_calculate_bitrate(struct rate_info *rate);
449−
450448 int ieee80211_get_ratemask(struct ieee80211_supported_band *sband,
451449 const u8 *rates, unsigned int n_rates,
452450 u32 *mask);
net/wireless/nl80211.c+37−32
@@ -1179,6 +1179,27 @@ static bool nl80211_can_set_dev_channel(struct wireless_dev *wdev) · 1178 unmodified lines
11791179 wdev->iftype == NL80211_IFTYPE_P2P_GO;
11801180 }
11811181
1182+static bool nl80211_valid_channel_type(struct genl_info *info,
1183+ enum nl80211_channel_type *channel_type)
1184+{
1185+ enum nl80211_channel_type tmp;
1186+
1187+ if (!info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE])
1188+ return false;
1189+
1190+ tmp = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
1191+ if (tmp != NL80211_CHAN_NO_HT &&
1192+ tmp != NL80211_CHAN_HT20 &&
1193+ tmp != NL80211_CHAN_HT40PLUS &&
1194+ tmp != NL80211_CHAN_HT40MINUS)
1195+ return false;
1196+
1197+ if (channel_type)
1198+ *channel_type = tmp;
1199+
1200+ return true;
1201+}
1202+
11821203 static int __nl80211_set_channel(struct cfg80211_registered_device *rdev,
11831204 struct wireless_dev *wdev,
11841205 struct genl_info *info)
@@ -1193,15 +1214,9 @@ static int __nl80211_set_channel(struct cfg80211_registered_device *rdev, · 8 unmodified lines
11931214 if (!nl80211_can_set_dev_channel(wdev))
11941215 return -EOPNOTSUPP;
11951216
1196− if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
1197− channel_type = nla_get_u32(info->attrs[
1198− NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
1199− if (channel_type != NL80211_CHAN_NO_HT &&
1200− channel_type != NL80211_CHAN_HT20 &&
1201− channel_type != NL80211_CHAN_HT40PLUS &&
1202− channel_type != NL80211_CHAN_HT40MINUS)
1203− return -EINVAL;
1204− }
1217+ if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE] &&
1218+ !nl80211_valid_channel_type(info, &channel_type))
1219+ return -EINVAL;
12051220
12061221 freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]);
12071222
@@ -2410,10 +2425,16 @@ static int parse_station_flags(struct genl_info *info, · 1202 unmodified lines
24102425 return -EINVAL;
24112426 }
24122427
2413− for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++)
2414− if (flags[flag])
2428+ for (flag = 1; flag <= NL80211_STA_FLAG_MAX; flag++) {
2429+ if (flags[flag]) {
24152430 params->sta_flags_set |= (1<<flag);
24162431
2432+ /* no longer support new API additions in old API */
2433+ if (flag > NL80211_STA_FLAG_MAX_OLD_API)
2434+ return -EINVAL;
2435+ }
2436+ }
2437+
24172438 return 0;
24182439 }
24192440
@@ -4912,12 +4933,7 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) · 2492 unmodified lines
49124933 if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
49134934 enum nl80211_channel_type channel_type;
49144935
4915− channel_type = nla_get_u32(
4916− info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
4917− if (channel_type != NL80211_CHAN_NO_HT &&
4918− channel_type != NL80211_CHAN_HT20 &&
4919− channel_type != NL80211_CHAN_HT40MINUS &&
4920− channel_type != NL80211_CHAN_HT40PLUS)
4936+ if (!nl80211_valid_channel_type(info, &channel_type))
49214937 return -EINVAL;
49224938
49234939 if (channel_type != NL80211_CHAN_NO_HT &&
@@ -5485,15 +5501,9 @@ static int nl80211_remain_on_channel(struct sk_buff *skb, · 561 unmodified lines
54855501 !(rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL))
54865502 return -EOPNOTSUPP;
54875503
5488− if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
5489− channel_type = nla_get_u32(
5490− info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
5491− if (channel_type != NL80211_CHAN_NO_HT &&
5492− channel_type != NL80211_CHAN_HT20 &&
5493− channel_type != NL80211_CHAN_HT40PLUS &&
5494− channel_type != NL80211_CHAN_HT40MINUS)
5495− return -EINVAL;
5496− }
5504+ if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE] &&
5505+ !nl80211_valid_channel_type(info, &channel_type))
5506+ return -EINVAL;
54975507
54985508 freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]);
54995509 chan = rdev_freq_to_chan(rdev, freq, channel_type);
@@ -5764,12 +5774,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) · 264 unmodified lines
57645774 }
57655775
57665776 if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) {
5767− channel_type = nla_get_u32(
5768− info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]);
5769− if (channel_type != NL80211_CHAN_NO_HT &&
5770− channel_type != NL80211_CHAN_HT20 &&
5771− channel_type != NL80211_CHAN_HT40PLUS &&
5772− channel_type != NL80211_CHAN_HT40MINUS)
5777+ if (!nl80211_valid_channel_type(info, &channel_type))
57735778 return -EINVAL;
57745779 channel_type_valid = true;
57755780 }
net/wireless/util.c+1−1
@@ -879,7 +879,7 @@ u16 cfg80211_calculate_bitrate(struct rate_info *rate) · 878 unmodified lines
879879 return rate->legacy;
880880
881881 /* the formula below does only work for MCS values smaller than 32 */
882− if (rate->mcs >= 32)
882+ if (WARN_ON_ONCE(rate->mcs >= 32))
883883 return 0;
884884
885885 modulation = rate->mcs & 7;