p54.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /*
  2. * Shared defines for all mac80211 Prism54 code
  3. *
  4. * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
  5. *
  6. * Based on the islsm (softmac prism54) driver, which is:
  7. * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef P54_H
  14. #define P54_H
  15. #ifdef CONFIG_P54_LEDS
  16. #include <linux/leds.h>
  17. #endif /* CONFIG_P54_LEDS */
  18. #define ISL38XX_DEV_FIRMWARE_ADDR 0x20000
  19. #define BR_CODE_MIN 0x80000000
  20. #define BR_CODE_COMPONENT_ID 0x80000001
  21. #define BR_CODE_COMPONENT_VERSION 0x80000002
  22. #define BR_CODE_DEPENDENT_IF 0x80000003
  23. #define BR_CODE_EXPOSED_IF 0x80000004
  24. #define BR_CODE_DESCR 0x80000101
  25. #define BR_CODE_MAX 0x8FFFFFFF
  26. #define BR_CODE_END_OF_BRA 0xFF0000FF
  27. #define LEGACY_BR_CODE_END_OF_BRA 0xFFFFFFFF
  28. struct bootrec {
  29. __le32 code;
  30. __le32 len;
  31. u32 data[10];
  32. } __packed;
  33. /* Interface role definitions */
  34. #define BR_INTERFACE_ROLE_SERVER 0x0000
  35. #define BR_INTERFACE_ROLE_CLIENT 0x8000
  36. #define BR_DESC_PRIV_CAP_WEP BIT(0)
  37. #define BR_DESC_PRIV_CAP_TKIP BIT(1)
  38. #define BR_DESC_PRIV_CAP_MICHAEL BIT(2)
  39. #define BR_DESC_PRIV_CAP_CCX_CP BIT(3)
  40. #define BR_DESC_PRIV_CAP_CCX_MIC BIT(4)
  41. #define BR_DESC_PRIV_CAP_AESCCMP BIT(5)
  42. struct bootrec_desc {
  43. __le16 modes;
  44. __le16 flags;
  45. __le32 rx_start;
  46. __le32 rx_end;
  47. u8 headroom;
  48. u8 tailroom;
  49. u8 tx_queues;
  50. u8 tx_depth;
  51. u8 privacy_caps;
  52. u8 rx_keycache_size;
  53. u8 time_size;
  54. u8 padding;
  55. u8 rates[16];
  56. u8 padding2[4];
  57. __le16 rx_mtu;
  58. } __packed;
  59. #define FW_FMAC 0x464d4143
  60. #define FW_LM86 0x4c4d3836
  61. #define FW_LM87 0x4c4d3837
  62. #define FW_LM20 0x4c4d3230
  63. struct bootrec_comp_id {
  64. __le32 fw_variant;
  65. } __packed;
  66. struct bootrec_comp_ver {
  67. char fw_version[24];
  68. } __packed;
  69. struct bootrec_end {
  70. __le16 crc;
  71. u8 padding[2];
  72. u8 md5[16];
  73. } __packed;
  74. /* provide 16 bytes for the transport back-end */
  75. #define P54_TX_INFO_DATA_SIZE 16
  76. /* stored in ieee80211_tx_info's rate_driver_data */
  77. struct p54_tx_info {
  78. u32 start_addr;
  79. u32 end_addr;
  80. union {
  81. void *data[P54_TX_INFO_DATA_SIZE / sizeof(void *)];
  82. struct {
  83. u32 extra_len;
  84. };
  85. };
  86. };
  87. #define P54_MAX_CTRL_FRAME_LEN 0x1000
  88. #define P54_SET_QUEUE(queue, ai_fs, cw_min, cw_max, _txop) \
  89. do { \
  90. queue.aifs = cpu_to_le16(ai_fs); \
  91. queue.cwmin = cpu_to_le16(cw_min); \
  92. queue.cwmax = cpu_to_le16(cw_max); \
  93. queue.txop = cpu_to_le16(_txop); \
  94. } while (0)
  95. struct p54_edcf_queue_param {
  96. __le16 aifs;
  97. __le16 cwmin;
  98. __le16 cwmax;
  99. __le16 txop;
  100. } __packed;
  101. struct p54_rssi_db_entry {
  102. u16 freq;
  103. s16 mul;
  104. s16 add;
  105. s16 longbow_unkn;
  106. s16 longbow_unk2;
  107. };
  108. struct p54_cal_database {
  109. size_t entries;
  110. size_t entry_size;
  111. size_t offset;
  112. size_t len;
  113. u8 data[0];
  114. };
  115. #define EEPROM_READBACK_LEN 0x3fc
  116. enum fw_state {
  117. FW_STATE_OFF,
  118. FW_STATE_BOOTING,
  119. FW_STATE_READY,
  120. FW_STATE_RESET,
  121. FW_STATE_RESETTING,
  122. };
  123. #ifdef CONFIG_P54_LEDS
  124. #define P54_LED_MAX_NAME_LEN 31
  125. struct p54_led_dev {
  126. struct ieee80211_hw *hw_dev;
  127. struct led_classdev led_dev;
  128. char name[P54_LED_MAX_NAME_LEN + 1];
  129. unsigned int toggled;
  130. unsigned int index;
  131. unsigned int registered;
  132. };
  133. #endif /* CONFIG_P54_LEDS */
  134. struct p54_tx_queue_stats {
  135. unsigned int len;
  136. unsigned int limit;
  137. unsigned int count;
  138. };
  139. struct p54_common {
  140. struct ieee80211_hw *hw;
  141. struct ieee80211_vif *vif;
  142. void (*tx)(struct ieee80211_hw *dev, struct sk_buff *skb);
  143. int (*open)(struct ieee80211_hw *dev);
  144. void (*stop)(struct ieee80211_hw *dev);
  145. struct sk_buff_head tx_pending;
  146. struct sk_buff_head tx_queue;
  147. struct mutex conf_mutex;
  148. bool registered;
  149. /* memory management (as seen by the firmware) */
  150. u32 rx_start;
  151. u32 rx_end;
  152. u16 rx_mtu;
  153. u8 headroom;
  154. u8 tailroom;
  155. /* firmware/hardware info */
  156. unsigned int tx_hdr_len;
  157. unsigned int fw_var;
  158. unsigned int fw_interface;
  159. u8 version;
  160. /* (e)DCF / QOS state */
  161. bool use_short_slot;
  162. spinlock_t tx_stats_lock;
  163. struct p54_tx_queue_stats tx_stats[8];
  164. struct p54_edcf_queue_param qos_params[8];
  165. /* Radio data */
  166. u16 rxhw;
  167. u8 rx_diversity_mask;
  168. u8 tx_diversity_mask;
  169. unsigned int output_power;
  170. struct p54_rssi_db_entry *cur_rssi;
  171. struct ieee80211_channel *curchan;
  172. struct survey_info *survey;
  173. unsigned int chan_num;
  174. struct completion stat_comp;
  175. bool update_stats;
  176. struct {
  177. unsigned int timestamp;
  178. unsigned int cached_cca;
  179. unsigned int cached_tx;
  180. unsigned int cached_rssi;
  181. u64 active;
  182. u64 cca;
  183. u64 tx;
  184. u64 rssi;
  185. } survey_raw;
  186. int noise;
  187. /* calibration, output power limit and rssi<->dBm conversation data */
  188. struct pda_iq_autocal_entry *iq_autocal;
  189. unsigned int iq_autocal_len;
  190. struct p54_cal_database *curve_data;
  191. struct p54_cal_database *output_limit;
  192. struct p54_cal_database *rssi_db;
  193. struct ieee80211_supported_band *band_table[IEEE80211_NUM_BANDS];
  194. /* BBP/MAC state */
  195. u8 mac_addr[ETH_ALEN];
  196. u8 bssid[ETH_ALEN];
  197. u8 mc_maclist[4][ETH_ALEN];
  198. u16 wakeup_timer;
  199. unsigned int filter_flags;
  200. int mc_maclist_num;
  201. int mode;
  202. u32 tsf_low32, tsf_high32;
  203. u32 basic_rate_mask;
  204. u16 aid;
  205. u8 coverage_class;
  206. bool phy_idle;
  207. bool phy_ps;
  208. bool powersave_override;
  209. __le32 beacon_req_id;
  210. struct completion beacon_comp;
  211. /* cryptographic engine information */
  212. u8 privacy_caps;
  213. u8 rx_keycache_size;
  214. unsigned long *used_rxkeys;
  215. /* LED management */
  216. #ifdef CONFIG_P54_LEDS
  217. struct p54_led_dev leds[4];
  218. struct delayed_work led_work;
  219. #endif /* CONFIG_P54_LEDS */
  220. u16 softled_state; /* bit field of glowing LEDs */
  221. /* statistics */
  222. struct ieee80211_low_level_stats stats;
  223. struct delayed_work work;
  224. /* eeprom handling */
  225. void *eeprom;
  226. struct completion eeprom_comp;
  227. struct mutex eeprom_mutex;
  228. };
  229. /* interfaces for the drivers */
  230. int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb);
  231. void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb);
  232. int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw);
  233. int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len);
  234. int p54_read_eeprom(struct ieee80211_hw *dev);
  235. struct ieee80211_hw *p54_init_common(size_t priv_data_len);
  236. int p54_register_common(struct ieee80211_hw *dev, struct device *pdev);
  237. void p54_free_common(struct ieee80211_hw *dev);
  238. void p54_unregister_common(struct ieee80211_hw *dev);
  239. #endif /* P54_H */