common.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (c) 2010-2011 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef COMMON_H
  17. #define COMMON_H
  18. #include <linux/netdevice.h>
  19. #define ATH6KL_MAX_IE 256
  20. extern int ath6kl_printk(const char *level, const char *fmt, ...);
  21. #define A_CACHE_LINE_PAD 128
  22. /*
  23. * Reflects the version of binary interface exposed by ATH6KL target
  24. * firmware. Needs to be incremented by 1 for any change in the firmware
  25. * that requires upgrade of the driver on the host side for the change to
  26. * work correctly
  27. */
  28. #define ATH6KL_ABI_VERSION 1
  29. #define SIGNAL_QUALITY_METRICS_NUM_MAX 2
  30. enum {
  31. SIGNAL_QUALITY_METRICS_SNR = 0,
  32. SIGNAL_QUALITY_METRICS_RSSI,
  33. SIGNAL_QUALITY_METRICS_ALL,
  34. };
  35. /*
  36. * Data Path
  37. */
  38. #define WMI_MAX_TX_DATA_FRAME_LENGTH \
  39. (1500 + sizeof(struct wmi_data_hdr) + \
  40. sizeof(struct ethhdr) + \
  41. sizeof(struct ath6kl_llc_snap_hdr))
  42. /* An AMSDU frame */ /* The MAX AMSDU length of AR6003 is 3839 */
  43. #define WMI_MAX_AMSDU_RX_DATA_FRAME_LENGTH \
  44. (3840 + sizeof(struct wmi_data_hdr) + \
  45. sizeof(struct ethhdr) + \
  46. sizeof(struct ath6kl_llc_snap_hdr))
  47. #define EPPING_ALIGNMENT_PAD \
  48. (((sizeof(struct htc_frame_hdr) + 3) & (~0x3)) \
  49. - sizeof(struct htc_frame_hdr))
  50. struct ath6kl_llc_snap_hdr {
  51. u8 dsap;
  52. u8 ssap;
  53. u8 cntl;
  54. u8 org_code[3];
  55. __be16 eth_type;
  56. } __packed;
  57. enum crypto_type {
  58. NONE_CRYPT = 0x01,
  59. WEP_CRYPT = 0x02,
  60. TKIP_CRYPT = 0x04,
  61. AES_CRYPT = 0x08,
  62. };
  63. #define ATH6KL_NODE_HASHSIZE 32
  64. /* simple hash is enough for variation of macaddr */
  65. #define ATH6KL_NODE_HASH(addr) \
  66. (((const u8 *)(addr))[ETH_ALEN - 1] % \
  67. ATH6KL_NODE_HASHSIZE)
  68. /*
  69. * Table of ath6kl_node instances. Each ieee80211com
  70. * has at least one for holding the scan candidates.
  71. * When operating as an access point or in ibss mode there
  72. * is a second table for associated stations or neighbors.
  73. */
  74. struct ath6kl_node_table {
  75. spinlock_t nt_nodelock; /* on node table */
  76. struct bss *nt_node_first; /* information of all nodes */
  77. struct bss *nt_node_last; /* information of all nodes */
  78. struct bss *nt_hash[ATH6KL_NODE_HASHSIZE];
  79. const char *nt_name; /* for debugging */
  80. u32 nt_node_age; /* node aging time */
  81. };
  82. #define WLAN_NODE_INACT_TIMEOUT_MSEC 120000
  83. #define WLAN_NODE_INACT_CNT 4
  84. struct ath6kl_common_ie {
  85. u16 ie_chan;
  86. u8 *ie_tstamp;
  87. u8 *ie_ssid;
  88. u8 *ie_rates;
  89. u8 *ie_xrates;
  90. u8 *ie_country;
  91. u8 *ie_wpa;
  92. u8 *ie_rsn;
  93. u8 *ie_wmm;
  94. u8 *ie_ath;
  95. u16 ie_capInfo;
  96. u16 ie_beaconInt;
  97. u8 *ie_tim;
  98. u8 *ie_chswitch;
  99. u8 ie_erp;
  100. u8 *ie_wsc;
  101. u8 *ie_htcap;
  102. u8 *ie_htop;
  103. };
  104. struct bss {
  105. u8 ni_macaddr[ETH_ALEN];
  106. u8 ni_snr;
  107. s16 ni_rssi;
  108. struct bss *ni_list_next;
  109. struct bss *ni_list_prev;
  110. struct bss *ni_hash_next;
  111. struct bss *ni_hash_prev;
  112. struct ath6kl_common_ie ni_cie;
  113. u8 *ni_buf;
  114. u16 ni_framelen;
  115. struct ath6kl_node_table *ni_table;
  116. u32 ni_refcnt;
  117. u32 ni_tstamp;
  118. u32 ni_actcnt;
  119. };
  120. struct htc_endpoint_credit_dist;
  121. struct ath6kl;
  122. enum htc_credit_dist_reason;
  123. struct htc_credit_state_info;
  124. struct bss *wlan_node_alloc(int wh_size);
  125. void wlan_node_free(struct bss *ni);
  126. void wlan_setup_node(struct ath6kl_node_table *nt, struct bss *ni,
  127. const u8 *mac_addr);
  128. struct bss *wlan_find_node(struct ath6kl_node_table *nt,
  129. const u8 *mac_addr);
  130. void wlan_node_reclaim(struct ath6kl_node_table *nt, struct bss *ni);
  131. void wlan_free_allnodes(struct ath6kl_node_table *nt);
  132. void wlan_iterate_nodes(struct ath6kl_node_table *nt, void *arg);
  133. void wlan_node_table_init(struct ath6kl_node_table *nt);
  134. void wlan_node_table_cleanup(struct ath6kl_node_table *nt);
  135. void wlan_refresh_inactive_nodes(struct ath6kl *ar);
  136. struct bss *wlan_find_ssid_node(struct ath6kl_node_table *nt, u8 *ssid,
  137. u32 ssid_len, bool is_wpa2, bool match_ssid);
  138. void wlan_node_return(struct ath6kl_node_table *nt, struct bss *ni);
  139. int ath6k_setup_credit_dist(void *htc_handle,
  140. struct htc_credit_state_info *cred_info);
  141. void ath6k_credit_distribute(struct htc_credit_state_info *cred_inf,
  142. struct list_head *epdist_list,
  143. enum htc_credit_dist_reason reason);
  144. void ath6k_credit_init(struct htc_credit_state_info *cred_inf,
  145. struct list_head *ep_list,
  146. int tot_credits);
  147. void ath6k_seek_credits(struct htc_credit_state_info *cred_inf,
  148. struct htc_endpoint_credit_dist *ep_dist);
  149. struct ath6kl *ath6kl_core_alloc(struct device *sdev);
  150. int ath6kl_core_init(struct ath6kl *ar);
  151. int ath6kl_unavail_ev(struct ath6kl *ar);
  152. struct sk_buff *ath6kl_buf_alloc(int size);
  153. #endif /* COMMON_H */