p54.h 6.0 KB

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