iwl-dev.h 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2003 - 2008 Intel Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
  17. *
  18. * The full GNU General Public License is included in this distribution in the
  19. * file called LICENSE.
  20. *
  21. * Contact Information:
  22. * James P. Ketrenos <ipw2100-admin@linux.intel.com>
  23. * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
  24. *
  25. *****************************************************************************/
  26. /*
  27. * Please use this file (iwl-dev.h) for driver implementation definitions.
  28. * Please use iwl-commands.h for uCode API definitions.
  29. * Please use iwl-4965-hw.h for hardware-related definitions.
  30. */
  31. #ifndef __iwl_dev_h__
  32. #define __iwl_dev_h__
  33. #include <linux/pci.h> /* for struct pci_device_id */
  34. #include <linux/kernel.h>
  35. #include <net/ieee80211_radiotap.h>
  36. #define DRV_NAME "iwl4965"
  37. #include "iwl-rfkill.h"
  38. #include "iwl-eeprom.h"
  39. #include "iwl-4965-hw.h"
  40. #include "iwl-csr.h"
  41. #include "iwl-prph.h"
  42. #include "iwl-debug.h"
  43. #include "iwl-led.h"
  44. #include "iwl-power.h"
  45. /* configuration for the iwl4965 */
  46. extern struct iwl_cfg iwl4965_agn_cfg;
  47. extern struct iwl_cfg iwl5300_agn_cfg;
  48. extern struct iwl_cfg iwl5100_agn_cfg;
  49. extern struct iwl_cfg iwl5350_agn_cfg;
  50. extern struct iwl_cfg iwl5100_bg_cfg;
  51. extern struct iwl_cfg iwl5100_abg_cfg;
  52. /* CT-KILL constants */
  53. #define CT_KILL_THRESHOLD 110 /* in Celsius */
  54. /* Default noise level to report when noise measurement is not available.
  55. * This may be because we're:
  56. * 1) Not associated (4965, no beacon statistics being sent to driver)
  57. * 2) Scanning (noise measurement does not apply to associated channel)
  58. * 3) Receiving CCK (3945 delivers noise info only for OFDM frames)
  59. * Use default noise value of -127 ... this is below the range of measurable
  60. * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user.
  61. * Also, -127 works better than 0 when averaging frames with/without
  62. * noise info (e.g. averaging might be done in app); measured dBm values are
  63. * always negative ... using a negative value as the default keeps all
  64. * averages within an s8's (used in some apps) range of negative values. */
  65. #define IWL_NOISE_MEAS_NOT_AVAILABLE (-127)
  66. /*
  67. * RTS threshold here is total size [2347] minus 4 FCS bytes
  68. * Per spec:
  69. * a value of 0 means RTS on all data/management packets
  70. * a value > max MSDU size means no RTS
  71. * else RTS for data/management frames where MPDU is larger
  72. * than RTS value.
  73. */
  74. #define DEFAULT_RTS_THRESHOLD 2347U
  75. #define MIN_RTS_THRESHOLD 0U
  76. #define MAX_RTS_THRESHOLD 2347U
  77. #define MAX_MSDU_SIZE 2304U
  78. #define MAX_MPDU_SIZE 2346U
  79. #define DEFAULT_BEACON_INTERVAL 100U
  80. #define DEFAULT_SHORT_RETRY_LIMIT 7U
  81. #define DEFAULT_LONG_RETRY_LIMIT 4U
  82. struct iwl_rx_mem_buffer {
  83. dma_addr_t dma_addr;
  84. struct sk_buff *skb;
  85. struct list_head list;
  86. };
  87. /*
  88. * Generic queue structure
  89. *
  90. * Contains common data for Rx and Tx queues
  91. */
  92. struct iwl_queue {
  93. int n_bd; /* number of BDs in this queue */
  94. int write_ptr; /* 1-st empty entry (index) host_w*/
  95. int read_ptr; /* last used entry (index) host_r*/
  96. dma_addr_t dma_addr; /* physical addr for BD's */
  97. int n_window; /* safe queue window */
  98. u32 id;
  99. int low_mark; /* low watermark, resume queue if free
  100. * space more than this */
  101. int high_mark; /* high watermark, stop queue if free
  102. * space less than this */
  103. } __attribute__ ((packed));
  104. #define MAX_NUM_OF_TBS (20)
  105. /* One for each TFD */
  106. struct iwl_tx_info {
  107. struct sk_buff *skb[MAX_NUM_OF_TBS];
  108. };
  109. /**
  110. * struct iwl_tx_queue - Tx Queue for DMA
  111. * @q: generic Rx/Tx queue descriptor
  112. * @bd: base of circular buffer of TFDs
  113. * @cmd: array of command/Tx buffers
  114. * @dma_addr_cmd: physical address of cmd/tx buffer array
  115. * @txb: array of per-TFD driver data
  116. * @need_update: indicates need to update read/write index
  117. * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled
  118. *
  119. * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame
  120. * descriptors) and required locking structures.
  121. */
  122. struct iwl_tx_queue {
  123. struct iwl_queue q;
  124. struct iwl_tfd_frame *bd;
  125. struct iwl_cmd *cmd;
  126. dma_addr_t dma_addr_cmd;
  127. struct iwl_tx_info *txb;
  128. int need_update;
  129. int sched_retry;
  130. int active;
  131. };
  132. #define IWL_NUM_SCAN_RATES (2)
  133. struct iwl4965_channel_tgd_info {
  134. u8 type;
  135. s8 max_power;
  136. };
  137. struct iwl4965_channel_tgh_info {
  138. s64 last_radar_time;
  139. };
  140. /*
  141. * One for each channel, holds all channel setup data
  142. * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant
  143. * with one another!
  144. */
  145. struct iwl_channel_info {
  146. struct iwl4965_channel_tgd_info tgd;
  147. struct iwl4965_channel_tgh_info tgh;
  148. struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */
  149. struct iwl_eeprom_channel fat_eeprom; /* EEPROM regulatory limit for
  150. * FAT channel */
  151. u8 channel; /* channel number */
  152. u8 flags; /* flags copied from EEPROM */
  153. s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  154. s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */
  155. s8 min_power; /* always 0 */
  156. s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */
  157. u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */
  158. u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */
  159. enum ieee80211_band band;
  160. /* FAT channel info */
  161. s8 fat_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */
  162. s8 fat_curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) */
  163. s8 fat_min_power; /* always 0 */
  164. s8 fat_scan_power; /* (dBm) eeprom, direct scans, any rate */
  165. u8 fat_flags; /* flags copied from EEPROM */
  166. u8 fat_extension_channel; /* HT_IE_EXT_CHANNEL_* */
  167. };
  168. struct iwl4965_clip_group {
  169. /* maximum power level to prevent clipping for each rate, derived by
  170. * us from this band's saturation power in EEPROM */
  171. const s8 clip_powers[IWL_MAX_RATES];
  172. };
  173. #include "iwl-4965-rs.h"
  174. #define IWL_TX_FIFO_AC0 0
  175. #define IWL_TX_FIFO_AC1 1
  176. #define IWL_TX_FIFO_AC2 2
  177. #define IWL_TX_FIFO_AC3 3
  178. #define IWL_TX_FIFO_HCCA_1 5
  179. #define IWL_TX_FIFO_HCCA_2 6
  180. #define IWL_TX_FIFO_NONE 7
  181. /* Minimum number of queues. MAX_NUM is defined in hw specific files */
  182. #define IWL_MIN_NUM_QUEUES 4
  183. /* Power management (not Tx power) structures */
  184. enum iwl_pwr_src {
  185. IWL_PWR_SRC_VMAIN,
  186. IWL_PWR_SRC_VAUX,
  187. };
  188. #define IEEE80211_DATA_LEN 2304
  189. #define IEEE80211_4ADDR_LEN 30
  190. #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN)
  191. #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
  192. struct iwl_frame {
  193. union {
  194. struct ieee80211_hdr frame;
  195. struct iwl4965_tx_beacon_cmd beacon;
  196. u8 raw[IEEE80211_FRAME_LEN];
  197. u8 cmd[360];
  198. } u;
  199. struct list_head list;
  200. };
  201. #define SEQ_TO_QUEUE(x) ((x >> 8) & 0xbf)
  202. #define QUEUE_TO_SEQ(x) ((x & 0xbf) << 8)
  203. #define SEQ_TO_INDEX(x) ((u8)(x & 0xff))
  204. #define INDEX_TO_SEQ(x) ((u8)(x & 0xff))
  205. #define SEQ_HUGE_FRAME (0x4000)
  206. #define SEQ_RX_FRAME __constant_cpu_to_le16(0x8000)
  207. #define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
  208. #define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ)
  209. #define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4)
  210. enum {
  211. /* CMD_SIZE_NORMAL = 0, */
  212. CMD_SIZE_HUGE = (1 << 0),
  213. /* CMD_SYNC = 0, */
  214. CMD_ASYNC = (1 << 1),
  215. /* CMD_NO_SKB = 0, */
  216. CMD_WANT_SKB = (1 << 2),
  217. };
  218. struct iwl_cmd;
  219. struct iwl_priv;
  220. struct iwl_cmd_meta {
  221. struct iwl_cmd_meta *source;
  222. union {
  223. struct sk_buff *skb;
  224. int (*callback)(struct iwl_priv *priv,
  225. struct iwl_cmd *cmd, struct sk_buff *skb);
  226. } __attribute__ ((packed)) u;
  227. /* The CMD_SIZE_HUGE flag bit indicates that the command
  228. * structure is stored at the end of the shared queue memory. */
  229. u32 flags;
  230. } __attribute__ ((packed));
  231. #define IWL_CMD_MAX_PAYLOAD 320
  232. /**
  233. * struct iwl_cmd
  234. *
  235. * For allocation of the command and tx queues, this establishes the overall
  236. * size of the largest command we send to uCode, except for a scan command
  237. * (which is relatively huge; space is allocated separately).
  238. */
  239. struct iwl_cmd {
  240. struct iwl_cmd_meta meta; /* driver data */
  241. struct iwl_cmd_header hdr; /* uCode API */
  242. union {
  243. struct iwl_addsta_cmd addsta;
  244. struct iwl_led_cmd led;
  245. u32 flags;
  246. u8 val8;
  247. u16 val16;
  248. u32 val32;
  249. struct iwl4965_bt_cmd bt;
  250. struct iwl4965_rxon_time_cmd rxon_time;
  251. struct iwl4965_powertable_cmd powertable;
  252. struct iwl_qosparam_cmd qosparam;
  253. struct iwl_tx_cmd tx;
  254. struct iwl4965_tx_beacon_cmd tx_beacon;
  255. struct iwl4965_rxon_assoc_cmd rxon_assoc;
  256. struct iwl_rem_sta_cmd rm_sta;
  257. u8 *indirect;
  258. u8 payload[IWL_CMD_MAX_PAYLOAD];
  259. } __attribute__ ((packed)) cmd;
  260. } __attribute__ ((packed));
  261. struct iwl_host_cmd {
  262. u8 id;
  263. u16 len;
  264. struct iwl_cmd_meta meta;
  265. const void *data;
  266. };
  267. #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_cmd) - \
  268. sizeof(struct iwl_cmd_meta))
  269. /*
  270. * RX related structures and functions
  271. */
  272. #define RX_FREE_BUFFERS 64
  273. #define RX_LOW_WATERMARK 8
  274. #define SUP_RATE_11A_MAX_NUM_CHANNELS 8
  275. #define SUP_RATE_11B_MAX_NUM_CHANNELS 4
  276. #define SUP_RATE_11G_MAX_NUM_CHANNELS 12
  277. /**
  278. * struct iwl_rx_queue - Rx queue
  279. * @processed: Internal index to last handled Rx packet
  280. * @read: Shared index to newest available Rx buffer
  281. * @write: Shared index to oldest written Rx packet
  282. * @free_count: Number of pre-allocated buffers in rx_free
  283. * @rx_free: list of free SKBs for use
  284. * @rx_used: List of Rx buffers with no SKB
  285. * @need_update: flag to indicate we need to update read/write index
  286. *
  287. * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers
  288. */
  289. struct iwl_rx_queue {
  290. __le32 *bd;
  291. dma_addr_t dma_addr;
  292. struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS];
  293. struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE];
  294. u32 processed;
  295. u32 read;
  296. u32 write;
  297. u32 free_count;
  298. struct list_head rx_free;
  299. struct list_head rx_used;
  300. int need_update;
  301. spinlock_t lock;
  302. };
  303. #define IWL_SUPPORTED_RATES_IE_LEN 8
  304. #define SCAN_INTERVAL 100
  305. #define MAX_A_CHANNELS 252
  306. #define MIN_A_CHANNELS 7
  307. #define MAX_B_CHANNELS 14
  308. #define MIN_B_CHANNELS 1
  309. #define MAX_TID_COUNT 9
  310. #define IWL_INVALID_RATE 0xFF
  311. #define IWL_INVALID_VALUE -1
  312. /**
  313. * struct iwl_ht_agg -- aggregation status while waiting for block-ack
  314. * @txq_id: Tx queue used for Tx attempt
  315. * @frame_count: # frames attempted by Tx command
  316. * @wait_for_ba: Expect block-ack before next Tx reply
  317. * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx window
  318. * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx window
  319. * @bitmap1: High order, one bit for each frame pending ACK in Tx window
  320. * @rate_n_flags: Rate at which Tx was attempted
  321. *
  322. * If REPLY_TX indicates that aggregation was attempted, driver must wait
  323. * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info
  324. * until block ack arrives.
  325. */
  326. struct iwl_ht_agg {
  327. u16 txq_id;
  328. u16 frame_count;
  329. u16 wait_for_ba;
  330. u16 start_idx;
  331. u64 bitmap;
  332. u32 rate_n_flags;
  333. #define IWL_AGG_OFF 0
  334. #define IWL_AGG_ON 1
  335. #define IWL_EMPTYING_HW_QUEUE_ADDBA 2
  336. #define IWL_EMPTYING_HW_QUEUE_DELBA 3
  337. u8 state;
  338. };
  339. struct iwl_tid_data {
  340. u16 seq_number;
  341. u16 tfds_in_queue;
  342. struct iwl_ht_agg agg;
  343. };
  344. struct iwl_hw_key {
  345. enum ieee80211_key_alg alg;
  346. int keylen;
  347. u8 keyidx;
  348. u8 key[32];
  349. };
  350. union iwl4965_ht_rate_supp {
  351. u16 rates;
  352. struct {
  353. u8 siso_rate;
  354. u8 mimo_rate;
  355. };
  356. };
  357. #define CFG_HT_RX_AMPDU_FACTOR_DEF (0x3)
  358. #define CFG_HT_MPDU_DENSITY_2USEC (0x5)
  359. #define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_2USEC
  360. struct iwl_ht_info {
  361. /* self configuration data */
  362. u8 is_ht;
  363. u8 supported_chan_width;
  364. u16 tx_mimo_ps_mode;
  365. u8 is_green_field;
  366. u8 sgf; /* HT_SHORT_GI_* short guard interval */
  367. u8 max_amsdu_size;
  368. u8 ampdu_factor;
  369. u8 mpdu_density;
  370. u8 supp_mcs_set[16];
  371. /* BSS related data */
  372. u8 control_channel;
  373. u8 extension_chan_offset;
  374. u8 tx_chan_width;
  375. u8 ht_protection;
  376. u8 non_GF_STA_present;
  377. };
  378. union iwl_qos_capabity {
  379. struct {
  380. u8 edca_count:4; /* bit 0-3 */
  381. u8 q_ack:1; /* bit 4 */
  382. u8 queue_request:1; /* bit 5 */
  383. u8 txop_request:1; /* bit 6 */
  384. u8 reserved:1; /* bit 7 */
  385. } q_AP;
  386. struct {
  387. u8 acvo_APSD:1; /* bit 0 */
  388. u8 acvi_APSD:1; /* bit 1 */
  389. u8 ac_bk_APSD:1; /* bit 2 */
  390. u8 ac_be_APSD:1; /* bit 3 */
  391. u8 q_ack:1; /* bit 4 */
  392. u8 max_len:2; /* bit 5-6 */
  393. u8 more_data_ack:1; /* bit 7 */
  394. } q_STA;
  395. u8 val;
  396. };
  397. /* QoS structures */
  398. struct iwl_qos_info {
  399. int qos_enable;
  400. int qos_active;
  401. union iwl_qos_capabity qos_cap;
  402. struct iwl_qosparam_cmd def_qos_parm;
  403. };
  404. #define STA_PS_STATUS_WAKE 0
  405. #define STA_PS_STATUS_SLEEP 1
  406. struct iwl_station_entry {
  407. struct iwl_addsta_cmd sta;
  408. struct iwl_tid_data tid[MAX_TID_COUNT];
  409. u8 used;
  410. u8 ps_status;
  411. struct iwl_hw_key keyinfo;
  412. };
  413. /* one for each uCode image (inst/data, boot/init/runtime) */
  414. struct fw_desc {
  415. void *v_addr; /* access by driver */
  416. dma_addr_t p_addr; /* access by card's busmaster DMA */
  417. u32 len; /* bytes */
  418. };
  419. /* uCode file layout */
  420. struct iwl_ucode {
  421. __le32 ver; /* major/minor/subminor */
  422. __le32 inst_size; /* bytes of runtime instructions */
  423. __le32 data_size; /* bytes of runtime data */
  424. __le32 init_size; /* bytes of initialization instructions */
  425. __le32 init_data_size; /* bytes of initialization data */
  426. __le32 boot_size; /* bytes of bootstrap instructions */
  427. u8 data[0]; /* data in same order as "size" elements */
  428. };
  429. struct iwl4965_ibss_seq {
  430. u8 mac[ETH_ALEN];
  431. u16 seq_num;
  432. u16 frag_num;
  433. unsigned long packet_time;
  434. struct list_head list;
  435. };
  436. struct iwl_sensitivity_ranges {
  437. u16 min_nrg_cck;
  438. u16 max_nrg_cck;
  439. u16 nrg_th_cck;
  440. u16 nrg_th_ofdm;
  441. u16 auto_corr_min_ofdm;
  442. u16 auto_corr_min_ofdm_mrc;
  443. u16 auto_corr_min_ofdm_x1;
  444. u16 auto_corr_min_ofdm_mrc_x1;
  445. u16 auto_corr_max_ofdm;
  446. u16 auto_corr_max_ofdm_mrc;
  447. u16 auto_corr_max_ofdm_x1;
  448. u16 auto_corr_max_ofdm_mrc_x1;
  449. u16 auto_corr_max_cck;
  450. u16 auto_corr_max_cck_mrc;
  451. u16 auto_corr_min_cck;
  452. u16 auto_corr_min_cck_mrc;
  453. };
  454. #define IWL_FAT_CHANNEL_52 BIT(IEEE80211_BAND_5GHZ)
  455. /**
  456. * struct iwl_hw_params
  457. * @max_txq_num: Max # Tx queues supported
  458. * @tx/rx_chains_num: Number of TX/RX chains
  459. * @valid_tx/rx_ant: usable antennas
  460. * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2)
  461. * @max_rxq_log: Log-base-2 of max_rxq_size
  462. * @rx_buf_size: Rx buffer size
  463. * @max_stations:
  464. * @bcast_sta_id:
  465. * @fat_channel: is 40MHz width possible in band 2.4
  466. * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ)
  467. * @sw_crypto: 0 for hw, 1 for sw
  468. * @max_xxx_size: for ucode uses
  469. * @ct_kill_threshold: temperature threshold
  470. * @struct iwl_sensitivity_ranges: range of sensitivity values
  471. * @first_ampdu_q: first HW queue available for ampdu
  472. */
  473. struct iwl_hw_params {
  474. u16 max_txq_num;
  475. u8 tx_chains_num;
  476. u8 rx_chains_num;
  477. u8 valid_tx_ant;
  478. u8 valid_rx_ant;
  479. u16 max_rxq_size;
  480. u16 max_rxq_log;
  481. u32 rx_buf_size;
  482. u32 max_pkt_size;
  483. u8 max_stations;
  484. u8 bcast_sta_id;
  485. u8 fat_channel;
  486. u8 sw_crypto;
  487. u32 max_inst_size;
  488. u32 max_data_size;
  489. u32 max_bsm_size;
  490. u32 ct_kill_threshold; /* value in hw-dependent units */
  491. const struct iwl_sensitivity_ranges *sens;
  492. u8 first_ampdu_q;
  493. };
  494. #define HT_SHORT_GI_20MHZ (1 << 0)
  495. #define HT_SHORT_GI_40MHZ (1 << 1)
  496. #define IWL_RX_HDR(x) ((struct iwl4965_rx_frame_hdr *)(\
  497. x->u.rx_frame.stats.payload + \
  498. x->u.rx_frame.stats.phy_count))
  499. #define IWL_RX_END(x) ((struct iwl4965_rx_frame_end *)(\
  500. IWL_RX_HDR(x)->payload + \
  501. le16_to_cpu(IWL_RX_HDR(x)->len)))
  502. #define IWL_RX_STATS(x) (&x->u.rx_frame.stats)
  503. #define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload)
  504. /******************************************************************************
  505. *
  506. * Functions implemented in iwl-base.c which are forward declared here
  507. * for use by iwl-*.c
  508. *
  509. *****************************************************************************/
  510. struct iwl_addsta_cmd;
  511. extern int iwl_send_add_sta(struct iwl_priv *priv,
  512. struct iwl_addsta_cmd *sta, u8 flags);
  513. u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap,
  514. u8 flags, struct ieee80211_ht_info *ht_info);
  515. extern unsigned int iwl4965_fill_beacon_frame(struct iwl_priv *priv,
  516. struct ieee80211_hdr *hdr,
  517. const u8 *dest, int left);
  518. extern void iwl4965_update_chain_flags(struct iwl_priv *priv);
  519. int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
  520. extern const u8 iwl_bcast_addr[ETH_ALEN];
  521. /******************************************************************************
  522. *
  523. * Functions implemented in iwl-[34]*.c which are forward declared here
  524. * for use by iwl-base.c
  525. *
  526. * NOTE: The implementation of these functions are hardware specific
  527. * which is why they are in the hardware specific files (vs. iwl-base.c)
  528. *
  529. * Naming convention --
  530. * iwl4965_ <-- Its part of iwlwifi (should be changed to iwl4965_)
  531. * iwl4965_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
  532. * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
  533. * iwl4965_bg_ <-- Called from work queue context
  534. * iwl4965_mac_ <-- mac80211 callback
  535. *
  536. ****************************************************************************/
  537. extern int iwl_rxq_stop(struct iwl_priv *priv);
  538. extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
  539. extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
  540. struct iwl_frame *frame, u8 rate);
  541. extern void iwl4965_disable_events(struct iwl_priv *priv);
  542. extern int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel);
  543. extern int iwl_queue_space(const struct iwl_queue *q);
  544. static inline int iwl_queue_used(const struct iwl_queue *q, int i)
  545. {
  546. return q->write_ptr > q->read_ptr ?
  547. (i >= q->read_ptr && i < q->write_ptr) :
  548. !(i < q->read_ptr && i >= q->write_ptr);
  549. }
  550. static inline u8 get_cmd_index(struct iwl_queue *q, u32 index, int is_huge)
  551. {
  552. /* This is for scan command, the big buffer at end of command array */
  553. if (is_huge)
  554. return q->n_window; /* must be power of 2 */
  555. /* Otherwise, use normal size buffers */
  556. return index & (q->n_window - 1);
  557. }
  558. struct iwl_priv;
  559. /*
  560. * Forward declare iwl-4965.c functions for iwl-base.c
  561. */
  562. extern void iwl4965_rf_kill_ct_config(struct iwl_priv *priv);
  563. int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw,
  564. enum ieee80211_ampdu_mlme_action action,
  565. const u8 *addr, u16 tid, u16 *ssn);
  566. int iwl4965_check_empty_hw_queue(struct iwl_priv *priv, int sta_id,
  567. u8 tid, int txq_id);
  568. /* Structures, enum, and defines specific to the 4965 */
  569. #define IWL_KW_SIZE 0x1000 /*4k */
  570. struct iwl_kw {
  571. dma_addr_t dma_addr;
  572. void *v_addr;
  573. size_t size;
  574. };
  575. #define IWL_CHANNEL_WIDTH_20MHZ 0
  576. #define IWL_CHANNEL_WIDTH_40MHZ 1
  577. #define IWL_MIMO_PS_STATIC 0
  578. #define IWL_MIMO_PS_NONE 3
  579. #define IWL_MIMO_PS_DYNAMIC 1
  580. #define IWL_MIMO_PS_INVALID 2
  581. #define IWL_OPERATION_MODE_AUTO 0
  582. #define IWL_OPERATION_MODE_HT_ONLY 1
  583. #define IWL_OPERATION_MODE_MIXED 2
  584. #define IWL_OPERATION_MODE_20MHZ 3
  585. #define IWL_TX_CRC_SIZE 4
  586. #define IWL_TX_DELIMITER_SIZE 4
  587. #define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000
  588. struct iwl4965_lq_mngr {
  589. spinlock_t lock;
  590. s32 max_window_size;
  591. s32 *expected_tpt;
  592. u8 *next_higher_rate;
  593. u8 *next_lower_rate;
  594. unsigned long stamp;
  595. unsigned long stamp_last;
  596. u32 flush_time;
  597. u32 tx_packets;
  598. };
  599. /* Sensitivity and chain noise calibration */
  600. #define INTERFERENCE_DATA_AVAILABLE __constant_cpu_to_le32(1)
  601. #define INITIALIZATION_VALUE 0xFFFF
  602. #define CAL_NUM_OF_BEACONS 20
  603. #define MAXIMUM_ALLOWED_PATHLOSS 15
  604. #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3
  605. #define MAX_FA_OFDM 50
  606. #define MIN_FA_OFDM 5
  607. #define MAX_FA_CCK 50
  608. #define MIN_FA_CCK 5
  609. #define AUTO_CORR_STEP_OFDM 1
  610. #define AUTO_CORR_STEP_CCK 3
  611. #define AUTO_CORR_MAX_TH_CCK 160
  612. #define NRG_DIFF 2
  613. #define NRG_STEP_CCK 2
  614. #define NRG_MARGIN 8
  615. #define MAX_NUMBER_CCK_NO_FA 100
  616. #define AUTO_CORR_CCK_MIN_VAL_DEF (125)
  617. #define CHAIN_A 0
  618. #define CHAIN_B 1
  619. #define CHAIN_C 2
  620. #define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4
  621. #define ALL_BAND_FILTER 0xFF00
  622. #define IN_BAND_FILTER 0xFF
  623. #define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF
  624. #define NRG_NUM_PREV_STAT_L 20
  625. #define NUM_RX_CHAINS 3
  626. enum iwl4965_false_alarm_state {
  627. IWL_FA_TOO_MANY = 0,
  628. IWL_FA_TOO_FEW = 1,
  629. IWL_FA_GOOD_RANGE = 2,
  630. };
  631. enum iwl4965_chain_noise_state {
  632. IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
  633. IWL_CHAIN_NOISE_ACCUMULATE = 1,
  634. IWL_CHAIN_NOISE_CALIBRATED = 2,
  635. };
  636. enum iwl4965_calib_enabled_state {
  637. IWL_CALIB_DISABLED = 0, /* must be 0 */
  638. IWL_CALIB_ENABLED = 1,
  639. };
  640. struct statistics_general_data {
  641. u32 beacon_silence_rssi_a;
  642. u32 beacon_silence_rssi_b;
  643. u32 beacon_silence_rssi_c;
  644. u32 beacon_energy_a;
  645. u32 beacon_energy_b;
  646. u32 beacon_energy_c;
  647. };
  648. struct iwl_calib_results {
  649. void *tx_iq_res;
  650. void *tx_iq_perd_res;
  651. void *lo_res;
  652. u32 tx_iq_res_len;
  653. u32 tx_iq_perd_res_len;
  654. u32 lo_res_len;
  655. };
  656. enum ucode_type {
  657. UCODE_NONE = 0,
  658. UCODE_INIT,
  659. UCODE_RT
  660. };
  661. /* Sensitivity calib data */
  662. struct iwl_sensitivity_data {
  663. u32 auto_corr_ofdm;
  664. u32 auto_corr_ofdm_mrc;
  665. u32 auto_corr_ofdm_x1;
  666. u32 auto_corr_ofdm_mrc_x1;
  667. u32 auto_corr_cck;
  668. u32 auto_corr_cck_mrc;
  669. u32 last_bad_plcp_cnt_ofdm;
  670. u32 last_fa_cnt_ofdm;
  671. u32 last_bad_plcp_cnt_cck;
  672. u32 last_fa_cnt_cck;
  673. u32 nrg_curr_state;
  674. u32 nrg_prev_state;
  675. u32 nrg_value[10];
  676. u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L];
  677. u32 nrg_silence_ref;
  678. u32 nrg_energy_idx;
  679. u32 nrg_silence_idx;
  680. u32 nrg_th_cck;
  681. s32 nrg_auto_corr_silence_diff;
  682. u32 num_in_cck_no_fa;
  683. u32 nrg_th_ofdm;
  684. };
  685. /* Chain noise (differential Rx gain) calib data */
  686. struct iwl_chain_noise_data {
  687. u8 state;
  688. u16 beacon_count;
  689. u32 chain_noise_a;
  690. u32 chain_noise_b;
  691. u32 chain_noise_c;
  692. u32 chain_signal_a;
  693. u32 chain_signal_b;
  694. u32 chain_signal_c;
  695. u8 disconn_array[NUM_RX_CHAINS];
  696. u8 delta_gain_code[NUM_RX_CHAINS];
  697. u8 radio_write;
  698. };
  699. #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
  700. #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */
  701. #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
  702. enum {
  703. MEASUREMENT_READY = (1 << 0),
  704. MEASUREMENT_ACTIVE = (1 << 1),
  705. };
  706. #endif
  707. #define IWL_MAX_NUM_QUEUES 20 /* FIXME: do dynamic allocation */
  708. struct iwl_priv {
  709. /* ieee device used by generic ieee processing code */
  710. struct ieee80211_hw *hw;
  711. struct ieee80211_channel *ieee_channels;
  712. struct ieee80211_rate *ieee_rates;
  713. struct iwl_cfg *cfg;
  714. /* temporary frame storage list */
  715. struct list_head free_frames;
  716. int frames_count;
  717. enum ieee80211_band band;
  718. int alloc_rxb_skb;
  719. bool add_radiotap;
  720. void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv,
  721. struct iwl_rx_mem_buffer *rxb);
  722. struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS];
  723. #ifdef CONFIG_IWL4965_SPECTRUM_MEASUREMENT
  724. /* spectrum measurement report caching */
  725. struct iwl4965_spectrum_notification measure_report;
  726. u8 measurement_status;
  727. #endif
  728. /* ucode beacon time */
  729. u32 ucode_beacon_time;
  730. /* we allocate array of iwl4965_channel_info for NIC's valid channels.
  731. * Access via channel # using indirect index array */
  732. struct iwl_channel_info *channel_info; /* channel info array */
  733. u8 channel_count; /* # of channels */
  734. /* each calibration channel group in the EEPROM has a derived
  735. * clip setting for each rate. */
  736. const struct iwl4965_clip_group clip_groups[5];
  737. /* thermal calibration */
  738. s32 temperature; /* degrees Kelvin */
  739. s32 last_temperature;
  740. /* init calibration results */
  741. struct iwl_calib_results calib_results;
  742. /* Scan related variables */
  743. unsigned long last_scan_jiffies;
  744. unsigned long next_scan_jiffies;
  745. unsigned long scan_start;
  746. unsigned long scan_pass_start;
  747. unsigned long scan_start_tsf;
  748. int scan_bands;
  749. int one_direct_scan;
  750. u8 direct_ssid_len;
  751. u8 direct_ssid[IW_ESSID_MAX_SIZE];
  752. struct iwl_scan_cmd *scan;
  753. u32 scan_tx_ant[IEEE80211_NUM_BANDS];
  754. /* spinlock */
  755. spinlock_t lock; /* protect general shared data */
  756. spinlock_t hcmd_lock; /* protect hcmd */
  757. struct mutex mutex;
  758. /* basic pci-network driver stuff */
  759. struct pci_dev *pci_dev;
  760. /* pci hardware address support */
  761. void __iomem *hw_base;
  762. u32 hw_rev;
  763. u32 hw_wa_rev;
  764. u8 rev_id;
  765. /* uCode images, save to reload in case of failure */
  766. struct fw_desc ucode_code; /* runtime inst */
  767. struct fw_desc ucode_data; /* runtime data original */
  768. struct fw_desc ucode_data_backup; /* runtime data save/restore */
  769. struct fw_desc ucode_init; /* initialization inst */
  770. struct fw_desc ucode_init_data; /* initialization data */
  771. struct fw_desc ucode_boot; /* bootstrap inst */
  772. enum ucode_type ucode_type;
  773. u8 ucode_write_complete; /* the image write is complete */
  774. struct iwl4965_rxon_time_cmd rxon_timing;
  775. /* We declare this const so it can only be
  776. * changed via explicit cast within the
  777. * routines that actually update the physical
  778. * hardware */
  779. const struct iwl_rxon_cmd active_rxon;
  780. struct iwl_rxon_cmd staging_rxon;
  781. int error_recovering;
  782. struct iwl_rxon_cmd recovery_rxon;
  783. /* 1st responses from initialize and runtime uCode images.
  784. * 4965's initialize alive response contains some calibration data. */
  785. struct iwl_init_alive_resp card_alive_init;
  786. struct iwl_alive_resp card_alive;
  787. #ifdef CONFIG_IWLWIFI_RFKILL
  788. struct rfkill *rfkill;
  789. #endif
  790. #ifdef CONFIG_IWLWIFI_LEDS
  791. struct iwl_led led[IWL_LED_TRG_MAX];
  792. unsigned long last_blink_time;
  793. u8 last_blink_rate;
  794. u8 allow_blinking;
  795. u64 led_tpt;
  796. #endif
  797. u16 active_rate;
  798. u16 active_rate_basic;
  799. u8 assoc_station_added;
  800. u8 use_ant_b_for_management_frame; /* Tx antenna selection */
  801. u8 start_calib;
  802. struct iwl_sensitivity_data sensitivity_data;
  803. struct iwl_chain_noise_data chain_noise_data;
  804. __le16 sensitivity_tbl[HD_TABLE_SIZE];
  805. struct iwl_ht_info current_ht_config;
  806. u8 last_phy_res[100];
  807. /* Rate scaling data */
  808. struct iwl4965_lq_mngr lq_mngr;
  809. /* Rate scaling data */
  810. s8 data_retry_limit;
  811. u8 retry_rate;
  812. wait_queue_head_t wait_command_queue;
  813. int activity_timer_active;
  814. /* Rx and Tx DMA processing queues */
  815. struct iwl_rx_queue rxq;
  816. struct iwl_tx_queue txq[IWL_MAX_NUM_QUEUES];
  817. unsigned long txq_ctx_active_msk;
  818. struct iwl_kw kw; /* keep warm address */
  819. u32 scd_base_addr; /* scheduler sram base address */
  820. unsigned long status;
  821. int last_rx_rssi; /* From Rx packet statisitics */
  822. int last_rx_noise; /* From beacon statistics */
  823. /* counts mgmt, ctl, and data packets */
  824. struct traffic_stats {
  825. u32 cnt;
  826. u64 bytes;
  827. } tx_stats[3], rx_stats[3];
  828. struct iwl_power_mgr power_data;
  829. struct iwl_notif_statistics statistics;
  830. unsigned long last_statistics_time;
  831. /* context information */
  832. u8 essid[IW_ESSID_MAX_SIZE];
  833. u8 essid_len;
  834. u16 rates_mask;
  835. u32 power_mode;
  836. u32 antenna;
  837. u8 bssid[ETH_ALEN];
  838. u16 rts_threshold;
  839. u8 mac_addr[ETH_ALEN];
  840. /*station table variables */
  841. spinlock_t sta_lock;
  842. int num_stations;
  843. struct iwl_station_entry stations[IWL_STATION_COUNT];
  844. struct iwl_wep_key wep_keys[WEP_KEYS_MAX];
  845. u8 default_wep_key;
  846. u8 key_mapping_key;
  847. unsigned long ucode_key_table;
  848. /* Indication if ieee80211_ops->open has been called */
  849. u8 is_open;
  850. u8 mac80211_registered;
  851. /* Rx'd packet timing information */
  852. u32 last_beacon_time;
  853. u64 last_tsf;
  854. /* eeprom */
  855. u8 *eeprom;
  856. struct iwl_eeprom_calib_info *calib_info;
  857. enum ieee80211_if_types iw_mode;
  858. struct sk_buff *ibss_beacon;
  859. /* Last Rx'd beacon timestamp */
  860. u64 timestamp;
  861. u16 beacon_int;
  862. struct ieee80211_vif *vif;
  863. struct iwl_hw_params hw_params;
  864. /* driver/uCode shared Tx Byte Counts and Rx status */
  865. void *shared_virt;
  866. int rb_closed_offset;
  867. /* Physical Pointer to Tx Byte Counts and Rx status */
  868. dma_addr_t shared_phys;
  869. /* Current association information needed to configure the
  870. * hardware */
  871. u16 assoc_id;
  872. u16 assoc_capability;
  873. u8 ps_mode;
  874. struct iwl_qos_info qos_data;
  875. struct workqueue_struct *workqueue;
  876. struct work_struct up;
  877. struct work_struct restart;
  878. struct work_struct calibrated_work;
  879. struct work_struct scan_completed;
  880. struct work_struct rx_replenish;
  881. struct work_struct rf_kill;
  882. struct work_struct abort_scan;
  883. struct work_struct update_link_led;
  884. struct work_struct auth_work;
  885. struct work_struct report_work;
  886. struct work_struct request_scan;
  887. struct work_struct beacon_update;
  888. struct work_struct set_monitor;
  889. struct tasklet_struct irq_tasklet;
  890. struct delayed_work init_alive_start;
  891. struct delayed_work alive_start;
  892. struct delayed_work scan_check;
  893. /* TX Power */
  894. s8 tx_power_user_lmt;
  895. s8 tx_power_channel_lmt;
  896. #ifdef CONFIG_PM
  897. u32 pm_state[16];
  898. #endif
  899. #ifdef CONFIG_IWLWIFI_DEBUG
  900. /* debugging info */
  901. u32 debug_level;
  902. u32 framecnt_to_us;
  903. atomic_t restrict_refcnt;
  904. #ifdef CONFIG_IWLWIFI_DEBUGFS
  905. /* debugfs */
  906. struct iwl_debugfs *dbgfs;
  907. #endif /* CONFIG_IWLWIFI_DEBUGFS */
  908. #endif /* CONFIG_IWLWIFI_DEBUG */
  909. struct work_struct txpower_work;
  910. u32 disable_sens_cal;
  911. u32 disable_chain_noise_cal;
  912. u32 disable_tx_power_cal;
  913. struct work_struct run_time_calib_work;
  914. struct timer_list statistics_periodic;
  915. }; /*iwl_priv */
  916. static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id)
  917. {
  918. set_bit(txq_id, &priv->txq_ctx_active_msk);
  919. }
  920. static inline void iwl_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id)
  921. {
  922. clear_bit(txq_id, &priv->txq_ctx_active_msk);
  923. }
  924. #ifdef CONFIG_IWLWIFI_DEBUG
  925. const char *iwl_get_tx_fail_reason(u32 status);
  926. #else
  927. static inline const char *iwl_get_tx_fail_reason(u32 status) { return ""; }
  928. #endif
  929. static inline struct ieee80211_hdr *iwl_tx_queue_get_hdr(struct iwl_priv *priv,
  930. int txq_id, int idx)
  931. {
  932. if (priv->txq[txq_id].txb[idx].skb[0])
  933. return (struct ieee80211_hdr *)priv->txq[txq_id].
  934. txb[idx].skb[0]->data;
  935. return NULL;
  936. }
  937. static inline int iwl_is_associated(struct iwl_priv *priv)
  938. {
  939. return (priv->active_rxon.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0;
  940. }
  941. static inline int is_channel_valid(const struct iwl_channel_info *ch_info)
  942. {
  943. if (ch_info == NULL)
  944. return 0;
  945. return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0;
  946. }
  947. static inline int is_channel_radar(const struct iwl_channel_info *ch_info)
  948. {
  949. return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0;
  950. }
  951. static inline u8 is_channel_a_band(const struct iwl_channel_info *ch_info)
  952. {
  953. return ch_info->band == IEEE80211_BAND_5GHZ;
  954. }
  955. static inline u8 is_channel_bg_band(const struct iwl_channel_info *ch_info)
  956. {
  957. return ch_info->band == IEEE80211_BAND_2GHZ;
  958. }
  959. static inline int is_channel_passive(const struct iwl_channel_info *ch)
  960. {
  961. return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0;
  962. }
  963. static inline int is_channel_ibss(const struct iwl_channel_info *ch)
  964. {
  965. return ((ch->flags & EEPROM_CHANNEL_IBSS)) ? 1 : 0;
  966. }
  967. #ifdef CONFIG_IWLWIFI_DEBUG
  968. static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level,
  969. void *p, u32 len)
  970. {
  971. if (!(priv->debug_level & level))
  972. return;
  973. print_hex_dump(KERN_DEBUG, "iwl data: ", DUMP_PREFIX_OFFSET, 16, 1,
  974. p, len, 1);
  975. }
  976. #else
  977. static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level,
  978. void *p, u32 len)
  979. {
  980. }
  981. #endif
  982. extern const struct iwl_channel_info *iwl_get_channel_info(
  983. const struct iwl_priv *priv, enum ieee80211_band band, u16 channel);
  984. /* Requires full declaration of iwl_priv before including */
  985. #endif /* __iwl_dev_h__ */