p54.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. /* memory management (as seen by the firmware) */
  149. u32 rx_start;
  150. u32 rx_end;
  151. u16 rx_mtu;
  152. u8 headroom;
  153. u8 tailroom;
  154. /* firmware/hardware info */
  155. unsigned int tx_hdr_len;
  156. unsigned int fw_var;
  157. unsigned int fw_interface;
  158. u8 version;
  159. /* (e)DCF / QOS state */
  160. bool use_short_slot;
  161. spinlock_t tx_stats_lock;
  162. struct p54_tx_queue_stats tx_stats[8];
  163. struct p54_edcf_queue_param qos_params[8];
  164. /* Radio data */
  165. u16 rxhw;
  166. u8 rx_diversity_mask;
  167. u8 tx_diversity_mask;
  168. unsigned int output_power;
  169. struct p54_rssi_db_entry *cur_rssi;
  170. int noise;
  171. /* calibration, output power limit and rssi<->dBm conversation data */
  172. struct pda_iq_autocal_entry *iq_autocal;
  173. unsigned int iq_autocal_len;
  174. struct p54_cal_database *curve_data;
  175. struct p54_cal_database *output_limit;
  176. struct p54_cal_database *rssi_db;
  177. struct ieee80211_supported_band *band_table[IEEE80211_NUM_BANDS];
  178. /* BBP/MAC state */
  179. u8 mac_addr[ETH_ALEN];
  180. u8 bssid[ETH_ALEN];
  181. u8 mc_maclist[4][ETH_ALEN];
  182. u16 wakeup_timer;
  183. unsigned int filter_flags;
  184. int mc_maclist_num;
  185. int mode;
  186. u32 tsf_low32, tsf_high32;
  187. u32 basic_rate_mask;
  188. u16 aid;
  189. u8 coverage_class;
  190. bool powersave_override;
  191. __le32 beacon_req_id;
  192. struct completion beacon_comp;
  193. /* cryptographic engine information */
  194. u8 privacy_caps;
  195. u8 rx_keycache_size;
  196. unsigned long *used_rxkeys;
  197. /* LED management */
  198. #ifdef CONFIG_P54_LEDS
  199. struct p54_led_dev leds[4];
  200. struct delayed_work led_work;
  201. #endif /* CONFIG_P54_LEDS */
  202. u16 softled_state; /* bit field of glowing LEDs */
  203. /* statistics */
  204. struct ieee80211_low_level_stats stats;
  205. struct delayed_work work;
  206. /* eeprom handling */
  207. void *eeprom;
  208. struct completion eeprom_comp;
  209. struct mutex eeprom_mutex;
  210. };
  211. /* interfaces for the drivers */
  212. int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb);
  213. void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb);
  214. int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw);
  215. int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len);
  216. int p54_read_eeprom(struct ieee80211_hw *dev);
  217. struct ieee80211_hw *p54_init_common(size_t priv_data_len);
  218. int p54_register_common(struct ieee80211_hw *dev, struct device *pdev);
  219. void p54_free_common(struct ieee80211_hw *dev);
  220. void p54_unregister_common(struct ieee80211_hw *dev);
  221. #endif /* P54_H */