htc.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. /*
  2. * Copyright (c) 2004-2011 Atheros Communications Inc.
  3. * Copyright (c) 2011 Qualcomm Atheros, Inc.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef HTC_H
  18. #define HTC_H
  19. #include "common.h"
  20. /* frame header flags */
  21. /* send direction */
  22. #define HTC_FLAGS_NEED_CREDIT_UPDATE (1 << 0)
  23. #define HTC_FLAGS_SEND_BUNDLE (1 << 1)
  24. #define HTC_FLAGS_TX_FIXUP_NETBUF (1 << 2)
  25. /* receive direction */
  26. #define HTC_FLG_RX_UNUSED (1 << 0)
  27. #define HTC_FLG_RX_TRAILER (1 << 1)
  28. /* Bundle count maske and shift */
  29. #define HTC_FLG_RX_BNDL_CNT (0xF0)
  30. #define HTC_FLG_RX_BNDL_CNT_S 4
  31. #define HTC_HDR_LENGTH (sizeof(struct htc_frame_hdr))
  32. #define HTC_MAX_PAYLOAD_LENGTH (4096 - sizeof(struct htc_frame_hdr))
  33. /* HTC control message IDs */
  34. #define HTC_MSG_READY_ID 1
  35. #define HTC_MSG_CONN_SVC_ID 2
  36. #define HTC_MSG_CONN_SVC_RESP_ID 3
  37. #define HTC_MSG_SETUP_COMPLETE_ID 4
  38. #define HTC_MSG_SETUP_COMPLETE_EX_ID 5
  39. #define HTC_MAX_CTRL_MSG_LEN 256
  40. #define HTC_VERSION_2P0 0x00
  41. #define HTC_VERSION_2P1 0x01
  42. #define HTC_SERVICE_META_DATA_MAX_LENGTH 128
  43. #define HTC_CONN_FLGS_THRESH_LVL_QUAT 0x0
  44. #define HTC_CONN_FLGS_THRESH_LVL_HALF 0x1
  45. #define HTC_CONN_FLGS_THRESH_LVL_THREE_QUAT 0x2
  46. #define HTC_CONN_FLGS_REDUCE_CRED_DRIB 0x4
  47. #define HTC_CONN_FLGS_THRESH_MASK 0x3
  48. /* disable credit flow control on a specific service */
  49. #define HTC_CONN_FLGS_DISABLE_CRED_FLOW_CTRL (1 << 3)
  50. #define HTC_CONN_FLGS_SET_RECV_ALLOC_SHIFT 8
  51. #define HTC_CONN_FLGS_SET_RECV_ALLOC_MASK 0xFF00U
  52. /* connect response status codes */
  53. #define HTC_SERVICE_SUCCESS 0
  54. #define HTC_SERVICE_NOT_FOUND 1
  55. #define HTC_SERVICE_FAILED 2
  56. /* no resources (i.e. no more endpoints) */
  57. #define HTC_SERVICE_NO_RESOURCES 3
  58. /* specific service is not allowing any more endpoints */
  59. #define HTC_SERVICE_NO_MORE_EP 4
  60. /* report record IDs */
  61. #define HTC_RECORD_NULL 0
  62. #define HTC_RECORD_CREDITS 1
  63. #define HTC_RECORD_LOOKAHEAD 2
  64. #define HTC_RECORD_LOOKAHEAD_BUNDLE 3
  65. #define HTC_SETUP_COMP_FLG_RX_BNDL_EN (1 << 0)
  66. #define HTC_SETUP_COMP_FLG_DISABLE_TX_CREDIT_FLOW (1 << 1)
  67. #define MAKE_SERVICE_ID(group, index) \
  68. (int)(((int)group << 8) | (int)(index))
  69. /* NOTE: service ID of 0x0000 is reserved and should never be used */
  70. #define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 1)
  71. #define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 0)
  72. #define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 1)
  73. #define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 2)
  74. #define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 3)
  75. #define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4)
  76. #define WMI_MAX_SERVICES 5
  77. #define WMM_NUM_AC 4
  78. /* reserved and used to flush ALL packets */
  79. #define HTC_TX_PACKET_TAG_ALL 0
  80. #define HTC_SERVICE_TX_PACKET_TAG 1
  81. #define HTC_TX_PACKET_TAG_USER_DEFINED (HTC_SERVICE_TX_PACKET_TAG + 9)
  82. /* more packets on this endpoint are being fetched */
  83. #define HTC_RX_FLAGS_INDICATE_MORE_PKTS (1 << 0)
  84. /* TODO.. for BMI */
  85. #define ENDPOINT1 0
  86. /* TODO -remove me, but we have to fix BMI first */
  87. #define HTC_MAILBOX_NUM_MAX 4
  88. /* enable send bundle padding for this endpoint */
  89. #define HTC_FLGS_TX_BNDL_PAD_EN (1 << 0)
  90. #define HTC_EP_ACTIVE ((u32) (1u << 31))
  91. /* HTC operational parameters */
  92. #define HTC_TARGET_RESPONSE_TIMEOUT 2000 /* in ms */
  93. #define HTC_TARGET_RESPONSE_POLL_WAIT 10
  94. #define HTC_TARGET_RESPONSE_POLL_COUNT 200
  95. #define HTC_TARGET_DEBUG_INTR_MASK 0x01
  96. #define HTC_TARGET_CREDIT_INTR_MASK 0xF0
  97. #define HTC_HOST_MAX_MSG_PER_BUNDLE 8
  98. #define HTC_MIN_HTC_MSGS_TO_BUNDLE 2
  99. /* packet flags */
  100. #define HTC_RX_PKT_IGNORE_LOOKAHEAD (1 << 0)
  101. #define HTC_RX_PKT_REFRESH_HDR (1 << 1)
  102. #define HTC_RX_PKT_PART_OF_BUNDLE (1 << 2)
  103. #define HTC_RX_PKT_NO_RECYCLE (1 << 3)
  104. #define NUM_CONTROL_BUFFERS 8
  105. #define NUM_CONTROL_TX_BUFFERS 2
  106. #define NUM_CONTROL_RX_BUFFERS (NUM_CONTROL_BUFFERS - NUM_CONTROL_TX_BUFFERS)
  107. #define HTC_RECV_WAIT_BUFFERS (1 << 0)
  108. #define HTC_OP_STATE_STOPPING (1 << 0)
  109. #define HTC_OP_STATE_SETUP_COMPLETE (1 << 1)
  110. /*
  111. * The frame header length and message formats defined herein were selected
  112. * to accommodate optimal alignment for target processing. This reduces
  113. * code size and improves performance. Any changes to the header length may
  114. * alter the alignment and cause exceptions on the target. When adding to
  115. * the messagestructures insure that fields are properly aligned.
  116. */
  117. /* HTC frame header
  118. *
  119. * NOTE: do not remove or re-arrange the fields, these are minimally
  120. * required to take advantage of 4-byte lookaheads in some hardware
  121. * implementations.
  122. */
  123. struct htc_frame_hdr {
  124. u8 eid;
  125. u8 flags;
  126. /* length of data (including trailer) that follows the header */
  127. __le16 payld_len;
  128. /* end of 4-byte lookahead */
  129. u8 ctrl[2];
  130. } __packed;
  131. /* HTC ready message */
  132. struct htc_ready_msg {
  133. __le16 msg_id;
  134. __le16 cred_cnt;
  135. __le16 cred_sz;
  136. u8 max_ep;
  137. u8 pad;
  138. } __packed;
  139. /* extended HTC ready message */
  140. struct htc_ready_ext_msg {
  141. struct htc_ready_msg ver2_0_info;
  142. u8 htc_ver;
  143. u8 msg_per_htc_bndl;
  144. } __packed;
  145. /* connect service */
  146. struct htc_conn_service_msg {
  147. __le16 msg_id;
  148. __le16 svc_id;
  149. __le16 conn_flags;
  150. u8 svc_meta_len;
  151. u8 pad;
  152. } __packed;
  153. /* connect response */
  154. struct htc_conn_service_resp {
  155. __le16 msg_id;
  156. __le16 svc_id;
  157. u8 status;
  158. u8 eid;
  159. __le16 max_msg_sz;
  160. u8 svc_meta_len;
  161. u8 pad;
  162. } __packed;
  163. struct htc_setup_comp_msg {
  164. __le16 msg_id;
  165. } __packed;
  166. /* extended setup completion message */
  167. struct htc_setup_comp_ext_msg {
  168. __le16 msg_id;
  169. __le32 flags;
  170. u8 msg_per_rxbndl;
  171. u8 Rsvd[3];
  172. } __packed;
  173. struct htc_record_hdr {
  174. u8 rec_id;
  175. u8 len;
  176. } __packed;
  177. struct htc_credit_report {
  178. u8 eid;
  179. u8 credits;
  180. } __packed;
  181. /*
  182. * NOTE: The lk_ahd array is guarded by a pre_valid
  183. * and Post Valid guard bytes. The pre_valid bytes must
  184. * equal the inverse of the post_valid byte.
  185. */
  186. struct htc_lookahead_report {
  187. u8 pre_valid;
  188. u8 lk_ahd[4];
  189. u8 post_valid;
  190. } __packed;
  191. struct htc_bundle_lkahd_rpt {
  192. u8 lk_ahd[4];
  193. } __packed;
  194. /* Current service IDs */
  195. enum htc_service_grp_ids {
  196. RSVD_SERVICE_GROUP = 0,
  197. WMI_SERVICE_GROUP = 1,
  198. HTC_TEST_GROUP = 254,
  199. HTC_SERVICE_GROUP_LAST = 255
  200. };
  201. /* ------ endpoint IDS ------ */
  202. enum htc_endpoint_id {
  203. ENDPOINT_UNUSED = -1,
  204. ENDPOINT_0 = 0,
  205. ENDPOINT_1 = 1,
  206. ENDPOINT_2 = 2,
  207. ENDPOINT_3,
  208. ENDPOINT_4,
  209. ENDPOINT_5,
  210. ENDPOINT_6,
  211. ENDPOINT_7,
  212. ENDPOINT_8,
  213. ENDPOINT_MAX,
  214. };
  215. struct htc_tx_packet_info {
  216. u16 tag;
  217. int cred_used;
  218. u8 flags;
  219. int seqno;
  220. };
  221. struct htc_rx_packet_info {
  222. u32 exp_hdr;
  223. u32 rx_flags;
  224. u32 indicat_flags;
  225. };
  226. struct htc_target;
  227. /* wrapper around endpoint-specific packets */
  228. struct htc_packet {
  229. struct list_head list;
  230. /* caller's per packet specific context */
  231. void *pkt_cntxt;
  232. /*
  233. * the true buffer start , the caller can store the real
  234. * buffer start here. In receive callbacks, the HTC layer
  235. * sets buf to the start of the payload past the header.
  236. * This field allows the caller to reset buf when it recycles
  237. * receive packets back to HTC.
  238. */
  239. u8 *buf_start;
  240. /*
  241. * Pointer to the start of the buffer. In the transmit
  242. * direction this points to the start of the payload. In the
  243. * receive direction, however, the buffer when queued up
  244. * points to the start of the HTC header but when returned
  245. * to the caller points to the start of the payload
  246. */
  247. u8 *buf;
  248. u32 buf_len;
  249. /* actual length of payload */
  250. u32 act_len;
  251. /* endpoint that this packet was sent/recv'd from */
  252. enum htc_endpoint_id endpoint;
  253. /* completion status */
  254. int status;
  255. union {
  256. struct htc_tx_packet_info tx;
  257. struct htc_rx_packet_info rx;
  258. } info;
  259. void (*completion) (struct htc_target *, struct htc_packet *);
  260. struct htc_target *context;
  261. /*
  262. * optimization for network-oriented data, the HTC packet
  263. * can pass the network buffer corresponding to the HTC packet
  264. * lower layers may optimized the transfer knowing this is
  265. * a network buffer
  266. */
  267. struct sk_buff *skb;
  268. };
  269. enum htc_send_full_action {
  270. HTC_SEND_FULL_KEEP = 0,
  271. HTC_SEND_FULL_DROP = 1,
  272. };
  273. struct htc_ep_callbacks {
  274. void (*tx_complete) (struct htc_target *, struct htc_packet *);
  275. void (*rx) (struct htc_target *, struct htc_packet *);
  276. void (*rx_refill) (struct htc_target *, enum htc_endpoint_id endpoint);
  277. enum htc_send_full_action (*tx_full) (struct htc_target *,
  278. struct htc_packet *);
  279. struct htc_packet *(*rx_allocthresh) (struct htc_target *,
  280. enum htc_endpoint_id, int);
  281. void (*tx_comp_multi) (struct htc_target *, struct list_head *);
  282. int rx_alloc_thresh;
  283. int rx_refill_thresh;
  284. };
  285. /* service connection information */
  286. struct htc_service_connect_req {
  287. u16 svc_id;
  288. u16 conn_flags;
  289. struct htc_ep_callbacks ep_cb;
  290. int max_txq_depth;
  291. u32 flags;
  292. unsigned int max_rxmsg_sz;
  293. };
  294. /* service connection response information */
  295. struct htc_service_connect_resp {
  296. u8 buf_len;
  297. u8 act_len;
  298. enum htc_endpoint_id endpoint;
  299. unsigned int len_max;
  300. u8 resp_code;
  301. };
  302. /* endpoint distributionstructure */
  303. struct htc_endpoint_credit_dist {
  304. struct list_head list;
  305. /* Service ID (set by HTC) */
  306. u16 svc_id;
  307. /* endpoint for this distributionstruct (set by HTC) */
  308. enum htc_endpoint_id endpoint;
  309. u32 dist_flags;
  310. /*
  311. * credits for normal operation, anything above this
  312. * indicates the endpoint is over-subscribed.
  313. */
  314. int cred_norm;
  315. /* floor for credit distribution */
  316. int cred_min;
  317. int cred_assngd;
  318. /* current credits available */
  319. int credits;
  320. /*
  321. * pending credits to distribute on this endpoint, this
  322. * is set by HTC when credit reports arrive. The credit
  323. * distribution functions sets this to zero when it distributes
  324. * the credits.
  325. */
  326. int cred_to_dist;
  327. /*
  328. * the number of credits that the current pending TX packet needs
  329. * to transmit. This is set by HTC when endpoint needs credits in
  330. * order to transmit.
  331. */
  332. int seek_cred;
  333. /* size in bytes of each credit */
  334. int cred_sz;
  335. /* credits required for a maximum sized messages */
  336. int cred_per_msg;
  337. /* reserved for HTC use */
  338. struct htc_endpoint *htc_ep;
  339. /*
  340. * current depth of TX queue , i.e. messages waiting for credits
  341. * This field is valid only when HTC_CREDIT_DIST_ACTIVITY_CHANGE
  342. * or HTC_CREDIT_DIST_SEND_COMPLETE is indicated on an endpoint
  343. * that has non-zero credits to recover.
  344. */
  345. int txq_depth;
  346. };
  347. /*
  348. * credit distibution code that is passed into the distrbution function,
  349. * there are mandatory and optional codes that must be handled
  350. */
  351. enum htc_credit_dist_reason {
  352. HTC_CREDIT_DIST_SEND_COMPLETE = 0,
  353. HTC_CREDIT_DIST_ACTIVITY_CHANGE = 1,
  354. HTC_CREDIT_DIST_SEEK_CREDITS,
  355. };
  356. struct ath6kl_htc_credit_info {
  357. int total_avail_credits;
  358. int cur_free_credits;
  359. /* list of lowest priority endpoints */
  360. struct list_head lowestpri_ep_dist;
  361. };
  362. /* endpoint statistics */
  363. struct htc_endpoint_stats {
  364. /*
  365. * number of times the host set the credit-low flag in a send
  366. * message on this endpoint
  367. */
  368. u32 cred_low_indicate;
  369. u32 tx_issued;
  370. u32 tx_pkt_bundled;
  371. u32 tx_bundles;
  372. u32 tx_dropped;
  373. /* running count of total credit reports received for this endpoint */
  374. u32 tx_cred_rpt;
  375. /* credit reports received from this endpoint's RX packets */
  376. u32 cred_rpt_from_rx;
  377. /* credit reports received from RX packets of other endpoints */
  378. u32 cred_rpt_from_other;
  379. /* credit reports received from endpoint 0 RX packets */
  380. u32 cred_rpt_ep0;
  381. /* count of credits received via Rx packets on this endpoint */
  382. u32 cred_from_rx;
  383. /* count of credits received via another endpoint */
  384. u32 cred_from_other;
  385. /* count of credits received via another endpoint */
  386. u32 cred_from_ep0;
  387. /* count of consummed credits */
  388. u32 cred_cosumd;
  389. /* count of credits returned */
  390. u32 cred_retnd;
  391. u32 rx_pkts;
  392. /* count of lookahead records found in Rx msg */
  393. u32 rx_lkahds;
  394. /* count of recv packets received in a bundle */
  395. u32 rx_bundl;
  396. /* count of number of bundled lookaheads */
  397. u32 rx_bundle_lkahd;
  398. /* count of the number of bundle indications from the HTC header */
  399. u32 rx_bundle_from_hdr;
  400. /* the number of times the recv allocation threshold was hit */
  401. u32 rx_alloc_thresh_hit;
  402. /* total number of bytes */
  403. u32 rxalloc_thresh_byte;
  404. };
  405. struct htc_endpoint {
  406. enum htc_endpoint_id eid;
  407. u16 svc_id;
  408. struct list_head txq;
  409. struct list_head rx_bufq;
  410. struct htc_endpoint_credit_dist cred_dist;
  411. struct htc_ep_callbacks ep_cb;
  412. int max_txq_depth;
  413. int len_max;
  414. int tx_proc_cnt;
  415. int rx_proc_cnt;
  416. struct htc_target *target;
  417. u8 seqno;
  418. u32 conn_flags;
  419. struct htc_endpoint_stats ep_st;
  420. u16 tx_drop_packet_threshold;
  421. struct {
  422. u8 pipeid_ul;
  423. u8 pipeid_dl;
  424. struct list_head tx_lookup_queue;
  425. bool tx_credit_flow_enabled;
  426. } pipe;
  427. };
  428. struct htc_control_buffer {
  429. struct htc_packet packet;
  430. u8 *buf;
  431. };
  432. struct htc_pipe_txcredit_alloc {
  433. u16 service_id;
  434. u8 credit_alloc;
  435. };
  436. enum htc_send_queue_result {
  437. HTC_SEND_QUEUE_OK = 0, /* packet was queued */
  438. HTC_SEND_QUEUE_DROP = 1, /* this packet should be dropped */
  439. };
  440. struct ath6kl_htc_ops {
  441. void* (*create)(struct ath6kl *ar);
  442. int (*wait_target)(struct htc_target *target);
  443. int (*start)(struct htc_target *target);
  444. int (*conn_service)(struct htc_target *target,
  445. struct htc_service_connect_req *req,
  446. struct htc_service_connect_resp *resp);
  447. int (*tx)(struct htc_target *target, struct htc_packet *packet);
  448. void (*stop)(struct htc_target *target);
  449. void (*cleanup)(struct htc_target *target);
  450. void (*flush_txep)(struct htc_target *target,
  451. enum htc_endpoint_id endpoint, u16 tag);
  452. void (*flush_rx_buf)(struct htc_target *target);
  453. void (*activity_changed)(struct htc_target *target,
  454. enum htc_endpoint_id endpoint,
  455. bool active);
  456. int (*get_rxbuf_num)(struct htc_target *target,
  457. enum htc_endpoint_id endpoint);
  458. int (*add_rxbuf_multiple)(struct htc_target *target,
  459. struct list_head *pktq);
  460. int (*credit_setup)(struct htc_target *target,
  461. struct ath6kl_htc_credit_info *cred_info);
  462. int (*tx_complete)(struct ath6kl *ar, struct sk_buff *skb);
  463. int (*rx_complete)(struct ath6kl *ar, struct sk_buff *skb, u8 pipe);
  464. };
  465. struct ath6kl_device;
  466. /* our HTC target state */
  467. struct htc_target {
  468. struct htc_endpoint endpoint[ENDPOINT_MAX];
  469. /* contains struct htc_endpoint_credit_dist */
  470. struct list_head cred_dist_list;
  471. struct list_head free_ctrl_txbuf;
  472. struct list_head free_ctrl_rxbuf;
  473. struct ath6kl_htc_credit_info *credit_info;
  474. int tgt_creds;
  475. unsigned int tgt_cred_sz;
  476. /* protects free_ctrl_txbuf and free_ctrl_rxbuf */
  477. spinlock_t htc_lock;
  478. /* FIXME: does this protext rx_bufq and endpoint structures or what? */
  479. spinlock_t rx_lock;
  480. /* protects endpoint->txq */
  481. spinlock_t tx_lock;
  482. struct ath6kl_device *dev;
  483. u32 htc_flags;
  484. u32 rx_st_flags;
  485. enum htc_endpoint_id ep_waiting;
  486. u8 htc_tgt_ver;
  487. /* max messages per bundle for HTC */
  488. int msg_per_bndl_max;
  489. u32 tx_bndl_mask;
  490. int rx_bndl_enable;
  491. int max_rx_bndl_sz;
  492. int max_tx_bndl_sz;
  493. u32 block_sz;
  494. u32 block_mask;
  495. int max_scat_entries;
  496. int max_xfer_szper_scatreq;
  497. int chk_irq_status_cnt;
  498. /* counts the number of Tx without bundling continously per AC */
  499. u32 ac_tx_count[WMM_NUM_AC];
  500. struct {
  501. struct htc_packet *htc_packet_pool;
  502. u8 ctrl_response_buf[HTC_MAX_CTRL_MSG_LEN];
  503. int ctrl_response_len;
  504. bool ctrl_response_valid;
  505. struct htc_pipe_txcredit_alloc txcredit_alloc[ENDPOINT_MAX];
  506. } pipe;
  507. };
  508. int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target,
  509. u32 msg_look_ahead, int *n_pkts);
  510. static inline void set_htc_pkt_info(struct htc_packet *packet, void *context,
  511. u8 *buf, unsigned int len,
  512. enum htc_endpoint_id eid, u16 tag)
  513. {
  514. packet->pkt_cntxt = context;
  515. packet->buf = buf;
  516. packet->act_len = len;
  517. packet->endpoint = eid;
  518. packet->info.tx.tag = tag;
  519. }
  520. static inline void htc_rxpkt_reset(struct htc_packet *packet)
  521. {
  522. packet->buf = packet->buf_start;
  523. packet->act_len = 0;
  524. }
  525. static inline void set_htc_rxpkt_info(struct htc_packet *packet, void *context,
  526. u8 *buf, unsigned long len,
  527. enum htc_endpoint_id eid)
  528. {
  529. packet->pkt_cntxt = context;
  530. packet->buf = buf;
  531. packet->buf_start = buf;
  532. packet->buf_len = len;
  533. packet->endpoint = eid;
  534. }
  535. static inline int get_queue_depth(struct list_head *queue)
  536. {
  537. struct list_head *tmp_list;
  538. int depth = 0;
  539. list_for_each(tmp_list, queue)
  540. depth++;
  541. return depth;
  542. }
  543. void ath6kl_htc_pipe_attach(struct ath6kl *ar);
  544. void ath6kl_htc_mbox_attach(struct ath6kl *ar);
  545. #endif