rc.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435
  1. /*
  2. * Copyright (c) 2004 Video54 Technologies, Inc.
  3. * Copyright (c) 2004-2009 Atheros Communications, Inc.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #include "ath9k.h"
  18. static const struct ath_rate_table ar5416_11na_ratetable = {
  19. 42,
  20. 8, /* MCS start */
  21. {
  22. { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
  23. 5400, 0, 12, 0, 0, 0, 0, 0 },
  24. { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
  25. 7800, 1, 18, 0, 1, 1, 1, 1 },
  26. { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
  27. 10000, 2, 24, 2, 2, 2, 2, 2 },
  28. { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
  29. 13900, 3, 36, 2, 3, 3, 3, 3 },
  30. { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
  31. 17300, 4, 48, 4, 4, 4, 4, 4 },
  32. { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
  33. 23000, 5, 72, 4, 5, 5, 5, 5 },
  34. { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
  35. 27400, 6, 96, 4, 6, 6, 6, 6 },
  36. { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
  37. 29300, 7, 108, 4, 7, 7, 7, 7 },
  38. { VALID_2040, VALID_2040, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */
  39. 6400, 0, 0, 0, 8, 24, 8, 24 },
  40. { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */
  41. 12700, 1, 1, 2, 9, 25, 9, 25 },
  42. { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */
  43. 18800, 2, 2, 2, 10, 26, 10, 26 },
  44. { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */
  45. 25000, 3, 3, 4, 11, 27, 11, 27 },
  46. { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */
  47. 36700, 4, 4, 4, 12, 28, 12, 28 },
  48. { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */
  49. 48100, 5, 5, 4, 13, 29, 13, 29 },
  50. { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */
  51. 53500, 6, 6, 4, 14, 30, 14, 30 },
  52. { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */
  53. 59000, 7, 7, 4, 15, 31, 15, 32 },
  54. { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */
  55. 12700, 8, 8, 3, 16, 33, 16, 33 },
  56. { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */
  57. 24800, 9, 9, 2, 17, 34, 17, 34 },
  58. { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */
  59. 36600, 10, 10, 2, 18, 35, 18, 35 },
  60. { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */
  61. 48100, 11, 11, 4, 19, 36, 19, 36 },
  62. { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */
  63. 69500, 12, 12, 4, 20, 37, 20, 37 },
  64. { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */
  65. 89500, 13, 13, 4, 21, 38, 21, 38 },
  66. { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */
  67. 98900, 14, 14, 4, 22, 39, 22, 39 },
  68. { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */
  69. 108300, 15, 15, 4, 23, 40, 23, 41 },
  70. { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */
  71. 13200, 0, 0, 0, 8, 24, 24, 24 },
  72. { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */
  73. 25900, 1, 1, 2, 9, 25, 25, 25 },
  74. { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */
  75. 38600, 2, 2, 2, 10, 26, 26, 26 },
  76. { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */
  77. 49800, 3, 3, 4, 11, 27, 27, 27 },
  78. { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */
  79. 72200, 4, 4, 4, 12, 28, 28, 28 },
  80. { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */
  81. 92900, 5, 5, 4, 13, 29, 29, 29 },
  82. { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */
  83. 102700, 6, 6, 4, 14, 30, 30, 30 },
  84. { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */
  85. 112000, 7, 7, 4, 15, 31, 32, 32 },
  86. { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */
  87. 122000, 7, 7, 4, 15, 31, 32, 32 },
  88. { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */
  89. 25800, 8, 8, 0, 16, 33, 33, 33 },
  90. { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */
  91. 49800, 9, 9, 2, 17, 34, 34, 34 },
  92. { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */
  93. 71900, 10, 10, 2, 18, 35, 35, 35 },
  94. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */
  95. 92500, 11, 11, 4, 19, 36, 36, 36 },
  96. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */
  97. 130300, 12, 12, 4, 20, 37, 37, 37 },
  98. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */
  99. 162800, 13, 13, 4, 21, 38, 38, 38 },
  100. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */
  101. 178200, 14, 14, 4, 22, 39, 39, 39 },
  102. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */
  103. 192100, 15, 15, 4, 23, 40, 41, 41 },
  104. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */
  105. 207000, 15, 15, 4, 23, 40, 41, 41 },
  106. },
  107. 50, /* probe interval */
  108. WLAN_RC_HT_FLAG, /* Phy rates allowed initially */
  109. };
  110. /* 4ms frame limit not used for NG mode. The values filled
  111. * for HT are the 64K max aggregate limit */
  112. static const struct ath_rate_table ar5416_11ng_ratetable = {
  113. 46,
  114. 12, /* MCS start */
  115. {
  116. { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */
  117. 900, 0, 2, 0, 0, 0, 0, 0 },
  118. { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */
  119. 1900, 1, 4, 1, 1, 1, 1, 1 },
  120. { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */
  121. 4900, 2, 11, 2, 2, 2, 2, 2 },
  122. { VALID_ALL, VALID_ALL, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */
  123. 8100, 3, 22, 3, 3, 3, 3, 3 },
  124. { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
  125. 5400, 4, 12, 4, 4, 4, 4, 4 },
  126. { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
  127. 7800, 5, 18, 4, 5, 5, 5, 5 },
  128. { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
  129. 10100, 6, 24, 6, 6, 6, 6, 6 },
  130. { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
  131. 14100, 7, 36, 6, 7, 7, 7, 7 },
  132. { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
  133. 17700, 8, 48, 8, 8, 8, 8, 8 },
  134. { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
  135. 23700, 9, 72, 8, 9, 9, 9, 9 },
  136. { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
  137. 27400, 10, 96, 8, 10, 10, 10, 10 },
  138. { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
  139. 30900, 11, 108, 8, 11, 11, 11, 11 },
  140. { INVALID, INVALID, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */
  141. 6400, 0, 0, 4, 12, 28, 12, 28 },
  142. { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */
  143. 12700, 1, 1, 6, 13, 29, 13, 29 },
  144. { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */
  145. 18800, 2, 2, 6, 14, 30, 14, 30 },
  146. { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */
  147. 25000, 3, 3, 8, 15, 31, 15, 31 },
  148. { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */
  149. 36700, 4, 4, 8, 16, 32, 16, 32 },
  150. { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */
  151. 48100, 5, 5, 8, 17, 33, 17, 33 },
  152. { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */
  153. 53500, 6, 6, 8, 18, 34, 18, 34 },
  154. { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */
  155. 59000, 7, 7, 8, 19, 35, 19, 36 },
  156. { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */
  157. 12700, 8, 8, 4, 20, 37, 20, 37 },
  158. { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */
  159. 24800, 9, 9, 6, 21, 38, 21, 38 },
  160. { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */
  161. 36600, 10, 10, 6, 22, 39, 22, 39 },
  162. { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */
  163. 48100, 11, 11, 8, 23, 40, 23, 40 },
  164. { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */
  165. 69500, 12, 12, 8, 24, 41, 24, 41 },
  166. { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */
  167. 89500, 13, 13, 8, 25, 42, 25, 42 },
  168. { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */
  169. 98900, 14, 14, 8, 26, 43, 26, 44 },
  170. { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */
  171. 108300, 15, 15, 8, 27, 44, 27, 45 },
  172. { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */
  173. 13200, 0, 0, 8, 12, 28, 28, 28 },
  174. { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */
  175. 25900, 1, 1, 8, 13, 29, 29, 29 },
  176. { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */
  177. 38600, 2, 2, 8, 14, 30, 30, 30 },
  178. { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */
  179. 49800, 3, 3, 8, 15, 31, 31, 31 },
  180. { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */
  181. 72200, 4, 4, 8, 16, 32, 32, 32 },
  182. { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */
  183. 92900, 5, 5, 8, 17, 33, 33, 33 },
  184. { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */
  185. 102700, 6, 6, 8, 18, 34, 34, 34 },
  186. { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */
  187. 112000, 7, 7, 8, 19, 35, 36, 36 },
  188. { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */
  189. 122000, 7, 7, 8, 19, 35, 36, 36 },
  190. { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */
  191. 25800, 8, 8, 8, 20, 37, 37, 37 },
  192. { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */
  193. 49800, 9, 9, 8, 21, 38, 38, 38 },
  194. { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */
  195. 71900, 10, 10, 8, 22, 39, 39, 39 },
  196. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */
  197. 92500, 11, 11, 8, 23, 40, 40, 40 },
  198. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */
  199. 130300, 12, 12, 8, 24, 41, 41, 41 },
  200. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */
  201. 162800, 13, 13, 8, 25, 42, 42, 42 },
  202. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */
  203. 178200, 14, 14, 8, 26, 43, 43, 43 },
  204. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */
  205. 192100, 15, 15, 8, 27, 44, 45, 45 },
  206. { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */
  207. 207000, 15, 15, 8, 27, 44, 45, 45 },
  208. },
  209. 50, /* probe interval */
  210. WLAN_RC_HT_FLAG, /* Phy rates allowed initially */
  211. };
  212. static const struct ath_rate_table ar5416_11a_ratetable = {
  213. 8,
  214. 0,
  215. {
  216. { VALID, VALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
  217. 5400, 0, 12, 0, 0, 0 },
  218. { VALID, VALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
  219. 7800, 1, 18, 0, 1, 0 },
  220. { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
  221. 10000, 2, 24, 2, 2, 0 },
  222. { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
  223. 13900, 3, 36, 2, 3, 0 },
  224. { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
  225. 17300, 4, 48, 4, 4, 0 },
  226. { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
  227. 23000, 5, 72, 4, 5, 0 },
  228. { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
  229. 27400, 6, 96, 4, 6, 0 },
  230. { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
  231. 29300, 7, 108, 4, 7, 0 },
  232. },
  233. 50, /* probe interval */
  234. 0, /* Phy rates allowed initially */
  235. };
  236. static const struct ath_rate_table ar5416_11g_ratetable = {
  237. 12,
  238. 0,
  239. {
  240. { VALID, VALID, WLAN_RC_PHY_CCK, 1000, /* 1 Mb */
  241. 900, 0, 2, 0, 0, 0 },
  242. { VALID, VALID, WLAN_RC_PHY_CCK, 2000, /* 2 Mb */
  243. 1900, 1, 4, 1, 1, 0 },
  244. { VALID, VALID, WLAN_RC_PHY_CCK, 5500, /* 5.5 Mb */
  245. 4900, 2, 11, 2, 2, 0 },
  246. { VALID, VALID, WLAN_RC_PHY_CCK, 11000, /* 11 Mb */
  247. 8100, 3, 22, 3, 3, 0 },
  248. { INVALID, INVALID, WLAN_RC_PHY_OFDM, 6000, /* 6 Mb */
  249. 5400, 4, 12, 4, 4, 0 },
  250. { INVALID, INVALID, WLAN_RC_PHY_OFDM, 9000, /* 9 Mb */
  251. 7800, 5, 18, 4, 5, 0 },
  252. { VALID, VALID, WLAN_RC_PHY_OFDM, 12000, /* 12 Mb */
  253. 10000, 6, 24, 6, 6, 0 },
  254. { VALID, VALID, WLAN_RC_PHY_OFDM, 18000, /* 18 Mb */
  255. 13900, 7, 36, 6, 7, 0 },
  256. { VALID, VALID, WLAN_RC_PHY_OFDM, 24000, /* 24 Mb */
  257. 17300, 8, 48, 8, 8, 0 },
  258. { VALID, VALID, WLAN_RC_PHY_OFDM, 36000, /* 36 Mb */
  259. 23000, 9, 72, 8, 9, 0 },
  260. { VALID, VALID, WLAN_RC_PHY_OFDM, 48000, /* 48 Mb */
  261. 27400, 10, 96, 8, 10, 0 },
  262. { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
  263. 29300, 11, 108, 8, 11, 0 },
  264. },
  265. 50, /* probe interval */
  266. 0, /* Phy rates allowed initially */
  267. };
  268. static const struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX] = {
  269. [ATH9K_MODE_11A] = &ar5416_11a_ratetable,
  270. [ATH9K_MODE_11G] = &ar5416_11g_ratetable,
  271. [ATH9K_MODE_11NA_HT20] = &ar5416_11na_ratetable,
  272. [ATH9K_MODE_11NG_HT20] = &ar5416_11ng_ratetable,
  273. [ATH9K_MODE_11NA_HT40PLUS] = &ar5416_11na_ratetable,
  274. [ATH9K_MODE_11NA_HT40MINUS] = &ar5416_11na_ratetable,
  275. [ATH9K_MODE_11NG_HT40PLUS] = &ar5416_11ng_ratetable,
  276. [ATH9K_MODE_11NG_HT40MINUS] = &ar5416_11ng_ratetable,
  277. };
  278. static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
  279. struct ieee80211_tx_rate *rate);
  280. static inline int8_t median(int8_t a, int8_t b, int8_t c)
  281. {
  282. if (a >= b) {
  283. if (b >= c)
  284. return b;
  285. else if (a > c)
  286. return c;
  287. else
  288. return a;
  289. } else {
  290. if (a >= c)
  291. return a;
  292. else if (b >= c)
  293. return c;
  294. else
  295. return b;
  296. }
  297. }
  298. static void ath_rc_sort_validrates(const struct ath_rate_table *rate_table,
  299. struct ath_rate_priv *ath_rc_priv)
  300. {
  301. u8 i, j, idx, idx_next;
  302. for (i = ath_rc_priv->max_valid_rate - 1; i > 0; i--) {
  303. for (j = 0; j <= i-1; j++) {
  304. idx = ath_rc_priv->valid_rate_index[j];
  305. idx_next = ath_rc_priv->valid_rate_index[j+1];
  306. if (rate_table->info[idx].ratekbps >
  307. rate_table->info[idx_next].ratekbps) {
  308. ath_rc_priv->valid_rate_index[j] = idx_next;
  309. ath_rc_priv->valid_rate_index[j+1] = idx;
  310. }
  311. }
  312. }
  313. }
  314. static void ath_rc_init_valid_txmask(struct ath_rate_priv *ath_rc_priv)
  315. {
  316. u8 i;
  317. for (i = 0; i < ath_rc_priv->rate_table_size; i++)
  318. ath_rc_priv->valid_rate_index[i] = 0;
  319. }
  320. static inline void ath_rc_set_valid_txmask(struct ath_rate_priv *ath_rc_priv,
  321. u8 index, int valid_tx_rate)
  322. {
  323. BUG_ON(index > ath_rc_priv->rate_table_size);
  324. ath_rc_priv->valid_rate_index[index] = valid_tx_rate ? 1 : 0;
  325. }
  326. static inline
  327. int ath_rc_get_nextvalid_txrate(const struct ath_rate_table *rate_table,
  328. struct ath_rate_priv *ath_rc_priv,
  329. u8 cur_valid_txrate,
  330. u8 *next_idx)
  331. {
  332. u8 i;
  333. for (i = 0; i < ath_rc_priv->max_valid_rate - 1; i++) {
  334. if (ath_rc_priv->valid_rate_index[i] == cur_valid_txrate) {
  335. *next_idx = ath_rc_priv->valid_rate_index[i+1];
  336. return 1;
  337. }
  338. }
  339. /* No more valid rates */
  340. *next_idx = 0;
  341. return 0;
  342. }
  343. /* Return true only for single stream */
  344. static int ath_rc_valid_phyrate(u32 phy, u32 capflag, int ignore_cw)
  345. {
  346. if (WLAN_RC_PHY_HT(phy) && !(capflag & WLAN_RC_HT_FLAG))
  347. return 0;
  348. if (WLAN_RC_PHY_DS(phy) && !(capflag & WLAN_RC_DS_FLAG))
  349. return 0;
  350. if (WLAN_RC_PHY_SGI(phy) && !(capflag & WLAN_RC_SGI_FLAG))
  351. return 0;
  352. if (!ignore_cw && WLAN_RC_PHY_HT(phy))
  353. if (WLAN_RC_PHY_40(phy) && !(capflag & WLAN_RC_40_FLAG))
  354. return 0;
  355. return 1;
  356. }
  357. static inline int
  358. ath_rc_get_lower_rix(const struct ath_rate_table *rate_table,
  359. struct ath_rate_priv *ath_rc_priv,
  360. u8 cur_valid_txrate, u8 *next_idx)
  361. {
  362. int8_t i;
  363. for (i = 1; i < ath_rc_priv->max_valid_rate ; i++) {
  364. if (ath_rc_priv->valid_rate_index[i] == cur_valid_txrate) {
  365. *next_idx = ath_rc_priv->valid_rate_index[i-1];
  366. return 1;
  367. }
  368. }
  369. return 0;
  370. }
  371. static u8 ath_rc_init_validrates(struct ath_rate_priv *ath_rc_priv,
  372. const struct ath_rate_table *rate_table,
  373. u32 capflag)
  374. {
  375. u8 i, hi = 0;
  376. u32 valid;
  377. for (i = 0; i < rate_table->rate_cnt; i++) {
  378. valid = (!(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ?
  379. rate_table->info[i].valid_single_stream :
  380. rate_table->info[i].valid);
  381. if (valid == 1) {
  382. u32 phy = rate_table->info[i].phy;
  383. u8 valid_rate_count = 0;
  384. if (!ath_rc_valid_phyrate(phy, capflag, 0))
  385. continue;
  386. valid_rate_count = ath_rc_priv->valid_phy_ratecnt[phy];
  387. ath_rc_priv->valid_phy_rateidx[phy][valid_rate_count] = i;
  388. ath_rc_priv->valid_phy_ratecnt[phy] += 1;
  389. ath_rc_set_valid_txmask(ath_rc_priv, i, 1);
  390. hi = A_MAX(hi, i);
  391. }
  392. }
  393. return hi;
  394. }
  395. static u8 ath_rc_setvalid_rates(struct ath_rate_priv *ath_rc_priv,
  396. const struct ath_rate_table *rate_table,
  397. struct ath_rateset *rateset,
  398. u32 capflag)
  399. {
  400. u8 i, j, hi = 0;
  401. /* Use intersection of working rates and valid rates */
  402. for (i = 0; i < rateset->rs_nrates; i++) {
  403. for (j = 0; j < rate_table->rate_cnt; j++) {
  404. u32 phy = rate_table->info[j].phy;
  405. u32 valid = (!(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ?
  406. rate_table->info[j].valid_single_stream :
  407. rate_table->info[j].valid);
  408. u8 rate = rateset->rs_rates[i];
  409. u8 dot11rate = rate_table->info[j].dot11rate;
  410. /* We allow a rate only if its valid and the
  411. * capflag matches one of the validity
  412. * (VALID/VALID_20/VALID_40) flags */
  413. if ((rate == dot11rate) &&
  414. ((valid & WLAN_RC_CAP_MODE(capflag)) ==
  415. WLAN_RC_CAP_MODE(capflag)) &&
  416. !WLAN_RC_PHY_HT(phy)) {
  417. u8 valid_rate_count = 0;
  418. if (!ath_rc_valid_phyrate(phy, capflag, 0))
  419. continue;
  420. valid_rate_count =
  421. ath_rc_priv->valid_phy_ratecnt[phy];
  422. ath_rc_priv->valid_phy_rateidx[phy]
  423. [valid_rate_count] = j;
  424. ath_rc_priv->valid_phy_ratecnt[phy] += 1;
  425. ath_rc_set_valid_txmask(ath_rc_priv, j, 1);
  426. hi = A_MAX(hi, j);
  427. }
  428. }
  429. }
  430. return hi;
  431. }
  432. static u8 ath_rc_setvalid_htrates(struct ath_rate_priv *ath_rc_priv,
  433. const struct ath_rate_table *rate_table,
  434. u8 *mcs_set, u32 capflag)
  435. {
  436. struct ath_rateset *rateset = (struct ath_rateset *)mcs_set;
  437. u8 i, j, hi = 0;
  438. /* Use intersection of working rates and valid rates */
  439. for (i = 0; i < rateset->rs_nrates; i++) {
  440. for (j = 0; j < rate_table->rate_cnt; j++) {
  441. u32 phy = rate_table->info[j].phy;
  442. u32 valid = (!(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG) ?
  443. rate_table->info[j].valid_single_stream :
  444. rate_table->info[j].valid);
  445. u8 rate = rateset->rs_rates[i];
  446. u8 dot11rate = rate_table->info[j].dot11rate;
  447. if ((rate != dot11rate) || !WLAN_RC_PHY_HT(phy) ||
  448. !WLAN_RC_PHY_HT_VALID(valid, capflag))
  449. continue;
  450. if (!ath_rc_valid_phyrate(phy, capflag, 0))
  451. continue;
  452. ath_rc_priv->valid_phy_rateidx[phy]
  453. [ath_rc_priv->valid_phy_ratecnt[phy]] = j;
  454. ath_rc_priv->valid_phy_ratecnt[phy] += 1;
  455. ath_rc_set_valid_txmask(ath_rc_priv, j, 1);
  456. hi = A_MAX(hi, j);
  457. }
  458. }
  459. return hi;
  460. }
  461. /* Finds the highest rate index we can use */
  462. static u8 ath_rc_get_highest_rix(struct ath_softc *sc,
  463. struct ath_rate_priv *ath_rc_priv,
  464. const struct ath_rate_table *rate_table,
  465. int *is_probing)
  466. {
  467. u32 best_thruput, this_thruput, now_msec;
  468. u8 rate, next_rate, best_rate, maxindex, minindex;
  469. int8_t index = 0;
  470. now_msec = jiffies_to_msecs(jiffies);
  471. *is_probing = 0;
  472. best_thruput = 0;
  473. maxindex = ath_rc_priv->max_valid_rate-1;
  474. minindex = 0;
  475. best_rate = minindex;
  476. /*
  477. * Try the higher rate first. It will reduce memory moving time
  478. * if we have very good channel characteristics.
  479. */
  480. for (index = maxindex; index >= minindex ; index--) {
  481. u8 per_thres;
  482. rate = ath_rc_priv->valid_rate_index[index];
  483. if (rate > ath_rc_priv->rate_max_phy)
  484. continue;
  485. /*
  486. * For TCP the average collision rate is around 11%,
  487. * so we ignore PERs less than this. This is to
  488. * prevent the rate we are currently using (whose
  489. * PER might be in the 10-15 range because of TCP
  490. * collisions) looking worse than the next lower
  491. * rate whose PER has decayed close to 0. If we
  492. * used to next lower rate, its PER would grow to
  493. * 10-15 and we would be worse off then staying
  494. * at the current rate.
  495. */
  496. per_thres = ath_rc_priv->per[rate];
  497. if (per_thres < 12)
  498. per_thres = 12;
  499. this_thruput = rate_table->info[rate].user_ratekbps *
  500. (100 - per_thres);
  501. if (best_thruput <= this_thruput) {
  502. best_thruput = this_thruput;
  503. best_rate = rate;
  504. }
  505. }
  506. rate = best_rate;
  507. /*
  508. * Must check the actual rate (ratekbps) to account for
  509. * non-monoticity of 11g's rate table
  510. */
  511. if (rate >= ath_rc_priv->rate_max_phy) {
  512. rate = ath_rc_priv->rate_max_phy;
  513. /* Probe the next allowed phy state */
  514. if (ath_rc_get_nextvalid_txrate(rate_table,
  515. ath_rc_priv, rate, &next_rate) &&
  516. (now_msec - ath_rc_priv->probe_time >
  517. rate_table->probe_interval) &&
  518. (ath_rc_priv->hw_maxretry_pktcnt >= 1)) {
  519. rate = next_rate;
  520. ath_rc_priv->probe_rate = rate;
  521. ath_rc_priv->probe_time = now_msec;
  522. ath_rc_priv->hw_maxretry_pktcnt = 0;
  523. *is_probing = 1;
  524. }
  525. }
  526. if (rate > (ath_rc_priv->rate_table_size - 1))
  527. rate = ath_rc_priv->rate_table_size - 1;
  528. if (rate_table->info[rate].valid &&
  529. (ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG))
  530. return rate;
  531. if (rate_table->info[rate].valid_single_stream &&
  532. !(ath_rc_priv->ht_cap & WLAN_RC_DS_FLAG))
  533. return rate;
  534. /* This should not happen */
  535. WARN_ON(1);
  536. rate = ath_rc_priv->valid_rate_index[0];
  537. return rate;
  538. }
  539. static void ath_rc_rate_set_series(const struct ath_rate_table *rate_table,
  540. struct ieee80211_tx_rate *rate,
  541. struct ieee80211_tx_rate_control *txrc,
  542. u8 tries, u8 rix, int rtsctsenable)
  543. {
  544. rate->count = tries;
  545. rate->idx = rate_table->info[rix].ratecode;
  546. if (txrc->short_preamble)
  547. rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
  548. if (txrc->rts || rtsctsenable)
  549. rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS;
  550. if (WLAN_RC_PHY_HT(rate_table->info[rix].phy)) {
  551. rate->flags |= IEEE80211_TX_RC_MCS;
  552. if (WLAN_RC_PHY_40(rate_table->info[rix].phy))
  553. rate->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH;
  554. if (WLAN_RC_PHY_SGI(rate_table->info[rix].phy))
  555. rate->flags |= IEEE80211_TX_RC_SHORT_GI;
  556. }
  557. }
  558. static void ath_rc_rate_set_rtscts(struct ath_softc *sc,
  559. const struct ath_rate_table *rate_table,
  560. struct ieee80211_tx_info *tx_info)
  561. {
  562. struct ieee80211_tx_rate *rates = tx_info->control.rates;
  563. int i = 0, rix = 0, cix, enable_g_protection = 0;
  564. /* get the cix for the lowest valid rix */
  565. for (i = 3; i >= 0; i--) {
  566. if (rates[i].count && (rates[i].idx >= 0)) {
  567. rix = ath_rc_get_rateindex(rate_table, &rates[i]);
  568. break;
  569. }
  570. }
  571. cix = rate_table->info[rix].ctrl_rate;
  572. /* All protection frames are transmited at 2Mb/s for 802.11g,
  573. * otherwise we transmit them at 1Mb/s */
  574. if (sc->hw->conf.channel->band == IEEE80211_BAND_2GHZ &&
  575. !conf_is_ht(&sc->hw->conf))
  576. enable_g_protection = 1;
  577. /*
  578. * If 802.11g protection is enabled, determine whether to use RTS/CTS or
  579. * just CTS. Note that this is only done for OFDM/HT unicast frames.
  580. */
  581. if ((sc->sc_flags & SC_OP_PROTECT_ENABLE) &&
  582. (rate_table->info[rix].phy == WLAN_RC_PHY_OFDM ||
  583. WLAN_RC_PHY_HT(rate_table->info[rix].phy))) {
  584. rates[0].flags |= IEEE80211_TX_RC_USE_CTS_PROTECT;
  585. cix = rate_table->info[enable_g_protection].ctrl_rate;
  586. }
  587. tx_info->control.rts_cts_rate_idx = cix;
  588. }
  589. static void ath_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
  590. struct ieee80211_tx_rate_control *txrc)
  591. {
  592. struct ath_softc *sc = priv;
  593. struct ath_rate_priv *ath_rc_priv = priv_sta;
  594. const struct ath_rate_table *rate_table;
  595. struct sk_buff *skb = txrc->skb;
  596. struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
  597. struct ieee80211_tx_rate *rates = tx_info->control.rates;
  598. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
  599. __le16 fc = hdr->frame_control;
  600. u8 try_per_rate, i = 0, rix;
  601. int is_probe = 0;
  602. if (rate_control_send_low(sta, priv_sta, txrc))
  603. return;
  604. /*
  605. * For Multi Rate Retry we use a different number of
  606. * retry attempt counts. This ends up looking like this:
  607. *
  608. * MRR[0] = 4
  609. * MRR[1] = 4
  610. * MRR[2] = 4
  611. * MRR[3] = 8
  612. *
  613. */
  614. try_per_rate = 4;
  615. rate_table = sc->cur_rate_table;
  616. rix = ath_rc_get_highest_rix(sc, ath_rc_priv, rate_table, &is_probe);
  617. /*
  618. * If we're in HT mode and both us and our peer supports LDPC.
  619. * We don't need to check our own device's capabilities as our own
  620. * ht capabilities would have already been intersected with our peer's.
  621. */
  622. if (conf_is_ht(&sc->hw->conf) &&
  623. (sta->ht_cap.cap & IEEE80211_HT_CAP_LDPC_CODING))
  624. tx_info->flags |= IEEE80211_TX_CTL_LDPC;
  625. if (is_probe) {
  626. /* set one try for probe rates. For the
  627. * probes don't enable rts */
  628. ath_rc_rate_set_series(rate_table, &rates[i++], txrc,
  629. 1, rix, 0);
  630. /* Get the next tried/allowed rate. No RTS for the next series
  631. * after the probe rate
  632. */
  633. ath_rc_get_lower_rix(rate_table, ath_rc_priv, rix, &rix);
  634. ath_rc_rate_set_series(rate_table, &rates[i++], txrc,
  635. try_per_rate, rix, 0);
  636. tx_info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
  637. } else {
  638. /* Set the choosen rate. No RTS for first series entry. */
  639. ath_rc_rate_set_series(rate_table, &rates[i++], txrc,
  640. try_per_rate, rix, 0);
  641. }
  642. /* Fill in the other rates for multirate retry */
  643. for ( ; i < 4; i++) {
  644. /* Use twice the number of tries for the last MRR segment. */
  645. if (i + 1 == 4)
  646. try_per_rate = 8;
  647. ath_rc_get_lower_rix(rate_table, ath_rc_priv, rix, &rix);
  648. /* All other rates in the series have RTS enabled */
  649. ath_rc_rate_set_series(rate_table, &rates[i], txrc,
  650. try_per_rate, rix, 1);
  651. }
  652. /*
  653. * NB:Change rate series to enable aggregation when operating
  654. * at lower MCS rates. When first rate in series is MCS2
  655. * in HT40 @ 2.4GHz, series should look like:
  656. *
  657. * {MCS2, MCS1, MCS0, MCS0}.
  658. *
  659. * When first rate in series is MCS3 in HT20 @ 2.4GHz, series should
  660. * look like:
  661. *
  662. * {MCS3, MCS2, MCS1, MCS1}
  663. *
  664. * So, set fourth rate in series to be same as third one for
  665. * above conditions.
  666. */
  667. if ((sc->hw->conf.channel->band == IEEE80211_BAND_2GHZ) &&
  668. (conf_is_ht(&sc->hw->conf))) {
  669. u8 dot11rate = rate_table->info[rix].dot11rate;
  670. u8 phy = rate_table->info[rix].phy;
  671. if (i == 4 &&
  672. ((dot11rate == 2 && phy == WLAN_RC_PHY_HT_40_SS) ||
  673. (dot11rate == 3 && phy == WLAN_RC_PHY_HT_20_SS))) {
  674. rates[3].idx = rates[2].idx;
  675. rates[3].flags = rates[2].flags;
  676. }
  677. }
  678. /*
  679. * Force hardware to use computed duration for next
  680. * fragment by disabling multi-rate retry, which
  681. * updates duration based on the multi-rate duration table.
  682. *
  683. * FIXME: Fix duration
  684. */
  685. if (ieee80211_has_morefrags(fc) ||
  686. (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG)) {
  687. rates[1].count = rates[2].count = rates[3].count = 0;
  688. rates[1].idx = rates[2].idx = rates[3].idx = 0;
  689. rates[0].count = ATH_TXMAXTRY;
  690. }
  691. /* Setup RTS/CTS */
  692. ath_rc_rate_set_rtscts(sc, rate_table, tx_info);
  693. }
  694. static bool ath_rc_update_per(struct ath_softc *sc,
  695. const struct ath_rate_table *rate_table,
  696. struct ath_rate_priv *ath_rc_priv,
  697. struct ieee80211_tx_info *tx_info,
  698. int tx_rate, int xretries, int retries,
  699. u32 now_msec)
  700. {
  701. bool state_change = false;
  702. int count, n_bad_frames;
  703. u8 last_per;
  704. static u32 nretry_to_per_lookup[10] = {
  705. 100 * 0 / 1,
  706. 100 * 1 / 4,
  707. 100 * 1 / 2,
  708. 100 * 3 / 4,
  709. 100 * 4 / 5,
  710. 100 * 5 / 6,
  711. 100 * 6 / 7,
  712. 100 * 7 / 8,
  713. 100 * 8 / 9,
  714. 100 * 9 / 10
  715. };
  716. last_per = ath_rc_priv->per[tx_rate];
  717. n_bad_frames = tx_info->status.ampdu_len - tx_info->status.ampdu_ack_len;
  718. if (xretries) {
  719. if (xretries == 1) {
  720. ath_rc_priv->per[tx_rate] += 30;
  721. if (ath_rc_priv->per[tx_rate] > 100)
  722. ath_rc_priv->per[tx_rate] = 100;
  723. } else {
  724. /* xretries == 2 */
  725. count = ARRAY_SIZE(nretry_to_per_lookup);
  726. if (retries >= count)
  727. retries = count - 1;
  728. /* new_PER = 7/8*old_PER + 1/8*(currentPER) */
  729. ath_rc_priv->per[tx_rate] =
  730. (u8)(last_per - (last_per >> 3) + (100 >> 3));
  731. }
  732. /* xretries == 1 or 2 */
  733. if (ath_rc_priv->probe_rate == tx_rate)
  734. ath_rc_priv->probe_rate = 0;
  735. } else { /* xretries == 0 */
  736. count = ARRAY_SIZE(nretry_to_per_lookup);
  737. if (retries >= count)
  738. retries = count - 1;
  739. if (n_bad_frames) {
  740. /* new_PER = 7/8*old_PER + 1/8*(currentPER)
  741. * Assuming that n_frames is not 0. The current PER
  742. * from the retries is 100 * retries / (retries+1),
  743. * since the first retries attempts failed, and the
  744. * next one worked. For the one that worked,
  745. * n_bad_frames subframes out of n_frames wored,
  746. * so the PER for that part is
  747. * 100 * n_bad_frames / n_frames, and it contributes
  748. * 100 * n_bad_frames / (n_frames * (retries+1)) to
  749. * the above PER. The expression below is a
  750. * simplified version of the sum of these two terms.
  751. */
  752. if (tx_info->status.ampdu_len > 0) {
  753. int n_frames, n_bad_tries;
  754. u8 cur_per, new_per;
  755. n_bad_tries = retries * tx_info->status.ampdu_len +
  756. n_bad_frames;
  757. n_frames = tx_info->status.ampdu_len * (retries + 1);
  758. cur_per = (100 * n_bad_tries / n_frames) >> 3;
  759. new_per = (u8)(last_per - (last_per >> 3) + cur_per);
  760. ath_rc_priv->per[tx_rate] = new_per;
  761. }
  762. } else {
  763. ath_rc_priv->per[tx_rate] =
  764. (u8)(last_per - (last_per >> 3) +
  765. (nretry_to_per_lookup[retries] >> 3));
  766. }
  767. /*
  768. * If we got at most one retry then increase the max rate if
  769. * this was a probe. Otherwise, ignore the probe.
  770. */
  771. if (ath_rc_priv->probe_rate && ath_rc_priv->probe_rate == tx_rate) {
  772. if (retries > 0 || 2 * n_bad_frames > tx_info->status.ampdu_len) {
  773. /*
  774. * Since we probed with just a single attempt,
  775. * any retries means the probe failed. Also,
  776. * if the attempt worked, but more than half
  777. * the subframes were bad then also consider
  778. * the probe a failure.
  779. */
  780. ath_rc_priv->probe_rate = 0;
  781. } else {
  782. u8 probe_rate = 0;
  783. ath_rc_priv->rate_max_phy =
  784. ath_rc_priv->probe_rate;
  785. probe_rate = ath_rc_priv->probe_rate;
  786. if (ath_rc_priv->per[probe_rate] > 30)
  787. ath_rc_priv->per[probe_rate] = 20;
  788. ath_rc_priv->probe_rate = 0;
  789. /*
  790. * Since this probe succeeded, we allow the next
  791. * probe twice as soon. This allows the maxRate
  792. * to move up faster if the probes are
  793. * successful.
  794. */
  795. ath_rc_priv->probe_time =
  796. now_msec - rate_table->probe_interval / 2;
  797. }
  798. }
  799. if (retries > 0) {
  800. /*
  801. * Don't update anything. We don't know if
  802. * this was because of collisions or poor signal.
  803. */
  804. ath_rc_priv->hw_maxretry_pktcnt = 0;
  805. } else {
  806. /*
  807. * It worked with no retries. First ignore bogus (small)
  808. * rssi_ack values.
  809. */
  810. if (tx_rate == ath_rc_priv->rate_max_phy &&
  811. ath_rc_priv->hw_maxretry_pktcnt < 255) {
  812. ath_rc_priv->hw_maxretry_pktcnt++;
  813. }
  814. }
  815. }
  816. return state_change;
  817. }
  818. /* Update PER, RSSI and whatever else that the code thinks it is doing.
  819. If you can make sense of all this, you really need to go out more. */
  820. static void ath_rc_update_ht(struct ath_softc *sc,
  821. struct ath_rate_priv *ath_rc_priv,
  822. struct ieee80211_tx_info *tx_info,
  823. int tx_rate, int xretries, int retries)
  824. {
  825. u32 now_msec = jiffies_to_msecs(jiffies);
  826. int rate;
  827. u8 last_per;
  828. bool state_change = false;
  829. const struct ath_rate_table *rate_table = sc->cur_rate_table;
  830. int size = ath_rc_priv->rate_table_size;
  831. if ((tx_rate < 0) || (tx_rate > rate_table->rate_cnt))
  832. return;
  833. last_per = ath_rc_priv->per[tx_rate];
  834. /* Update PER first */
  835. state_change = ath_rc_update_per(sc, rate_table, ath_rc_priv,
  836. tx_info, tx_rate, xretries,
  837. retries, now_msec);
  838. /*
  839. * If this rate looks bad (high PER) then stop using it for
  840. * a while (except if we are probing).
  841. */
  842. if (ath_rc_priv->per[tx_rate] >= 55 && tx_rate > 0 &&
  843. rate_table->info[tx_rate].ratekbps <=
  844. rate_table->info[ath_rc_priv->rate_max_phy].ratekbps) {
  845. ath_rc_get_lower_rix(rate_table, ath_rc_priv,
  846. (u8)tx_rate, &ath_rc_priv->rate_max_phy);
  847. /* Don't probe for a little while. */
  848. ath_rc_priv->probe_time = now_msec;
  849. }
  850. /* Make sure the rates below this have lower PER */
  851. /* Monotonicity is kept only for rates below the current rate. */
  852. if (ath_rc_priv->per[tx_rate] < last_per) {
  853. for (rate = tx_rate - 1; rate >= 0; rate--) {
  854. if (ath_rc_priv->per[rate] >
  855. ath_rc_priv->per[rate+1]) {
  856. ath_rc_priv->per[rate] =
  857. ath_rc_priv->per[rate+1];
  858. }
  859. }
  860. }
  861. /* Maintain monotonicity for rates above the current rate */
  862. for (rate = tx_rate; rate < size - 1; rate++) {
  863. if (ath_rc_priv->per[rate+1] <
  864. ath_rc_priv->per[rate])
  865. ath_rc_priv->per[rate+1] =
  866. ath_rc_priv->per[rate];
  867. }
  868. /* Every so often, we reduce the thresholds
  869. * and PER (different for CCK and OFDM). */
  870. if (now_msec - ath_rc_priv->per_down_time >=
  871. rate_table->probe_interval) {
  872. for (rate = 0; rate < size; rate++) {
  873. ath_rc_priv->per[rate] =
  874. 7 * ath_rc_priv->per[rate] / 8;
  875. }
  876. ath_rc_priv->per_down_time = now_msec;
  877. }
  878. ath_debug_stat_retries(sc, tx_rate, xretries, retries,
  879. ath_rc_priv->per[tx_rate]);
  880. }
  881. static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
  882. struct ieee80211_tx_rate *rate)
  883. {
  884. int rix;
  885. if (!(rate->flags & IEEE80211_TX_RC_MCS))
  886. return rate->idx;
  887. rix = rate->idx + rate_table->mcs_start;
  888. if ((rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
  889. (rate->flags & IEEE80211_TX_RC_SHORT_GI))
  890. rix = rate_table->info[rix].ht_index;
  891. else if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
  892. rix = rate_table->info[rix].sgi_index;
  893. else if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
  894. rix = rate_table->info[rix].cw40index;
  895. else
  896. rix = rate_table->info[rix].base_index;
  897. return rix;
  898. }
  899. static void ath_rc_tx_status(struct ath_softc *sc,
  900. struct ath_rate_priv *ath_rc_priv,
  901. struct ieee80211_tx_info *tx_info,
  902. int final_ts_idx, int xretries, int long_retry)
  903. {
  904. const struct ath_rate_table *rate_table;
  905. struct ieee80211_tx_rate *rates = tx_info->status.rates;
  906. u8 flags;
  907. u32 i = 0, rix;
  908. rate_table = sc->cur_rate_table;
  909. /*
  910. * If the first rate is not the final index, there
  911. * are intermediate rate failures to be processed.
  912. */
  913. if (final_ts_idx != 0) {
  914. /* Process intermediate rates that failed.*/
  915. for (i = 0; i < final_ts_idx ; i++) {
  916. if (rates[i].count != 0 && (rates[i].idx >= 0)) {
  917. flags = rates[i].flags;
  918. /* If HT40 and we have switched mode from
  919. * 40 to 20 => don't update */
  920. if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
  921. !(ath_rc_priv->ht_cap & WLAN_RC_40_FLAG))
  922. return;
  923. rix = ath_rc_get_rateindex(rate_table, &rates[i]);
  924. ath_rc_update_ht(sc, ath_rc_priv, tx_info,
  925. rix, xretries ? 1 : 2,
  926. rates[i].count);
  927. }
  928. }
  929. } else {
  930. /*
  931. * Handle the special case of MIMO PS burst, where the second
  932. * aggregate is sent out with only one rate and one try.
  933. * Treating it as an excessive retry penalizes the rate
  934. * inordinately.
  935. */
  936. if (rates[0].count == 1 && xretries == 1)
  937. xretries = 2;
  938. }
  939. flags = rates[i].flags;
  940. /* If HT40 and we have switched mode from 40 to 20 => don't update */
  941. if ((flags & IEEE80211_TX_RC_40_MHZ_WIDTH) &&
  942. !(ath_rc_priv->ht_cap & WLAN_RC_40_FLAG))
  943. return;
  944. rix = ath_rc_get_rateindex(rate_table, &rates[i]);
  945. ath_rc_update_ht(sc, ath_rc_priv, tx_info, rix, xretries, long_retry);
  946. }
  947. static const
  948. struct ath_rate_table *ath_choose_rate_table(struct ath_softc *sc,
  949. enum ieee80211_band band,
  950. bool is_ht,
  951. bool is_cw_40)
  952. {
  953. int mode = 0;
  954. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  955. switch(band) {
  956. case IEEE80211_BAND_2GHZ:
  957. mode = ATH9K_MODE_11G;
  958. if (is_ht)
  959. mode = ATH9K_MODE_11NG_HT20;
  960. if (is_cw_40)
  961. mode = ATH9K_MODE_11NG_HT40PLUS;
  962. break;
  963. case IEEE80211_BAND_5GHZ:
  964. mode = ATH9K_MODE_11A;
  965. if (is_ht)
  966. mode = ATH9K_MODE_11NA_HT20;
  967. if (is_cw_40)
  968. mode = ATH9K_MODE_11NA_HT40PLUS;
  969. break;
  970. default:
  971. ath_print(common, ATH_DBG_CONFIG, "Invalid band\n");
  972. return NULL;
  973. }
  974. BUG_ON(mode >= ATH9K_MODE_MAX);
  975. ath_print(common, ATH_DBG_CONFIG,
  976. "Choosing rate table for mode: %d\n", mode);
  977. sc->cur_rate_mode = mode;
  978. return hw_rate_table[mode];
  979. }
  980. static void ath_rc_init(struct ath_softc *sc,
  981. struct ath_rate_priv *ath_rc_priv,
  982. struct ieee80211_supported_band *sband,
  983. struct ieee80211_sta *sta,
  984. const struct ath_rate_table *rate_table)
  985. {
  986. struct ath_rateset *rateset = &ath_rc_priv->neg_rates;
  987. struct ath_common *common = ath9k_hw_common(sc->sc_ah);
  988. u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates;
  989. u8 i, j, k, hi = 0, hthi = 0;
  990. /* Initial rate table size. Will change depending
  991. * on the working rate set */
  992. ath_rc_priv->rate_table_size = RATE_TABLE_SIZE;
  993. /* Initialize thresholds according to the global rate table */
  994. for (i = 0 ; i < ath_rc_priv->rate_table_size; i++) {
  995. ath_rc_priv->per[i] = 0;
  996. }
  997. /* Determine the valid rates */
  998. ath_rc_init_valid_txmask(ath_rc_priv);
  999. for (i = 0; i < WLAN_RC_PHY_MAX; i++) {
  1000. for (j = 0; j < MAX_TX_RATE_PHY; j++)
  1001. ath_rc_priv->valid_phy_rateidx[i][j] = 0;
  1002. ath_rc_priv->valid_phy_ratecnt[i] = 0;
  1003. }
  1004. if (!rateset->rs_nrates) {
  1005. /* No working rate, just initialize valid rates */
  1006. hi = ath_rc_init_validrates(ath_rc_priv, rate_table,
  1007. ath_rc_priv->ht_cap);
  1008. } else {
  1009. /* Use intersection of working rates and valid rates */
  1010. hi = ath_rc_setvalid_rates(ath_rc_priv, rate_table,
  1011. rateset, ath_rc_priv->ht_cap);
  1012. if (ath_rc_priv->ht_cap & WLAN_RC_HT_FLAG) {
  1013. hthi = ath_rc_setvalid_htrates(ath_rc_priv,
  1014. rate_table,
  1015. ht_mcs,
  1016. ath_rc_priv->ht_cap);
  1017. }
  1018. hi = A_MAX(hi, hthi);
  1019. }
  1020. ath_rc_priv->rate_table_size = hi + 1;
  1021. ath_rc_priv->rate_max_phy = 0;
  1022. BUG_ON(ath_rc_priv->rate_table_size > RATE_TABLE_SIZE);
  1023. for (i = 0, k = 0; i < WLAN_RC_PHY_MAX; i++) {
  1024. for (j = 0; j < ath_rc_priv->valid_phy_ratecnt[i]; j++) {
  1025. ath_rc_priv->valid_rate_index[k++] =
  1026. ath_rc_priv->valid_phy_rateidx[i][j];
  1027. }
  1028. if (!ath_rc_valid_phyrate(i, rate_table->initial_ratemax, 1)
  1029. || !ath_rc_priv->valid_phy_ratecnt[i])
  1030. continue;
  1031. ath_rc_priv->rate_max_phy = ath_rc_priv->valid_phy_rateidx[i][j-1];
  1032. }
  1033. BUG_ON(ath_rc_priv->rate_table_size > RATE_TABLE_SIZE);
  1034. BUG_ON(k > RATE_TABLE_SIZE);
  1035. ath_rc_priv->max_valid_rate = k;
  1036. ath_rc_sort_validrates(rate_table, ath_rc_priv);
  1037. ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4];
  1038. sc->cur_rate_table = rate_table;
  1039. ath_print(common, ATH_DBG_CONFIG,
  1040. "RC Initialized with capabilities: 0x%x\n",
  1041. ath_rc_priv->ht_cap);
  1042. }
  1043. static u8 ath_rc_build_ht_caps(struct ath_softc *sc, struct ieee80211_sta *sta,
  1044. bool is_cw40, bool is_sgi40)
  1045. {
  1046. u8 caps = 0;
  1047. if (sta->ht_cap.ht_supported) {
  1048. caps = WLAN_RC_HT_FLAG;
  1049. if (sc->sc_ah->caps.tx_chainmask != 1 &&
  1050. ath9k_hw_getcapability(sc->sc_ah, ATH9K_CAP_DS, 0, NULL)) {
  1051. if (sta->ht_cap.mcs.rx_mask[1])
  1052. caps |= WLAN_RC_DS_FLAG;
  1053. }
  1054. if (is_cw40)
  1055. caps |= WLAN_RC_40_FLAG;
  1056. if (is_sgi40)
  1057. caps |= WLAN_RC_SGI_FLAG;
  1058. }
  1059. return caps;
  1060. }
  1061. /***********************************/
  1062. /* mac80211 Rate Control callbacks */
  1063. /***********************************/
  1064. static void ath_tx_status(void *priv, struct ieee80211_supported_band *sband,
  1065. struct ieee80211_sta *sta, void *priv_sta,
  1066. struct sk_buff *skb)
  1067. {
  1068. struct ath_softc *sc = priv;
  1069. struct ath_rate_priv *ath_rc_priv = priv_sta;
  1070. struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
  1071. struct ieee80211_hdr *hdr;
  1072. int final_ts_idx = 0, tx_status = 0, is_underrun = 0;
  1073. int long_retry = 0;
  1074. __le16 fc;
  1075. int i;
  1076. hdr = (struct ieee80211_hdr *)skb->data;
  1077. fc = hdr->frame_control;
  1078. for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
  1079. struct ieee80211_tx_rate *rate = &tx_info->status.rates[i];
  1080. if (!rate->count)
  1081. break;
  1082. final_ts_idx = i;
  1083. long_retry = rate->count - 1;
  1084. }
  1085. if (!priv_sta || !ieee80211_is_data(fc))
  1086. return;
  1087. /* This packet was aggregated but doesn't carry status info */
  1088. if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) &&
  1089. !(tx_info->flags & IEEE80211_TX_STAT_AMPDU))
  1090. return;
  1091. if (tx_info->flags & IEEE80211_TX_STAT_TX_FILTERED)
  1092. return;
  1093. /*
  1094. * If an underrun error is seen assume it as an excessive retry only
  1095. * if max frame trigger level has been reached (2 KB for singel stream,
  1096. * and 4 KB for dual stream). Adjust the long retry as if the frame was
  1097. * tried hw->max_rate_tries times to affect how ratectrl updates PER for
  1098. * the failed rate. In case of congestion on the bus penalizing these
  1099. * type of underruns should help hardware actually transmit new frames
  1100. * successfully by eventually preferring slower rates. This itself
  1101. * should also alleviate congestion on the bus.
  1102. */
  1103. if ((tx_info->pad[0] & ATH_TX_INFO_UNDERRUN) &&
  1104. (sc->sc_ah->tx_trig_level >= ath_rc_priv->tx_triglevel_max)) {
  1105. tx_status = 1;
  1106. is_underrun = 1;
  1107. }
  1108. if (tx_info->pad[0] & ATH_TX_INFO_XRETRY)
  1109. tx_status = 1;
  1110. ath_rc_tx_status(sc, ath_rc_priv, tx_info, final_ts_idx, tx_status,
  1111. (is_underrun) ? sc->hw->max_rate_tries : long_retry);
  1112. /* Check if aggregation has to be enabled for this tid */
  1113. if (conf_is_ht(&sc->hw->conf) &&
  1114. !(skb->protocol == cpu_to_be16(ETH_P_PAE))) {
  1115. if (ieee80211_is_data_qos(fc)) {
  1116. u8 *qc, tid;
  1117. struct ath_node *an;
  1118. qc = ieee80211_get_qos_ctl(hdr);
  1119. tid = qc[0] & 0xf;
  1120. an = (struct ath_node *)sta->drv_priv;
  1121. if(ath_tx_aggr_check(sc, an, tid))
  1122. ieee80211_start_tx_ba_session(sta, tid);
  1123. }
  1124. }
  1125. ath_debug_stat_rc(sc, ath_rc_get_rateindex(sc->cur_rate_table,
  1126. &tx_info->status.rates[final_ts_idx]));
  1127. }
  1128. static void ath_rate_init(void *priv, struct ieee80211_supported_band *sband,
  1129. struct ieee80211_sta *sta, void *priv_sta)
  1130. {
  1131. struct ath_softc *sc = priv;
  1132. struct ath_rate_priv *ath_rc_priv = priv_sta;
  1133. const struct ath_rate_table *rate_table;
  1134. bool is_cw40, is_sgi40;
  1135. int i, j = 0;
  1136. for (i = 0; i < sband->n_bitrates; i++) {
  1137. if (sta->supp_rates[sband->band] & BIT(i)) {
  1138. ath_rc_priv->neg_rates.rs_rates[j]
  1139. = (sband->bitrates[i].bitrate * 2) / 10;
  1140. j++;
  1141. }
  1142. }
  1143. ath_rc_priv->neg_rates.rs_nrates = j;
  1144. if (sta->ht_cap.ht_supported) {
  1145. for (i = 0, j = 0; i < 77; i++) {
  1146. if (sta->ht_cap.mcs.rx_mask[i/8] & (1<<(i%8)))
  1147. ath_rc_priv->neg_ht_rates.rs_rates[j++] = i;
  1148. if (j == ATH_RATE_MAX)
  1149. break;
  1150. }
  1151. ath_rc_priv->neg_ht_rates.rs_nrates = j;
  1152. }
  1153. is_cw40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40;
  1154. is_sgi40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40;
  1155. /* Choose rate table first */
  1156. if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) ||
  1157. (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT) ||
  1158. (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC)) {
  1159. rate_table = ath_choose_rate_table(sc, sband->band,
  1160. sta->ht_cap.ht_supported, is_cw40);
  1161. } else {
  1162. rate_table = hw_rate_table[sc->cur_rate_mode];
  1163. }
  1164. ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta, is_cw40, is_sgi40);
  1165. ath_rc_init(sc, priv_sta, sband, sta, rate_table);
  1166. }
  1167. static void ath_rate_update(void *priv, struct ieee80211_supported_band *sband,
  1168. struct ieee80211_sta *sta, void *priv_sta,
  1169. u32 changed, enum nl80211_channel_type oper_chan_type)
  1170. {
  1171. struct ath_softc *sc = priv;
  1172. struct ath_rate_priv *ath_rc_priv = priv_sta;
  1173. const struct ath_rate_table *rate_table = NULL;
  1174. bool oper_cw40 = false, oper_sgi40;
  1175. bool local_cw40 = (ath_rc_priv->ht_cap & WLAN_RC_40_FLAG) ?
  1176. true : false;
  1177. bool local_sgi40 = (ath_rc_priv->ht_cap & WLAN_RC_SGI_FLAG) ?
  1178. true : false;
  1179. /* FIXME: Handle AP mode later when we support CWM */
  1180. if (changed & IEEE80211_RC_HT_CHANGED) {
  1181. if (sc->sc_ah->opmode != NL80211_IFTYPE_STATION)
  1182. return;
  1183. if (oper_chan_type == NL80211_CHAN_HT40MINUS ||
  1184. oper_chan_type == NL80211_CHAN_HT40PLUS)
  1185. oper_cw40 = true;
  1186. oper_sgi40 = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
  1187. true : false;
  1188. if ((local_cw40 != oper_cw40) || (local_sgi40 != oper_sgi40)) {
  1189. rate_table = ath_choose_rate_table(sc, sband->band,
  1190. sta->ht_cap.ht_supported,
  1191. oper_cw40);
  1192. ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta,
  1193. oper_cw40, oper_sgi40);
  1194. ath_rc_init(sc, priv_sta, sband, sta, rate_table);
  1195. ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
  1196. "Operating HT Bandwidth changed to: %d\n",
  1197. sc->hw->conf.channel_type);
  1198. sc->cur_rate_table = hw_rate_table[sc->cur_rate_mode];
  1199. }
  1200. }
  1201. }
  1202. static void *ath_rate_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
  1203. {
  1204. struct ath_wiphy *aphy = hw->priv;
  1205. return aphy->sc;
  1206. }
  1207. static void ath_rate_free(void *priv)
  1208. {
  1209. return;
  1210. }
  1211. static void *ath_rate_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
  1212. {
  1213. struct ath_softc *sc = priv;
  1214. struct ath_rate_priv *rate_priv;
  1215. rate_priv = kzalloc(sizeof(struct ath_rate_priv), gfp);
  1216. if (!rate_priv) {
  1217. ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_FATAL,
  1218. "Unable to allocate private rc structure\n");
  1219. return NULL;
  1220. }
  1221. rate_priv->tx_triglevel_max = sc->sc_ah->caps.tx_triglevel_max;
  1222. return rate_priv;
  1223. }
  1224. static void ath_rate_free_sta(void *priv, struct ieee80211_sta *sta,
  1225. void *priv_sta)
  1226. {
  1227. struct ath_rate_priv *rate_priv = priv_sta;
  1228. kfree(rate_priv);
  1229. }
  1230. static struct rate_control_ops ath_rate_ops = {
  1231. .module = NULL,
  1232. .name = "ath9k_rate_control",
  1233. .tx_status = ath_tx_status,
  1234. .get_rate = ath_get_rate,
  1235. .rate_init = ath_rate_init,
  1236. .rate_update = ath_rate_update,
  1237. .alloc = ath_rate_alloc,
  1238. .free = ath_rate_free,
  1239. .alloc_sta = ath_rate_alloc_sta,
  1240. .free_sta = ath_rate_free_sta,
  1241. };
  1242. int ath_rate_control_register(void)
  1243. {
  1244. return ieee80211_rate_control_register(&ath_rate_ops);
  1245. }
  1246. void ath_rate_control_unregister(void)
  1247. {
  1248. ieee80211_rate_control_unregister(&ath_rate_ops);
  1249. }