common.h 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * Intel Linux Wireless <ilw@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. #ifndef __il_core_h__
  27. #define __il_core_h__
  28. #include <linux/interrupt.h>
  29. #include <linux/pci.h> /* for struct pci_device_id */
  30. #include <linux/kernel.h>
  31. #include <linux/leds.h>
  32. #include <linux/wait.h>
  33. #include <net/mac80211.h>
  34. #include <net/ieee80211_radiotap.h>
  35. #include "commands.h"
  36. #include "csr.h"
  37. #include "prph.h"
  38. #include "iwl-debug.h"
  39. struct il_host_cmd;
  40. struct il_cmd;
  41. struct il_tx_queue;
  42. #define RX_QUEUE_SIZE 256
  43. #define RX_QUEUE_MASK 255
  44. #define RX_QUEUE_SIZE_LOG 8
  45. /*
  46. * RX related structures and functions
  47. */
  48. #define RX_FREE_BUFFERS 64
  49. #define RX_LOW_WATERMARK 8
  50. #define U32_PAD(n) ((4-(n))&0x3)
  51. /* CT-KILL constants */
  52. #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */
  53. /* Default noise level to report when noise measurement is not available.
  54. * This may be because we're:
  55. * 1) Not associated (4965, no beacon stats being sent to driver)
  56. * 2) Scanning (noise measurement does not apply to associated channel)
  57. * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
  58. * Use default noise value of -127 ... this is below the range of measurable
  59. * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
  60. * Also, -127 works better than 0 when averaging frames with/without
  61. * noise info (e.g. averaging might be done in app); measured dBm values are
  62. * always negative ... using a negative value as the default keeps all
  63. * averages within an s8's (used in some apps) range of negative values. */
  64. #define IL_NOISE_MEAS_NOT_AVAILABLE (-127)
  65. /*
  66. * RTS threshold here is total size [2347] minus 4 FCS bytes
  67. * Per spec:
  68. * a value of 0 means RTS on all data/management packets
  69. * a value > max MSDU size means no RTS
  70. * else RTS for data/management frames where MPDU is larger
  71. * than RTS value.
  72. */
  73. #define DEFAULT_RTS_THRESHOLD 2347U
  74. #define MIN_RTS_THRESHOLD 0U
  75. #define MAX_RTS_THRESHOLD 2347U
  76. #define MAX_MSDU_SIZE 2304U
  77. #define MAX_MPDU_SIZE 2346U
  78. #define DEFAULT_BEACON_INTERVAL 100U
  79. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  80. #define DEFAULT_LONG_RETRY_LIMIT 4U
  81. struct il_rx_buf {
  82. dma_addr_t page_dma;
  83. struct page *page;
  84. struct list_head list;
  85. };
  86. #define rxb_addr(r) page_address(r->page)
  87. /* defined below */
  88. struct il_device_cmd;
  89. struct il_cmd_meta {
  90. /* only for SYNC commands, iff the reply skb is wanted */
  91. struct il_host_cmd *source;
  92. /*
  93. * only for ASYNC commands
  94. * (which is somewhat stupid -- look at common.c for instance
  95. * which duplicates a bunch of code because the callback isn't
  96. * invoked for SYNC commands, if it were and its result passed
  97. * through it would be simpler...)
  98. */
  99. void (*callback)(struct il_priv *il,
  100. struct il_device_cmd *cmd,
  101. struct il_rx_pkt *pkt);
  102. /* The CMD_SIZE_HUGE flag bit indicates that the command
  103. * structure is stored at the end of the shared queue memory. */
  104. u32 flags;
  105. DEFINE_DMA_UNMAP_ADDR(mapping);
  106. DEFINE_DMA_UNMAP_LEN(len);
  107. };
  108. /*
  109. * Generic queue structure
  110. *
  111. * Contains common data for Rx and Tx queues
  112. */
  113. struct il_queue {
  114. int n_bd; /* number of BDs in this queue */
  115. int write_ptr; /* 1-st empty entry (idx) host_w*/
  116. int read_ptr; /* last used entry (idx) host_r*/
  117. /* use for monitoring and recovering the stuck queue */
  118. dma_addr_t dma_addr; /* physical addr for BD's */
  119. int n_win; /* safe queue win */
  120. u32 id;
  121. int low_mark; /* low watermark, resume queue if free
  122. * space more than this */
  123. int high_mark; /* high watermark, stop queue if free
  124. * space less than this */
  125. };
  126. /* One for each TFD */
  127. struct il_tx_info {
  128. struct sk_buff *skb;
  129. struct il_rxon_context *ctx;
  130. };
  131. /**
  132. * struct il_tx_queue - Tx Queue for DMA
  133. * @q: generic Rx/Tx queue descriptor
  134. * @bd: base of circular buffer of TFDs
  135. * @cmd: array of command/TX buffer pointers
  136. * @meta: array of meta data for each command/tx buffer
  137. * @dma_addr_cmd: physical address of cmd/tx buffer array
  138. * @txb: array of per-TFD driver data
  139. * @time_stamp: time (in jiffies) of last read_ptr change
  140. * @need_update: indicates need to update read/write idx
  141. * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
  142. *
  143. * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
  144. * descriptors) and required locking structures.
  145. */
  146. #define TFD_TX_CMD_SLOTS 256
  147. #define TFD_CMD_SLOTS 32
  148. struct il_tx_queue {
  149. struct il_queue q;
  150. void *tfds;
  151. struct il_device_cmd **cmd;
  152. struct il_cmd_meta *meta;
  153. struct il_tx_info *txb;
  154. unsigned long time_stamp;
  155. u8 need_update;
  156. u8 sched_retry;
  157. u8 active;
  158. u8 swq_id;
  159. };
  160. /*
  161. * EEPROM access time values:
  162. *
  163. * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG.
  164. * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1).
  165. * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec.
  166. * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG.
  167. */
  168. #define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */
  169. #define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */
  170. #define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
  171. /*
  172. * Regulatory channel usage flags in EEPROM struct il4965_eeprom_channel.flags.
  173. *
  174. * IBSS and/or AP operation is allowed *only* on those channels with
  175. * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because
  176. * RADAR detection is not supported by the 4965 driver, but is a
  177. * requirement for establishing a new network for legal operation on channels
  178. * requiring RADAR detection or restricting ACTIVE scanning.
  179. *
  180. * NOTE: "WIDE" flag does not indicate anything about "HT40" 40 MHz channels.
  181. * It only indicates that 20 MHz channel use is supported; HT40 channel
  182. * usage is indicated by a separate set of regulatory flags for each
  183. * HT40 channel pair.
  184. *
  185. * NOTE: Using a channel inappropriately will result in a uCode error!
  186. */
  187. #define IL_NUM_TX_CALIB_GROUPS 5
  188. enum {
  189. EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */
  190. EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */
  191. /* Bit 2 Reserved */
  192. EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */
  193. EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */
  194. EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */
  195. /* Bit 6 Reserved (was Narrow Channel) */
  196. EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */
  197. };
  198. /* SKU Capabilities */
  199. /* 3945 only */
  200. #define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0)
  201. #define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1)
  202. /* *regulatory* channel data format in eeprom, one for each channel.
  203. * There are separate entries for HT40 (40 MHz) vs. normal (20 MHz) channels. */
  204. struct il_eeprom_channel {
  205. u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */
  206. s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */
  207. } __packed;
  208. /* 3945 Specific */
  209. #define EEPROM_3945_EEPROM_VERSION (0x2f)
  210. /* 4965 has two radio transmitters (and 3 radio receivers) */
  211. #define EEPROM_TX_POWER_TX_CHAINS (2)
  212. /* 4965 has room for up to 8 sets of txpower calibration data */
  213. #define EEPROM_TX_POWER_BANDS (8)
  214. /* 4965 factory calibration measures txpower gain settings for
  215. * each of 3 target output levels */
  216. #define EEPROM_TX_POWER_MEASUREMENTS (3)
  217. /* 4965 Specific */
  218. /* 4965 driver does not work with txpower calibration version < 5 */
  219. #define EEPROM_4965_TX_POWER_VERSION (5)
  220. #define EEPROM_4965_EEPROM_VERSION (0x2f)
  221. #define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */
  222. #define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */
  223. #define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */
  224. #define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */
  225. /* 2.4 GHz */
  226. extern const u8 il_eeprom_band_1[14];
  227. /*
  228. * factory calibration data for one txpower level, on one channel,
  229. * measured on one of the 2 tx chains (radio transmitter and associated
  230. * antenna). EEPROM contains:
  231. *
  232. * 1) Temperature (degrees Celsius) of device when measurement was made.
  233. *
  234. * 2) Gain table idx used to achieve the target measurement power.
  235. * This refers to the "well-known" gain tables (see 4965.h).
  236. *
  237. * 3) Actual measured output power, in half-dBm ("34" = 17 dBm).
  238. *
  239. * 4) RF power amplifier detector level measurement (not used).
  240. */
  241. struct il_eeprom_calib_measure {
  242. u8 temperature; /* Device temperature (Celsius) */
  243. u8 gain_idx; /* Index into gain table */
  244. u8 actual_pow; /* Measured RF output power, half-dBm */
  245. s8 pa_det; /* Power amp detector level (not used) */
  246. } __packed;
  247. /*
  248. * measurement set for one channel. EEPROM contains:
  249. *
  250. * 1) Channel number measured
  251. *
  252. * 2) Measurements for each of 3 power levels for each of 2 radio transmitters
  253. * (a.k.a. "tx chains") (6 measurements altogether)
  254. */
  255. struct il_eeprom_calib_ch_info {
  256. u8 ch_num;
  257. struct il_eeprom_calib_measure
  258. measurements[EEPROM_TX_POWER_TX_CHAINS]
  259. [EEPROM_TX_POWER_MEASUREMENTS];
  260. } __packed;
  261. /*
  262. * txpower subband info.
  263. *
  264. * For each frequency subband, EEPROM contains the following:
  265. *
  266. * 1) First and last channels within range of the subband. "0" values
  267. * indicate that this sample set is not being used.
  268. *
  269. * 2) Sample measurement sets for 2 channels close to the range endpoints.
  270. */
  271. struct il_eeprom_calib_subband_info {
  272. u8 ch_from; /* channel number of lowest channel in subband */
  273. u8 ch_to; /* channel number of highest channel in subband */
  274. struct il_eeprom_calib_ch_info ch1;
  275. struct il_eeprom_calib_ch_info ch2;
  276. } __packed;
  277. /*
  278. * txpower calibration info. EEPROM contains:
  279. *
  280. * 1) Factory-measured saturation power levels (maximum levels at which
  281. * tx power amplifier can output a signal without too much distortion).
  282. * There is one level for 2.4 GHz band and one for 5 GHz band. These
  283. * values apply to all channels within each of the bands.
  284. *
  285. * 2) Factory-measured power supply voltage level. This is assumed to be
  286. * constant (i.e. same value applies to all channels/bands) while the
  287. * factory measurements are being made.
  288. *
  289. * 3) Up to 8 sets of factory-measured txpower calibration values.
  290. * These are for different frequency ranges, since txpower gain
  291. * characteristics of the analog radio circuitry vary with frequency.
  292. *
  293. * Not all sets need to be filled with data;
  294. * struct il_eeprom_calib_subband_info contains range of channels
  295. * (0 if unused) for each set of data.
  296. */
  297. struct il_eeprom_calib_info {
  298. u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */
  299. u8 saturation_power52; /* half-dBm */
  300. __le16 voltage; /* signed */
  301. struct il_eeprom_calib_subband_info
  302. band_info[EEPROM_TX_POWER_BANDS];
  303. } __packed;
  304. /* General */
  305. #define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */
  306. #define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */
  307. #define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */
  308. #define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */
  309. #define EEPROM_VERSION (2*0x44) /* 2 bytes */
  310. #define EEPROM_SKU_CAP (2*0x45) /* 2 bytes */
  311. #define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
  312. #define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
  313. #define EEPROM_RADIO_CONFIG (2*0x48) /* 2 bytes */
  314. #define EEPROM_NUM_MAC_ADDRESS (2*0x4C) /* 2 bytes */
  315. /* The following masks are to be applied on EEPROM_RADIO_CONFIG */
  316. #define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */
  317. #define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */
  318. #define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */
  319. #define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */
  320. #define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */
  321. #define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */
  322. #define EEPROM_3945_RF_CFG_TYPE_MAX 0x0
  323. #define EEPROM_4965_RF_CFG_TYPE_MAX 0x1
  324. /*
  325. * Per-channel regulatory data.
  326. *
  327. * Each channel that *might* be supported by iwl has a fixed location
  328. * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory
  329. * txpower (MSB).
  330. *
  331. * Entries immediately below are for 20 MHz channel width. HT40 (40 MHz)
  332. * channels (only for 4965, not supported by 3945) appear later in the EEPROM.
  333. *
  334. * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14
  335. */
  336. #define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */
  337. #define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */
  338. #define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */
  339. /*
  340. * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196,
  341. * 5.0 GHz channels 7, 8, 11, 12, 16
  342. * (4915-5080MHz) (none of these is ever supported)
  343. */
  344. #define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */
  345. #define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */
  346. /*
  347. * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64
  348. * (5170-5320MHz)
  349. */
  350. #define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */
  351. #define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */
  352. /*
  353. * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140
  354. * (5500-5700MHz)
  355. */
  356. #define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */
  357. #define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */
  358. /*
  359. * 5.7 GHz channels 145, 149, 153, 157, 161, 165
  360. * (5725-5825MHz)
  361. */
  362. #define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */
  363. #define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */
  364. /*
  365. * 2.4 GHz HT40 channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11)
  366. *
  367. * The channel listed is the center of the lower 20 MHz half of the channel.
  368. * The overall center frequency is actually 2 channels (10 MHz) above that,
  369. * and the upper half of each HT40 channel is centered 4 channels (20 MHz) away
  370. * from the lower half; e.g. the upper half of HT40 channel 1 is channel 5,
  371. * and the overall HT40 channel width centers on channel 3.
  372. *
  373. * NOTE: The RXON command uses 20 MHz channel numbers to specify the
  374. * control channel to which to tune. RXON also specifies whether the
  375. * control channel is the upper or lower half of a HT40 channel.
  376. *
  377. * NOTE: 4965 does not support HT40 channels on 2.4 GHz.
  378. */
  379. #define EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS (2*0xA0) /* 14 bytes */
  380. /*
  381. * 5.2 GHz HT40 channels 36 (40), 44 (48), 52 (56), 60 (64),
  382. * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161)
  383. */
  384. #define EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS (2*0xA8) /* 22 bytes */
  385. #define EEPROM_REGULATORY_BAND_NO_HT40 (0)
  386. struct il_eeprom_ops {
  387. const u32 regulatory_bands[7];
  388. int (*acquire_semaphore) (struct il_priv *il);
  389. void (*release_semaphore) (struct il_priv *il);
  390. };
  391. int il_eeprom_init(struct il_priv *il);
  392. void il_eeprom_free(struct il_priv *il);
  393. const u8 *il_eeprom_query_addr(const struct il_priv *il,
  394. size_t offset);
  395. u16 il_eeprom_query16(const struct il_priv *il, size_t offset);
  396. int il_init_channel_map(struct il_priv *il);
  397. void il_free_channel_map(struct il_priv *il);
  398. const struct il_channel_info *il_get_channel_info(
  399. const struct il_priv *il,
  400. enum ieee80211_band band, u16 channel);
  401. #define IL_NUM_SCAN_RATES (2)
  402. struct il4965_channel_tgd_info {
  403. u8 type;
  404. s8 max_power;
  405. };
  406. struct il4965_channel_tgh_info {
  407. s64 last_radar_time;
  408. };
  409. #define IL4965_MAX_RATE (33)
  410. struct il3945_clip_group {
  411. /* maximum power level to prevent clipping for each rate, derived by
  412. * us from this band's saturation power in EEPROM */
  413. const s8 clip_powers[IL_MAX_RATES];
  414. };
  415. /* current Tx power values to use, one for each rate for each channel.
  416. * requested power is limited by:
  417. * -- regulatory EEPROM limits for this channel
  418. * -- hardware capabilities (clip-powers)
  419. * -- spectrum management
  420. * -- user preference (e.g. iwconfig)
  421. * when requested power is set, base power idx must also be set. */
  422. struct il3945_channel_power_info {
  423. struct il3945_tx_power tpc; /* actual radio and DSP gain settings */
  424. s8 power_table_idx; /* actual (compenst'd) idx into gain table */
  425. s8 base_power_idx; /* gain idx for power at factory temp. */
  426. s8 requested_power; /* power (dBm) requested for this chnl/rate */
  427. };
  428. /* current scan Tx power values to use, one for each scan rate for each
  429. * channel. */
  430. struct il3945_scan_power_info {
  431. struct il3945_tx_power tpc; /* actual radio and DSP gain settings */
  432. s8 power_table_idx; /* actual (compenst'd) idx into gain table */
  433. s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */
  434. };
  435. /*
  436. * One for each channel, holds all channel setup data
  437. * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
  438. * with one another!
  439. */
  440. struct il_channel_info {
  441. struct il4965_channel_tgd_info tgd;
  442. struct il4965_channel_tgh_info tgh;
  443. struct il_eeprom_channel eeprom; /* EEPROM regulatory limit */
  444. struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for
  445. * HT40 channel */
  446. u8 channel; /* channel number */
  447. u8 flags; /* flags copied from EEPROM */
  448. s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  449. s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */
  450. s8 min_power; /* always 0 */
  451. s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
  452. u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */
  453. u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */
  454. enum ieee80211_band band;
  455. /* HT40 channel info */
  456. s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  457. u8 ht40_flags; /* flags copied from EEPROM */
  458. u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */
  459. /* Radio/DSP gain settings for each "normal" data Tx rate.
  460. * These include, in addition to RF and DSP gain, a few fields for
  461. * remembering/modifying gain settings (idxes). */
  462. struct il3945_channel_power_info power_info[IL4965_MAX_RATE];
  463. /* Radio/DSP gain settings for each scan rate, for directed scans. */
  464. struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES];
  465. };
  466. #define IL_TX_FIFO_BK 0 /* shared */
  467. #define IL_TX_FIFO_BE 1
  468. #define IL_TX_FIFO_VI 2 /* shared */
  469. #define IL_TX_FIFO_VO 3
  470. #define IL_TX_FIFO_UNUSED -1
  471. /* Minimum number of queues. MAX_NUM is defined in hw specific files.
  472. * Set the minimum to accommodate the 4 standard TX queues, 1 command
  473. * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */
  474. #define IL_MIN_NUM_QUEUES 10
  475. #define IL_DEFAULT_CMD_QUEUE_NUM 4
  476. #define IEEE80211_DATA_LEN 2304
  477. #define IEEE80211_4ADDR_LEN 30
  478. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  479. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  480. struct il_frame {
  481. union {
  482. struct ieee80211_hdr frame;
  483. struct il_tx_beacon_cmd beacon;
  484. u8 raw[IEEE80211_FRAME_LEN];
  485. u8 cmd[360];
  486. } u;
  487. struct list_head list;
  488. };
  489. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  490. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  491. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  492. enum {
  493. CMD_SYNC = 0,
  494. CMD_SIZE_NORMAL = 0,
  495. CMD_NO_SKB = 0,
  496. CMD_SIZE_HUGE = (1 << 0),
  497. CMD_ASYNC = (1 << 1),
  498. CMD_WANT_SKB = (1 << 2),
  499. CMD_MAPPED = (1 << 3),
  500. };
  501. #define DEF_CMD_PAYLOAD_SIZE 320
  502. /**
  503. * struct il_device_cmd
  504. *
  505. * For allocation of the command and tx queues, this establishes the overall
  506. * size of the largest command we send to uCode, except for a scan command
  507. * (which is relatively huge; space is allocated separately).
  508. */
  509. struct il_device_cmd {
  510. struct il_cmd_header hdr; /* uCode API */
  511. union {
  512. u32 flags;
  513. u8 val8;
  514. u16 val16;
  515. u32 val32;
  516. struct il_tx_cmd tx;
  517. u8 payload[DEF_CMD_PAYLOAD_SIZE];
  518. } __packed cmd;
  519. } __packed;
  520. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd))
  521. struct il_host_cmd {
  522. const void *data;
  523. unsigned long reply_page;
  524. void (*callback)(struct il_priv *il,
  525. struct il_device_cmd *cmd,
  526. struct il_rx_pkt *pkt);
  527. u32 flags;
  528. u16 len;
  529. u8 id;
  530. };
  531. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  532. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  533. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  534. /**
  535. * struct il_rx_queue - Rx queue
  536. * @bd: driver's pointer to buffer of receive buffer descriptors (rbd)
  537. * @bd_dma: bus address of buffer of receive buffer descriptors (rbd)
  538. * @read: Shared idx to newest available Rx buffer
  539. * @write: Shared idx to oldest written Rx packet
  540. * @free_count: Number of pre-allocated buffers in rx_free
  541. * @rx_free: list of free SKBs for use
  542. * @rx_used: List of Rx buffers with no SKB
  543. * @need_update: flag to indicate we need to update read/write idx
  544. * @rb_stts: driver's pointer to receive buffer status
  545. * @rb_stts_dma: bus address of receive buffer status
  546. *
  547. * NOTE: rx_free and rx_used are used as a FIFO for il_rx_bufs
  548. */
  549. struct il_rx_queue {
  550. __le32 *bd;
  551. dma_addr_t bd_dma;
  552. struct il_rx_buf pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  553. struct il_rx_buf *queue[RX_QUEUE_SIZE];
  554. u32 read;
  555. u32 write;
  556. u32 free_count;
  557. u32 write_actual;
  558. struct list_head rx_free;
  559. struct list_head rx_used;
  560. int need_update;
  561. struct il_rb_status *rb_stts;
  562. dma_addr_t rb_stts_dma;
  563. spinlock_t lock;
  564. };
  565. #define IL_SUPPORTED_RATES_IE_LEN 8
  566. #define MAX_TID_COUNT 9
  567. #define IL_INVALID_RATE 0xFF
  568. #define IL_INVALID_VALUE -1
  569. /**
  570. * struct il_ht_agg -- aggregation status while waiting for block-ack
  571. * @txq_id: Tx queue used for Tx attempt
  572. * @frame_count: # frames attempted by Tx command
  573. * @wait_for_ba: Expect block-ack before next Tx reply
  574. * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx win
  575. * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win
  576. * @bitmap1: High order, one bit for each frame pending ACK in Tx win
  577. * @rate_n_flags: Rate at which Tx was attempted
  578. *
  579. * If C_TX indicates that aggregation was attempted, driver must wait
  580. * for block ack (N_COMPRESSED_BA). This struct stores tx reply info
  581. * until block ack arrives.
  582. */
  583. struct il_ht_agg {
  584. u16 txq_id;
  585. u16 frame_count;
  586. u16 wait_for_ba;
  587. u16 start_idx;
  588. u64 bitmap;
  589. u32 rate_n_flags;
  590. #define IL_AGG_OFF 0
  591. #define IL_AGG_ON 1
  592. #define IL_EMPTYING_HW_QUEUE_ADDBA 2
  593. #define IL_EMPTYING_HW_QUEUE_DELBA 3
  594. u8 state;
  595. };
  596. struct il_tid_data {
  597. u16 seq_number; /* 4965 only */
  598. u16 tfds_in_queue;
  599. struct il_ht_agg agg;
  600. };
  601. struct il_hw_key {
  602. u32 cipher;
  603. int keylen;
  604. u8 keyidx;
  605. u8 key[32];
  606. };
  607. union il_ht_rate_supp {
  608. u16 rates;
  609. struct {
  610. u8 siso_rate;
  611. u8 mimo_rate;
  612. };
  613. };
  614. #define CFG_HT_RX_AMPDU_FACTOR_8K (0x0)
  615. #define CFG_HT_RX_AMPDU_FACTOR_16K (0x1)
  616. #define CFG_HT_RX_AMPDU_FACTOR_32K (0x2)
  617. #define CFG_HT_RX_AMPDU_FACTOR_64K (0x3)
  618. #define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K
  619. #define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K
  620. #define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K
  621. /*
  622. * Maximal MPDU density for TX aggregation
  623. * 4 - 2us density
  624. * 5 - 4us density
  625. * 6 - 8us density
  626. * 7 - 16us density
  627. */
  628. #define CFG_HT_MPDU_DENSITY_2USEC (0x4)
  629. #define CFG_HT_MPDU_DENSITY_4USEC (0x5)
  630. #define CFG_HT_MPDU_DENSITY_8USEC (0x6)
  631. #define CFG_HT_MPDU_DENSITY_16USEC (0x7)
  632. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC
  633. #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC
  634. #define CFG_HT_MPDU_DENSITY_MIN (0x1)
  635. struct il_ht_config {
  636. bool single_chain_sufficient;
  637. enum ieee80211_smps_mode smps; /* current smps mode */
  638. };
  639. /* QoS structures */
  640. struct il_qos_info {
  641. int qos_active;
  642. struct il_qosparam_cmd def_qos_parm;
  643. };
  644. /*
  645. * Structure should be accessed with sta_lock held. When station addition
  646. * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only
  647. * the commands (il_addsta_cmd and il_link_quality_cmd) without
  648. * sta_lock held.
  649. */
  650. struct il_station_entry {
  651. struct il_addsta_cmd sta;
  652. struct il_tid_data tid[MAX_TID_COUNT];
  653. u8 used, ctxid;
  654. struct il_hw_key keyinfo;
  655. struct il_link_quality_cmd *lq;
  656. };
  657. struct il_station_priv_common {
  658. struct il_rxon_context *ctx;
  659. u8 sta_id;
  660. };
  661. /**
  662. * struct il_vif_priv - driver's ilate per-interface information
  663. *
  664. * When mac80211 allocates a virtual interface, it can allocate
  665. * space for us to put data into.
  666. */
  667. struct il_vif_priv {
  668. struct il_rxon_context *ctx;
  669. u8 ibss_bssid_sta_id;
  670. };
  671. /* one for each uCode image (inst/data, boot/init/runtime) */
  672. struct fw_desc {
  673. void *v_addr; /* access by driver */
  674. dma_addr_t p_addr; /* access by card's busmaster DMA */
  675. u32 len; /* bytes */
  676. };
  677. /* uCode file layout */
  678. struct il_ucode_header {
  679. __le32 ver; /* major/minor/API/serial */
  680. struct {
  681. __le32 inst_size; /* bytes of runtime code */
  682. __le32 data_size; /* bytes of runtime data */
  683. __le32 init_size; /* bytes of init code */
  684. __le32 init_data_size; /* bytes of init data */
  685. __le32 boot_size; /* bytes of bootstrap code */
  686. u8 data[0]; /* in same order as sizes */
  687. } v1;
  688. };
  689. struct il4965_ibss_seq {
  690. u8 mac[ETH_ALEN];
  691. u16 seq_num;
  692. u16 frag_num;
  693. unsigned long packet_time;
  694. struct list_head list;
  695. };
  696. struct il_sensitivity_ranges {
  697. u16 min_nrg_cck;
  698. u16 max_nrg_cck;
  699. u16 nrg_th_cck;
  700. u16 nrg_th_ofdm;
  701. u16 auto_corr_min_ofdm;
  702. u16 auto_corr_min_ofdm_mrc;
  703. u16 auto_corr_min_ofdm_x1;
  704. u16 auto_corr_min_ofdm_mrc_x1;
  705. u16 auto_corr_max_ofdm;
  706. u16 auto_corr_max_ofdm_mrc;
  707. u16 auto_corr_max_ofdm_x1;
  708. u16 auto_corr_max_ofdm_mrc_x1;
  709. u16 auto_corr_max_cck;
  710. u16 auto_corr_max_cck_mrc;
  711. u16 auto_corr_min_cck;
  712. u16 auto_corr_min_cck_mrc;
  713. u16 barker_corr_th_min;
  714. u16 barker_corr_th_min_mrc;
  715. u16 nrg_th_cca;
  716. };
  717. #define KELVIN_TO_CELSIUS(x) ((x)-273)
  718. #define CELSIUS_TO_KELVIN(x) ((x)+273)
  719. /**
  720. * struct il_hw_params
  721. * @max_txq_num: Max # Tx queues supported
  722. * @dma_chnl_num: Number of Tx DMA/FIFO channels
  723. * @scd_bc_tbls_size: size of scheduler byte count tables
  724. * @tfd_size: TFD size
  725. * @tx/rx_chains_num: Number of TX/RX chains
  726. * @valid_tx/rx_ant: usable antennas
  727. * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
  728. * @max_rxq_log: Log-base-2 of max_rxq_size
  729. * @rx_page_order: Rx buffer page order
  730. * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR
  731. * @max_stations:
  732. * @ht40_channel: is 40MHz width possible in band 2.4
  733. * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
  734. * @sw_crypto: 0 for hw, 1 for sw
  735. * @max_xxx_size: for ucode uses
  736. * @ct_kill_threshold: temperature threshold
  737. * @beacon_time_tsf_bits: number of valid tsf bits for beacon time
  738. * @struct il_sensitivity_ranges: range of sensitivity values
  739. */
  740. struct il_hw_params {
  741. u8 max_txq_num;
  742. u8 dma_chnl_num;
  743. u16 scd_bc_tbls_size;
  744. u32 tfd_size;
  745. u8 tx_chains_num;
  746. u8 rx_chains_num;
  747. u8 valid_tx_ant;
  748. u8 valid_rx_ant;
  749. u16 max_rxq_size;
  750. u16 max_rxq_log;
  751. u32 rx_page_order;
  752. u32 rx_wrt_ptr_reg;
  753. u8 max_stations;
  754. u8 ht40_channel;
  755. u8 max_beacon_itrvl; /* in 1024 ms */
  756. u32 max_inst_size;
  757. u32 max_data_size;
  758. u32 max_bsm_size;
  759. u32 ct_kill_threshold; /* value in hw-dependent units */
  760. u16 beacon_time_tsf_bits;
  761. const struct il_sensitivity_ranges *sens;
  762. };
  763. /******************************************************************************
  764. *
  765. * Functions implemented in core module which are forward declared here
  766. * for use by iwl-[4-5].c
  767. *
  768. * NOTE: The implementation of these functions are not hardware specific
  769. * which is why they are in the core module files.
  770. *
  771. * Naming convention --
  772. * il_ <-- Is part of iwlwifi
  773. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  774. * il4965_bg_ <-- Called from work queue context
  775. * il4965_mac_ <-- mac80211 callback
  776. *
  777. ****************************************************************************/
  778. extern void il4965_update_chain_flags(struct il_priv *il);
  779. extern const u8 il_bcast_addr[ETH_ALEN];
  780. extern int il_queue_space(const struct il_queue *q);
  781. static inline int il_queue_used(const struct il_queue *q, int i)
  782. {
  783. return q->write_ptr >= q->read_ptr ?
  784. (i >= q->read_ptr && i < q->write_ptr) :
  785. !(i < q->read_ptr && i >= q->write_ptr);
  786. }
  787. static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx,
  788. int is_huge)
  789. {
  790. /*
  791. * This is for init calibration result and scan command which
  792. * required buffer > TFD_MAX_PAYLOAD_SIZE,
  793. * the big buffer at end of command array
  794. */
  795. if (is_huge)
  796. return q->n_win; /* must be power of 2 */
  797. /* Otherwise, use normal size buffers */
  798. return idx & (q->n_win - 1);
  799. }
  800. struct il_dma_ptr {
  801. dma_addr_t dma;
  802. void *addr;
  803. size_t size;
  804. };
  805. #define IL_OPERATION_MODE_AUTO 0
  806. #define IL_OPERATION_MODE_HT_ONLY 1
  807. #define IL_OPERATION_MODE_MIXED 2
  808. #define IL_OPERATION_MODE_20MHZ 3
  809. #define IL_TX_CRC_SIZE 4
  810. #define IL_TX_DELIMITER_SIZE 4
  811. #define TX_POWER_IL_ILLEGAL_VOLTAGE -10000
  812. /* Sensitivity and chain noise calibration */
  813. #define INITIALIZATION_VALUE 0xFFFF
  814. #define IL4965_CAL_NUM_BEACONS 20
  815. #define IL_CAL_NUM_BEACONS 16
  816. #define MAXIMUM_ALLOWED_PATHLOSS 15
  817. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  818. #define MAX_FA_OFDM 50
  819. #define MIN_FA_OFDM 5
  820. #define MAX_FA_CCK 50
  821. #define MIN_FA_CCK 5
  822. #define AUTO_CORR_STEP_OFDM 1
  823. #define AUTO_CORR_STEP_CCK 3
  824. #define AUTO_CORR_MAX_TH_CCK 160
  825. #define NRG_DIFF 2
  826. #define NRG_STEP_CCK 2
  827. #define NRG_MARGIN 8
  828. #define MAX_NUMBER_CCK_NO_FA 100
  829. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  830. #define CHAIN_A 0
  831. #define CHAIN_B 1
  832. #define CHAIN_C 2
  833. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  834. #define ALL_BAND_FILTER 0xFF00
  835. #define IN_BAND_FILTER 0xFF
  836. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  837. #define NRG_NUM_PREV_STAT_L 20
  838. #define NUM_RX_CHAINS 3
  839. enum il4965_false_alarm_state {
  840. IL_FA_TOO_MANY = 0,
  841. IL_FA_TOO_FEW = 1,
  842. IL_FA_GOOD_RANGE = 2,
  843. };
  844. enum il4965_chain_noise_state {
  845. IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  846. IL_CHAIN_NOISE_ACCUMULATE,
  847. IL_CHAIN_NOISE_CALIBRATED,
  848. IL_CHAIN_NOISE_DONE,
  849. };
  850. enum il4965_calib_enabled_state {
  851. IL_CALIB_DISABLED = 0, /* must be 0 */
  852. IL_CALIB_ENABLED = 1,
  853. };
  854. /*
  855. * enum il_calib
  856. * defines the order in which results of initial calibrations
  857. * should be sent to the runtime uCode
  858. */
  859. enum il_calib {
  860. IL_CALIB_MAX,
  861. };
  862. /* Opaque calibration results */
  863. struct il_calib_result {
  864. void *buf;
  865. size_t buf_len;
  866. };
  867. enum ucode_type {
  868. UCODE_NONE = 0,
  869. UCODE_INIT,
  870. UCODE_RT
  871. };
  872. /* Sensitivity calib data */
  873. struct il_sensitivity_data {
  874. u32 auto_corr_ofdm;
  875. u32 auto_corr_ofdm_mrc;
  876. u32 auto_corr_ofdm_x1;
  877. u32 auto_corr_ofdm_mrc_x1;
  878. u32 auto_corr_cck;
  879. u32 auto_corr_cck_mrc;
  880. u32 last_bad_plcp_cnt_ofdm;
  881. u32 last_fa_cnt_ofdm;
  882. u32 last_bad_plcp_cnt_cck;
  883. u32 last_fa_cnt_cck;
  884. u32 nrg_curr_state;
  885. u32 nrg_prev_state;
  886. u32 nrg_value[10];
  887. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  888. u32 nrg_silence_ref;
  889. u32 nrg_energy_idx;
  890. u32 nrg_silence_idx;
  891. u32 nrg_th_cck;
  892. s32 nrg_auto_corr_silence_diff;
  893. u32 num_in_cck_no_fa;
  894. u32 nrg_th_ofdm;
  895. u16 barker_corr_th_min;
  896. u16 barker_corr_th_min_mrc;
  897. u16 nrg_th_cca;
  898. };
  899. /* Chain noise (differential Rx gain) calib data */
  900. struct il_chain_noise_data {
  901. u32 active_chains;
  902. u32 chain_noise_a;
  903. u32 chain_noise_b;
  904. u32 chain_noise_c;
  905. u32 chain_signal_a;
  906. u32 chain_signal_b;
  907. u32 chain_signal_c;
  908. u16 beacon_count;
  909. u8 disconn_array[NUM_RX_CHAINS];
  910. u8 delta_gain_code[NUM_RX_CHAINS];
  911. u8 radio_write;
  912. u8 state;
  913. };
  914. #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
  915. #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
  916. #define IL_TRAFFIC_ENTRIES (256)
  917. #define IL_TRAFFIC_ENTRY_SIZE (64)
  918. enum {
  919. MEASUREMENT_READY = (1 << 0),
  920. MEASUREMENT_ACTIVE = (1 << 1),
  921. };
  922. /* interrupt stats */
  923. struct isr_stats {
  924. u32 hw;
  925. u32 sw;
  926. u32 err_code;
  927. u32 sch;
  928. u32 alive;
  929. u32 rfkill;
  930. u32 ctkill;
  931. u32 wakeup;
  932. u32 rx;
  933. u32 handlers[IL_CN_MAX];
  934. u32 tx;
  935. u32 unhandled;
  936. };
  937. /* management stats */
  938. enum il_mgmt_stats {
  939. MANAGEMENT_ASSOC_REQ = 0,
  940. MANAGEMENT_ASSOC_RESP,
  941. MANAGEMENT_REASSOC_REQ,
  942. MANAGEMENT_REASSOC_RESP,
  943. MANAGEMENT_PROBE_REQ,
  944. MANAGEMENT_PROBE_RESP,
  945. MANAGEMENT_BEACON,
  946. MANAGEMENT_ATIM,
  947. MANAGEMENT_DISASSOC,
  948. MANAGEMENT_AUTH,
  949. MANAGEMENT_DEAUTH,
  950. MANAGEMENT_ACTION,
  951. MANAGEMENT_MAX,
  952. };
  953. /* control stats */
  954. enum il_ctrl_stats {
  955. CONTROL_BACK_REQ = 0,
  956. CONTROL_BACK,
  957. CONTROL_PSPOLL,
  958. CONTROL_RTS,
  959. CONTROL_CTS,
  960. CONTROL_ACK,
  961. CONTROL_CFEND,
  962. CONTROL_CFENDACK,
  963. CONTROL_MAX,
  964. };
  965. struct traffic_stats {
  966. #ifdef CONFIG_IWLEGACY_DEBUGFS
  967. u32 mgmt[MANAGEMENT_MAX];
  968. u32 ctrl[CONTROL_MAX];
  969. u32 data_cnt;
  970. u64 data_bytes;
  971. #endif
  972. };
  973. /*
  974. * host interrupt timeout value
  975. * used with setting interrupt coalescing timer
  976. * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
  977. *
  978. * default interrupt coalescing timer is 64 x 32 = 2048 usecs
  979. * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
  980. */
  981. #define IL_HOST_INT_TIMEOUT_MAX (0xFF)
  982. #define IL_HOST_INT_TIMEOUT_DEF (0x40)
  983. #define IL_HOST_INT_TIMEOUT_MIN (0x0)
  984. #define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF)
  985. #define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
  986. #define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
  987. #define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5)
  988. /* TX queue watchdog timeouts in mSecs */
  989. #define IL_DEF_WD_TIMEOUT (2000)
  990. #define IL_LONG_WD_TIMEOUT (10000)
  991. #define IL_MAX_WD_TIMEOUT (120000)
  992. struct il_force_reset {
  993. int reset_request_count;
  994. int reset_success_count;
  995. int reset_reject_count;
  996. unsigned long reset_duration;
  997. unsigned long last_force_reset_jiffies;
  998. };
  999. /* extend beacon time format bit shifting */
  1000. /*
  1001. * for _3945 devices
  1002. * bits 31:24 - extended
  1003. * bits 23:0 - interval
  1004. */
  1005. #define IL3945_EXT_BEACON_TIME_POS 24
  1006. /*
  1007. * for _4965 devices
  1008. * bits 31:22 - extended
  1009. * bits 21:0 - interval
  1010. */
  1011. #define IL4965_EXT_BEACON_TIME_POS 22
  1012. struct il_rxon_context {
  1013. struct ieee80211_vif *vif;
  1014. const u8 *ac_to_fifo;
  1015. const u8 *ac_to_queue;
  1016. u8 mcast_queue;
  1017. /*
  1018. * We could use the vif to indicate active, but we
  1019. * also need it to be active during disabling when
  1020. * we already removed the vif for type setting.
  1021. */
  1022. bool always_active, is_active;
  1023. bool ht_need_multiple_chains;
  1024. int ctxid;
  1025. u32 interface_modes, exclusive_interface_modes;
  1026. u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype;
  1027. /*
  1028. * We declare this const so it can only be
  1029. * changed via explicit cast within the
  1030. * routines that actually update the physical
  1031. * hardware.
  1032. */
  1033. const struct il_rxon_cmd active;
  1034. struct il_rxon_cmd staging;
  1035. struct il_rxon_time_cmd timing;
  1036. struct il_qos_info qos_data;
  1037. u8 bcast_sta_id, ap_sta_id;
  1038. u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd;
  1039. u8 qos_cmd;
  1040. u8 wep_key_cmd;
  1041. struct il_wep_key wep_keys[WEP_KEYS_MAX];
  1042. u8 key_mapping_keys;
  1043. __le32 station_flags;
  1044. struct {
  1045. bool non_gf_sta_present;
  1046. u8 protection;
  1047. bool enabled, is_40mhz;
  1048. u8 extension_chan_offset;
  1049. } ht;
  1050. };
  1051. struct il_power_mgr {
  1052. struct il_powertable_cmd sleep_cmd;
  1053. struct il_powertable_cmd sleep_cmd_next;
  1054. int debug_sleep_level_override;
  1055. bool pci_pm;
  1056. };
  1057. struct il_priv {
  1058. /* ieee device used by generic ieee processing code */
  1059. struct ieee80211_hw *hw;
  1060. struct ieee80211_channel *ieee_channels;
  1061. struct ieee80211_rate *ieee_rates;
  1062. struct il_cfg *cfg;
  1063. /* temporary frame storage list */
  1064. struct list_head free_frames;
  1065. int frames_count;
  1066. enum ieee80211_band band;
  1067. int alloc_rxb_page;
  1068. void (*handlers[IL_CN_MAX])(struct il_priv *il,
  1069. struct il_rx_buf *rxb);
  1070. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  1071. /* spectrum measurement report caching */
  1072. struct il_spectrum_notification measure_report;
  1073. u8 measurement_status;
  1074. /* ucode beacon time */
  1075. u32 ucode_beacon_time;
  1076. int missed_beacon_threshold;
  1077. /* track IBSS manager (last beacon) status */
  1078. u32 ibss_manager;
  1079. /* force reset */
  1080. struct il_force_reset force_reset;
  1081. /* we allocate array of il_channel_info for NIC's valid channels.
  1082. * Access via channel # using indirect idx array */
  1083. struct il_channel_info *channel_info; /* channel info array */
  1084. u8 channel_count; /* # of channels */
  1085. /* thermal calibration */
  1086. s32 temperature; /* degrees Kelvin */
  1087. s32 last_temperature;
  1088. /* init calibration results */
  1089. struct il_calib_result calib_results[IL_CALIB_MAX];
  1090. /* Scan related variables */
  1091. unsigned long scan_start;
  1092. unsigned long scan_start_tsf;
  1093. void *scan_cmd;
  1094. enum ieee80211_band scan_band;
  1095. struct cfg80211_scan_request *scan_request;
  1096. struct ieee80211_vif *scan_vif;
  1097. u8 scan_tx_ant[IEEE80211_NUM_BANDS];
  1098. u8 mgmt_tx_ant;
  1099. /* spinlock */
  1100. spinlock_t lock; /* protect general shared data */
  1101. spinlock_t hcmd_lock; /* protect hcmd */
  1102. spinlock_t reg_lock; /* protect hw register access */
  1103. struct mutex mutex;
  1104. /* basic pci-network driver stuff */
  1105. struct pci_dev *pci_dev;
  1106. /* pci hardware address support */
  1107. void __iomem *hw_base;
  1108. u32 hw_rev;
  1109. u32 hw_wa_rev;
  1110. u8 rev_id;
  1111. /* command queue number */
  1112. u8 cmd_queue;
  1113. /* max number of station keys */
  1114. u8 sta_key_max_num;
  1115. /* EEPROM MAC addresses */
  1116. struct mac_address addresses[1];
  1117. /* uCode images, save to reload in case of failure */
  1118. int fw_idx; /* firmware we're trying to load */
  1119. u32 ucode_ver; /* version of ucode, copy of
  1120. il_ucode.ver */
  1121. struct fw_desc ucode_code; /* runtime inst */
  1122. struct fw_desc ucode_data; /* runtime data original */
  1123. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  1124. struct fw_desc ucode_init; /* initialization inst */
  1125. struct fw_desc ucode_init_data; /* initialization data */
  1126. struct fw_desc ucode_boot; /* bootstrap inst */
  1127. enum ucode_type ucode_type;
  1128. u8 ucode_write_complete; /* the image write is complete */
  1129. char firmware_name[25];
  1130. struct il_rxon_context ctx;
  1131. __le16 switch_channel;
  1132. /* 1st responses from initialize and runtime uCode images.
  1133. * _4965's initialize alive response contains some calibration data. */
  1134. struct il_init_alive_resp card_alive_init;
  1135. struct il_alive_resp card_alive;
  1136. u16 active_rate;
  1137. u8 start_calib;
  1138. struct il_sensitivity_data sensitivity_data;
  1139. struct il_chain_noise_data chain_noise_data;
  1140. __le16 sensitivity_tbl[HD_TBL_SIZE];
  1141. struct il_ht_config current_ht_config;
  1142. /* Rate scaling data */
  1143. u8 retry_rate;
  1144. wait_queue_head_t wait_command_queue;
  1145. int activity_timer_active;
  1146. /* Rx and Tx DMA processing queues */
  1147. struct il_rx_queue rxq;
  1148. struct il_tx_queue *txq;
  1149. unsigned long txq_ctx_active_msk;
  1150. struct il_dma_ptr kw; /* keep warm address */
  1151. struct il_dma_ptr scd_bc_tbls;
  1152. u32 scd_base_addr; /* scheduler sram base address */
  1153. unsigned long status;
  1154. /* counts mgmt, ctl, and data packets */
  1155. struct traffic_stats tx_stats;
  1156. struct traffic_stats rx_stats;
  1157. /* counts interrupts */
  1158. struct isr_stats isr_stats;
  1159. struct il_power_mgr power_data;
  1160. /* context information */
  1161. u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */
  1162. /* station table variables */
  1163. /* Note: if lock and sta_lock are needed, lock must be acquired first */
  1164. spinlock_t sta_lock;
  1165. int num_stations;
  1166. struct il_station_entry stations[IL_STATION_COUNT];
  1167. unsigned long ucode_key_table;
  1168. /* queue refcounts */
  1169. #define IL_MAX_HW_QUEUES 32
  1170. unsigned long queue_stopped[BITS_TO_LONGS(IL_MAX_HW_QUEUES)];
  1171. /* for each AC */
  1172. atomic_t queue_stop_count[4];
  1173. /* Indication if ieee80211_ops->open has been called */
  1174. u8 is_open;
  1175. u8 mac80211_registered;
  1176. /* eeprom -- this is in the card's little endian byte order */
  1177. u8 *eeprom;
  1178. struct il_eeprom_calib_info *calib_info;
  1179. enum nl80211_iftype iw_mode;
  1180. /* Last Rx'd beacon timestamp */
  1181. u64 timestamp;
  1182. union {
  1183. #if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE)
  1184. struct {
  1185. void *shared_virt;
  1186. dma_addr_t shared_phys;
  1187. struct delayed_work thermal_periodic;
  1188. struct delayed_work rfkill_poll;
  1189. struct il3945_notif_stats stats;
  1190. #ifdef CONFIG_IWLEGACY_DEBUGFS
  1191. struct il3945_notif_stats accum_stats;
  1192. struct il3945_notif_stats delta_stats;
  1193. struct il3945_notif_stats max_delta;
  1194. #endif
  1195. u32 sta_supp_rates;
  1196. int last_rx_rssi; /* From Rx packet stats */
  1197. /* Rx'd packet timing information */
  1198. u32 last_beacon_time;
  1199. u64 last_tsf;
  1200. /*
  1201. * each calibration channel group in the
  1202. * EEPROM has a derived clip setting for
  1203. * each rate.
  1204. */
  1205. const struct il3945_clip_group clip_groups[5];
  1206. } _3945;
  1207. #endif
  1208. #if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE)
  1209. struct {
  1210. struct il_rx_phy_res last_phy_res;
  1211. bool last_phy_res_valid;
  1212. struct completion firmware_loading_complete;
  1213. /*
  1214. * chain noise reset and gain commands are the
  1215. * two extra calibration commands follows the standard
  1216. * phy calibration commands
  1217. */
  1218. u8 phy_calib_chain_noise_reset_cmd;
  1219. u8 phy_calib_chain_noise_gain_cmd;
  1220. struct il_notif_stats stats;
  1221. #ifdef CONFIG_IWLEGACY_DEBUGFS
  1222. struct il_notif_stats accum_stats;
  1223. struct il_notif_stats delta_stats;
  1224. struct il_notif_stats max_delta;
  1225. #endif
  1226. } _4965;
  1227. #endif
  1228. };
  1229. struct il_hw_params hw_params;
  1230. u32 inta_mask;
  1231. struct workqueue_struct *workqueue;
  1232. struct work_struct restart;
  1233. struct work_struct scan_completed;
  1234. struct work_struct rx_replenish;
  1235. struct work_struct abort_scan;
  1236. struct il_rxon_context *beacon_ctx;
  1237. struct sk_buff *beacon_skb;
  1238. struct work_struct tx_flush;
  1239. struct tasklet_struct irq_tasklet;
  1240. struct delayed_work init_alive_start;
  1241. struct delayed_work alive_start;
  1242. struct delayed_work scan_check;
  1243. /* TX Power */
  1244. s8 tx_power_user_lmt;
  1245. s8 tx_power_device_lmt;
  1246. s8 tx_power_next;
  1247. #ifdef CONFIG_IWLEGACY_DEBUG
  1248. /* debugging info */
  1249. u32 debug_level; /* per device debugging will override global
  1250. il_debug_level if set */
  1251. #endif /* CONFIG_IWLEGACY_DEBUG */
  1252. #ifdef CONFIG_IWLEGACY_DEBUGFS
  1253. /* debugfs */
  1254. u16 tx_traffic_idx;
  1255. u16 rx_traffic_idx;
  1256. u8 *tx_traffic;
  1257. u8 *rx_traffic;
  1258. struct dentry *debugfs_dir;
  1259. u32 dbgfs_sram_offset, dbgfs_sram_len;
  1260. bool disable_ht40;
  1261. #endif /* CONFIG_IWLEGACY_DEBUGFS */
  1262. struct work_struct txpower_work;
  1263. u32 disable_sens_cal;
  1264. u32 disable_chain_noise_cal;
  1265. u32 disable_tx_power_cal;
  1266. struct work_struct run_time_calib_work;
  1267. struct timer_list stats_periodic;
  1268. struct timer_list watchdog;
  1269. bool hw_ready;
  1270. struct led_classdev led;
  1271. unsigned long blink_on, blink_off;
  1272. bool led_registered;
  1273. }; /*il_priv */
  1274. static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id)
  1275. {
  1276. set_bit(txq_id, &il->txq_ctx_active_msk);
  1277. }
  1278. static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id)
  1279. {
  1280. clear_bit(txq_id, &il->txq_ctx_active_msk);
  1281. }
  1282. #ifdef CONFIG_IWLEGACY_DEBUG
  1283. /*
  1284. * il_get_debug_level: Return active debug level for device
  1285. *
  1286. * Using sysfs it is possible to set per device debug level. This debug
  1287. * level will be used if set, otherwise the global debug level which can be
  1288. * set via module parameter is used.
  1289. */
  1290. static inline u32 il_get_debug_level(struct il_priv *il)
  1291. {
  1292. if (il->debug_level)
  1293. return il->debug_level;
  1294. else
  1295. return il_debug_level;
  1296. }
  1297. #else
  1298. static inline u32 il_get_debug_level(struct il_priv *il)
  1299. {
  1300. return il_debug_level;
  1301. }
  1302. #endif
  1303. static inline struct ieee80211_hdr *
  1304. il_tx_queue_get_hdr(struct il_priv *il,
  1305. int txq_id, int idx)
  1306. {
  1307. if (il->txq[txq_id].txb[idx].skb)
  1308. return (struct ieee80211_hdr *)il->txq[txq_id].
  1309. txb[idx].skb->data;
  1310. return NULL;
  1311. }
  1312. static inline struct il_rxon_context *
  1313. il_rxon_ctx_from_vif(struct ieee80211_vif *vif)
  1314. {
  1315. struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
  1316. return vif_priv->ctx;
  1317. }
  1318. #define for_each_context(il, _ctx) \
  1319. for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++)
  1320. static inline int il_is_associated(struct il_priv *il)
  1321. {
  1322. return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1323. }
  1324. static inline int il_is_any_associated(struct il_priv *il)
  1325. {
  1326. return il_is_associated(il);
  1327. }
  1328. static inline int il_is_associated_ctx(struct il_rxon_context *ctx)
  1329. {
  1330. return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  1331. }
  1332. static inline int il_is_channel_valid(const struct il_channel_info *ch_info)
  1333. {
  1334. if (ch_info == NULL)
  1335. return 0;
  1336. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  1337. }
  1338. static inline int il_is_channel_radar(const struct il_channel_info *ch_info)
  1339. {
  1340. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  1341. }
  1342. static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info)
  1343. {
  1344. return ch_info->band == IEEE80211_BAND_5GHZ;
  1345. }
  1346. static inline int
  1347. il_is_channel_passive(const struct il_channel_info *ch)
  1348. {
  1349. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  1350. }
  1351. static inline int
  1352. il_is_channel_ibss(const struct il_channel_info *ch)
  1353. {
  1354. return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0;
  1355. }
  1356. static inline void
  1357. __il_free_pages(struct il_priv *il, struct page *page)
  1358. {
  1359. __free_pages(page, il->hw_params.rx_page_order);
  1360. il->alloc_rxb_page--;
  1361. }
  1362. static inline void il_free_pages(struct il_priv *il, unsigned long page)
  1363. {
  1364. free_pages(page, il->hw_params.rx_page_order);
  1365. il->alloc_rxb_page--;
  1366. }
  1367. #define IWLWIFI_VERSION "in-tree:"
  1368. #define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation"
  1369. #define DRV_AUTHOR "<ilw@linux.intel.com>"
  1370. #define IL_PCI_DEVICE(dev, subdev, cfg) \
  1371. .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \
  1372. .subvendor = PCI_ANY_ID, .subdevice = (subdev), \
  1373. .driver_data = (kernel_ulong_t)&(cfg)
  1374. #define TIME_UNIT 1024
  1375. #define IL_SKU_G 0x1
  1376. #define IL_SKU_A 0x2
  1377. #define IL_SKU_N 0x8
  1378. #define IL_CMD(x) case x: return #x
  1379. /* Size of one Rx buffer in host DRAM */
  1380. #define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */
  1381. #define IL_RX_BUF_SIZE_4K (4 * 1024)
  1382. #define IL_RX_BUF_SIZE_8K (8 * 1024)
  1383. struct il_hcmd_ops {
  1384. int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx);
  1385. int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx);
  1386. void (*set_rxon_chain)(struct il_priv *il,
  1387. struct il_rxon_context *ctx);
  1388. };
  1389. struct il_hcmd_utils_ops {
  1390. u16 (*get_hcmd_size)(u8 cmd_id, u16 len);
  1391. u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd,
  1392. u8 *data);
  1393. int (*request_scan)(struct il_priv *il, struct ieee80211_vif *vif);
  1394. void (*post_scan)(struct il_priv *il);
  1395. };
  1396. struct il_apm_ops {
  1397. int (*init)(struct il_priv *il);
  1398. void (*config)(struct il_priv *il);
  1399. };
  1400. struct il_debugfs_ops {
  1401. ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf,
  1402. size_t count, loff_t *ppos);
  1403. ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf,
  1404. size_t count, loff_t *ppos);
  1405. ssize_t (*general_stats_read)(struct file *file, char __user *user_buf,
  1406. size_t count, loff_t *ppos);
  1407. };
  1408. struct il_temp_ops {
  1409. void (*temperature)(struct il_priv *il);
  1410. };
  1411. struct il_lib_ops {
  1412. /* set hw dependent parameters */
  1413. int (*set_hw_params)(struct il_priv *il);
  1414. /* Handling TX */
  1415. void (*txq_update_byte_cnt_tbl)(struct il_priv *il,
  1416. struct il_tx_queue *txq,
  1417. u16 byte_cnt);
  1418. int (*txq_attach_buf_to_tfd)(struct il_priv *il,
  1419. struct il_tx_queue *txq,
  1420. dma_addr_t addr,
  1421. u16 len, u8 reset, u8 pad);
  1422. void (*txq_free_tfd)(struct il_priv *il,
  1423. struct il_tx_queue *txq);
  1424. int (*txq_init)(struct il_priv *il,
  1425. struct il_tx_queue *txq);
  1426. /* setup Rx handler */
  1427. void (*handler_setup)(struct il_priv *il);
  1428. /* alive notification after init uCode load */
  1429. void (*init_alive_start)(struct il_priv *il);
  1430. /* check validity of rtc data address */
  1431. int (*is_valid_rtc_data_addr)(u32 addr);
  1432. /* 1st ucode load */
  1433. int (*load_ucode)(struct il_priv *il);
  1434. void (*dump_nic_error_log)(struct il_priv *il);
  1435. int (*dump_fh)(struct il_priv *il, char **buf, bool display);
  1436. int (*set_channel_switch)(struct il_priv *il,
  1437. struct ieee80211_channel_switch *ch_switch);
  1438. /* power management */
  1439. struct il_apm_ops apm_ops;
  1440. /* power */
  1441. int (*send_tx_power) (struct il_priv *il);
  1442. void (*update_chain_flags)(struct il_priv *il);
  1443. /* eeprom operations */
  1444. struct il_eeprom_ops eeprom_ops;
  1445. /* temperature */
  1446. struct il_temp_ops temp_ops;
  1447. struct il_debugfs_ops debugfs_ops;
  1448. };
  1449. struct il_led_ops {
  1450. int (*cmd)(struct il_priv *il, struct il_led_cmd *led_cmd);
  1451. };
  1452. struct il_legacy_ops {
  1453. void (*post_associate)(struct il_priv *il);
  1454. void (*config_ap)(struct il_priv *il);
  1455. /* station management */
  1456. int (*update_bcast_stations)(struct il_priv *il);
  1457. int (*manage_ibss_station)(struct il_priv *il,
  1458. struct ieee80211_vif *vif, bool add);
  1459. };
  1460. struct il_ops {
  1461. const struct il_lib_ops *lib;
  1462. const struct il_hcmd_ops *hcmd;
  1463. const struct il_hcmd_utils_ops *utils;
  1464. const struct il_led_ops *led;
  1465. const struct il_nic_ops *nic;
  1466. const struct il_legacy_ops *legacy;
  1467. const struct ieee80211_ops *ieee80211_ops;
  1468. };
  1469. struct il_mod_params {
  1470. int sw_crypto; /* def: 0 = using hardware encryption */
  1471. int disable_hw_scan; /* def: 0 = use h/w scan */
  1472. int num_of_queues; /* def: HW dependent */
  1473. int disable_11n; /* def: 0 = 11n capabilities enabled */
  1474. int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */
  1475. int antenna; /* def: 0 = both antennas (use diversity) */
  1476. int restart_fw; /* def: 1 = restart firmware */
  1477. };
  1478. /*
  1479. * @led_compensation: compensate on the led on/off time per HW according
  1480. * to the deviation to achieve the desired led frequency.
  1481. * The detail algorithm is described in common.c
  1482. * @chain_noise_num_beacons: number of beacons used to compute chain noise
  1483. * @wd_timeout: TX queues watchdog timeout
  1484. * @temperature_kelvin: temperature report by uCode in kelvin
  1485. * @ucode_tracing: support ucode continuous tracing
  1486. * @sensitivity_calib_by_driver: driver has the capability to perform
  1487. * sensitivity calibration operation
  1488. * @chain_noise_calib_by_driver: driver has the capability to perform
  1489. * chain noise calibration operation
  1490. */
  1491. struct il_base_params {
  1492. int eeprom_size;
  1493. int num_of_queues; /* def: HW dependent */
  1494. int num_of_ampdu_queues;/* def: HW dependent */
  1495. /* for il_apm_init() */
  1496. u32 pll_cfg_val;
  1497. bool set_l0s;
  1498. bool use_bsm;
  1499. u16 led_compensation;
  1500. int chain_noise_num_beacons;
  1501. unsigned int wd_timeout;
  1502. bool temperature_kelvin;
  1503. const bool ucode_tracing;
  1504. const bool sensitivity_calib_by_driver;
  1505. const bool chain_noise_calib_by_driver;
  1506. };
  1507. #define IL_LED_SOLID 11
  1508. #define IL_DEF_LED_INTRVL cpu_to_le32(1000)
  1509. #define IL_LED_ACTIVITY (0<<1)
  1510. #define IL_LED_LINK (1<<1)
  1511. /*
  1512. * LED mode
  1513. * IL_LED_DEFAULT: use device default
  1514. * IL_LED_RF_STATE: turn LED on/off based on RF state
  1515. * LED ON = RF ON
  1516. * LED OFF = RF OFF
  1517. * IL_LED_BLINK: adjust led blink rate based on blink table
  1518. */
  1519. enum il_led_mode {
  1520. IL_LED_DEFAULT,
  1521. IL_LED_RF_STATE,
  1522. IL_LED_BLINK,
  1523. };
  1524. void il_leds_init(struct il_priv *il);
  1525. void il_leds_exit(struct il_priv *il);
  1526. /**
  1527. * struct il_cfg
  1528. * @fw_name_pre: Firmware filename prefix. The api version and extension
  1529. * (.ucode) will be added to filename before loading from disk. The
  1530. * filename is constructed as fw_name_pre<api>.ucode.
  1531. * @ucode_api_max: Highest version of uCode API supported by driver.
  1532. * @ucode_api_min: Lowest version of uCode API supported by driver.
  1533. * @scan_antennas: available antenna for scan operation
  1534. * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off)
  1535. *
  1536. * We enable the driver to be backward compatible wrt API version. The
  1537. * driver specifies which APIs it supports (with @ucode_api_max being the
  1538. * highest and @ucode_api_min the lowest). Firmware will only be loaded if
  1539. * it has a supported API version. The firmware's API version will be
  1540. * stored in @il_priv, enabling the driver to make runtime changes based
  1541. * on firmware version used.
  1542. *
  1543. * For example,
  1544. * if (IL_UCODE_API(il->ucode_ver) >= 2) {
  1545. * Driver interacts with Firmware API version >= 2.
  1546. * } else {
  1547. * Driver interacts with Firmware API version 1.
  1548. * }
  1549. *
  1550. * The ideal usage of this infrastructure is to treat a new ucode API
  1551. * release as a new hardware revision. That is, through utilizing the
  1552. * il_hcmd_utils_ops etc. we accommodate different command structures
  1553. * and flows between hardware versions as well as their API
  1554. * versions.
  1555. *
  1556. */
  1557. struct il_cfg {
  1558. /* params specific to an individual device within a device family */
  1559. const char *name;
  1560. const char *fw_name_pre;
  1561. const unsigned int ucode_api_max;
  1562. const unsigned int ucode_api_min;
  1563. u8 valid_tx_ant;
  1564. u8 valid_rx_ant;
  1565. unsigned int sku;
  1566. u16 eeprom_ver;
  1567. u16 eeprom_calib_ver;
  1568. const struct il_ops *ops;
  1569. /* module based parameters which can be set from modprobe cmd */
  1570. const struct il_mod_params *mod_params;
  1571. /* params not likely to change within a device family */
  1572. struct il_base_params *base_params;
  1573. /* params likely to change within a device family */
  1574. u8 scan_rx_antennas[IEEE80211_NUM_BANDS];
  1575. enum il_led_mode led_mode;
  1576. };
  1577. /***************************
  1578. * L i b *
  1579. ***************************/
  1580. struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg);
  1581. int il_mac_conf_tx(struct ieee80211_hw *hw,
  1582. struct ieee80211_vif *vif, u16 queue,
  1583. const struct ieee80211_tx_queue_params *params);
  1584. int il_mac_tx_last_beacon(struct ieee80211_hw *hw);
  1585. void il_set_rxon_hwcrypto(struct il_priv *il,
  1586. struct il_rxon_context *ctx,
  1587. int hw_decrypt);
  1588. int il_check_rxon_cmd(struct il_priv *il,
  1589. struct il_rxon_context *ctx);
  1590. int il_full_rxon_required(struct il_priv *il,
  1591. struct il_rxon_context *ctx);
  1592. int il_set_rxon_channel(struct il_priv *il,
  1593. struct ieee80211_channel *ch,
  1594. struct il_rxon_context *ctx);
  1595. void il_set_flags_for_band(struct il_priv *il,
  1596. struct il_rxon_context *ctx,
  1597. enum ieee80211_band band,
  1598. struct ieee80211_vif *vif);
  1599. u8 il_get_single_channel_number(struct il_priv *il,
  1600. enum ieee80211_band band);
  1601. void il_set_rxon_ht(struct il_priv *il,
  1602. struct il_ht_config *ht_conf);
  1603. bool il_is_ht40_tx_allowed(struct il_priv *il,
  1604. struct il_rxon_context *ctx,
  1605. struct ieee80211_sta_ht_cap *ht_cap);
  1606. void il_connection_init_rx_config(struct il_priv *il,
  1607. struct il_rxon_context *ctx);
  1608. void il_set_rate(struct il_priv *il);
  1609. int il_set_decrypted_flag(struct il_priv *il,
  1610. struct ieee80211_hdr *hdr,
  1611. u32 decrypt_res,
  1612. struct ieee80211_rx_status *stats);
  1613. void il_irq_handle_error(struct il_priv *il);
  1614. int il_mac_add_interface(struct ieee80211_hw *hw,
  1615. struct ieee80211_vif *vif);
  1616. void il_mac_remove_interface(struct ieee80211_hw *hw,
  1617. struct ieee80211_vif *vif);
  1618. int il_mac_change_interface(struct ieee80211_hw *hw,
  1619. struct ieee80211_vif *vif,
  1620. enum nl80211_iftype newtype, bool newp2p);
  1621. int il_alloc_txq_mem(struct il_priv *il);
  1622. void il_txq_mem(struct il_priv *il);
  1623. #ifdef CONFIG_IWLEGACY_DEBUGFS
  1624. int il_alloc_traffic_mem(struct il_priv *il);
  1625. void il_free_traffic_mem(struct il_priv *il);
  1626. void il_reset_traffic_log(struct il_priv *il);
  1627. void il_dbg_log_tx_data_frame(struct il_priv *il,
  1628. u16 length, struct ieee80211_hdr *header);
  1629. void il_dbg_log_rx_data_frame(struct il_priv *il,
  1630. u16 length, struct ieee80211_hdr *header);
  1631. const char *il_get_mgmt_string(int cmd);
  1632. const char *il_get_ctrl_string(int cmd);
  1633. void il_clear_traffic_stats(struct il_priv *il);
  1634. void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc,
  1635. u16 len);
  1636. #else
  1637. static inline int il_alloc_traffic_mem(struct il_priv *il)
  1638. {
  1639. return 0;
  1640. }
  1641. static inline void il_free_traffic_mem(struct il_priv *il)
  1642. {
  1643. }
  1644. static inline void il_reset_traffic_log(struct il_priv *il)
  1645. {
  1646. }
  1647. static inline void il_dbg_log_tx_data_frame(struct il_priv *il,
  1648. u16 length, struct ieee80211_hdr *header)
  1649. {
  1650. }
  1651. static inline void il_dbg_log_rx_data_frame(struct il_priv *il,
  1652. u16 length, struct ieee80211_hdr *header)
  1653. {
  1654. }
  1655. static inline void il_update_stats(struct il_priv *il, bool is_tx,
  1656. __le16 fc, u16 len)
  1657. {
  1658. }
  1659. #endif
  1660. /*****************************************************
  1661. * RX handlers.
  1662. * **************************************************/
  1663. void il_hdl_pm_sleep(struct il_priv *il,
  1664. struct il_rx_buf *rxb);
  1665. void il_hdl_pm_debug_stats(struct il_priv *il,
  1666. struct il_rx_buf *rxb);
  1667. void il_hdl_error(struct il_priv *il,
  1668. struct il_rx_buf *rxb);
  1669. /*****************************************************
  1670. * RX
  1671. ******************************************************/
  1672. void il_cmd_queue_unmap(struct il_priv *il);
  1673. void il_cmd_queue_free(struct il_priv *il);
  1674. int il_rx_queue_alloc(struct il_priv *il);
  1675. void il_rx_queue_update_write_ptr(struct il_priv *il,
  1676. struct il_rx_queue *q);
  1677. int il_rx_queue_space(const struct il_rx_queue *q);
  1678. void il_tx_cmd_complete(struct il_priv *il,
  1679. struct il_rx_buf *rxb);
  1680. /* Handlers */
  1681. void il_hdl_spectrum_measurement(struct il_priv *il,
  1682. struct il_rx_buf *rxb);
  1683. void il_recover_from_stats(struct il_priv *il,
  1684. struct il_rx_pkt *pkt);
  1685. void il_chswitch_done(struct il_priv *il, bool is_success);
  1686. void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb);
  1687. /* TX helpers */
  1688. /*****************************************************
  1689. * TX
  1690. ******************************************************/
  1691. void il_txq_update_write_ptr(struct il_priv *il,
  1692. struct il_tx_queue *txq);
  1693. int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq,
  1694. int slots_num, u32 txq_id);
  1695. void il_tx_queue_reset(struct il_priv *il,
  1696. struct il_tx_queue *txq,
  1697. int slots_num, u32 txq_id);
  1698. void il_tx_queue_unmap(struct il_priv *il, int txq_id);
  1699. void il_tx_queue_free(struct il_priv *il, int txq_id);
  1700. void il_setup_watchdog(struct il_priv *il);
  1701. /*****************************************************
  1702. * TX power
  1703. ****************************************************/
  1704. int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force);
  1705. /*******************************************************************************
  1706. * Rate
  1707. ******************************************************************************/
  1708. u8 il_get_lowest_plcp(struct il_priv *il,
  1709. struct il_rxon_context *ctx);
  1710. /*******************************************************************************
  1711. * Scanning
  1712. ******************************************************************************/
  1713. void il_init_scan_params(struct il_priv *il);
  1714. int il_scan_cancel(struct il_priv *il);
  1715. int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms);
  1716. void il_force_scan_end(struct il_priv *il);
  1717. int il_mac_hw_scan(struct ieee80211_hw *hw,
  1718. struct ieee80211_vif *vif,
  1719. struct cfg80211_scan_request *req);
  1720. void il_internal_short_hw_scan(struct il_priv *il);
  1721. int il_force_reset(struct il_priv *il, bool external);
  1722. u16 il_fill_probe_req(struct il_priv *il,
  1723. struct ieee80211_mgmt *frame,
  1724. const u8 *ta, const u8 *ie, int ie_len, int left);
  1725. void il_setup_rx_scan_handlers(struct il_priv *il);
  1726. u16 il_get_active_dwell_time(struct il_priv *il,
  1727. enum ieee80211_band band,
  1728. u8 n_probes);
  1729. u16 il_get_passive_dwell_time(struct il_priv *il,
  1730. enum ieee80211_band band,
  1731. struct ieee80211_vif *vif);
  1732. void il_setup_scan_deferred_work(struct il_priv *il);
  1733. void il_cancel_scan_deferred_work(struct il_priv *il);
  1734. /* For faster active scanning, scan will move to the next channel if fewer than
  1735. * PLCP_QUIET_THRESH packets are heard on this channel within
  1736. * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell
  1737. * time if it's a quiet channel (nothing responded to our probe, and there's
  1738. * no other traffic).
  1739. * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */
  1740. #define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */
  1741. #define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */
  1742. #define IL_SCAN_CHECK_WATCHDOG (HZ * 7)
  1743. /*****************************************************
  1744. * S e n d i n g H o s t C o m m a n d s *
  1745. *****************************************************/
  1746. const char *il_get_cmd_string(u8 cmd);
  1747. int __must_check il_send_cmd_sync(struct il_priv *il,
  1748. struct il_host_cmd *cmd);
  1749. int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd);
  1750. int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id,
  1751. u16 len, const void *data);
  1752. int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len,
  1753. const void *data,
  1754. void (*callback)(struct il_priv *il,
  1755. struct il_device_cmd *cmd,
  1756. struct il_rx_pkt *pkt));
  1757. int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd);
  1758. /*****************************************************
  1759. * PCI *
  1760. *****************************************************/
  1761. static inline u16 il_pcie_link_ctl(struct il_priv *il)
  1762. {
  1763. int pos;
  1764. u16 pci_lnk_ctl;
  1765. pos = pci_pcie_cap(il->pci_dev);
  1766. pci_read_config_word(il->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl);
  1767. return pci_lnk_ctl;
  1768. }
  1769. void il_bg_watchdog(unsigned long data);
  1770. u32 il_usecs_to_beacons(struct il_priv *il,
  1771. u32 usec, u32 beacon_interval);
  1772. __le32 il_add_beacon_time(struct il_priv *il, u32 base,
  1773. u32 addon, u32 beacon_interval);
  1774. #ifdef CONFIG_PM
  1775. int il_pci_suspend(struct device *device);
  1776. int il_pci_resume(struct device *device);
  1777. extern const struct dev_pm_ops il_pm_ops;
  1778. #define IL_LEGACY_PM_OPS (&il_pm_ops)
  1779. #else /* !CONFIG_PM */
  1780. #define IL_LEGACY_PM_OPS NULL
  1781. #endif /* !CONFIG_PM */
  1782. /*****************************************************
  1783. * Error Handling Debugging
  1784. ******************************************************/
  1785. void il4965_dump_nic_error_log(struct il_priv *il);
  1786. #ifdef CONFIG_IWLEGACY_DEBUG
  1787. void il_print_rx_config_cmd(struct il_priv *il,
  1788. struct il_rxon_context *ctx);
  1789. #else
  1790. static inline void il_print_rx_config_cmd(struct il_priv *il,
  1791. struct il_rxon_context *ctx)
  1792. {
  1793. }
  1794. #endif
  1795. void il_clear_isr_stats(struct il_priv *il);
  1796. /*****************************************************
  1797. * GEOS
  1798. ******************************************************/
  1799. int il_init_geos(struct il_priv *il);
  1800. void il_free_geos(struct il_priv *il);
  1801. /*************** DRIVER STATUS FUNCTIONS *****/
  1802. #define S_HCMD_ACTIVE 0 /* host command in progress */
  1803. /* 1 is unused (used to be S_HCMD_SYNC_ACTIVE) */
  1804. #define S_INT_ENABLED 2
  1805. #define S_RF_KILL_HW 3
  1806. #define S_CT_KILL 4
  1807. #define S_INIT 5
  1808. #define S_ALIVE 6
  1809. #define S_READY 7
  1810. #define S_TEMPERATURE 8
  1811. #define S_GEO_CONFIGURED 9
  1812. #define S_EXIT_PENDING 10
  1813. #define S_STATS 12
  1814. #define S_SCANNING 13
  1815. #define S_SCAN_ABORTING 14
  1816. #define S_SCAN_HW 15
  1817. #define S_POWER_PMI 16
  1818. #define S_FW_ERROR 17
  1819. #define S_CHANNEL_SWITCH_PENDING 18
  1820. static inline int il_is_ready(struct il_priv *il)
  1821. {
  1822. /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are
  1823. * set but EXIT_PENDING is not */
  1824. return test_bit(S_READY, &il->status) &&
  1825. test_bit(S_GEO_CONFIGURED, &il->status) &&
  1826. !test_bit(S_EXIT_PENDING, &il->status);
  1827. }
  1828. static inline int il_is_alive(struct il_priv *il)
  1829. {
  1830. return test_bit(S_ALIVE, &il->status);
  1831. }
  1832. static inline int il_is_init(struct il_priv *il)
  1833. {
  1834. return test_bit(S_INIT, &il->status);
  1835. }
  1836. static inline int il_is_rfkill_hw(struct il_priv *il)
  1837. {
  1838. return test_bit(S_RF_KILL_HW, &il->status);
  1839. }
  1840. static inline int il_is_rfkill(struct il_priv *il)
  1841. {
  1842. return il_is_rfkill_hw(il);
  1843. }
  1844. static inline int il_is_ctkill(struct il_priv *il)
  1845. {
  1846. return test_bit(S_CT_KILL, &il->status);
  1847. }
  1848. static inline int il_is_ready_rf(struct il_priv *il)
  1849. {
  1850. if (il_is_rfkill(il))
  1851. return 0;
  1852. return il_is_ready(il);
  1853. }
  1854. extern void il_send_bt_config(struct il_priv *il);
  1855. extern int il_send_stats_request(struct il_priv *il,
  1856. u8 flags, bool clear);
  1857. void il_apm_stop(struct il_priv *il);
  1858. int il_apm_init(struct il_priv *il);
  1859. int il_send_rxon_timing(struct il_priv *il,
  1860. struct il_rxon_context *ctx);
  1861. static inline int il_send_rxon_assoc(struct il_priv *il,
  1862. struct il_rxon_context *ctx)
  1863. {
  1864. return il->cfg->ops->hcmd->rxon_assoc(il, ctx);
  1865. }
  1866. static inline int il_commit_rxon(struct il_priv *il,
  1867. struct il_rxon_context *ctx)
  1868. {
  1869. return il->cfg->ops->hcmd->commit_rxon(il, ctx);
  1870. }
  1871. static inline const struct ieee80211_supported_band *il_get_hw_mode(
  1872. struct il_priv *il, enum ieee80211_band band)
  1873. {
  1874. return il->hw->wiphy->bands[band];
  1875. }
  1876. /* mac80211 handlers */
  1877. int il_mac_config(struct ieee80211_hw *hw, u32 changed);
  1878. void il_mac_reset_tsf(struct ieee80211_hw *hw,
  1879. struct ieee80211_vif *vif);
  1880. void il_mac_bss_info_changed(struct ieee80211_hw *hw,
  1881. struct ieee80211_vif *vif,
  1882. struct ieee80211_bss_conf *bss_conf,
  1883. u32 changes);
  1884. void il_tx_cmd_protection(struct il_priv *il,
  1885. struct ieee80211_tx_info *info,
  1886. __le16 fc, __le32 *tx_flags);
  1887. irqreturn_t il_isr(int irq, void *data);
  1888. #include <linux/io.h>
  1889. static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val)
  1890. {
  1891. iowrite8(val, il->hw_base + ofs);
  1892. }
  1893. #define il_write8(il, ofs, val) _il_write8(il, ofs, val)
  1894. static inline void _il_wr(struct il_priv *il, u32 ofs, u32 val)
  1895. {
  1896. iowrite32(val, il->hw_base + ofs);
  1897. }
  1898. static inline u32 _il_rd(struct il_priv *il, u32 ofs)
  1899. {
  1900. return ioread32(il->hw_base + ofs);
  1901. }
  1902. #define IL_POLL_INTERVAL 10 /* microseconds */
  1903. static inline int
  1904. _il_poll_bit(struct il_priv *il, u32 addr,
  1905. u32 bits, u32 mask, int timeout)
  1906. {
  1907. int t = 0;
  1908. do {
  1909. if ((_il_rd(il, addr) & mask) == (bits & mask))
  1910. return t;
  1911. udelay(IL_POLL_INTERVAL);
  1912. t += IL_POLL_INTERVAL;
  1913. } while (t < timeout);
  1914. return -ETIMEDOUT;
  1915. }
  1916. static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask)
  1917. {
  1918. _il_wr(il, reg, _il_rd(il, reg) | mask);
  1919. }
  1920. static inline void il_set_bit(struct il_priv *p, u32 r, u32 m)
  1921. {
  1922. unsigned long reg_flags;
  1923. spin_lock_irqsave(&p->reg_lock, reg_flags);
  1924. _il_set_bit(p, r, m);
  1925. spin_unlock_irqrestore(&p->reg_lock, reg_flags);
  1926. }
  1927. static inline void
  1928. _il_clear_bit(struct il_priv *il, u32 reg, u32 mask)
  1929. {
  1930. _il_wr(il, reg, _il_rd(il, reg) & ~mask);
  1931. }
  1932. static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m)
  1933. {
  1934. unsigned long reg_flags;
  1935. spin_lock_irqsave(&p->reg_lock, reg_flags);
  1936. _il_clear_bit(p, r, m);
  1937. spin_unlock_irqrestore(&p->reg_lock, reg_flags);
  1938. }
  1939. static inline int _il_grab_nic_access(struct il_priv *il)
  1940. {
  1941. int ret;
  1942. u32 val;
  1943. /* this bit wakes up the NIC */
  1944. _il_set_bit(il, CSR_GP_CNTRL,
  1945. CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
  1946. /*
  1947. * These bits say the device is running, and should keep running for
  1948. * at least a short while (at least as long as MAC_ACCESS_REQ stays 1),
  1949. * but they do not indicate that embedded SRAM is restored yet;
  1950. * 3945 and 4965 have volatile SRAM, and must save/restore contents
  1951. * to/from host DRAM when sleeping/waking for power-saving.
  1952. * Each direction takes approximately 1/4 millisecond; with this
  1953. * overhead, it's a good idea to grab and hold MAC_ACCESS_REQUEST if a
  1954. * series of register accesses are expected (e.g. reading Event Log),
  1955. * to keep device from sleeping.
  1956. *
  1957. * CSR_UCODE_DRV_GP1 register bit MAC_SLEEP == 0 indicates that
  1958. * SRAM is okay/restored. We don't check that here because this call
  1959. * is just for hardware register access; but GP1 MAC_SLEEP check is a
  1960. * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log).
  1961. *
  1962. */
  1963. ret = _il_poll_bit(il, CSR_GP_CNTRL,
  1964. CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN,
  1965. (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |
  1966. CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000);
  1967. if (ret < 0) {
  1968. val = _il_rd(il, CSR_GP_CNTRL);
  1969. IL_ERR(
  1970. "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val);
  1971. _il_wr(il, CSR_RESET,
  1972. CSR_RESET_REG_FLAG_FORCE_NMI);
  1973. return -EIO;
  1974. }
  1975. return 0;
  1976. }
  1977. static inline void _il_release_nic_access(struct il_priv *il)
  1978. {
  1979. _il_clear_bit(il, CSR_GP_CNTRL,
  1980. CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
  1981. }
  1982. static inline u32 il_rd(struct il_priv *il, u32 reg)
  1983. {
  1984. u32 value;
  1985. unsigned long reg_flags;
  1986. spin_lock_irqsave(&il->reg_lock, reg_flags);
  1987. _il_grab_nic_access(il);
  1988. value = _il_rd(il, reg);
  1989. _il_release_nic_access(il);
  1990. spin_unlock_irqrestore(&il->reg_lock, reg_flags);
  1991. return value;
  1992. }
  1993. static inline void
  1994. il_wr(struct il_priv *il, u32 reg, u32 value)
  1995. {
  1996. unsigned long reg_flags;
  1997. spin_lock_irqsave(&il->reg_lock, reg_flags);
  1998. if (!_il_grab_nic_access(il)) {
  1999. _il_wr(il, reg, value);
  2000. _il_release_nic_access(il);
  2001. }
  2002. spin_unlock_irqrestore(&il->reg_lock, reg_flags);
  2003. }
  2004. static inline void il_write_reg_buf(struct il_priv *il,
  2005. u32 reg, u32 len, u32 *values)
  2006. {
  2007. u32 count = sizeof(u32);
  2008. if (il != NULL && values != NULL) {
  2009. for (; 0 < len; len -= count, reg += count, values++)
  2010. il_wr(il, reg, *values);
  2011. }
  2012. }
  2013. static inline int il_poll_bit(struct il_priv *il, u32 addr,
  2014. u32 mask, int timeout)
  2015. {
  2016. int t = 0;
  2017. do {
  2018. if ((il_rd(il, addr) & mask) == mask)
  2019. return t;
  2020. udelay(IL_POLL_INTERVAL);
  2021. t += IL_POLL_INTERVAL;
  2022. } while (t < timeout);
  2023. return -ETIMEDOUT;
  2024. }
  2025. static inline u32 _il_rd_prph(struct il_priv *il, u32 reg)
  2026. {
  2027. _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24));
  2028. rmb();
  2029. return _il_rd(il, HBUS_TARG_PRPH_RDAT);
  2030. }
  2031. static inline u32 il_rd_prph(struct il_priv *il, u32 reg)
  2032. {
  2033. unsigned long reg_flags;
  2034. u32 val;
  2035. spin_lock_irqsave(&il->reg_lock, reg_flags);
  2036. _il_grab_nic_access(il);
  2037. val = _il_rd_prph(il, reg);
  2038. _il_release_nic_access(il);
  2039. spin_unlock_irqrestore(&il->reg_lock, reg_flags);
  2040. return val;
  2041. }
  2042. static inline void _il_wr_prph(struct il_priv *il,
  2043. u32 addr, u32 val)
  2044. {
  2045. _il_wr(il, HBUS_TARG_PRPH_WADDR,
  2046. ((addr & 0x0000FFFF) | (3 << 24)));
  2047. wmb();
  2048. _il_wr(il, HBUS_TARG_PRPH_WDAT, val);
  2049. }
  2050. static inline void
  2051. il_wr_prph(struct il_priv *il, u32 addr, u32 val)
  2052. {
  2053. unsigned long reg_flags;
  2054. spin_lock_irqsave(&il->reg_lock, reg_flags);
  2055. if (!_il_grab_nic_access(il)) {
  2056. _il_wr_prph(il, addr, val);
  2057. _il_release_nic_access(il);
  2058. }
  2059. spin_unlock_irqrestore(&il->reg_lock, reg_flags);
  2060. }
  2061. #define _il_set_bits_prph(il, reg, mask) \
  2062. _il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask))
  2063. static inline void
  2064. il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask)
  2065. {
  2066. unsigned long reg_flags;
  2067. spin_lock_irqsave(&il->reg_lock, reg_flags);
  2068. _il_grab_nic_access(il);
  2069. _il_set_bits_prph(il, reg, mask);
  2070. _il_release_nic_access(il);
  2071. spin_unlock_irqrestore(&il->reg_lock, reg_flags);
  2072. }
  2073. #define _il_set_bits_mask_prph(il, reg, bits, mask) \
  2074. _il_wr_prph(il, reg, \
  2075. ((_il_rd_prph(il, reg) & mask) | bits))
  2076. static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg,
  2077. u32 bits, u32 mask)
  2078. {
  2079. unsigned long reg_flags;
  2080. spin_lock_irqsave(&il->reg_lock, reg_flags);
  2081. _il_grab_nic_access(il);
  2082. _il_set_bits_mask_prph(il, reg, bits, mask);
  2083. _il_release_nic_access(il);
  2084. spin_unlock_irqrestore(&il->reg_lock, reg_flags);
  2085. }
  2086. static inline void il_clear_bits_prph(struct il_priv
  2087. *il, u32 reg, u32 mask)
  2088. {
  2089. unsigned long reg_flags;
  2090. u32 val;
  2091. spin_lock_irqsave(&il->reg_lock, reg_flags);
  2092. _il_grab_nic_access(il);
  2093. val = _il_rd_prph(il, reg);
  2094. _il_wr_prph(il, reg, (val & ~mask));
  2095. _il_release_nic_access(il);
  2096. spin_unlock_irqrestore(&il->reg_lock, reg_flags);
  2097. }
  2098. static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr)
  2099. {
  2100. unsigned long reg_flags;
  2101. u32 value;
  2102. spin_lock_irqsave(&il->reg_lock, reg_flags);
  2103. _il_grab_nic_access(il);
  2104. _il_wr(il, HBUS_TARG_MEM_RADDR, addr);
  2105. rmb();
  2106. value = _il_rd(il, HBUS_TARG_MEM_RDAT);
  2107. _il_release_nic_access(il);
  2108. spin_unlock_irqrestore(&il->reg_lock, reg_flags);
  2109. return value;
  2110. }
  2111. static inline void
  2112. il_write_targ_mem(struct il_priv *il, u32 addr, u32 val)
  2113. {
  2114. unsigned long reg_flags;
  2115. spin_lock_irqsave(&il->reg_lock, reg_flags);
  2116. if (!_il_grab_nic_access(il)) {
  2117. _il_wr(il, HBUS_TARG_MEM_WADDR, addr);
  2118. wmb();
  2119. _il_wr(il, HBUS_TARG_MEM_WDAT, val);
  2120. _il_release_nic_access(il);
  2121. }
  2122. spin_unlock_irqrestore(&il->reg_lock, reg_flags);
  2123. }
  2124. static inline void
  2125. il_write_targ_mem_buf(struct il_priv *il, u32 addr,
  2126. u32 len, u32 *values)
  2127. {
  2128. unsigned long reg_flags;
  2129. spin_lock_irqsave(&il->reg_lock, reg_flags);
  2130. if (!_il_grab_nic_access(il)) {
  2131. _il_wr(il, HBUS_TARG_MEM_WADDR, addr);
  2132. wmb();
  2133. for (; 0 < len; len -= sizeof(u32), values++)
  2134. _il_wr(il,
  2135. HBUS_TARG_MEM_WDAT, *values);
  2136. _il_release_nic_access(il);
  2137. }
  2138. spin_unlock_irqrestore(&il->reg_lock, reg_flags);
  2139. }
  2140. #define HW_KEY_DYNAMIC 0
  2141. #define HW_KEY_DEFAULT 1
  2142. #define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */
  2143. #define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */
  2144. #define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of
  2145. being activated */
  2146. #define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211;
  2147. (this is for the IBSS BSSID stations) */
  2148. #define IL_STA_BCAST BIT(4) /* this station is the special bcast station */
  2149. void il_restore_stations(struct il_priv *il,
  2150. struct il_rxon_context *ctx);
  2151. void il_clear_ucode_stations(struct il_priv *il,
  2152. struct il_rxon_context *ctx);
  2153. void il_dealloc_bcast_stations(struct il_priv *il);
  2154. int il_get_free_ucode_key_idx(struct il_priv *il);
  2155. int il_send_add_sta(struct il_priv *il,
  2156. struct il_addsta_cmd *sta, u8 flags);
  2157. int il_add_station_common(struct il_priv *il,
  2158. struct il_rxon_context *ctx,
  2159. const u8 *addr, bool is_ap,
  2160. struct ieee80211_sta *sta, u8 *sta_id_r);
  2161. int il_remove_station(struct il_priv *il,
  2162. const u8 sta_id,
  2163. const u8 *addr);
  2164. int il_mac_sta_remove(struct ieee80211_hw *hw,
  2165. struct ieee80211_vif *vif,
  2166. struct ieee80211_sta *sta);
  2167. u8 il_prep_station(struct il_priv *il,
  2168. struct il_rxon_context *ctx,
  2169. const u8 *addr, bool is_ap,
  2170. struct ieee80211_sta *sta);
  2171. int il_send_lq_cmd(struct il_priv *il,
  2172. struct il_rxon_context *ctx,
  2173. struct il_link_quality_cmd *lq,
  2174. u8 flags, bool init);
  2175. /**
  2176. * il_clear_driver_stations - clear knowledge of all stations from driver
  2177. * @il: iwl il struct
  2178. *
  2179. * This is called during il_down() to make sure that in the case
  2180. * we're coming there from a hardware restart mac80211 will be
  2181. * able to reconfigure stations -- if we're getting there in the
  2182. * normal down flow then the stations will already be cleared.
  2183. */
  2184. static inline void il_clear_driver_stations(struct il_priv *il)
  2185. {
  2186. unsigned long flags;
  2187. struct il_rxon_context *ctx = &il->ctx;
  2188. spin_lock_irqsave(&il->sta_lock, flags);
  2189. memset(il->stations, 0, sizeof(il->stations));
  2190. il->num_stations = 0;
  2191. il->ucode_key_table = 0;
  2192. /*
  2193. * Remove all key information that is not stored as part
  2194. * of station information since mac80211 may not have had
  2195. * a chance to remove all the keys. When device is
  2196. * reconfigured by mac80211 after an error all keys will
  2197. * be reconfigured.
  2198. */
  2199. memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys));
  2200. ctx->key_mapping_keys = 0;
  2201. spin_unlock_irqrestore(&il->sta_lock, flags);
  2202. }
  2203. static inline int il_sta_id(struct ieee80211_sta *sta)
  2204. {
  2205. if (WARN_ON(!sta))
  2206. return IL_INVALID_STATION;
  2207. return ((struct il_station_priv_common *)sta->drv_priv)->sta_id;
  2208. }
  2209. /**
  2210. * il_sta_id_or_broadcast - return sta_id or broadcast sta
  2211. * @il: iwl il
  2212. * @context: the current context
  2213. * @sta: mac80211 station
  2214. *
  2215. * In certain circumstances mac80211 passes a station pointer
  2216. * that may be %NULL, for example during TX or key setup. In
  2217. * that case, we need to use the broadcast station, so this
  2218. * inline wraps that pattern.
  2219. */
  2220. static inline int il_sta_id_or_broadcast(struct il_priv *il,
  2221. struct il_rxon_context *context,
  2222. struct ieee80211_sta *sta)
  2223. {
  2224. int sta_id;
  2225. if (!sta)
  2226. return context->bcast_sta_id;
  2227. sta_id = il_sta_id(sta);
  2228. /*
  2229. * mac80211 should not be passing a partially
  2230. * initialised station!
  2231. */
  2232. WARN_ON(sta_id == IL_INVALID_STATION);
  2233. return sta_id;
  2234. }
  2235. /**
  2236. * il_queue_inc_wrap - increment queue idx, wrap back to beginning
  2237. * @idx -- current idx
  2238. * @n_bd -- total number of entries in queue (must be power of 2)
  2239. */
  2240. static inline int il_queue_inc_wrap(int idx, int n_bd)
  2241. {
  2242. return ++idx & (n_bd - 1);
  2243. }
  2244. /**
  2245. * il_queue_dec_wrap - decrement queue idx, wrap back to end
  2246. * @idx -- current idx
  2247. * @n_bd -- total number of entries in queue (must be power of 2)
  2248. */
  2249. static inline int il_queue_dec_wrap(int idx, int n_bd)
  2250. {
  2251. return --idx & (n_bd - 1);
  2252. }
  2253. /* TODO: Move fw_desc functions to iwl-pci.ko */
  2254. static inline void il_free_fw_desc(struct pci_dev *pci_dev,
  2255. struct fw_desc *desc)
  2256. {
  2257. if (desc->v_addr)
  2258. dma_free_coherent(&pci_dev->dev, desc->len,
  2259. desc->v_addr, desc->p_addr);
  2260. desc->v_addr = NULL;
  2261. desc->len = 0;
  2262. }
  2263. static inline int il_alloc_fw_desc(struct pci_dev *pci_dev,
  2264. struct fw_desc *desc)
  2265. {
  2266. if (!desc->len) {
  2267. desc->v_addr = NULL;
  2268. return -EINVAL;
  2269. }
  2270. desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len,
  2271. &desc->p_addr, GFP_KERNEL);
  2272. return (desc->v_addr != NULL) ? 0 : -ENOMEM;
  2273. }
  2274. /*
  2275. * we have 8 bits used like this:
  2276. *
  2277. * 7 6 5 4 3 2 1 0
  2278. * | | | | | | | |
  2279. * | | | | | | +-+-------- AC queue (0-3)
  2280. * | | | | | |
  2281. * | +-+-+-+-+------------ HW queue ID
  2282. * |
  2283. * +---------------------- unused
  2284. */
  2285. static inline void
  2286. il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq)
  2287. {
  2288. BUG_ON(ac > 3); /* only have 2 bits */
  2289. BUG_ON(hwq > 31); /* only use 5 bits */
  2290. txq->swq_id = (hwq << 2) | ac;
  2291. }
  2292. static inline void il_wake_queue(struct il_priv *il,
  2293. struct il_tx_queue *txq)
  2294. {
  2295. u8 queue = txq->swq_id;
  2296. u8 ac = queue & 3;
  2297. u8 hwq = (queue >> 2) & 0x1f;
  2298. if (test_and_clear_bit(hwq, il->queue_stopped))
  2299. if (atomic_dec_return(&il->queue_stop_count[ac]) <= 0)
  2300. ieee80211_wake_queue(il->hw, ac);
  2301. }
  2302. static inline void il_stop_queue(struct il_priv *il,
  2303. struct il_tx_queue *txq)
  2304. {
  2305. u8 queue = txq->swq_id;
  2306. u8 ac = queue & 3;
  2307. u8 hwq = (queue >> 2) & 0x1f;
  2308. if (!test_and_set_bit(hwq, il->queue_stopped))
  2309. if (atomic_inc_return(&il->queue_stop_count[ac]) > 0)
  2310. ieee80211_stop_queue(il->hw, ac);
  2311. }
  2312. #ifdef ieee80211_stop_queue
  2313. #undef ieee80211_stop_queue
  2314. #endif
  2315. #define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue
  2316. #ifdef ieee80211_wake_queue
  2317. #undef ieee80211_wake_queue
  2318. #endif
  2319. #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue
  2320. static inline void il_disable_interrupts(struct il_priv *il)
  2321. {
  2322. clear_bit(S_INT_ENABLED, &il->status);
  2323. /* disable interrupts from uCode/NIC to host */
  2324. _il_wr(il, CSR_INT_MASK, 0x00000000);
  2325. /* acknowledge/clear/reset any interrupts still pending
  2326. * from uCode or flow handler (Rx/Tx DMA) */
  2327. _il_wr(il, CSR_INT, 0xffffffff);
  2328. _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff);
  2329. D_ISR("Disabled interrupts\n");
  2330. }
  2331. static inline void il_enable_rfkill_int(struct il_priv *il)
  2332. {
  2333. D_ISR("Enabling rfkill interrupt\n");
  2334. _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL);
  2335. }
  2336. static inline void il_enable_interrupts(struct il_priv *il)
  2337. {
  2338. D_ISR("Enabling interrupts\n");
  2339. set_bit(S_INT_ENABLED, &il->status);
  2340. _il_wr(il, CSR_INT_MASK, il->inta_mask);
  2341. }
  2342. /**
  2343. * il_beacon_time_mask_low - mask of lower 32 bit of beacon time
  2344. * @il -- pointer to il_priv data structure
  2345. * @tsf_bits -- number of bits need to shift for masking)
  2346. */
  2347. static inline u32 il_beacon_time_mask_low(struct il_priv *il,
  2348. u16 tsf_bits)
  2349. {
  2350. return (1 << tsf_bits) - 1;
  2351. }
  2352. /**
  2353. * il_beacon_time_mask_high - mask of higher 32 bit of beacon time
  2354. * @il -- pointer to il_priv data structure
  2355. * @tsf_bits -- number of bits need to shift for masking)
  2356. */
  2357. static inline u32 il_beacon_time_mask_high(struct il_priv *il,
  2358. u16 tsf_bits)
  2359. {
  2360. return ((1 << (32 - tsf_bits)) - 1) << tsf_bits;
  2361. }
  2362. /**
  2363. * struct il_rb_status - reseve buffer status host memory mapped FH registers
  2364. *
  2365. * @closed_rb_num [0:11] - Indicates the idx of the RB which was closed
  2366. * @closed_fr_num [0:11] - Indicates the idx of the RX Frame which was closed
  2367. * @finished_rb_num [0:11] - Indicates the idx of the current RB
  2368. * in which the last frame was written to
  2369. * @finished_fr_num [0:11] - Indicates the idx of the RX Frame
  2370. * which was transferred
  2371. */
  2372. struct il_rb_status {
  2373. __le16 closed_rb_num;
  2374. __le16 closed_fr_num;
  2375. __le16 finished_rb_num;
  2376. __le16 finished_fr_nam;
  2377. __le32 __unused; /* 3945 only */
  2378. } __packed;
  2379. #define TFD_QUEUE_SIZE_MAX (256)
  2380. #define TFD_QUEUE_SIZE_BC_DUP (64)
  2381. #define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP)
  2382. #define IL_TX_DMA_MASK DMA_BIT_MASK(36)
  2383. #define IL_NUM_OF_TBS 20
  2384. static inline u8 il_get_dma_hi_addr(dma_addr_t addr)
  2385. {
  2386. return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF;
  2387. }
  2388. /**
  2389. * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor
  2390. *
  2391. * This structure contains dma address and length of transmission address
  2392. *
  2393. * @lo: low [31:0] portion of the dma address of TX buffer
  2394. * every even is unaligned on 16 bit boundary
  2395. * @hi_n_len 0-3 [35:32] portion of dma
  2396. * 4-15 length of the tx buffer
  2397. */
  2398. struct il_tfd_tb {
  2399. __le32 lo;
  2400. __le16 hi_n_len;
  2401. } __packed;
  2402. /**
  2403. * struct il_tfd
  2404. *
  2405. * Transmit Frame Descriptor (TFD)
  2406. *
  2407. * @ __reserved1[3] reserved
  2408. * @ num_tbs 0-4 number of active tbs
  2409. * 5 reserved
  2410. * 6-7 padding (not used)
  2411. * @ tbs[20] transmit frame buffer descriptors
  2412. * @ __pad padding
  2413. *
  2414. * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM.
  2415. * Both driver and device share these circular buffers, each of which must be
  2416. * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes
  2417. *
  2418. * Driver must indicate the physical address of the base of each
  2419. * circular buffer via the FH_MEM_CBBC_QUEUE registers.
  2420. *
  2421. * Each TFD contains pointer/size information for up to 20 data buffers
  2422. * in host DRAM. These buffers collectively contain the (one) frame described
  2423. * by the TFD. Each buffer must be a single contiguous block of memory within
  2424. * itself, but buffers may be scattered in host DRAM. Each buffer has max size
  2425. * of (4K - 4). The concatenates all of a TFD's buffers into a single
  2426. * Tx frame, up to 8 KBytes in size.
  2427. *
  2428. * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx.
  2429. */
  2430. struct il_tfd {
  2431. u8 __reserved1[3];
  2432. u8 num_tbs;
  2433. struct il_tfd_tb tbs[IL_NUM_OF_TBS];
  2434. __le32 __pad;
  2435. } __packed;
  2436. /* PCI registers */
  2437. #define PCI_CFG_RETRY_TIMEOUT 0x041
  2438. /* PCI register values */
  2439. #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01
  2440. #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02
  2441. struct il_rate_info {
  2442. u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */
  2443. u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */
  2444. u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */
  2445. u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */
  2446. u8 prev_ieee; /* previous rate in IEEE speeds */
  2447. u8 next_ieee; /* next rate in IEEE speeds */
  2448. u8 prev_rs; /* previous rate used in rs algo */
  2449. u8 next_rs; /* next rate used in rs algo */
  2450. u8 prev_rs_tgg; /* previous rate used in TGG rs algo */
  2451. u8 next_rs_tgg; /* next rate used in TGG rs algo */
  2452. };
  2453. struct il3945_rate_info {
  2454. u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */
  2455. u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */
  2456. u8 prev_ieee; /* previous rate in IEEE speeds */
  2457. u8 next_ieee; /* next rate in IEEE speeds */
  2458. u8 prev_rs; /* previous rate used in rs algo */
  2459. u8 next_rs; /* next rate used in rs algo */
  2460. u8 prev_rs_tgg; /* previous rate used in TGG rs algo */
  2461. u8 next_rs_tgg; /* next rate used in TGG rs algo */
  2462. u8 table_rs_idx; /* idx in rate scale table cmd */
  2463. u8 prev_table_rs; /* prev in rate table cmd */
  2464. };
  2465. /*
  2466. * These serve as idxes into
  2467. * struct il_rate_info il_rates[RATE_COUNT];
  2468. */
  2469. enum {
  2470. RATE_1M_IDX = 0,
  2471. RATE_2M_IDX,
  2472. RATE_5M_IDX,
  2473. RATE_11M_IDX,
  2474. RATE_6M_IDX,
  2475. RATE_9M_IDX,
  2476. RATE_12M_IDX,
  2477. RATE_18M_IDX,
  2478. RATE_24M_IDX,
  2479. RATE_36M_IDX,
  2480. RATE_48M_IDX,
  2481. RATE_54M_IDX,
  2482. RATE_60M_IDX,
  2483. RATE_COUNT,
  2484. RATE_COUNT_LEGACY = RATE_COUNT - 1, /* Excluding 60M */
  2485. RATE_COUNT_3945 = RATE_COUNT - 1,
  2486. RATE_INVM_IDX = RATE_COUNT,
  2487. RATE_INVALID = RATE_COUNT,
  2488. };
  2489. enum {
  2490. RATE_6M_IDX_TBL = 0,
  2491. RATE_9M_IDX_TBL,
  2492. RATE_12M_IDX_TBL,
  2493. RATE_18M_IDX_TBL,
  2494. RATE_24M_IDX_TBL,
  2495. RATE_36M_IDX_TBL,
  2496. RATE_48M_IDX_TBL,
  2497. RATE_54M_IDX_TBL,
  2498. RATE_1M_IDX_TBL,
  2499. RATE_2M_IDX_TBL,
  2500. RATE_5M_IDX_TBL,
  2501. RATE_11M_IDX_TBL,
  2502. RATE_INVM_IDX_TBL = RATE_INVM_IDX - 1,
  2503. };
  2504. enum {
  2505. IL_FIRST_OFDM_RATE = RATE_6M_IDX,
  2506. IL39_LAST_OFDM_RATE = RATE_54M_IDX,
  2507. IL_LAST_OFDM_RATE = RATE_60M_IDX,
  2508. IL_FIRST_CCK_RATE = RATE_1M_IDX,
  2509. IL_LAST_CCK_RATE = RATE_11M_IDX,
  2510. };
  2511. /* #define vs. enum to keep from defaulting to 'large integer' */
  2512. #define RATE_6M_MASK (1 << RATE_6M_IDX)
  2513. #define RATE_9M_MASK (1 << RATE_9M_IDX)
  2514. #define RATE_12M_MASK (1 << RATE_12M_IDX)
  2515. #define RATE_18M_MASK (1 << RATE_18M_IDX)
  2516. #define RATE_24M_MASK (1 << RATE_24M_IDX)
  2517. #define RATE_36M_MASK (1 << RATE_36M_IDX)
  2518. #define RATE_48M_MASK (1 << RATE_48M_IDX)
  2519. #define RATE_54M_MASK (1 << RATE_54M_IDX)
  2520. #define RATE_60M_MASK (1 << RATE_60M_IDX)
  2521. #define RATE_1M_MASK (1 << RATE_1M_IDX)
  2522. #define RATE_2M_MASK (1 << RATE_2M_IDX)
  2523. #define RATE_5M_MASK (1 << RATE_5M_IDX)
  2524. #define RATE_11M_MASK (1 << RATE_11M_IDX)
  2525. /* uCode API values for legacy bit rates, both OFDM and CCK */
  2526. enum {
  2527. RATE_6M_PLCP = 13,
  2528. RATE_9M_PLCP = 15,
  2529. RATE_12M_PLCP = 5,
  2530. RATE_18M_PLCP = 7,
  2531. RATE_24M_PLCP = 9,
  2532. RATE_36M_PLCP = 11,
  2533. RATE_48M_PLCP = 1,
  2534. RATE_54M_PLCP = 3,
  2535. RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/
  2536. RATE_1M_PLCP = 10,
  2537. RATE_2M_PLCP = 20,
  2538. RATE_5M_PLCP = 55,
  2539. RATE_11M_PLCP = 110,
  2540. /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0,*/
  2541. };
  2542. /* uCode API values for OFDM high-throughput (HT) bit rates */
  2543. enum {
  2544. RATE_SISO_6M_PLCP = 0,
  2545. RATE_SISO_12M_PLCP = 1,
  2546. RATE_SISO_18M_PLCP = 2,
  2547. RATE_SISO_24M_PLCP = 3,
  2548. RATE_SISO_36M_PLCP = 4,
  2549. RATE_SISO_48M_PLCP = 5,
  2550. RATE_SISO_54M_PLCP = 6,
  2551. RATE_SISO_60M_PLCP = 7,
  2552. RATE_MIMO2_6M_PLCP = 0x8,
  2553. RATE_MIMO2_12M_PLCP = 0x9,
  2554. RATE_MIMO2_18M_PLCP = 0xa,
  2555. RATE_MIMO2_24M_PLCP = 0xb,
  2556. RATE_MIMO2_36M_PLCP = 0xc,
  2557. RATE_MIMO2_48M_PLCP = 0xd,
  2558. RATE_MIMO2_54M_PLCP = 0xe,
  2559. RATE_MIMO2_60M_PLCP = 0xf,
  2560. RATE_SISO_INVM_PLCP,
  2561. RATE_MIMO2_INVM_PLCP = RATE_SISO_INVM_PLCP,
  2562. };
  2563. /* MAC header values for bit rates */
  2564. enum {
  2565. RATE_6M_IEEE = 12,
  2566. RATE_9M_IEEE = 18,
  2567. RATE_12M_IEEE = 24,
  2568. RATE_18M_IEEE = 36,
  2569. RATE_24M_IEEE = 48,
  2570. RATE_36M_IEEE = 72,
  2571. RATE_48M_IEEE = 96,
  2572. RATE_54M_IEEE = 108,
  2573. RATE_60M_IEEE = 120,
  2574. RATE_1M_IEEE = 2,
  2575. RATE_2M_IEEE = 4,
  2576. RATE_5M_IEEE = 11,
  2577. RATE_11M_IEEE = 22,
  2578. };
  2579. #define IL_CCK_BASIC_RATES_MASK \
  2580. (RATE_1M_MASK | \
  2581. RATE_2M_MASK)
  2582. #define IL_CCK_RATES_MASK \
  2583. (IL_CCK_BASIC_RATES_MASK | \
  2584. RATE_5M_MASK | \
  2585. RATE_11M_MASK)
  2586. #define IL_OFDM_BASIC_RATES_MASK \
  2587. (RATE_6M_MASK | \
  2588. RATE_12M_MASK | \
  2589. RATE_24M_MASK)
  2590. #define IL_OFDM_RATES_MASK \
  2591. (IL_OFDM_BASIC_RATES_MASK | \
  2592. RATE_9M_MASK | \
  2593. RATE_18M_MASK | \
  2594. RATE_36M_MASK | \
  2595. RATE_48M_MASK | \
  2596. RATE_54M_MASK)
  2597. #define IL_BASIC_RATES_MASK \
  2598. (IL_OFDM_BASIC_RATES_MASK | \
  2599. IL_CCK_BASIC_RATES_MASK)
  2600. #define RATES_MASK ((1 << RATE_COUNT) - 1)
  2601. #define RATES_MASK_3945 ((1 << RATE_COUNT_3945) - 1)
  2602. #define IL_INVALID_VALUE -1
  2603. #define IL_MIN_RSSI_VAL -100
  2604. #define IL_MAX_RSSI_VAL 0
  2605. /* These values specify how many Tx frame attempts before
  2606. * searching for a new modulation mode */
  2607. #define IL_LEGACY_FAILURE_LIMIT 160
  2608. #define IL_LEGACY_SUCCESS_LIMIT 480
  2609. #define IL_LEGACY_TBL_COUNT 160
  2610. #define IL_NONE_LEGACY_FAILURE_LIMIT 400
  2611. #define IL_NONE_LEGACY_SUCCESS_LIMIT 4500
  2612. #define IL_NONE_LEGACY_TBL_COUNT 1500
  2613. /* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */
  2614. #define IL_RS_GOOD_RATIO 12800 /* 100% */
  2615. #define RATE_SCALE_SWITCH 10880 /* 85% */
  2616. #define RATE_HIGH_TH 10880 /* 85% */
  2617. #define RATE_INCREASE_TH 6400 /* 50% */
  2618. #define RATE_DECREASE_TH 1920 /* 15% */
  2619. /* possible actions when in legacy mode */
  2620. #define IL_LEGACY_SWITCH_ANTENNA1 0
  2621. #define IL_LEGACY_SWITCH_ANTENNA2 1
  2622. #define IL_LEGACY_SWITCH_SISO 2
  2623. #define IL_LEGACY_SWITCH_MIMO2_AB 3
  2624. #define IL_LEGACY_SWITCH_MIMO2_AC 4
  2625. #define IL_LEGACY_SWITCH_MIMO2_BC 5
  2626. /* possible actions when in siso mode */
  2627. #define IL_SISO_SWITCH_ANTENNA1 0
  2628. #define IL_SISO_SWITCH_ANTENNA2 1
  2629. #define IL_SISO_SWITCH_MIMO2_AB 2
  2630. #define IL_SISO_SWITCH_MIMO2_AC 3
  2631. #define IL_SISO_SWITCH_MIMO2_BC 4
  2632. #define IL_SISO_SWITCH_GI 5
  2633. /* possible actions when in mimo mode */
  2634. #define IL_MIMO2_SWITCH_ANTENNA1 0
  2635. #define IL_MIMO2_SWITCH_ANTENNA2 1
  2636. #define IL_MIMO2_SWITCH_SISO_A 2
  2637. #define IL_MIMO2_SWITCH_SISO_B 3
  2638. #define IL_MIMO2_SWITCH_SISO_C 4
  2639. #define IL_MIMO2_SWITCH_GI 5
  2640. #define IL_MAX_SEARCH IL_MIMO2_SWITCH_GI
  2641. #define IL_ACTION_LIMIT 3 /* # possible actions */
  2642. #define LQ_SIZE 2 /* 2 mode tables: "Active" and "Search" */
  2643. /* load per tid defines for A-MPDU activation */
  2644. #define IL_AGG_TPT_THREHOLD 0
  2645. #define IL_AGG_LOAD_THRESHOLD 10
  2646. #define IL_AGG_ALL_TID 0xff
  2647. #define TID_QUEUE_CELL_SPACING 50 /*mS */
  2648. #define TID_QUEUE_MAX_SIZE 20
  2649. #define TID_ROUND_VALUE 5 /* mS */
  2650. #define TID_MAX_LOAD_COUNT 8
  2651. #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING)
  2652. #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y))
  2653. extern const struct il_rate_info il_rates[RATE_COUNT];
  2654. enum il_table_type {
  2655. LQ_NONE,
  2656. LQ_G, /* legacy types */
  2657. LQ_A,
  2658. LQ_SISO, /* high-throughput types */
  2659. LQ_MIMO2,
  2660. LQ_MAX,
  2661. };
  2662. #define is_legacy(tbl) ((tbl) == LQ_G || (tbl) == LQ_A)
  2663. #define is_siso(tbl) ((tbl) == LQ_SISO)
  2664. #define is_mimo2(tbl) ((tbl) == LQ_MIMO2)
  2665. #define is_mimo(tbl) (is_mimo2(tbl))
  2666. #define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl))
  2667. #define is_a_band(tbl) ((tbl) == LQ_A)
  2668. #define is_g_and(tbl) ((tbl) == LQ_G)
  2669. #define ANT_NONE 0x0
  2670. #define ANT_A BIT(0)
  2671. #define ANT_B BIT(1)
  2672. #define ANT_AB (ANT_A | ANT_B)
  2673. #define ANT_C BIT(2)
  2674. #define ANT_AC (ANT_A | ANT_C)
  2675. #define ANT_BC (ANT_B | ANT_C)
  2676. #define ANT_ABC (ANT_AB | ANT_C)
  2677. #define IL_MAX_MCS_DISPLAY_SIZE 12
  2678. struct il_rate_mcs_info {
  2679. char mbps[IL_MAX_MCS_DISPLAY_SIZE];
  2680. char mcs[IL_MAX_MCS_DISPLAY_SIZE];
  2681. };
  2682. /**
  2683. * struct il_rate_scale_data -- tx success history for one rate
  2684. */
  2685. struct il_rate_scale_data {
  2686. u64 data; /* bitmap of successful frames */
  2687. s32 success_counter; /* number of frames successful */
  2688. s32 success_ratio; /* per-cent * 128 */
  2689. s32 counter; /* number of frames attempted */
  2690. s32 average_tpt; /* success ratio * expected throughput */
  2691. unsigned long stamp;
  2692. };
  2693. /**
  2694. * struct il_scale_tbl_info -- tx params and success history for all rates
  2695. *
  2696. * There are two of these in struct il_lq_sta,
  2697. * one for "active", and one for "search".
  2698. */
  2699. struct il_scale_tbl_info {
  2700. enum il_table_type lq_type;
  2701. u8 ant_type;
  2702. u8 is_SGI; /* 1 = short guard interval */
  2703. u8 is_ht40; /* 1 = 40 MHz channel width */
  2704. u8 is_dup; /* 1 = duplicated data streams */
  2705. u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */
  2706. u8 max_search; /* maximun number of tables we can search */
  2707. s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */
  2708. u32 current_rate; /* rate_n_flags, uCode API format */
  2709. struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */
  2710. };
  2711. struct il_traffic_load {
  2712. unsigned long time_stamp; /* age of the oldest stats */
  2713. u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time
  2714. * slice */
  2715. u32 total; /* total num of packets during the
  2716. * last TID_MAX_TIME_DIFF */
  2717. u8 queue_count; /* number of queues that has
  2718. * been used since the last cleanup */
  2719. u8 head; /* start of the circular buffer */
  2720. };
  2721. /**
  2722. * struct il_lq_sta -- driver's rate scaling ilate structure
  2723. *
  2724. * Pointer to this gets passed back and forth between driver and mac80211.
  2725. */
  2726. struct il_lq_sta {
  2727. u8 active_tbl; /* idx of active table, range 0-1 */
  2728. u8 enable_counter; /* indicates HT mode */
  2729. u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */
  2730. u8 search_better_tbl; /* 1: currently trying alternate mode */
  2731. s32 last_tpt;
  2732. /* The following determine when to search for a new mode */
  2733. u32 table_count_limit;
  2734. u32 max_failure_limit; /* # failed frames before new search */
  2735. u32 max_success_limit; /* # successful frames before new search */
  2736. u32 table_count;
  2737. u32 total_failed; /* total failed frames, any/all rates */
  2738. u32 total_success; /* total successful frames, any/all rates */
  2739. u64 flush_timer; /* time staying in mode before new search */
  2740. u8 action_counter; /* # mode-switch actions tried */
  2741. u8 is_green;
  2742. u8 is_dup;
  2743. enum ieee80211_band band;
  2744. /* The following are bitmaps of rates; RATE_6M_MASK, etc. */
  2745. u32 supp_rates;
  2746. u16 active_legacy_rate;
  2747. u16 active_siso_rate;
  2748. u16 active_mimo2_rate;
  2749. s8 max_rate_idx; /* Max rate set by user */
  2750. u8 missed_rate_counter;
  2751. struct il_link_quality_cmd lq;
  2752. struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */
  2753. struct il_traffic_load load[TID_MAX_LOAD_COUNT];
  2754. u8 tx_agg_tid_en;
  2755. #ifdef CONFIG_MAC80211_DEBUGFS
  2756. struct dentry *rs_sta_dbgfs_scale_table_file;
  2757. struct dentry *rs_sta_dbgfs_stats_table_file;
  2758. struct dentry *rs_sta_dbgfs_rate_scale_data_file;
  2759. struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file;
  2760. u32 dbg_fixed_rate;
  2761. #endif
  2762. struct il_priv *drv;
  2763. /* used to be in sta_info */
  2764. int last_txrate_idx;
  2765. /* last tx rate_n_flags */
  2766. u32 last_rate_n_flags;
  2767. /* packets destined for this STA are aggregated */
  2768. u8 is_agg;
  2769. };
  2770. /*
  2771. * il_station_priv: Driver's ilate station information
  2772. *
  2773. * When mac80211 creates a station it reserves some space (hw->sta_data_size)
  2774. * in the structure for use by driver. This structure is places in that
  2775. * space.
  2776. *
  2777. * The common struct MUST be first because it is shared between
  2778. * 3945 and 4965!
  2779. */
  2780. struct il_station_priv {
  2781. struct il_station_priv_common common;
  2782. struct il_lq_sta lq_sta;
  2783. atomic_t pending_frames;
  2784. bool client;
  2785. bool asleep;
  2786. };
  2787. static inline u8 il4965_num_of_ant(u8 m)
  2788. {
  2789. return !!(m & ANT_A) + !!(m & ANT_B) + !!(m & ANT_C);
  2790. }
  2791. static inline u8 il4965_first_antenna(u8 mask)
  2792. {
  2793. if (mask & ANT_A)
  2794. return ANT_A;
  2795. if (mask & ANT_B)
  2796. return ANT_B;
  2797. return ANT_C;
  2798. }
  2799. /**
  2800. * il3945_rate_scale_init - Initialize the rate scale table based on assoc info
  2801. *
  2802. * The specific throughput table used is based on the type of network
  2803. * the associated with, including A, B, G, and G w/ TGG protection
  2804. */
  2805. extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id);
  2806. /* Initialize station's rate scaling information after adding station */
  2807. extern void il4965_rs_rate_init(struct il_priv *il,
  2808. struct ieee80211_sta *sta, u8 sta_id);
  2809. extern void il3945_rs_rate_init(struct il_priv *il,
  2810. struct ieee80211_sta *sta, u8 sta_id);
  2811. /**
  2812. * il_rate_control_register - Register the rate control algorithm callbacks
  2813. *
  2814. * Since the rate control algorithm is hardware specific, there is no need
  2815. * or reason to place it as a stand alone module. The driver can call
  2816. * il_rate_control_register in order to register the rate control callbacks
  2817. * with the mac80211 subsystem. This should be performed prior to calling
  2818. * ieee80211_register_hw
  2819. *
  2820. */
  2821. extern int il4965_rate_control_register(void);
  2822. extern int il3945_rate_control_register(void);
  2823. /**
  2824. * il_rate_control_unregister - Unregister the rate control callbacks
  2825. *
  2826. * This should be called after calling ieee80211_unregister_hw, but before
  2827. * the driver is unloaded.
  2828. */
  2829. extern void il4965_rate_control_unregister(void);
  2830. extern void il3945_rate_control_unregister(void);
  2831. extern int il_power_update_mode(struct il_priv *il, bool force);
  2832. extern void il_power_initialize(struct il_priv *il);
  2833. #endif /* __il_core_h__ */