htc_hst.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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_ep_callbacks {
  69. void *priv;
  70. void (*tx) (void *, struct sk_buff *, enum htc_endpoint_id, bool txok);
  71. void (*rx) (void *, struct sk_buff *, enum htc_endpoint_id);
  72. };
  73. struct htc_endpoint {
  74. u16 service_id;
  75. struct htc_ep_callbacks ep_callbacks;
  76. u32 max_txqdepth;
  77. int max_msglen;
  78. u8 ul_pipeid;
  79. u8 dl_pipeid;
  80. };
  81. #define HTC_MAX_CONTROL_MESSAGE_LENGTH 255
  82. #define HTC_CONTROL_BUFFER_SIZE \
  83. (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr))
  84. #define HTC_OP_START_WAIT BIT(0)
  85. #define HTC_OP_CONFIG_PIPE_CREDITS BIT(1)
  86. struct htc_target {
  87. void *hif_dev;
  88. struct ath9k_htc_priv *drv_priv;
  89. struct device *dev;
  90. struct ath9k_htc_hif *hif;
  91. struct htc_endpoint endpoint[ENDPOINT_MAX];
  92. struct completion target_wait;
  93. struct completion cmd_wait;
  94. struct list_head list;
  95. enum htc_endpoint_id conn_rsp_epid;
  96. u16 credits;
  97. u16 credit_size;
  98. u8 htc_flags;
  99. atomic_t tgt_ready;
  100. };
  101. enum htc_msg_id {
  102. HTC_MSG_READY_ID = 1,
  103. HTC_MSG_CONNECT_SERVICE_ID,
  104. HTC_MSG_CONNECT_SERVICE_RESPONSE_ID,
  105. HTC_MSG_SETUP_COMPLETE_ID,
  106. HTC_MSG_CONFIG_PIPE_ID,
  107. HTC_MSG_CONFIG_PIPE_RESPONSE_ID,
  108. };
  109. struct htc_service_connreq {
  110. u16 service_id;
  111. u16 con_flags;
  112. u32 max_send_qdepth;
  113. struct htc_ep_callbacks ep_callbacks;
  114. };
  115. /* Current service IDs */
  116. enum htc_service_group_ids{
  117. RSVD_SERVICE_GROUP = 0,
  118. WMI_SERVICE_GROUP = 1,
  119. HTC_SERVICE_GROUP_LAST = 255
  120. };
  121. #define MAKE_SERVICE_ID(group, index) \
  122. (int)(((int)group << 8) | (int)(index))
  123. /* NOTE: service ID of 0x0000 is reserved and should never be used */
  124. #define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 1)
  125. #define HTC_LOOPBACK_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 2)
  126. #define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 0)
  127. #define WMI_BEACON_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 1)
  128. #define WMI_CAB_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 2)
  129. #define WMI_UAPSD_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 3)
  130. #define WMI_MGMT_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4)
  131. #define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 5)
  132. #define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 6)
  133. #define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 7)
  134. #define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 8)
  135. struct htc_conn_svc_msg {
  136. __be16 msg_id;
  137. __be16 service_id;
  138. __be16 con_flags;
  139. u8 dl_pipeid;
  140. u8 ul_pipeid;
  141. u8 svc_meta_len;
  142. u8 pad;
  143. } __packed;
  144. /* connect response status codes */
  145. #define HTC_SERVICE_SUCCESS 0
  146. #define HTC_SERVICE_NOT_FOUND 1
  147. #define HTC_SERVICE_FAILED 2
  148. #define HTC_SERVICE_NO_RESOURCES 3
  149. #define HTC_SERVICE_NO_MORE_EP 4
  150. struct htc_conn_svc_rspmsg {
  151. __be16 msg_id;
  152. __be16 service_id;
  153. u8 status;
  154. u8 endpoint_id;
  155. __be16 max_msg_len;
  156. u8 svc_meta_len;
  157. u8 pad;
  158. } __packed;
  159. struct htc_comp_msg {
  160. __be16 msg_id;
  161. } __packed;
  162. int htc_init(struct htc_target *target);
  163. int htc_connect_service(struct htc_target *target,
  164. struct htc_service_connreq *service_connreq,
  165. enum htc_endpoint_id *conn_rsp_eid);
  166. int htc_send(struct htc_target *target, struct sk_buff *skb);
  167. int htc_send_epid(struct htc_target *target, struct sk_buff *skb,
  168. enum htc_endpoint_id epid);
  169. void htc_stop(struct htc_target *target);
  170. void htc_start(struct htc_target *target);
  171. void htc_sta_drain(struct htc_target *target, u8 idx);
  172. void ath9k_htc_rx_msg(struct htc_target *htc_handle,
  173. struct sk_buff *skb, u32 len, u8 pipe_id);
  174. void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
  175. struct sk_buff *skb, bool txok);
  176. struct htc_target *ath9k_htc_hw_alloc(void *hif_handle,
  177. struct ath9k_htc_hif *hif,
  178. struct device *dev);
  179. void ath9k_htc_hw_free(struct htc_target *htc);
  180. int ath9k_htc_hw_init(struct htc_target *target,
  181. struct device *dev, u16 devid, char *product,
  182. u32 drv_info);
  183. void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug);
  184. #endif /* HTC_HST_H */