diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/htc_hst.h')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/htc_hst.h | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.h b/drivers/net/wireless/ath/ath9k/htc_hst.h new file mode 100644 index 00000000000..cd7048ffd23 --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/htc_hst.h | |||
@@ -0,0 +1,246 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2010 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 | |||
17 | #ifndef HTC_HST_H | ||
18 | #define HTC_HST_H | ||
19 | |||
20 | struct ath9k_htc_priv; | ||
21 | struct htc_target; | ||
22 | struct ath9k_htc_tx_ctl; | ||
23 | |||
24 | enum ath9k_hif_transports { | ||
25 | ATH9K_HIF_USB, | ||
26 | }; | ||
27 | |||
28 | struct ath9k_htc_hif { | ||
29 | struct list_head list; | ||
30 | const enum ath9k_hif_transports transport; | ||
31 | const char *name; | ||
32 | |||
33 | u8 control_dl_pipe; | ||
34 | u8 control_ul_pipe; | ||
35 | |||
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); | ||
40 | }; | ||
41 | |||
42 | enum htc_endpoint_id { | ||
43 | ENDPOINT_UNUSED = -1, | ||
44 | ENDPOINT0 = 0, | ||
45 | ENDPOINT1 = 1, | ||
46 | ENDPOINT2 = 2, | ||
47 | ENDPOINT3 = 3, | ||
48 | ENDPOINT4 = 4, | ||
49 | ENDPOINT5 = 5, | ||
50 | ENDPOINT6 = 6, | ||
51 | ENDPOINT7 = 7, | ||
52 | ENDPOINT8 = 8, | ||
53 | ENDPOINT_MAX = 22 | ||
54 | }; | ||
55 | |||
56 | /* Htc frame hdr flags */ | ||
57 | #define HTC_FLAGS_RECV_TRAILER (1 << 1) | ||
58 | |||
59 | struct htc_frame_hdr { | ||
60 | u8 endpoint_id; | ||
61 | u8 flags; | ||
62 | u16 payload_len; | ||
63 | u8 control[4]; | ||
64 | } __packed; | ||
65 | |||
66 | struct htc_ready_msg { | ||
67 | u16 message_id; | ||
68 | u16 credits; | ||
69 | u16 credit_size; | ||
70 | u8 max_endpoints; | ||
71 | u8 pad; | ||
72 | } __packed; | ||
73 | |||
74 | struct htc_config_pipe_msg { | ||
75 | u16 message_id; | ||
76 | u8 pipe_id; | ||
77 | u8 credits; | ||
78 | } __packed; | ||
79 | |||
80 | struct htc_packet { | ||
81 | void *pktcontext; | ||
82 | u8 *buf; | ||
83 | u8 *buf_payload; | ||
84 | u32 buflen; | ||
85 | u32 payload_len; | ||
86 | |||
87 | int endpoint; | ||
88 | int status; | ||
89 | |||
90 | void *context; | ||
91 | u32 reserved; | ||
92 | }; | ||
93 | |||
94 | struct htc_ep_callbacks { | ||
95 | void *priv; | ||
96 | void (*tx) (void *, struct sk_buff *, enum htc_endpoint_id, bool txok); | ||
97 | void (*rx) (void *, struct sk_buff *, enum htc_endpoint_id); | ||
98 | }; | ||
99 | |||
100 | #define HTC_TX_QUEUE_SIZE 256 | ||
101 | |||
102 | struct htc_txq { | ||
103 | struct sk_buff *buf[HTC_TX_QUEUE_SIZE]; | ||
104 | u32 txqdepth; | ||
105 | u16 txbuf_cnt; | ||
106 | u16 txq_head; | ||
107 | u16 txq_tail; | ||
108 | }; | ||
109 | |||
110 | struct htc_endpoint { | ||
111 | u16 service_id; | ||
112 | |||
113 | struct htc_ep_callbacks ep_callbacks; | ||
114 | struct htc_txq htc_txq; | ||
115 | u32 max_txqdepth; | ||
116 | int max_msglen; | ||
117 | |||
118 | u8 ul_pipeid; | ||
119 | u8 dl_pipeid; | ||
120 | }; | ||
121 | |||
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)) | ||
125 | |||
126 | #define NUM_CONTROL_BUFFERS 8 | ||
127 | #define HST_ENDPOINT_MAX 8 | ||
128 | |||
129 | struct htc_control_buf { | ||
130 | struct htc_packet htc_pkt; | ||
131 | u8 buf[HTC_CONTROL_BUFFER_SIZE]; | ||
132 | }; | ||
133 | |||
134 | #define HTC_OP_START_WAIT BIT(0) | ||
135 | #define HTC_OP_CONFIG_PIPE_CREDITS BIT(1) | ||
136 | |||
137 | struct htc_target { | ||
138 | void *hif_dev; | ||
139 | struct ath9k_htc_priv *drv_priv; | ||
140 | struct device *dev; | ||
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; | ||
147 | u16 credits; | ||
148 | u16 credit_size; | ||
149 | u8 htc_flags; | ||
150 | }; | ||
151 | |||
152 | enum htc_msg_id { | ||
153 | HTC_MSG_READY_ID = 1, | ||
154 | HTC_MSG_CONNECT_SERVICE_ID, | ||
155 | HTC_MSG_CONNECT_SERVICE_RESPONSE_ID, | ||
156 | HTC_MSG_SETUP_COMPLETE_ID, | ||
157 | HTC_MSG_CONFIG_PIPE_ID, | ||
158 | HTC_MSG_CONFIG_PIPE_RESPONSE_ID, | ||
159 | }; | ||
160 | |||
161 | struct htc_service_connreq { | ||
162 | u16 service_id; | ||
163 | u16 con_flags; | ||
164 | u32 max_send_qdepth; | ||
165 | struct htc_ep_callbacks ep_callbacks; | ||
166 | }; | ||
167 | |||
168 | /* Current service IDs */ | ||
169 | |||
170 | enum htc_service_group_ids{ | ||
171 | RSVD_SERVICE_GROUP = 0, | ||
172 | WMI_SERVICE_GROUP = 1, | ||
173 | |||
174 | HTC_SERVICE_GROUP_LAST = 255 | ||
175 | }; | ||
176 | |||
177 | #define MAKE_SERVICE_ID(group, index) \ | ||
178 | (int)(((int)group << 8) | (int)(index)) | ||
179 | |||
180 | /* NOTE: service ID of 0x0000 is reserved and should never be used */ | ||
181 | #define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 1) | ||
182 | #define HTC_LOOPBACK_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 2) | ||
183 | |||
184 | #define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 0) | ||
185 | #define WMI_BEACON_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 1) | ||
186 | #define WMI_CAB_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 2) | ||
187 | #define WMI_UAPSD_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 3) | ||
188 | #define WMI_MGMT_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4) | ||
189 | #define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 5) | ||
190 | #define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 6) | ||
191 | #define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 7) | ||
192 | #define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 8) | ||
193 | |||
194 | struct htc_conn_svc_msg { | ||
195 | u16 msg_id; | ||
196 | u16 service_id; | ||
197 | u16 con_flags; | ||
198 | u8 dl_pipeid; | ||
199 | u8 ul_pipeid; | ||
200 | u8 svc_meta_len; | ||
201 | u8 pad; | ||
202 | } __packed; | ||
203 | |||
204 | /* connect response status codes */ | ||
205 | #define HTC_SERVICE_SUCCESS 0 | ||
206 | #define HTC_SERVICE_NOT_FOUND 1 | ||
207 | #define HTC_SERVICE_FAILED 2 | ||
208 | #define HTC_SERVICE_NO_RESOURCES 3 | ||
209 | #define HTC_SERVICE_NO_MORE_EP 4 | ||
210 | |||
211 | struct htc_conn_svc_rspmsg { | ||
212 | u16 msg_id; | ||
213 | u16 service_id; | ||
214 | u8 status; | ||
215 | u8 endpoint_id; | ||
216 | u16 max_msg_len; | ||
217 | u8 svc_meta_len; | ||
218 | u8 pad; | ||
219 | } __packed; | ||
220 | |||
221 | struct htc_comp_msg { | ||
222 | u16 msg_id; | ||
223 | } __packed; | ||
224 | |||
225 | int htc_init(struct htc_target *target); | ||
226 | int htc_connect_service(struct htc_target *target, | ||
227 | struct htc_service_connreq *service_connreq, | ||
228 | enum htc_endpoint_id *conn_rsp_eid); | ||
229 | int htc_send(struct htc_target *target, struct sk_buff *skb, | ||
230 | enum htc_endpoint_id eid, struct ath9k_htc_tx_ctl *tx_ctl); | ||
231 | void htc_stop(struct htc_target *target); | ||
232 | void htc_start(struct htc_target *target); | ||
233 | |||
234 | void ath9k_htc_rx_msg(struct htc_target *htc_handle, | ||
235 | struct sk_buff *skb, u32 len, u8 pipe_id); | ||
236 | void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle, | ||
237 | struct sk_buff *skb, bool txok); | ||
238 | |||
239 | struct htc_target *ath9k_htc_hw_alloc(void *hif_handle); | ||
240 | void ath9k_htc_hw_free(struct htc_target *htc); | ||
241 | int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target, | ||
242 | void *hif_handle, struct device *dev, u16 devid, | ||
243 | enum ath9k_hif_transports transport); | ||
244 | void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug); | ||
245 | |||
246 | #endif /* HTC_HST_H */ | ||