2 * Copyright (c) 2010 Atheros Communications Inc.
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.
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.
20 struct ath9k_htc_priv
;
22 struct ath9k_htc_tx_ctl
;
24 enum ath9k_hif_transports
{
28 struct ath9k_htc_hif
{
29 struct list_head list
;
30 const enum ath9k_hif_transports transport
;
36 void (*start
) (void *hif_handle
, u8 pipe
);
37 void (*stop
) (void *hif_handle
, u8 pipe
);
38 int (*send
) (void *hif_handle
, u8 pipe
, struct sk_buff
*buf
,
39 struct ath9k_htc_tx_ctl
*tx_ctl
);
42 enum htc_endpoint_id
{
56 /* Htc frame hdr flags */
57 #define HTC_FLAGS_RECV_TRAILER (1 << 1)
59 struct htc_frame_hdr
{
66 struct htc_ready_msg
{
74 struct htc_config_pipe_msg
{
94 struct htc_ep_callbacks
{
96 void (*tx
) (void *, struct sk_buff
*, enum htc_endpoint_id
, bool txok
);
97 void (*rx
) (void *, struct sk_buff
*, enum htc_endpoint_id
);
100 #define HTC_TX_QUEUE_SIZE 256
103 struct sk_buff
*buf
[HTC_TX_QUEUE_SIZE
];
110 struct htc_endpoint
{
113 struct htc_ep_callbacks ep_callbacks
;
114 struct htc_txq htc_txq
;
122 #define HTC_MAX_CONTROL_MESSAGE_LENGTH 255
123 #define HTC_CONTROL_BUFFER_SIZE \
124 (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr))
126 #define NUM_CONTROL_BUFFERS 8
127 #define HST_ENDPOINT_MAX 8
129 struct htc_control_buf
{
130 struct htc_packet htc_pkt
;
131 u8 buf
[HTC_CONTROL_BUFFER_SIZE
];
134 #define HTC_OP_START_WAIT BIT(0)
135 #define HTC_OP_CONFIG_PIPE_CREDITS BIT(1)
139 struct ath9k_htc_priv
*drv_priv
;
141 struct ath9k_htc_hif
*hif
;
142 struct htc_endpoint endpoint
[HST_ENDPOINT_MAX
];
143 struct completion target_wait
;
144 struct completion cmd_wait
;
145 struct list_head list
;
146 enum htc_endpoint_id conn_rsp_epid
;
154 HTC_MSG_READY_ID
= 1,
155 HTC_MSG_CONNECT_SERVICE_ID
,
156 HTC_MSG_CONNECT_SERVICE_RESPONSE_ID
,
157 HTC_MSG_SETUP_COMPLETE_ID
,
158 HTC_MSG_CONFIG_PIPE_ID
,
159 HTC_MSG_CONFIG_PIPE_RESPONSE_ID
,
162 struct htc_service_connreq
{
166 struct htc_ep_callbacks ep_callbacks
;
169 /* Current service IDs */
171 enum htc_service_group_ids
{
172 RSVD_SERVICE_GROUP
= 0,
173 WMI_SERVICE_GROUP
= 1,
175 HTC_SERVICE_GROUP_LAST
= 255
178 #define MAKE_SERVICE_ID(group, index) \
179 (int)(((int)group << 8) | (int)(index))
181 /* NOTE: service ID of 0x0000 is reserved and should never be used */
182 #define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 1)
183 #define HTC_LOOPBACK_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 2)
185 #define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 0)
186 #define WMI_BEACON_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 1)
187 #define WMI_CAB_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 2)
188 #define WMI_UAPSD_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 3)
189 #define WMI_MGMT_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4)
190 #define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 5)
191 #define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 6)
192 #define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 7)
193 #define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 8)
195 struct htc_conn_svc_msg
{
205 /* connect response status codes */
206 #define HTC_SERVICE_SUCCESS 0
207 #define HTC_SERVICE_NOT_FOUND 1
208 #define HTC_SERVICE_FAILED 2
209 #define HTC_SERVICE_NO_RESOURCES 3
210 #define HTC_SERVICE_NO_MORE_EP 4
212 struct htc_conn_svc_rspmsg
{
222 struct htc_comp_msg
{
226 int htc_init(struct htc_target
*target
);
227 int htc_connect_service(struct htc_target
*target
,
228 struct htc_service_connreq
*service_connreq
,
229 enum htc_endpoint_id
*conn_rsp_eid
);
230 int htc_send(struct htc_target
*target
, struct sk_buff
*skb
,
231 enum htc_endpoint_id eid
, struct ath9k_htc_tx_ctl
*tx_ctl
);
232 void htc_stop(struct htc_target
*target
);
233 void htc_start(struct htc_target
*target
);
235 void ath9k_htc_rx_msg(struct htc_target
*htc_handle
,
236 struct sk_buff
*skb
, u32 len
, u8 pipe_id
);
237 void ath9k_htc_txcompletion_cb(struct htc_target
*htc_handle
,
238 struct sk_buff
*skb
, bool txok
);
240 struct htc_target
*ath9k_htc_hw_alloc(void *hif_handle
,
241 struct ath9k_htc_hif
*hif
,
243 void ath9k_htc_hw_free(struct htc_target
*htc
);
244 int ath9k_htc_hw_init(struct htc_target
*target
,
245 struct device
*dev
, u16 devid
);
246 void ath9k_htc_hw_deinit(struct htc_target
*target
, bool hot_unplug
);
248 #endif /* HTC_HST_H */