htc_hst.h 5.7 KB

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