300-pending_work.patch 126 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709
  1. commit 1abdeca3c6fb9cf1f84f85e78ed8d1c33bd69db0
  2. Author: Felix Fietkau <[email protected]>
  3. Date: Fri Feb 28 18:52:56 2014 +0100
  4. ath9k_hw: tweak noise immunity thresholds for older chipsets
  5. Older chipsets are more sensitive to high PHY error counts, and the
  6. current noise immunity thresholds were based on tests run at QCA with
  7. newer chipsets.
  8. This patch brings back the values from the old ANI implementation for
  9. old chipsets, and it also disables weak signal detection on an earlier
  10. noise immunity level, to improve overall radio stability on affected
  11. devices.
  12. Signed-off-by: Felix Fietkau <[email protected]>
  13. commit 431e506da5953adc3b65af25f4b90873d528c115
  14. Author: Felix Fietkau <[email protected]>
  15. Date: Fri Feb 28 18:44:13 2014 +0100
  16. ath9k_hw: toggle weak signal detection in AP mode on older chipsets
  17. The commit 80b4205b "ath9k: Fix OFDM weak signal detection for AP mode"
  18. prevented weak signal detection changes from taking effect in AP mode on
  19. all chipsets, claiming it is "not allowed".
  20. The main reason for not disabling weak signal detection in AP mode is
  21. that typically beacon RSSI is used to track whether it is needed to
  22. boost range, and this is unavailable in AP mode for obvious reasons.
  23. The problem with not disabling weak signal detection is that older
  24. chipsets are very sensitive to high PHY error counts. When faced with
  25. heavy noise, this can lead to an excessive amount of "Failed to stop
  26. TX DMA" errors in the field.
  27. Signed-off-by: Felix Fietkau <[email protected]>
  28. commit 98d1a6c5b14688ed030e81b889f607be308e0df9
  29. Author: Felix Fietkau <[email protected]>
  30. Date: Mon Feb 24 22:20:32 2014 +0100
  31. ath9k: fix invalid descriptor discarding
  32. Only set sc->rx.discard_next to rx_stats->rs_more when actually
  33. discarding the current descriptor.
  34. Also, fix a detection of broken descriptors:
  35. First the code checks if the current descriptor is not done.
  36. Then it checks if the next descriptor is done.
  37. Add a check that afterwards checks the first descriptor again, because
  38. it might have been completed in the mean time.
  39. This fixes a regression introduced in
  40. commit 723e711356b5a8a95728a890e254e8b0d47b55cf
  41. "ath9k: fix handling of broken descriptors"
  42. Cc: [email protected]
  43. Reported-by: Marco André Dinis <[email protected]>
  44. Signed-off-by: Felix Fietkau <[email protected]>
  45. commit 52a46300e782fe6994466523eb2b0b59091ea59f
  46. Author: Felix Fietkau <[email protected]>
  47. Date: Mon Feb 24 11:43:50 2014 +0100
  48. ath9k: reduce baseband hang detection false positive rate
  49. Check if the baseband state remains stable, and add a small delay
  50. between register reads.
  51. Signed-off-by: Felix Fietkau <[email protected]>
  52. commit 118945bb12082e9d4edddc868d88143164e0f440
  53. Author: Felix Fietkau <[email protected]>
  54. Date: Sat Feb 22 14:55:23 2014 +0100
  55. ath5k: set SURVEY_INFO_IN_USE on get_survey
  56. Only one channel is returned - the one currently being used.
  57. Signed-off-by: Felix Fietkau <[email protected]>
  58. commit ee41f72476e1ea44283dfe1cbf75b9543a1e15c8
  59. Author: Felix Fietkau <[email protected]>
  60. Date: Sat Feb 22 14:44:52 2014 +0100
  61. ath9k: make some hardware reset log messages debug-only
  62. On some chips, baseband watchdog hangs are more common than others, and
  63. the driver has support for handling them.
  64. Interrupts even after a watchdog hang are also quite common, so there's
  65. not much point in spamming the user's logfiles.
  66. Signed-off-by: Felix Fietkau <[email protected]>
  67. commit b14fbb554fc65a2e0b5c41a319269b0350f187e7
  68. Author: Felix Fietkau <[email protected]>
  69. Date: Sat Feb 22 14:35:25 2014 +0100
  70. ath9k: do not set half/quarter channel flags in AR_PHY_MODE
  71. 5/10 MHz channel bandwidth is configured via the PLL clock, instead of
  72. the AR_PHY_MODE register. Using that register is AR93xx specific, and
  73. makes the mode incompatible with earlier chipsets.
  74. In some early versions, these flags were apparently applied at the wrong
  75. point in time and thus did not cause connectivity issues, however now
  76. they are causing problems, as pointed out in this OpenWrt ticket:
  77. https://dev.openwrt.org/ticket/14916
  78. Signed-off-by: Felix Fietkau <[email protected]>
  79. commit 0f1cb7be2551b30b02cd54c897e0e29e483cfda5
  80. Author: Felix Fietkau <[email protected]>
  81. Date: Sat Feb 22 13:43:29 2014 +0100
  82. ath9k: fix ps-poll responses under a-mpdu sessions
  83. When passing tx frames to the U-APSD queue for powersave poll responses,
  84. the ath_atx_tid pointer needs to be passed to ath_tx_setup_buffer for
  85. proper sequence number accounting.
  86. This fixes high latency and connection stability issues with ath9k
  87. running as AP and a few kinds of mobile phones as client, when PS-Poll
  88. is heavily used
  89. Cc: [email protected]
  90. Signed-off-by: Felix Fietkau <[email protected]>
  91. commit d5d87a37bbd6066b2c3c5d0bd0fe2a6e2ea45cc5
  92. Author: Felix Fietkau <[email protected]>
  93. Date: Fri Feb 21 11:39:59 2014 +0100
  94. ath9k: list more reset causes in debugfs
  95. Number of MAC hangs and stuck beacons were missing
  96. Signed-off-by: Felix Fietkau <[email protected]>
  97. commit d84856012e0f10fe598a5ad3b7b869397a089e07
  98. Author: Johannes Berg <[email protected]>
  99. Date: Thu Feb 20 11:19:58 2014 +0100
  100. mac80211: fix station wakeup powersave race
  101. Consider the following (relatively unlikely) scenario:
  102. 1) station goes to sleep while frames are buffered in driver
  103. 2) driver blocks wakeup (until no more frames are buffered)
  104. 3) station wakes up again
  105. 4) driver unblocks wakeup
  106. In this case, the current mac80211 code will do the following:
  107. 1) WLAN_STA_PS_STA set
  108. 2) WLAN_STA_PS_DRIVER set
  109. 3) - nothing -
  110. 4) WLAN_STA_PS_DRIVER cleared
  111. As a result, no frames will be delivered to the client, even
  112. though it is awake, until it sends another frame to us that
  113. triggers ieee80211_sta_ps_deliver_wakeup() in sta_ps_end().
  114. Since we now take the PS spinlock, we can fix this while at
  115. the same time removing the complexity with the pending skb
  116. queue function. This was broken since my commit 50a9432daeec
  117. ("mac80211: fix powersaving clients races") due to removing
  118. the clearing of WLAN_STA_PS_STA in the RX path.
  119. While at it, fix a cleanup path issue when a station is
  120. removed while the driver is still blocking its wakeup.
  121. Signed-off-by: Johannes Berg <[email protected]>
  122. commit 798f2786602cbe93e6b928299614aa36ebf50692
  123. Author: Johannes Berg <[email protected]>
  124. Date: Mon Feb 17 20:49:03 2014 +0100
  125. mac80211: insert stations before adding to driver
  126. There's a race condition in mac80211 because we add stations
  127. to the internal lists after adding them to the driver, which
  128. means that (for example) the following can happen:
  129. 1. a station connects and is added
  130. 2. first, it is added to the driver
  131. 3. then, it is added to the mac80211 lists
  132. If the station goes to sleep between steps 2 and 3, and the
  133. firmware/hardware records it as being asleep, mac80211 will
  134. never instruct the driver to wake it up again as it never
  135. realized it went to sleep since the RX path discarded the
  136. frame as a "spurious class 3 frame", no station entry was
  137. present yet.
  138. Fix this by adding the station in software first, and only
  139. then adding it to the driver. That way, any state that the
  140. driver changes will be reflected properly in mac80211's
  141. station state. The problematic part is the roll-back if the
  142. driver fails to add the station, in that case a bit more is
  143. needed. To not make that overly complex prevent starting BA
  144. sessions in the meantime.
  145. Signed-off-by: Johannes Berg <[email protected]>
  146. commit b9ba6a520cb07ab3aa7aaaf9ce4a0bc7a6bc06fe
  147. Author: Emmanuel Grumbach <[email protected]>
  148. Date: Thu Feb 20 09:22:11 2014 +0200
  149. mac80211: fix AP powersave TX vs. wakeup race
  150. There is a race between the TX path and the STA wakeup: while
  151. a station is sleeping, mac80211 buffers frames until it wakes
  152. up, then the frames are transmitted. However, the RX and TX
  153. path are concurrent, so the packet indicating wakeup can be
  154. processed while a packet is being transmitted.
  155. This can lead to a situation where the buffered frames list
  156. is emptied on the one side, while a frame is being added on
  157. the other side, as the station is still seen as sleeping in
  158. the TX path.
  159. As a result, the newly added frame will not be send anytime
  160. soon. It might be sent much later (and out of order) when the
  161. station goes to sleep and wakes up the next time.
  162. Additionally, it can lead to the crash below.
  163. Fix all this by synchronising both paths with a new lock.
  164. Both path are not fastpath since they handle PS situations.
  165. In a later patch we'll remove the extra skb queue locks to
  166. reduce locking overhead.
  167. BUG: unable to handle kernel
  168. NULL pointer dereference at 000000b0
  169. IP: [<ff6f1791>] ieee80211_report_used_skb+0x11/0x3e0 [mac80211]
  170. *pde = 00000000
  171. Oops: 0000 [#1] SMP DEBUG_PAGEALLOC
  172. EIP: 0060:[<ff6f1791>] EFLAGS: 00210282 CPU: 1
  173. EIP is at ieee80211_report_used_skb+0x11/0x3e0 [mac80211]
  174. EAX: e5900da0 EBX: 00000000 ECX: 00000001 EDX: 00000000
  175. ESI: e41d00c0 EDI: e5900da0 EBP: ebe458e4 ESP: ebe458b0
  176. DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
  177. CR0: 8005003b CR2: 000000b0 CR3: 25a78000 CR4: 000407d0
  178. DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
  179. DR6: ffff0ff0 DR7: 00000400
  180. Process iperf (pid: 3934, ti=ebe44000 task=e757c0b0 task.ti=ebe44000)
  181. iwlwifi 0000:02:00.0: I iwl_pcie_enqueue_hcmd Sending command LQ_CMD (#4e), seq: 0x0903, 92 bytes at 3[3]:9
  182. Stack:
  183. e403b32c ebe458c4 00200002 00200286 e403b338 ebe458cc c10960bb e5900da0
  184. ff76a6ec ebe458d8 00000000 e41d00c0 e5900da0 ebe458f0 ff6f1b75 e403b210
  185. ebe4598c ff723dc1 00000000 ff76a6ec e597c978 e403b758 00000002 00000002
  186. Call Trace:
  187. [<ff6f1b75>] ieee80211_free_txskb+0x15/0x20 [mac80211]
  188. [<ff723dc1>] invoke_tx_handlers+0x1661/0x1780 [mac80211]
  189. [<ff7248a5>] ieee80211_tx+0x75/0x100 [mac80211]
  190. [<ff7249bf>] ieee80211_xmit+0x8f/0xc0 [mac80211]
  191. [<ff72550e>] ieee80211_subif_start_xmit+0x4fe/0xe20 [mac80211]
  192. [<c149ef70>] dev_hard_start_xmit+0x450/0x950
  193. [<c14b9aa9>] sch_direct_xmit+0xa9/0x250
  194. [<c14b9c9b>] __qdisc_run+0x4b/0x150
  195. [<c149f732>] dev_queue_xmit+0x2c2/0xca0
  196. Cc: [email protected]
  197. Reported-by: Yaara Rozenblum <[email protected]>
  198. Signed-off-by: Emmanuel Grumbach <[email protected]>
  199. Reviewed-by: Stanislaw Gruszka <[email protected]>
  200. [reword commit log, use a separate lock]
  201. Signed-off-by: Johannes Berg <[email protected]>
  202. commit 80e419de0dff38436b30d363311c625766193f86
  203. Author: Inbal Hacohen <[email protected]>
  204. Date: Wed Feb 12 09:32:27 2014 +0200
  205. cfg80211: bugfix in regulatory user hint process
  206. After processing hint_user, we would want to schedule the
  207. timeout work only if we are actually waiting to CRDA. This happens
  208. when the status is not "IGNORE" nor "ALREADY_SET".
  209. Signed-off-by: Inbal Hacohen <[email protected]>
  210. Signed-off-by: Johannes Berg <[email protected]>
  211. commit 6514c93afede55284e2cb63359aadedb85884c80
  212. Author: Jouni Malinen <[email protected]>
  213. Date: Tue Feb 18 20:41:08 2014 +0200
  214. ath9k: Enable U-APSD AP mode support
  215. mac80211 handles the actual operations, so ath9k can just indicate
  216. support for this. Based on initial tests, this combination seems to
  217. work fine.
  218. Signed-off-by: Jouni Malinen <[email protected]>
  219. commit a63caf0a357ad5c1f08d6b7827dc76c451445017
  220. Author: Stanislaw Gruszka <[email protected]>
  221. Date: Wed Feb 19 13:15:17 2014 +0100
  222. ath9k: protect tid->sched check
  223. We check tid->sched without a lock taken on ath_tx_aggr_sleep(). That
  224. is race condition which can result of doing list_del(&tid->list) twice
  225. (second time with poisoned list node) and cause crash like shown below:
  226. [424271.637220] BUG: unable to handle kernel paging request at 00100104
  227. [424271.637328] IP: [<f90fc072>] ath_tx_aggr_sleep+0x62/0xe0 [ath9k]
  228. ...
  229. [424271.639953] Call Trace:
  230. [424271.639998] [<f90f6900>] ? ath9k_get_survey+0x110/0x110 [ath9k]
  231. [424271.640083] [<f90f6942>] ath9k_sta_notify+0x42/0x50 [ath9k]
  232. [424271.640177] [<f809cfef>] sta_ps_start+0x8f/0x1c0 [mac80211]
  233. [424271.640258] [<c10f730e>] ? free_compound_page+0x2e/0x40
  234. [424271.640346] [<f809e915>] ieee80211_rx_handlers+0x9d5/0x2340 [mac80211]
  235. [424271.640437] [<c112f048>] ? kmem_cache_free+0x1d8/0x1f0
  236. [424271.640510] [<c1345a84>] ? kfree_skbmem+0x34/0x90
  237. [424271.640578] [<c10fc23c>] ? put_page+0x2c/0x40
  238. [424271.640640] [<c1345a84>] ? kfree_skbmem+0x34/0x90
  239. [424271.640706] [<c1345a84>] ? kfree_skbmem+0x34/0x90
  240. [424271.640787] [<f809dde3>] ? ieee80211_rx_handlers_result+0x73/0x1d0 [mac80211]
  241. [424271.640897] [<f80a07a0>] ieee80211_prepare_and_rx_handle+0x520/0xad0 [mac80211]
  242. [424271.641009] [<f809e22d>] ? ieee80211_rx_handlers+0x2ed/0x2340 [mac80211]
  243. [424271.641104] [<c13846ce>] ? ip_output+0x7e/0xd0
  244. [424271.641182] [<f80a1057>] ieee80211_rx+0x307/0x7c0 [mac80211]
  245. [424271.641266] [<f90fa6ee>] ath_rx_tasklet+0x88e/0xf70 [ath9k]
  246. [424271.641358] [<f80a0f2c>] ? ieee80211_rx+0x1dc/0x7c0 [mac80211]
  247. [424271.641445] [<f90f82db>] ath9k_tasklet+0xcb/0x130 [ath9k]
  248. Bug report:
  249. https://bugzilla.kernel.org/show_bug.cgi?id=70551
  250. Reported-and-tested-by: Max Sydorenko <[email protected]>
  251. Cc: [email protected]
  252. Signed-off-by: Stanislaw Gruszka <[email protected]>
  253. commit 82ed9e3ccc02797df2ffe4b78127c4cd5f799a41
  254. Author: Felix Fietkau <[email protected]>
  255. Date: Tue Feb 11 15:54:13 2014 +0100
  256. mac80211: send control port protocol frames to the VO queue
  257. Improves reliability of wifi connections with WPA, since authentication
  258. frames are prioritized over normal traffic and also typically exempt
  259. from aggregation.
  260. Cc: [email protected]
  261. Signed-off-by: Felix Fietkau <[email protected]>
  262. commit d4426800f71e972feaa33e04c5801fc730627bdd
  263. Author: Stanislaw Gruszka <[email protected]>
  264. Date: Mon Feb 10 22:38:28 2014 +0100
  265. rtl8187: fix regression on MIPS without coherent DMA
  266. This patch fixes regression caused by commit a16dad77634 "MIPS: Fix
  267. potencial corruption". That commit fixes one corruption scenario in
  268. cost of adding another one, which actually start to cause crashes
  269. on Yeeloong laptop when rtl8187 driver is used.
  270. For correct DMA read operation on machines without DMA coherence, kernel
  271. have to invalidate cache, such it will refill later with new data that
  272. device wrote to memory, when that data is needed to process. We can only
  273. invalidate full cache line. Hence when cache line includes both dma
  274. buffer and some other data (written in cache, but not yet in main
  275. memory), the other data can not hit memory due to invalidation. That
  276. happen on rtl8187 where struct rtl8187_priv fields are located just
  277. before and after small buffers that are passed to USB layer and DMA
  278. is performed on them.
  279. To fix the problem we align buffers and reserve space after them to make
  280. them match cache line.
  281. This patch does not resolve all possible MIPS problems entirely, for
  282. that we have to assure that we always map cache aligned buffers for DMA,
  283. what can be complex or even not possible. But patch fixes visible and
  284. reproducible regression and seems other possible corruptions do not
  285. happen in practice, since Yeeloong laptop works stable without rtl8187
  286. driver.
  287. Bug report:
  288. https://bugzilla.kernel.org/show_bug.cgi?id=54391
  289. Reported-by: Petr Pisar <[email protected]>
  290. Bisected-by: Tom Li <[email protected]>
  291. Reported-and-tested-by: Tom Li <[email protected]>
  292. Cc: [email protected]
  293. Signed-off-by: Stanislaw Gruszka <[email protected]>
  294. commit e2f141d67ad1e7fe10aaab61811e8a409dfb2442
  295. Author: Sujith Manoharan <[email protected]>
  296. Date: Fri Feb 7 10:29:55 2014 +0530
  297. ath9k: Calculate IQ-CAL median
  298. This patch adds a routine to calculate the median IQ correction
  299. values for AR955x, which is used for outlier detection.
  300. The normal method which is used for all other chips is
  301. bypassed for AR955x.
  302. Signed-off-by: Sujith Manoharan <[email protected]>
  303. commit c52a6fce0820c8d0687443ab86058ae03b478c8f
  304. Author: Sujith Manoharan <[email protected]>
  305. Date: Fri Feb 7 10:29:54 2014 +0530
  306. ath9k: Expand the IQ coefficient array
  307. This will be used for storing data for mutiple
  308. IQ calibration runs, for AR955x.
  309. Signed-off-by: Sujith Manoharan <[email protected]>
  310. commit 034969ff5c2b6431d10e07c1938f0b916da85cc3
  311. Author: Sujith Manoharan <[email protected]>
  312. Date: Fri Feb 7 10:29:53 2014 +0530
  313. ath9k: Modify IQ calibration for AR955x
  314. IQ calibration post-processing for AR955x is different
  315. from other chips - instead of just doing it as part
  316. of AGC calibration once, it is triggered 3 times and
  317. a median is determined. This patch adds initial support
  318. for changing the calibration behavior for AR955x.
  319. Also, to simplify things, a helper routine to issue/poll
  320. AGC calibration is used.
  321. For non-AR955x chips, the iqcal_idx (which will be used
  322. in subsequent patches) is set to zero.
  323. Signed-off-by: Sujith Manoharan <[email protected]>
  324. commit 9b1ed6454e6f3511f24266be99b4e403f243f6a8
  325. Author: Sujith Manoharan <[email protected]>
  326. Date: Fri Feb 7 10:29:52 2014 +0530
  327. ath9k: Fix magnitude/phase calculation
  328. Incorrect values are programmed in the registers
  329. containing the IQ correction coefficients by the IQ-CAL
  330. post-processing code. Fix this.
  331. Signed-off-by: Sujith Manoharan <[email protected]>
  332. commit 36f93484f96f79171dcecb67c5ef0c3de22531a6
  333. Author: Sujith Manoharan <[email protected]>
  334. Date: Fri Feb 7 10:29:51 2014 +0530
  335. ath9k: Rename ar9003_hw_tx_iqcal_load_avg_2_passes
  336. Use ar9003_hw_tx_iq_cal_outlier_detection instead.
  337. Signed-off-by: Sujith Manoharan <[email protected]>
  338. commit 3af09a7f5d21dd5fd15b973ce6a91a575da30417
  339. Author: Sujith Manoharan <[email protected]>
  340. Date: Fri Feb 7 10:29:50 2014 +0530
  341. ath9k: Check explicitly for IQ calibration
  342. In chips like AR955x, the initvals contain the information
  343. whether IQ calibration is to be done in the HW when an
  344. AGC calibration is triggered. Check if IQ-CAL is enabled
  345. in the initvals before flagging 'txiqcal_done' as true.
  346. Signed-off-by: Sujith Manoharan <[email protected]>
  347. commit cb4969634b93c4643a32cc3fbd27d2b288b25771
  348. Author: Sujith Manoharan <[email protected]>
  349. Date: Fri Feb 7 10:29:49 2014 +0530
  350. ath9k: Fix IQ cal post processing for SoC
  351. Calibration data is not reused for SoC chips, so
  352. call ar9003_hw_tx_iq_cal_post_proc() with the correct
  353. argument. The 'is_reusable' flag is currently used
  354. only for PC-OEM chips, but it makes things clearer to
  355. specify it explicity.
  356. Signed-off-by: Sujith Manoharan <[email protected]>
  357. commit e138e0ef9560c46ce93dbb22a728a57888e94d1c
  358. Author: Sujith Manoharan <[email protected]>
  359. Date: Mon Feb 3 13:31:37 2014 +0530
  360. ath9k: Fix TX power calculation
  361. The commit, "ath9k_hw: Fix incorrect Tx control power in AR9003 template"
  362. fixed the incorrect values in the eeprom templates, but if
  363. boards have already been calibrated with incorrect values,
  364. they would still be using the wrong TX power. Fix this by assigning
  365. a default value in such cases.
  366. Cc: Rajkumar Manoharan <[email protected]>
  367. Signed-off-by: Sujith Manoharan <[email protected]>
  368. commit b9f268b5b01331c3c82179abca551429450e9417
  369. Author: Michal Kazior <[email protected]>
  370. Date: Wed Jan 29 14:22:27 2014 +0100
  371. cfg80211: consider existing DFS interfaces
  372. It was possible to break interface combinations in
  373. the following way:
  374. combo 1: iftype = AP, num_ifaces = 2, num_chans = 2,
  375. combo 2: iftype = AP, num_ifaces = 1, num_chans = 1, radar = HT20
  376. With the above interface combinations it was
  377. possible to:
  378. step 1. start AP on DFS channel by matching combo 2
  379. step 2. start AP on non-DFS channel by matching combo 1
  380. This was possible beacuse (step 2) did not consider
  381. if other interfaces require radar detection.
  382. The patch changes how cfg80211 tracks channels -
  383. instead of channel itself now a complete chandef
  384. is stored.
  385. Signed-off-by: Michal Kazior <[email protected]>
  386. Signed-off-by: Johannes Berg <[email protected]>
  387. commit bc9c62f5f511cc395c62dbf4cdd437f23db53b28
  388. Author: Antonio Quartulli <[email protected]>
  389. Date: Wed Jan 29 17:53:43 2014 +0100
  390. cfg80211: fix channel configuration in IBSS join
  391. When receiving an IBSS_JOINED event select the BSS object
  392. based on the {bssid, channel} couple rather than the bssid
  393. only.
  394. With the current approach if another cell having the same
  395. BSSID (but using a different channel) exists then cfg80211
  396. picks up the wrong BSS object.
  397. The result is a mismatching channel configuration between
  398. cfg80211 and the driver, that can lead to any sort of
  399. problem.
  400. The issue can be triggered by having an IBSS sitting on
  401. given channel and then asking the driver to create a new
  402. cell using the same BSSID but with a different frequency.
  403. By passing the channel to cfg80211_get_bss() we can solve
  404. this ambiguity and retrieve/create the correct BSS object.
  405. All the users of cfg80211_ibss_joined() have been changed
  406. accordingly.
  407. Moreover WARN when cfg80211_ibss_joined() gets a NULL
  408. channel as argument and remove a bogus call of the same
  409. function in ath6kl (it does not make sense to call
  410. cfg80211_ibss_joined() with a zero BSSID on ibss-leave).
  411. Cc: Kalle Valo <[email protected]>
  412. Cc: Arend van Spriel <[email protected]>
  413. Cc: Bing Zhao <[email protected]>
  414. Cc: Jussi Kivilinna <[email protected]>
  415. Cc: [email protected]
  416. Acked-by: Kalle Valo <[email protected]>
  417. Signed-off-by: Antonio Quartulli <[email protected]>
  418. [minor code cleanup in ath6kl]
  419. Signed-off-by: Johannes Berg <[email protected]>
  420. commit 7e0c41cb41f215aba2c39b1c237bb4d42ec49a85
  421. Author: Johannes Berg <[email protected]>
  422. Date: Fri Jan 24 14:41:44 2014 +0100
  423. mac80211: fix bufferable MMPDU RX handling
  424. Action, disassoc and deauth frames are bufferable, and as such don't
  425. have the PM bit in the frame control field reserved which means we
  426. need to react to the bit when receiving in such a frame.
  427. Fix this by introducing a new helper ieee80211_is_bufferable_mmpdu()
  428. and using it for the RX path that currently ignores the PM bit in
  429. any non-data frames for doze->wake transitions, but listens to it in
  430. all frames for wake->doze transitions, both of which are wrong.
  431. Also use the new helper in the TX path to clean up the code.
  432. Signed-off-by: Johannes Berg <[email protected]>
  433. commit fc0df6d2343636e3f48a069330d5b972e3d8659d
  434. Author: Janusz Dziedzic <[email protected]>
  435. Date: Fri Jan 24 14:29:21 2014 +0100
  436. cfg80211: set preset_chandef after channel switch
  437. Set preset_chandef in channel switch notification.
  438. In other case we will have old preset_chandef.
  439. Signed-off-by: Janusz Dziedzic <[email protected]>
  440. Signed-off-by: Johannes Berg <[email protected]>
  441. commit cdec895e2344987ff171cece96e25d7407a3ebf6
  442. Author: Simon Wunderlich <[email protected]>
  443. Date: Fri Jan 24 23:48:29 2014 +0100
  444. mac80211: send ibss probe responses with noack flag
  445. Responding to probe requests for scanning clients will often create
  446. excessive retries, as it happens quite often that the scanning client
  447. already left the channel. Therefore do it like hostapd and send probe
  448. responses for wildcard SSID only once by using the noack flag.
  449. Signed-off-by: Simon Wunderlich <[email protected]>
  450. [fix typo & 'wildcard SSID' in commit log]
  451. Signed-off-by: Johannes Berg <[email protected]>
  452. commit 0b865d1e6b9c05052adae9315df7cb195dc60c3b
  453. Author: Luciano Coelho <[email protected]>
  454. Date: Tue Jan 28 17:09:08 2014 +0200
  455. mac80211: ibss: remove unnecessary call to release channel
  456. The ieee80211_vif_use_channel() function calls
  457. ieee80211_vif_release_channel(), so there's no need to call it
  458. explicitly in __ieee80211_sta_join_ibss().
  459. Signed-off-by: Luciano Coelho <[email protected]>
  460. Signed-off-by: Johannes Berg <[email protected]>
  461. commit e1b6c17e971f0a51ff86c2dac2584c63cd999cd7
  462. Author: Michal Kazior <[email protected]>
  463. Date: Wed Jan 29 07:56:21 2014 +0100
  464. mac80211: add missing CSA locking
  465. The patch adds a missing sdata lock and adds a few
  466. lockdeps for easier maintenance.
  467. Signed-off-by: Michal Kazior <[email protected]>
  468. Signed-off-by: Johannes Berg <[email protected]>
  469. commit ad17ba7d14d225b109b73c177cd446afb8050598
  470. Author: Michal Kazior <[email protected]>
  471. Date: Wed Jan 29 07:56:20 2014 +0100
  472. mac80211: fix sdata->radar_required locking
  473. radar_required setting wasn't protected by
  474. local->mtx in some places. This should prevent
  475. from scanning/radar detection/roc colliding.
  476. Signed-off-by: Michal Kazior <[email protected]>
  477. Signed-off-by: Johannes Berg <[email protected]>
  478. commit 5fcd5f1808813a3d9e502fd756e01bee8a79c85d
  479. Author: Michal Kazior <[email protected]>
  480. Date: Wed Jan 29 07:56:19 2014 +0100
  481. mac80211: move csa_active setting in STA CSA
  482. The sdata->vif.csa_active could be left set after,
  483. e.g. channel context constraints check fail in STA
  484. mode leaving the interface in a strange state for
  485. a brief period of time until it is disconnected.
  486. This was harmless but ugly.
  487. Signed-off-by: Michal Kazior <[email protected]>
  488. Reviewed-by: Luciano Coelho <[email protected]>
  489. Signed-off-by: Johannes Berg <[email protected]>
  490. commit e486da4b7eed71821c6b4c1bb9ac62ffd3ab13e9
  491. Author: Michal Kazior <[email protected]>
  492. Date: Wed Jan 29 07:56:18 2014 +0100
  493. mac80211: fix possible memory leak on AP CSA failure
  494. If CSA for AP interface failed and the interface
  495. was not stopped afterwards another CSA request
  496. would leak sdata->u.ap.next_beacon.
  497. Signed-off-by: Michal Kazior <[email protected]>
  498. Reviewed-by: Luciano Coelho <[email protected]>
  499. Signed-off-by: Johannes Berg <[email protected]>
  500. commit 3a77ba08940682bf3d52cf14f980337324af9d4a
  501. Author: Johannes Berg <[email protected]>
  502. Date: Sat Feb 1 00:33:29 2014 +0100
  503. mac80211: fix fragmentation code, particularly for encryption
  504. The "new" fragmentation code (since my rewrite almost 5 years ago)
  505. erroneously sets skb->len rather than using skb_trim() to adjust
  506. the length of the first fragment after copying out all the others.
  507. This leaves the skb tail pointer pointing to after where the data
  508. originally ended, and thus causes the encryption MIC to be written
  509. at that point, rather than where it belongs: immediately after the
  510. data.
  511. The impact of this is that if software encryption is done, then
  512. a) encryption doesn't work for the first fragment, the connection
  513. becomes unusable as the first fragment will never be properly
  514. verified at the receiver, the MIC is practically guaranteed to
  515. be wrong
  516. b) we leak up to 8 bytes of plaintext (!) of the packet out into
  517. the air
  518. This is only mitigated by the fact that many devices are capable
  519. of doing encryption in hardware, in which case this can't happen
  520. as the tail pointer is irrelevant in that case. Additionally,
  521. fragmentation is not used very frequently and would normally have
  522. to be configured manually.
  523. Fix this by using skb_trim() properly.
  524. Cc: [email protected]
  525. Fixes: 2de8e0d999b8 ("mac80211: rewrite fragmentation")
  526. Reported-by: Jouni Malinen <[email protected]>
  527. Signed-off-by: Johannes Berg <[email protected]>
  528. commit de5f242e0c10e841017e37eb8c38974a642dbca8
  529. Author: Sujith Manoharan <[email protected]>
  530. Date: Tue Jan 28 06:21:59 2014 +0530
  531. ath9k: Fix build error on ARM
  532. Use mdelay instead of udelay to fix this error:
  533. ERROR: "__bad_udelay" [drivers/net/wireless/ath/ath9k/ath9k_hw.ko] undefined!
  534. make[1]: *** [__modpost] Error 1
  535. make: *** [modules] Error 2
  536. Reported-by: Josh Boyer <[email protected]>
  537. Signed-off-by: Sujith Manoharan <[email protected]>
  538. commit 8e3ea7a51dfc61810fcefd947f6edcf61125252a
  539. Author: Geert Uytterhoeven <[email protected]>
  540. Date: Sun Jan 26 11:53:21 2014 +0100
  541. ath9k: Fix uninitialized variable in ath9k_has_tx_pending()
  542. drivers/net/wireless/ath/ath9k/main.c: In function ‘ath9k_has_tx_pending’:
  543. drivers/net/wireless/ath/ath9k/main.c:1869: warning: ‘npend’ may be used uninitialized in this function
  544. Introduced by commit 10e2318103f5941aa70c318afe34bc41f1b98529 ("ath9k:
  545. optimize ath9k_flush").
  546. Signed-off-by: Geert Uytterhoeven <[email protected]>
  547. commit a4a634a6937ebdd827fa58e8fcdb8ca49a3769f6
  548. Author: Emmanuel Grumbach <[email protected]>
  549. Date: Mon Jan 27 11:07:42 2014 +0200
  550. mac80211: release the channel in error path in start_ap
  551. When the driver cannot start the AP or when the assignement
  552. of the beacon goes wrong, we need to unassign the vif.
  553. Cc: [email protected]
  554. Signed-off-by: Emmanuel Grumbach <[email protected]>
  555. Signed-off-by: Johannes Berg <[email protected]>
  556. commit dfb6889a75c601aedb7450b7e606668e77da6679
  557. Author: Johannes Berg <[email protected]>
  558. Date: Wed Jan 22 11:14:19 2014 +0200
  559. cfg80211: send scan results from work queue
  560. Due to the previous commit, when a scan finishes, it is in theory
  561. possible to hit the following sequence:
  562. 1. interface starts being removed
  563. 2. scan is cancelled by driver and cfg80211 is notified
  564. 3. scan done work is scheduled
  565. 4. interface is removed completely, rdev->scan_req is freed,
  566. event sent to userspace but scan done work remains pending
  567. 5. new scan is requested on another virtual interface
  568. 6. scan done work runs, freeing the still-running scan
  569. To fix this situation, hang on to the scan done message and block
  570. new scans while that is the case, and only send the message from
  571. the work function, regardless of whether the scan_req is already
  572. freed from interface removal. This makes step 5 above impossible
  573. and changes step 6 to be
  574. 5. scan done work runs, sending the scan done message
  575. As this can't work for wext, so we send the message immediately,
  576. but this shouldn't be an issue since we still return -EBUSY.
  577. Signed-off-by: Johannes Berg <[email protected]>
  578. commit 45b7ab41fc08627d9a8428cb413d5d84662a9707
  579. Author: Johannes Berg <[email protected]>
  580. Date: Wed Jan 22 11:14:18 2014 +0200
  581. cfg80211: fix scan done race
  582. When an interface/wdev is removed, any ongoing scan should be
  583. cancelled by the driver. This will make it call cfg80211, which
  584. only queues a work struct. If interface/wdev removal is quick
  585. enough, this can leave the scan request pending and processed
  586. only after the interface is gone, causing a use-after-free.
  587. Fix this by making sure the scan request is not pending after
  588. the interface is destroyed. We can't flush or cancel the work
  589. item due to locking concerns, but when it'll run it shouldn't
  590. find anything to do. This leaves a potential issue, if a new
  591. scan gets requested before the work runs, it prematurely stops
  592. the running scan, potentially causing another crash. I'll fix
  593. that in the next patch.
  594. This was particularly observed with P2P_DEVICE wdevs, likely
  595. because freeing them is quicker than freeing netdevs.
  596. Reported-by: Andrei Otcheretianski <[email protected]>
  597. Fixes: 4a58e7c38443 ("cfg80211: don't "leak" uncompleted scans")
  598. Signed-off-by: Johannes Berg <[email protected]>
  599. commit ae04fa489ab31b5a10d3cc8399f52761175d4321
  600. Author: Emmanuel Grumbach <[email protected]>
  601. Date: Thu Jan 23 14:28:16 2014 +0200
  602. mac80211: avoid deadlock revealed by lockdep
  603. sdata->u.ap.request_smps_work can’t be flushed synchronously
  604. under wdev_lock(wdev) since ieee80211_request_smps_ap_work
  605. itself locks the same lock.
  606. While at it, reset the driver_smps_mode when the ap is
  607. stopped to its default: OFF.
  608. This solves:
  609. ======================================================
  610. [ INFO: possible circular locking dependency detected ]
  611. 3.12.0-ipeer+ #2 Tainted: G O
  612. -------------------------------------------------------
  613. rmmod/2867 is trying to acquire lock:
  614. ((&sdata->u.ap.request_smps_work)){+.+...}, at: [<c105b8d0>] flush_work+0x0/0x90
  615. but task is already holding lock:
  616. (&wdev->mtx){+.+.+.}, at: [<f9b32626>] cfg80211_stop_ap+0x26/0x230 [cfg80211]
  617. which lock already depends on the new lock.
  618. the existing dependency chain (in reverse order) is:
  619. -> #1 (&wdev->mtx){+.+.+.}:
  620. [<c10aefa9>] lock_acquire+0x79/0xe0
  621. [<c1607a1a>] mutex_lock_nested+0x4a/0x360
  622. [<fb06288b>] ieee80211_request_smps_ap_work+0x2b/0x50 [mac80211]
  623. [<c105cdd8>] process_one_work+0x198/0x450
  624. [<c105d469>] worker_thread+0xf9/0x320
  625. [<c10669ff>] kthread+0x9f/0xb0
  626. [<c1613397>] ret_from_kernel_thread+0x1b/0x28
  627. -> #0 ((&sdata->u.ap.request_smps_work)){+.+...}:
  628. [<c10ae9df>] __lock_acquire+0x183f/0x1910
  629. [<c10aefa9>] lock_acquire+0x79/0xe0
  630. [<c105b917>] flush_work+0x47/0x90
  631. [<c105d867>] __cancel_work_timer+0x67/0xe0
  632. [<c105d90f>] cancel_work_sync+0xf/0x20
  633. [<fb0765cc>] ieee80211_stop_ap+0x8c/0x340 [mac80211]
  634. [<f9b3268c>] cfg80211_stop_ap+0x8c/0x230 [cfg80211]
  635. [<f9b0d8f9>] cfg80211_leave+0x79/0x100 [cfg80211]
  636. [<f9b0da72>] cfg80211_netdev_notifier_call+0xf2/0x4f0 [cfg80211]
  637. [<c160f2c9>] notifier_call_chain+0x59/0x130
  638. [<c106c6de>] __raw_notifier_call_chain+0x1e/0x30
  639. [<c106c70f>] raw_notifier_call_chain+0x1f/0x30
  640. [<c14f8213>] call_netdevice_notifiers_info+0x33/0x70
  641. [<c14f8263>] call_netdevice_notifiers+0x13/0x20
  642. [<c14f82a4>] __dev_close_many+0x34/0xb0
  643. [<c14f83fe>] dev_close_many+0x6e/0xc0
  644. [<c14f9c77>] rollback_registered_many+0xa7/0x1f0
  645. [<c14f9dd4>] unregister_netdevice_many+0x14/0x60
  646. [<fb06f4d9>] ieee80211_remove_interfaces+0xe9/0x170 [mac80211]
  647. [<fb055116>] ieee80211_unregister_hw+0x56/0x110 [mac80211]
  648. [<fa3e9396>] iwl_op_mode_mvm_stop+0x26/0xe0 [iwlmvm]
  649. [<f9b9d8ca>] _iwl_op_mode_stop+0x3a/0x70 [iwlwifi]
  650. [<f9b9d96f>] iwl_opmode_deregister+0x6f/0x90 [iwlwifi]
  651. [<fa405179>] __exit_compat+0xd/0x19 [iwlmvm]
  652. [<c10b8bf9>] SyS_delete_module+0x179/0x2b0
  653. [<c1613421>] sysenter_do_call+0x12/0x32
  654. Fixes: 687da132234f ("mac80211: implement SMPS for AP")
  655. Cc: <[email protected]> [3.13]
  656. Reported-by: Ilan Peer <[email protected]>
  657. Signed-off-by: Emmanuel Grumbach <[email protected]>
  658. Signed-off-by: Johannes Berg <[email protected]>
  659. commit 178b205e96217164fd7c30113464250d0b6f5eca
  660. Author: Johannes Berg <[email protected]>
  661. Date: Thu Jan 23 16:32:29 2014 +0100
  662. cfg80211: re-enable 5/10 MHz support
  663. Unfortunately I forgot this during the merge window, but the
  664. patch seems small enough to go in as a fix. The userspace API
  665. bug that was the reason for disabling it has long been fixed.
  666. Signed-off-by: Johannes Berg <[email protected]>
  667. commit 110a1c79acda14edc83b7c8dc5af9c7ddd23eb61
  668. Author: Pontus Fuchs <[email protected]>
  669. Date: Thu Jan 16 15:00:40 2014 +0100
  670. nl80211: Reset split_start when netlink skb is exhausted
  671. When the netlink skb is exhausted split_start is left set. In the
  672. subsequent retry, with a larger buffer, the dump is continued from the
  673. failing point instead of from the beginning.
  674. This was causing my rt28xx based USB dongle to now show up when
  675. running "iw list" with an old iw version without split dump support.
  676. Cc: [email protected]
  677. Fixes: 3713b4e364ef ("nl80211: allow splitting wiphy information in dumps")
  678. Signed-off-by: Pontus Fuchs <[email protected]>
  679. [avoid the entire workaround when state->split is set]
  680. Signed-off-by: Johannes Berg <[email protected]>
  681. commit b4c31b45ffc7ef110fa9ecc34d7878fe7c5b9da4
  682. Author: Eliad Peller <[email protected]>
  683. Date: Sun Jan 12 11:06:37 2014 +0200
  684. mac80211: move roc cookie assignment earlier
  685. ieee80211_start_roc_work() might add a new roc
  686. to existing roc, and tell cfg80211 it has already
  687. started.
  688. However, this might happen before the roc cookie
  689. was set, resulting in REMAIN_ON_CHANNEL (started)
  690. event with null cookie. Consequently, it can make
  691. wpa_supplicant go out of sync.
  692. Fix it by setting the roc cookie earlier.
  693. Cc: [email protected]
  694. Signed-off-by: Eliad Peller <[email protected]>
  695. Signed-off-by: Johannes Berg <[email protected]>
  696. commit cfdc9157bfd7bcf88ab4dae08873a9907eba984c
  697. Author: Johannes Berg <[email protected]>
  698. Date: Fri Jan 24 14:06:29 2014 +0100
  699. nl80211: send event when AP operation is stopped
  700. There are a few cases, e.g. suspend, where an AP interface is
  701. stopped by the kernel rather than by userspace request, most
  702. commonly when suspending. To let userspace know about this,
  703. send the NL80211_CMD_STOP_AP command as an event every time
  704. an AP interface is stopped. This also happens when userspace
  705. did in fact request the AP stop, but that's not a problem.
  706. For full-MAC drivers this may need to be extended to also
  707. cover cases where the device stopped the AP operation for
  708. some reason, this a bit more complicated because then all
  709. cfg80211 state also needs to be reset; such API is not part
  710. of this patch.
  711. Signed-off-by: Johannes Berg <[email protected]>
  712. commit d5d567eda7704f190379ca852a8f9a4112e3eee3
  713. Author: Johannes Berg <[email protected]>
  714. Date: Thu Jan 23 16:20:29 2014 +0100
  715. mac80211: add length check in ieee80211_is_robust_mgmt_frame()
  716. A few places weren't checking that the frame passed to the
  717. function actually has enough data even though the function
  718. clearly documents it must have a payload byte. Make this
  719. safer by changing the function to take an skb and checking
  720. the length inside. The old version is preserved for now as
  721. the rtl* drivers use it and don't have a correct skb.
  722. Signed-off-by: Johannes Berg <[email protected]>
  723. commit f8f6d212a047fc65c7d3442dfc038f65517236fc
  724. Author: Johannes Berg <[email protected]>
  725. Date: Fri Jan 24 10:53:53 2014 +0100
  726. nl80211: fix scheduled scan RSSI matchset attribute confusion
  727. The scheduled scan matchsets were intended to be a list of filters,
  728. with the found BSS having to pass at least one of them to be passed
  729. to the host. When the RSSI attribute was added, however, this was
  730. broken and currently wpa_supplicant adds that attribute in its own
  731. matchset; however, it doesn't intend that to mean that anything
  732. that passes the RSSI filter should be passed to the host, instead
  733. it wants it to mean that everything needs to also have higher RSSI.
  734. This is semantically problematic because we have a list of filters
  735. like [ SSID1, SSID2, SSID3, RSSI ] with no real indication which
  736. one should be OR'ed and which one AND'ed.
  737. To fix this, move the RSSI filter attribute into each matchset. As
  738. we need to stay backward compatible, treat a matchset with only the
  739. RSSI attribute as a "default RSSI filter" for all other matchsets,
  740. but only if there are other matchsets (an RSSI-only matchset by
  741. itself is still desirable.)
  742. To make driver implementation easier, keep a global min_rssi_thold
  743. for the entire request as well. The only affected driver is ath6kl.
  744. I found this when I looked into the code after Raja Mani submitted
  745. a patch fixing the n_match_sets calculation to disregard the RSSI,
  746. but that patch didn't address the semantic issue.
  747. Reported-by: Raja Mani <[email protected]>
  748. Acked-by: Luciano Coelho <[email protected]>
  749. Signed-off-by: Johannes Berg <[email protected]>
  750. commit de553e8545e65a6dc4e45f43df7e1443d4291922
  751. Author: Johannes Berg <[email protected]>
  752. Date: Fri Jan 24 10:17:47 2014 +0100
  753. nl80211: check nla_parse() return values
  754. If there's a policy, then nla_parse() return values must be
  755. checked, otherwise the policy is useless and there's nothing
  756. that ensures the attributes are actually what we expect them
  757. to be.
  758. Signed-off-by: Johannes Berg <[email protected]>
  759. commit 652204a0733e9e1c54661d6f9d36e2e1e3b22bb1
  760. Author: Karl Beldan <[email protected]>
  761. Date: Thu Jan 23 20:06:34 2014 +0100
  762. mac80211: send {ADD,DEL}BA on AC_VO like other mgmt frames, as per spec
  763. ATM, {ADD,DEL}BA and BAR frames are sent on the AC matching the TID of
  764. the BA parameters. In the discussion [1] about this patch, Johannes
  765. recalled that it fixed some races with the DELBA and indeed this
  766. behavior was introduced in [2].
  767. While [2] is right for the BARs, the part queueing the {ADD,DEL}BAs on
  768. their BA params TID AC violates the spec and is more a workaround for
  769. some drivers. Helmut expressed some concerns wrt such drivers, in
  770. particular DELBAs in rt2x00.
  771. ATM, DELBAs are sent after a driver has called (hence "purposely")
  772. ieee80211_start_tx_ba_cb_irqsafe and Johannes and Emmanuel gave some
  773. details wrt intentions behind the split of the IEEE80211_AMPDU_TX_STOP_*
  774. given to the driver ampdu_action supposed to call this function, which
  775. could prove handy to people trying to do the right thing in faulty
  776. drivers (if their fw/hw don't get in their way).
  777. [1] http://mid.gmane.org/[email protected]
  778. [2] Commit: cf6bb79ad828 ("mac80211: Use appropriate TID for sending BAR, ADDBA and DELBA frames")
  779. Signed-off-by: Karl Beldan <[email protected]>
  780. Cc: Helmut Schaa <[email protected]>
  781. Cc: Emmanuel Grumbach <[email protected]>
  782. Signed-off-by: Johannes Berg <[email protected]>
  783. --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
  784. +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
  785. @@ -790,7 +790,7 @@ void ath6kl_cfg80211_connect_event(struc
  786. if (nw_type & ADHOC_NETWORK) {
  787. ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "ad-hoc %s selected\n",
  788. nw_type & ADHOC_CREATOR ? "creator" : "joiner");
  789. - cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL);
  790. + cfg80211_ibss_joined(vif->ndev, bssid, chan, GFP_KERNEL);
  791. cfg80211_put_bss(ar->wiphy, bss);
  792. return;
  793. }
  794. @@ -861,13 +861,9 @@ void ath6kl_cfg80211_disconnect_event(st
  795. }
  796. if (vif->nw_type & ADHOC_NETWORK) {
  797. - if (vif->wdev.iftype != NL80211_IFTYPE_ADHOC) {
  798. + if (vif->wdev.iftype != NL80211_IFTYPE_ADHOC)
  799. ath6kl_dbg(ATH6KL_DBG_WLAN_CFG,
  800. "%s: ath6k not in ibss mode\n", __func__);
  801. - return;
  802. - }
  803. - memset(bssid, 0, ETH_ALEN);
  804. - cfg80211_ibss_joined(vif->ndev, bssid, GFP_KERNEL);
  805. return;
  806. }
  807. @@ -3256,6 +3252,15 @@ static int ath6kl_cfg80211_sscan_start(s
  808. struct ath6kl_vif *vif = netdev_priv(dev);
  809. u16 interval;
  810. int ret, rssi_thold;
  811. + int n_match_sets = request->n_match_sets;
  812. +
  813. + /*
  814. + * If there's a matchset w/o an SSID, then assume it's just for
  815. + * the RSSI (nothing else is currently supported) and ignore it.
  816. + * The device only supports a global RSSI filter that we set below.
  817. + */
  818. + if (n_match_sets == 1 && !request->match_sets[0].ssid.ssid_len)
  819. + n_match_sets = 0;
  820. if (ar->state != ATH6KL_STATE_ON)
  821. return -EIO;
  822. @@ -3268,11 +3273,11 @@ static int ath6kl_cfg80211_sscan_start(s
  823. ret = ath6kl_set_probed_ssids(ar, vif, request->ssids,
  824. request->n_ssids,
  825. request->match_sets,
  826. - request->n_match_sets);
  827. + n_match_sets);
  828. if (ret < 0)
  829. return ret;
  830. - if (!request->n_match_sets) {
  831. + if (!n_match_sets) {
  832. ret = ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
  833. ALL_BSS_FILTER, 0);
  834. if (ret < 0)
  835. @@ -3286,12 +3291,12 @@ static int ath6kl_cfg80211_sscan_start(s
  836. if (test_bit(ATH6KL_FW_CAPABILITY_RSSI_SCAN_THOLD,
  837. ar->fw_capabilities)) {
  838. - if (request->rssi_thold <= NL80211_SCAN_RSSI_THOLD_OFF)
  839. + if (request->min_rssi_thold <= NL80211_SCAN_RSSI_THOLD_OFF)
  840. rssi_thold = 0;
  841. - else if (request->rssi_thold < -127)
  842. + else if (request->min_rssi_thold < -127)
  843. rssi_thold = -127;
  844. else
  845. - rssi_thold = request->rssi_thold;
  846. + rssi_thold = request->min_rssi_thold;
  847. ret = ath6kl_wmi_set_rssi_filter_cmd(ar->wmi, vif->fw_vif_idx,
  848. rssi_thold);
  849. --- a/drivers/net/wireless/ath/ath9k/hw.c
  850. +++ b/drivers/net/wireless/ath/ath9k/hw.c
  851. @@ -1316,7 +1316,7 @@ static bool ath9k_hw_set_reset(struct at
  852. if (AR_SREV_9300_20_OR_LATER(ah))
  853. udelay(50);
  854. else if (AR_SREV_9100(ah))
  855. - udelay(10000);
  856. + mdelay(10);
  857. else
  858. udelay(100);
  859. @@ -1534,7 +1534,7 @@ EXPORT_SYMBOL(ath9k_hw_check_nav);
  860. bool ath9k_hw_check_alive(struct ath_hw *ah)
  861. {
  862. int count = 50;
  863. - u32 reg;
  864. + u32 reg, last_val;
  865. if (AR_SREV_9300(ah))
  866. return !ath9k_hw_detect_mac_hang(ah);
  867. @@ -1542,9 +1542,13 @@ bool ath9k_hw_check_alive(struct ath_hw
  868. if (AR_SREV_9285_12_OR_LATER(ah))
  869. return true;
  870. + last_val = REG_READ(ah, AR_OBS_BUS_1);
  871. do {
  872. reg = REG_READ(ah, AR_OBS_BUS_1);
  873. + if (reg != last_val)
  874. + return true;
  875. + last_val = reg;
  876. if ((reg & 0x7E7FFFEF) == 0x00702400)
  877. continue;
  878. @@ -1556,6 +1560,8 @@ bool ath9k_hw_check_alive(struct ath_hw
  879. default:
  880. return true;
  881. }
  882. +
  883. + udelay(1);
  884. } while (count-- > 0);
  885. return false;
  886. @@ -2051,9 +2057,8 @@ static bool ath9k_hw_set_power_awake(str
  887. REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
  888. AR_RTC_FORCE_WAKE_EN);
  889. -
  890. if (AR_SREV_9100(ah))
  891. - udelay(10000);
  892. + mdelay(10);
  893. else
  894. udelay(50);
  895. --- a/drivers/net/wireless/ath/ath9k/main.c
  896. +++ b/drivers/net/wireless/ath/ath9k/main.c
  897. @@ -451,7 +451,7 @@ void ath9k_tasklet(unsigned long data)
  898. * interrupts are enabled in the reset routine.
  899. */
  900. atomic_inc(&ah->intr_ref_cnt);
  901. - ath_dbg(common, ANY, "FATAL: Skipping interrupts\n");
  902. + ath_dbg(common, RESET, "FATAL: Skipping interrupts\n");
  903. goto out;
  904. }
  905. @@ -471,7 +471,7 @@ void ath9k_tasklet(unsigned long data)
  906. * interrupts are enabled in the reset routine.
  907. */
  908. atomic_inc(&ah->intr_ref_cnt);
  909. - ath_dbg(common, ANY,
  910. + ath_dbg(common, RESET,
  911. "BB_WATCHDOG: Skipping interrupts\n");
  912. goto out;
  913. }
  914. @@ -484,7 +484,7 @@ void ath9k_tasklet(unsigned long data)
  915. type = RESET_TYPE_TX_GTT;
  916. ath9k_queue_reset(sc, type);
  917. atomic_inc(&ah->intr_ref_cnt);
  918. - ath_dbg(common, ANY,
  919. + ath_dbg(common, RESET,
  920. "GTT: Skipping interrupts\n");
  921. goto out;
  922. }
  923. @@ -1866,7 +1866,7 @@ static void ath9k_set_coverage_class(str
  924. static bool ath9k_has_tx_pending(struct ath_softc *sc)
  925. {
  926. - int i, npend;
  927. + int i, npend = 0;
  928. for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
  929. if (!ATH_TXQ_SETUP(sc, i))
  930. --- a/drivers/net/wireless/iwlwifi/mvm/scan.c
  931. +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
  932. @@ -595,6 +595,9 @@ static void iwl_scan_offload_build_ssid(
  933. * config match list.
  934. */
  935. for (i = 0; i < req->n_match_sets && i < PROBE_OPTION_MAX; i++) {
  936. + /* skip empty SSID matchsets */
  937. + if (!req->match_sets[i].ssid.ssid_len)
  938. + continue;
  939. scan->direct_scan[i].id = WLAN_EID_SSID;
  940. scan->direct_scan[i].len = req->match_sets[i].ssid.ssid_len;
  941. memcpy(scan->direct_scan[i].ssid, req->match_sets[i].ssid.ssid,
  942. --- a/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
  943. +++ b/drivers/net/wireless/rtlwifi/rtl8188ee/trx.c
  944. @@ -452,7 +452,7 @@ bool rtl88ee_rx_query_desc(struct ieee80
  945. /* During testing, hdr was NULL */
  946. return false;
  947. }
  948. - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
  949. + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
  950. (ieee80211_has_protected(hdr->frame_control)))
  951. rx_status->flag &= ~RX_FLAG_DECRYPTED;
  952. else
  953. --- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
  954. +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
  955. @@ -393,7 +393,7 @@ bool rtl92ce_rx_query_desc(struct ieee80
  956. /* In testing, hdr was NULL here */
  957. return false;
  958. }
  959. - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
  960. + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
  961. (ieee80211_has_protected(hdr->frame_control)))
  962. rx_status->flag &= ~RX_FLAG_DECRYPTED;
  963. else
  964. --- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
  965. +++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
  966. @@ -310,7 +310,7 @@ bool rtl92se_rx_query_desc(struct ieee80
  967. /* during testing, hdr was NULL here */
  968. return false;
  969. }
  970. - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
  971. + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
  972. (ieee80211_has_protected(hdr->frame_control)))
  973. rx_status->flag &= ~RX_FLAG_DECRYPTED;
  974. else
  975. --- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
  976. +++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
  977. @@ -334,7 +334,7 @@ bool rtl8723ae_rx_query_desc(struct ieee
  978. /* during testing, hdr could be NULL here */
  979. return false;
  980. }
  981. - if ((ieee80211_is_robust_mgmt_frame(hdr)) &&
  982. + if ((_ieee80211_is_robust_mgmt_frame(hdr)) &&
  983. (ieee80211_has_protected(hdr->frame_control)))
  984. rx_status->flag &= ~RX_FLAG_DECRYPTED;
  985. else
  986. --- a/include/linux/ieee80211.h
  987. +++ b/include/linux/ieee80211.h
  988. @@ -597,6 +597,20 @@ static inline int ieee80211_is_qos_nullf
  989. }
  990. /**
  991. + * ieee80211_is_bufferable_mmpdu - check if frame is bufferable MMPDU
  992. + * @fc: frame control field in little-endian byteorder
  993. + */
  994. +static inline bool ieee80211_is_bufferable_mmpdu(__le16 fc)
  995. +{
  996. + /* IEEE 802.11-2012, definition of "bufferable management frame";
  997. + * note that this ignores the IBSS special case. */
  998. + return ieee80211_is_mgmt(fc) &&
  999. + (ieee80211_is_action(fc) ||
  1000. + ieee80211_is_disassoc(fc) ||
  1001. + ieee80211_is_deauth(fc));
  1002. +}
  1003. +
  1004. +/**
  1005. * ieee80211_is_first_frag - check if IEEE80211_SCTL_FRAG is not set
  1006. * @seq_ctrl: frame sequence control bytes in little-endian byteorder
  1007. */
  1008. @@ -2192,10 +2206,10 @@ static inline u8 *ieee80211_get_DA(struc
  1009. }
  1010. /**
  1011. - * ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
  1012. + * _ieee80211_is_robust_mgmt_frame - check if frame is a robust management frame
  1013. * @hdr: the frame (buffer must include at least the first octet of payload)
  1014. */
  1015. -static inline bool ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
  1016. +static inline bool _ieee80211_is_robust_mgmt_frame(struct ieee80211_hdr *hdr)
  1017. {
  1018. if (ieee80211_is_disassoc(hdr->frame_control) ||
  1019. ieee80211_is_deauth(hdr->frame_control))
  1020. @@ -2224,6 +2238,17 @@ static inline bool ieee80211_is_robust_m
  1021. }
  1022. /**
  1023. + * ieee80211_is_robust_mgmt_frame - check if skb contains a robust mgmt frame
  1024. + * @skb: the skb containing the frame, length will be checked
  1025. + */
  1026. +static inline bool ieee80211_is_robust_mgmt_frame(struct sk_buff *skb)
  1027. +{
  1028. + if (skb->len < 25)
  1029. + return false;
  1030. + return _ieee80211_is_robust_mgmt_frame((void *)skb->data);
  1031. +}
  1032. +
  1033. +/**
  1034. * ieee80211_is_public_action - check if frame is a public action frame
  1035. * @hdr: the frame
  1036. * @len: length of the frame
  1037. --- a/include/net/cfg80211.h
  1038. +++ b/include/net/cfg80211.h
  1039. @@ -1395,9 +1395,11 @@ struct cfg80211_scan_request {
  1040. * struct cfg80211_match_set - sets of attributes to match
  1041. *
  1042. * @ssid: SSID to be matched
  1043. + * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
  1044. */
  1045. struct cfg80211_match_set {
  1046. struct cfg80211_ssid ssid;
  1047. + s32 rssi_thold;
  1048. };
  1049. /**
  1050. @@ -1420,7 +1422,8 @@ struct cfg80211_match_set {
  1051. * @dev: the interface
  1052. * @scan_start: start time of the scheduled scan
  1053. * @channels: channels to scan
  1054. - * @rssi_thold: don't report scan results below this threshold (in s32 dBm)
  1055. + * @min_rssi_thold: for drivers only supporting a single threshold, this
  1056. + * contains the minimum over all matchsets
  1057. */
  1058. struct cfg80211_sched_scan_request {
  1059. struct cfg80211_ssid *ssids;
  1060. @@ -1433,7 +1436,7 @@ struct cfg80211_sched_scan_request {
  1061. u32 flags;
  1062. struct cfg80211_match_set *match_sets;
  1063. int n_match_sets;
  1064. - s32 rssi_thold;
  1065. + s32 min_rssi_thold;
  1066. /* internal */
  1067. struct wiphy *wiphy;
  1068. @@ -3130,8 +3133,8 @@ struct cfg80211_cached_keys;
  1069. * @identifier: (private) Identifier used in nl80211 to identify this
  1070. * wireless device if it has no netdev
  1071. * @current_bss: (private) Used by the internal configuration code
  1072. - * @channel: (private) Used by the internal configuration code to track
  1073. - * the user-set AP, monitor and WDS channel
  1074. + * @chandef: (private) Used by the internal configuration code to track
  1075. + * the user-set channel definition.
  1076. * @preset_chandef: (private) Used by the internal configuration code to
  1077. * track the channel to be used for AP later
  1078. * @bssid: (private) Used by the internal configuration code
  1079. @@ -3195,9 +3198,7 @@ struct wireless_dev {
  1080. struct cfg80211_internal_bss *current_bss; /* associated / joined */
  1081. struct cfg80211_chan_def preset_chandef;
  1082. -
  1083. - /* for AP and mesh channel tracking */
  1084. - struct ieee80211_channel *channel;
  1085. + struct cfg80211_chan_def chandef;
  1086. bool ibss_fixed;
  1087. bool ibss_dfs_possible;
  1088. @@ -3879,6 +3880,7 @@ void cfg80211_michael_mic_failure(struct
  1089. *
  1090. * @dev: network device
  1091. * @bssid: the BSSID of the IBSS joined
  1092. + * @channel: the channel of the IBSS joined
  1093. * @gfp: allocation flags
  1094. *
  1095. * This function notifies cfg80211 that the device joined an IBSS or
  1096. @@ -3888,7 +3890,8 @@ void cfg80211_michael_mic_failure(struct
  1097. * with the locally generated beacon -- this guarantees that there is
  1098. * always a scan result for this IBSS. cfg80211 will handle the rest.
  1099. */
  1100. -void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp);
  1101. +void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
  1102. + struct ieee80211_channel *channel, gfp_t gfp);
  1103. /**
  1104. * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate
  1105. --- a/include/uapi/linux/nl80211.h
  1106. +++ b/include/uapi/linux/nl80211.h
  1107. @@ -2442,9 +2442,15 @@ enum nl80211_reg_rule_attr {
  1108. * enum nl80211_sched_scan_match_attr - scheduled scan match attributes
  1109. * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
  1110. * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
  1111. - * only report BSS with matching SSID.
  1112. + * only report BSS with matching SSID.
  1113. * @NL80211_SCHED_SCAN_MATCH_ATTR_RSSI: RSSI threshold (in dBm) for reporting a
  1114. - * BSS in scan results. Filtering is turned off if not specified.
  1115. + * BSS in scan results. Filtering is turned off if not specified. Note that
  1116. + * if this attribute is in a match set of its own, then it is treated as
  1117. + * the default value for all matchsets with an SSID, rather than being a
  1118. + * matchset of its own without an RSSI filter. This is due to problems with
  1119. + * how this API was implemented in the past. Also, due to the same problem,
  1120. + * the only way to create a matchset with only an RSSI filter (with this
  1121. + * attribute) is if there's only a single matchset with the RSSI attribute.
  1122. * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
  1123. * attribute number currently defined
  1124. * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
  1125. --- a/net/mac80211/agg-tx.c
  1126. +++ b/net/mac80211/agg-tx.c
  1127. @@ -107,7 +107,7 @@ static void ieee80211_send_addba_request
  1128. mgmt->u.action.u.addba_req.start_seq_num =
  1129. cpu_to_le16(start_seq_num << 4);
  1130. - ieee80211_tx_skb_tid(sdata, skb, tid);
  1131. + ieee80211_tx_skb(sdata, skb);
  1132. }
  1133. void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn)
  1134. --- a/net/mac80211/cfg.c
  1135. +++ b/net/mac80211/cfg.c
  1136. @@ -970,9 +970,9 @@ static int ieee80211_start_ap(struct wip
  1137. /* TODO: make hostapd tell us what it wants */
  1138. sdata->smps_mode = IEEE80211_SMPS_OFF;
  1139. sdata->needed_rx_chains = sdata->local->rx_chains;
  1140. - sdata->radar_required = params->radar_required;
  1141. mutex_lock(&local->mtx);
  1142. + sdata->radar_required = params->radar_required;
  1143. err = ieee80211_vif_use_channel(sdata, &params->chandef,
  1144. IEEE80211_CHANCTX_SHARED);
  1145. mutex_unlock(&local->mtx);
  1146. @@ -1021,8 +1021,10 @@ static int ieee80211_start_ap(struct wip
  1147. IEEE80211_P2P_OPPPS_ENABLE_BIT;
  1148. err = ieee80211_assign_beacon(sdata, &params->beacon);
  1149. - if (err < 0)
  1150. + if (err < 0) {
  1151. + ieee80211_vif_release_channel(sdata);
  1152. return err;
  1153. + }
  1154. changed |= err;
  1155. err = drv_start_ap(sdata->local, sdata);
  1156. @@ -1032,6 +1034,7 @@ static int ieee80211_start_ap(struct wip
  1157. if (old)
  1158. kfree_rcu(old, rcu_head);
  1159. RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
  1160. + ieee80211_vif_release_channel(sdata);
  1161. return err;
  1162. }
  1163. @@ -1053,6 +1056,7 @@ static int ieee80211_change_beacon(struc
  1164. int err;
  1165. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1166. + sdata_assert_lock(sdata);
  1167. /* don't allow changing the beacon while CSA is in place - offset
  1168. * of channel switch counter may change
  1169. @@ -1080,6 +1084,8 @@ static int ieee80211_stop_ap(struct wiph
  1170. struct probe_resp *old_probe_resp;
  1171. struct cfg80211_chan_def chandef;
  1172. + sdata_assert_lock(sdata);
  1173. +
  1174. old_beacon = sdata_dereference(sdata->u.ap.beacon, sdata);
  1175. if (!old_beacon)
  1176. return -ENOENT;
  1177. @@ -1090,8 +1096,6 @@ static int ieee80211_stop_ap(struct wiph
  1178. kfree(sdata->u.ap.next_beacon);
  1179. sdata->u.ap.next_beacon = NULL;
  1180. - cancel_work_sync(&sdata->u.ap.request_smps_work);
  1181. -
  1182. /* turn off carrier for this interface and dependent VLANs */
  1183. list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
  1184. netif_carrier_off(vlan->dev);
  1185. @@ -1103,6 +1107,7 @@ static int ieee80211_stop_ap(struct wiph
  1186. kfree_rcu(old_beacon, rcu_head);
  1187. if (old_probe_resp)
  1188. kfree_rcu(old_probe_resp, rcu_head);
  1189. + sdata->u.ap.driver_smps_mode = IEEE80211_SMPS_OFF;
  1190. __sta_info_flush(sdata, true);
  1191. ieee80211_free_keys(sdata, true);
  1192. @@ -2638,6 +2643,24 @@ static int ieee80211_start_roc_work(stru
  1193. INIT_DELAYED_WORK(&roc->work, ieee80211_sw_roc_work);
  1194. INIT_LIST_HEAD(&roc->dependents);
  1195. + /*
  1196. + * cookie is either the roc cookie (for normal roc)
  1197. + * or the SKB (for mgmt TX)
  1198. + */
  1199. + if (!txskb) {
  1200. + /* local->mtx protects this */
  1201. + local->roc_cookie_counter++;
  1202. + roc->cookie = local->roc_cookie_counter;
  1203. + /* wow, you wrapped 64 bits ... more likely a bug */
  1204. + if (WARN_ON(roc->cookie == 0)) {
  1205. + roc->cookie = 1;
  1206. + local->roc_cookie_counter++;
  1207. + }
  1208. + *cookie = roc->cookie;
  1209. + } else {
  1210. + *cookie = (unsigned long)txskb;
  1211. + }
  1212. +
  1213. /* if there's one pending or we're scanning, queue this one */
  1214. if (!list_empty(&local->roc_list) ||
  1215. local->scanning || local->radar_detect_enabled)
  1216. @@ -2772,24 +2795,6 @@ static int ieee80211_start_roc_work(stru
  1217. if (!queued)
  1218. list_add_tail(&roc->list, &local->roc_list);
  1219. - /*
  1220. - * cookie is either the roc cookie (for normal roc)
  1221. - * or the SKB (for mgmt TX)
  1222. - */
  1223. - if (!txskb) {
  1224. - /* local->mtx protects this */
  1225. - local->roc_cookie_counter++;
  1226. - roc->cookie = local->roc_cookie_counter;
  1227. - /* wow, you wrapped 64 bits ... more likely a bug */
  1228. - if (WARN_ON(roc->cookie == 0)) {
  1229. - roc->cookie = 1;
  1230. - local->roc_cookie_counter++;
  1231. - }
  1232. - *cookie = roc->cookie;
  1233. - } else {
  1234. - *cookie = (unsigned long)txskb;
  1235. - }
  1236. -
  1237. return 0;
  1238. }
  1239. @@ -3004,8 +3009,10 @@ void ieee80211_csa_finalize_work(struct
  1240. if (!ieee80211_sdata_running(sdata))
  1241. goto unlock;
  1242. - sdata->radar_required = sdata->csa_radar_required;
  1243. + sdata_assert_lock(sdata);
  1244. +
  1245. mutex_lock(&local->mtx);
  1246. + sdata->radar_required = sdata->csa_radar_required;
  1247. err = ieee80211_vif_change_channel(sdata, &changed);
  1248. mutex_unlock(&local->mtx);
  1249. if (WARN_ON(err < 0))
  1250. @@ -3022,13 +3029,13 @@ void ieee80211_csa_finalize_work(struct
  1251. switch (sdata->vif.type) {
  1252. case NL80211_IFTYPE_AP:
  1253. err = ieee80211_assign_beacon(sdata, sdata->u.ap.next_beacon);
  1254. + kfree(sdata->u.ap.next_beacon);
  1255. + sdata->u.ap.next_beacon = NULL;
  1256. +
  1257. if (err < 0)
  1258. goto unlock;
  1259. changed |= err;
  1260. - kfree(sdata->u.ap.next_beacon);
  1261. - sdata->u.ap.next_beacon = NULL;
  1262. -
  1263. ieee80211_bss_info_change_notify(sdata, err);
  1264. break;
  1265. case NL80211_IFTYPE_ADHOC:
  1266. @@ -3066,7 +3073,7 @@ int ieee80211_channel_switch(struct wiph
  1267. struct ieee80211_if_mesh __maybe_unused *ifmsh;
  1268. int err, num_chanctx;
  1269. - lockdep_assert_held(&sdata->wdev.mtx);
  1270. + sdata_assert_lock(sdata);
  1271. if (!list_empty(&local->roc_list) || local->scanning)
  1272. return -EBUSY;
  1273. --- a/net/mac80211/ht.c
  1274. +++ b/net/mac80211/ht.c
  1275. @@ -375,7 +375,7 @@ void ieee80211_send_delba(struct ieee802
  1276. mgmt->u.action.u.delba.params = cpu_to_le16(params);
  1277. mgmt->u.action.u.delba.reason_code = cpu_to_le16(reason_code);
  1278. - ieee80211_tx_skb_tid(sdata, skb, tid);
  1279. + ieee80211_tx_skb(sdata, skb);
  1280. }
  1281. void ieee80211_process_delba(struct ieee80211_sub_if_data *sdata,
  1282. @@ -466,7 +466,9 @@ void ieee80211_request_smps_ap_work(stru
  1283. u.ap.request_smps_work);
  1284. sdata_lock(sdata);
  1285. - __ieee80211_request_smps_ap(sdata, sdata->u.ap.driver_smps_mode);
  1286. + if (sdata_dereference(sdata->u.ap.beacon, sdata))
  1287. + __ieee80211_request_smps_ap(sdata,
  1288. + sdata->u.ap.driver_smps_mode);
  1289. sdata_unlock(sdata);
  1290. }
  1291. --- a/net/mac80211/iface.c
  1292. +++ b/net/mac80211/iface.c
  1293. @@ -770,12 +770,19 @@ static void ieee80211_do_stop(struct iee
  1294. ieee80211_roc_purge(local, sdata);
  1295. - if (sdata->vif.type == NL80211_IFTYPE_STATION)
  1296. + switch (sdata->vif.type) {
  1297. + case NL80211_IFTYPE_STATION:
  1298. ieee80211_mgd_stop(sdata);
  1299. -
  1300. - if (sdata->vif.type == NL80211_IFTYPE_ADHOC)
  1301. + break;
  1302. + case NL80211_IFTYPE_ADHOC:
  1303. ieee80211_ibss_stop(sdata);
  1304. -
  1305. + break;
  1306. + case NL80211_IFTYPE_AP:
  1307. + cancel_work_sync(&sdata->u.ap.request_smps_work);
  1308. + break;
  1309. + default:
  1310. + break;
  1311. + }
  1312. /*
  1313. * Remove all stations associated with this interface.
  1314. @@ -827,7 +834,9 @@ static void ieee80211_do_stop(struct iee
  1315. cancel_work_sync(&local->dynamic_ps_enable_work);
  1316. cancel_work_sync(&sdata->recalc_smps);
  1317. + sdata_lock(sdata);
  1318. sdata->vif.csa_active = false;
  1319. + sdata_unlock(sdata);
  1320. cancel_work_sync(&sdata->csa_finalize_work);
  1321. cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
  1322. --- a/net/mac80211/rx.c
  1323. +++ b/net/mac80211/rx.c
  1324. @@ -599,10 +599,10 @@ static int ieee80211_is_unicast_robust_m
  1325. {
  1326. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  1327. - if (skb->len < 24 || is_multicast_ether_addr(hdr->addr1))
  1328. + if (is_multicast_ether_addr(hdr->addr1))
  1329. return 0;
  1330. - return ieee80211_is_robust_mgmt_frame(hdr);
  1331. + return ieee80211_is_robust_mgmt_frame(skb);
  1332. }
  1333. @@ -610,10 +610,10 @@ static int ieee80211_is_multicast_robust
  1334. {
  1335. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  1336. - if (skb->len < 24 || !is_multicast_ether_addr(hdr->addr1))
  1337. + if (!is_multicast_ether_addr(hdr->addr1))
  1338. return 0;
  1339. - return ieee80211_is_robust_mgmt_frame(hdr);
  1340. + return ieee80211_is_robust_mgmt_frame(skb);
  1341. }
  1342. @@ -626,7 +626,7 @@ static int ieee80211_get_mmie_keyidx(str
  1343. if (skb->len < 24 + sizeof(*mmie) || !is_multicast_ether_addr(hdr->da))
  1344. return -1;
  1345. - if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *) hdr))
  1346. + if (!ieee80211_is_robust_mgmt_frame(skb))
  1347. return -1; /* not a robust management frame */
  1348. mmie = (struct ieee80211_mmie *)
  1349. @@ -1128,6 +1128,13 @@ static void sta_ps_end(struct sta_info *
  1350. sta->sta.addr, sta->sta.aid);
  1351. if (test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
  1352. + /*
  1353. + * Clear the flag only if the other one is still set
  1354. + * so that the TX path won't start TX'ing new frames
  1355. + * directly ... In the case that the driver flag isn't
  1356. + * set ieee80211_sta_ps_deliver_wakeup() will clear it.
  1357. + */
  1358. + clear_sta_flag(sta, WLAN_STA_PS_STA);
  1359. ps_dbg(sta->sdata, "STA %pM aid %d driver-ps-blocked\n",
  1360. sta->sta.addr, sta->sta.aid);
  1361. return;
  1362. @@ -1311,18 +1318,15 @@ ieee80211_rx_h_sta_process(struct ieee80
  1363. !ieee80211_has_morefrags(hdr->frame_control) &&
  1364. !(status->rx_flags & IEEE80211_RX_DEFERRED_RELEASE) &&
  1365. (rx->sdata->vif.type == NL80211_IFTYPE_AP ||
  1366. - rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)) {
  1367. + rx->sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
  1368. + /* PM bit is only checked in frames where it isn't reserved,
  1369. + * in AP mode it's reserved in non-bufferable management frames
  1370. + * (cf. IEEE 802.11-2012 8.2.4.1.7 Power Management field)
  1371. + */
  1372. + (!ieee80211_is_mgmt(hdr->frame_control) ||
  1373. + ieee80211_is_bufferable_mmpdu(hdr->frame_control))) {
  1374. if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
  1375. - /*
  1376. - * Ignore doze->wake transitions that are
  1377. - * indicated by non-data frames, the standard
  1378. - * is unclear here, but for example going to
  1379. - * PS mode and then scanning would cause a
  1380. - * doze->wake transition for the probe request,
  1381. - * and that is clearly undesirable.
  1382. - */
  1383. - if (ieee80211_is_data(hdr->frame_control) &&
  1384. - !ieee80211_has_pm(hdr->frame_control))
  1385. + if (!ieee80211_has_pm(hdr->frame_control))
  1386. sta_ps_end(sta);
  1387. } else {
  1388. if (ieee80211_has_pm(hdr->frame_control))
  1389. @@ -1845,8 +1849,7 @@ static int ieee80211_drop_unencrypted_mg
  1390. * having configured keys.
  1391. */
  1392. if (unlikely(ieee80211_is_action(fc) && !rx->key &&
  1393. - ieee80211_is_robust_mgmt_frame(
  1394. - (struct ieee80211_hdr *) rx->skb->data)))
  1395. + ieee80211_is_robust_mgmt_frame(rx->skb)))
  1396. return -EACCES;
  1397. }
  1398. --- a/net/mac80211/tx.c
  1399. +++ b/net/mac80211/tx.c
  1400. @@ -452,8 +452,7 @@ static int ieee80211_use_mfp(__le16 fc,
  1401. if (sta == NULL || !test_sta_flag(sta, WLAN_STA_MFP))
  1402. return 0;
  1403. - if (!ieee80211_is_robust_mgmt_frame((struct ieee80211_hdr *)
  1404. - skb->data))
  1405. + if (!ieee80211_is_robust_mgmt_frame(skb))
  1406. return 0;
  1407. return 1;
  1408. @@ -478,6 +477,20 @@ ieee80211_tx_h_unicast_ps_buf(struct iee
  1409. sta->sta.addr, sta->sta.aid, ac);
  1410. if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
  1411. purge_old_ps_buffers(tx->local);
  1412. +
  1413. + /* sync with ieee80211_sta_ps_deliver_wakeup */
  1414. + spin_lock(&sta->ps_lock);
  1415. + /*
  1416. + * STA woke up the meantime and all the frames on ps_tx_buf have
  1417. + * been queued to pending queue. No reordering can happen, go
  1418. + * ahead and Tx the packet.
  1419. + */
  1420. + if (!test_sta_flag(sta, WLAN_STA_PS_STA) &&
  1421. + !test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
  1422. + spin_unlock(&sta->ps_lock);
  1423. + return TX_CONTINUE;
  1424. + }
  1425. +
  1426. if (skb_queue_len(&sta->ps_tx_buf[ac]) >= STA_MAX_TX_BUFFER) {
  1427. struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf[ac]);
  1428. ps_dbg(tx->sdata,
  1429. @@ -492,6 +505,7 @@ ieee80211_tx_h_unicast_ps_buf(struct iee
  1430. info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
  1431. info->flags &= ~IEEE80211_TX_TEMPORARY_FLAGS;
  1432. skb_queue_tail(&sta->ps_tx_buf[ac], tx->skb);
  1433. + spin_unlock(&sta->ps_lock);
  1434. if (!timer_pending(&local->sta_cleanup))
  1435. mod_timer(&local->sta_cleanup,
  1436. @@ -525,9 +539,7 @@ ieee80211_tx_h_ps_buf(struct ieee80211_t
  1437. /* only deauth, disassoc and action are bufferable MMPDUs */
  1438. if (ieee80211_is_mgmt(hdr->frame_control) &&
  1439. - !ieee80211_is_deauth(hdr->frame_control) &&
  1440. - !ieee80211_is_disassoc(hdr->frame_control) &&
  1441. - !ieee80211_is_action(hdr->frame_control)) {
  1442. + !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) {
  1443. if (tx->flags & IEEE80211_TX_UNICAST)
  1444. info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER;
  1445. return TX_CONTINUE;
  1446. @@ -567,7 +579,7 @@ ieee80211_tx_h_select_key(struct ieee802
  1447. tx->key = key;
  1448. else if (ieee80211_is_mgmt(hdr->frame_control) &&
  1449. is_multicast_ether_addr(hdr->addr1) &&
  1450. - ieee80211_is_robust_mgmt_frame(hdr) &&
  1451. + ieee80211_is_robust_mgmt_frame(tx->skb) &&
  1452. (key = rcu_dereference(tx->sdata->default_mgmt_key)))
  1453. tx->key = key;
  1454. else if (is_multicast_ether_addr(hdr->addr1) &&
  1455. @@ -582,12 +594,12 @@ ieee80211_tx_h_select_key(struct ieee802
  1456. tx->key = NULL;
  1457. else if (tx->skb->protocol == tx->sdata->control_port_protocol)
  1458. tx->key = NULL;
  1459. - else if (ieee80211_is_robust_mgmt_frame(hdr) &&
  1460. + else if (ieee80211_is_robust_mgmt_frame(tx->skb) &&
  1461. !(ieee80211_is_action(hdr->frame_control) &&
  1462. tx->sta && test_sta_flag(tx->sta, WLAN_STA_MFP)))
  1463. tx->key = NULL;
  1464. else if (ieee80211_is_mgmt(hdr->frame_control) &&
  1465. - !ieee80211_is_robust_mgmt_frame(hdr))
  1466. + !ieee80211_is_robust_mgmt_frame(tx->skb))
  1467. tx->key = NULL;
  1468. else {
  1469. I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
  1470. @@ -878,7 +890,7 @@ static int ieee80211_fragment(struct iee
  1471. }
  1472. /* adjust first fragment's length */
  1473. - skb->len = hdrlen + per_fragm;
  1474. + skb_trim(skb, hdrlen + per_fragm);
  1475. return 0;
  1476. }
  1477. --- a/net/mac80211/wpa.c
  1478. +++ b/net/mac80211/wpa.c
  1479. @@ -499,7 +499,7 @@ ieee80211_crypto_ccmp_decrypt(struct iee
  1480. hdrlen = ieee80211_hdrlen(hdr->frame_control);
  1481. if (!ieee80211_is_data(hdr->frame_control) &&
  1482. - !ieee80211_is_robust_mgmt_frame(hdr))
  1483. + !ieee80211_is_robust_mgmt_frame(skb))
  1484. return RX_CONTINUE;
  1485. data_len = skb->len - hdrlen - IEEE80211_CCMP_HDR_LEN -
  1486. --- a/net/wireless/ap.c
  1487. +++ b/net/wireless/ap.c
  1488. @@ -27,9 +27,10 @@ static int __cfg80211_stop_ap(struct cfg
  1489. err = rdev_stop_ap(rdev, dev);
  1490. if (!err) {
  1491. wdev->beacon_interval = 0;
  1492. - wdev->channel = NULL;
  1493. + memset(&wdev->chandef, 0, sizeof(wdev->chandef));
  1494. wdev->ssid_len = 0;
  1495. rdev_set_qos_map(rdev, dev, NULL);
  1496. + nl80211_send_ap_stopped(wdev);
  1497. }
  1498. return err;
  1499. --- a/net/wireless/core.c
  1500. +++ b/net/wireless/core.c
  1501. @@ -203,8 +203,11 @@ void cfg80211_stop_p2p_device(struct cfg
  1502. rdev->opencount--;
  1503. - WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev &&
  1504. - !rdev->scan_req->notified);
  1505. + if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
  1506. + if (WARN_ON(!rdev->scan_req->notified))
  1507. + rdev->scan_req->aborted = true;
  1508. + ___cfg80211_scan_done(rdev, false);
  1509. + }
  1510. }
  1511. static int cfg80211_rfkill_set_block(void *data, bool blocked)
  1512. @@ -447,9 +450,6 @@ int wiphy_register(struct wiphy *wiphy)
  1513. int i;
  1514. u16 ifmodes = wiphy->interface_modes;
  1515. - /* support for 5/10 MHz is broken due to nl80211 API mess - disable */
  1516. - wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_5_10_MHZ;
  1517. -
  1518. /*
  1519. * There are major locking problems in nl80211/mac80211 for CSA,
  1520. * disable for all drivers until this has been reworked.
  1521. @@ -875,8 +875,11 @@ static int cfg80211_netdev_notifier_call
  1522. break;
  1523. case NETDEV_DOWN:
  1524. cfg80211_update_iface_num(rdev, wdev->iftype, -1);
  1525. - WARN_ON(rdev->scan_req && rdev->scan_req->wdev == wdev &&
  1526. - !rdev->scan_req->notified);
  1527. + if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
  1528. + if (WARN_ON(!rdev->scan_req->notified))
  1529. + rdev->scan_req->aborted = true;
  1530. + ___cfg80211_scan_done(rdev, false);
  1531. + }
  1532. if (WARN_ON(rdev->sched_scan_req &&
  1533. rdev->sched_scan_req->dev == wdev->netdev)) {
  1534. --- a/net/wireless/core.h
  1535. +++ b/net/wireless/core.h
  1536. @@ -62,6 +62,7 @@ struct cfg80211_registered_device {
  1537. struct rb_root bss_tree;
  1538. u32 bss_generation;
  1539. struct cfg80211_scan_request *scan_req; /* protected by RTNL */
  1540. + struct sk_buff *scan_msg;
  1541. struct cfg80211_sched_scan_request *sched_scan_req;
  1542. unsigned long suspend_at;
  1543. struct work_struct scan_done_wk;
  1544. @@ -210,6 +211,7 @@ struct cfg80211_event {
  1545. } dc;
  1546. struct {
  1547. u8 bssid[ETH_ALEN];
  1548. + struct ieee80211_channel *channel;
  1549. } ij;
  1550. };
  1551. };
  1552. @@ -257,7 +259,8 @@ int __cfg80211_leave_ibss(struct cfg8021
  1553. struct net_device *dev, bool nowext);
  1554. int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
  1555. struct net_device *dev, bool nowext);
  1556. -void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid);
  1557. +void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
  1558. + struct ieee80211_channel *channel);
  1559. int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev,
  1560. struct wireless_dev *wdev);
  1561. @@ -361,7 +364,8 @@ int cfg80211_validate_key_settings(struc
  1562. struct key_params *params, int key_idx,
  1563. bool pairwise, const u8 *mac_addr);
  1564. void __cfg80211_scan_done(struct work_struct *wk);
  1565. -void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev);
  1566. +void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
  1567. + bool send_message);
  1568. void __cfg80211_sched_scan_results(struct work_struct *wk);
  1569. int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
  1570. bool driver_initiated);
  1571. @@ -441,7 +445,8 @@ static inline unsigned int elapsed_jiffi
  1572. void
  1573. cfg80211_get_chan_state(struct wireless_dev *wdev,
  1574. struct ieee80211_channel **chan,
  1575. - enum cfg80211_chan_mode *chanmode);
  1576. + enum cfg80211_chan_mode *chanmode,
  1577. + u8 *radar_detect);
  1578. int cfg80211_set_monitor_channel(struct cfg80211_registered_device *rdev,
  1579. struct cfg80211_chan_def *chandef);
  1580. --- a/net/wireless/nl80211.c
  1581. +++ b/net/wireless/nl80211.c
  1582. @@ -1723,9 +1723,10 @@ static int nl80211_dump_wiphy(struct sk_
  1583. * We can then retry with the larger buffer.
  1584. */
  1585. if ((ret == -ENOBUFS || ret == -EMSGSIZE) &&
  1586. - !skb->len &&
  1587. + !skb->len && !state->split &&
  1588. cb->min_dump_alloc < 4096) {
  1589. cb->min_dump_alloc = 4096;
  1590. + state->split_start = 0;
  1591. rtnl_unlock();
  1592. return 1;
  1593. }
  1594. @@ -2047,10 +2048,12 @@ static int nl80211_set_wiphy(struct sk_b
  1595. nla_for_each_nested(nl_txq_params,
  1596. info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS],
  1597. rem_txq_params) {
  1598. - nla_parse(tb, NL80211_TXQ_ATTR_MAX,
  1599. - nla_data(nl_txq_params),
  1600. - nla_len(nl_txq_params),
  1601. - txq_params_policy);
  1602. + result = nla_parse(tb, NL80211_TXQ_ATTR_MAX,
  1603. + nla_data(nl_txq_params),
  1604. + nla_len(nl_txq_params),
  1605. + txq_params_policy);
  1606. + if (result)
  1607. + goto bad_res;
  1608. result = parse_txq_params(tb, &txq_params);
  1609. if (result)
  1610. goto bad_res;
  1611. @@ -3289,7 +3292,7 @@ static int nl80211_start_ap(struct sk_bu
  1612. if (!err) {
  1613. wdev->preset_chandef = params.chandef;
  1614. wdev->beacon_interval = params.beacon_interval;
  1615. - wdev->channel = params.chandef.chan;
  1616. + wdev->chandef = params.chandef;
  1617. wdev->ssid_len = params.ssid_len;
  1618. memcpy(wdev->ssid, params.ssid, wdev->ssid_len);
  1619. }
  1620. @@ -5210,9 +5213,11 @@ static int nl80211_set_reg(struct sk_buf
  1621. nla_for_each_nested(nl_reg_rule, info->attrs[NL80211_ATTR_REG_RULES],
  1622. rem_reg_rules) {
  1623. - nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
  1624. - nla_data(nl_reg_rule), nla_len(nl_reg_rule),
  1625. - reg_rule_policy);
  1626. + r = nla_parse(tb, NL80211_REG_RULE_ATTR_MAX,
  1627. + nla_data(nl_reg_rule), nla_len(nl_reg_rule),
  1628. + reg_rule_policy);
  1629. + if (r)
  1630. + goto bad_reg;
  1631. r = parse_reg_rule(tb, &rd->reg_rules[rule_idx]);
  1632. if (r)
  1633. goto bad_reg;
  1634. @@ -5277,7 +5282,7 @@ static int nl80211_trigger_scan(struct s
  1635. if (!rdev->ops->scan)
  1636. return -EOPNOTSUPP;
  1637. - if (rdev->scan_req) {
  1638. + if (rdev->scan_req || rdev->scan_msg) {
  1639. err = -EBUSY;
  1640. goto unlock;
  1641. }
  1642. @@ -5475,6 +5480,7 @@ static int nl80211_start_sched_scan(stru
  1643. enum ieee80211_band band;
  1644. size_t ie_len;
  1645. struct nlattr *tb[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1];
  1646. + s32 default_match_rssi = NL80211_SCAN_RSSI_THOLD_OFF;
  1647. if (!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_SCHED_SCAN) ||
  1648. !rdev->ops->sched_scan_start)
  1649. @@ -5509,11 +5515,40 @@ static int nl80211_start_sched_scan(stru
  1650. if (n_ssids > wiphy->max_sched_scan_ssids)
  1651. return -EINVAL;
  1652. - if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH])
  1653. + /*
  1654. + * First, count the number of 'real' matchsets. Due to an issue with
  1655. + * the old implementation, matchsets containing only the RSSI attribute
  1656. + * (NL80211_SCHED_SCAN_MATCH_ATTR_RSSI) are considered as the 'default'
  1657. + * RSSI for all matchsets, rather than their own matchset for reporting
  1658. + * all APs with a strong RSSI. This is needed to be compatible with
  1659. + * older userspace that treated a matchset with only the RSSI as the
  1660. + * global RSSI for all other matchsets - if there are other matchsets.
  1661. + */
  1662. + if (info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH]) {
  1663. nla_for_each_nested(attr,
  1664. info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH],
  1665. - tmp)
  1666. - n_match_sets++;
  1667. + tmp) {
  1668. + struct nlattr *rssi;
  1669. +
  1670. + err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
  1671. + nla_data(attr), nla_len(attr),
  1672. + nl80211_match_policy);
  1673. + if (err)
  1674. + return err;
  1675. + /* add other standalone attributes here */
  1676. + if (tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID]) {
  1677. + n_match_sets++;
  1678. + continue;
  1679. + }
  1680. + rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
  1681. + if (rssi)
  1682. + default_match_rssi = nla_get_s32(rssi);
  1683. + }
  1684. + }
  1685. +
  1686. + /* However, if there's no other matchset, add the RSSI one */
  1687. + if (!n_match_sets && default_match_rssi != NL80211_SCAN_RSSI_THOLD_OFF)
  1688. + n_match_sets = 1;
  1689. if (n_match_sets > wiphy->max_match_sets)
  1690. return -EINVAL;
  1691. @@ -5634,11 +5669,22 @@ static int nl80211_start_sched_scan(stru
  1692. tmp) {
  1693. struct nlattr *ssid, *rssi;
  1694. - nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
  1695. - nla_data(attr), nla_len(attr),
  1696. - nl80211_match_policy);
  1697. + err = nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
  1698. + nla_data(attr), nla_len(attr),
  1699. + nl80211_match_policy);
  1700. + if (err)
  1701. + goto out_free;
  1702. ssid = tb[NL80211_SCHED_SCAN_MATCH_ATTR_SSID];
  1703. if (ssid) {
  1704. + if (WARN_ON(i >= n_match_sets)) {
  1705. + /* this indicates a programming error,
  1706. + * the loop above should have verified
  1707. + * things properly
  1708. + */
  1709. + err = -EINVAL;
  1710. + goto out_free;
  1711. + }
  1712. +
  1713. if (nla_len(ssid) > IEEE80211_MAX_SSID_LEN) {
  1714. err = -EINVAL;
  1715. goto out_free;
  1716. @@ -5647,15 +5693,28 @@ static int nl80211_start_sched_scan(stru
  1717. nla_data(ssid), nla_len(ssid));
  1718. request->match_sets[i].ssid.ssid_len =
  1719. nla_len(ssid);
  1720. + /* special attribute - old implemenation w/a */
  1721. + request->match_sets[i].rssi_thold =
  1722. + default_match_rssi;
  1723. + rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
  1724. + if (rssi)
  1725. + request->match_sets[i].rssi_thold =
  1726. + nla_get_s32(rssi);
  1727. }
  1728. - rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
  1729. - if (rssi)
  1730. - request->rssi_thold = nla_get_u32(rssi);
  1731. - else
  1732. - request->rssi_thold =
  1733. - NL80211_SCAN_RSSI_THOLD_OFF;
  1734. i++;
  1735. }
  1736. +
  1737. + /* there was no other matchset, so the RSSI one is alone */
  1738. + if (i == 0)
  1739. + request->match_sets[0].rssi_thold = default_match_rssi;
  1740. +
  1741. + request->min_rssi_thold = INT_MAX;
  1742. + for (i = 0; i < n_match_sets; i++)
  1743. + request->min_rssi_thold =
  1744. + min(request->match_sets[i].rssi_thold,
  1745. + request->min_rssi_thold);
  1746. + } else {
  1747. + request->min_rssi_thold = NL80211_SCAN_RSSI_THOLD_OFF;
  1748. }
  1749. if (info->attrs[NL80211_ATTR_IE]) {
  1750. @@ -5751,7 +5810,7 @@ static int nl80211_start_radar_detection
  1751. err = rdev->ops->start_radar_detection(&rdev->wiphy, dev, &chandef);
  1752. if (!err) {
  1753. - wdev->channel = chandef.chan;
  1754. + wdev->chandef = chandef;
  1755. wdev->cac_started = true;
  1756. wdev->cac_start_time = jiffies;
  1757. }
  1758. @@ -7502,16 +7561,19 @@ static int nl80211_set_tx_bitrate_mask(s
  1759. * directly to the enum ieee80211_band values used in cfg80211.
  1760. */
  1761. BUILD_BUG_ON(NL80211_MAX_SUPP_HT_RATES > IEEE80211_HT_MCS_MASK_LEN * 8);
  1762. - nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem)
  1763. - {
  1764. + nla_for_each_nested(tx_rates, info->attrs[NL80211_ATTR_TX_RATES], rem) {
  1765. enum ieee80211_band band = nla_type(tx_rates);
  1766. + int err;
  1767. +
  1768. if (band < 0 || band >= IEEE80211_NUM_BANDS)
  1769. return -EINVAL;
  1770. sband = rdev->wiphy.bands[band];
  1771. if (sband == NULL)
  1772. return -EINVAL;
  1773. - nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
  1774. - nla_len(tx_rates), nl80211_txattr_policy);
  1775. + err = nla_parse(tb, NL80211_TXRATE_MAX, nla_data(tx_rates),
  1776. + nla_len(tx_rates), nl80211_txattr_policy);
  1777. + if (err)
  1778. + return err;
  1779. if (tb[NL80211_TXRATE_LEGACY]) {
  1780. mask.control[band].legacy = rateset_to_mask(
  1781. sband,
  1782. @@ -10054,40 +10116,31 @@ void nl80211_send_scan_start(struct cfg8
  1783. NL80211_MCGRP_SCAN, GFP_KERNEL);
  1784. }
  1785. -void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
  1786. - struct wireless_dev *wdev)
  1787. +struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,
  1788. + struct wireless_dev *wdev, bool aborted)
  1789. {
  1790. struct sk_buff *msg;
  1791. msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
  1792. if (!msg)
  1793. - return;
  1794. + return NULL;
  1795. if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
  1796. - NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
  1797. + aborted ? NL80211_CMD_SCAN_ABORTED :
  1798. + NL80211_CMD_NEW_SCAN_RESULTS) < 0) {
  1799. nlmsg_free(msg);
  1800. - return;
  1801. + return NULL;
  1802. }
  1803. - genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
  1804. - NL80211_MCGRP_SCAN, GFP_KERNEL);
  1805. + return msg;
  1806. }
  1807. -void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
  1808. - struct wireless_dev *wdev)
  1809. +void nl80211_send_scan_result(struct cfg80211_registered_device *rdev,
  1810. + struct sk_buff *msg)
  1811. {
  1812. - struct sk_buff *msg;
  1813. -
  1814. - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
  1815. if (!msg)
  1816. return;
  1817. - if (nl80211_send_scan_msg(msg, rdev, wdev, 0, 0, 0,
  1818. - NL80211_CMD_SCAN_ABORTED) < 0) {
  1819. - nlmsg_free(msg);
  1820. - return;
  1821. - }
  1822. -
  1823. genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
  1824. NL80211_MCGRP_SCAN, GFP_KERNEL);
  1825. }
  1826. @@ -11158,7 +11211,8 @@ void cfg80211_ch_switch_notify(struct ne
  1827. wdev->iftype != NL80211_IFTYPE_MESH_POINT))
  1828. return;
  1829. - wdev->channel = chandef->chan;
  1830. + wdev->chandef = *chandef;
  1831. + wdev->preset_chandef = *chandef;
  1832. nl80211_ch_switch_notify(rdev, dev, chandef, GFP_KERNEL);
  1833. }
  1834. EXPORT_SYMBOL(cfg80211_ch_switch_notify);
  1835. @@ -11673,6 +11727,35 @@ void cfg80211_crit_proto_stopped(struct
  1836. }
  1837. EXPORT_SYMBOL(cfg80211_crit_proto_stopped);
  1838. +void nl80211_send_ap_stopped(struct wireless_dev *wdev)
  1839. +{
  1840. + struct wiphy *wiphy = wdev->wiphy;
  1841. + struct cfg80211_registered_device *rdev = wiphy_to_dev(wiphy);
  1842. + struct sk_buff *msg;
  1843. + void *hdr;
  1844. +
  1845. + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
  1846. + if (!msg)
  1847. + return;
  1848. +
  1849. + hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_STOP_AP);
  1850. + if (!hdr)
  1851. + goto out;
  1852. +
  1853. + if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
  1854. + nla_put_u32(msg, NL80211_ATTR_IFINDEX, wdev->netdev->ifindex) ||
  1855. + nla_put_u64(msg, NL80211_ATTR_WDEV, wdev_id(wdev)))
  1856. + goto out;
  1857. +
  1858. + genlmsg_end(msg, hdr);
  1859. +
  1860. + genlmsg_multicast_netns(&nl80211_fam, wiphy_net(wiphy), msg, 0,
  1861. + NL80211_MCGRP_MLME, GFP_KERNEL);
  1862. + return;
  1863. + out:
  1864. + nlmsg_free(msg);
  1865. +}
  1866. +
  1867. /* initialisation/exit functions */
  1868. int nl80211_init(void)
  1869. --- a/net/wireless/nl80211.h
  1870. +++ b/net/wireless/nl80211.h
  1871. @@ -8,10 +8,10 @@ void nl80211_exit(void);
  1872. void nl80211_notify_dev_rename(struct cfg80211_registered_device *rdev);
  1873. void nl80211_send_scan_start(struct cfg80211_registered_device *rdev,
  1874. struct wireless_dev *wdev);
  1875. -void nl80211_send_scan_done(struct cfg80211_registered_device *rdev,
  1876. - struct wireless_dev *wdev);
  1877. -void nl80211_send_scan_aborted(struct cfg80211_registered_device *rdev,
  1878. - struct wireless_dev *wdev);
  1879. +struct sk_buff *nl80211_build_scan_msg(struct cfg80211_registered_device *rdev,
  1880. + struct wireless_dev *wdev, bool aborted);
  1881. +void nl80211_send_scan_result(struct cfg80211_registered_device *rdev,
  1882. + struct sk_buff *msg);
  1883. void nl80211_send_sched_scan(struct cfg80211_registered_device *rdev,
  1884. struct net_device *netdev, u32 cmd);
  1885. void nl80211_send_sched_scan_results(struct cfg80211_registered_device *rdev,
  1886. @@ -74,6 +74,8 @@ nl80211_radar_notify(struct cfg80211_reg
  1887. enum nl80211_radar_event event,
  1888. struct net_device *netdev, gfp_t gfp);
  1889. +void nl80211_send_ap_stopped(struct wireless_dev *wdev);
  1890. +
  1891. void cfg80211_rdev_free_coalesce(struct cfg80211_registered_device *rdev);
  1892. #endif /* __NET_WIRELESS_NL80211_H */
  1893. --- a/net/wireless/scan.c
  1894. +++ b/net/wireless/scan.c
  1895. @@ -161,18 +161,25 @@ static void __cfg80211_bss_expire(struct
  1896. dev->bss_generation++;
  1897. }
  1898. -void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev)
  1899. +void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
  1900. + bool send_message)
  1901. {
  1902. struct cfg80211_scan_request *request;
  1903. struct wireless_dev *wdev;
  1904. + struct sk_buff *msg;
  1905. #ifdef CPTCFG_CFG80211_WEXT
  1906. union iwreq_data wrqu;
  1907. #endif
  1908. ASSERT_RTNL();
  1909. - request = rdev->scan_req;
  1910. + if (rdev->scan_msg) {
  1911. + nl80211_send_scan_result(rdev, rdev->scan_msg);
  1912. + rdev->scan_msg = NULL;
  1913. + return;
  1914. + }
  1915. + request = rdev->scan_req;
  1916. if (!request)
  1917. return;
  1918. @@ -186,18 +193,16 @@ void ___cfg80211_scan_done(struct cfg802
  1919. if (wdev->netdev)
  1920. cfg80211_sme_scan_done(wdev->netdev);
  1921. - if (request->aborted) {
  1922. - nl80211_send_scan_aborted(rdev, wdev);
  1923. - } else {
  1924. - if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
  1925. - /* flush entries from previous scans */
  1926. - spin_lock_bh(&rdev->bss_lock);
  1927. - __cfg80211_bss_expire(rdev, request->scan_start);
  1928. - spin_unlock_bh(&rdev->bss_lock);
  1929. - }
  1930. - nl80211_send_scan_done(rdev, wdev);
  1931. + if (!request->aborted &&
  1932. + request->flags & NL80211_SCAN_FLAG_FLUSH) {
  1933. + /* flush entries from previous scans */
  1934. + spin_lock_bh(&rdev->bss_lock);
  1935. + __cfg80211_bss_expire(rdev, request->scan_start);
  1936. + spin_unlock_bh(&rdev->bss_lock);
  1937. }
  1938. + msg = nl80211_build_scan_msg(rdev, wdev, request->aborted);
  1939. +
  1940. #ifdef CPTCFG_CFG80211_WEXT
  1941. if (wdev->netdev && !request->aborted) {
  1942. memset(&wrqu, 0, sizeof(wrqu));
  1943. @@ -211,6 +216,11 @@ void ___cfg80211_scan_done(struct cfg802
  1944. rdev->scan_req = NULL;
  1945. kfree(request);
  1946. +
  1947. + if (!send_message)
  1948. + rdev->scan_msg = msg;
  1949. + else
  1950. + nl80211_send_scan_result(rdev, msg);
  1951. }
  1952. void __cfg80211_scan_done(struct work_struct *wk)
  1953. @@ -221,7 +231,7 @@ void __cfg80211_scan_done(struct work_st
  1954. scan_done_wk);
  1955. rtnl_lock();
  1956. - ___cfg80211_scan_done(rdev);
  1957. + ___cfg80211_scan_done(rdev, true);
  1958. rtnl_unlock();
  1959. }
  1960. @@ -1079,7 +1089,7 @@ int cfg80211_wext_siwscan(struct net_dev
  1961. if (IS_ERR(rdev))
  1962. return PTR_ERR(rdev);
  1963. - if (rdev->scan_req) {
  1964. + if (rdev->scan_req || rdev->scan_msg) {
  1965. err = -EBUSY;
  1966. goto out;
  1967. }
  1968. @@ -1481,7 +1491,7 @@ int cfg80211_wext_giwscan(struct net_dev
  1969. if (IS_ERR(rdev))
  1970. return PTR_ERR(rdev);
  1971. - if (rdev->scan_req)
  1972. + if (rdev->scan_req || rdev->scan_msg)
  1973. return -EAGAIN;
  1974. res = ieee80211_scan_results(rdev, info, extra, data->length);
  1975. --- a/net/wireless/sme.c
  1976. +++ b/net/wireless/sme.c
  1977. @@ -67,7 +67,7 @@ static int cfg80211_conn_scan(struct wir
  1978. ASSERT_RDEV_LOCK(rdev);
  1979. ASSERT_WDEV_LOCK(wdev);
  1980. - if (rdev->scan_req)
  1981. + if (rdev->scan_req || rdev->scan_msg)
  1982. return -EBUSY;
  1983. if (wdev->conn->params.channel)
  1984. --- a/net/mac80211/mlme.c
  1985. +++ b/net/mac80211/mlme.c
  1986. @@ -1001,7 +1001,6 @@ ieee80211_sta_process_chanswitch(struct
  1987. }
  1988. ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED;
  1989. - sdata->vif.csa_active = true;
  1990. mutex_lock(&local->chanctx_mtx);
  1991. if (local->use_chanctx) {
  1992. @@ -1039,6 +1038,7 @@ ieee80211_sta_process_chanswitch(struct
  1993. mutex_unlock(&local->chanctx_mtx);
  1994. sdata->csa_chandef = csa_ie.chandef;
  1995. + sdata->vif.csa_active = true;
  1996. if (csa_ie.mode)
  1997. ieee80211_stop_queues_by_reason(&local->hw,
  1998. --- a/net/mac80211/chan.c
  1999. +++ b/net/mac80211/chan.c
  2000. @@ -196,6 +196,8 @@ static bool ieee80211_is_radar_required(
  2001. {
  2002. struct ieee80211_sub_if_data *sdata;
  2003. + lockdep_assert_held(&local->mtx);
  2004. +
  2005. rcu_read_lock();
  2006. list_for_each_entry_rcu(sdata, &local->interfaces, list) {
  2007. if (sdata->radar_required) {
  2008. --- a/net/mac80211/ibss.c
  2009. +++ b/net/mac80211/ibss.c
  2010. @@ -294,7 +294,6 @@ static void __ieee80211_sta_join_ibss(st
  2011. }
  2012. mutex_lock(&local->mtx);
  2013. - ieee80211_vif_release_channel(sdata);
  2014. if (ieee80211_vif_use_channel(sdata, &chandef,
  2015. ifibss->fixed_channel ?
  2016. IEEE80211_CHANCTX_SHARED :
  2017. @@ -303,6 +302,7 @@ static void __ieee80211_sta_join_ibss(st
  2018. mutex_unlock(&local->mtx);
  2019. return;
  2020. }
  2021. + sdata->radar_required = radar_required;
  2022. mutex_unlock(&local->mtx);
  2023. memcpy(ifibss->bssid, bssid, ETH_ALEN);
  2024. @@ -318,7 +318,6 @@ static void __ieee80211_sta_join_ibss(st
  2025. rcu_assign_pointer(ifibss->presp, presp);
  2026. mgmt = (void *)presp->head;
  2027. - sdata->radar_required = radar_required;
  2028. sdata->vif.bss_conf.enable_beacon = true;
  2029. sdata->vif.bss_conf.beacon_int = beacon_int;
  2030. sdata->vif.bss_conf.basic_rates = basic_rates;
  2031. @@ -386,7 +385,7 @@ static void __ieee80211_sta_join_ibss(st
  2032. presp->head_len, 0, GFP_KERNEL);
  2033. cfg80211_put_bss(local->hw.wiphy, bss);
  2034. netif_carrier_on(sdata->dev);
  2035. - cfg80211_ibss_joined(sdata->dev, ifibss->bssid, GFP_KERNEL);
  2036. + cfg80211_ibss_joined(sdata->dev, ifibss->bssid, chan, GFP_KERNEL);
  2037. }
  2038. static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
  2039. @@ -802,6 +801,8 @@ ieee80211_ibss_process_chanswitch(struct
  2040. int err;
  2041. u32 sta_flags;
  2042. + sdata_assert_lock(sdata);
  2043. +
  2044. sta_flags = IEEE80211_STA_DISABLE_VHT;
  2045. switch (ifibss->chandef.width) {
  2046. case NL80211_CHAN_WIDTH_5:
  2047. @@ -1471,6 +1472,11 @@ static void ieee80211_rx_mgmt_probe_req(
  2048. memcpy(((struct ieee80211_mgmt *) skb->data)->da, mgmt->sa, ETH_ALEN);
  2049. ibss_dbg(sdata, "Sending ProbeResp to %pM\n", mgmt->sa);
  2050. IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT;
  2051. +
  2052. + /* avoid excessive retries for probe request to wildcard SSIDs */
  2053. + if (pos[1] == 0)
  2054. + IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_NO_ACK;
  2055. +
  2056. ieee80211_tx_skb(sdata, skb);
  2057. }
  2058. --- a/net/mac80211/mesh.c
  2059. +++ b/net/mac80211/mesh.c
  2060. @@ -872,6 +872,8 @@ ieee80211_mesh_process_chnswitch(struct
  2061. if (!ifmsh->mesh_id)
  2062. return false;
  2063. + sdata_assert_lock(sdata);
  2064. +
  2065. sta_flags = IEEE80211_STA_DISABLE_VHT;
  2066. switch (sdata->vif.bss_conf.chandef.width) {
  2067. case NL80211_CHAN_WIDTH_20_NOHT:
  2068. --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
  2069. +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
  2070. @@ -4658,6 +4658,7 @@ brcmf_notify_connect_status(struct brcmf
  2071. struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
  2072. struct net_device *ndev = ifp->ndev;
  2073. struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;
  2074. + struct ieee80211_channel *chan;
  2075. s32 err = 0;
  2076. if (ifp->vif->mode == WL_MODE_AP) {
  2077. @@ -4665,9 +4666,10 @@ brcmf_notify_connect_status(struct brcmf
  2078. } else if (brcmf_is_linkup(e)) {
  2079. brcmf_dbg(CONN, "Linkup\n");
  2080. if (brcmf_is_ibssmode(ifp->vif)) {
  2081. + chan = ieee80211_get_channel(cfg->wiphy, cfg->channel);
  2082. memcpy(profile->bssid, e->addr, ETH_ALEN);
  2083. wl_inform_ibss(cfg, ndev, e->addr);
  2084. - cfg80211_ibss_joined(ndev, e->addr, GFP_KERNEL);
  2085. + cfg80211_ibss_joined(ndev, e->addr, chan, GFP_KERNEL);
  2086. clear_bit(BRCMF_VIF_STATUS_CONNECTING,
  2087. &ifp->vif->sme_state);
  2088. set_bit(BRCMF_VIF_STATUS_CONNECTED,
  2089. --- a/drivers/net/wireless/libertas/cfg.c
  2090. +++ b/drivers/net/wireless/libertas/cfg.c
  2091. @@ -1766,7 +1766,8 @@ static void lbs_join_post(struct lbs_pri
  2092. memcpy(priv->wdev->ssid, params->ssid, params->ssid_len);
  2093. priv->wdev->ssid_len = params->ssid_len;
  2094. - cfg80211_ibss_joined(priv->dev, bssid, GFP_KERNEL);
  2095. + cfg80211_ibss_joined(priv->dev, bssid, params->chandef.chan,
  2096. + GFP_KERNEL);
  2097. /* TODO: consider doing this at MACREG_INT_CODE_LINK_SENSED time */
  2098. priv->connect_status = LBS_CONNECTED;
  2099. --- a/drivers/net/wireless/mwifiex/cfg80211.c
  2100. +++ b/drivers/net/wireless/mwifiex/cfg80211.c
  2101. @@ -1881,7 +1881,8 @@ mwifiex_cfg80211_join_ibss(struct wiphy
  2102. params->privacy);
  2103. done:
  2104. if (!ret) {
  2105. - cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid, GFP_KERNEL);
  2106. + cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid,
  2107. + params->chandef.chan, GFP_KERNEL);
  2108. dev_dbg(priv->adapter->dev,
  2109. "info: joined/created adhoc network with bssid"
  2110. " %pM successfully\n", priv->cfg_bssid);
  2111. --- a/drivers/net/wireless/rndis_wlan.c
  2112. +++ b/drivers/net/wireless/rndis_wlan.c
  2113. @@ -2835,7 +2835,9 @@ static void rndis_wlan_do_link_up_work(s
  2114. bssid, req_ie, req_ie_len,
  2115. resp_ie, resp_ie_len, GFP_KERNEL);
  2116. } else if (priv->infra_mode == NDIS_80211_INFRA_ADHOC)
  2117. - cfg80211_ibss_joined(usbdev->net, bssid, GFP_KERNEL);
  2118. + cfg80211_ibss_joined(usbdev->net, bssid,
  2119. + get_current_channel(usbdev, NULL),
  2120. + GFP_KERNEL);
  2121. kfree(info);
  2122. --- a/net/wireless/ibss.c
  2123. +++ b/net/wireless/ibss.c
  2124. @@ -14,7 +14,8 @@
  2125. #include "rdev-ops.h"
  2126. -void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid)
  2127. +void __cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
  2128. + struct ieee80211_channel *channel)
  2129. {
  2130. struct wireless_dev *wdev = dev->ieee80211_ptr;
  2131. struct cfg80211_bss *bss;
  2132. @@ -28,8 +29,7 @@ void __cfg80211_ibss_joined(struct net_d
  2133. if (!wdev->ssid_len)
  2134. return;
  2135. - bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid,
  2136. - wdev->ssid, wdev->ssid_len,
  2137. + bss = cfg80211_get_bss(wdev->wiphy, channel, bssid, NULL, 0,
  2138. WLAN_CAPABILITY_IBSS, WLAN_CAPABILITY_IBSS);
  2139. if (WARN_ON(!bss))
  2140. @@ -54,21 +54,26 @@ void __cfg80211_ibss_joined(struct net_d
  2141. #endif
  2142. }
  2143. -void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp)
  2144. +void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
  2145. + struct ieee80211_channel *channel, gfp_t gfp)
  2146. {
  2147. struct wireless_dev *wdev = dev->ieee80211_ptr;
  2148. struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy);
  2149. struct cfg80211_event *ev;
  2150. unsigned long flags;
  2151. - trace_cfg80211_ibss_joined(dev, bssid);
  2152. + trace_cfg80211_ibss_joined(dev, bssid, channel);
  2153. +
  2154. + if (WARN_ON(!channel))
  2155. + return;
  2156. ev = kzalloc(sizeof(*ev), gfp);
  2157. if (!ev)
  2158. return;
  2159. ev->type = EVENT_IBSS_JOINED;
  2160. - memcpy(ev->cr.bssid, bssid, ETH_ALEN);
  2161. + memcpy(ev->ij.bssid, bssid, ETH_ALEN);
  2162. + ev->ij.channel = channel;
  2163. spin_lock_irqsave(&wdev->event_lock, flags);
  2164. list_add_tail(&ev->list, &wdev->event_list);
  2165. @@ -117,6 +122,7 @@ int __cfg80211_join_ibss(struct cfg80211
  2166. wdev->ibss_fixed = params->channel_fixed;
  2167. wdev->ibss_dfs_possible = params->userspace_handles_dfs;
  2168. + wdev->chandef = params->chandef;
  2169. #ifdef CPTCFG_CFG80211_WEXT
  2170. wdev->wext.ibss.chandef = params->chandef;
  2171. #endif
  2172. @@ -200,6 +206,7 @@ static void __cfg80211_clear_ibss(struct
  2173. wdev->current_bss = NULL;
  2174. wdev->ssid_len = 0;
  2175. + memset(&wdev->chandef, 0, sizeof(wdev->chandef));
  2176. #ifdef CPTCFG_CFG80211_WEXT
  2177. if (!nowext)
  2178. wdev->wext.ibss.ssid_len = 0;
  2179. --- a/net/wireless/trace.h
  2180. +++ b/net/wireless/trace.h
  2181. @@ -2278,11 +2278,6 @@ DECLARE_EVENT_CLASS(cfg80211_rx_evt,
  2182. TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT, NETDEV_PR_ARG, MAC_PR_ARG(addr))
  2183. );
  2184. -DEFINE_EVENT(cfg80211_rx_evt, cfg80211_ibss_joined,
  2185. - TP_PROTO(struct net_device *netdev, const u8 *addr),
  2186. - TP_ARGS(netdev, addr)
  2187. -);
  2188. -
  2189. DEFINE_EVENT(cfg80211_rx_evt, cfg80211_rx_spurious_frame,
  2190. TP_PROTO(struct net_device *netdev, const u8 *addr),
  2191. TP_ARGS(netdev, addr)
  2192. @@ -2293,6 +2288,24 @@ DEFINE_EVENT(cfg80211_rx_evt, cfg80211_r
  2193. TP_ARGS(netdev, addr)
  2194. );
  2195. +TRACE_EVENT(cfg80211_ibss_joined,
  2196. + TP_PROTO(struct net_device *netdev, const u8 *bssid,
  2197. + struct ieee80211_channel *channel),
  2198. + TP_ARGS(netdev, bssid, channel),
  2199. + TP_STRUCT__entry(
  2200. + NETDEV_ENTRY
  2201. + MAC_ENTRY(bssid)
  2202. + CHAN_ENTRY
  2203. + ),
  2204. + TP_fast_assign(
  2205. + NETDEV_ASSIGN;
  2206. + MAC_ASSIGN(bssid, bssid);
  2207. + CHAN_ASSIGN(channel);
  2208. + ),
  2209. + TP_printk(NETDEV_PR_FMT ", bssid: " MAC_PR_FMT ", " CHAN_PR_FMT,
  2210. + NETDEV_PR_ARG, MAC_PR_ARG(bssid), CHAN_PR_ARG)
  2211. +);
  2212. +
  2213. TRACE_EVENT(cfg80211_probe_status,
  2214. TP_PROTO(struct net_device *netdev, const u8 *addr, u64 cookie,
  2215. bool acked),
  2216. --- a/net/wireless/util.c
  2217. +++ b/net/wireless/util.c
  2218. @@ -820,7 +820,8 @@ void cfg80211_process_wdev_events(struct
  2219. ev->dc.reason, true);
  2220. break;
  2221. case EVENT_IBSS_JOINED:
  2222. - __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid);
  2223. + __cfg80211_ibss_joined(wdev->netdev, ev->ij.bssid,
  2224. + ev->ij.channel);
  2225. break;
  2226. }
  2227. wdev_unlock(wdev);
  2228. @@ -1356,7 +1357,7 @@ int cfg80211_can_use_iftype_chan(struct
  2229. */
  2230. mutex_lock_nested(&wdev_iter->mtx, 1);
  2231. __acquire(wdev_iter->mtx);
  2232. - cfg80211_get_chan_state(wdev_iter, &ch, &chmode);
  2233. + cfg80211_get_chan_state(wdev_iter, &ch, &chmode, &radar_detect);
  2234. wdev_unlock(wdev_iter);
  2235. switch (chmode) {
  2236. --- a/net/wireless/chan.c
  2237. +++ b/net/wireless/chan.c
  2238. @@ -642,7 +642,8 @@ int cfg80211_set_monitor_channel(struct
  2239. void
  2240. cfg80211_get_chan_state(struct wireless_dev *wdev,
  2241. struct ieee80211_channel **chan,
  2242. - enum cfg80211_chan_mode *chanmode)
  2243. + enum cfg80211_chan_mode *chanmode,
  2244. + u8 *radar_detect)
  2245. {
  2246. *chan = NULL;
  2247. *chanmode = CHAN_MODE_UNDEFINED;
  2248. @@ -660,6 +661,11 @@ cfg80211_get_chan_state(struct wireless_
  2249. !wdev->ibss_dfs_possible)
  2250. ? CHAN_MODE_SHARED
  2251. : CHAN_MODE_EXCLUSIVE;
  2252. +
  2253. + /* consider worst-case - IBSS can try to return to the
  2254. + * original user-specified channel as creator */
  2255. + if (wdev->ibss_dfs_possible)
  2256. + *radar_detect |= BIT(wdev->chandef.width);
  2257. return;
  2258. }
  2259. break;
  2260. @@ -674,17 +680,26 @@ cfg80211_get_chan_state(struct wireless_
  2261. case NL80211_IFTYPE_AP:
  2262. case NL80211_IFTYPE_P2P_GO:
  2263. if (wdev->cac_started) {
  2264. - *chan = wdev->channel;
  2265. + *chan = wdev->chandef.chan;
  2266. *chanmode = CHAN_MODE_SHARED;
  2267. + *radar_detect |= BIT(wdev->chandef.width);
  2268. } else if (wdev->beacon_interval) {
  2269. - *chan = wdev->channel;
  2270. + *chan = wdev->chandef.chan;
  2271. *chanmode = CHAN_MODE_SHARED;
  2272. +
  2273. + if (cfg80211_chandef_dfs_required(wdev->wiphy,
  2274. + &wdev->chandef))
  2275. + *radar_detect |= BIT(wdev->chandef.width);
  2276. }
  2277. return;
  2278. case NL80211_IFTYPE_MESH_POINT:
  2279. if (wdev->mesh_id_len) {
  2280. - *chan = wdev->channel;
  2281. + *chan = wdev->chandef.chan;
  2282. *chanmode = CHAN_MODE_SHARED;
  2283. +
  2284. + if (cfg80211_chandef_dfs_required(wdev->wiphy,
  2285. + &wdev->chandef))
  2286. + *radar_detect |= BIT(wdev->chandef.width);
  2287. }
  2288. return;
  2289. case NL80211_IFTYPE_MONITOR:
  2290. --- a/net/wireless/mesh.c
  2291. +++ b/net/wireless/mesh.c
  2292. @@ -195,7 +195,7 @@ int __cfg80211_join_mesh(struct cfg80211
  2293. if (!err) {
  2294. memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len);
  2295. wdev->mesh_id_len = setup->mesh_id_len;
  2296. - wdev->channel = setup->chandef.chan;
  2297. + wdev->chandef = setup->chandef;
  2298. }
  2299. return err;
  2300. @@ -244,7 +244,7 @@ int cfg80211_set_mesh_channel(struct cfg
  2301. err = rdev_libertas_set_mesh_channel(rdev, wdev->netdev,
  2302. chandef->chan);
  2303. if (!err)
  2304. - wdev->channel = chandef->chan;
  2305. + wdev->chandef = *chandef;
  2306. return err;
  2307. }
  2308. @@ -276,7 +276,7 @@ static int __cfg80211_leave_mesh(struct
  2309. err = rdev_leave_mesh(rdev, dev);
  2310. if (!err) {
  2311. wdev->mesh_id_len = 0;
  2312. - wdev->channel = NULL;
  2313. + memset(&wdev->chandef, 0, sizeof(wdev->chandef));
  2314. rdev_set_qos_map(rdev, dev, NULL);
  2315. }
  2316. --- a/net/wireless/mlme.c
  2317. +++ b/net/wireless/mlme.c
  2318. @@ -772,7 +772,7 @@ void cfg80211_cac_event(struct net_devic
  2319. if (WARN_ON(!wdev->cac_started))
  2320. return;
  2321. - if (WARN_ON(!wdev->channel))
  2322. + if (WARN_ON(!wdev->chandef.chan))
  2323. return;
  2324. switch (event) {
  2325. --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
  2326. +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
  2327. @@ -5065,6 +5065,10 @@ static u16 ar9003_hw_get_max_edge_power(
  2328. break;
  2329. }
  2330. }
  2331. +
  2332. + if (is2GHz && !twiceMaxEdgePower)
  2333. + twiceMaxEdgePower = 60;
  2334. +
  2335. return twiceMaxEdgePower;
  2336. }
  2337. --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
  2338. +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
  2339. @@ -23,10 +23,11 @@
  2340. #define MAX_MEASUREMENT MAX_IQCAL_MEASUREMENT
  2341. #define MAX_MAG_DELTA 11
  2342. #define MAX_PHS_DELTA 10
  2343. +#define MAXIQCAL 3
  2344. struct coeff {
  2345. - int mag_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT];
  2346. - int phs_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT];
  2347. + int mag_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT][MAXIQCAL];
  2348. + int phs_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT][MAXIQCAL];
  2349. int iqc_coeff[2];
  2350. };
  2351. @@ -800,7 +801,7 @@ static bool ar9003_hw_calc_iq_corr(struc
  2352. if (q_q_coff > 63)
  2353. q_q_coff = 63;
  2354. - iqc_coeff[0] = (q_q_coff * 128) + q_i_coff;
  2355. + iqc_coeff[0] = (q_q_coff * 128) + (0x7f & q_i_coff);
  2356. ath_dbg(common, CALIBRATE, "tx chain %d: iq corr coeff=%x\n",
  2357. chain_idx, iqc_coeff[0]);
  2358. @@ -831,7 +832,7 @@ static bool ar9003_hw_calc_iq_corr(struc
  2359. if (q_q_coff > 63)
  2360. q_q_coff = 63;
  2361. - iqc_coeff[1] = (q_q_coff * 128) + q_i_coff;
  2362. + iqc_coeff[1] = (q_q_coff * 128) + (0x7f & q_i_coff);
  2363. ath_dbg(common, CALIBRATE, "rx chain %d: iq corr coeff=%x\n",
  2364. chain_idx, iqc_coeff[1]);
  2365. @@ -839,7 +840,8 @@ static bool ar9003_hw_calc_iq_corr(struc
  2366. return true;
  2367. }
  2368. -static void ar9003_hw_detect_outlier(int *mp_coeff, int nmeasurement,
  2369. +static void ar9003_hw_detect_outlier(int mp_coeff[][MAXIQCAL],
  2370. + int nmeasurement,
  2371. int max_delta)
  2372. {
  2373. int mp_max = -64, max_idx = 0;
  2374. @@ -848,20 +850,20 @@ static void ar9003_hw_detect_outlier(int
  2375. /* find min/max mismatch across all calibrated gains */
  2376. for (i = 0; i < nmeasurement; i++) {
  2377. - if (mp_coeff[i] > mp_max) {
  2378. - mp_max = mp_coeff[i];
  2379. + if (mp_coeff[i][0] > mp_max) {
  2380. + mp_max = mp_coeff[i][0];
  2381. max_idx = i;
  2382. - } else if (mp_coeff[i] < mp_min) {
  2383. - mp_min = mp_coeff[i];
  2384. + } else if (mp_coeff[i][0] < mp_min) {
  2385. + mp_min = mp_coeff[i][0];
  2386. min_idx = i;
  2387. }
  2388. }
  2389. /* find average (exclude max abs value) */
  2390. for (i = 0; i < nmeasurement; i++) {
  2391. - if ((abs(mp_coeff[i]) < abs(mp_max)) ||
  2392. - (abs(mp_coeff[i]) < abs(mp_min))) {
  2393. - mp_avg += mp_coeff[i];
  2394. + if ((abs(mp_coeff[i][0]) < abs(mp_max)) ||
  2395. + (abs(mp_coeff[i][0]) < abs(mp_min))) {
  2396. + mp_avg += mp_coeff[i][0];
  2397. mp_count++;
  2398. }
  2399. }
  2400. @@ -873,7 +875,7 @@ static void ar9003_hw_detect_outlier(int
  2401. if (mp_count)
  2402. mp_avg /= mp_count;
  2403. else
  2404. - mp_avg = mp_coeff[nmeasurement - 1];
  2405. + mp_avg = mp_coeff[nmeasurement - 1][0];
  2406. /* detect outlier */
  2407. if (abs(mp_max - mp_min) > max_delta) {
  2408. @@ -882,15 +884,16 @@ static void ar9003_hw_detect_outlier(int
  2409. else
  2410. outlier_idx = min_idx;
  2411. - mp_coeff[outlier_idx] = mp_avg;
  2412. + mp_coeff[outlier_idx][0] = mp_avg;
  2413. }
  2414. }
  2415. -static void ar9003_hw_tx_iqcal_load_avg_2_passes(struct ath_hw *ah,
  2416. - struct coeff *coeff,
  2417. - bool is_reusable)
  2418. +static void ar9003_hw_tx_iq_cal_outlier_detection(struct ath_hw *ah,
  2419. + struct coeff *coeff,
  2420. + bool is_reusable)
  2421. {
  2422. int i, im, nmeasurement;
  2423. + int magnitude, phase;
  2424. u32 tx_corr_coeff[MAX_MEASUREMENT][AR9300_MAX_CHAINS];
  2425. struct ath9k_hw_cal_data *caldata = ah->caldata;
  2426. @@ -920,21 +923,30 @@ static void ar9003_hw_tx_iqcal_load_avg_
  2427. if (nmeasurement > MAX_MEASUREMENT)
  2428. nmeasurement = MAX_MEASUREMENT;
  2429. - /* detect outlier only if nmeasurement > 1 */
  2430. - if (nmeasurement > 1) {
  2431. - /* Detect magnitude outlier */
  2432. - ar9003_hw_detect_outlier(coeff->mag_coeff[i],
  2433. - nmeasurement, MAX_MAG_DELTA);
  2434. -
  2435. - /* Detect phase outlier */
  2436. - ar9003_hw_detect_outlier(coeff->phs_coeff[i],
  2437. - nmeasurement, MAX_PHS_DELTA);
  2438. + /*
  2439. + * Skip normal outlier detection for AR9550.
  2440. + */
  2441. + if (!AR_SREV_9550(ah)) {
  2442. + /* detect outlier only if nmeasurement > 1 */
  2443. + if (nmeasurement > 1) {
  2444. + /* Detect magnitude outlier */
  2445. + ar9003_hw_detect_outlier(coeff->mag_coeff[i],
  2446. + nmeasurement,
  2447. + MAX_MAG_DELTA);
  2448. +
  2449. + /* Detect phase outlier */
  2450. + ar9003_hw_detect_outlier(coeff->phs_coeff[i],
  2451. + nmeasurement,
  2452. + MAX_PHS_DELTA);
  2453. + }
  2454. }
  2455. for (im = 0; im < nmeasurement; im++) {
  2456. + magnitude = coeff->mag_coeff[i][im][0];
  2457. + phase = coeff->phs_coeff[i][im][0];
  2458. - coeff->iqc_coeff[0] = (coeff->mag_coeff[i][im] & 0x7f) |
  2459. - ((coeff->phs_coeff[i][im] & 0x7f) << 7);
  2460. + coeff->iqc_coeff[0] =
  2461. + (phase & 0x7f) | ((magnitude & 0x7f) << 7);
  2462. if ((im % 2) == 0)
  2463. REG_RMW_FIELD(ah, tx_corr_coeff[im][i],
  2464. @@ -991,7 +1003,63 @@ static bool ar9003_hw_tx_iq_cal_run(stru
  2465. return true;
  2466. }
  2467. -static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw *ah, bool is_reusable)
  2468. +static void __ar955x_tx_iq_cal_sort(struct ath_hw *ah,
  2469. + struct coeff *coeff,
  2470. + int i, int nmeasurement)
  2471. +{
  2472. + struct ath_common *common = ath9k_hw_common(ah);
  2473. + int im, ix, iy, temp;
  2474. +
  2475. + for (im = 0; im < nmeasurement; im++) {
  2476. + for (ix = 0; ix < MAXIQCAL - 1; ix++) {
  2477. + for (iy = ix + 1; iy <= MAXIQCAL - 1; iy++) {
  2478. + if (coeff->mag_coeff[i][im][iy] <
  2479. + coeff->mag_coeff[i][im][ix]) {
  2480. + temp = coeff->mag_coeff[i][im][ix];
  2481. + coeff->mag_coeff[i][im][ix] =
  2482. + coeff->mag_coeff[i][im][iy];
  2483. + coeff->mag_coeff[i][im][iy] = temp;
  2484. + }
  2485. + if (coeff->phs_coeff[i][im][iy] <
  2486. + coeff->phs_coeff[i][im][ix]) {
  2487. + temp = coeff->phs_coeff[i][im][ix];
  2488. + coeff->phs_coeff[i][im][ix] =
  2489. + coeff->phs_coeff[i][im][iy];
  2490. + coeff->phs_coeff[i][im][iy] = temp;
  2491. + }
  2492. + }
  2493. + }
  2494. + coeff->mag_coeff[i][im][0] = coeff->mag_coeff[i][im][MAXIQCAL / 2];
  2495. + coeff->phs_coeff[i][im][0] = coeff->phs_coeff[i][im][MAXIQCAL / 2];
  2496. +
  2497. + ath_dbg(common, CALIBRATE,
  2498. + "IQCAL: Median [ch%d][gain%d]: mag = %d phase = %d\n",
  2499. + i, im,
  2500. + coeff->mag_coeff[i][im][0],
  2501. + coeff->phs_coeff[i][im][0]);
  2502. + }
  2503. +}
  2504. +
  2505. +static bool ar955x_tx_iq_cal_median(struct ath_hw *ah,
  2506. + struct coeff *coeff,
  2507. + int iqcal_idx,
  2508. + int nmeasurement)
  2509. +{
  2510. + int i;
  2511. +
  2512. + if ((iqcal_idx + 1) != MAXIQCAL)
  2513. + return false;
  2514. +
  2515. + for (i = 0; i < AR9300_MAX_CHAINS; i++) {
  2516. + __ar955x_tx_iq_cal_sort(ah, coeff, i, nmeasurement);
  2517. + }
  2518. +
  2519. + return true;
  2520. +}
  2521. +
  2522. +static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw *ah,
  2523. + int iqcal_idx,
  2524. + bool is_reusable)
  2525. {
  2526. struct ath_common *common = ath9k_hw_common(ah);
  2527. const u32 txiqcal_status[AR9300_MAX_CHAINS] = {
  2528. @@ -1004,10 +1072,11 @@ static void ar9003_hw_tx_iq_cal_post_pro
  2529. AR_PHY_CHAN_INFO_TAB_1,
  2530. AR_PHY_CHAN_INFO_TAB_2,
  2531. };
  2532. - struct coeff coeff;
  2533. + static struct coeff coeff;
  2534. s32 iq_res[6];
  2535. int i, im, j;
  2536. - int nmeasurement;
  2537. + int nmeasurement = 0;
  2538. + bool outlier_detect = true;
  2539. for (i = 0; i < AR9300_MAX_CHAINS; i++) {
  2540. if (!(ah->txchainmask & (1 << i)))
  2541. @@ -1065,17 +1134,23 @@ static void ar9003_hw_tx_iq_cal_post_pro
  2542. goto tx_iqcal_fail;
  2543. }
  2544. - coeff.mag_coeff[i][im] = coeff.iqc_coeff[0] & 0x7f;
  2545. - coeff.phs_coeff[i][im] =
  2546. + coeff.phs_coeff[i][im][iqcal_idx] =
  2547. + coeff.iqc_coeff[0] & 0x7f;
  2548. + coeff.mag_coeff[i][im][iqcal_idx] =
  2549. (coeff.iqc_coeff[0] >> 7) & 0x7f;
  2550. - if (coeff.mag_coeff[i][im] > 63)
  2551. - coeff.mag_coeff[i][im] -= 128;
  2552. - if (coeff.phs_coeff[i][im] > 63)
  2553. - coeff.phs_coeff[i][im] -= 128;
  2554. + if (coeff.mag_coeff[i][im][iqcal_idx] > 63)
  2555. + coeff.mag_coeff[i][im][iqcal_idx] -= 128;
  2556. + if (coeff.phs_coeff[i][im][iqcal_idx] > 63)
  2557. + coeff.phs_coeff[i][im][iqcal_idx] -= 128;
  2558. }
  2559. }
  2560. - ar9003_hw_tx_iqcal_load_avg_2_passes(ah, &coeff, is_reusable);
  2561. +
  2562. + if (AR_SREV_9550(ah))
  2563. + outlier_detect = ar955x_tx_iq_cal_median(ah, &coeff,
  2564. + iqcal_idx, nmeasurement);
  2565. + if (outlier_detect)
  2566. + ar9003_hw_tx_iq_cal_outlier_detection(ah, &coeff, is_reusable);
  2567. return;
  2568. @@ -1409,7 +1484,7 @@ skip_tx_iqcal:
  2569. }
  2570. if (txiqcal_done)
  2571. - ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable);
  2572. + ar9003_hw_tx_iq_cal_post_proc(ah, 0, is_reusable);
  2573. else if (caldata && test_bit(TXIQCAL_DONE, &caldata->cal_flags))
  2574. ar9003_hw_tx_iq_cal_reload(ah);
  2575. @@ -1455,14 +1530,38 @@ skip_tx_iqcal:
  2576. return true;
  2577. }
  2578. +static bool do_ar9003_agc_cal(struct ath_hw *ah)
  2579. +{
  2580. + struct ath_common *common = ath9k_hw_common(ah);
  2581. + bool status;
  2582. +
  2583. + REG_WRITE(ah, AR_PHY_AGC_CONTROL,
  2584. + REG_READ(ah, AR_PHY_AGC_CONTROL) |
  2585. + AR_PHY_AGC_CONTROL_CAL);
  2586. +
  2587. + status = ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
  2588. + AR_PHY_AGC_CONTROL_CAL,
  2589. + 0, AH_WAIT_TIMEOUT);
  2590. + if (!status) {
  2591. + ath_dbg(common, CALIBRATE,
  2592. + "offset calibration failed to complete in %d ms,"
  2593. + "noisy environment?\n",
  2594. + AH_WAIT_TIMEOUT / 1000);
  2595. + return false;
  2596. + }
  2597. +
  2598. + return true;
  2599. +}
  2600. +
  2601. static bool ar9003_hw_init_cal_soc(struct ath_hw *ah,
  2602. struct ath9k_channel *chan)
  2603. {
  2604. struct ath_common *common = ath9k_hw_common(ah);
  2605. struct ath9k_hw_cal_data *caldata = ah->caldata;
  2606. bool txiqcal_done = false;
  2607. - bool is_reusable = true, status = true;
  2608. + bool status = true;
  2609. bool run_agc_cal = false, sep_iq_cal = false;
  2610. + int i = 0;
  2611. /* Use chip chainmask only for calibration */
  2612. ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
  2613. @@ -1485,7 +1584,12 @@ static bool ar9003_hw_init_cal_soc(struc
  2614. * AGC calibration. Specifically, AR9550 in SoC chips.
  2615. */
  2616. if (ah->enabled_cals & TX_IQ_ON_AGC_CAL) {
  2617. - txiqcal_done = true;
  2618. + if (REG_READ_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_0,
  2619. + AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL)) {
  2620. + txiqcal_done = true;
  2621. + } else {
  2622. + txiqcal_done = false;
  2623. + }
  2624. run_agc_cal = true;
  2625. } else {
  2626. sep_iq_cal = true;
  2627. @@ -1512,27 +1616,37 @@ skip_tx_iqcal:
  2628. if (AR_SREV_9330_11(ah))
  2629. ar9003_hw_manual_peak_cal(ah, 0, IS_CHAN_2GHZ(chan));
  2630. - /* Calibrate the AGC */
  2631. - REG_WRITE(ah, AR_PHY_AGC_CONTROL,
  2632. - REG_READ(ah, AR_PHY_AGC_CONTROL) |
  2633. - AR_PHY_AGC_CONTROL_CAL);
  2634. -
  2635. - /* Poll for offset calibration complete */
  2636. - status = ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
  2637. - AR_PHY_AGC_CONTROL_CAL,
  2638. - 0, AH_WAIT_TIMEOUT);
  2639. - }
  2640. + /*
  2641. + * For non-AR9550 chips, we just trigger AGC calibration
  2642. + * in the HW, poll for completion and then process
  2643. + * the results.
  2644. + *
  2645. + * For AR955x, we run it multiple times and use
  2646. + * median IQ correction.
  2647. + */
  2648. + if (!AR_SREV_9550(ah)) {
  2649. + status = do_ar9003_agc_cal(ah);
  2650. + if (!status)
  2651. + return false;
  2652. - if (!status) {
  2653. - ath_dbg(common, CALIBRATE,
  2654. - "offset calibration failed to complete in %d ms; noisy environment?\n",
  2655. - AH_WAIT_TIMEOUT / 1000);
  2656. - return false;
  2657. + if (txiqcal_done)
  2658. + ar9003_hw_tx_iq_cal_post_proc(ah, 0, false);
  2659. + } else {
  2660. + if (!txiqcal_done) {
  2661. + status = do_ar9003_agc_cal(ah);
  2662. + if (!status)
  2663. + return false;
  2664. + } else {
  2665. + for (i = 0; i < MAXIQCAL; i++) {
  2666. + status = do_ar9003_agc_cal(ah);
  2667. + if (!status)
  2668. + return false;
  2669. + ar9003_hw_tx_iq_cal_post_proc(ah, i, false);
  2670. + }
  2671. + }
  2672. + }
  2673. }
  2674. - if (txiqcal_done)
  2675. - ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable);
  2676. -
  2677. /* Revert chainmask to runtime parameters */
  2678. ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
  2679. --- a/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h
  2680. +++ b/drivers/net/wireless/rtl818x/rtl8187/rtl8187.h
  2681. @@ -15,6 +15,8 @@
  2682. #ifndef RTL8187_H
  2683. #define RTL8187_H
  2684. +#include <linux/cache.h>
  2685. +
  2686. #include "rtl818x.h"
  2687. #include "leds.h"
  2688. @@ -139,7 +141,10 @@ struct rtl8187_priv {
  2689. u8 aifsn[4];
  2690. u8 rfkill_mask;
  2691. struct {
  2692. - __le64 buf;
  2693. + union {
  2694. + __le64 buf;
  2695. + u8 dummy1[L1_CACHE_BYTES];
  2696. + } ____cacheline_aligned;
  2697. struct sk_buff_head queue;
  2698. } b_tx_status; /* This queue is used by both -b and non-b devices */
  2699. struct mutex io_mutex;
  2700. @@ -147,7 +152,8 @@ struct rtl8187_priv {
  2701. u8 bits8;
  2702. __le16 bits16;
  2703. __le32 bits32;
  2704. - } *io_dmabuf;
  2705. + u8 dummy2[L1_CACHE_BYTES];
  2706. + } *io_dmabuf ____cacheline_aligned;
  2707. bool rfkill_off;
  2708. u16 seqno;
  2709. };
  2710. --- a/net/mac80211/wme.c
  2711. +++ b/net/mac80211/wme.c
  2712. @@ -154,6 +154,11 @@ u16 ieee80211_select_queue(struct ieee80
  2713. return IEEE80211_AC_BE;
  2714. }
  2715. + if (skb->protocol == sdata->control_port_protocol) {
  2716. + skb->priority = 7;
  2717. + return ieee80211_downgrade_queue(sdata, skb);
  2718. + }
  2719. +
  2720. /* use the data classifier to determine what 802.1d tag the
  2721. * data frame has */
  2722. rcu_read_lock();
  2723. --- a/drivers/net/wireless/ath/ath9k/xmit.c
  2724. +++ b/drivers/net/wireless/ath/ath9k/xmit.c
  2725. @@ -1444,14 +1444,16 @@ void ath_tx_aggr_sleep(struct ieee80211_
  2726. for (tidno = 0, tid = &an->tid[tidno];
  2727. tidno < IEEE80211_NUM_TIDS; tidno++, tid++) {
  2728. - if (!tid->sched)
  2729. - continue;
  2730. -
  2731. ac = tid->ac;
  2732. txq = ac->txq;
  2733. ath_txq_lock(sc, txq);
  2734. + if (!tid->sched) {
  2735. + ath_txq_unlock(sc, txq);
  2736. + continue;
  2737. + }
  2738. +
  2739. buffered = ath_tid_has_buffered(tid);
  2740. tid->sched = false;
  2741. @@ -2184,14 +2186,15 @@ int ath_tx_start(struct ieee80211_hw *hw
  2742. txq->stopped = true;
  2743. }
  2744. + if (txctl->an)
  2745. + tid = ath_get_skb_tid(sc, txctl->an, skb);
  2746. +
  2747. if (info->flags & IEEE80211_TX_CTL_PS_RESPONSE) {
  2748. ath_txq_unlock(sc, txq);
  2749. txq = sc->tx.uapsdq;
  2750. ath_txq_lock(sc, txq);
  2751. } else if (txctl->an &&
  2752. ieee80211_is_data_present(hdr->frame_control)) {
  2753. - tid = ath_get_skb_tid(sc, txctl->an, skb);
  2754. -
  2755. WARN_ON(tid->ac->txq != txctl->txq);
  2756. if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT)
  2757. --- a/drivers/net/wireless/ath/ath9k/init.c
  2758. +++ b/drivers/net/wireless/ath/ath9k/init.c
  2759. @@ -943,6 +943,7 @@ static void ath9k_set_hw_capab(struct at
  2760. hw->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
  2761. hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_5_10_MHZ;
  2762. hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
  2763. + hw->wiphy->flags |= WIPHY_FLAG_AP_UAPSD;
  2764. hw->queues = 4;
  2765. hw->max_rates = 4;
  2766. --- a/net/mac80211/ieee80211_i.h
  2767. +++ b/net/mac80211/ieee80211_i.h
  2768. @@ -1700,14 +1700,8 @@ void ieee80211_stop_queue_by_reason(stru
  2769. void ieee80211_propagate_queue_wake(struct ieee80211_local *local, int queue);
  2770. void ieee80211_add_pending_skb(struct ieee80211_local *local,
  2771. struct sk_buff *skb);
  2772. -void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
  2773. - struct sk_buff_head *skbs,
  2774. - void (*fn)(void *data), void *data);
  2775. -static inline void ieee80211_add_pending_skbs(struct ieee80211_local *local,
  2776. - struct sk_buff_head *skbs)
  2777. -{
  2778. - ieee80211_add_pending_skbs_fn(local, skbs, NULL, NULL);
  2779. -}
  2780. +void ieee80211_add_pending_skbs(struct ieee80211_local *local,
  2781. + struct sk_buff_head *skbs);
  2782. void ieee80211_flush_queues(struct ieee80211_local *local,
  2783. struct ieee80211_sub_if_data *sdata);
  2784. --- a/net/mac80211/sta_info.c
  2785. +++ b/net/mac80211/sta_info.c
  2786. @@ -91,7 +91,7 @@ static int sta_info_hash_del(struct ieee
  2787. return -ENOENT;
  2788. }
  2789. -static void cleanup_single_sta(struct sta_info *sta)
  2790. +static void __cleanup_single_sta(struct sta_info *sta)
  2791. {
  2792. int ac, i;
  2793. struct tid_ampdu_tx *tid_tx;
  2794. @@ -99,7 +99,8 @@ static void cleanup_single_sta(struct st
  2795. struct ieee80211_local *local = sdata->local;
  2796. struct ps_data *ps;
  2797. - if (test_sta_flag(sta, WLAN_STA_PS_STA)) {
  2798. + if (test_sta_flag(sta, WLAN_STA_PS_STA) ||
  2799. + test_sta_flag(sta, WLAN_STA_PS_DRIVER)) {
  2800. if (sta->sdata->vif.type == NL80211_IFTYPE_AP ||
  2801. sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  2802. ps = &sdata->bss->ps;
  2803. @@ -109,6 +110,7 @@ static void cleanup_single_sta(struct st
  2804. return;
  2805. clear_sta_flag(sta, WLAN_STA_PS_STA);
  2806. + clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
  2807. atomic_dec(&ps->num_sta_ps);
  2808. sta_info_recalc_tim(sta);
  2809. @@ -139,7 +141,14 @@ static void cleanup_single_sta(struct st
  2810. ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending);
  2811. kfree(tid_tx);
  2812. }
  2813. +}
  2814. +static void cleanup_single_sta(struct sta_info *sta)
  2815. +{
  2816. + struct ieee80211_sub_if_data *sdata = sta->sdata;
  2817. + struct ieee80211_local *local = sdata->local;
  2818. +
  2819. + __cleanup_single_sta(sta);
  2820. sta_info_free(local, sta);
  2821. }
  2822. @@ -330,6 +339,7 @@ struct sta_info *sta_info_alloc(struct i
  2823. rcu_read_unlock();
  2824. spin_lock_init(&sta->lock);
  2825. + spin_lock_init(&sta->ps_lock);
  2826. INIT_WORK(&sta->drv_unblock_wk, sta_unblock);
  2827. INIT_WORK(&sta->ampdu_mlme.work, ieee80211_ba_session_work);
  2828. mutex_init(&sta->ampdu_mlme.mtx);
  2829. @@ -487,21 +497,26 @@ static int sta_info_insert_finish(struct
  2830. goto out_err;
  2831. }
  2832. - /* notify driver */
  2833. - err = sta_info_insert_drv_state(local, sdata, sta);
  2834. - if (err)
  2835. - goto out_err;
  2836. -
  2837. local->num_sta++;
  2838. local->sta_generation++;
  2839. smp_mb();
  2840. + /* simplify things and don't accept BA sessions yet */
  2841. + set_sta_flag(sta, WLAN_STA_BLOCK_BA);
  2842. +
  2843. /* make the station visible */
  2844. sta_info_hash_add(local, sta);
  2845. list_add_rcu(&sta->list, &local->sta_list);
  2846. + /* notify driver */
  2847. + err = sta_info_insert_drv_state(local, sdata, sta);
  2848. + if (err)
  2849. + goto out_remove;
  2850. +
  2851. set_sta_flag(sta, WLAN_STA_INSERTED);
  2852. + /* accept BA sessions now */
  2853. + clear_sta_flag(sta, WLAN_STA_BLOCK_BA);
  2854. ieee80211_recalc_min_chandef(sdata);
  2855. ieee80211_sta_debugfs_add(sta);
  2856. @@ -522,6 +537,12 @@ static int sta_info_insert_finish(struct
  2857. mesh_accept_plinks_update(sdata);
  2858. return 0;
  2859. + out_remove:
  2860. + sta_info_hash_del(local, sta);
  2861. + list_del_rcu(&sta->list);
  2862. + local->num_sta--;
  2863. + synchronize_net();
  2864. + __cleanup_single_sta(sta);
  2865. out_err:
  2866. mutex_unlock(&local->sta_mtx);
  2867. rcu_read_lock();
  2868. @@ -1071,10 +1092,14 @@ struct ieee80211_sta *ieee80211_find_sta
  2869. }
  2870. EXPORT_SYMBOL(ieee80211_find_sta);
  2871. -static void clear_sta_ps_flags(void *_sta)
  2872. +/* powersave support code */
  2873. +void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
  2874. {
  2875. - struct sta_info *sta = _sta;
  2876. struct ieee80211_sub_if_data *sdata = sta->sdata;
  2877. + struct ieee80211_local *local = sdata->local;
  2878. + struct sk_buff_head pending;
  2879. + int filtered = 0, buffered = 0, ac;
  2880. + unsigned long flags;
  2881. struct ps_data *ps;
  2882. if (sdata->vif.type == NL80211_IFTYPE_AP ||
  2883. @@ -1085,20 +1110,6 @@ static void clear_sta_ps_flags(void *_st
  2884. else
  2885. return;
  2886. - clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
  2887. - if (test_and_clear_sta_flag(sta, WLAN_STA_PS_STA))
  2888. - atomic_dec(&ps->num_sta_ps);
  2889. -}
  2890. -
  2891. -/* powersave support code */
  2892. -void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
  2893. -{
  2894. - struct ieee80211_sub_if_data *sdata = sta->sdata;
  2895. - struct ieee80211_local *local = sdata->local;
  2896. - struct sk_buff_head pending;
  2897. - int filtered = 0, buffered = 0, ac;
  2898. - unsigned long flags;
  2899. -
  2900. clear_sta_flag(sta, WLAN_STA_SP);
  2901. BUILD_BUG_ON(BITS_TO_LONGS(IEEE80211_NUM_TIDS) > 1);
  2902. @@ -1109,6 +1120,8 @@ void ieee80211_sta_ps_deliver_wakeup(str
  2903. skb_queue_head_init(&pending);
  2904. + /* sync with ieee80211_tx_h_unicast_ps_buf */
  2905. + spin_lock(&sta->ps_lock);
  2906. /* Send all buffered frames to the station */
  2907. for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
  2908. int count = skb_queue_len(&pending), tmp;
  2909. @@ -1127,7 +1140,12 @@ void ieee80211_sta_ps_deliver_wakeup(str
  2910. buffered += tmp - count;
  2911. }
  2912. - ieee80211_add_pending_skbs_fn(local, &pending, clear_sta_ps_flags, sta);
  2913. + ieee80211_add_pending_skbs(local, &pending);
  2914. + clear_sta_flag(sta, WLAN_STA_PS_DRIVER);
  2915. + clear_sta_flag(sta, WLAN_STA_PS_STA);
  2916. + spin_unlock(&sta->ps_lock);
  2917. +
  2918. + atomic_dec(&ps->num_sta_ps);
  2919. /* This station just woke up and isn't aware of our SMPS state */
  2920. if (!ieee80211_smps_is_restrictive(sta->known_smps_mode,
  2921. --- a/net/mac80211/sta_info.h
  2922. +++ b/net/mac80211/sta_info.h
  2923. @@ -267,6 +267,7 @@ struct ieee80211_tx_latency_stat {
  2924. * @drv_unblock_wk: used for driver PS unblocking
  2925. * @listen_interval: listen interval of this station, when we're acting as AP
  2926. * @_flags: STA flags, see &enum ieee80211_sta_info_flags, do not use directly
  2927. + * @ps_lock: used for powersave (when mac80211 is the AP) related locking
  2928. * @ps_tx_buf: buffers (per AC) of frames to transmit to this station
  2929. * when it leaves power saving state or polls
  2930. * @tx_filtered: buffers (per AC) of frames we already tried to
  2931. @@ -356,10 +357,8 @@ struct sta_info {
  2932. /* use the accessors defined below */
  2933. unsigned long _flags;
  2934. - /*
  2935. - * STA powersave frame queues, no more than the internal
  2936. - * locking required.
  2937. - */
  2938. + /* STA powersave lock and frame queues */
  2939. + spinlock_t ps_lock;
  2940. struct sk_buff_head ps_tx_buf[IEEE80211_NUM_ACS];
  2941. struct sk_buff_head tx_filtered[IEEE80211_NUM_ACS];
  2942. unsigned long driver_buffered_tids;
  2943. --- a/net/mac80211/util.c
  2944. +++ b/net/mac80211/util.c
  2945. @@ -435,9 +435,8 @@ void ieee80211_add_pending_skb(struct ie
  2946. spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
  2947. }
  2948. -void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
  2949. - struct sk_buff_head *skbs,
  2950. - void (*fn)(void *data), void *data)
  2951. +void ieee80211_add_pending_skbs(struct ieee80211_local *local,
  2952. + struct sk_buff_head *skbs)
  2953. {
  2954. struct ieee80211_hw *hw = &local->hw;
  2955. struct sk_buff *skb;
  2956. @@ -461,9 +460,6 @@ void ieee80211_add_pending_skbs_fn(struc
  2957. __skb_queue_tail(&local->pending[queue], skb);
  2958. }
  2959. - if (fn)
  2960. - fn(data);
  2961. -
  2962. for (i = 0; i < hw->queues; i++)
  2963. __ieee80211_wake_queue(hw, i,
  2964. IEEE80211_QUEUE_STOP_REASON_SKB_ADD);
  2965. --- a/net/wireless/reg.c
  2966. +++ b/net/wireless/reg.c
  2967. @@ -1700,7 +1700,7 @@ static void reg_process_hint(struct regu
  2968. return;
  2969. case NL80211_REGDOM_SET_BY_USER:
  2970. treatment = reg_process_hint_user(reg_request);
  2971. - if (treatment == REG_REQ_OK ||
  2972. + if (treatment == REG_REQ_IGNORE ||
  2973. treatment == REG_REQ_ALREADY_SET)
  2974. return;
  2975. schedule_delayed_work(&reg_timeout, msecs_to_jiffies(3142));
  2976. --- a/drivers/net/wireless/ath/ath9k/debug.c
  2977. +++ b/drivers/net/wireless/ath/ath9k/debug.c
  2978. @@ -866,6 +866,12 @@ static ssize_t read_file_reset(struct fi
  2979. "%17s: %2d\n", "PLL RX Hang",
  2980. sc->debug.stats.reset[RESET_TYPE_PLL_HANG]);
  2981. len += scnprintf(buf + len, sizeof(buf) - len,
  2982. + "%17s: %2d\n", "MAC Hang",
  2983. + sc->debug.stats.reset[RESET_TYPE_MAC_HANG]);
  2984. + len += scnprintf(buf + len, sizeof(buf) - len,
  2985. + "%17s: %2d\n", "Stuck Beacon",
  2986. + sc->debug.stats.reset[RESET_TYPE_BEACON_STUCK]);
  2987. + len += scnprintf(buf + len, sizeof(buf) - len,
  2988. "%17s: %2d\n", "MCI Reset",
  2989. sc->debug.stats.reset[RESET_TYPE_MCI]);
  2990. --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
  2991. +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
  2992. @@ -868,10 +868,6 @@ static void ar9003_hw_set_rfmode(struct
  2993. if (IS_CHAN_A_FAST_CLOCK(ah, chan))
  2994. rfMode |= (AR_PHY_MODE_DYNAMIC | AR_PHY_MODE_DYN_CCK_DISABLE);
  2995. - if (IS_CHAN_QUARTER_RATE(chan))
  2996. - rfMode |= AR_PHY_MODE_QUARTER;
  2997. - if (IS_CHAN_HALF_RATE(chan))
  2998. - rfMode |= AR_PHY_MODE_HALF;
  2999. if (rfMode & (AR_PHY_MODE_QUARTER | AR_PHY_MODE_HALF))
  3000. REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL,
  3001. --- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
  3002. +++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
  3003. @@ -706,6 +706,7 @@ ath5k_get_survey(struct ieee80211_hw *hw
  3004. survey->channel = conf->chandef.chan;
  3005. survey->noise = ah->ah_noise_floor;
  3006. survey->filled = SURVEY_INFO_NOISE_DBM |
  3007. + SURVEY_INFO_IN_USE |
  3008. SURVEY_INFO_CHANNEL_TIME |
  3009. SURVEY_INFO_CHANNEL_TIME_BUSY |
  3010. SURVEY_INFO_CHANNEL_TIME_RX |
  3011. --- a/drivers/net/wireless/ath/ath9k/recv.c
  3012. +++ b/drivers/net/wireless/ath/ath9k/recv.c
  3013. @@ -732,11 +732,18 @@ static struct ath_rxbuf *ath_get_next_rx
  3014. return NULL;
  3015. /*
  3016. - * mark descriptor as zero-length and set the 'more'
  3017. - * flag to ensure that both buffers get discarded
  3018. + * Re-check previous descriptor, in case it has been filled
  3019. + * in the mean time.
  3020. */
  3021. - rs->rs_datalen = 0;
  3022. - rs->rs_more = true;
  3023. + ret = ath9k_hw_rxprocdesc(ah, ds, rs);
  3024. + if (ret == -EINPROGRESS) {
  3025. + /*
  3026. + * mark descriptor as zero-length and set the 'more'
  3027. + * flag to ensure that both buffers get discarded
  3028. + */
  3029. + rs->rs_datalen = 0;
  3030. + rs->rs_more = true;
  3031. + }
  3032. }
  3033. list_del(&bf->list);
  3034. @@ -985,32 +992,32 @@ static int ath9k_rx_skb_preprocess(struc
  3035. struct ath_common *common = ath9k_hw_common(ah);
  3036. struct ieee80211_hdr *hdr;
  3037. bool discard_current = sc->rx.discard_next;
  3038. - int ret = 0;
  3039. /*
  3040. * Discard corrupt descriptors which are marked in
  3041. * ath_get_next_rx_buf().
  3042. */
  3043. - sc->rx.discard_next = rx_stats->rs_more;
  3044. if (discard_current)
  3045. - return -EINVAL;
  3046. + goto corrupt;
  3047. +
  3048. + sc->rx.discard_next = false;
  3049. /*
  3050. * Discard zero-length packets.
  3051. */
  3052. if (!rx_stats->rs_datalen) {
  3053. RX_STAT_INC(rx_len_err);
  3054. - return -EINVAL;
  3055. + goto corrupt;
  3056. }
  3057. - /*
  3058. - * rs_status follows rs_datalen so if rs_datalen is too large
  3059. - * we can take a hint that hardware corrupted it, so ignore
  3060. - * those frames.
  3061. - */
  3062. + /*
  3063. + * rs_status follows rs_datalen so if rs_datalen is too large
  3064. + * we can take a hint that hardware corrupted it, so ignore
  3065. + * those frames.
  3066. + */
  3067. if (rx_stats->rs_datalen > (common->rx_bufsize - ah->caps.rx_status_len)) {
  3068. RX_STAT_INC(rx_len_err);
  3069. - return -EINVAL;
  3070. + goto corrupt;
  3071. }
  3072. /* Only use status info from the last fragment */
  3073. @@ -1024,10 +1031,8 @@ static int ath9k_rx_skb_preprocess(struc
  3074. * This is different from the other corrupt descriptor
  3075. * condition handled above.
  3076. */
  3077. - if (rx_stats->rs_status & ATH9K_RXERR_CORRUPT_DESC) {
  3078. - ret = -EINVAL;
  3079. - goto exit;
  3080. - }
  3081. + if (rx_stats->rs_status & ATH9K_RXERR_CORRUPT_DESC)
  3082. + goto corrupt;
  3083. hdr = (struct ieee80211_hdr *) (skb->data + ah->caps.rx_status_len);
  3084. @@ -1043,18 +1048,15 @@ static int ath9k_rx_skb_preprocess(struc
  3085. if (ath_process_fft(sc, hdr, rx_stats, rx_status->mactime))
  3086. RX_STAT_INC(rx_spectral);
  3087. - ret = -EINVAL;
  3088. - goto exit;
  3089. + return -EINVAL;
  3090. }
  3091. /*
  3092. * everything but the rate is checked here, the rate check is done
  3093. * separately to avoid doing two lookups for a rate for each frame.
  3094. */
  3095. - if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error)) {
  3096. - ret = -EINVAL;
  3097. - goto exit;
  3098. - }
  3099. + if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error))
  3100. + return -EINVAL;
  3101. if (ath_is_mybeacon(common, hdr)) {
  3102. RX_STAT_INC(rx_beacons);
  3103. @@ -1064,15 +1066,11 @@ static int ath9k_rx_skb_preprocess(struc
  3104. /*
  3105. * This shouldn't happen, but have a safety check anyway.
  3106. */
  3107. - if (WARN_ON(!ah->curchan)) {
  3108. - ret = -EINVAL;
  3109. - goto exit;
  3110. - }
  3111. + if (WARN_ON(!ah->curchan))
  3112. + return -EINVAL;
  3113. - if (ath9k_process_rate(common, hw, rx_stats, rx_status)) {
  3114. - ret =-EINVAL;
  3115. - goto exit;
  3116. - }
  3117. + if (ath9k_process_rate(common, hw, rx_stats, rx_status))
  3118. + return -EINVAL;
  3119. ath9k_process_rssi(common, hw, rx_stats, rx_status);
  3120. @@ -1087,9 +1085,11 @@ static int ath9k_rx_skb_preprocess(struc
  3121. sc->rx.num_pkts++;
  3122. #endif
  3123. -exit:
  3124. - sc->rx.discard_next = false;
  3125. - return ret;
  3126. + return 0;
  3127. +
  3128. +corrupt:
  3129. + sc->rx.discard_next = rx_stats->rs_more;
  3130. + return -EINVAL;
  3131. }
  3132. static void ath9k_rx_skb_postprocess(struct ath_common *common,
  3133. --- a/drivers/net/wireless/ath/ath9k/ani.c
  3134. +++ b/drivers/net/wireless/ath/ath9k/ani.c
  3135. @@ -176,16 +176,26 @@ static void ath9k_hw_set_ofdm_nil(struct
  3136. if (ah->opmode == NL80211_IFTYPE_STATION &&
  3137. BEACON_RSSI(ah) <= ATH9K_ANI_RSSI_THR_HIGH)
  3138. weak_sig = true;
  3139. -
  3140. /*
  3141. - * OFDM Weak signal detection is always enabled for AP mode.
  3142. + * Newer chipsets are better at dealing with high PHY error counts -
  3143. + * keep weak signal detection enabled when no RSSI threshold is
  3144. + * available to determine if it is needed (mode != STA)
  3145. */
  3146. - if (ah->opmode != NL80211_IFTYPE_AP &&
  3147. - aniState->ofdmWeakSigDetect != weak_sig) {
  3148. - ath9k_hw_ani_control(ah,
  3149. - ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
  3150. - entry_ofdm->ofdm_weak_signal_on);
  3151. - }
  3152. + else if (AR_SREV_9300_20_OR_LATER(ah) &&
  3153. + ah->opmode != NL80211_IFTYPE_STATION)
  3154. + weak_sig = true;
  3155. +
  3156. + /* Older chipsets are more sensitive to high PHY error counts */
  3157. + else if (!AR_SREV_9300_20_OR_LATER(ah) &&
  3158. + aniState->ofdmNoiseImmunityLevel >= 8)
  3159. + weak_sig = false;
  3160. +
  3161. + if (aniState->ofdmWeakSigDetect != weak_sig)
  3162. + ath9k_hw_ani_control(ah, ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION,
  3163. + weak_sig);
  3164. +
  3165. + if (!AR_SREV_9300_20_OR_LATER(ah))
  3166. + return;
  3167. if (aniState->ofdmNoiseImmunityLevel >= ATH9K_ANI_OFDM_DEF_LEVEL) {
  3168. ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH;
  3169. @@ -483,10 +493,17 @@ void ath9k_hw_ani_init(struct ath_hw *ah
  3170. ath_dbg(common, ANI, "Initialize ANI\n");
  3171. - ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH;
  3172. - ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW;
  3173. - ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH;
  3174. - ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW;
  3175. + if (AR_SREV_9300_20_OR_LATER(ah)) {
  3176. + ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH;
  3177. + ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW;
  3178. + ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH;
  3179. + ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW;
  3180. + } else {
  3181. + ah->config.ofdm_trig_high = ATH9K_ANI_OFDM_TRIG_HIGH_OLD;
  3182. + ah->config.ofdm_trig_low = ATH9K_ANI_OFDM_TRIG_LOW_OLD;
  3183. + ah->config.cck_trig_high = ATH9K_ANI_CCK_TRIG_HIGH_OLD;
  3184. + ah->config.cck_trig_low = ATH9K_ANI_CCK_TRIG_LOW_OLD;
  3185. + }
  3186. ani->spurImmunityLevel = ATH9K_ANI_SPUR_IMMUNE_LVL;
  3187. ani->firstepLevel = ATH9K_ANI_FIRSTEP_LVL;
  3188. --- a/drivers/net/wireless/ath/ath9k/ani.h
  3189. +++ b/drivers/net/wireless/ath/ath9k/ani.h
  3190. @@ -22,12 +22,16 @@
  3191. /* units are errors per second */
  3192. #define ATH9K_ANI_OFDM_TRIG_HIGH 3500
  3193. #define ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI 1000
  3194. +#define ATH9K_ANI_OFDM_TRIG_HIGH_OLD 500
  3195. #define ATH9K_ANI_OFDM_TRIG_LOW 400
  3196. #define ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI 900
  3197. +#define ATH9K_ANI_OFDM_TRIG_LOW_OLD 200
  3198. #define ATH9K_ANI_CCK_TRIG_HIGH 600
  3199. +#define ATH9K_ANI_CCK_TRIG_HIGH_OLD 200
  3200. #define ATH9K_ANI_CCK_TRIG_LOW 300
  3201. +#define ATH9K_ANI_CCK_TRIG_LOW_OLD 100
  3202. #define ATH9K_ANI_SPUR_IMMUNE_LVL 3
  3203. #define ATH9K_ANI_FIRSTEP_LVL 2