18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2004-2011 Atheros Communications Inc. 38c2ecf20Sopenharmony_ci * Copyright (c) 2011 Qualcomm Atheros, Inc. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 68c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 78c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 108c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 118c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 128c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 138c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 148c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 158c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#ifndef HTC_H 198c2ecf20Sopenharmony_ci#define HTC_H 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#include "common.h" 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* frame header flags */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* send direction */ 268c2ecf20Sopenharmony_ci#define HTC_FLAGS_NEED_CREDIT_UPDATE (1 << 0) 278c2ecf20Sopenharmony_ci#define HTC_FLAGS_SEND_BUNDLE (1 << 1) 288c2ecf20Sopenharmony_ci#define HTC_FLAGS_TX_FIXUP_NETBUF (1 << 2) 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* receive direction */ 318c2ecf20Sopenharmony_ci#define HTC_FLG_RX_UNUSED (1 << 0) 328c2ecf20Sopenharmony_ci#define HTC_FLG_RX_TRAILER (1 << 1) 338c2ecf20Sopenharmony_ci/* Bundle count maske and shift */ 348c2ecf20Sopenharmony_ci#define HTC_FLG_RX_BNDL_CNT (0xF0) 358c2ecf20Sopenharmony_ci#define HTC_FLG_RX_BNDL_CNT_S 4 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define HTC_HDR_LENGTH (sizeof(struct htc_frame_hdr)) 388c2ecf20Sopenharmony_ci#define HTC_MAX_PAYLOAD_LENGTH (4096 - sizeof(struct htc_frame_hdr)) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* HTC control message IDs */ 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#define HTC_MSG_READY_ID 1 438c2ecf20Sopenharmony_ci#define HTC_MSG_CONN_SVC_ID 2 448c2ecf20Sopenharmony_ci#define HTC_MSG_CONN_SVC_RESP_ID 3 458c2ecf20Sopenharmony_ci#define HTC_MSG_SETUP_COMPLETE_ID 4 468c2ecf20Sopenharmony_ci#define HTC_MSG_SETUP_COMPLETE_EX_ID 5 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci#define HTC_MAX_CTRL_MSG_LEN 256 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define HTC_VERSION_2P0 0x00 518c2ecf20Sopenharmony_ci#define HTC_VERSION_2P1 0x01 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define HTC_SERVICE_META_DATA_MAX_LENGTH 128 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define HTC_CONN_FLGS_THRESH_LVL_QUAT 0x0 568c2ecf20Sopenharmony_ci#define HTC_CONN_FLGS_THRESH_LVL_HALF 0x1 578c2ecf20Sopenharmony_ci#define HTC_CONN_FLGS_THRESH_LVL_THREE_QUAT 0x2 588c2ecf20Sopenharmony_ci#define HTC_CONN_FLGS_REDUCE_CRED_DRIB 0x4 598c2ecf20Sopenharmony_ci#define HTC_CONN_FLGS_THRESH_MASK 0x3 608c2ecf20Sopenharmony_ci/* disable credit flow control on a specific service */ 618c2ecf20Sopenharmony_ci#define HTC_CONN_FLGS_DISABLE_CRED_FLOW_CTRL (1 << 3) 628c2ecf20Sopenharmony_ci#define HTC_CONN_FLGS_SET_RECV_ALLOC_SHIFT 8 638c2ecf20Sopenharmony_ci#define HTC_CONN_FLGS_SET_RECV_ALLOC_MASK 0xFF00U 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* connect response status codes */ 668c2ecf20Sopenharmony_ci#define HTC_SERVICE_SUCCESS 0 678c2ecf20Sopenharmony_ci#define HTC_SERVICE_NOT_FOUND 1 688c2ecf20Sopenharmony_ci#define HTC_SERVICE_FAILED 2 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* no resources (i.e. no more endpoints) */ 718c2ecf20Sopenharmony_ci#define HTC_SERVICE_NO_RESOURCES 3 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* specific service is not allowing any more endpoints */ 748c2ecf20Sopenharmony_ci#define HTC_SERVICE_NO_MORE_EP 4 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci/* report record IDs */ 778c2ecf20Sopenharmony_ci#define HTC_RECORD_NULL 0 788c2ecf20Sopenharmony_ci#define HTC_RECORD_CREDITS 1 798c2ecf20Sopenharmony_ci#define HTC_RECORD_LOOKAHEAD 2 808c2ecf20Sopenharmony_ci#define HTC_RECORD_LOOKAHEAD_BUNDLE 3 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define HTC_SETUP_COMP_FLG_RX_BNDL_EN (1 << 0) 838c2ecf20Sopenharmony_ci#define HTC_SETUP_COMP_FLG_DISABLE_TX_CREDIT_FLOW (1 << 1) 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#define MAKE_SERVICE_ID(group, index) \ 868c2ecf20Sopenharmony_ci (int)(((int)group << 8) | (int)(index)) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci/* NOTE: service ID of 0x0000 is reserved and should never be used */ 898c2ecf20Sopenharmony_ci#define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 1) 908c2ecf20Sopenharmony_ci#define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 0) 918c2ecf20Sopenharmony_ci#define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 1) 928c2ecf20Sopenharmony_ci#define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 2) 938c2ecf20Sopenharmony_ci#define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 3) 948c2ecf20Sopenharmony_ci#define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4) 958c2ecf20Sopenharmony_ci#define WMI_MAX_SERVICES 5 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#define WMM_NUM_AC 4 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci/* reserved and used to flush ALL packets */ 1008c2ecf20Sopenharmony_ci#define HTC_TX_PACKET_TAG_ALL 0 1018c2ecf20Sopenharmony_ci#define HTC_SERVICE_TX_PACKET_TAG 1 1028c2ecf20Sopenharmony_ci#define HTC_TX_PACKET_TAG_USER_DEFINED (HTC_SERVICE_TX_PACKET_TAG + 9) 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* more packets on this endpoint are being fetched */ 1058c2ecf20Sopenharmony_ci#define HTC_RX_FLAGS_INDICATE_MORE_PKTS (1 << 0) 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci/* TODO.. for BMI */ 1088c2ecf20Sopenharmony_ci#define ENDPOINT1 0 1098c2ecf20Sopenharmony_ci/* TODO -remove me, but we have to fix BMI first */ 1108c2ecf20Sopenharmony_ci#define HTC_MAILBOX_NUM_MAX 4 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* enable send bundle padding for this endpoint */ 1138c2ecf20Sopenharmony_ci#define HTC_FLGS_TX_BNDL_PAD_EN (1 << 0) 1148c2ecf20Sopenharmony_ci#define HTC_EP_ACTIVE ((u32) (1u << 31)) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci/* HTC operational parameters */ 1178c2ecf20Sopenharmony_ci#define HTC_TARGET_RESPONSE_TIMEOUT 2000 /* in ms */ 1188c2ecf20Sopenharmony_ci#define HTC_TARGET_RESPONSE_POLL_WAIT 10 1198c2ecf20Sopenharmony_ci#define HTC_TARGET_RESPONSE_POLL_COUNT 200 1208c2ecf20Sopenharmony_ci#define HTC_TARGET_DEBUG_INTR_MASK 0x01 1218c2ecf20Sopenharmony_ci#define HTC_TARGET_CREDIT_INTR_MASK 0xF0 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci#define HTC_HOST_MAX_MSG_PER_BUNDLE 8 1248c2ecf20Sopenharmony_ci#define HTC_MIN_HTC_MSGS_TO_BUNDLE 2 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci/* packet flags */ 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci#define HTC_RX_PKT_IGNORE_LOOKAHEAD (1 << 0) 1298c2ecf20Sopenharmony_ci#define HTC_RX_PKT_REFRESH_HDR (1 << 1) 1308c2ecf20Sopenharmony_ci#define HTC_RX_PKT_PART_OF_BUNDLE (1 << 2) 1318c2ecf20Sopenharmony_ci#define HTC_RX_PKT_NO_RECYCLE (1 << 3) 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci#define NUM_CONTROL_BUFFERS 8 1348c2ecf20Sopenharmony_ci#define NUM_CONTROL_TX_BUFFERS 2 1358c2ecf20Sopenharmony_ci#define NUM_CONTROL_RX_BUFFERS (NUM_CONTROL_BUFFERS - NUM_CONTROL_TX_BUFFERS) 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci#define HTC_RECV_WAIT_BUFFERS (1 << 0) 1388c2ecf20Sopenharmony_ci#define HTC_OP_STATE_STOPPING (1 << 0) 1398c2ecf20Sopenharmony_ci#define HTC_OP_STATE_SETUP_COMPLETE (1 << 1) 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* 1428c2ecf20Sopenharmony_ci * The frame header length and message formats defined herein were selected 1438c2ecf20Sopenharmony_ci * to accommodate optimal alignment for target processing. This reduces 1448c2ecf20Sopenharmony_ci * code size and improves performance. Any changes to the header length may 1458c2ecf20Sopenharmony_ci * alter the alignment and cause exceptions on the target. When adding to 1468c2ecf20Sopenharmony_ci * the messagestructures insure that fields are properly aligned. 1478c2ecf20Sopenharmony_ci */ 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci/* HTC frame header 1508c2ecf20Sopenharmony_ci * 1518c2ecf20Sopenharmony_ci * NOTE: do not remove or re-arrange the fields, these are minimally 1528c2ecf20Sopenharmony_ci * required to take advantage of 4-byte lookaheads in some hardware 1538c2ecf20Sopenharmony_ci * implementations. 1548c2ecf20Sopenharmony_ci */ 1558c2ecf20Sopenharmony_cistruct htc_frame_hdr { 1568c2ecf20Sopenharmony_ci struct_group_tagged(htc_frame_look_ahead, header, 1578c2ecf20Sopenharmony_ci union { 1588c2ecf20Sopenharmony_ci struct { 1598c2ecf20Sopenharmony_ci u8 eid; 1608c2ecf20Sopenharmony_ci u8 flags; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci /* length of data (including trailer) that follows the header */ 1638c2ecf20Sopenharmony_ci __le16 payld_len; 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci }; 1668c2ecf20Sopenharmony_ci u32 word; 1678c2ecf20Sopenharmony_ci }; 1688c2ecf20Sopenharmony_ci ); 1698c2ecf20Sopenharmony_ci /* end of 4-byte lookahead */ 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ci u8 ctrl[2]; 1728c2ecf20Sopenharmony_ci} __packed; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci/* HTC ready message */ 1758c2ecf20Sopenharmony_cistruct htc_ready_msg { 1768c2ecf20Sopenharmony_ci __le16 msg_id; 1778c2ecf20Sopenharmony_ci __le16 cred_cnt; 1788c2ecf20Sopenharmony_ci __le16 cred_sz; 1798c2ecf20Sopenharmony_ci u8 max_ep; 1808c2ecf20Sopenharmony_ci u8 pad; 1818c2ecf20Sopenharmony_ci} __packed; 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci/* extended HTC ready message */ 1848c2ecf20Sopenharmony_cistruct htc_ready_ext_msg { 1858c2ecf20Sopenharmony_ci struct htc_ready_msg ver2_0_info; 1868c2ecf20Sopenharmony_ci u8 htc_ver; 1878c2ecf20Sopenharmony_ci u8 msg_per_htc_bndl; 1888c2ecf20Sopenharmony_ci} __packed; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_ci/* connect service */ 1918c2ecf20Sopenharmony_cistruct htc_conn_service_msg { 1928c2ecf20Sopenharmony_ci __le16 msg_id; 1938c2ecf20Sopenharmony_ci __le16 svc_id; 1948c2ecf20Sopenharmony_ci __le16 conn_flags; 1958c2ecf20Sopenharmony_ci u8 svc_meta_len; 1968c2ecf20Sopenharmony_ci u8 pad; 1978c2ecf20Sopenharmony_ci} __packed; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci/* connect response */ 2008c2ecf20Sopenharmony_cistruct htc_conn_service_resp { 2018c2ecf20Sopenharmony_ci __le16 msg_id; 2028c2ecf20Sopenharmony_ci __le16 svc_id; 2038c2ecf20Sopenharmony_ci u8 status; 2048c2ecf20Sopenharmony_ci u8 eid; 2058c2ecf20Sopenharmony_ci __le16 max_msg_sz; 2068c2ecf20Sopenharmony_ci u8 svc_meta_len; 2078c2ecf20Sopenharmony_ci u8 pad; 2088c2ecf20Sopenharmony_ci} __packed; 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_cistruct htc_setup_comp_msg { 2118c2ecf20Sopenharmony_ci __le16 msg_id; 2128c2ecf20Sopenharmony_ci} __packed; 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci/* extended setup completion message */ 2158c2ecf20Sopenharmony_cistruct htc_setup_comp_ext_msg { 2168c2ecf20Sopenharmony_ci __le16 msg_id; 2178c2ecf20Sopenharmony_ci __le32 flags; 2188c2ecf20Sopenharmony_ci u8 msg_per_rxbndl; 2198c2ecf20Sopenharmony_ci u8 Rsvd[3]; 2208c2ecf20Sopenharmony_ci} __packed; 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_cistruct htc_record_hdr { 2238c2ecf20Sopenharmony_ci u8 rec_id; 2248c2ecf20Sopenharmony_ci u8 len; 2258c2ecf20Sopenharmony_ci} __packed; 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_cistruct htc_credit_report { 2288c2ecf20Sopenharmony_ci u8 eid; 2298c2ecf20Sopenharmony_ci u8 credits; 2308c2ecf20Sopenharmony_ci} __packed; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci/* 2338c2ecf20Sopenharmony_ci * NOTE: The lk_ahd array is guarded by a pre_valid 2348c2ecf20Sopenharmony_ci * and Post Valid guard bytes. The pre_valid bytes must 2358c2ecf20Sopenharmony_ci * equal the inverse of the post_valid byte. 2368c2ecf20Sopenharmony_ci */ 2378c2ecf20Sopenharmony_cistruct htc_lookahead_report { 2388c2ecf20Sopenharmony_ci u8 pre_valid; 2398c2ecf20Sopenharmony_ci u8 lk_ahd[4]; 2408c2ecf20Sopenharmony_ci u8 post_valid; 2418c2ecf20Sopenharmony_ci} __packed; 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_cistruct htc_bundle_lkahd_rpt { 2448c2ecf20Sopenharmony_ci u8 lk_ahd[4]; 2458c2ecf20Sopenharmony_ci} __packed; 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci/* Current service IDs */ 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_cienum htc_service_grp_ids { 2508c2ecf20Sopenharmony_ci RSVD_SERVICE_GROUP = 0, 2518c2ecf20Sopenharmony_ci WMI_SERVICE_GROUP = 1, 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_ci HTC_TEST_GROUP = 254, 2548c2ecf20Sopenharmony_ci HTC_SERVICE_GROUP_LAST = 255 2558c2ecf20Sopenharmony_ci}; 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci/* ------ endpoint IDS ------ */ 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_cienum htc_endpoint_id { 2608c2ecf20Sopenharmony_ci ENDPOINT_UNUSED = -1, 2618c2ecf20Sopenharmony_ci ENDPOINT_0 = 0, 2628c2ecf20Sopenharmony_ci ENDPOINT_1 = 1, 2638c2ecf20Sopenharmony_ci ENDPOINT_2 = 2, 2648c2ecf20Sopenharmony_ci ENDPOINT_3, 2658c2ecf20Sopenharmony_ci ENDPOINT_4, 2668c2ecf20Sopenharmony_ci ENDPOINT_5, 2678c2ecf20Sopenharmony_ci ENDPOINT_6, 2688c2ecf20Sopenharmony_ci ENDPOINT_7, 2698c2ecf20Sopenharmony_ci ENDPOINT_8, 2708c2ecf20Sopenharmony_ci ENDPOINT_MAX, 2718c2ecf20Sopenharmony_ci}; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_cistruct htc_tx_packet_info { 2748c2ecf20Sopenharmony_ci u16 tag; 2758c2ecf20Sopenharmony_ci int cred_used; 2768c2ecf20Sopenharmony_ci u8 flags; 2778c2ecf20Sopenharmony_ci int seqno; 2788c2ecf20Sopenharmony_ci}; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_cistruct htc_rx_packet_info { 2818c2ecf20Sopenharmony_ci u32 exp_hdr; 2828c2ecf20Sopenharmony_ci u32 rx_flags; 2838c2ecf20Sopenharmony_ci u32 indicat_flags; 2848c2ecf20Sopenharmony_ci}; 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_cistruct htc_target; 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci/* wrapper around endpoint-specific packets */ 2898c2ecf20Sopenharmony_cistruct htc_packet { 2908c2ecf20Sopenharmony_ci struct list_head list; 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci /* caller's per packet specific context */ 2938c2ecf20Sopenharmony_ci void *pkt_cntxt; 2948c2ecf20Sopenharmony_ci 2958c2ecf20Sopenharmony_ci /* 2968c2ecf20Sopenharmony_ci * the true buffer start , the caller can store the real 2978c2ecf20Sopenharmony_ci * buffer start here. In receive callbacks, the HTC layer 2988c2ecf20Sopenharmony_ci * sets buf to the start of the payload past the header. 2998c2ecf20Sopenharmony_ci * This field allows the caller to reset buf when it recycles 3008c2ecf20Sopenharmony_ci * receive packets back to HTC. 3018c2ecf20Sopenharmony_ci */ 3028c2ecf20Sopenharmony_ci u8 *buf_start; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_ci /* 3058c2ecf20Sopenharmony_ci * Pointer to the start of the buffer. In the transmit 3068c2ecf20Sopenharmony_ci * direction this points to the start of the payload. In the 3078c2ecf20Sopenharmony_ci * receive direction, however, the buffer when queued up 3088c2ecf20Sopenharmony_ci * points to the start of the HTC header but when returned 3098c2ecf20Sopenharmony_ci * to the caller points to the start of the payload 3108c2ecf20Sopenharmony_ci */ 3118c2ecf20Sopenharmony_ci u8 *buf; 3128c2ecf20Sopenharmony_ci u32 buf_len; 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci /* actual length of payload */ 3158c2ecf20Sopenharmony_ci u32 act_len; 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci /* endpoint that this packet was sent/recv'd from */ 3188c2ecf20Sopenharmony_ci enum htc_endpoint_id endpoint; 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci /* completion status */ 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci int status; 3238c2ecf20Sopenharmony_ci union { 3248c2ecf20Sopenharmony_ci struct htc_tx_packet_info tx; 3258c2ecf20Sopenharmony_ci struct htc_rx_packet_info rx; 3268c2ecf20Sopenharmony_ci } info; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci void (*completion) (struct htc_target *, struct htc_packet *); 3298c2ecf20Sopenharmony_ci struct htc_target *context; 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci /* 3328c2ecf20Sopenharmony_ci * optimization for network-oriented data, the HTC packet 3338c2ecf20Sopenharmony_ci * can pass the network buffer corresponding to the HTC packet 3348c2ecf20Sopenharmony_ci * lower layers may optimized the transfer knowing this is 3358c2ecf20Sopenharmony_ci * a network buffer 3368c2ecf20Sopenharmony_ci */ 3378c2ecf20Sopenharmony_ci struct sk_buff *skb; 3388c2ecf20Sopenharmony_ci}; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_cienum htc_send_full_action { 3418c2ecf20Sopenharmony_ci HTC_SEND_FULL_KEEP = 0, 3428c2ecf20Sopenharmony_ci HTC_SEND_FULL_DROP = 1, 3438c2ecf20Sopenharmony_ci}; 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_cistruct htc_ep_callbacks { 3468c2ecf20Sopenharmony_ci void (*tx_complete) (struct htc_target *, struct htc_packet *); 3478c2ecf20Sopenharmony_ci void (*rx) (struct htc_target *, struct htc_packet *); 3488c2ecf20Sopenharmony_ci void (*rx_refill) (struct htc_target *, enum htc_endpoint_id endpoint); 3498c2ecf20Sopenharmony_ci enum htc_send_full_action (*tx_full) (struct htc_target *, 3508c2ecf20Sopenharmony_ci struct htc_packet *); 3518c2ecf20Sopenharmony_ci struct htc_packet *(*rx_allocthresh) (struct htc_target *, 3528c2ecf20Sopenharmony_ci enum htc_endpoint_id, int); 3538c2ecf20Sopenharmony_ci void (*tx_comp_multi) (struct htc_target *, struct list_head *); 3548c2ecf20Sopenharmony_ci int rx_alloc_thresh; 3558c2ecf20Sopenharmony_ci int rx_refill_thresh; 3568c2ecf20Sopenharmony_ci}; 3578c2ecf20Sopenharmony_ci 3588c2ecf20Sopenharmony_ci/* service connection information */ 3598c2ecf20Sopenharmony_cistruct htc_service_connect_req { 3608c2ecf20Sopenharmony_ci u16 svc_id; 3618c2ecf20Sopenharmony_ci u16 conn_flags; 3628c2ecf20Sopenharmony_ci struct htc_ep_callbacks ep_cb; 3638c2ecf20Sopenharmony_ci int max_txq_depth; 3648c2ecf20Sopenharmony_ci u32 flags; 3658c2ecf20Sopenharmony_ci unsigned int max_rxmsg_sz; 3668c2ecf20Sopenharmony_ci}; 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci/* service connection response information */ 3698c2ecf20Sopenharmony_cistruct htc_service_connect_resp { 3708c2ecf20Sopenharmony_ci u8 buf_len; 3718c2ecf20Sopenharmony_ci u8 act_len; 3728c2ecf20Sopenharmony_ci enum htc_endpoint_id endpoint; 3738c2ecf20Sopenharmony_ci unsigned int len_max; 3748c2ecf20Sopenharmony_ci u8 resp_code; 3758c2ecf20Sopenharmony_ci}; 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci/* endpoint distributionstructure */ 3788c2ecf20Sopenharmony_cistruct htc_endpoint_credit_dist { 3798c2ecf20Sopenharmony_ci struct list_head list; 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci /* Service ID (set by HTC) */ 3828c2ecf20Sopenharmony_ci u16 svc_id; 3838c2ecf20Sopenharmony_ci 3848c2ecf20Sopenharmony_ci /* endpoint for this distributionstruct (set by HTC) */ 3858c2ecf20Sopenharmony_ci enum htc_endpoint_id endpoint; 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ci u32 dist_flags; 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci /* 3908c2ecf20Sopenharmony_ci * credits for normal operation, anything above this 3918c2ecf20Sopenharmony_ci * indicates the endpoint is over-subscribed. 3928c2ecf20Sopenharmony_ci */ 3938c2ecf20Sopenharmony_ci int cred_norm; 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_ci /* floor for credit distribution */ 3968c2ecf20Sopenharmony_ci int cred_min; 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ci int cred_assngd; 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci /* current credits available */ 4018c2ecf20Sopenharmony_ci int credits; 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ci /* 4048c2ecf20Sopenharmony_ci * pending credits to distribute on this endpoint, this 4058c2ecf20Sopenharmony_ci * is set by HTC when credit reports arrive. The credit 4068c2ecf20Sopenharmony_ci * distribution functions sets this to zero when it distributes 4078c2ecf20Sopenharmony_ci * the credits. 4088c2ecf20Sopenharmony_ci */ 4098c2ecf20Sopenharmony_ci int cred_to_dist; 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci /* 4128c2ecf20Sopenharmony_ci * the number of credits that the current pending TX packet needs 4138c2ecf20Sopenharmony_ci * to transmit. This is set by HTC when endpoint needs credits in 4148c2ecf20Sopenharmony_ci * order to transmit. 4158c2ecf20Sopenharmony_ci */ 4168c2ecf20Sopenharmony_ci int seek_cred; 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci /* size in bytes of each credit */ 4198c2ecf20Sopenharmony_ci int cred_sz; 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci /* credits required for a maximum sized messages */ 4228c2ecf20Sopenharmony_ci int cred_per_msg; 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci /* reserved for HTC use */ 4258c2ecf20Sopenharmony_ci struct htc_endpoint *htc_ep; 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci /* 4288c2ecf20Sopenharmony_ci * current depth of TX queue , i.e. messages waiting for credits 4298c2ecf20Sopenharmony_ci * This field is valid only when HTC_CREDIT_DIST_ACTIVITY_CHANGE 4308c2ecf20Sopenharmony_ci * or HTC_CREDIT_DIST_SEND_COMPLETE is indicated on an endpoint 4318c2ecf20Sopenharmony_ci * that has non-zero credits to recover. 4328c2ecf20Sopenharmony_ci */ 4338c2ecf20Sopenharmony_ci int txq_depth; 4348c2ecf20Sopenharmony_ci}; 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_ci/* 4378c2ecf20Sopenharmony_ci * credit distribution code that is passed into the distribution function, 4388c2ecf20Sopenharmony_ci * there are mandatory and optional codes that must be handled 4398c2ecf20Sopenharmony_ci */ 4408c2ecf20Sopenharmony_cienum htc_credit_dist_reason { 4418c2ecf20Sopenharmony_ci HTC_CREDIT_DIST_SEND_COMPLETE = 0, 4428c2ecf20Sopenharmony_ci HTC_CREDIT_DIST_ACTIVITY_CHANGE = 1, 4438c2ecf20Sopenharmony_ci HTC_CREDIT_DIST_SEEK_CREDITS, 4448c2ecf20Sopenharmony_ci}; 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_cistruct ath6kl_htc_credit_info { 4478c2ecf20Sopenharmony_ci int total_avail_credits; 4488c2ecf20Sopenharmony_ci int cur_free_credits; 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_ci /* list of lowest priority endpoints */ 4518c2ecf20Sopenharmony_ci struct list_head lowestpri_ep_dist; 4528c2ecf20Sopenharmony_ci}; 4538c2ecf20Sopenharmony_ci 4548c2ecf20Sopenharmony_ci/* endpoint statistics */ 4558c2ecf20Sopenharmony_cistruct htc_endpoint_stats { 4568c2ecf20Sopenharmony_ci /* 4578c2ecf20Sopenharmony_ci * number of times the host set the credit-low flag in a send 4588c2ecf20Sopenharmony_ci * message on this endpoint 4598c2ecf20Sopenharmony_ci */ 4608c2ecf20Sopenharmony_ci u32 cred_low_indicate; 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_ci u32 tx_issued; 4638c2ecf20Sopenharmony_ci u32 tx_pkt_bundled; 4648c2ecf20Sopenharmony_ci u32 tx_bundles; 4658c2ecf20Sopenharmony_ci u32 tx_dropped; 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci /* running count of total credit reports received for this endpoint */ 4688c2ecf20Sopenharmony_ci u32 tx_cred_rpt; 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci /* credit reports received from this endpoint's RX packets */ 4718c2ecf20Sopenharmony_ci u32 cred_rpt_from_rx; 4728c2ecf20Sopenharmony_ci 4738c2ecf20Sopenharmony_ci /* credit reports received from RX packets of other endpoints */ 4748c2ecf20Sopenharmony_ci u32 cred_rpt_from_other; 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_ci /* credit reports received from endpoint 0 RX packets */ 4778c2ecf20Sopenharmony_ci u32 cred_rpt_ep0; 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci /* count of credits received via Rx packets on this endpoint */ 4808c2ecf20Sopenharmony_ci u32 cred_from_rx; 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_ci /* count of credits received via another endpoint */ 4838c2ecf20Sopenharmony_ci u32 cred_from_other; 4848c2ecf20Sopenharmony_ci 4858c2ecf20Sopenharmony_ci /* count of credits received via another endpoint */ 4868c2ecf20Sopenharmony_ci u32 cred_from_ep0; 4878c2ecf20Sopenharmony_ci 4888c2ecf20Sopenharmony_ci /* count of consummed credits */ 4898c2ecf20Sopenharmony_ci u32 cred_cosumd; 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci /* count of credits returned */ 4928c2ecf20Sopenharmony_ci u32 cred_retnd; 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ci u32 rx_pkts; 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci /* count of lookahead records found in Rx msg */ 4978c2ecf20Sopenharmony_ci u32 rx_lkahds; 4988c2ecf20Sopenharmony_ci 4998c2ecf20Sopenharmony_ci /* count of recv packets received in a bundle */ 5008c2ecf20Sopenharmony_ci u32 rx_bundl; 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci /* count of number of bundled lookaheads */ 5038c2ecf20Sopenharmony_ci u32 rx_bundle_lkahd; 5048c2ecf20Sopenharmony_ci 5058c2ecf20Sopenharmony_ci /* count of the number of bundle indications from the HTC header */ 5068c2ecf20Sopenharmony_ci u32 rx_bundle_from_hdr; 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_ci /* the number of times the recv allocation threshold was hit */ 5098c2ecf20Sopenharmony_ci u32 rx_alloc_thresh_hit; 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci /* total number of bytes */ 5128c2ecf20Sopenharmony_ci u32 rxalloc_thresh_byte; 5138c2ecf20Sopenharmony_ci}; 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_cistruct htc_endpoint { 5168c2ecf20Sopenharmony_ci enum htc_endpoint_id eid; 5178c2ecf20Sopenharmony_ci u16 svc_id; 5188c2ecf20Sopenharmony_ci struct list_head txq; 5198c2ecf20Sopenharmony_ci struct list_head rx_bufq; 5208c2ecf20Sopenharmony_ci struct htc_endpoint_credit_dist cred_dist; 5218c2ecf20Sopenharmony_ci struct htc_ep_callbacks ep_cb; 5228c2ecf20Sopenharmony_ci int max_txq_depth; 5238c2ecf20Sopenharmony_ci int len_max; 5248c2ecf20Sopenharmony_ci int tx_proc_cnt; 5258c2ecf20Sopenharmony_ci int rx_proc_cnt; 5268c2ecf20Sopenharmony_ci struct htc_target *target; 5278c2ecf20Sopenharmony_ci u8 seqno; 5288c2ecf20Sopenharmony_ci u32 conn_flags; 5298c2ecf20Sopenharmony_ci struct htc_endpoint_stats ep_st; 5308c2ecf20Sopenharmony_ci u16 tx_drop_packet_threshold; 5318c2ecf20Sopenharmony_ci 5328c2ecf20Sopenharmony_ci struct { 5338c2ecf20Sopenharmony_ci u8 pipeid_ul; 5348c2ecf20Sopenharmony_ci u8 pipeid_dl; 5358c2ecf20Sopenharmony_ci struct list_head tx_lookup_queue; 5368c2ecf20Sopenharmony_ci bool tx_credit_flow_enabled; 5378c2ecf20Sopenharmony_ci } pipe; 5388c2ecf20Sopenharmony_ci}; 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_cistruct htc_control_buffer { 5418c2ecf20Sopenharmony_ci struct htc_packet packet; 5428c2ecf20Sopenharmony_ci u8 *buf; 5438c2ecf20Sopenharmony_ci}; 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_cistruct htc_pipe_txcredit_alloc { 5468c2ecf20Sopenharmony_ci u16 service_id; 5478c2ecf20Sopenharmony_ci u8 credit_alloc; 5488c2ecf20Sopenharmony_ci}; 5498c2ecf20Sopenharmony_ci 5508c2ecf20Sopenharmony_cienum htc_send_queue_result { 5518c2ecf20Sopenharmony_ci HTC_SEND_QUEUE_OK = 0, /* packet was queued */ 5528c2ecf20Sopenharmony_ci HTC_SEND_QUEUE_DROP = 1, /* this packet should be dropped */ 5538c2ecf20Sopenharmony_ci}; 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_cistruct ath6kl_htc_ops { 5568c2ecf20Sopenharmony_ci void* (*create)(struct ath6kl *ar); 5578c2ecf20Sopenharmony_ci int (*wait_target)(struct htc_target *target); 5588c2ecf20Sopenharmony_ci int (*start)(struct htc_target *target); 5598c2ecf20Sopenharmony_ci int (*conn_service)(struct htc_target *target, 5608c2ecf20Sopenharmony_ci struct htc_service_connect_req *req, 5618c2ecf20Sopenharmony_ci struct htc_service_connect_resp *resp); 5628c2ecf20Sopenharmony_ci int (*tx)(struct htc_target *target, struct htc_packet *packet); 5638c2ecf20Sopenharmony_ci void (*stop)(struct htc_target *target); 5648c2ecf20Sopenharmony_ci void (*cleanup)(struct htc_target *target); 5658c2ecf20Sopenharmony_ci void (*flush_txep)(struct htc_target *target, 5668c2ecf20Sopenharmony_ci enum htc_endpoint_id endpoint, u16 tag); 5678c2ecf20Sopenharmony_ci void (*flush_rx_buf)(struct htc_target *target); 5688c2ecf20Sopenharmony_ci void (*activity_changed)(struct htc_target *target, 5698c2ecf20Sopenharmony_ci enum htc_endpoint_id endpoint, 5708c2ecf20Sopenharmony_ci bool active); 5718c2ecf20Sopenharmony_ci int (*get_rxbuf_num)(struct htc_target *target, 5728c2ecf20Sopenharmony_ci enum htc_endpoint_id endpoint); 5738c2ecf20Sopenharmony_ci int (*add_rxbuf_multiple)(struct htc_target *target, 5748c2ecf20Sopenharmony_ci struct list_head *pktq); 5758c2ecf20Sopenharmony_ci int (*credit_setup)(struct htc_target *target, 5768c2ecf20Sopenharmony_ci struct ath6kl_htc_credit_info *cred_info); 5778c2ecf20Sopenharmony_ci int (*tx_complete)(struct ath6kl *ar, struct sk_buff *skb); 5788c2ecf20Sopenharmony_ci int (*rx_complete)(struct ath6kl *ar, struct sk_buff *skb, u8 pipe); 5798c2ecf20Sopenharmony_ci}; 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_cistruct ath6kl_device; 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ci/* our HTC target state */ 5848c2ecf20Sopenharmony_cistruct htc_target { 5858c2ecf20Sopenharmony_ci struct htc_endpoint endpoint[ENDPOINT_MAX]; 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_ci /* contains struct htc_endpoint_credit_dist */ 5888c2ecf20Sopenharmony_ci struct list_head cred_dist_list; 5898c2ecf20Sopenharmony_ci 5908c2ecf20Sopenharmony_ci struct list_head free_ctrl_txbuf; 5918c2ecf20Sopenharmony_ci struct list_head free_ctrl_rxbuf; 5928c2ecf20Sopenharmony_ci struct ath6kl_htc_credit_info *credit_info; 5938c2ecf20Sopenharmony_ci int tgt_creds; 5948c2ecf20Sopenharmony_ci unsigned int tgt_cred_sz; 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci /* protects free_ctrl_txbuf and free_ctrl_rxbuf */ 5978c2ecf20Sopenharmony_ci spinlock_t htc_lock; 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_ci /* FIXME: does this protext rx_bufq and endpoint structures or what? */ 6008c2ecf20Sopenharmony_ci spinlock_t rx_lock; 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci /* protects endpoint->txq */ 6038c2ecf20Sopenharmony_ci spinlock_t tx_lock; 6048c2ecf20Sopenharmony_ci 6058c2ecf20Sopenharmony_ci struct ath6kl_device *dev; 6068c2ecf20Sopenharmony_ci u32 htc_flags; 6078c2ecf20Sopenharmony_ci u32 rx_st_flags; 6088c2ecf20Sopenharmony_ci enum htc_endpoint_id ep_waiting; 6098c2ecf20Sopenharmony_ci u8 htc_tgt_ver; 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci /* max messages per bundle for HTC */ 6128c2ecf20Sopenharmony_ci int msg_per_bndl_max; 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_ci u32 tx_bndl_mask; 6158c2ecf20Sopenharmony_ci int rx_bndl_enable; 6168c2ecf20Sopenharmony_ci int max_rx_bndl_sz; 6178c2ecf20Sopenharmony_ci int max_tx_bndl_sz; 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_ci u32 block_sz; 6208c2ecf20Sopenharmony_ci u32 block_mask; 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_ci int max_scat_entries; 6238c2ecf20Sopenharmony_ci int max_xfer_szper_scatreq; 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_ci int chk_irq_status_cnt; 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_ci /* counts the number of Tx without bundling continously per AC */ 6288c2ecf20Sopenharmony_ci u32 ac_tx_count[WMM_NUM_AC]; 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_ci struct { 6318c2ecf20Sopenharmony_ci struct htc_packet *htc_packet_pool; 6328c2ecf20Sopenharmony_ci u8 ctrl_response_buf[HTC_MAX_CTRL_MSG_LEN]; 6338c2ecf20Sopenharmony_ci int ctrl_response_len; 6348c2ecf20Sopenharmony_ci bool ctrl_response_valid; 6358c2ecf20Sopenharmony_ci struct htc_pipe_txcredit_alloc txcredit_alloc[ENDPOINT_MAX]; 6368c2ecf20Sopenharmony_ci } pipe; 6378c2ecf20Sopenharmony_ci}; 6388c2ecf20Sopenharmony_ci 6398c2ecf20Sopenharmony_ciint ath6kl_htc_rxmsg_pending_handler(struct htc_target *target, 6408c2ecf20Sopenharmony_ci u32 msg_look_ahead, int *n_pkts); 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_cistatic inline void set_htc_pkt_info(struct htc_packet *packet, void *context, 6438c2ecf20Sopenharmony_ci u8 *buf, unsigned int len, 6448c2ecf20Sopenharmony_ci enum htc_endpoint_id eid, u16 tag) 6458c2ecf20Sopenharmony_ci{ 6468c2ecf20Sopenharmony_ci packet->pkt_cntxt = context; 6478c2ecf20Sopenharmony_ci packet->buf = buf; 6488c2ecf20Sopenharmony_ci packet->act_len = len; 6498c2ecf20Sopenharmony_ci packet->endpoint = eid; 6508c2ecf20Sopenharmony_ci packet->info.tx.tag = tag; 6518c2ecf20Sopenharmony_ci} 6528c2ecf20Sopenharmony_ci 6538c2ecf20Sopenharmony_cistatic inline void htc_rxpkt_reset(struct htc_packet *packet) 6548c2ecf20Sopenharmony_ci{ 6558c2ecf20Sopenharmony_ci packet->buf = packet->buf_start; 6568c2ecf20Sopenharmony_ci packet->act_len = 0; 6578c2ecf20Sopenharmony_ci} 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_cistatic inline void set_htc_rxpkt_info(struct htc_packet *packet, void *context, 6608c2ecf20Sopenharmony_ci u8 *buf, unsigned long len, 6618c2ecf20Sopenharmony_ci enum htc_endpoint_id eid) 6628c2ecf20Sopenharmony_ci{ 6638c2ecf20Sopenharmony_ci packet->pkt_cntxt = context; 6648c2ecf20Sopenharmony_ci packet->buf = buf; 6658c2ecf20Sopenharmony_ci packet->buf_start = buf; 6668c2ecf20Sopenharmony_ci packet->buf_len = len; 6678c2ecf20Sopenharmony_ci packet->endpoint = eid; 6688c2ecf20Sopenharmony_ci} 6698c2ecf20Sopenharmony_ci 6708c2ecf20Sopenharmony_cistatic inline int get_queue_depth(struct list_head *queue) 6718c2ecf20Sopenharmony_ci{ 6728c2ecf20Sopenharmony_ci struct list_head *tmp_list; 6738c2ecf20Sopenharmony_ci int depth = 0; 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ci list_for_each(tmp_list, queue) 6768c2ecf20Sopenharmony_ci depth++; 6778c2ecf20Sopenharmony_ci 6788c2ecf20Sopenharmony_ci return depth; 6798c2ecf20Sopenharmony_ci} 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_civoid ath6kl_htc_pipe_attach(struct ath6kl *ar); 6828c2ecf20Sopenharmony_civoid ath6kl_htc_mbox_attach(struct ath6kl *ar); 6838c2ecf20Sopenharmony_ci 6848c2ecf20Sopenharmony_ci#endif 685