lmac.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. /*
  2. * LMAC Interface specific definitions for mac80211 Prism54 drivers
  3. *
  4. * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
  5. * Copyright (c) 2007 - 2009, Christian Lamparter <chunkeey@web.de>
  6. *
  7. * Based on:
  8. * - the islsm (softmac prism54) driver, which is:
  9. * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al.
  10. *
  11. * - LMAC API interface header file for STLC4560 (lmac_longbow.h)
  12. * Copyright (C) 2007 Conexant Systems, Inc.
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #ifndef LMAC_H
  19. #define LMAC_H
  20. enum p54_control_frame_types {
  21. P54_CONTROL_TYPE_SETUP = 0,
  22. P54_CONTROL_TYPE_SCAN,
  23. P54_CONTROL_TYPE_TRAP,
  24. P54_CONTROL_TYPE_DCFINIT,
  25. P54_CONTROL_TYPE_RX_KEYCACHE,
  26. P54_CONTROL_TYPE_TIM,
  27. P54_CONTROL_TYPE_PSM,
  28. P54_CONTROL_TYPE_TXCANCEL,
  29. P54_CONTROL_TYPE_TXDONE,
  30. P54_CONTROL_TYPE_BURST,
  31. P54_CONTROL_TYPE_STAT_READBACK,
  32. P54_CONTROL_TYPE_BBP,
  33. P54_CONTROL_TYPE_EEPROM_READBACK,
  34. P54_CONTROL_TYPE_LED,
  35. P54_CONTROL_TYPE_GPIO,
  36. P54_CONTROL_TYPE_TIMER,
  37. P54_CONTROL_TYPE_MODULATION,
  38. P54_CONTROL_TYPE_SYNTH_CONFIG,
  39. P54_CONTROL_TYPE_DETECTOR_VALUE,
  40. P54_CONTROL_TYPE_XBOW_SYNTH_CFG,
  41. P54_CONTROL_TYPE_CCE_QUIET,
  42. P54_CONTROL_TYPE_PSM_STA_UNLOCK,
  43. P54_CONTROL_TYPE_PCS,
  44. P54_CONTROL_TYPE_BT_BALANCER = 28,
  45. P54_CONTROL_TYPE_GROUP_ADDRESS_TABLE = 30,
  46. P54_CONTROL_TYPE_ARPTABLE = 31,
  47. P54_CONTROL_TYPE_BT_OPTIONS = 35,
  48. };
  49. #define P54_HDR_FLAG_CONTROL BIT(15)
  50. #define P54_HDR_FLAG_CONTROL_OPSET (BIT(15) + BIT(0))
  51. #define P54_HDR_FLAG_DATA_ALIGN BIT(14)
  52. #define P54_HDR_FLAG_DATA_OUT_PROMISC BIT(0)
  53. #define P54_HDR_FLAG_DATA_OUT_TIMESTAMP BIT(1)
  54. #define P54_HDR_FLAG_DATA_OUT_SEQNR BIT(2)
  55. #define P54_HDR_FLAG_DATA_OUT_BIT3 BIT(3)
  56. #define P54_HDR_FLAG_DATA_OUT_BURST BIT(4)
  57. #define P54_HDR_FLAG_DATA_OUT_NOCANCEL BIT(5)
  58. #define P54_HDR_FLAG_DATA_OUT_CLEARTIM BIT(6)
  59. #define P54_HDR_FLAG_DATA_OUT_HITCHHIKE BIT(7)
  60. #define P54_HDR_FLAG_DATA_OUT_COMPRESS BIT(8)
  61. #define P54_HDR_FLAG_DATA_OUT_CONCAT BIT(9)
  62. #define P54_HDR_FLAG_DATA_OUT_PCS_ACCEPT BIT(10)
  63. #define P54_HDR_FLAG_DATA_OUT_WAITEOSP BIT(11)
  64. #define P54_HDR_FLAG_DATA_IN_FCS_GOOD BIT(0)
  65. #define P54_HDR_FLAG_DATA_IN_MATCH_MAC BIT(1)
  66. #define P54_HDR_FLAG_DATA_IN_MCBC BIT(2)
  67. #define P54_HDR_FLAG_DATA_IN_BEACON BIT(3)
  68. #define P54_HDR_FLAG_DATA_IN_MATCH_BSS BIT(4)
  69. #define P54_HDR_FLAG_DATA_IN_BCAST_BSS BIT(5)
  70. #define P54_HDR_FLAG_DATA_IN_DATA BIT(6)
  71. #define P54_HDR_FLAG_DATA_IN_TRUNCATED BIT(7)
  72. #define P54_HDR_FLAG_DATA_IN_BIT8 BIT(8)
  73. #define P54_HDR_FLAG_DATA_IN_TRANSPARENT BIT(9)
  74. struct p54_hdr {
  75. __le16 flags;
  76. __le16 len;
  77. __le32 req_id;
  78. __le16 type; /* enum p54_control_frame_types */
  79. u8 rts_tries;
  80. u8 tries;
  81. u8 data[0];
  82. } __packed;
  83. #define GET_REQ_ID(skb) \
  84. (((struct p54_hdr *) ((struct sk_buff *) skb)->data)->req_id) \
  85. #define FREE_AFTER_TX(skb) \
  86. ((((struct p54_hdr *) ((struct sk_buff *) skb)->data)-> \
  87. flags) == cpu_to_le16(P54_HDR_FLAG_CONTROL_OPSET))
  88. #define IS_DATA_FRAME(skb) \
  89. (!((((struct p54_hdr *) ((struct sk_buff *) skb)->data)-> \
  90. flags) & cpu_to_le16(P54_HDR_FLAG_CONTROL)))
  91. #define GET_HW_QUEUE(skb) \
  92. (((struct p54_tx_data *)((struct p54_hdr *) \
  93. skb->data)->data)->hw_queue)
  94. /*
  95. * shared interface ID definitions
  96. * The interface ID is a unique identification of a specific interface.
  97. * The following values are reserved: 0x0000, 0x0002, 0x0012, 0x0014, 0x0015
  98. */
  99. #define IF_ID_ISL36356A 0x0001 /* ISL36356A <-> Firmware */
  100. #define IF_ID_MVC 0x0003 /* MAC Virtual Coprocessor */
  101. #define IF_ID_DEBUG 0x0008 /* PolDebug Interface */
  102. #define IF_ID_PRODUCT 0x0009
  103. #define IF_ID_OEM 0x000a
  104. #define IF_ID_PCI3877 0x000b /* 3877 <-> Host PCI */
  105. #define IF_ID_ISL37704C 0x000c /* ISL37704C <-> Fw */
  106. #define IF_ID_ISL39000 0x000f /* ISL39000 <-> Fw */
  107. #define IF_ID_ISL39300A 0x0010 /* ISL39300A <-> Fw */
  108. #define IF_ID_ISL37700_UAP 0x0016 /* ISL37700 uAP Fw <-> Fw */
  109. #define IF_ID_ISL39000_UAP 0x0017 /* ISL39000 uAP Fw <-> Fw */
  110. #define IF_ID_LMAC 0x001a /* Interface exposed by LMAC */
  111. struct exp_if {
  112. __le16 role;
  113. __le16 if_id;
  114. __le16 variant;
  115. __le16 btm_compat;
  116. __le16 top_compat;
  117. } __packed;
  118. struct dep_if {
  119. __le16 role;
  120. __le16 if_id;
  121. __le16 variant;
  122. } __packed;
  123. /* driver <-> lmac definitions */
  124. struct p54_eeprom_lm86 {
  125. union {
  126. struct {
  127. __le16 offset;
  128. __le16 len;
  129. u8 data[0];
  130. } __packed v1;
  131. struct {
  132. __le32 offset;
  133. __le16 len;
  134. u8 magic2;
  135. u8 pad;
  136. u8 magic[4];
  137. u8 data[0];
  138. } __packed v2;
  139. } __packed;
  140. } __packed;
  141. enum p54_rx_decrypt_status {
  142. P54_DECRYPT_NONE = 0,
  143. P54_DECRYPT_OK,
  144. P54_DECRYPT_NOKEY,
  145. P54_DECRYPT_NOMICHAEL,
  146. P54_DECRYPT_NOCKIPMIC,
  147. P54_DECRYPT_FAIL_WEP,
  148. P54_DECRYPT_FAIL_TKIP,
  149. P54_DECRYPT_FAIL_MICHAEL,
  150. P54_DECRYPT_FAIL_CKIPKP,
  151. P54_DECRYPT_FAIL_CKIPMIC,
  152. P54_DECRYPT_FAIL_AESCCMP
  153. };
  154. struct p54_rx_data {
  155. __le16 flags;
  156. __le16 len;
  157. __le16 freq;
  158. u8 antenna;
  159. u8 rate;
  160. u8 rssi;
  161. u8 quality;
  162. u8 decrypt_status;
  163. u8 rssi_raw;
  164. __le32 tsf32;
  165. __le32 unalloc0;
  166. u8 align[0];
  167. } __packed;
  168. enum p54_trap_type {
  169. P54_TRAP_SCAN = 0,
  170. P54_TRAP_TIMER,
  171. P54_TRAP_BEACON_TX,
  172. P54_TRAP_FAA_RADIO_ON,
  173. P54_TRAP_FAA_RADIO_OFF,
  174. P54_TRAP_RADAR,
  175. P54_TRAP_NO_BEACON,
  176. P54_TRAP_TBTT,
  177. P54_TRAP_SCO_ENTER,
  178. P54_TRAP_SCO_EXIT
  179. };
  180. struct p54_trap {
  181. __le16 event;
  182. __le16 frequency;
  183. } __packed;
  184. enum p54_frame_sent_status {
  185. P54_TX_OK = 0,
  186. P54_TX_FAILED,
  187. P54_TX_PSM,
  188. P54_TX_PSM_CANCELLED = 4
  189. };
  190. struct p54_frame_sent {
  191. u8 status;
  192. u8 tries;
  193. u8 ack_rssi;
  194. u8 quality;
  195. __le16 seq;
  196. u8 antenna;
  197. u8 padding;
  198. } __packed;
  199. enum p54_tx_data_crypt {
  200. P54_CRYPTO_NONE = 0,
  201. P54_CRYPTO_WEP,
  202. P54_CRYPTO_TKIP,
  203. P54_CRYPTO_TKIPMICHAEL,
  204. P54_CRYPTO_CCX_WEPMIC,
  205. P54_CRYPTO_CCX_KPMIC,
  206. P54_CRYPTO_CCX_KP,
  207. P54_CRYPTO_AESCCMP
  208. };
  209. enum p54_tx_data_queue {
  210. P54_QUEUE_BEACON = 0,
  211. P54_QUEUE_FWSCAN = 1,
  212. P54_QUEUE_MGMT = 2,
  213. P54_QUEUE_CAB = 3,
  214. P54_QUEUE_DATA = 4,
  215. P54_QUEUE_AC_NUM = 4,
  216. P54_QUEUE_AC_VO = 4,
  217. P54_QUEUE_AC_VI = 5,
  218. P54_QUEUE_AC_BE = 6,
  219. P54_QUEUE_AC_BK = 7,
  220. /* keep last */
  221. P54_QUEUE_NUM = 8,
  222. };
  223. #define IS_QOS_QUEUE(n) (n >= P54_QUEUE_DATA)
  224. struct p54_tx_data {
  225. u8 rateset[8];
  226. u8 rts_rate_idx;
  227. u8 crypt_offset;
  228. u8 key_type;
  229. u8 key_len;
  230. u8 key[16];
  231. u8 hw_queue;
  232. u8 backlog;
  233. __le16 durations[4];
  234. u8 tx_antenna;
  235. union {
  236. struct {
  237. u8 cts_rate;
  238. __le16 output_power;
  239. } __packed longbow;
  240. struct {
  241. u8 output_power;
  242. u8 cts_rate;
  243. u8 unalloc;
  244. } __packed normal;
  245. } __packed;
  246. u8 unalloc2[2];
  247. u8 align[0];
  248. } __packed;
  249. /* unit is ms */
  250. #define P54_TX_FRAME_LIFETIME 2000
  251. #define P54_TX_TIMEOUT 4000
  252. #define P54_STATISTICS_UPDATE 5000
  253. #define P54_FILTER_TYPE_NONE 0
  254. #define P54_FILTER_TYPE_STATION BIT(0)
  255. #define P54_FILTER_TYPE_IBSS BIT(1)
  256. #define P54_FILTER_TYPE_AP BIT(2)
  257. #define P54_FILTER_TYPE_TRANSPARENT BIT(3)
  258. #define P54_FILTER_TYPE_PROMISCUOUS BIT(4)
  259. #define P54_FILTER_TYPE_HIBERNATE BIT(5)
  260. #define P54_FILTER_TYPE_NOACK BIT(6)
  261. #define P54_FILTER_TYPE_RX_DISABLED BIT(7)
  262. struct p54_setup_mac {
  263. __le16 mac_mode;
  264. u8 mac_addr[ETH_ALEN];
  265. u8 bssid[ETH_ALEN];
  266. u8 rx_antenna;
  267. u8 rx_align;
  268. union {
  269. struct {
  270. __le32 basic_rate_mask;
  271. u8 rts_rates[8];
  272. __le32 rx_addr;
  273. __le16 max_rx;
  274. __le16 rxhw;
  275. __le16 wakeup_timer;
  276. __le16 unalloc0;
  277. } __packed v1;
  278. struct {
  279. __le32 rx_addr;
  280. __le16 max_rx;
  281. __le16 rxhw;
  282. __le16 timer;
  283. __le16 truncate;
  284. __le32 basic_rate_mask;
  285. u8 sbss_offset;
  286. u8 mcast_window;
  287. u8 rx_rssi_threshold;
  288. u8 rx_ed_threshold;
  289. __le32 ref_clock;
  290. __le16 lpf_bandwidth;
  291. __le16 osc_start_delay;
  292. } __packed v2;
  293. } __packed;
  294. } __packed;
  295. #define P54_SETUP_V1_LEN 40
  296. #define P54_SETUP_V2_LEN (sizeof(struct p54_setup_mac))
  297. #define P54_SCAN_EXIT BIT(0)
  298. #define P54_SCAN_TRAP BIT(1)
  299. #define P54_SCAN_ACTIVE BIT(2)
  300. #define P54_SCAN_FILTER BIT(3)
  301. struct p54_scan_head {
  302. __le16 mode;
  303. __le16 dwell;
  304. u8 scan_params[20];
  305. __le16 freq;
  306. } __packed;
  307. struct p54_pa_curve_data_sample {
  308. u8 rf_power;
  309. u8 pa_detector;
  310. u8 data_barker;
  311. u8 data_bpsk;
  312. u8 data_qpsk;
  313. u8 data_16qam;
  314. u8 data_64qam;
  315. u8 padding;
  316. } __packed;
  317. struct p54_scan_body {
  318. u8 pa_points_per_curve;
  319. u8 val_barker;
  320. u8 val_bpsk;
  321. u8 val_qpsk;
  322. u8 val_16qam;
  323. u8 val_64qam;
  324. struct p54_pa_curve_data_sample curve_data[8];
  325. u8 dup_bpsk;
  326. u8 dup_qpsk;
  327. u8 dup_16qam;
  328. u8 dup_64qam;
  329. } __packed;
  330. /*
  331. * Warning: Longbow's structures are bogus.
  332. */
  333. struct p54_channel_output_limit_longbow {
  334. __le16 rf_power_points[12];
  335. } __packed;
  336. struct p54_pa_curve_data_sample_longbow {
  337. __le16 rf_power;
  338. __le16 pa_detector;
  339. struct {
  340. __le16 data[4];
  341. } points[3] __packed;
  342. } __packed;
  343. struct p54_scan_body_longbow {
  344. struct p54_channel_output_limit_longbow power_limits;
  345. struct p54_pa_curve_data_sample_longbow curve_data[8];
  346. __le16 unkn[6]; /* maybe more power_limits or rate_mask */
  347. } __packed;
  348. union p54_scan_body_union {
  349. struct p54_scan_body normal;
  350. struct p54_scan_body_longbow longbow;
  351. } __packed;
  352. struct p54_scan_tail_rate {
  353. __le32 basic_rate_mask;
  354. u8 rts_rates[8];
  355. } __packed;
  356. struct p54_led {
  357. __le16 flags;
  358. __le16 mask[2];
  359. __le16 delay[2];
  360. } __packed;
  361. struct p54_edcf {
  362. u8 flags;
  363. u8 slottime;
  364. u8 sifs;
  365. u8 eofpad;
  366. struct p54_edcf_queue_param queue[8];
  367. u8 mapping[4];
  368. __le16 frameburst;
  369. __le16 round_trip_delay;
  370. } __packed;
  371. struct p54_statistics {
  372. __le32 rx_success;
  373. __le32 rx_bad_fcs;
  374. __le32 rx_abort;
  375. __le32 rx_abort_phy;
  376. __le32 rts_success;
  377. __le32 rts_fail;
  378. __le32 tsf32;
  379. __le32 airtime;
  380. __le32 noise;
  381. __le32 sample_noise[8];
  382. __le32 sample_cca;
  383. __le32 sample_tx;
  384. } __packed;
  385. struct p54_xbow_synth {
  386. __le16 magic1;
  387. __le16 magic2;
  388. __le16 freq;
  389. u32 padding[5];
  390. } __packed;
  391. struct p54_timer {
  392. __le32 interval;
  393. } __packed;
  394. struct p54_keycache {
  395. u8 entry;
  396. u8 key_id;
  397. u8 mac[ETH_ALEN];
  398. u8 padding[2];
  399. u8 key_type;
  400. u8 key_len;
  401. u8 key[24];
  402. } __packed;
  403. struct p54_burst {
  404. u8 flags;
  405. u8 queue;
  406. u8 backlog;
  407. u8 pad;
  408. __le16 durations[32];
  409. } __packed;
  410. struct p54_psm_interval {
  411. __le16 interval;
  412. __le16 periods;
  413. } __packed;
  414. #define P54_PSM_CAM 0
  415. #define P54_PSM BIT(0)
  416. #define P54_PSM_DTIM BIT(1)
  417. #define P54_PSM_MCBC BIT(2)
  418. #define P54_PSM_CHECKSUM BIT(3)
  419. #define P54_PSM_SKIP_MORE_DATA BIT(4)
  420. #define P54_PSM_BEACON_TIMEOUT BIT(5)
  421. #define P54_PSM_HFOSLEEP BIT(6)
  422. #define P54_PSM_AUTOSWITCH_SLEEP BIT(7)
  423. #define P54_PSM_LPIT BIT(8)
  424. #define P54_PSM_BF_UCAST_SKIP BIT(9)
  425. #define P54_PSM_BF_MCAST_SKIP BIT(10)
  426. struct p54_psm {
  427. __le16 mode;
  428. __le16 aid;
  429. struct p54_psm_interval intervals[4];
  430. u8 beacon_rssi_skip_max;
  431. u8 rssi_delta_threshold;
  432. u8 nr;
  433. u8 exclude[1];
  434. } __packed;
  435. #define MC_FILTER_ADDRESS_NUM 4
  436. struct p54_group_address_table {
  437. __le16 filter_enable;
  438. __le16 num_address;
  439. u8 mac_list[MC_FILTER_ADDRESS_NUM][ETH_ALEN];
  440. } __packed;
  441. struct p54_txcancel {
  442. __le32 req_id;
  443. } __packed;
  444. struct p54_sta_unlock {
  445. u8 addr[ETH_ALEN];
  446. u16 padding;
  447. } __packed;
  448. #define P54_TIM_CLEAR BIT(15)
  449. struct p54_tim {
  450. u8 count;
  451. u8 padding[3];
  452. __le16 entry[8];
  453. } __packed;
  454. struct p54_cce_quiet {
  455. __le32 period;
  456. } __packed;
  457. struct p54_bt_balancer {
  458. __le16 prio_thresh;
  459. __le16 acl_thresh;
  460. } __packed;
  461. struct p54_arp_table {
  462. __le16 filter_enable;
  463. u8 ipv4_addr[4];
  464. } __packed;
  465. /* LED control */
  466. int p54_set_leds(struct p54_common *priv);
  467. int p54_init_leds(struct p54_common *priv);
  468. void p54_unregister_leds(struct p54_common *priv);
  469. /* xmit functions */
  470. void p54_tx_80211(struct ieee80211_hw *dev,
  471. struct ieee80211_tx_control *control,
  472. struct sk_buff *skb);
  473. int p54_tx_cancel(struct p54_common *priv, __le32 req_id);
  474. void p54_tx(struct p54_common *priv, struct sk_buff *skb);
  475. /* synth/phy configuration */
  476. int p54_init_xbow_synth(struct p54_common *priv);
  477. int p54_scan(struct p54_common *priv, u16 mode, u16 dwell);
  478. /* MAC */
  479. int p54_sta_unlock(struct p54_common *priv, u8 *addr);
  480. int p54_update_beacon_tim(struct p54_common *priv, u16 aid, bool set);
  481. int p54_setup_mac(struct p54_common *priv);
  482. int p54_set_ps(struct p54_common *priv);
  483. int p54_fetch_statistics(struct p54_common *priv);
  484. int p54_set_groupfilter(struct p54_common *priv);
  485. /* e/v DCF setup */
  486. int p54_set_edcf(struct p54_common *priv);
  487. /* cryptographic engine */
  488. int p54_upload_key(struct p54_common *priv, u8 algo, int slot,
  489. u8 idx, u8 len, u8 *addr, u8* key);
  490. /* eeprom */
  491. int p54_download_eeprom(struct p54_common *priv, void *buf,
  492. u16 offset, u16 len);
  493. struct p54_rssi_db_entry *p54_rssi_find(struct p54_common *p, const u16 freq);
  494. /* utility */
  495. u8 *p54_find_ie(struct sk_buff *skb, u8 ie);
  496. #endif /* LMAC_H */