Branch data Line data Source code
1 : : // SPDX-License-Identifier: ISC
2 : : /*
3 : : * Copyright (c) 2005-2011 Atheros Communications Inc.
4 : : * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5 : : */
6 : :
7 : : #include <linux/slab.h>
8 : : #include <linux/if_ether.h>
9 : :
10 : : #include "htt.h"
11 : : #include "core.h"
12 : : #include "debug.h"
13 : :
14 : : static const enum htt_t2h_msg_type htt_main_t2h_msg_types[] = {
15 : : [HTT_MAIN_T2H_MSG_TYPE_VERSION_CONF] = HTT_T2H_MSG_TYPE_VERSION_CONF,
16 : : [HTT_MAIN_T2H_MSG_TYPE_RX_IND] = HTT_T2H_MSG_TYPE_RX_IND,
17 : : [HTT_MAIN_T2H_MSG_TYPE_RX_FLUSH] = HTT_T2H_MSG_TYPE_RX_FLUSH,
18 : : [HTT_MAIN_T2H_MSG_TYPE_PEER_MAP] = HTT_T2H_MSG_TYPE_PEER_MAP,
19 : : [HTT_MAIN_T2H_MSG_TYPE_PEER_UNMAP] = HTT_T2H_MSG_TYPE_PEER_UNMAP,
20 : : [HTT_MAIN_T2H_MSG_TYPE_RX_ADDBA] = HTT_T2H_MSG_TYPE_RX_ADDBA,
21 : : [HTT_MAIN_T2H_MSG_TYPE_RX_DELBA] = HTT_T2H_MSG_TYPE_RX_DELBA,
22 : : [HTT_MAIN_T2H_MSG_TYPE_TX_COMPL_IND] = HTT_T2H_MSG_TYPE_TX_COMPL_IND,
23 : : [HTT_MAIN_T2H_MSG_TYPE_PKTLOG] = HTT_T2H_MSG_TYPE_PKTLOG,
24 : : [HTT_MAIN_T2H_MSG_TYPE_STATS_CONF] = HTT_T2H_MSG_TYPE_STATS_CONF,
25 : : [HTT_MAIN_T2H_MSG_TYPE_RX_FRAG_IND] = HTT_T2H_MSG_TYPE_RX_FRAG_IND,
26 : : [HTT_MAIN_T2H_MSG_TYPE_SEC_IND] = HTT_T2H_MSG_TYPE_SEC_IND,
27 : : [HTT_MAIN_T2H_MSG_TYPE_TX_INSPECT_IND] =
28 : : HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
29 : : [HTT_MAIN_T2H_MSG_TYPE_MGMT_TX_COMPL_IND] =
30 : : HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
31 : : [HTT_MAIN_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND] =
32 : : HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
33 : : [HTT_MAIN_T2H_MSG_TYPE_RX_PN_IND] = HTT_T2H_MSG_TYPE_RX_PN_IND,
34 : : [HTT_MAIN_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND] =
35 : : HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
36 : : [HTT_MAIN_T2H_MSG_TYPE_TEST] = HTT_T2H_MSG_TYPE_TEST,
37 : : };
38 : :
39 : : static const enum htt_t2h_msg_type htt_10x_t2h_msg_types[] = {
40 : : [HTT_10X_T2H_MSG_TYPE_VERSION_CONF] = HTT_T2H_MSG_TYPE_VERSION_CONF,
41 : : [HTT_10X_T2H_MSG_TYPE_RX_IND] = HTT_T2H_MSG_TYPE_RX_IND,
42 : : [HTT_10X_T2H_MSG_TYPE_RX_FLUSH] = HTT_T2H_MSG_TYPE_RX_FLUSH,
43 : : [HTT_10X_T2H_MSG_TYPE_PEER_MAP] = HTT_T2H_MSG_TYPE_PEER_MAP,
44 : : [HTT_10X_T2H_MSG_TYPE_PEER_UNMAP] = HTT_T2H_MSG_TYPE_PEER_UNMAP,
45 : : [HTT_10X_T2H_MSG_TYPE_RX_ADDBA] = HTT_T2H_MSG_TYPE_RX_ADDBA,
46 : : [HTT_10X_T2H_MSG_TYPE_RX_DELBA] = HTT_T2H_MSG_TYPE_RX_DELBA,
47 : : [HTT_10X_T2H_MSG_TYPE_TX_COMPL_IND] = HTT_T2H_MSG_TYPE_TX_COMPL_IND,
48 : : [HTT_10X_T2H_MSG_TYPE_PKTLOG] = HTT_T2H_MSG_TYPE_PKTLOG,
49 : : [HTT_10X_T2H_MSG_TYPE_STATS_CONF] = HTT_T2H_MSG_TYPE_STATS_CONF,
50 : : [HTT_10X_T2H_MSG_TYPE_RX_FRAG_IND] = HTT_T2H_MSG_TYPE_RX_FRAG_IND,
51 : : [HTT_10X_T2H_MSG_TYPE_SEC_IND] = HTT_T2H_MSG_TYPE_SEC_IND,
52 : : [HTT_10X_T2H_MSG_TYPE_RC_UPDATE_IND] = HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
53 : : [HTT_10X_T2H_MSG_TYPE_TX_INSPECT_IND] = HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
54 : : [HTT_10X_T2H_MSG_TYPE_TEST] = HTT_T2H_MSG_TYPE_TEST,
55 : : [HTT_10X_T2H_MSG_TYPE_CHAN_CHANGE] = HTT_T2H_MSG_TYPE_CHAN_CHANGE,
56 : : [HTT_10X_T2H_MSG_TYPE_AGGR_CONF] = HTT_T2H_MSG_TYPE_AGGR_CONF,
57 : : [HTT_10X_T2H_MSG_TYPE_STATS_NOUPLOAD] = HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
58 : : [HTT_10X_T2H_MSG_TYPE_MGMT_TX_COMPL_IND] =
59 : : HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
60 : : };
61 : :
62 : : static const enum htt_t2h_msg_type htt_tlv_t2h_msg_types[] = {
63 : : [HTT_TLV_T2H_MSG_TYPE_VERSION_CONF] = HTT_T2H_MSG_TYPE_VERSION_CONF,
64 : : [HTT_TLV_T2H_MSG_TYPE_RX_IND] = HTT_T2H_MSG_TYPE_RX_IND,
65 : : [HTT_TLV_T2H_MSG_TYPE_RX_FLUSH] = HTT_T2H_MSG_TYPE_RX_FLUSH,
66 : : [HTT_TLV_T2H_MSG_TYPE_PEER_MAP] = HTT_T2H_MSG_TYPE_PEER_MAP,
67 : : [HTT_TLV_T2H_MSG_TYPE_PEER_UNMAP] = HTT_T2H_MSG_TYPE_PEER_UNMAP,
68 : : [HTT_TLV_T2H_MSG_TYPE_RX_ADDBA] = HTT_T2H_MSG_TYPE_RX_ADDBA,
69 : : [HTT_TLV_T2H_MSG_TYPE_RX_DELBA] = HTT_T2H_MSG_TYPE_RX_DELBA,
70 : : [HTT_TLV_T2H_MSG_TYPE_TX_COMPL_IND] = HTT_T2H_MSG_TYPE_TX_COMPL_IND,
71 : : [HTT_TLV_T2H_MSG_TYPE_PKTLOG] = HTT_T2H_MSG_TYPE_PKTLOG,
72 : : [HTT_TLV_T2H_MSG_TYPE_STATS_CONF] = HTT_T2H_MSG_TYPE_STATS_CONF,
73 : : [HTT_TLV_T2H_MSG_TYPE_RX_FRAG_IND] = HTT_T2H_MSG_TYPE_RX_FRAG_IND,
74 : : [HTT_TLV_T2H_MSG_TYPE_SEC_IND] = HTT_T2H_MSG_TYPE_SEC_IND,
75 : : [HTT_TLV_T2H_MSG_TYPE_RC_UPDATE_IND] = HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
76 : : [HTT_TLV_T2H_MSG_TYPE_TX_INSPECT_IND] = HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
77 : : [HTT_TLV_T2H_MSG_TYPE_MGMT_TX_COMPL_IND] =
78 : : HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
79 : : [HTT_TLV_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND] =
80 : : HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
81 : : [HTT_TLV_T2H_MSG_TYPE_RX_PN_IND] = HTT_T2H_MSG_TYPE_RX_PN_IND,
82 : : [HTT_TLV_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND] =
83 : : HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
84 : : [HTT_TLV_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND] =
85 : : HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND,
86 : : [HTT_TLV_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE] =
87 : : HTT_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE,
88 : : [HTT_TLV_T2H_MSG_TYPE_CHAN_CHANGE] = HTT_T2H_MSG_TYPE_CHAN_CHANGE,
89 : : [HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR] =
90 : : HTT_T2H_MSG_TYPE_RX_OFLD_PKT_ERR,
91 : : [HTT_TLV_T2H_MSG_TYPE_TEST] = HTT_T2H_MSG_TYPE_TEST,
92 : : };
93 : :
94 : : static const enum htt_t2h_msg_type htt_10_4_t2h_msg_types[] = {
95 : : [HTT_10_4_T2H_MSG_TYPE_VERSION_CONF] = HTT_T2H_MSG_TYPE_VERSION_CONF,
96 : : [HTT_10_4_T2H_MSG_TYPE_RX_IND] = HTT_T2H_MSG_TYPE_RX_IND,
97 : : [HTT_10_4_T2H_MSG_TYPE_RX_FLUSH] = HTT_T2H_MSG_TYPE_RX_FLUSH,
98 : : [HTT_10_4_T2H_MSG_TYPE_PEER_MAP] = HTT_T2H_MSG_TYPE_PEER_MAP,
99 : : [HTT_10_4_T2H_MSG_TYPE_PEER_UNMAP] = HTT_T2H_MSG_TYPE_PEER_UNMAP,
100 : : [HTT_10_4_T2H_MSG_TYPE_RX_ADDBA] = HTT_T2H_MSG_TYPE_RX_ADDBA,
101 : : [HTT_10_4_T2H_MSG_TYPE_RX_DELBA] = HTT_T2H_MSG_TYPE_RX_DELBA,
102 : : [HTT_10_4_T2H_MSG_TYPE_TX_COMPL_IND] = HTT_T2H_MSG_TYPE_TX_COMPL_IND,
103 : : [HTT_10_4_T2H_MSG_TYPE_PKTLOG] = HTT_T2H_MSG_TYPE_PKTLOG,
104 : : [HTT_10_4_T2H_MSG_TYPE_STATS_CONF] = HTT_T2H_MSG_TYPE_STATS_CONF,
105 : : [HTT_10_4_T2H_MSG_TYPE_RX_FRAG_IND] = HTT_T2H_MSG_TYPE_RX_FRAG_IND,
106 : : [HTT_10_4_T2H_MSG_TYPE_SEC_IND] = HTT_T2H_MSG_TYPE_SEC_IND,
107 : : [HTT_10_4_T2H_MSG_TYPE_RC_UPDATE_IND] = HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
108 : : [HTT_10_4_T2H_MSG_TYPE_TX_INSPECT_IND] =
109 : : HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
110 : : [HTT_10_4_T2H_MSG_TYPE_MGMT_TX_COMPL_IND] =
111 : : HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
112 : : [HTT_10_4_T2H_MSG_TYPE_CHAN_CHANGE] = HTT_T2H_MSG_TYPE_CHAN_CHANGE,
113 : : [HTT_10_4_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND] =
114 : : HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
115 : : [HTT_10_4_T2H_MSG_TYPE_RX_PN_IND] = HTT_T2H_MSG_TYPE_RX_PN_IND,
116 : : [HTT_10_4_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND] =
117 : : HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
118 : : [HTT_10_4_T2H_MSG_TYPE_TEST] = HTT_T2H_MSG_TYPE_TEST,
119 : : [HTT_10_4_T2H_MSG_TYPE_EN_STATS] = HTT_T2H_MSG_TYPE_EN_STATS,
120 : : [HTT_10_4_T2H_MSG_TYPE_AGGR_CONF] = HTT_T2H_MSG_TYPE_AGGR_CONF,
121 : : [HTT_10_4_T2H_MSG_TYPE_TX_FETCH_IND] =
122 : : HTT_T2H_MSG_TYPE_TX_FETCH_IND,
123 : : [HTT_10_4_T2H_MSG_TYPE_TX_FETCH_CONFIRM] =
124 : : HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
125 : : [HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD] =
126 : : HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
127 : : [HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND] =
128 : : HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
129 : : [HTT_10_4_T2H_MSG_TYPE_PEER_STATS] =
130 : : HTT_T2H_MSG_TYPE_PEER_STATS,
131 : : };
132 : :
133 : 0 : int ath10k_htt_connect(struct ath10k_htt *htt)
134 : : {
135 : 0 : struct ath10k_htc_svc_conn_req conn_req;
136 : 0 : struct ath10k_htc_svc_conn_resp conn_resp;
137 : 0 : int status;
138 : :
139 : 0 : memset(&conn_req, 0, sizeof(conn_req));
140 : 0 : memset(&conn_resp, 0, sizeof(conn_resp));
141 : :
142 : 0 : conn_req.ep_ops.ep_tx_complete = ath10k_htt_htc_tx_complete;
143 : 0 : conn_req.ep_ops.ep_rx_complete = ath10k_htt_htc_t2h_msg_handler;
144 : :
145 : : /* connect to control service */
146 : 0 : conn_req.service_id = ATH10K_HTC_SVC_ID_HTT_DATA_MSG;
147 : :
148 : 0 : status = ath10k_htc_connect_service(&htt->ar->htc, &conn_req,
149 : : &conn_resp);
150 : :
151 [ # # ]: 0 : if (status)
152 : : return status;
153 : :
154 : 0 : htt->eid = conn_resp.eid;
155 : :
156 : 0 : return 0;
157 : : }
158 : :
159 : 0 : int ath10k_htt_init(struct ath10k *ar)
160 : : {
161 : 0 : struct ath10k_htt *htt = &ar->htt;
162 : :
163 : 0 : htt->ar = ar;
164 : :
165 : : /*
166 : : * Prefetch enough data to satisfy target
167 : : * classification engine.
168 : : * This is for LL chips. HL chips will probably
169 : : * transfer all frame in the tx fragment.
170 : : */
171 : 0 : htt->prefetch_len =
172 : : 36 + /* 802.11 + qos + ht */
173 : : 4 + /* 802.1q */
174 : : 8 + /* llc snap */
175 : : 2; /* ip4 dscp or ip6 priority */
176 : :
177 [ # # # # : 0 : switch (ar->running_fw->fw_file.htt_op_version) {
# # ]
178 : 0 : case ATH10K_FW_HTT_OP_VERSION_10_4:
179 : 0 : ar->htt.t2h_msg_types = htt_10_4_t2h_msg_types;
180 : 0 : ar->htt.t2h_msg_types_max = HTT_10_4_T2H_NUM_MSGS;
181 : 0 : break;
182 : 0 : case ATH10K_FW_HTT_OP_VERSION_10_1:
183 : 0 : ar->htt.t2h_msg_types = htt_10x_t2h_msg_types;
184 : 0 : ar->htt.t2h_msg_types_max = HTT_10X_T2H_NUM_MSGS;
185 : 0 : break;
186 : 0 : case ATH10K_FW_HTT_OP_VERSION_TLV:
187 : 0 : ar->htt.t2h_msg_types = htt_tlv_t2h_msg_types;
188 : 0 : ar->htt.t2h_msg_types_max = HTT_TLV_T2H_NUM_MSGS;
189 : 0 : break;
190 : 0 : case ATH10K_FW_HTT_OP_VERSION_MAIN:
191 : 0 : ar->htt.t2h_msg_types = htt_main_t2h_msg_types;
192 : 0 : ar->htt.t2h_msg_types_max = HTT_MAIN_T2H_NUM_MSGS;
193 : 0 : break;
194 : : case ATH10K_FW_HTT_OP_VERSION_MAX:
195 : : case ATH10K_FW_HTT_OP_VERSION_UNSET:
196 : 0 : WARN_ON(1);
197 : 0 : return -EINVAL;
198 : : }
199 : 0 : ath10k_htt_set_tx_ops(htt);
200 : 0 : ath10k_htt_set_rx_ops(htt);
201 : :
202 : 0 : return 0;
203 : : }
204 : :
205 : : #define HTT_TARGET_VERSION_TIMEOUT_HZ (3 * HZ)
206 : :
207 : 0 : static int ath10k_htt_verify_version(struct ath10k_htt *htt)
208 : : {
209 : 0 : struct ath10k *ar = htt->ar;
210 : :
211 [ # # ]: 0 : ath10k_dbg(ar, ATH10K_DBG_BOOT, "htt target version %d.%d\n",
212 : : htt->target_version_major, htt->target_version_minor);
213 : :
214 [ # # ]: 0 : if (htt->target_version_major != 2 &&
215 : : htt->target_version_major != 3) {
216 : 0 : ath10k_err(ar, "unsupported htt major version %d. supported versions are 2 and 3\n",
217 : : htt->target_version_major);
218 : 0 : return -ENOTSUPP;
219 : : }
220 : :
221 : : return 0;
222 : : }
223 : :
224 : 0 : int ath10k_htt_setup(struct ath10k_htt *htt)
225 : : {
226 : 0 : struct ath10k *ar = htt->ar;
227 : 0 : int status;
228 : :
229 : 0 : init_completion(&htt->target_version_received);
230 : :
231 : 0 : status = ath10k_htt_h2t_ver_req_msg(htt);
232 [ # # ]: 0 : if (status)
233 : : return status;
234 : :
235 : 0 : status = wait_for_completion_timeout(&htt->target_version_received,
236 : : HTT_TARGET_VERSION_TIMEOUT_HZ);
237 [ # # ]: 0 : if (status == 0) {
238 : 0 : ath10k_warn(ar, "htt version request timed out\n");
239 : 0 : return -ETIMEDOUT;
240 : : }
241 : :
242 : 0 : status = ath10k_htt_verify_version(htt);
243 [ # # ]: 0 : if (status) {
244 : 0 : ath10k_warn(ar, "failed to verify htt version: %d\n",
245 : : status);
246 : 0 : return status;
247 : : }
248 : :
249 [ # # ]: 0 : status = ath10k_htt_send_frag_desc_bank_cfg(htt);
250 [ # # ]: 0 : if (status)
251 : 0 : return status;
252 : :
253 [ # # ]: 0 : status = ath10k_htt_send_rx_ring_cfg(htt);
254 [ # # ]: 0 : if (status) {
255 : 0 : ath10k_warn(ar, "failed to setup rx ring: %d\n",
256 : : status);
257 : 0 : return status;
258 : : }
259 : :
260 : 0 : status = ath10k_htt_h2t_aggr_cfg_msg(htt,
261 : 0 : htt->max_num_ampdu,
262 [ # # ]: 0 : htt->max_num_amsdu);
263 [ # # ]: 0 : if (status) {
264 : 0 : ath10k_warn(ar, "failed to setup amsdu/ampdu limit: %d\n",
265 : : status);
266 : 0 : return status;
267 : : }
268 : :
269 : : return 0;
270 : : }
|