Loading...
1/*
2 * Copyright (c) 2010-2011 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
20struct ath9k_htc_priv;
21struct htc_target;
22struct ath9k_htc_tx_ctl;
23
24enum ath9k_hif_transports {
25 ATH9K_HIF_USB,
26};
27
28struct 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);
37 void (*stop) (void *hif_handle);
38 void (*sta_drain) (void *hif_handle, u8 idx);
39 int (*send) (void *hif_handle, u8 pipe, struct sk_buff *buf);
40};
41
42enum 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
59struct htc_frame_hdr {
60 u8 endpoint_id;
61 u8 flags;
62 __be16 payload_len;
63 u8 control[4];
64} __packed;
65
66struct htc_ready_msg {
67 __be16 message_id;
68 __be16 credits;
69 __be16 credit_size;
70 u8 max_endpoints;
71 u8 pad;
72} __packed;
73
74struct htc_config_pipe_msg {
75 __be16 message_id;
76 u8 pipe_id;
77 u8 credits;
78} __packed;
79
80struct htc_ep_callbacks {
81 void *priv;
82 void (*tx) (void *, struct sk_buff *, enum htc_endpoint_id, bool txok);
83 void (*rx) (void *, struct sk_buff *, enum htc_endpoint_id);
84};
85
86struct htc_endpoint {
87 u16 service_id;
88
89 struct htc_ep_callbacks ep_callbacks;
90 u32 max_txqdepth;
91 int max_msglen;
92
93 u8 ul_pipeid;
94 u8 dl_pipeid;
95};
96
97#define HTC_MAX_CONTROL_MESSAGE_LENGTH 255
98#define HTC_CONTROL_BUFFER_SIZE \
99 (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr))
100
101#define HTC_OP_START_WAIT BIT(0)
102#define HTC_OP_CONFIG_PIPE_CREDITS BIT(1)
103
104struct htc_target {
105 void *hif_dev;
106 struct ath9k_htc_priv *drv_priv;
107 struct device *dev;
108 struct ath9k_htc_hif *hif;
109 struct htc_endpoint endpoint[ENDPOINT_MAX];
110 struct completion target_wait;
111 struct completion cmd_wait;
112 struct list_head list;
113 enum htc_endpoint_id conn_rsp_epid;
114 u16 credits;
115 u16 credit_size;
116 u8 htc_flags;
117 atomic_t tgt_ready;
118};
119
120enum htc_msg_id {
121 HTC_MSG_READY_ID = 1,
122 HTC_MSG_CONNECT_SERVICE_ID,
123 HTC_MSG_CONNECT_SERVICE_RESPONSE_ID,
124 HTC_MSG_SETUP_COMPLETE_ID,
125 HTC_MSG_CONFIG_PIPE_ID,
126 HTC_MSG_CONFIG_PIPE_RESPONSE_ID,
127};
128
129struct htc_service_connreq {
130 u16 service_id;
131 u16 con_flags;
132 u32 max_send_qdepth;
133 struct htc_ep_callbacks ep_callbacks;
134};
135
136/* Current service IDs */
137
138enum htc_service_group_ids{
139 RSVD_SERVICE_GROUP = 0,
140 WMI_SERVICE_GROUP = 1,
141
142 HTC_SERVICE_GROUP_LAST = 255
143};
144
145#define MAKE_SERVICE_ID(group, index) \
146 (int)(((int)group << 8) | (int)(index))
147
148/* NOTE: service ID of 0x0000 is reserved and should never be used */
149#define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 1)
150#define HTC_LOOPBACK_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 2)
151
152#define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 0)
153#define WMI_BEACON_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 1)
154#define WMI_CAB_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 2)
155#define WMI_UAPSD_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 3)
156#define WMI_MGMT_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4)
157#define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 5)
158#define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 6)
159#define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 7)
160#define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 8)
161
162struct htc_conn_svc_msg {
163 __be16 msg_id;
164 __be16 service_id;
165 __be16 con_flags;
166 u8 dl_pipeid;
167 u8 ul_pipeid;
168 u8 svc_meta_len;
169 u8 pad;
170} __packed;
171
172/* connect response status codes */
173#define HTC_SERVICE_SUCCESS 0
174#define HTC_SERVICE_NOT_FOUND 1
175#define HTC_SERVICE_FAILED 2
176#define HTC_SERVICE_NO_RESOURCES 3
177#define HTC_SERVICE_NO_MORE_EP 4
178
179struct htc_conn_svc_rspmsg {
180 __be16 msg_id;
181 __be16 service_id;
182 u8 status;
183 u8 endpoint_id;
184 __be16 max_msg_len;
185 u8 svc_meta_len;
186 u8 pad;
187} __packed;
188
189struct htc_comp_msg {
190 __be16 msg_id;
191} __packed;
192
193int htc_init(struct htc_target *target);
194int htc_connect_service(struct htc_target *target,
195 struct htc_service_connreq *service_connreq,
196 enum htc_endpoint_id *conn_rsp_eid);
197int htc_send(struct htc_target *target, struct sk_buff *skb);
198int htc_send_epid(struct htc_target *target, struct sk_buff *skb,
199 enum htc_endpoint_id epid);
200void htc_stop(struct htc_target *target);
201void htc_start(struct htc_target *target);
202void htc_sta_drain(struct htc_target *target, u8 idx);
203
204void ath9k_htc_rx_msg(struct htc_target *htc_handle,
205 struct sk_buff *skb, u32 len, u8 pipe_id);
206void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
207 struct sk_buff *skb, bool txok);
208
209struct htc_target *ath9k_htc_hw_alloc(void *hif_handle,
210 struct ath9k_htc_hif *hif,
211 struct device *dev);
212void ath9k_htc_hw_free(struct htc_target *htc);
213int ath9k_htc_hw_init(struct htc_target *target,
214 struct device *dev, u16 devid, char *product,
215 u32 drv_info);
216void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug);
217
218#endif /* HTC_HST_H */
1/*
2 * Copyright (c) 2010-2011 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
20struct ath9k_htc_priv;
21struct htc_target;
22struct ath9k_htc_tx_ctl;
23
24enum ath9k_hif_transports {
25 ATH9K_HIF_USB,
26};
27
28struct 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);
37 void (*stop) (void *hif_handle);
38 void (*sta_drain) (void *hif_handle, u8 idx);
39 int (*send) (void *hif_handle, u8 pipe, struct sk_buff *buf);
40};
41
42enum 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
59struct htc_frame_hdr {
60 u8 endpoint_id;
61 u8 flags;
62 __be16 payload_len;
63 u8 control[4];
64} __packed;
65
66struct htc_ready_msg {
67 __be16 message_id;
68 __be16 credits;
69 __be16 credit_size;
70 u8 max_endpoints;
71 u8 pad;
72} __packed;
73
74struct htc_config_pipe_msg {
75 __be16 message_id;
76 u8 pipe_id;
77 u8 credits;
78} __packed;
79
80struct htc_panic_bad_vaddr {
81 __be32 pattern;
82 __be32 exccause;
83 __be32 pc;
84 __be32 badvaddr;
85} __packed;
86
87struct htc_panic_bad_epid {
88 __be32 pattern;
89 __be32 epid;
90} __packed;
91
92struct htc_ep_callbacks {
93 void *priv;
94 void (*tx) (void *, struct sk_buff *, enum htc_endpoint_id, bool txok);
95 void (*rx) (void *, struct sk_buff *, enum htc_endpoint_id);
96};
97
98struct htc_endpoint {
99 u16 service_id;
100
101 struct htc_ep_callbacks ep_callbacks;
102 u32 max_txqdepth;
103 int max_msglen;
104
105 u8 ul_pipeid;
106 u8 dl_pipeid;
107};
108
109#define HTC_MAX_CONTROL_MESSAGE_LENGTH 255
110#define HTC_CONTROL_BUFFER_SIZE \
111 (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr))
112
113#define HTC_OP_START_WAIT BIT(0)
114#define HTC_OP_CONFIG_PIPE_CREDITS BIT(1)
115
116struct htc_target {
117 void *hif_dev;
118 struct ath9k_htc_priv *drv_priv;
119 struct device *dev;
120 struct ath9k_htc_hif *hif;
121 struct htc_endpoint endpoint[ENDPOINT_MAX];
122 struct completion target_wait;
123 struct completion cmd_wait;
124 struct list_head list;
125 enum htc_endpoint_id conn_rsp_epid;
126 u16 credits;
127 u16 credit_size;
128 u8 htc_flags;
129 atomic_t tgt_ready;
130};
131
132enum htc_msg_id {
133 HTC_MSG_READY_ID = 1,
134 HTC_MSG_CONNECT_SERVICE_ID,
135 HTC_MSG_CONNECT_SERVICE_RESPONSE_ID,
136 HTC_MSG_SETUP_COMPLETE_ID,
137 HTC_MSG_CONFIG_PIPE_ID,
138 HTC_MSG_CONFIG_PIPE_RESPONSE_ID,
139};
140
141struct htc_service_connreq {
142 u16 service_id;
143 u16 con_flags;
144 u32 max_send_qdepth;
145 struct htc_ep_callbacks ep_callbacks;
146};
147
148/* Current service IDs */
149
150enum htc_service_group_ids{
151 RSVD_SERVICE_GROUP = 0,
152 WMI_SERVICE_GROUP = 1,
153
154 HTC_SERVICE_GROUP_LAST = 255
155};
156
157#define MAKE_SERVICE_ID(group, index) \
158 (int)(((int)group << 8) | (int)(index))
159
160/* NOTE: service ID of 0x0000 is reserved and should never be used */
161#define HTC_CTRL_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 1)
162#define HTC_LOOPBACK_RSVD_SVC MAKE_SERVICE_ID(RSVD_SERVICE_GROUP, 2)
163
164#define WMI_CONTROL_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 0)
165#define WMI_BEACON_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 1)
166#define WMI_CAB_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 2)
167#define WMI_UAPSD_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 3)
168#define WMI_MGMT_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 4)
169#define WMI_DATA_VO_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 5)
170#define WMI_DATA_VI_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 6)
171#define WMI_DATA_BE_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 7)
172#define WMI_DATA_BK_SVC MAKE_SERVICE_ID(WMI_SERVICE_GROUP, 8)
173
174struct htc_conn_svc_msg {
175 __be16 msg_id;
176 __be16 service_id;
177 __be16 con_flags;
178 u8 dl_pipeid;
179 u8 ul_pipeid;
180 u8 svc_meta_len;
181 u8 pad;
182} __packed;
183
184/* connect response status codes */
185#define HTC_SERVICE_SUCCESS 0
186#define HTC_SERVICE_NOT_FOUND 1
187#define HTC_SERVICE_FAILED 2
188#define HTC_SERVICE_NO_RESOURCES 3
189#define HTC_SERVICE_NO_MORE_EP 4
190
191struct htc_conn_svc_rspmsg {
192 __be16 msg_id;
193 __be16 service_id;
194 u8 status;
195 u8 endpoint_id;
196 __be16 max_msg_len;
197 u8 svc_meta_len;
198 u8 pad;
199} __packed;
200
201struct htc_comp_msg {
202 __be16 msg_id;
203} __packed;
204
205int htc_init(struct htc_target *target);
206int htc_connect_service(struct htc_target *target,
207 struct htc_service_connreq *service_connreq,
208 enum htc_endpoint_id *conn_rsp_eid);
209int htc_send(struct htc_target *target, struct sk_buff *skb);
210int htc_send_epid(struct htc_target *target, struct sk_buff *skb,
211 enum htc_endpoint_id epid);
212void htc_stop(struct htc_target *target);
213void htc_start(struct htc_target *target);
214void htc_sta_drain(struct htc_target *target, u8 idx);
215
216void ath9k_htc_rx_msg(struct htc_target *htc_handle,
217 struct sk_buff *skb, u32 len, u8 pipe_id);
218void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
219 struct sk_buff *skb, bool txok);
220
221struct htc_target *ath9k_htc_hw_alloc(void *hif_handle,
222 struct ath9k_htc_hif *hif,
223 struct device *dev);
224void ath9k_htc_hw_free(struct htc_target *htc);
225int ath9k_htc_hw_init(struct htc_target *target,
226 struct device *dev, u16 devid, char *product,
227 u32 drv_info);
228void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug);
229
230#endif /* HTC_HST_H */