htc_hst.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 HTC_HST_H
  17. #define HTC_HST_H
  18. struct ath9k_htc_priv;
  19. struct htc_target;
  20. struct ath9k_htc_tx_ctl;
  21. enum ath9k_hif_transports {
  22. ATH9K_HIF_USB,
  23. };
  24. struct ath9k_htc_hif {
  25. struct list_head list;
  26. const enum ath9k_hif_transports transport;
  27. const char *name;
  28. u8 control_dl_pipe;
  29. u8 control_ul_pipe;
  30. void (*start) (void *hif_handle);
  31. void (*stop) (void *hif_handle);
  32. void (*sta_drain) (void *hif_handle, u8 idx);
  33. int (*send) (void *hif_handle, u8 pipe, struct sk_buff *buf);
  34. };
  35. enum htc_endpoint_id {
  36. ENDPOINT_UNUSED = -1,
  37. ENDPOINT0 = 0,
  38. ENDPOINT1 = 1,
  39. ENDPOINT2 = 2,
  40. ENDPOINT3 = 3,
  41. ENDPOINT4 = 4,
  42. ENDPOINT5 = 5,
  43. ENDPOINT6 = 6,
  44. ENDPOINT7 = 7,
  45. ENDPOINT8 = 8,
  46. ENDPOINT_MAX = 22
  47. };
  48. /* Htc frame hdr flags */
  49. #define HTC_FLAGS_RECV_TRAILER (1 << 1)
  50. struct htc_frame_hdr {
  51. u8 endpoint_id;
  52. u8 flags;
  53. __be16 payload_len;
  54. u8 control[4];
  55. } __packed;
  56. struct htc_ready_msg {
  57. __be16 message_id;
  58. __be16 credits;
  59. __be16 credit_size;
  60. u8 max_endpoints;
  61. u8 pad;
  62. } __packed;
  63. struct htc_config_pipe_msg {
  64. __be16 message_id;
  65. u8 pipe_id;
  66. u8 credits;
  67. } __packed;
  68. struct htc_panic_bad_vaddr {
  69. __be32 pattern;
  70. __be32 exccause;
  71. __be32 pc;
  72. __be32 badvaddr;
  73. } __packed;
  74. struct htc_panic_bad_epid {
  75. __be32 pattern;
  76. __be32 epid;
  77. } __packed;
  78. struct htc_ep_callbacks {
  79. void *priv;
  80. void (*tx) (void *, struct sk_buff *, enum htc_endpoint_id, bool txok);
  81. void (*rx) (void *, struct sk_buff *, enum htc_endpoint_id);
  82. };
  83. struct htc_endpoint {
  84. u16 service_id;
  85. struct htc_ep_callbacks ep_callbacks;
  86. u32 max_txqdepth;
  87. int max_msglen;
  88. u8 ul_pipeid;
  89. u8 dl_pipeid;
  90. };
  91. #define HTC_MAX_CONTROL_MESSAGE_LENGTH 255
  92. #define HTC_CONTROL_BUFFER_SIZE \
  93. (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr))
  94. #define HTC_OP_START_WAIT BIT(0)
  95. #define HTC_OP_CONFIG_PIPE_CREDITS BIT(1)
  96. struct htc_target {
  97. void *hif_dev;
  98. struct ath9k_htc_priv *drv_priv;
  99. struct device *dev;
  100. struct ath9k_htc_hif *hif;
  101. struct htc_endpoint endpoint[ENDPOINT_MAX];
  102. struct completion target_wait;
  103. struct completion cmd_wait;
  104. struct list_head list;
  105. enum htc_endpoint_id conn_rsp_epid;
  106. u16 credits;
  107. u16 credit_size;
  108. u8 htc_flags;
  109. atomic_t tgt_ready;
  110. };
  111. enum htc_msg_id {
  112. HTC_MSG_READY_ID = 1,
  113. HTC_MSG_CONNECT_SERVICE_ID,
  114. HTC_MSG_CONNECT_SERVICE_RESPONSE_ID,
  115. HTC_MSG_SETUP_COMPLETE_ID,
  116. HTC_MSG_CONFIG_PIPE_ID,
  117. HTC_MSG_CONFIG_PIPE_RESPONSE_ID,
  118. };
  119. struct htc_service_connreq {
  120. u16 service_id;
  121. u16 con_flags;
  122. u32 max_send_qdepth;
  123. struct htc_ep_callbacks ep_callbacks;
  124. };
  125. /* Current service IDs */
  126. enum htc_service_group_ids{
  127. RSVD_SERVICE_GROUP = 0,
  128. WMI_SERVICE_GROUP = 1,
  129. HTC_SERVICE_GROUP_LAST = 255
  130. };
  131. #define MAKE_SERVICE_ID(group, index) \
  132. (int)(((int)group << 8) | (int)(index))
  133. /* NOTE: service ID of 0x0000 is reserved and should never be used */
  134. #define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 1)
  135. #define HTC_LOOPBACK_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 2)
  136. #define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 0)
  137. #define WMI_BEACON_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 1)
  138. #define WMI_CAB_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 2)
  139. #define WMI_UAPSD_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 3)
  140. #define WMI_MGMT_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4)
  141. #define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 5)
  142. #define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 6)
  143. #define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 7)
  144. #define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 8)
  145. struct htc_conn_svc_msg {
  146. __be16 msg_id;
  147. __be16 service_id;
  148. __be16 con_flags;
  149. u8 dl_pipeid;
  150. u8 ul_pipeid;
  151. u8 svc_meta_len;
  152. u8 pad;
  153. } __packed;
  154. /* connect response status codes */
  155. #define HTC_SERVICE_SUCCESS 0
  156. #define HTC_SERVICE_NOT_FOUND 1
  157. #define HTC_SERVICE_FAILED 2
  158. #define HTC_SERVICE_NO_RESOURCES 3
  159. #define HTC_SERVICE_NO_MORE_EP 4
  160. struct htc_conn_svc_rspmsg {
  161. __be16 msg_id;
  162. __be16 service_id;
  163. u8 status;
  164. u8 endpoint_id;
  165. __be16 max_msg_len;
  166. u8 svc_meta_len;
  167. u8 pad;
  168. } __packed;
  169. struct htc_comp_msg {
  170. __be16 msg_id;
  171. } __packed;
  172. int htc_init(struct htc_target *target);
  173. int htc_connect_service(struct htc_target *target,
  174. struct htc_service_connreq *service_connreq,
  175. enum htc_endpoint_id *conn_rsp_eid);
  176. int htc_send(struct htc_target *target, struct sk_buff *skb);
  177. int htc_send_epid(struct htc_target *target, struct sk_buff *skb,
  178. enum htc_endpoint_id epid);
  179. void htc_stop(struct htc_target *target);
  180. void htc_start(struct htc_target *target);
  181. void htc_sta_drain(struct htc_target *target, u8 idx);
  182. void ath9k_htc_rx_msg(struct htc_target *htc_handle,
  183. struct sk_buff *skb, u32 len, u8 pipe_id);
  184. void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
  185. struct sk_buff *skb, bool txok);
  186. struct htc_target *ath9k_htc_hw_alloc(void *hif_handle,
  187. struct ath9k_htc_hif *hif,
  188. struct device *dev);
  189. void ath9k_htc_hw_free(struct htc_target *htc);
  190. int ath9k_htc_hw_init(struct htc_target *target,
  191. struct device *dev, u16 devid, char *product,
  192. u32 drv_info);
  193. void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug);
  194. #endif /* HTC_HST_H */