3945.c 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /******************************************************************************
  3. *
  4. * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved.
  5. *
  6. * Contact Information:
  7. * Intel Linux Wireless <[email protected]>
  8. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  9. *
  10. *****************************************************************************/
  11. #include <linux/kernel.h>
  12. #include <linux/module.h>
  13. #include <linux/slab.h>
  14. #include <linux/pci.h>
  15. #include <linux/dma-mapping.h>
  16. #include <linux/delay.h>
  17. #include <linux/sched.h>
  18. #include <linux/skbuff.h>
  19. #include <linux/netdevice.h>
  20. #include <linux/firmware.h>
  21. #include <linux/etherdevice.h>
  22. #include <asm/unaligned.h>
  23. #include <net/mac80211.h>
  24. #include "common.h"
  25. #include "3945.h"
  26. /* Send led command */
  27. static int
  28. il3945_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd)
  29. {
  30. struct il_host_cmd cmd = {
  31. .id = C_LEDS,
  32. .len = sizeof(struct il_led_cmd),
  33. .data = led_cmd,
  34. .flags = CMD_ASYNC,
  35. .callback = NULL,
  36. };
  37. return il_send_cmd(il, &cmd);
  38. }
  39. #define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \
  40. [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \
  41. RATE_##r##M_IEEE, \
  42. RATE_##ip##M_IDX, \
  43. RATE_##in##M_IDX, \
  44. RATE_##rp##M_IDX, \
  45. RATE_##rn##M_IDX, \
  46. RATE_##pp##M_IDX, \
  47. RATE_##np##M_IDX, \
  48. RATE_##r##M_IDX_TBL, \
  49. RATE_##ip##M_IDX_TBL }
  50. /*
  51. * Parameter order:
  52. * rate, prev rate, next rate, prev tgg rate, next tgg rate
  53. *
  54. * If there isn't a valid next or previous rate then INV is used which
  55. * maps to RATE_INVALID
  56. *
  57. */
  58. const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = {
  59. IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */
  60. IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */
  61. IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */
  62. IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */
  63. IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */
  64. IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */
  65. IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */
  66. IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */
  67. IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */
  68. IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */
  69. IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */
  70. IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV), /* 54mbps */
  71. };
  72. static inline u8
  73. il3945_get_prev_ieee_rate(u8 rate_idx)
  74. {
  75. u8 rate = il3945_rates[rate_idx].prev_ieee;
  76. if (rate == RATE_INVALID)
  77. rate = rate_idx;
  78. return rate;
  79. }
  80. /* 1 = enable the il3945_disable_events() function */
  81. #define IL_EVT_DISABLE (0)
  82. #define IL_EVT_DISABLE_SIZE (1532/32)
  83. /*
  84. * il3945_disable_events - Disable selected events in uCode event log
  85. *
  86. * Disable an event by writing "1"s into "disable"
  87. * bitmap in SRAM. Bit position corresponds to Event # (id/type).
  88. * Default values of 0 enable uCode events to be logged.
  89. * Use for only special debugging. This function is just a placeholder as-is,
  90. * you'll need to provide the special bits! ...
  91. * ... and set IL_EVT_DISABLE to 1. */
  92. void
  93. il3945_disable_events(struct il_priv *il)
  94. {
  95. int i;
  96. u32 base; /* SRAM address of event log header */
  97. u32 disable_ptr; /* SRAM address of event-disable bitmap array */
  98. u32 array_size; /* # of u32 entries in array */
  99. static const u32 evt_disable[IL_EVT_DISABLE_SIZE] = {
  100. 0x00000000, /* 31 - 0 Event id numbers */
  101. 0x00000000, /* 63 - 32 */
  102. 0x00000000, /* 95 - 64 */
  103. 0x00000000, /* 127 - 96 */
  104. 0x00000000, /* 159 - 128 */
  105. 0x00000000, /* 191 - 160 */
  106. 0x00000000, /* 223 - 192 */
  107. 0x00000000, /* 255 - 224 */
  108. 0x00000000, /* 287 - 256 */
  109. 0x00000000, /* 319 - 288 */
  110. 0x00000000, /* 351 - 320 */
  111. 0x00000000, /* 383 - 352 */
  112. 0x00000000, /* 415 - 384 */
  113. 0x00000000, /* 447 - 416 */
  114. 0x00000000, /* 479 - 448 */
  115. 0x00000000, /* 511 - 480 */
  116. 0x00000000, /* 543 - 512 */
  117. 0x00000000, /* 575 - 544 */
  118. 0x00000000, /* 607 - 576 */
  119. 0x00000000, /* 639 - 608 */
  120. 0x00000000, /* 671 - 640 */
  121. 0x00000000, /* 703 - 672 */
  122. 0x00000000, /* 735 - 704 */
  123. 0x00000000, /* 767 - 736 */
  124. 0x00000000, /* 799 - 768 */
  125. 0x00000000, /* 831 - 800 */
  126. 0x00000000, /* 863 - 832 */
  127. 0x00000000, /* 895 - 864 */
  128. 0x00000000, /* 927 - 896 */
  129. 0x00000000, /* 959 - 928 */
  130. 0x00000000, /* 991 - 960 */
  131. 0x00000000, /* 1023 - 992 */
  132. 0x00000000, /* 1055 - 1024 */
  133. 0x00000000, /* 1087 - 1056 */
  134. 0x00000000, /* 1119 - 1088 */
  135. 0x00000000, /* 1151 - 1120 */
  136. 0x00000000, /* 1183 - 1152 */
  137. 0x00000000, /* 1215 - 1184 */
  138. 0x00000000, /* 1247 - 1216 */
  139. 0x00000000, /* 1279 - 1248 */
  140. 0x00000000, /* 1311 - 1280 */
  141. 0x00000000, /* 1343 - 1312 */
  142. 0x00000000, /* 1375 - 1344 */
  143. 0x00000000, /* 1407 - 1376 */
  144. 0x00000000, /* 1439 - 1408 */
  145. 0x00000000, /* 1471 - 1440 */
  146. 0x00000000, /* 1503 - 1472 */
  147. };
  148. base = le32_to_cpu(il->card_alive.log_event_table_ptr);
  149. if (!il3945_hw_valid_rtc_data_addr(base)) {
  150. IL_ERR("Invalid event log pointer 0x%08X\n", base);
  151. return;
  152. }
  153. disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32)));
  154. array_size = il_read_targ_mem(il, base + (5 * sizeof(u32)));
  155. if (IL_EVT_DISABLE && array_size == IL_EVT_DISABLE_SIZE) {
  156. D_INFO("Disabling selected uCode log events at 0x%x\n",
  157. disable_ptr);
  158. for (i = 0; i < IL_EVT_DISABLE_SIZE; i++)
  159. il_write_targ_mem(il, disable_ptr + (i * sizeof(u32)),
  160. evt_disable[i]);
  161. } else {
  162. D_INFO("Selected uCode log events may be disabled\n");
  163. D_INFO(" by writing \"1\"s into disable bitmap\n");
  164. D_INFO(" in SRAM at 0x%x, size %d u32s\n", disable_ptr,
  165. array_size);
  166. }
  167. }
  168. static int
  169. il3945_hwrate_to_plcp_idx(u8 plcp)
  170. {
  171. int idx;
  172. for (idx = 0; idx < RATE_COUNT_3945; idx++)
  173. if (il3945_rates[idx].plcp == plcp)
  174. return idx;
  175. return -1;
  176. }
  177. #ifdef CONFIG_IWLEGACY_DEBUG
  178. #define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x
  179. static const char *
  180. il3945_get_tx_fail_reason(u32 status)
  181. {
  182. switch (status & TX_STATUS_MSK) {
  183. case TX_3945_STATUS_SUCCESS:
  184. return "SUCCESS";
  185. TX_STATUS_ENTRY(SHORT_LIMIT);
  186. TX_STATUS_ENTRY(LONG_LIMIT);
  187. TX_STATUS_ENTRY(FIFO_UNDERRUN);
  188. TX_STATUS_ENTRY(MGMNT_ABORT);
  189. TX_STATUS_ENTRY(NEXT_FRAG);
  190. TX_STATUS_ENTRY(LIFE_EXPIRE);
  191. TX_STATUS_ENTRY(DEST_PS);
  192. TX_STATUS_ENTRY(ABORTED);
  193. TX_STATUS_ENTRY(BT_RETRY);
  194. TX_STATUS_ENTRY(STA_INVALID);
  195. TX_STATUS_ENTRY(FRAG_DROPPED);
  196. TX_STATUS_ENTRY(TID_DISABLE);
  197. TX_STATUS_ENTRY(FRAME_FLUSHED);
  198. TX_STATUS_ENTRY(INSUFFICIENT_CF_POLL);
  199. TX_STATUS_ENTRY(TX_LOCKED);
  200. TX_STATUS_ENTRY(NO_BEACON_ON_RADAR);
  201. }
  202. return "UNKNOWN";
  203. }
  204. #else
  205. static inline const char *
  206. il3945_get_tx_fail_reason(u32 status)
  207. {
  208. return "";
  209. }
  210. #endif
  211. /*
  212. * get ieee prev rate from rate scale table.
  213. * for A and B mode we need to overright prev
  214. * value
  215. */
  216. int
  217. il3945_rs_next_rate(struct il_priv *il, int rate)
  218. {
  219. int next_rate = il3945_get_prev_ieee_rate(rate);
  220. switch (il->band) {
  221. case NL80211_BAND_5GHZ:
  222. if (rate == RATE_12M_IDX)
  223. next_rate = RATE_9M_IDX;
  224. else if (rate == RATE_6M_IDX)
  225. next_rate = RATE_6M_IDX;
  226. break;
  227. case NL80211_BAND_2GHZ:
  228. if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) &&
  229. il_is_associated(il)) {
  230. if (rate == RATE_11M_IDX)
  231. next_rate = RATE_5M_IDX;
  232. }
  233. break;
  234. default:
  235. break;
  236. }
  237. return next_rate;
  238. }
  239. /*
  240. * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd
  241. *
  242. * When FW advances 'R' idx, all entries between old and new 'R' idx
  243. * need to be reclaimed. As result, some free space forms. If there is
  244. * enough free space (> low mark), wake the stack that feeds us.
  245. */
  246. static void
  247. il3945_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx)
  248. {
  249. struct il_tx_queue *txq = &il->txq[txq_id];
  250. struct il_queue *q = &txq->q;
  251. struct sk_buff *skb;
  252. BUG_ON(txq_id == IL39_CMD_QUEUE_NUM);
  253. for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx;
  254. q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) {
  255. skb = txq->skbs[txq->q.read_ptr];
  256. ieee80211_tx_status_irqsafe(il->hw, skb);
  257. txq->skbs[txq->q.read_ptr] = NULL;
  258. il->ops->txq_free_tfd(il, txq);
  259. }
  260. if (il_queue_space(q) > q->low_mark && txq_id >= 0 &&
  261. txq_id != IL39_CMD_QUEUE_NUM && il->mac80211_registered)
  262. il_wake_queue(il, txq);
  263. }
  264. /*
  265. * il3945_hdl_tx - Handle Tx response
  266. */
  267. static void
  268. il3945_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb)
  269. {
  270. struct il_rx_pkt *pkt = rxb_addr(rxb);
  271. u16 sequence = le16_to_cpu(pkt->hdr.sequence);
  272. int txq_id = SEQ_TO_QUEUE(sequence);
  273. int idx = SEQ_TO_IDX(sequence);
  274. struct il_tx_queue *txq = &il->txq[txq_id];
  275. struct ieee80211_tx_info *info;
  276. struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0];
  277. u32 status = le32_to_cpu(tx_resp->status);
  278. int rate_idx;
  279. int fail;
  280. if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) {
  281. IL_ERR("Read idx for DMA queue txq_id (%d) idx %d "
  282. "is out of range [0-%d] %d %d\n", txq_id, idx,
  283. txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr);
  284. return;
  285. }
  286. /*
  287. * Firmware will not transmit frame on passive channel, if it not yet
  288. * received some valid frame on that channel. When this error happen
  289. * we have to wait until firmware will unblock itself i.e. when we
  290. * note received beacon or other frame. We unblock queues in
  291. * il3945_pass_packet_to_mac80211 or in il_mac_bss_info_changed.
  292. */
  293. if (unlikely((status & TX_STATUS_MSK) == TX_STATUS_FAIL_PASSIVE_NO_RX) &&
  294. il->iw_mode == NL80211_IFTYPE_STATION) {
  295. il_stop_queues_by_reason(il, IL_STOP_REASON_PASSIVE);
  296. D_INFO("Stopped queues - RX waiting on passive channel\n");
  297. }
  298. txq->time_stamp = jiffies;
  299. info = IEEE80211_SKB_CB(txq->skbs[txq->q.read_ptr]);
  300. ieee80211_tx_info_clear_status(info);
  301. /* Fill the MRR chain with some info about on-chip retransmissions */
  302. rate_idx = il3945_hwrate_to_plcp_idx(tx_resp->rate);
  303. if (info->band == NL80211_BAND_5GHZ)
  304. rate_idx -= IL_FIRST_OFDM_RATE;
  305. fail = tx_resp->failure_frame;
  306. info->status.rates[0].idx = rate_idx;
  307. info->status.rates[0].count = fail + 1; /* add final attempt */
  308. /* tx_status->rts_retry_count = tx_resp->failure_rts; */
  309. info->flags |=
  310. ((status & TX_STATUS_MSK) ==
  311. TX_STATUS_SUCCESS) ? IEEE80211_TX_STAT_ACK : 0;
  312. D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", txq_id,
  313. il3945_get_tx_fail_reason(status), status, tx_resp->rate,
  314. tx_resp->failure_frame);
  315. D_TX_REPLY("Tx queue reclaim %d\n", idx);
  316. il3945_tx_queue_reclaim(il, txq_id, idx);
  317. if (status & TX_ABORT_REQUIRED_MSK)
  318. IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n");
  319. }
  320. /*****************************************************************************
  321. *
  322. * Intel PRO/Wireless 3945ABG/BG Network Connection
  323. *
  324. * RX handler implementations
  325. *
  326. *****************************************************************************/
  327. #ifdef CONFIG_IWLEGACY_DEBUGFS
  328. static void
  329. il3945_accumulative_stats(struct il_priv *il, __le32 * stats)
  330. {
  331. int i;
  332. __le32 *prev_stats;
  333. u32 *accum_stats;
  334. u32 *delta, *max_delta;
  335. prev_stats = (__le32 *) &il->_3945.stats;
  336. accum_stats = (u32 *) &il->_3945.accum_stats;
  337. delta = (u32 *) &il->_3945.delta_stats;
  338. max_delta = (u32 *) &il->_3945.max_delta;
  339. for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats);
  340. i +=
  341. sizeof(__le32), stats++, prev_stats++, delta++, max_delta++,
  342. accum_stats++) {
  343. if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) {
  344. *delta =
  345. (le32_to_cpu(*stats) - le32_to_cpu(*prev_stats));
  346. *accum_stats += *delta;
  347. if (*delta > *max_delta)
  348. *max_delta = *delta;
  349. }
  350. }
  351. /* reset accumulative stats for "no-counter" type stats */
  352. il->_3945.accum_stats.general.temperature =
  353. il->_3945.stats.general.temperature;
  354. il->_3945.accum_stats.general.ttl_timestamp =
  355. il->_3945.stats.general.ttl_timestamp;
  356. }
  357. #endif
  358. void
  359. il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb)
  360. {
  361. struct il_rx_pkt *pkt = rxb_addr(rxb);
  362. D_RX("Statistics notification received (%d vs %d).\n",
  363. (int)sizeof(struct il3945_notif_stats),
  364. le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK);
  365. #ifdef CONFIG_IWLEGACY_DEBUGFS
  366. il3945_accumulative_stats(il, (__le32 *) &pkt->u.raw);
  367. #endif
  368. memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats));
  369. }
  370. void
  371. il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb)
  372. {
  373. struct il_rx_pkt *pkt = rxb_addr(rxb);
  374. __le32 *flag = (__le32 *) &pkt->u.raw;
  375. if (le32_to_cpu(*flag) & UCODE_STATS_CLEAR_MSK) {
  376. #ifdef CONFIG_IWLEGACY_DEBUGFS
  377. memset(&il->_3945.accum_stats, 0,
  378. sizeof(struct il3945_notif_stats));
  379. memset(&il->_3945.delta_stats, 0,
  380. sizeof(struct il3945_notif_stats));
  381. memset(&il->_3945.max_delta, 0,
  382. sizeof(struct il3945_notif_stats));
  383. #endif
  384. D_RX("Statistics have been cleared\n");
  385. }
  386. il3945_hdl_stats(il, rxb);
  387. }
  388. /******************************************************************************
  389. *
  390. * Misc. internal state and helper functions
  391. *
  392. ******************************************************************************/
  393. /* This is necessary only for a number of stats, see the caller. */
  394. static int
  395. il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header)
  396. {
  397. /* Filter incoming packets to determine if they are targeted toward
  398. * this network, discarding packets coming from ourselves */
  399. switch (il->iw_mode) {
  400. case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */
  401. /* packets to our IBSS update information */
  402. return ether_addr_equal_64bits(header->addr3, il->bssid);
  403. case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */
  404. /* packets to our IBSS update information */
  405. return ether_addr_equal_64bits(header->addr2, il->bssid);
  406. default:
  407. return 1;
  408. }
  409. }
  410. #define SMALL_PACKET_SIZE 256
  411. static void
  412. il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb,
  413. struct ieee80211_rx_status *stats)
  414. {
  415. struct il_rx_pkt *pkt = rxb_addr(rxb);
  416. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt);
  417. struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt);
  418. struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt);
  419. u32 len = le16_to_cpu(rx_hdr->len);
  420. struct sk_buff *skb;
  421. __le16 fc = hdr->frame_control;
  422. u32 fraglen = PAGE_SIZE << il->hw_params.rx_page_order;
  423. /* We received data from the HW, so stop the watchdog */
  424. if (unlikely(len + IL39_RX_FRAME_SIZE > fraglen)) {
  425. D_DROP("Corruption detected!\n");
  426. return;
  427. }
  428. /* We only process data packets if the interface is open */
  429. if (unlikely(!il->is_open)) {
  430. D_DROP("Dropping packet while interface is not open.\n");
  431. return;
  432. }
  433. if (unlikely(test_bit(IL_STOP_REASON_PASSIVE, &il->stop_reason))) {
  434. il_wake_queues_by_reason(il, IL_STOP_REASON_PASSIVE);
  435. D_INFO("Woke queues - frame received on passive channel\n");
  436. }
  437. skb = dev_alloc_skb(SMALL_PACKET_SIZE);
  438. if (!skb) {
  439. IL_ERR("dev_alloc_skb failed\n");
  440. return;
  441. }
  442. if (!il3945_mod_params.sw_crypto)
  443. il_set_decrypted_flag(il, (struct ieee80211_hdr *)pkt,
  444. le32_to_cpu(rx_end->status), stats);
  445. /* If frame is small enough to fit into skb->head, copy it
  446. * and do not consume a full page
  447. */
  448. if (len <= SMALL_PACKET_SIZE) {
  449. skb_put_data(skb, rx_hdr->payload, len);
  450. } else {
  451. skb_add_rx_frag(skb, 0, rxb->page,
  452. (void *)rx_hdr->payload - (void *)pkt, len,
  453. fraglen);
  454. il->alloc_rxb_page--;
  455. rxb->page = NULL;
  456. }
  457. il_update_stats(il, false, fc, len);
  458. memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats));
  459. ieee80211_rx(il->hw, skb);
  460. }
  461. #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6)
  462. static void
  463. il3945_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb)
  464. {
  465. struct ieee80211_hdr *header;
  466. struct ieee80211_rx_status rx_status = {};
  467. struct il_rx_pkt *pkt = rxb_addr(rxb);
  468. struct il3945_rx_frame_stats *rx_stats = IL_RX_STATS(pkt);
  469. struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt);
  470. struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt);
  471. u16 rx_stats_sig_avg __maybe_unused = le16_to_cpu(rx_stats->sig_avg);
  472. u16 rx_stats_noise_diff __maybe_unused =
  473. le16_to_cpu(rx_stats->noise_diff);
  474. u8 network_packet;
  475. rx_status.flag = 0;
  476. rx_status.mactime = le64_to_cpu(rx_end->timestamp);
  477. rx_status.band =
  478. (rx_hdr->
  479. phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? NL80211_BAND_2GHZ :
  480. NL80211_BAND_5GHZ;
  481. rx_status.freq =
  482. ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel),
  483. rx_status.band);
  484. rx_status.rate_idx = il3945_hwrate_to_plcp_idx(rx_hdr->rate);
  485. if (rx_status.band == NL80211_BAND_5GHZ)
  486. rx_status.rate_idx -= IL_FIRST_OFDM_RATE;
  487. rx_status.antenna =
  488. (le16_to_cpu(rx_hdr->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) >>
  489. 4;
  490. /* set the preamble flag if appropriate */
  491. if (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK)
  492. rx_status.enc_flags |= RX_ENC_FLAG_SHORTPRE;
  493. if ((unlikely(rx_stats->phy_count > 20))) {
  494. D_DROP("dsp size out of range [0,20]: %d\n",
  495. rx_stats->phy_count);
  496. return;
  497. }
  498. if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) ||
  499. !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) {
  500. D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status);
  501. return;
  502. }
  503. /* Convert 3945's rssi indicator to dBm */
  504. rx_status.signal = rx_stats->rssi - IL39_RSSI_OFFSET;
  505. D_STATS("Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal,
  506. rx_stats_sig_avg, rx_stats_noise_diff);
  507. header = (struct ieee80211_hdr *)IL_RX_DATA(pkt);
  508. network_packet = il3945_is_network_packet(il, header);
  509. D_STATS("[%c] %d RSSI:%d Signal:%u, Rate:%u\n",
  510. network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel),
  511. rx_status.signal, rx_status.signal, rx_status.rate_idx);
  512. if (network_packet) {
  513. il->_3945.last_beacon_time =
  514. le32_to_cpu(rx_end->beacon_timestamp);
  515. il->_3945.last_tsf = le64_to_cpu(rx_end->timestamp);
  516. il->_3945.last_rx_rssi = rx_status.signal;
  517. }
  518. il3945_pass_packet_to_mac80211(il, rxb, &rx_status);
  519. }
  520. int
  521. il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq,
  522. dma_addr_t addr, u16 len, u8 reset, u8 pad)
  523. {
  524. int count;
  525. struct il_queue *q;
  526. struct il3945_tfd *tfd, *tfd_tmp;
  527. q = &txq->q;
  528. tfd_tmp = (struct il3945_tfd *)txq->tfds;
  529. tfd = &tfd_tmp[q->write_ptr];
  530. if (reset)
  531. memset(tfd, 0, sizeof(*tfd));
  532. count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags));
  533. if (count >= NUM_TFD_CHUNKS || count < 0) {
  534. IL_ERR("Error can not send more than %d chunks\n",
  535. NUM_TFD_CHUNKS);
  536. return -EINVAL;
  537. }
  538. tfd->tbs[count].addr = cpu_to_le32(addr);
  539. tfd->tbs[count].len = cpu_to_le32(len);
  540. count++;
  541. tfd->control_flags =
  542. cpu_to_le32(TFD_CTL_COUNT_SET(count) | TFD_CTL_PAD_SET(pad));
  543. return 0;
  544. }
  545. /*
  546. * il3945_hw_txq_free_tfd - Free one TFD, those at idx [txq->q.read_ptr]
  547. *
  548. * Does NOT advance any idxes
  549. */
  550. void
  551. il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq)
  552. {
  553. struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds;
  554. int idx = txq->q.read_ptr;
  555. struct il3945_tfd *tfd = &tfd_tmp[idx];
  556. struct pci_dev *dev = il->pci_dev;
  557. int i;
  558. int counter;
  559. /* sanity check */
  560. counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags));
  561. if (counter > NUM_TFD_CHUNKS) {
  562. IL_ERR("Too many chunks: %i\n", counter);
  563. /* @todo issue fatal error, it is quite serious situation */
  564. return;
  565. }
  566. /* Unmap tx_cmd */
  567. if (counter)
  568. dma_unmap_single(&dev->dev,
  569. dma_unmap_addr(&txq->meta[idx], mapping),
  570. dma_unmap_len(&txq->meta[idx], len),
  571. DMA_TO_DEVICE);
  572. /* unmap chunks if any */
  573. for (i = 1; i < counter; i++)
  574. dma_unmap_single(&dev->dev, le32_to_cpu(tfd->tbs[i].addr),
  575. le32_to_cpu(tfd->tbs[i].len), DMA_TO_DEVICE);
  576. /* free SKB */
  577. if (txq->skbs) {
  578. struct sk_buff *skb = txq->skbs[txq->q.read_ptr];
  579. /* can be called from irqs-disabled context */
  580. if (skb) {
  581. dev_kfree_skb_any(skb);
  582. txq->skbs[txq->q.read_ptr] = NULL;
  583. }
  584. }
  585. }
  586. /*
  587. * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD:
  588. *
  589. */
  590. void
  591. il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd,
  592. struct ieee80211_tx_info *info,
  593. struct ieee80211_hdr *hdr, int sta_id)
  594. {
  595. u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value;
  596. u16 rate_idx = min(hw_value & 0xffff, RATE_COUNT_3945 - 1);
  597. u16 rate_mask;
  598. int rate;
  599. const u8 rts_retry_limit = 7;
  600. u8 data_retry_limit;
  601. __le32 tx_flags;
  602. __le16 fc = hdr->frame_control;
  603. struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload;
  604. rate = il3945_rates[rate_idx].plcp;
  605. tx_flags = tx_cmd->tx_flags;
  606. /* We need to figure out how to get the sta->supp_rates while
  607. * in this running context */
  608. rate_mask = RATES_MASK_3945;
  609. /* Set retry limit on DATA packets and Probe Responses */
  610. if (ieee80211_is_probe_resp(fc))
  611. data_retry_limit = 3;
  612. else
  613. data_retry_limit = IL_DEFAULT_TX_RETRY;
  614. tx_cmd->data_retry_limit = data_retry_limit;
  615. /* Set retry limit on RTS packets */
  616. tx_cmd->rts_retry_limit = min(data_retry_limit, rts_retry_limit);
  617. tx_cmd->rate = rate;
  618. tx_cmd->tx_flags = tx_flags;
  619. /* OFDM */
  620. tx_cmd->supp_rates[0] =
  621. ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF;
  622. /* CCK */
  623. tx_cmd->supp_rates[1] = (rate_mask & 0xF);
  624. D_RATE("Tx sta id: %d, rate: %d (plcp), flags: 0x%4X "
  625. "cck/ofdm mask: 0x%x/0x%x\n", sta_id, tx_cmd->rate,
  626. le32_to_cpu(tx_cmd->tx_flags), tx_cmd->supp_rates[1],
  627. tx_cmd->supp_rates[0]);
  628. }
  629. static u8
  630. il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate)
  631. {
  632. unsigned long flags_spin;
  633. struct il_station_entry *station;
  634. if (sta_id == IL_INVALID_STATION)
  635. return IL_INVALID_STATION;
  636. spin_lock_irqsave(&il->sta_lock, flags_spin);
  637. station = &il->stations[sta_id];
  638. station->sta.sta.modify_mask = STA_MODIFY_TX_RATE_MSK;
  639. station->sta.rate_n_flags = cpu_to_le16(tx_rate);
  640. station->sta.mode = STA_CONTROL_MODIFY_MSK;
  641. il_send_add_sta(il, &station->sta, CMD_ASYNC);
  642. spin_unlock_irqrestore(&il->sta_lock, flags_spin);
  643. D_RATE("SCALE sync station %d to rate %d\n", sta_id, tx_rate);
  644. return sta_id;
  645. }
  646. static void
  647. il3945_set_pwr_vmain(struct il_priv *il)
  648. {
  649. /*
  650. * (for documentation purposes)
  651. * to set power to V_AUX, do
  652. if (pci_pme_capable(il->pci_dev, PCI_D3cold)) {
  653. il_set_bits_mask_prph(il, APMG_PS_CTRL_REG,
  654. APMG_PS_CTRL_VAL_PWR_SRC_VAUX,
  655. ~APMG_PS_CTRL_MSK_PWR_SRC);
  656. _il_poll_bit(il, CSR_GPIO_IN,
  657. CSR_GPIO_IN_VAL_VAUX_PWR_SRC,
  658. CSR_GPIO_IN_BIT_AUX_POWER, 5000);
  659. }
  660. */
  661. il_set_bits_mask_prph(il, APMG_PS_CTRL_REG,
  662. APMG_PS_CTRL_VAL_PWR_SRC_VMAIN,
  663. ~APMG_PS_CTRL_MSK_PWR_SRC);
  664. _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC,
  665. CSR_GPIO_IN_BIT_AUX_POWER, 5000);
  666. }
  667. static int
  668. il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq)
  669. {
  670. il_wr(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma);
  671. il_wr(il, FH39_RCSR_RPTR_ADDR(0), rxq->rb_stts_dma);
  672. il_wr(il, FH39_RCSR_WPTR(0), 0);
  673. il_wr(il, FH39_RCSR_CONFIG(0),
  674. FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE |
  675. FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE |
  676. FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN |
  677. FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 | (RX_QUEUE_SIZE_LOG
  678. <<
  679. FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE)
  680. | FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST | (1 <<
  681. FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH)
  682. | FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH);
  683. /* fake read to flush all prev I/O */
  684. il_rd(il, FH39_RSSR_CTRL);
  685. return 0;
  686. }
  687. static int
  688. il3945_tx_reset(struct il_priv *il)
  689. {
  690. /* bypass mode */
  691. il_wr_prph(il, ALM_SCD_MODE_REG, 0x2);
  692. /* RA 0 is active */
  693. il_wr_prph(il, ALM_SCD_ARASTAT_REG, 0x01);
  694. /* all 6 fifo are active */
  695. il_wr_prph(il, ALM_SCD_TXFACT_REG, 0x3f);
  696. il_wr_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000);
  697. il_wr_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002);
  698. il_wr_prph(il, ALM_SCD_TXF4MF_REG, 0x000004);
  699. il_wr_prph(il, ALM_SCD_TXF5MF_REG, 0x000005);
  700. il_wr(il, FH39_TSSR_CBB_BASE, il->_3945.shared_phys);
  701. il_wr(il, FH39_TSSR_MSG_CONFIG,
  702. FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON |
  703. FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON |
  704. FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B |
  705. FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON |
  706. FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON |
  707. FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH |
  708. FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH);
  709. return 0;
  710. }
  711. /*
  712. * il3945_txq_ctx_reset - Reset TX queue context
  713. *
  714. * Destroys all DMA structures and initialize them again
  715. */
  716. static int
  717. il3945_txq_ctx_reset(struct il_priv *il)
  718. {
  719. int rc, txq_id;
  720. il3945_hw_txq_ctx_free(il);
  721. /* allocate tx queue structure */
  722. rc = il_alloc_txq_mem(il);
  723. if (rc)
  724. return rc;
  725. /* Tx CMD queue */
  726. rc = il3945_tx_reset(il);
  727. if (rc)
  728. goto error;
  729. /* Tx queue(s) */
  730. for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) {
  731. rc = il_tx_queue_init(il, txq_id);
  732. if (rc) {
  733. IL_ERR("Tx %d queue init failed\n", txq_id);
  734. goto error;
  735. }
  736. }
  737. return rc;
  738. error:
  739. il3945_hw_txq_ctx_free(il);
  740. return rc;
  741. }
  742. /*
  743. * Start up 3945's basic functionality after it has been reset
  744. * (e.g. after platform boot, or shutdown via il_apm_stop())
  745. * NOTE: This does not load uCode nor start the embedded processor
  746. */
  747. static int
  748. il3945_apm_init(struct il_priv *il)
  749. {
  750. int ret = il_apm_init(il);
  751. /* Clear APMG (NIC's internal power management) interrupts */
  752. il_wr_prph(il, APMG_RTC_INT_MSK_REG, 0x0);
  753. il_wr_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF);
  754. /* Reset radio chip */
  755. il_set_bits_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ);
  756. udelay(5);
  757. il_clear_bits_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ);
  758. return ret;
  759. }
  760. static void
  761. il3945_nic_config(struct il_priv *il)
  762. {
  763. struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom;
  764. unsigned long flags;
  765. u8 rev_id = il->pci_dev->revision;
  766. spin_lock_irqsave(&il->lock, flags);
  767. /* Determine HW type */
  768. D_INFO("HW Revision ID = 0x%X\n", rev_id);
  769. if (rev_id & PCI_CFG_REV_ID_BIT_RTP)
  770. D_INFO("RTP type\n");
  771. else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) {
  772. D_INFO("3945 RADIO-MB type\n");
  773. il_set_bit(il, CSR_HW_IF_CONFIG_REG,
  774. CSR39_HW_IF_CONFIG_REG_BIT_3945_MB);
  775. } else {
  776. D_INFO("3945 RADIO-MM type\n");
  777. il_set_bit(il, CSR_HW_IF_CONFIG_REG,
  778. CSR39_HW_IF_CONFIG_REG_BIT_3945_MM);
  779. }
  780. if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) {
  781. D_INFO("SKU OP mode is mrc\n");
  782. il_set_bit(il, CSR_HW_IF_CONFIG_REG,
  783. CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC);
  784. } else
  785. D_INFO("SKU OP mode is basic\n");
  786. if ((eeprom->board_revision & 0xF0) == 0xD0) {
  787. D_INFO("3945ABG revision is 0x%X\n", eeprom->board_revision);
  788. il_set_bit(il, CSR_HW_IF_CONFIG_REG,
  789. CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE);
  790. } else {
  791. D_INFO("3945ABG revision is 0x%X\n", eeprom->board_revision);
  792. il_clear_bit(il, CSR_HW_IF_CONFIG_REG,
  793. CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE);
  794. }
  795. if (eeprom->almgor_m_version <= 1) {
  796. il_set_bit(il, CSR_HW_IF_CONFIG_REG,
  797. CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A);
  798. D_INFO("Card M type A version is 0x%X\n",
  799. eeprom->almgor_m_version);
  800. } else {
  801. D_INFO("Card M type B version is 0x%X\n",
  802. eeprom->almgor_m_version);
  803. il_set_bit(il, CSR_HW_IF_CONFIG_REG,
  804. CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B);
  805. }
  806. spin_unlock_irqrestore(&il->lock, flags);
  807. if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE)
  808. D_RF_KILL("SW RF KILL supported in EEPROM.\n");
  809. if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE)
  810. D_RF_KILL("HW RF KILL supported in EEPROM.\n");
  811. }
  812. int
  813. il3945_hw_nic_init(struct il_priv *il)
  814. {
  815. int rc;
  816. unsigned long flags;
  817. struct il_rx_queue *rxq = &il->rxq;
  818. spin_lock_irqsave(&il->lock, flags);
  819. il3945_apm_init(il);
  820. spin_unlock_irqrestore(&il->lock, flags);
  821. il3945_set_pwr_vmain(il);
  822. il3945_nic_config(il);
  823. /* Allocate the RX queue, or reset if it is already allocated */
  824. if (!rxq->bd) {
  825. rc = il_rx_queue_alloc(il);
  826. if (rc) {
  827. IL_ERR("Unable to initialize Rx queue\n");
  828. return -ENOMEM;
  829. }
  830. } else
  831. il3945_rx_queue_reset(il, rxq);
  832. il3945_rx_replenish(il);
  833. il3945_rx_init(il, rxq);
  834. /* Look at using this instead:
  835. rxq->need_update = 1;
  836. il_rx_queue_update_write_ptr(il, rxq);
  837. */
  838. il_wr(il, FH39_RCSR_WPTR(0), rxq->write & ~7);
  839. rc = il3945_txq_ctx_reset(il);
  840. if (rc)
  841. return rc;
  842. set_bit(S_INIT, &il->status);
  843. return 0;
  844. }
  845. /*
  846. * il3945_hw_txq_ctx_free - Free TXQ Context
  847. *
  848. * Destroy all TX DMA queues and structures
  849. */
  850. void
  851. il3945_hw_txq_ctx_free(struct il_priv *il)
  852. {
  853. int txq_id;
  854. /* Tx queues */
  855. if (il->txq) {
  856. for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++)
  857. if (txq_id == IL39_CMD_QUEUE_NUM)
  858. il_cmd_queue_free(il);
  859. else
  860. il_tx_queue_free(il, txq_id);
  861. }
  862. /* free tx queue structure */
  863. il_free_txq_mem(il);
  864. }
  865. void
  866. il3945_hw_txq_ctx_stop(struct il_priv *il)
  867. {
  868. int txq_id;
  869. /* stop SCD */
  870. _il_wr_prph(il, ALM_SCD_MODE_REG, 0);
  871. _il_wr_prph(il, ALM_SCD_TXFACT_REG, 0);
  872. /* reset TFD queues */
  873. for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) {
  874. _il_wr(il, FH39_TCSR_CONFIG(txq_id), 0x0);
  875. _il_poll_bit(il, FH39_TSSR_TX_STATUS,
  876. FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id),
  877. FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id),
  878. 1000);
  879. }
  880. }
  881. /*
  882. * il3945_hw_reg_adjust_power_by_temp
  883. * return idx delta into power gain settings table
  884. */
  885. static int
  886. il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading)
  887. {
  888. return (new_reading - old_reading) * (-11) / 100;
  889. }
  890. /*
  891. * il3945_hw_reg_temp_out_of_range - Keep temperature in sane range
  892. */
  893. static inline int
  894. il3945_hw_reg_temp_out_of_range(int temperature)
  895. {
  896. return (temperature < -260 || temperature > 25) ? 1 : 0;
  897. }
  898. int
  899. il3945_hw_get_temperature(struct il_priv *il)
  900. {
  901. return _il_rd(il, CSR_UCODE_DRV_GP2);
  902. }
  903. /*
  904. * il3945_hw_reg_txpower_get_temperature
  905. * get the current temperature by reading from NIC
  906. */
  907. static int
  908. il3945_hw_reg_txpower_get_temperature(struct il_priv *il)
  909. {
  910. struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom;
  911. int temperature;
  912. temperature = il3945_hw_get_temperature(il);
  913. /* driver's okay range is -260 to +25.
  914. * human readable okay range is 0 to +285 */
  915. D_INFO("Temperature: %d\n", temperature + IL_TEMP_CONVERT);
  916. /* handle insane temp reading */
  917. if (il3945_hw_reg_temp_out_of_range(temperature)) {
  918. IL_ERR("Error bad temperature value %d\n", temperature);
  919. /* if really really hot(?),
  920. * substitute the 3rd band/group's temp measured at factory */
  921. if (il->last_temperature > 100)
  922. temperature = eeprom->groups[2].temperature;
  923. else /* else use most recent "sane" value from driver */
  924. temperature = il->last_temperature;
  925. }
  926. return temperature; /* raw, not "human readable" */
  927. }
  928. /* Adjust Txpower only if temperature variance is greater than threshold.
  929. *
  930. * Both are lower than older versions' 9 degrees */
  931. #define IL_TEMPERATURE_LIMIT_TIMER 6
  932. /*
  933. * il3945_is_temp_calib_needed - determines if new calibration is needed
  934. *
  935. * records new temperature in tx_mgr->temperature.
  936. * replaces tx_mgr->last_temperature *only* if calib needed
  937. * (assumes caller will actually do the calibration!). */
  938. static int
  939. il3945_is_temp_calib_needed(struct il_priv *il)
  940. {
  941. int temp_diff;
  942. il->temperature = il3945_hw_reg_txpower_get_temperature(il);
  943. temp_diff = il->temperature - il->last_temperature;
  944. /* get absolute value */
  945. if (temp_diff < 0) {
  946. D_POWER("Getting cooler, delta %d,\n", temp_diff);
  947. temp_diff = -temp_diff;
  948. } else if (temp_diff == 0)
  949. D_POWER("Same temp,\n");
  950. else
  951. D_POWER("Getting warmer, delta %d,\n", temp_diff);
  952. /* if we don't need calibration, *don't* update last_temperature */
  953. if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) {
  954. D_POWER("Timed thermal calib not needed\n");
  955. return 0;
  956. }
  957. D_POWER("Timed thermal calib needed\n");
  958. /* assume that caller will actually do calib ...
  959. * update the "last temperature" value */
  960. il->last_temperature = il->temperature;
  961. return 1;
  962. }
  963. #define IL_MAX_GAIN_ENTRIES 78
  964. #define IL_CCK_FROM_OFDM_POWER_DIFF -5
  965. #define IL_CCK_FROM_OFDM_IDX_DIFF (10)
  966. /* radio and DSP power table, each step is 1/2 dB.
  967. * 1st number is for RF analog gain, 2nd number is for DSP pre-DAC gain. */
  968. static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = {
  969. {
  970. {251, 127}, /* 2.4 GHz, highest power */
  971. {251, 127},
  972. {251, 127},
  973. {251, 127},
  974. {251, 125},
  975. {251, 110},
  976. {251, 105},
  977. {251, 98},
  978. {187, 125},
  979. {187, 115},
  980. {187, 108},
  981. {187, 99},
  982. {243, 119},
  983. {243, 111},
  984. {243, 105},
  985. {243, 97},
  986. {243, 92},
  987. {211, 106},
  988. {211, 100},
  989. {179, 120},
  990. {179, 113},
  991. {179, 107},
  992. {147, 125},
  993. {147, 119},
  994. {147, 112},
  995. {147, 106},
  996. {147, 101},
  997. {147, 97},
  998. {147, 91},
  999. {115, 107},
  1000. {235, 121},
  1001. {235, 115},
  1002. {235, 109},
  1003. {203, 127},
  1004. {203, 121},
  1005. {203, 115},
  1006. {203, 108},
  1007. {203, 102},
  1008. {203, 96},
  1009. {203, 92},
  1010. {171, 110},
  1011. {171, 104},
  1012. {171, 98},
  1013. {139, 116},
  1014. {227, 125},
  1015. {227, 119},
  1016. {227, 113},
  1017. {227, 107},
  1018. {227, 101},
  1019. {227, 96},
  1020. {195, 113},
  1021. {195, 106},
  1022. {195, 102},
  1023. {195, 95},
  1024. {163, 113},
  1025. {163, 106},
  1026. {163, 102},
  1027. {163, 95},
  1028. {131, 113},
  1029. {131, 106},
  1030. {131, 102},
  1031. {131, 95},
  1032. {99, 113},
  1033. {99, 106},
  1034. {99, 102},
  1035. {99, 95},
  1036. {67, 113},
  1037. {67, 106},
  1038. {67, 102},
  1039. {67, 95},
  1040. {35, 113},
  1041. {35, 106},
  1042. {35, 102},
  1043. {35, 95},
  1044. {3, 113},
  1045. {3, 106},
  1046. {3, 102},
  1047. {3, 95} /* 2.4 GHz, lowest power */
  1048. },
  1049. {
  1050. {251, 127}, /* 5.x GHz, highest power */
  1051. {251, 120},
  1052. {251, 114},
  1053. {219, 119},
  1054. {219, 101},
  1055. {187, 113},
  1056. {187, 102},
  1057. {155, 114},
  1058. {155, 103},
  1059. {123, 117},
  1060. {123, 107},
  1061. {123, 99},
  1062. {123, 92},
  1063. {91, 108},
  1064. {59, 125},
  1065. {59, 118},
  1066. {59, 109},
  1067. {59, 102},
  1068. {59, 96},
  1069. {59, 90},
  1070. {27, 104},
  1071. {27, 98},
  1072. {27, 92},
  1073. {115, 118},
  1074. {115, 111},
  1075. {115, 104},
  1076. {83, 126},
  1077. {83, 121},
  1078. {83, 113},
  1079. {83, 105},
  1080. {83, 99},
  1081. {51, 118},
  1082. {51, 111},
  1083. {51, 104},
  1084. {51, 98},
  1085. {19, 116},
  1086. {19, 109},
  1087. {19, 102},
  1088. {19, 98},
  1089. {19, 93},
  1090. {171, 113},
  1091. {171, 107},
  1092. {171, 99},
  1093. {139, 120},
  1094. {139, 113},
  1095. {139, 107},
  1096. {139, 99},
  1097. {107, 120},
  1098. {107, 113},
  1099. {107, 107},
  1100. {107, 99},
  1101. {75, 120},
  1102. {75, 113},
  1103. {75, 107},
  1104. {75, 99},
  1105. {43, 120},
  1106. {43, 113},
  1107. {43, 107},
  1108. {43, 99},
  1109. {11, 120},
  1110. {11, 113},
  1111. {11, 107},
  1112. {11, 99},
  1113. {131, 107},
  1114. {131, 99},
  1115. {99, 120},
  1116. {99, 113},
  1117. {99, 107},
  1118. {99, 99},
  1119. {67, 120},
  1120. {67, 113},
  1121. {67, 107},
  1122. {67, 99},
  1123. {35, 120},
  1124. {35, 113},
  1125. {35, 107},
  1126. {35, 99},
  1127. {3, 120} /* 5.x GHz, lowest power */
  1128. }
  1129. };
  1130. static inline u8
  1131. il3945_hw_reg_fix_power_idx(int idx)
  1132. {
  1133. if (idx < 0)
  1134. return 0;
  1135. if (idx >= IL_MAX_GAIN_ENTRIES)
  1136. return IL_MAX_GAIN_ENTRIES - 1;
  1137. return (u8) idx;
  1138. }
  1139. /* Kick off thermal recalibration check every 60 seconds */
  1140. #define REG_RECALIB_PERIOD (60)
  1141. /*
  1142. * il3945_hw_reg_set_scan_power - Set Tx power for scan probe requests
  1143. *
  1144. * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK)
  1145. * or 6 Mbit (OFDM) rates.
  1146. */
  1147. static void
  1148. il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, s32 rate_idx,
  1149. const s8 *clip_pwrs,
  1150. struct il_channel_info *ch_info, int band_idx)
  1151. {
  1152. struct il3945_scan_power_info *scan_power_info;
  1153. s8 power;
  1154. u8 power_idx;
  1155. scan_power_info = &ch_info->scan_pwr_info[scan_tbl_idx];
  1156. /* use this channel group's 6Mbit clipping/saturation pwr,
  1157. * but cap at regulatory scan power restriction (set during init
  1158. * based on eeprom channel data) for this channel. */
  1159. power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TBL]);
  1160. power = min(power, il->tx_power_user_lmt);
  1161. scan_power_info->requested_power = power;
  1162. /* find difference between new scan *power* and current "normal"
  1163. * Tx *power* for 6Mb. Use this difference (x2) to adjust the
  1164. * current "normal" temperature-compensated Tx power *idx* for
  1165. * this rate (1Mb or 6Mb) to yield new temp-compensated scan power
  1166. * *idx*. */
  1167. power_idx =
  1168. ch_info->power_info[rate_idx].power_table_idx - (power -
  1169. ch_info->
  1170. power_info
  1171. [RATE_6M_IDX_TBL].
  1172. requested_power) *
  1173. 2;
  1174. /* store reference idx that we use when adjusting *all* scan
  1175. * powers. So we can accommodate user (all channel) or spectrum
  1176. * management (single channel) power changes "between" temperature
  1177. * feedback compensation procedures.
  1178. * don't force fit this reference idx into gain table; it may be a
  1179. * negative number. This will help avoid errors when we're at
  1180. * the lower bounds (highest gains, for warmest temperatures)
  1181. * of the table. */
  1182. /* don't exceed table bounds for "real" setting */
  1183. power_idx = il3945_hw_reg_fix_power_idx(power_idx);
  1184. scan_power_info->power_table_idx = power_idx;
  1185. scan_power_info->tpc.tx_gain =
  1186. power_gain_table[band_idx][power_idx].tx_gain;
  1187. scan_power_info->tpc.dsp_atten =
  1188. power_gain_table[band_idx][power_idx].dsp_atten;
  1189. }
  1190. /*
  1191. * il3945_send_tx_power - fill in Tx Power command with gain settings
  1192. *
  1193. * Configures power settings for all rates for the current channel,
  1194. * using values from channel info struct, and send to NIC
  1195. */
  1196. static int
  1197. il3945_send_tx_power(struct il_priv *il)
  1198. {
  1199. int rate_idx, i;
  1200. const struct il_channel_info *ch_info = NULL;
  1201. struct il3945_txpowertable_cmd txpower = {
  1202. .channel = il->active.channel,
  1203. };
  1204. u16 chan;
  1205. if (WARN_ONCE
  1206. (test_bit(S_SCAN_HW, &il->status),
  1207. "TX Power requested while scanning!\n"))
  1208. return -EAGAIN;
  1209. chan = le16_to_cpu(il->active.channel);
  1210. txpower.band = (il->band == NL80211_BAND_5GHZ) ? 0 : 1;
  1211. ch_info = il_get_channel_info(il, il->band, chan);
  1212. if (!ch_info) {
  1213. IL_ERR("Failed to get channel info for channel %d [%d]\n", chan,
  1214. il->band);
  1215. return -EINVAL;
  1216. }
  1217. if (!il_is_channel_valid(ch_info)) {
  1218. D_POWER("Not calling TX_PWR_TBL_CMD on " "non-Tx channel.\n");
  1219. return 0;
  1220. }
  1221. /* fill cmd with power settings for all rates for current channel */
  1222. /* Fill OFDM rate */
  1223. for (rate_idx = IL_FIRST_OFDM_RATE, i = 0;
  1224. rate_idx <= IL39_LAST_OFDM_RATE; rate_idx++, i++) {
  1225. txpower.power[i].tpc = ch_info->power_info[i].tpc;
  1226. txpower.power[i].rate = il3945_rates[rate_idx].plcp;
  1227. D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n",
  1228. le16_to_cpu(txpower.channel), txpower.band,
  1229. txpower.power[i].tpc.tx_gain,
  1230. txpower.power[i].tpc.dsp_atten, txpower.power[i].rate);
  1231. }
  1232. /* Fill CCK rates */
  1233. for (rate_idx = IL_FIRST_CCK_RATE; rate_idx <= IL_LAST_CCK_RATE;
  1234. rate_idx++, i++) {
  1235. txpower.power[i].tpc = ch_info->power_info[i].tpc;
  1236. txpower.power[i].rate = il3945_rates[rate_idx].plcp;
  1237. D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n",
  1238. le16_to_cpu(txpower.channel), txpower.band,
  1239. txpower.power[i].tpc.tx_gain,
  1240. txpower.power[i].tpc.dsp_atten, txpower.power[i].rate);
  1241. }
  1242. return il_send_cmd_pdu(il, C_TX_PWR_TBL,
  1243. sizeof(struct il3945_txpowertable_cmd),
  1244. &txpower);
  1245. }
  1246. /*
  1247. * il3945_hw_reg_set_new_power - Configures power tables at new levels
  1248. * @ch_info: Channel to update. Uses power_info.requested_power.
  1249. *
  1250. * Replace requested_power and base_power_idx ch_info fields for
  1251. * one channel.
  1252. *
  1253. * Called if user or spectrum management changes power preferences.
  1254. * Takes into account h/w and modulation limitations (clip power).
  1255. *
  1256. * This does *not* send anything to NIC, just sets up ch_info for one channel.
  1257. *
  1258. * NOTE: reg_compensate_for_temperature_dif() *must* be run after this to
  1259. * properly fill out the scan powers, and actual h/w gain settings,
  1260. * and send changes to NIC
  1261. */
  1262. static int
  1263. il3945_hw_reg_set_new_power(struct il_priv *il, struct il_channel_info *ch_info)
  1264. {
  1265. struct il3945_channel_power_info *power_info;
  1266. int power_changed = 0;
  1267. int i;
  1268. const s8 *clip_pwrs;
  1269. int power;
  1270. /* Get this chnlgrp's rate-to-max/clip-powers table */
  1271. clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers;
  1272. /* Get this channel's rate-to-current-power settings table */
  1273. power_info = ch_info->power_info;
  1274. /* update OFDM Txpower settings */
  1275. for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; i++, ++power_info) {
  1276. int delta_idx;
  1277. /* limit new power to be no more than h/w capability */
  1278. power = min(ch_info->curr_txpow, clip_pwrs[i]);
  1279. if (power == power_info->requested_power)
  1280. continue;
  1281. /* find difference between old and new requested powers,
  1282. * update base (non-temp-compensated) power idx */
  1283. delta_idx = (power - power_info->requested_power) * 2;
  1284. power_info->base_power_idx -= delta_idx;
  1285. /* save new requested power value */
  1286. power_info->requested_power = power;
  1287. power_changed = 1;
  1288. }
  1289. /* update CCK Txpower settings, based on OFDM 12M setting ...
  1290. * ... all CCK power settings for a given channel are the *same*. */
  1291. if (power_changed) {
  1292. power =
  1293. ch_info->power_info[RATE_12M_IDX_TBL].requested_power +
  1294. IL_CCK_FROM_OFDM_POWER_DIFF;
  1295. /* do all CCK rates' il3945_channel_power_info structures */
  1296. for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) {
  1297. power_info->requested_power = power;
  1298. power_info->base_power_idx =
  1299. ch_info->power_info[RATE_12M_IDX_TBL].
  1300. base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF;
  1301. ++power_info;
  1302. }
  1303. }
  1304. return 0;
  1305. }
  1306. /*
  1307. * il3945_hw_reg_get_ch_txpower_limit - returns new power limit for channel
  1308. *
  1309. * NOTE: Returned power limit may be less (but not more) than requested,
  1310. * based strictly on regulatory (eeprom and spectrum mgt) limitations
  1311. * (no consideration for h/w clipping limitations).
  1312. */
  1313. static int
  1314. il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info)
  1315. {
  1316. s8 max_power;
  1317. #if 0
  1318. /* if we're using TGd limits, use lower of TGd or EEPROM */
  1319. if (ch_info->tgd_data.max_power != 0)
  1320. max_power =
  1321. min(ch_info->tgd_data.max_power,
  1322. ch_info->eeprom.max_power_avg);
  1323. /* else just use EEPROM limits */
  1324. else
  1325. #endif
  1326. max_power = ch_info->eeprom.max_power_avg;
  1327. return min(max_power, ch_info->max_power_avg);
  1328. }
  1329. /*
  1330. * il3945_hw_reg_comp_txpower_temp - Compensate for temperature
  1331. *
  1332. * Compensate txpower settings of *all* channels for temperature.
  1333. * This only accounts for the difference between current temperature
  1334. * and the factory calibration temperatures, and bases the new settings
  1335. * on the channel's base_power_idx.
  1336. *
  1337. * If RxOn is "associated", this sends the new Txpower to NIC!
  1338. */
  1339. static int
  1340. il3945_hw_reg_comp_txpower_temp(struct il_priv *il)
  1341. {
  1342. struct il_channel_info *ch_info = NULL;
  1343. struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom;
  1344. int delta_idx;
  1345. const s8 *clip_pwrs; /* array of h/w max power levels for each rate */
  1346. u8 a_band;
  1347. u8 rate_idx;
  1348. u8 scan_tbl_idx;
  1349. u8 i;
  1350. int ref_temp;
  1351. int temperature = il->temperature;
  1352. if (il->disable_tx_power_cal || test_bit(S_SCANNING, &il->status)) {
  1353. /* do not perform tx power calibration */
  1354. return 0;
  1355. }
  1356. /* set up new Tx power info for each and every channel, 2.4 and 5.x */
  1357. for (i = 0; i < il->channel_count; i++) {
  1358. ch_info = &il->channel_info[i];
  1359. a_band = il_is_channel_a_band(ch_info);
  1360. /* Get this chnlgrp's factory calibration temperature */
  1361. ref_temp = (s16) eeprom->groups[ch_info->group_idx].temperature;
  1362. /* get power idx adjustment based on current and factory
  1363. * temps */
  1364. delta_idx =
  1365. il3945_hw_reg_adjust_power_by_temp(temperature, ref_temp);
  1366. /* set tx power value for all rates, OFDM and CCK */
  1367. for (rate_idx = 0; rate_idx < RATE_COUNT_3945; rate_idx++) {
  1368. int power_idx =
  1369. ch_info->power_info[rate_idx].base_power_idx;
  1370. /* temperature compensate */
  1371. power_idx += delta_idx;
  1372. /* stay within table range */
  1373. power_idx = il3945_hw_reg_fix_power_idx(power_idx);
  1374. ch_info->power_info[rate_idx].power_table_idx =
  1375. (u8) power_idx;
  1376. ch_info->power_info[rate_idx].tpc =
  1377. power_gain_table[a_band][power_idx];
  1378. }
  1379. /* Get this chnlgrp's rate-to-max/clip-powers table */
  1380. clip_pwrs =
  1381. il->_3945.clip_groups[ch_info->group_idx].clip_powers;
  1382. /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */
  1383. for (scan_tbl_idx = 0; scan_tbl_idx < IL_NUM_SCAN_RATES;
  1384. scan_tbl_idx++) {
  1385. s32 actual_idx =
  1386. (scan_tbl_idx ==
  1387. 0) ? RATE_1M_IDX_TBL : RATE_6M_IDX_TBL;
  1388. il3945_hw_reg_set_scan_power(il, scan_tbl_idx,
  1389. actual_idx, clip_pwrs,
  1390. ch_info, a_band);
  1391. }
  1392. }
  1393. /* send Txpower command for current channel to ucode */
  1394. return il->ops->send_tx_power(il);
  1395. }
  1396. int
  1397. il3945_hw_reg_set_txpower(struct il_priv *il, s8 power)
  1398. {
  1399. struct il_channel_info *ch_info;
  1400. s8 max_power;
  1401. u8 i;
  1402. if (il->tx_power_user_lmt == power) {
  1403. D_POWER("Requested Tx power same as current " "limit: %ddBm.\n",
  1404. power);
  1405. return 0;
  1406. }
  1407. D_POWER("Setting upper limit clamp to %ddBm.\n", power);
  1408. il->tx_power_user_lmt = power;
  1409. /* set up new Tx powers for each and every channel, 2.4 and 5.x */
  1410. for (i = 0; i < il->channel_count; i++) {
  1411. ch_info = &il->channel_info[i];
  1412. /* find minimum power of all user and regulatory constraints
  1413. * (does not consider h/w clipping limitations) */
  1414. max_power = il3945_hw_reg_get_ch_txpower_limit(ch_info);
  1415. max_power = min(power, max_power);
  1416. if (max_power != ch_info->curr_txpow) {
  1417. ch_info->curr_txpow = max_power;
  1418. /* this considers the h/w clipping limitations */
  1419. il3945_hw_reg_set_new_power(il, ch_info);
  1420. }
  1421. }
  1422. /* update txpower settings for all channels,
  1423. * send to NIC if associated. */
  1424. il3945_is_temp_calib_needed(il);
  1425. il3945_hw_reg_comp_txpower_temp(il);
  1426. return 0;
  1427. }
  1428. static int
  1429. il3945_send_rxon_assoc(struct il_priv *il)
  1430. {
  1431. int rc = 0;
  1432. struct il_rx_pkt *pkt;
  1433. struct il3945_rxon_assoc_cmd rxon_assoc;
  1434. struct il_host_cmd cmd = {
  1435. .id = C_RXON_ASSOC,
  1436. .len = sizeof(rxon_assoc),
  1437. .flags = CMD_WANT_SKB,
  1438. .data = &rxon_assoc,
  1439. };
  1440. const struct il_rxon_cmd *rxon1 = &il->staging;
  1441. const struct il_rxon_cmd *rxon2 = &il->active;
  1442. if (rxon1->flags == rxon2->flags &&
  1443. rxon1->filter_flags == rxon2->filter_flags &&
  1444. rxon1->cck_basic_rates == rxon2->cck_basic_rates &&
  1445. rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) {
  1446. D_INFO("Using current RXON_ASSOC. Not resending.\n");
  1447. return 0;
  1448. }
  1449. rxon_assoc.flags = il->staging.flags;
  1450. rxon_assoc.filter_flags = il->staging.filter_flags;
  1451. rxon_assoc.ofdm_basic_rates = il->staging.ofdm_basic_rates;
  1452. rxon_assoc.cck_basic_rates = il->staging.cck_basic_rates;
  1453. rxon_assoc.reserved = 0;
  1454. rc = il_send_cmd_sync(il, &cmd);
  1455. if (rc)
  1456. return rc;
  1457. pkt = (struct il_rx_pkt *)cmd.reply_page;
  1458. if (pkt->hdr.flags & IL_CMD_FAILED_MSK) {
  1459. IL_ERR("Bad return from C_RXON_ASSOC command\n");
  1460. rc = -EIO;
  1461. }
  1462. il_free_pages(il, cmd.reply_page);
  1463. return rc;
  1464. }
  1465. /*
  1466. * il3945_commit_rxon - commit staging_rxon to hardware
  1467. *
  1468. * The RXON command in staging_rxon is committed to the hardware and
  1469. * the active_rxon structure is updated with the new data. This
  1470. * function correctly transitions out of the RXON_ASSOC_MSK state if
  1471. * a HW tune is required based on the RXON structure changes.
  1472. */
  1473. int
  1474. il3945_commit_rxon(struct il_priv *il)
  1475. {
  1476. /* cast away the const for active_rxon in this function */
  1477. struct il3945_rxon_cmd *active_rxon = (void *)&il->active;
  1478. struct il3945_rxon_cmd *staging_rxon = (void *)&il->staging;
  1479. int rc = 0;
  1480. bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK);
  1481. if (test_bit(S_EXIT_PENDING, &il->status))
  1482. return -EINVAL;
  1483. if (!il_is_alive(il))
  1484. return -1;
  1485. /* always get timestamp with Rx frame */
  1486. staging_rxon->flags |= RXON_FLG_TSF2HOST_MSK;
  1487. /* select antenna */
  1488. staging_rxon->flags &= ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK);
  1489. staging_rxon->flags |= il3945_get_antenna_flags(il);
  1490. rc = il_check_rxon_cmd(il);
  1491. if (rc) {
  1492. IL_ERR("Invalid RXON configuration. Not committing.\n");
  1493. return -EINVAL;
  1494. }
  1495. /* If we don't need to send a full RXON, we can use
  1496. * il3945_rxon_assoc_cmd which is used to reconfigure filter
  1497. * and other flags for the current radio configuration. */
  1498. if (!il_full_rxon_required(il)) {
  1499. rc = il_send_rxon_assoc(il);
  1500. if (rc) {
  1501. IL_ERR("Error setting RXON_ASSOC "
  1502. "configuration (%d).\n", rc);
  1503. return rc;
  1504. }
  1505. memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
  1506. /*
  1507. * We do not commit tx power settings while channel changing,
  1508. * do it now if tx power changed.
  1509. */
  1510. il_set_tx_power(il, il->tx_power_next, false);
  1511. return 0;
  1512. }
  1513. /* If we are currently associated and the new config requires
  1514. * an RXON_ASSOC and the new config wants the associated mask enabled,
  1515. * we must clear the associated from the active configuration
  1516. * before we apply the new config */
  1517. if (il_is_associated(il) && new_assoc) {
  1518. D_INFO("Toggling associated bit on current RXON\n");
  1519. active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK;
  1520. /*
  1521. * reserved4 and 5 could have been filled by the iwlcore code.
  1522. * Let's clear them before pushing to the 3945.
  1523. */
  1524. active_rxon->reserved4 = 0;
  1525. active_rxon->reserved5 = 0;
  1526. rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd),
  1527. &il->active);
  1528. /* If the mask clearing failed then we set
  1529. * active_rxon back to what it was previously */
  1530. if (rc) {
  1531. active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK;
  1532. IL_ERR("Error clearing ASSOC_MSK on current "
  1533. "configuration (%d).\n", rc);
  1534. return rc;
  1535. }
  1536. il_clear_ucode_stations(il);
  1537. il_restore_stations(il);
  1538. }
  1539. D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n"
  1540. "* channel = %d\n" "* bssid = %pM\n", (new_assoc ? "" : "out"),
  1541. le16_to_cpu(staging_rxon->channel), staging_rxon->bssid_addr);
  1542. /*
  1543. * reserved4 and 5 could have been filled by the iwlcore code.
  1544. * Let's clear them before pushing to the 3945.
  1545. */
  1546. staging_rxon->reserved4 = 0;
  1547. staging_rxon->reserved5 = 0;
  1548. il_set_rxon_hwcrypto(il, !il3945_mod_params.sw_crypto);
  1549. /* Apply the new configuration */
  1550. rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd),
  1551. staging_rxon);
  1552. if (rc) {
  1553. IL_ERR("Error setting new configuration (%d).\n", rc);
  1554. return rc;
  1555. }
  1556. memcpy(active_rxon, staging_rxon, sizeof(*active_rxon));
  1557. if (!new_assoc) {
  1558. il_clear_ucode_stations(il);
  1559. il_restore_stations(il);
  1560. }
  1561. /* If we issue a new RXON command which required a tune then we must
  1562. * send a new TXPOWER command or we won't be able to Tx any frames */
  1563. rc = il_set_tx_power(il, il->tx_power_next, true);
  1564. if (rc) {
  1565. IL_ERR("Error setting Tx power (%d).\n", rc);
  1566. return rc;
  1567. }
  1568. /* Init the hardware's rate fallback order based on the band */
  1569. rc = il3945_init_hw_rate_table(il);
  1570. if (rc) {
  1571. IL_ERR("Error setting HW rate table: %02X\n", rc);
  1572. return -EIO;
  1573. }
  1574. return 0;
  1575. }
  1576. /*
  1577. * il3945_reg_txpower_periodic - called when time to check our temperature.
  1578. *
  1579. * -- reset periodic timer
  1580. * -- see if temp has changed enough to warrant re-calibration ... if so:
  1581. * -- correct coeffs for temp (can reset temp timer)
  1582. * -- save this temp as "last",
  1583. * -- send new set of gain settings to NIC
  1584. * NOTE: This should continue working, even when we're not associated,
  1585. * so we can keep our internal table of scan powers current. */
  1586. void
  1587. il3945_reg_txpower_periodic(struct il_priv *il)
  1588. {
  1589. /* This will kick in the "brute force"
  1590. * il3945_hw_reg_comp_txpower_temp() below */
  1591. if (!il3945_is_temp_calib_needed(il))
  1592. goto reschedule;
  1593. /* Set up a new set of temp-adjusted TxPowers, send to NIC.
  1594. * This is based *only* on current temperature,
  1595. * ignoring any previous power measurements */
  1596. il3945_hw_reg_comp_txpower_temp(il);
  1597. reschedule:
  1598. queue_delayed_work(il->workqueue, &il->_3945.thermal_periodic,
  1599. REG_RECALIB_PERIOD * HZ);
  1600. }
  1601. static void
  1602. il3945_bg_reg_txpower_periodic(struct work_struct *work)
  1603. {
  1604. struct il_priv *il = container_of(work, struct il_priv,
  1605. _3945.thermal_periodic.work);
  1606. mutex_lock(&il->mutex);
  1607. if (test_bit(S_EXIT_PENDING, &il->status) || il->txq == NULL)
  1608. goto out;
  1609. il3945_reg_txpower_periodic(il);
  1610. out:
  1611. mutex_unlock(&il->mutex);
  1612. }
  1613. /*
  1614. * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) for channel.
  1615. *
  1616. * This function is used when initializing channel-info structs.
  1617. *
  1618. * NOTE: These channel groups do *NOT* match the bands above!
  1619. * These channel groups are based on factory-tested channels;
  1620. * on A-band, EEPROM's "group frequency" entries represent the top
  1621. * channel in each group 1-4. Group 5 All B/G channels are in group 0.
  1622. */
  1623. static u16
  1624. il3945_hw_reg_get_ch_grp_idx(struct il_priv *il,
  1625. const struct il_channel_info *ch_info)
  1626. {
  1627. struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom;
  1628. struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0];
  1629. u8 group;
  1630. u16 group_idx = 0; /* based on factory calib frequencies */
  1631. u8 grp_channel;
  1632. /* Find the group idx for the channel ... don't use idx 1(?) */
  1633. if (il_is_channel_a_band(ch_info)) {
  1634. for (group = 1; group < 5; group++) {
  1635. grp_channel = ch_grp[group].group_channel;
  1636. if (ch_info->channel <= grp_channel) {
  1637. group_idx = group;
  1638. break;
  1639. }
  1640. }
  1641. /* group 4 has a few channels *above* its factory cal freq */
  1642. if (group == 5)
  1643. group_idx = 4;
  1644. } else
  1645. group_idx = 0; /* 2.4 GHz, group 0 */
  1646. D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, group_idx);
  1647. return group_idx;
  1648. }
  1649. /*
  1650. * il3945_hw_reg_get_matched_power_idx - Interpolate to get nominal idx
  1651. *
  1652. * Interpolate to get nominal (i.e. at factory calibration temperature) idx
  1653. * into radio/DSP gain settings table for requested power.
  1654. */
  1655. static int
  1656. il3945_hw_reg_get_matched_power_idx(struct il_priv *il, s8 requested_power,
  1657. s32 setting_idx, s32 *new_idx)
  1658. {
  1659. const struct il3945_eeprom_txpower_group *chnl_grp = NULL;
  1660. struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom;
  1661. s32 idx0, idx1;
  1662. s32 power = 2 * requested_power;
  1663. s32 i;
  1664. const struct il3945_eeprom_txpower_sample *samples;
  1665. s32 gains0, gains1;
  1666. s32 res;
  1667. s32 denominator;
  1668. chnl_grp = &eeprom->groups[setting_idx];
  1669. samples = chnl_grp->samples;
  1670. for (i = 0; i < 5; i++) {
  1671. if (power == samples[i].power) {
  1672. *new_idx = samples[i].gain_idx;
  1673. return 0;
  1674. }
  1675. }
  1676. if (power > samples[1].power) {
  1677. idx0 = 0;
  1678. idx1 = 1;
  1679. } else if (power > samples[2].power) {
  1680. idx0 = 1;
  1681. idx1 = 2;
  1682. } else if (power > samples[3].power) {
  1683. idx0 = 2;
  1684. idx1 = 3;
  1685. } else {
  1686. idx0 = 3;
  1687. idx1 = 4;
  1688. }
  1689. denominator = (s32) samples[idx1].power - (s32) samples[idx0].power;
  1690. if (denominator == 0)
  1691. return -EINVAL;
  1692. gains0 = (s32) samples[idx0].gain_idx * (1 << 19);
  1693. gains1 = (s32) samples[idx1].gain_idx * (1 << 19);
  1694. res =
  1695. gains0 + (gains1 - gains0) * ((s32) power -
  1696. (s32) samples[idx0].power) /
  1697. denominator + (1 << 18);
  1698. *new_idx = res >> 19;
  1699. return 0;
  1700. }
  1701. static void
  1702. il3945_hw_reg_init_channel_groups(struct il_priv *il)
  1703. {
  1704. u32 i;
  1705. s32 rate_idx;
  1706. struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom;
  1707. const struct il3945_eeprom_txpower_group *group;
  1708. D_POWER("Initializing factory calib info from EEPROM\n");
  1709. for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) {
  1710. s8 *clip_pwrs; /* table of power levels for each rate */
  1711. s8 satur_pwr; /* saturation power for each chnl group */
  1712. group = &eeprom->groups[i];
  1713. /* sanity check on factory saturation power value */
  1714. if (group->saturation_power < 40) {
  1715. IL_WARN("Error: saturation power is %d, "
  1716. "less than minimum expected 40\n",
  1717. group->saturation_power);
  1718. return;
  1719. }
  1720. /*
  1721. * Derive requested power levels for each rate, based on
  1722. * hardware capabilities (saturation power for band).
  1723. * Basic value is 3dB down from saturation, with further
  1724. * power reductions for highest 3 data rates. These
  1725. * backoffs provide headroom for high rate modulation
  1726. * power peaks, without too much distortion (clipping).
  1727. */
  1728. /* we'll fill in this array with h/w max power levels */
  1729. clip_pwrs = (s8 *) il->_3945.clip_groups[i].clip_powers;
  1730. /* divide factory saturation power by 2 to find -3dB level */
  1731. satur_pwr = (s8) (group->saturation_power >> 1);
  1732. /* fill in channel group's nominal powers for each rate */
  1733. for (rate_idx = 0; rate_idx < RATE_COUNT_3945;
  1734. rate_idx++, clip_pwrs++) {
  1735. switch (rate_idx) {
  1736. case RATE_36M_IDX_TBL:
  1737. if (i == 0) /* B/G */
  1738. *clip_pwrs = satur_pwr;
  1739. else /* A */
  1740. *clip_pwrs = satur_pwr - 5;
  1741. break;
  1742. case RATE_48M_IDX_TBL:
  1743. if (i == 0)
  1744. *clip_pwrs = satur_pwr - 7;
  1745. else
  1746. *clip_pwrs = satur_pwr - 10;
  1747. break;
  1748. case RATE_54M_IDX_TBL:
  1749. if (i == 0)
  1750. *clip_pwrs = satur_pwr - 9;
  1751. else
  1752. *clip_pwrs = satur_pwr - 12;
  1753. break;
  1754. default:
  1755. *clip_pwrs = satur_pwr;
  1756. break;
  1757. }
  1758. }
  1759. }
  1760. }
  1761. /*
  1762. * il3945_txpower_set_from_eeprom - Set channel power info based on EEPROM
  1763. *
  1764. * Second pass (during init) to set up il->channel_info
  1765. *
  1766. * Set up Tx-power settings in our channel info database for each VALID
  1767. * (for this geo/SKU) channel, at all Tx data rates, based on eeprom values
  1768. * and current temperature.
  1769. *
  1770. * Since this is based on current temperature (at init time), these values may
  1771. * not be valid for very long, but it gives us a starting/default point,
  1772. * and allows us to active (i.e. using Tx) scan.
  1773. *
  1774. * This does *not* write values to NIC, just sets up our internal table.
  1775. */
  1776. int
  1777. il3945_txpower_set_from_eeprom(struct il_priv *il)
  1778. {
  1779. struct il_channel_info *ch_info = NULL;
  1780. struct il3945_channel_power_info *pwr_info;
  1781. struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom;
  1782. int delta_idx;
  1783. u8 rate_idx;
  1784. u8 scan_tbl_idx;
  1785. const s8 *clip_pwrs; /* array of power levels for each rate */
  1786. u8 gain, dsp_atten;
  1787. s8 power;
  1788. u8 pwr_idx, base_pwr_idx, a_band;
  1789. u8 i;
  1790. int temperature;
  1791. /* save temperature reference,
  1792. * so we can determine next time to calibrate */
  1793. temperature = il3945_hw_reg_txpower_get_temperature(il);
  1794. il->last_temperature = temperature;
  1795. il3945_hw_reg_init_channel_groups(il);
  1796. /* initialize Tx power info for each and every channel, 2.4 and 5.x */
  1797. for (i = 0, ch_info = il->channel_info; i < il->channel_count;
  1798. i++, ch_info++) {
  1799. a_band = il_is_channel_a_band(ch_info);
  1800. if (!il_is_channel_valid(ch_info))
  1801. continue;
  1802. /* find this channel's channel group (*not* "band") idx */
  1803. ch_info->group_idx = il3945_hw_reg_get_ch_grp_idx(il, ch_info);
  1804. /* Get this chnlgrp's rate->max/clip-powers table */
  1805. clip_pwrs =
  1806. il->_3945.clip_groups[ch_info->group_idx].clip_powers;
  1807. /* calculate power idx *adjustment* value according to
  1808. * diff between current temperature and factory temperature */
  1809. delta_idx =
  1810. il3945_hw_reg_adjust_power_by_temp(temperature,
  1811. eeprom->groups[ch_info->
  1812. group_idx].
  1813. temperature);
  1814. D_POWER("Delta idx for channel %d: %d [%d]\n", ch_info->channel,
  1815. delta_idx, temperature + IL_TEMP_CONVERT);
  1816. /* set tx power value for all OFDM rates */
  1817. for (rate_idx = 0; rate_idx < IL_OFDM_RATES; rate_idx++) {
  1818. s32 power_idx;
  1819. int rc;
  1820. /* use channel group's clip-power table,
  1821. * but don't exceed channel's max power */
  1822. s8 pwr = min(ch_info->max_power_avg,
  1823. clip_pwrs[rate_idx]);
  1824. pwr_info = &ch_info->power_info[rate_idx];
  1825. /* get base (i.e. at factory-measured temperature)
  1826. * power table idx for this rate's power */
  1827. rc = il3945_hw_reg_get_matched_power_idx(il, pwr,
  1828. ch_info->
  1829. group_idx,
  1830. &power_idx);
  1831. if (rc) {
  1832. IL_ERR("Invalid power idx\n");
  1833. return rc;
  1834. }
  1835. pwr_info->base_power_idx = (u8) power_idx;
  1836. /* temperature compensate */
  1837. power_idx += delta_idx;
  1838. /* stay within range of gain table */
  1839. power_idx = il3945_hw_reg_fix_power_idx(power_idx);
  1840. /* fill 1 OFDM rate's il3945_channel_power_info struct */
  1841. pwr_info->requested_power = pwr;
  1842. pwr_info->power_table_idx = (u8) power_idx;
  1843. pwr_info->tpc.tx_gain =
  1844. power_gain_table[a_band][power_idx].tx_gain;
  1845. pwr_info->tpc.dsp_atten =
  1846. power_gain_table[a_band][power_idx].dsp_atten;
  1847. }
  1848. /* set tx power for CCK rates, based on OFDM 12 Mbit settings */
  1849. pwr_info = &ch_info->power_info[RATE_12M_IDX_TBL];
  1850. power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF;
  1851. pwr_idx = pwr_info->power_table_idx + IL_CCK_FROM_OFDM_IDX_DIFF;
  1852. base_pwr_idx =
  1853. pwr_info->base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF;
  1854. /* stay within table range */
  1855. pwr_idx = il3945_hw_reg_fix_power_idx(pwr_idx);
  1856. gain = power_gain_table[a_band][pwr_idx].tx_gain;
  1857. dsp_atten = power_gain_table[a_band][pwr_idx].dsp_atten;
  1858. /* fill each CCK rate's il3945_channel_power_info structure
  1859. * NOTE: All CCK-rate Txpwrs are the same for a given chnl!
  1860. * NOTE: CCK rates start at end of OFDM rates! */
  1861. for (rate_idx = 0; rate_idx < IL_CCK_RATES; rate_idx++) {
  1862. pwr_info =
  1863. &ch_info->power_info[rate_idx + IL_OFDM_RATES];
  1864. pwr_info->requested_power = power;
  1865. pwr_info->power_table_idx = pwr_idx;
  1866. pwr_info->base_power_idx = base_pwr_idx;
  1867. pwr_info->tpc.tx_gain = gain;
  1868. pwr_info->tpc.dsp_atten = dsp_atten;
  1869. }
  1870. /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */
  1871. for (scan_tbl_idx = 0; scan_tbl_idx < IL_NUM_SCAN_RATES;
  1872. scan_tbl_idx++) {
  1873. s32 actual_idx =
  1874. (scan_tbl_idx ==
  1875. 0) ? RATE_1M_IDX_TBL : RATE_6M_IDX_TBL;
  1876. il3945_hw_reg_set_scan_power(il, scan_tbl_idx,
  1877. actual_idx, clip_pwrs,
  1878. ch_info, a_band);
  1879. }
  1880. }
  1881. return 0;
  1882. }
  1883. int
  1884. il3945_hw_rxq_stop(struct il_priv *il)
  1885. {
  1886. int ret;
  1887. _il_wr(il, FH39_RCSR_CONFIG(0), 0);
  1888. ret = _il_poll_bit(il, FH39_RSSR_STATUS,
  1889. FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE,
  1890. FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE,
  1891. 1000);
  1892. if (ret < 0)
  1893. IL_ERR("Can't stop Rx DMA.\n");
  1894. return 0;
  1895. }
  1896. int
  1897. il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq)
  1898. {
  1899. int txq_id = txq->q.id;
  1900. struct il3945_shared *shared_data = il->_3945.shared_virt;
  1901. shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32) txq->q.dma_addr);
  1902. il_wr(il, FH39_CBCC_CTRL(txq_id), 0);
  1903. il_wr(il, FH39_CBCC_BASE(txq_id), 0);
  1904. il_wr(il, FH39_TCSR_CONFIG(txq_id),
  1905. FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT |
  1906. FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF |
  1907. FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD |
  1908. FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL |
  1909. FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE);
  1910. /* fake read to flush all prev. writes */
  1911. _il_rd(il, FH39_TSSR_CBB_BASE);
  1912. return 0;
  1913. }
  1914. /*
  1915. * HCMD utils
  1916. */
  1917. static u16
  1918. il3945_get_hcmd_size(u8 cmd_id, u16 len)
  1919. {
  1920. switch (cmd_id) {
  1921. case C_RXON:
  1922. return sizeof(struct il3945_rxon_cmd);
  1923. case C_POWER_TBL:
  1924. return sizeof(struct il3945_powertable_cmd);
  1925. default:
  1926. return len;
  1927. }
  1928. }
  1929. static u16
  1930. il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data)
  1931. {
  1932. struct il3945_addsta_cmd *addsta = (struct il3945_addsta_cmd *)data;
  1933. addsta->mode = cmd->mode;
  1934. memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify));
  1935. memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo));
  1936. addsta->station_flags = cmd->station_flags;
  1937. addsta->station_flags_msk = cmd->station_flags_msk;
  1938. addsta->tid_disable_tx = cpu_to_le16(0);
  1939. addsta->rate_n_flags = cmd->rate_n_flags;
  1940. addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid;
  1941. addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid;
  1942. addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn;
  1943. return (u16) sizeof(struct il3945_addsta_cmd);
  1944. }
  1945. static int
  1946. il3945_add_bssid_station(struct il_priv *il, const u8 * addr, u8 * sta_id_r)
  1947. {
  1948. int ret;
  1949. u8 sta_id;
  1950. unsigned long flags;
  1951. if (sta_id_r)
  1952. *sta_id_r = IL_INVALID_STATION;
  1953. ret = il_add_station_common(il, addr, 0, NULL, &sta_id);
  1954. if (ret) {
  1955. IL_ERR("Unable to add station %pM\n", addr);
  1956. return ret;
  1957. }
  1958. if (sta_id_r)
  1959. *sta_id_r = sta_id;
  1960. spin_lock_irqsave(&il->sta_lock, flags);
  1961. il->stations[sta_id].used |= IL_STA_LOCAL;
  1962. spin_unlock_irqrestore(&il->sta_lock, flags);
  1963. return 0;
  1964. }
  1965. static int
  1966. il3945_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif,
  1967. bool add)
  1968. {
  1969. struct il_vif_priv *vif_priv = (void *)vif->drv_priv;
  1970. int ret;
  1971. if (add) {
  1972. ret =
  1973. il3945_add_bssid_station(il, vif->bss_conf.bssid,
  1974. &vif_priv->ibss_bssid_sta_id);
  1975. if (ret)
  1976. return ret;
  1977. il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id,
  1978. (il->band ==
  1979. NL80211_BAND_5GHZ) ? RATE_6M_PLCP :
  1980. RATE_1M_PLCP);
  1981. il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id);
  1982. return 0;
  1983. }
  1984. return il_remove_station(il, vif_priv->ibss_bssid_sta_id,
  1985. vif->bss_conf.bssid);
  1986. }
  1987. /*
  1988. * il3945_init_hw_rate_table - Initialize the hardware rate fallback table
  1989. */
  1990. int
  1991. il3945_init_hw_rate_table(struct il_priv *il)
  1992. {
  1993. int rc, i, idx, prev_idx;
  1994. struct il3945_rate_scaling_cmd rate_cmd = {
  1995. .reserved = {0, 0, 0},
  1996. };
  1997. struct il3945_rate_scaling_info *table = rate_cmd.table;
  1998. for (i = 0; i < ARRAY_SIZE(il3945_rates); i++) {
  1999. idx = il3945_rates[i].table_rs_idx;
  2000. table[idx].rate_n_flags = cpu_to_le16(il3945_rates[i].plcp);
  2001. table[idx].try_cnt = il->retry_rate;
  2002. prev_idx = il3945_get_prev_ieee_rate(i);
  2003. table[idx].next_rate_idx = il3945_rates[prev_idx].table_rs_idx;
  2004. }
  2005. switch (il->band) {
  2006. case NL80211_BAND_5GHZ:
  2007. D_RATE("Select A mode rate scale\n");
  2008. /* If one of the following CCK rates is used,
  2009. * have it fall back to the 6M OFDM rate */
  2010. for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++)
  2011. table[i].next_rate_idx =
  2012. il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx;
  2013. /* Don't fall back to CCK rates */
  2014. table[RATE_12M_IDX_TBL].next_rate_idx = RATE_9M_IDX_TBL;
  2015. /* Don't drop out of OFDM rates */
  2016. table[RATE_6M_IDX_TBL].next_rate_idx =
  2017. il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx;
  2018. break;
  2019. case NL80211_BAND_2GHZ:
  2020. D_RATE("Select B/G mode rate scale\n");
  2021. /* If an OFDM rate is used, have it fall back to the
  2022. * 1M CCK rates */
  2023. if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) &&
  2024. il_is_associated(il)) {
  2025. idx = IL_FIRST_CCK_RATE;
  2026. for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; i++)
  2027. table[i].next_rate_idx =
  2028. il3945_rates[idx].table_rs_idx;
  2029. idx = RATE_11M_IDX_TBL;
  2030. /* CCK shouldn't fall back to OFDM... */
  2031. table[idx].next_rate_idx = RATE_5M_IDX_TBL;
  2032. }
  2033. break;
  2034. default:
  2035. WARN_ON(1);
  2036. break;
  2037. }
  2038. /* Update the rate scaling for control frame Tx */
  2039. rate_cmd.table_id = 0;
  2040. rc = il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), &rate_cmd);
  2041. if (rc)
  2042. return rc;
  2043. /* Update the rate scaling for data frame Tx */
  2044. rate_cmd.table_id = 1;
  2045. return il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), &rate_cmd);
  2046. }
  2047. /* Called when initializing driver */
  2048. int
  2049. il3945_hw_set_hw_params(struct il_priv *il)
  2050. {
  2051. memset((void *)&il->hw_params, 0, sizeof(struct il_hw_params));
  2052. il->_3945.shared_virt =
  2053. dma_alloc_coherent(&il->pci_dev->dev, sizeof(struct il3945_shared),
  2054. &il->_3945.shared_phys, GFP_KERNEL);
  2055. if (!il->_3945.shared_virt)
  2056. return -ENOMEM;
  2057. il->hw_params.bcast_id = IL3945_BROADCAST_ID;
  2058. /* Assign number of Usable TX queues */
  2059. il->hw_params.max_txq_num = il->cfg->num_of_queues;
  2060. il->hw_params.tfd_size = sizeof(struct il3945_tfd);
  2061. il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K);
  2062. il->hw_params.max_rxq_size = RX_QUEUE_SIZE;
  2063. il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG;
  2064. il->hw_params.max_stations = IL3945_STATION_COUNT;
  2065. il->sta_key_max_num = STA_KEY_MAX_NUM;
  2066. il->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR;
  2067. il->hw_params.max_beacon_itrvl = IL39_MAX_UCODE_BEACON_INTERVAL;
  2068. il->hw_params.beacon_time_tsf_bits = IL3945_EXT_BEACON_TIME_POS;
  2069. return 0;
  2070. }
  2071. unsigned int
  2072. il3945_hw_get_beacon_cmd(struct il_priv *il, struct il3945_frame *frame,
  2073. u8 rate)
  2074. {
  2075. struct il3945_tx_beacon_cmd *tx_beacon_cmd;
  2076. unsigned int frame_size;
  2077. tx_beacon_cmd = (struct il3945_tx_beacon_cmd *)&frame->u;
  2078. memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd));
  2079. tx_beacon_cmd->tx.sta_id = il->hw_params.bcast_id;
  2080. tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
  2081. frame_size =
  2082. il3945_fill_beacon_frame(il, tx_beacon_cmd->frame,
  2083. sizeof(frame->u) - sizeof(*tx_beacon_cmd));
  2084. BUG_ON(frame_size > MAX_MPDU_SIZE);
  2085. tx_beacon_cmd->tx.len = cpu_to_le16((u16) frame_size);
  2086. tx_beacon_cmd->tx.rate = rate;
  2087. tx_beacon_cmd->tx.tx_flags =
  2088. (TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK);
  2089. /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE */
  2090. tx_beacon_cmd->tx.supp_rates[0] =
  2091. (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF;
  2092. tx_beacon_cmd->tx.supp_rates[1] = (IL_CCK_BASIC_RATES_MASK & 0xF);
  2093. return sizeof(struct il3945_tx_beacon_cmd) + frame_size;
  2094. }
  2095. void
  2096. il3945_hw_handler_setup(struct il_priv *il)
  2097. {
  2098. il->handlers[C_TX] = il3945_hdl_tx;
  2099. il->handlers[N_3945_RX] = il3945_hdl_rx;
  2100. }
  2101. void
  2102. il3945_hw_setup_deferred_work(struct il_priv *il)
  2103. {
  2104. INIT_DELAYED_WORK(&il->_3945.thermal_periodic,
  2105. il3945_bg_reg_txpower_periodic);
  2106. }
  2107. void
  2108. il3945_hw_cancel_deferred_work(struct il_priv *il)
  2109. {
  2110. cancel_delayed_work(&il->_3945.thermal_periodic);
  2111. }
  2112. /* check contents of special bootstrap uCode SRAM */
  2113. static int
  2114. il3945_verify_bsm(struct il_priv *il)
  2115. {
  2116. __le32 *image = il->ucode_boot.v_addr;
  2117. u32 len = il->ucode_boot.len;
  2118. u32 reg;
  2119. u32 val;
  2120. D_INFO("Begin verify bsm\n");
  2121. /* verify BSM SRAM contents */
  2122. val = il_rd_prph(il, BSM_WR_DWCOUNT_REG);
  2123. for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len;
  2124. reg += sizeof(u32), image++) {
  2125. val = il_rd_prph(il, reg);
  2126. if (val != le32_to_cpu(*image)) {
  2127. IL_ERR("BSM uCode verification failed at "
  2128. "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n",
  2129. BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND,
  2130. len, val, le32_to_cpu(*image));
  2131. return -EIO;
  2132. }
  2133. }
  2134. D_INFO("BSM bootstrap uCode image OK\n");
  2135. return 0;
  2136. }
  2137. /******************************************************************************
  2138. *
  2139. * EEPROM related functions
  2140. *
  2141. ******************************************************************************/
  2142. /*
  2143. * Clear the OWNER_MSK, to establish driver (instead of uCode running on
  2144. * embedded controller) as EEPROM reader; each read is a series of pulses
  2145. * to/from the EEPROM chip, not a single event, so even reads could conflict
  2146. * if they weren't arbitrated by some ownership mechanism. Here, the driver
  2147. * simply claims ownership, which should be safe when this function is called
  2148. * (i.e. before loading uCode!).
  2149. */
  2150. static int
  2151. il3945_eeprom_acquire_semaphore(struct il_priv *il)
  2152. {
  2153. _il_clear_bit(il, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK);
  2154. return 0;
  2155. }
  2156. static void
  2157. il3945_eeprom_release_semaphore(struct il_priv *il)
  2158. {
  2159. return;
  2160. }
  2161. /*
  2162. * il3945_load_bsm - Load bootstrap instructions
  2163. *
  2164. * BSM operation:
  2165. *
  2166. * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program
  2167. * in special SRAM that does not power down during RFKILL. When powering back
  2168. * up after power-saving sleeps (or during initial uCode load), the BSM loads
  2169. * the bootstrap program into the on-board processor, and starts it.
  2170. *
  2171. * The bootstrap program loads (via DMA) instructions and data for a new
  2172. * program from host DRAM locations indicated by the host driver in the
  2173. * BSM_DRAM_* registers. Once the new program is loaded, it starts
  2174. * automatically.
  2175. *
  2176. * When initializing the NIC, the host driver points the BSM to the
  2177. * "initialize" uCode image. This uCode sets up some internal data, then
  2178. * notifies host via "initialize alive" that it is complete.
  2179. *
  2180. * The host then replaces the BSM_DRAM_* pointer values to point to the
  2181. * normal runtime uCode instructions and a backup uCode data cache buffer
  2182. * (filled initially with starting data values for the on-board processor),
  2183. * then triggers the "initialize" uCode to load and launch the runtime uCode,
  2184. * which begins normal operation.
  2185. *
  2186. * When doing a power-save shutdown, runtime uCode saves data SRAM into
  2187. * the backup data cache in DRAM before SRAM is powered down.
  2188. *
  2189. * When powering back up, the BSM loads the bootstrap program. This reloads
  2190. * the runtime uCode instructions and the backup data cache into SRAM,
  2191. * and re-launches the runtime uCode from where it left off.
  2192. */
  2193. static int
  2194. il3945_load_bsm(struct il_priv *il)
  2195. {
  2196. __le32 *image = il->ucode_boot.v_addr;
  2197. u32 len = il->ucode_boot.len;
  2198. dma_addr_t pinst;
  2199. dma_addr_t pdata;
  2200. u32 inst_len;
  2201. u32 data_len;
  2202. int rc;
  2203. int i;
  2204. u32 done;
  2205. u32 reg_offset;
  2206. D_INFO("Begin load bsm\n");
  2207. /* make sure bootstrap program is no larger than BSM's SRAM size */
  2208. if (len > IL39_MAX_BSM_SIZE)
  2209. return -EINVAL;
  2210. /* Tell bootstrap uCode where to find the "Initialize" uCode
  2211. * in host DRAM ... host DRAM physical address bits 31:0 for 3945.
  2212. * NOTE: il3945_initialize_alive_start() will replace these values,
  2213. * after the "initialize" uCode has run, to point to
  2214. * runtime/protocol instructions and backup data cache. */
  2215. pinst = il->ucode_init.p_addr;
  2216. pdata = il->ucode_init_data.p_addr;
  2217. inst_len = il->ucode_init.len;
  2218. data_len = il->ucode_init_data.len;
  2219. il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst);
  2220. il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata);
  2221. il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len);
  2222. il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len);
  2223. /* Fill BSM memory with bootstrap instructions */
  2224. for (reg_offset = BSM_SRAM_LOWER_BOUND;
  2225. reg_offset < BSM_SRAM_LOWER_BOUND + len;
  2226. reg_offset += sizeof(u32), image++)
  2227. _il_wr_prph(il, reg_offset, le32_to_cpu(*image));
  2228. rc = il3945_verify_bsm(il);
  2229. if (rc)
  2230. return rc;
  2231. /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */
  2232. il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0);
  2233. il_wr_prph(il, BSM_WR_MEM_DST_REG, IL39_RTC_INST_LOWER_BOUND);
  2234. il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32));
  2235. /* Load bootstrap code into instruction SRAM now,
  2236. * to prepare to load "initialize" uCode */
  2237. il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START);
  2238. /* Wait for load of bootstrap uCode to finish */
  2239. for (i = 0; i < 100; i++) {
  2240. done = il_rd_prph(il, BSM_WR_CTRL_REG);
  2241. if (!(done & BSM_WR_CTRL_REG_BIT_START))
  2242. break;
  2243. udelay(10);
  2244. }
  2245. if (i < 100)
  2246. D_INFO("BSM write complete, poll %d iterations\n", i);
  2247. else {
  2248. IL_ERR("BSM write did not complete!\n");
  2249. return -EIO;
  2250. }
  2251. /* Enable future boot loads whenever power management unit triggers it
  2252. * (e.g. when powering back up after power-save shutdown) */
  2253. il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN);
  2254. return 0;
  2255. }
  2256. const struct il_ops il3945_ops = {
  2257. .txq_attach_buf_to_tfd = il3945_hw_txq_attach_buf_to_tfd,
  2258. .txq_free_tfd = il3945_hw_txq_free_tfd,
  2259. .txq_init = il3945_hw_tx_queue_init,
  2260. .load_ucode = il3945_load_bsm,
  2261. .dump_nic_error_log = il3945_dump_nic_error_log,
  2262. .apm_init = il3945_apm_init,
  2263. .send_tx_power = il3945_send_tx_power,
  2264. .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr,
  2265. .eeprom_acquire_semaphore = il3945_eeprom_acquire_semaphore,
  2266. .eeprom_release_semaphore = il3945_eeprom_release_semaphore,
  2267. .rxon_assoc = il3945_send_rxon_assoc,
  2268. .commit_rxon = il3945_commit_rxon,
  2269. .get_hcmd_size = il3945_get_hcmd_size,
  2270. .build_addsta_hcmd = il3945_build_addsta_hcmd,
  2271. .request_scan = il3945_request_scan,
  2272. .post_scan = il3945_post_scan,
  2273. .post_associate = il3945_post_associate,
  2274. .config_ap = il3945_config_ap,
  2275. .manage_ibss_station = il3945_manage_ibss_station,
  2276. .send_led_cmd = il3945_send_led_cmd,
  2277. };
  2278. static const struct il_cfg il3945_bg_cfg = {
  2279. .name = "3945BG",
  2280. .fw_name_pre = IL3945_FW_PRE,
  2281. .ucode_api_max = IL3945_UCODE_API_MAX,
  2282. .ucode_api_min = IL3945_UCODE_API_MIN,
  2283. .sku = IL_SKU_G,
  2284. .eeprom_ver = EEPROM_3945_EEPROM_VERSION,
  2285. .mod_params = &il3945_mod_params,
  2286. .led_mode = IL_LED_BLINK,
  2287. .eeprom_size = IL3945_EEPROM_IMG_SIZE,
  2288. .num_of_queues = IL39_NUM_QUEUES,
  2289. .pll_cfg_val = CSR39_ANA_PLL_CFG_VAL,
  2290. .set_l0s = false,
  2291. .use_bsm = true,
  2292. .led_compensation = 64,
  2293. .wd_timeout = IL_DEF_WD_TIMEOUT,
  2294. .regulatory_bands = {
  2295. EEPROM_REGULATORY_BAND_1_CHANNELS,
  2296. EEPROM_REGULATORY_BAND_2_CHANNELS,
  2297. EEPROM_REGULATORY_BAND_3_CHANNELS,
  2298. EEPROM_REGULATORY_BAND_4_CHANNELS,
  2299. EEPROM_REGULATORY_BAND_5_CHANNELS,
  2300. EEPROM_REGULATORY_BAND_NO_HT40,
  2301. EEPROM_REGULATORY_BAND_NO_HT40,
  2302. },
  2303. };
  2304. static const struct il_cfg il3945_abg_cfg = {
  2305. .name = "3945ABG",
  2306. .fw_name_pre = IL3945_FW_PRE,
  2307. .ucode_api_max = IL3945_UCODE_API_MAX,
  2308. .ucode_api_min = IL3945_UCODE_API_MIN,
  2309. .sku = IL_SKU_A | IL_SKU_G,
  2310. .eeprom_ver = EEPROM_3945_EEPROM_VERSION,
  2311. .mod_params = &il3945_mod_params,
  2312. .led_mode = IL_LED_BLINK,
  2313. .eeprom_size = IL3945_EEPROM_IMG_SIZE,
  2314. .num_of_queues = IL39_NUM_QUEUES,
  2315. .pll_cfg_val = CSR39_ANA_PLL_CFG_VAL,
  2316. .set_l0s = false,
  2317. .use_bsm = true,
  2318. .led_compensation = 64,
  2319. .wd_timeout = IL_DEF_WD_TIMEOUT,
  2320. .regulatory_bands = {
  2321. EEPROM_REGULATORY_BAND_1_CHANNELS,
  2322. EEPROM_REGULATORY_BAND_2_CHANNELS,
  2323. EEPROM_REGULATORY_BAND_3_CHANNELS,
  2324. EEPROM_REGULATORY_BAND_4_CHANNELS,
  2325. EEPROM_REGULATORY_BAND_5_CHANNELS,
  2326. EEPROM_REGULATORY_BAND_NO_HT40,
  2327. EEPROM_REGULATORY_BAND_NO_HT40,
  2328. },
  2329. };
  2330. const struct pci_device_id il3945_hw_card_ids[] = {
  2331. {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)},
  2332. {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)},
  2333. {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)},
  2334. {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)},
  2335. {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)},
  2336. {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)},
  2337. {0}
  2338. };
  2339. MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids);