htc.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  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. struct_group_tagged(htc_frame_look_ahead, header,
  125. union {
  126. struct {
  127. u8 eid;
  128. u8 flags;
  129. /* length of data (including trailer) that follows the header */
  130. __le16 payld_len;
  131. };
  132. u32 word;
  133. };
  134. );
  135. /* end of 4-byte lookahead */
  136. u8 ctrl[2];
  137. } __packed;
  138. /* HTC ready message */
  139. struct htc_ready_msg {
  140. __le16 msg_id;
  141. __le16 cred_cnt;
  142. __le16 cred_sz;
  143. u8 max_ep;
  144. u8 pad;
  145. } __packed;
  146. /* extended HTC ready message */
  147. struct htc_ready_ext_msg {
  148. struct htc_ready_msg ver2_0_info;
  149. u8 htc_ver;
  150. u8 msg_per_htc_bndl;
  151. } __packed;
  152. /* connect service */
  153. struct htc_conn_service_msg {
  154. __le16 msg_id;
  155. __le16 svc_id;
  156. __le16 conn_flags;
  157. u8 svc_meta_len;
  158. u8 pad;
  159. } __packed;
  160. /* connect response */
  161. struct htc_conn_service_resp {
  162. __le16 msg_id;
  163. __le16 svc_id;
  164. u8 status;
  165. u8 eid;
  166. __le16 max_msg_sz;
  167. u8 svc_meta_len;
  168. u8 pad;
  169. } __packed;
  170. struct htc_setup_comp_msg {
  171. __le16 msg_id;
  172. } __packed;
  173. /* extended setup completion message */
  174. struct htc_setup_comp_ext_msg {
  175. __le16 msg_id;
  176. __le32 flags;
  177. u8 msg_per_rxbndl;
  178. u8 Rsvd[3];
  179. } __packed;
  180. struct htc_record_hdr {
  181. u8 rec_id;
  182. u8 len;
  183. } __packed;
  184. struct htc_credit_report {
  185. u8 eid;
  186. u8 credits;
  187. } __packed;
  188. /*
  189. * NOTE: The lk_ahd array is guarded by a pre_valid
  190. * and Post Valid guard bytes. The pre_valid bytes must
  191. * equal the inverse of the post_valid byte.
  192. */
  193. struct htc_lookahead_report {
  194. u8 pre_valid;
  195. u8 lk_ahd[4];
  196. u8 post_valid;
  197. } __packed;
  198. struct htc_bundle_lkahd_rpt {
  199. u8 lk_ahd[4];
  200. } __packed;
  201. /* Current service IDs */
  202. enum htc_service_grp_ids {
  203. RSVD_SERVICE_GROUP = 0,
  204. WMI_SERVICE_GROUP = 1,
  205. HTC_TEST_GROUP = 254,
  206. HTC_SERVICE_GROUP_LAST = 255
  207. };
  208. /* ------ endpoint IDS ------ */
  209. enum htc_endpoint_id {
  210. ENDPOINT_UNUSED = -1,
  211. ENDPOINT_0 = 0,
  212. ENDPOINT_1 = 1,
  213. ENDPOINT_2 = 2,
  214. ENDPOINT_3,
  215. ENDPOINT_4,
  216. ENDPOINT_5,
  217. ENDPOINT_6,
  218. ENDPOINT_7,
  219. ENDPOINT_8,
  220. ENDPOINT_MAX,
  221. };
  222. struct htc_tx_packet_info {
  223. u16 tag;
  224. int cred_used;
  225. u8 flags;
  226. int seqno;
  227. };
  228. struct htc_rx_packet_info {
  229. u32 exp_hdr;
  230. u32 rx_flags;
  231. u32 indicat_flags;
  232. };
  233. struct htc_target;
  234. /* wrapper around endpoint-specific packets */
  235. struct htc_packet {
  236. struct list_head list;
  237. /* caller's per packet specific context */
  238. void *pkt_cntxt;
  239. /*
  240. * the true buffer start , the caller can store the real
  241. * buffer start here. In receive callbacks, the HTC layer
  242. * sets buf to the start of the payload past the header.
  243. * This field allows the caller to reset buf when it recycles
  244. * receive packets back to HTC.
  245. */
  246. u8 *buf_start;
  247. /*
  248. * Pointer to the start of the buffer. In the transmit
  249. * direction this points to the start of the payload. In the
  250. * receive direction, however, the buffer when queued up
  251. * points to the start of the HTC header but when returned
  252. * to the caller points to the start of the payload
  253. */
  254. u8 *buf;
  255. u32 buf_len;
  256. /* actual length of payload */
  257. u32 act_len;
  258. /* endpoint that this packet was sent/recv'd from */
  259. enum htc_endpoint_id endpoint;
  260. /* completion status */
  261. int status;
  262. union {
  263. struct htc_tx_packet_info tx;
  264. struct htc_rx_packet_info rx;
  265. } info;
  266. void (*completion) (struct htc_target *, struct htc_packet *);
  267. struct htc_target *context;
  268. /*
  269. * optimization for network-oriented data, the HTC packet
  270. * can pass the network buffer corresponding to the HTC packet
  271. * lower layers may optimized the transfer knowing this is
  272. * a network buffer
  273. */
  274. struct sk_buff *skb;
  275. };
  276. enum htc_send_full_action {
  277. HTC_SEND_FULL_KEEP = 0,
  278. HTC_SEND_FULL_DROP = 1,
  279. };
  280. struct htc_ep_callbacks {
  281. void (*tx_complete) (struct htc_target *, struct htc_packet *);
  282. void (*rx) (struct htc_target *, struct htc_packet *);
  283. void (*rx_refill) (struct htc_target *, enum htc_endpoint_id endpoint);
  284. enum htc_send_full_action (*tx_full) (struct htc_target *,
  285. struct htc_packet *);
  286. struct htc_packet *(*rx_allocthresh) (struct htc_target *,
  287. enum htc_endpoint_id, int);
  288. void (*tx_comp_multi) (struct htc_target *, struct list_head *);
  289. int rx_alloc_thresh;
  290. int rx_refill_thresh;
  291. };
  292. /* service connection information */
  293. struct htc_service_connect_req {
  294. u16 svc_id;
  295. u16 conn_flags;
  296. struct htc_ep_callbacks ep_cb;
  297. int max_txq_depth;
  298. u32 flags;
  299. unsigned int max_rxmsg_sz;
  300. };
  301. /* service connection response information */
  302. struct htc_service_connect_resp {
  303. u8 buf_len;
  304. u8 act_len;
  305. enum htc_endpoint_id endpoint;
  306. unsigned int len_max;
  307. u8 resp_code;
  308. };
  309. /* endpoint distributionstructure */
  310. struct htc_endpoint_credit_dist {
  311. struct list_head list;
  312. /* Service ID (set by HTC) */
  313. u16 svc_id;
  314. /* endpoint for this distributionstruct (set by HTC) */
  315. enum htc_endpoint_id endpoint;
  316. u32 dist_flags;
  317. /*
  318. * credits for normal operation, anything above this
  319. * indicates the endpoint is over-subscribed.
  320. */
  321. int cred_norm;
  322. /* floor for credit distribution */
  323. int cred_min;
  324. int cred_assngd;
  325. /* current credits available */
  326. int credits;
  327. /*
  328. * pending credits to distribute on this endpoint, this
  329. * is set by HTC when credit reports arrive. The credit
  330. * distribution functions sets this to zero when it distributes
  331. * the credits.
  332. */
  333. int cred_to_dist;
  334. /*
  335. * the number of credits that the current pending TX packet needs
  336. * to transmit. This is set by HTC when endpoint needs credits in
  337. * order to transmit.
  338. */
  339. int seek_cred;
  340. /* size in bytes of each credit */
  341. int cred_sz;
  342. /* credits required for a maximum sized messages */
  343. int cred_per_msg;
  344. /* reserved for HTC use */
  345. struct htc_endpoint *htc_ep;
  346. /*
  347. * current depth of TX queue , i.e. messages waiting for credits
  348. * This field is valid only when HTC_CREDIT_DIST_ACTIVITY_CHANGE
  349. * or HTC_CREDIT_DIST_SEND_COMPLETE is indicated on an endpoint
  350. * that has non-zero credits to recover.
  351. */
  352. int txq_depth;
  353. };
  354. /*
  355. * credit distribution code that is passed into the distribution function,
  356. * there are mandatory and optional codes that must be handled
  357. */
  358. enum htc_credit_dist_reason {
  359. HTC_CREDIT_DIST_SEND_COMPLETE = 0,
  360. HTC_CREDIT_DIST_ACTIVITY_CHANGE = 1,
  361. HTC_CREDIT_DIST_SEEK_CREDITS,
  362. };
  363. struct ath6kl_htc_credit_info {
  364. int total_avail_credits;
  365. int cur_free_credits;
  366. /* list of lowest priority endpoints */
  367. struct list_head lowestpri_ep_dist;
  368. };
  369. /* endpoint statistics */
  370. struct htc_endpoint_stats {
  371. /*
  372. * number of times the host set the credit-low flag in a send
  373. * message on this endpoint
  374. */
  375. u32 cred_low_indicate;
  376. u32 tx_issued;
  377. u32 tx_pkt_bundled;
  378. u32 tx_bundles;
  379. u32 tx_dropped;
  380. /* running count of total credit reports received for this endpoint */
  381. u32 tx_cred_rpt;
  382. /* credit reports received from this endpoint's RX packets */
  383. u32 cred_rpt_from_rx;
  384. /* credit reports received from RX packets of other endpoints */
  385. u32 cred_rpt_from_other;
  386. /* credit reports received from endpoint 0 RX packets */
  387. u32 cred_rpt_ep0;
  388. /* count of credits received via Rx packets on this endpoint */
  389. u32 cred_from_rx;
  390. /* count of credits received via another endpoint */
  391. u32 cred_from_other;
  392. /* count of credits received via another endpoint */
  393. u32 cred_from_ep0;
  394. /* count of consummed credits */
  395. u32 cred_cosumd;
  396. /* count of credits returned */
  397. u32 cred_retnd;
  398. u32 rx_pkts;
  399. /* count of lookahead records found in Rx msg */
  400. u32 rx_lkahds;
  401. /* count of recv packets received in a bundle */
  402. u32 rx_bundl;
  403. /* count of number of bundled lookaheads */
  404. u32 rx_bundle_lkahd;
  405. /* count of the number of bundle indications from the HTC header */
  406. u32 rx_bundle_from_hdr;
  407. /* the number of times the recv allocation threshold was hit */
  408. u32 rx_alloc_thresh_hit;
  409. /* total number of bytes */
  410. u32 rxalloc_thresh_byte;
  411. };
  412. struct htc_endpoint {
  413. enum htc_endpoint_id eid;
  414. u16 svc_id;
  415. struct list_head txq;
  416. struct list_head rx_bufq;
  417. struct htc_endpoint_credit_dist cred_dist;
  418. struct htc_ep_callbacks ep_cb;
  419. int max_txq_depth;
  420. int len_max;
  421. int tx_proc_cnt;
  422. int rx_proc_cnt;
  423. struct htc_target *target;
  424. u8 seqno;
  425. u32 conn_flags;
  426. struct htc_endpoint_stats ep_st;
  427. u16 tx_drop_packet_threshold;
  428. struct {
  429. u8 pipeid_ul;
  430. u8 pipeid_dl;
  431. struct list_head tx_lookup_queue;
  432. bool tx_credit_flow_enabled;
  433. } pipe;
  434. };
  435. struct htc_control_buffer {
  436. struct htc_packet packet;
  437. u8 *buf;
  438. };
  439. struct htc_pipe_txcredit_alloc {
  440. u16 service_id;
  441. u8 credit_alloc;
  442. };
  443. enum htc_send_queue_result {
  444. HTC_SEND_QUEUE_OK = 0, /* packet was queued */
  445. HTC_SEND_QUEUE_DROP = 1, /* this packet should be dropped */
  446. };
  447. struct ath6kl_htc_ops {
  448. void* (*create)(struct ath6kl *ar);
  449. int (*wait_target)(struct htc_target *target);
  450. int (*start)(struct htc_target *target);
  451. int (*conn_service)(struct htc_target *target,
  452. struct htc_service_connect_req *req,
  453. struct htc_service_connect_resp *resp);
  454. int (*tx)(struct htc_target *target, struct htc_packet *packet);
  455. void (*stop)(struct htc_target *target);
  456. void (*cleanup)(struct htc_target *target);
  457. void (*flush_txep)(struct htc_target *target,
  458. enum htc_endpoint_id endpoint, u16 tag);
  459. void (*flush_rx_buf)(struct htc_target *target);
  460. void (*activity_changed)(struct htc_target *target,
  461. enum htc_endpoint_id endpoint,
  462. bool active);
  463. int (*get_rxbuf_num)(struct htc_target *target,
  464. enum htc_endpoint_id endpoint);
  465. int (*add_rxbuf_multiple)(struct htc_target *target,
  466. struct list_head *pktq);
  467. int (*credit_setup)(struct htc_target *target,
  468. struct ath6kl_htc_credit_info *cred_info);
  469. int (*tx_complete)(struct ath6kl *ar, struct sk_buff *skb);
  470. int (*rx_complete)(struct ath6kl *ar, struct sk_buff *skb, u8 pipe);
  471. };
  472. struct ath6kl_device;
  473. /* our HTC target state */
  474. struct htc_target {
  475. struct htc_endpoint endpoint[ENDPOINT_MAX];
  476. /* contains struct htc_endpoint_credit_dist */
  477. struct list_head cred_dist_list;
  478. struct list_head free_ctrl_txbuf;
  479. struct list_head free_ctrl_rxbuf;
  480. struct ath6kl_htc_credit_info *credit_info;
  481. int tgt_creds;
  482. unsigned int tgt_cred_sz;
  483. /* protects free_ctrl_txbuf and free_ctrl_rxbuf */
  484. spinlock_t htc_lock;
  485. /* FIXME: does this protext rx_bufq and endpoint structures or what? */
  486. spinlock_t rx_lock;
  487. /* protects endpoint->txq */
  488. spinlock_t tx_lock;
  489. struct ath6kl_device *dev;
  490. u32 htc_flags;
  491. u32 rx_st_flags;
  492. enum htc_endpoint_id ep_waiting;
  493. u8 htc_tgt_ver;
  494. /* max messages per bundle for HTC */
  495. int msg_per_bndl_max;
  496. u32 tx_bndl_mask;
  497. int rx_bndl_enable;
  498. int max_rx_bndl_sz;
  499. int max_tx_bndl_sz;
  500. u32 block_sz;
  501. u32 block_mask;
  502. int max_scat_entries;
  503. int max_xfer_szper_scatreq;
  504. int chk_irq_status_cnt;
  505. /* counts the number of Tx without bundling continously per AC */
  506. u32 ac_tx_count[WMM_NUM_AC];
  507. struct {
  508. struct htc_packet *htc_packet_pool;
  509. u8 ctrl_response_buf[HTC_MAX_CTRL_MSG_LEN];
  510. int ctrl_response_len;
  511. bool ctrl_response_valid;
  512. struct htc_pipe_txcredit_alloc txcredit_alloc[ENDPOINT_MAX];
  513. } pipe;
  514. };
  515. int ath6kl_htc_rxmsg_pending_handler(struct htc_target *target,
  516. u32 msg_look_ahead, int *n_pkts);
  517. static inline void set_htc_pkt_info(struct htc_packet *packet, void *context,
  518. u8 *buf, unsigned int len,
  519. enum htc_endpoint_id eid, u16 tag)
  520. {
  521. packet->pkt_cntxt = context;
  522. packet->buf = buf;
  523. packet->act_len = len;
  524. packet->endpoint = eid;
  525. packet->info.tx.tag = tag;
  526. }
  527. static inline void htc_rxpkt_reset(struct htc_packet *packet)
  528. {
  529. packet->buf = packet->buf_start;
  530. packet->act_len = 0;
  531. }
  532. static inline void set_htc_rxpkt_info(struct htc_packet *packet, void *context,
  533. u8 *buf, unsigned long len,
  534. enum htc_endpoint_id eid)
  535. {
  536. packet->pkt_cntxt = context;
  537. packet->buf = buf;
  538. packet->buf_start = buf;
  539. packet->buf_len = len;
  540. packet->endpoint = eid;
  541. }
  542. static inline int get_queue_depth(struct list_head *queue)
  543. {
  544. struct list_head *tmp_list;
  545. int depth = 0;
  546. list_for_each(tmp_list, queue)
  547. depth++;
  548. return depth;
  549. }
  550. void ath6kl_htc_pipe_attach(struct ath6kl *ar);
  551. void ath6kl_htc_mbox_attach(struct ath6kl *ar);
  552. #endif