blob: 8e64ace0119b482f567c7fef19162a6a4b2c9fa0 [file] [log] [blame]
Kalle Valo5e3dd152013-06-12 20:52:10 +03001/*
2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#ifndef _HTT_H_
19#define _HTT_H_
20
21#include <linux/bug.h>
Michal Kazior6e712d42013-09-24 10:18:36 +020022#include <linux/interrupt.h>
Michal Kaziora16942e2014-02-27 18:50:04 +020023#include <linux/dmapool.h>
Michal Kaziorc5450702015-01-24 12:14:48 +020024#include <linux/hashtable.h>
Janusz Dziedzic8f739db2014-03-24 21:23:17 +010025#include <net/mac80211.h>
Kalle Valo5e3dd152013-06-12 20:52:10 +030026
Kalle Valo5e3dd152013-06-12 20:52:10 +030027#include "htc.h"
Michal Kazior6aa4cf12015-03-30 09:51:55 +030028#include "hw.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030029#include "rx_desc.h"
Rajkumar Manoharan8348db22015-03-25 13:12:27 +020030#include "hw.h"
Kalle Valo5e3dd152013-06-12 20:52:10 +030031
Kalle Valo5e3dd152013-06-12 20:52:10 +030032enum htt_dbg_stats_type {
33 HTT_DBG_STATS_WAL_PDEV_TXRX = 1 << 0,
34 HTT_DBG_STATS_RX_REORDER = 1 << 1,
35 HTT_DBG_STATS_RX_RATE_INFO = 1 << 2,
36 HTT_DBG_STATS_TX_PPDU_LOG = 1 << 3,
37 HTT_DBG_STATS_TX_RATE_INFO = 1 << 4,
38 /* bits 5-23 currently reserved */
39
40 HTT_DBG_NUM_STATS /* keep this last */
41};
42
43enum htt_h2t_msg_type { /* host-to-target */
44 HTT_H2T_MSG_TYPE_VERSION_REQ = 0,
45 HTT_H2T_MSG_TYPE_TX_FRM = 1,
46 HTT_H2T_MSG_TYPE_RX_RING_CFG = 2,
47 HTT_H2T_MSG_TYPE_STATS_REQ = 3,
48 HTT_H2T_MSG_TYPE_SYNC = 4,
49 HTT_H2T_MSG_TYPE_AGGR_CFG = 5,
50 HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG = 6,
Michal Kazior961d4c32013-08-09 10:13:34 +020051
52 /* This command is used for sending management frames in HTT < 3.0.
53 * HTT >= 3.0 uses TX_FRM for everything. */
Kalle Valo5e3dd152013-06-12 20:52:10 +030054 HTT_H2T_MSG_TYPE_MGMT_TX = 7,
55
56 HTT_H2T_NUM_MSGS /* keep this last */
57};
58
59struct htt_cmd_hdr {
60 u8 msg_type;
61} __packed;
62
63struct htt_ver_req {
64 u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
65} __packed;
66
67/*
68 * HTT tx MSDU descriptor
69 *
70 * The HTT tx MSDU descriptor is created by the host HTT SW for each
71 * tx MSDU. The HTT tx MSDU descriptor contains the information that
72 * the target firmware needs for the FW's tx processing, particularly
73 * for creating the HW msdu descriptor.
74 * The same HTT tx descriptor is used for HL and LL systems, though
75 * a few fields within the tx descriptor are used only by LL or
76 * only by HL.
77 * The HTT tx descriptor is defined in two manners: by a struct with
78 * bitfields, and by a series of [dword offset, bit mask, bit shift]
79 * definitions.
80 * The target should use the struct def, for simplicitly and clarity,
81 * but the host shall use the bit-mast + bit-shift defs, to be endian-
82 * neutral. Specifically, the host shall use the get/set macros built
83 * around the mask + shift defs.
84 */
85struct htt_data_tx_desc_frag {
86 __le32 paddr;
87 __le32 len;
88} __packed;
89
90enum htt_data_tx_desc_flags0 {
91 HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT = 1 << 0,
92 HTT_DATA_TX_DESC_FLAGS0_NO_AGGR = 1 << 1,
93 HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT = 1 << 2,
94 HTT_DATA_TX_DESC_FLAGS0_NO_CLASSIFY = 1 << 3,
95 HTT_DATA_TX_DESC_FLAGS0_RSVD0 = 1 << 4
96#define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_MASK 0xE0
97#define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_LSB 5
98};
99
100enum htt_data_tx_desc_flags1 {
101#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_BITS 6
102#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_MASK 0x003F
103#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_LSB 0
104#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_BITS 5
105#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_MASK 0x07C0
106#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_LSB 6
107 HTT_DATA_TX_DESC_FLAGS1_POSTPONED = 1 << 11,
108 HTT_DATA_TX_DESC_FLAGS1_MORE_IN_BATCH = 1 << 12,
109 HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD = 1 << 13,
110 HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD = 1 << 14,
111 HTT_DATA_TX_DESC_FLAGS1_RSVD1 = 1 << 15
112};
113
114enum htt_data_tx_ext_tid {
115 HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST = 16,
116 HTT_DATA_TX_EXT_TID_MGMT = 17,
117 HTT_DATA_TX_EXT_TID_INVALID = 31
118};
119
120#define HTT_INVALID_PEERID 0xFFFF
121
122/*
123 * htt_data_tx_desc - used for data tx path
124 *
125 * Note: vdev_id irrelevant for pkt_type == raw and no_classify == 1.
126 * ext_tid: for qos-data frames (0-15), see %HTT_DATA_TX_EXT_TID_
127 * for special kinds of tids
128 * postponed: only for HL hosts. indicates if this is a resend
129 * (HL hosts manage queues on the host )
130 * more_in_batch: only for HL hosts. indicates if more packets are
131 * pending. this allows target to wait and aggregate
Michal Kazior8d6d3622014-11-24 14:58:31 +0100132 * freq: 0 means home channel of given vdev. intended for offchannel
Kalle Valo5e3dd152013-06-12 20:52:10 +0300133 */
134struct htt_data_tx_desc {
135 u8 flags0; /* %HTT_DATA_TX_DESC_FLAGS0_ */
136 __le16 flags1; /* %HTT_DATA_TX_DESC_FLAGS1_ */
137 __le16 len;
138 __le16 id;
139 __le32 frags_paddr;
Michal Kazior8d6d3622014-11-24 14:58:31 +0100140 __le16 peerid;
141 __le16 freq;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300142 u8 prefetch[0]; /* start of frame, for FW classification engine */
143} __packed;
144
145enum htt_rx_ring_flags {
146 HTT_RX_RING_FLAGS_MAC80211_HDR = 1 << 0,
147 HTT_RX_RING_FLAGS_MSDU_PAYLOAD = 1 << 1,
148 HTT_RX_RING_FLAGS_PPDU_START = 1 << 2,
149 HTT_RX_RING_FLAGS_PPDU_END = 1 << 3,
150 HTT_RX_RING_FLAGS_MPDU_START = 1 << 4,
151 HTT_RX_RING_FLAGS_MPDU_END = 1 << 5,
152 HTT_RX_RING_FLAGS_MSDU_START = 1 << 6,
153 HTT_RX_RING_FLAGS_MSDU_END = 1 << 7,
154 HTT_RX_RING_FLAGS_RX_ATTENTION = 1 << 8,
155 HTT_RX_RING_FLAGS_FRAG_INFO = 1 << 9,
156 HTT_RX_RING_FLAGS_UNICAST_RX = 1 << 10,
157 HTT_RX_RING_FLAGS_MULTICAST_RX = 1 << 11,
158 HTT_RX_RING_FLAGS_CTRL_RX = 1 << 12,
159 HTT_RX_RING_FLAGS_MGMT_RX = 1 << 13,
160 HTT_RX_RING_FLAGS_NULL_RX = 1 << 14,
161 HTT_RX_RING_FLAGS_PHY_DATA_RX = 1 << 15
162};
163
Michal Kaziorfe2407a2014-11-27 11:12:43 +0100164#define HTT_RX_RING_SIZE_MIN 128
165#define HTT_RX_RING_SIZE_MAX 2048
166
Kalle Valo5e3dd152013-06-12 20:52:10 +0300167struct htt_rx_ring_setup_ring {
168 __le32 fw_idx_shadow_reg_paddr;
169 __le32 rx_ring_base_paddr;
170 __le16 rx_ring_len; /* in 4-byte words */
171 __le16 rx_ring_bufsize; /* rx skb size - in bytes */
172 __le16 flags; /* %HTT_RX_RING_FLAGS_ */
173 __le16 fw_idx_init_val;
174
175 /* the following offsets are in 4-byte units */
176 __le16 mac80211_hdr_offset;
177 __le16 msdu_payload_offset;
178 __le16 ppdu_start_offset;
179 __le16 ppdu_end_offset;
180 __le16 mpdu_start_offset;
181 __le16 mpdu_end_offset;
182 __le16 msdu_start_offset;
183 __le16 msdu_end_offset;
184 __le16 rx_attention_offset;
185 __le16 frag_info_offset;
186} __packed;
187
188struct htt_rx_ring_setup_hdr {
189 u8 num_rings; /* supported values: 1, 2 */
190 __le16 rsvd0;
191} __packed;
192
193struct htt_rx_ring_setup {
194 struct htt_rx_ring_setup_hdr hdr;
195 struct htt_rx_ring_setup_ring rings[0];
196} __packed;
197
198/*
199 * htt_stats_req - request target to send specified statistics
200 *
201 * @msg_type: hardcoded %HTT_H2T_MSG_TYPE_STATS_REQ
202 * @upload_types: see %htt_dbg_stats_type. this is 24bit field actually
203 * so make sure its little-endian.
204 * @reset_types: see %htt_dbg_stats_type. this is 24bit field actually
205 * so make sure its little-endian.
206 * @cfg_val: stat_type specific configuration
207 * @stat_type: see %htt_dbg_stats_type
208 * @cookie_lsb: used for confirmation message from target->host
209 * @cookie_msb: ditto as %cookie
210 */
211struct htt_stats_req {
212 u8 upload_types[3];
213 u8 rsvd0;
214 u8 reset_types[3];
215 struct {
216 u8 mpdu_bytes;
217 u8 mpdu_num_msdus;
218 u8 msdu_bytes;
219 } __packed;
220 u8 stat_type;
221 __le32 cookie_lsb;
222 __le32 cookie_msb;
223} __packed;
224
225#define HTT_STATS_REQ_CFG_STAT_TYPE_INVALID 0xff
226
227/*
228 * htt_oob_sync_req - request out-of-band sync
229 *
230 * The HTT SYNC tells the target to suspend processing of subsequent
231 * HTT host-to-target messages until some other target agent locally
232 * informs the target HTT FW that the current sync counter is equal to
233 * or greater than (in a modulo sense) the sync counter specified in
234 * the SYNC message.
235 *
236 * This allows other host-target components to synchronize their operation
237 * with HTT, e.g. to ensure that tx frames don't get transmitted until a
238 * security key has been downloaded to and activated by the target.
239 * In the absence of any explicit synchronization counter value
240 * specification, the target HTT FW will use zero as the default current
241 * sync value.
242 *
243 * The HTT target FW will suspend its host->target message processing as long
244 * as 0 < (in-band sync counter - out-of-band sync counter) & 0xff < 128.
245 */
246struct htt_oob_sync_req {
247 u8 sync_count;
248 __le16 rsvd0;
249} __packed;
250
Kalle Valo5e3dd152013-06-12 20:52:10 +0300251struct htt_aggr_conf {
252 u8 max_num_ampdu_subframes;
Janusz Dziedzicd3856232014-06-02 21:19:46 +0300253 /* amsdu_subframes is limited by 0x1F mask */
254 u8 max_num_amsdu_subframes;
Kalle Valo5e3dd152013-06-12 20:52:10 +0300255} __packed;
256
257#define HTT_MGMT_FRM_HDR_DOWNLOAD_LEN 32
258
259struct htt_mgmt_tx_desc {
260 u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
261 __le32 msdu_paddr;
262 __le32 desc_id;
263 __le32 len;
264 __le32 vdev_id;
265 u8 hdr[HTT_MGMT_FRM_HDR_DOWNLOAD_LEN];
266} __packed;
267
268enum htt_mgmt_tx_status {
269 HTT_MGMT_TX_STATUS_OK = 0,
270 HTT_MGMT_TX_STATUS_RETRY = 1,
271 HTT_MGMT_TX_STATUS_DROP = 2
272};
273
274/*=== target -> host messages ===============================================*/
275
Rajkumar Manoharan8348db22015-03-25 13:12:27 +0200276enum htt_main_t2h_msg_type {
277 HTT_MAIN_T2H_MSG_TYPE_VERSION_CONF = 0x0,
278 HTT_MAIN_T2H_MSG_TYPE_RX_IND = 0x1,
279 HTT_MAIN_T2H_MSG_TYPE_RX_FLUSH = 0x2,
280 HTT_MAIN_T2H_MSG_TYPE_PEER_MAP = 0x3,
281 HTT_MAIN_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
282 HTT_MAIN_T2H_MSG_TYPE_RX_ADDBA = 0x5,
283 HTT_MAIN_T2H_MSG_TYPE_RX_DELBA = 0x6,
284 HTT_MAIN_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
285 HTT_MAIN_T2H_MSG_TYPE_PKTLOG = 0x8,
286 HTT_MAIN_T2H_MSG_TYPE_STATS_CONF = 0x9,
287 HTT_MAIN_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
288 HTT_MAIN_T2H_MSG_TYPE_SEC_IND = 0xb,
289 HTT_MAIN_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
290 HTT_MAIN_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
291 HTT_MAIN_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0xf,
292 HTT_MAIN_T2H_MSG_TYPE_RX_PN_IND = 0x10,
293 HTT_MAIN_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,
294 HTT_MAIN_T2H_MSG_TYPE_TEST,
295 /* keep this last */
296 HTT_MAIN_T2H_NUM_MSGS
297};
298
299enum htt_10x_t2h_msg_type {
300 HTT_10X_T2H_MSG_TYPE_VERSION_CONF = 0x0,
301 HTT_10X_T2H_MSG_TYPE_RX_IND = 0x1,
302 HTT_10X_T2H_MSG_TYPE_RX_FLUSH = 0x2,
303 HTT_10X_T2H_MSG_TYPE_PEER_MAP = 0x3,
304 HTT_10X_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
305 HTT_10X_T2H_MSG_TYPE_RX_ADDBA = 0x5,
306 HTT_10X_T2H_MSG_TYPE_RX_DELBA = 0x6,
307 HTT_10X_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
308 HTT_10X_T2H_MSG_TYPE_PKTLOG = 0x8,
309 HTT_10X_T2H_MSG_TYPE_STATS_CONF = 0x9,
310 HTT_10X_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
311 HTT_10X_T2H_MSG_TYPE_SEC_IND = 0xb,
312 HTT_10X_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,
313 HTT_10X_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
314 HTT_10X_T2H_MSG_TYPE_TEST = 0xe,
315 HTT_10X_T2H_MSG_TYPE_CHAN_CHANGE = 0xf,
316 HTT_10X_T2H_MSG_TYPE_AGGR_CONF = 0x11,
317 HTT_10X_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x12,
318 HTT_10X_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0x13,
319 /* keep this last */
320 HTT_10X_T2H_NUM_MSGS
321};
322
323enum htt_tlv_t2h_msg_type {
324 HTT_TLV_T2H_MSG_TYPE_VERSION_CONF = 0x0,
325 HTT_TLV_T2H_MSG_TYPE_RX_IND = 0x1,
326 HTT_TLV_T2H_MSG_TYPE_RX_FLUSH = 0x2,
327 HTT_TLV_T2H_MSG_TYPE_PEER_MAP = 0x3,
328 HTT_TLV_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
329 HTT_TLV_T2H_MSG_TYPE_RX_ADDBA = 0x5,
330 HTT_TLV_T2H_MSG_TYPE_RX_DELBA = 0x6,
331 HTT_TLV_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
332 HTT_TLV_T2H_MSG_TYPE_PKTLOG = 0x8,
333 HTT_TLV_T2H_MSG_TYPE_STATS_CONF = 0x9,
334 HTT_TLV_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
335 HTT_TLV_T2H_MSG_TYPE_SEC_IND = 0xb,
336 HTT_TLV_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc, /* deprecated */
337 HTT_TLV_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
338 HTT_TLV_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
339 HTT_TLV_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0xf,
340 HTT_TLV_T2H_MSG_TYPE_RX_PN_IND = 0x10,
341 HTT_TLV_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,
342 HTT_TLV_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND = 0x12,
Michal Kaziorc5450702015-01-24 12:14:48 +0200343 /* 0x13 reservd */
Rajkumar Manoharan8348db22015-03-25 13:12:27 +0200344 HTT_TLV_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE = 0x14,
345 HTT_TLV_T2H_MSG_TYPE_CHAN_CHANGE = 0x15,
346 HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR = 0x16,
347 HTT_TLV_T2H_MSG_TYPE_TEST,
348 /* keep this last */
349 HTT_TLV_T2H_NUM_MSGS
350};
Michal Kaziorc5450702015-01-24 12:14:48 +0200351
Raja Mani721ad3c2015-06-22 20:22:24 +0530352enum htt_10_4_t2h_msg_type {
353 HTT_10_4_T2H_MSG_TYPE_VERSION_CONF = 0x0,
354 HTT_10_4_T2H_MSG_TYPE_RX_IND = 0x1,
355 HTT_10_4_T2H_MSG_TYPE_RX_FLUSH = 0x2,
356 HTT_10_4_T2H_MSG_TYPE_PEER_MAP = 0x3,
357 HTT_10_4_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
358 HTT_10_4_T2H_MSG_TYPE_RX_ADDBA = 0x5,
359 HTT_10_4_T2H_MSG_TYPE_RX_DELBA = 0x6,
360 HTT_10_4_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
361 HTT_10_4_T2H_MSG_TYPE_PKTLOG = 0x8,
362 HTT_10_4_T2H_MSG_TYPE_STATS_CONF = 0x9,
363 HTT_10_4_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
364 HTT_10_4_T2H_MSG_TYPE_SEC_IND = 0xb,
365 HTT_10_4_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,
366 HTT_10_4_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
367 HTT_10_4_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
368 HTT_10_4_T2H_MSG_TYPE_CHAN_CHANGE = 0xf,
369 HTT_10_4_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0x10,
370 HTT_10_4_T2H_MSG_TYPE_RX_PN_IND = 0x11,
371 HTT_10_4_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x12,
372 HTT_10_4_T2H_MSG_TYPE_TEST = 0x13,
373 HTT_10_4_T2H_MSG_TYPE_EN_STATS = 0x14,
374 HTT_10_4_T2H_MSG_TYPE_AGGR_CONF = 0x15,
375 HTT_10_4_T2H_MSG_TYPE_TX_FETCH_IND = 0x16,
376 HTT_10_4_T2H_MSG_TYPE_TX_FETCH_CONF = 0x17,
377 HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x18,
378 /* 0x19 to 0x2f are reserved */
379 HTT_10_4_T2H_MSG_TYPE_TX_LOW_LATENCY_IND = 0x30,
380 /* keep this last */
381 HTT_10_4_T2H_NUM_MSGS
382};
383
Rajkumar Manoharan8348db22015-03-25 13:12:27 +0200384enum htt_t2h_msg_type {
385 HTT_T2H_MSG_TYPE_VERSION_CONF,
386 HTT_T2H_MSG_TYPE_RX_IND,
387 HTT_T2H_MSG_TYPE_RX_FLUSH,
388 HTT_T2H_MSG_TYPE_PEER_MAP,
389 HTT_T2H_MSG_TYPE_PEER_UNMAP,
390 HTT_T2H_MSG_TYPE_RX_ADDBA,
391 HTT_T2H_MSG_TYPE_RX_DELBA,
392 HTT_T2H_MSG_TYPE_TX_COMPL_IND,
393 HTT_T2H_MSG_TYPE_PKTLOG,
394 HTT_T2H_MSG_TYPE_STATS_CONF,
395 HTT_T2H_MSG_TYPE_RX_FRAG_IND,
396 HTT_T2H_MSG_TYPE_SEC_IND,
397 HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
398 HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
399 HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
400 HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
401 HTT_T2H_MSG_TYPE_RX_PN_IND,
402 HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
403 HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND,
404 HTT_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE,
405 HTT_T2H_MSG_TYPE_CHAN_CHANGE,
406 HTT_T2H_MSG_TYPE_RX_OFLD_PKT_ERR,
407 HTT_T2H_MSG_TYPE_AGGR_CONF,
408 HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
Kalle Valo5e3dd152013-06-12 20:52:10 +0300409 HTT_T2H_MSG_TYPE_TEST,
Raja Mani721ad3c2015-06-22 20:22:24 +0530410 HTT_T2H_MSG_TYPE_EN_STATS,
411 HTT_T2H_MSG_TYPE_TX_FETCH_IND,
412 HTT_T2H_MSG_TYPE_TX_FETCH_CONF,
413 HTT_T2H_MSG_TYPE_TX_LOW_LATENCY_IND,
Kalle Valo5e3dd152013-06-12 20:52:10 +0300414 /* keep this last */
415 HTT_T2H_NUM_MSGS
416};
417
418/*
419 * htt_resp_hdr - header for target-to-host messages
420 *
421 * msg_type: see htt_t2h_msg_type
422 */
423struct htt_resp_hdr {
424 u8 msg_type;
425} __packed;
426
427#define HTT_RESP_HDR_MSG_TYPE_OFFSET 0
428#define HTT_RESP_HDR_MSG_TYPE_MASK 0xff
429#define HTT_RESP_HDR_MSG_TYPE_LSB 0
430
431/* htt_ver_resp - response sent for htt_ver_req */
432struct htt_ver_resp {
433 u8 minor;
434 u8 major;
435 u8 rsvd0;
436} __packed;
437
438struct htt_mgmt_tx_completion {
439 u8 rsvd0;
440 u8 rsvd1;
441 u8 rsvd2;
442 __le32 desc_id;
443 __le32 status;
444} __packed;
445
446#define HTT_RX_INDICATION_INFO0_EXT_TID_MASK (0x3F)
447#define HTT_RX_INDICATION_INFO0_EXT_TID_LSB (0)
448#define HTT_RX_INDICATION_INFO0_FLUSH_VALID (1 << 6)
449#define HTT_RX_INDICATION_INFO0_RELEASE_VALID (1 << 7)
450
451#define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_MASK 0x0000003F
452#define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_LSB 0
453#define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_MASK 0x00000FC0
454#define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_LSB 6
455#define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_MASK 0x0003F000
456#define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_LSB 12
457#define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_MASK 0x00FC0000
458#define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_LSB 18
459#define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_MASK 0xFF000000
460#define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_LSB 24
461
462struct htt_rx_indication_hdr {
463 u8 info0; /* %HTT_RX_INDICATION_INFO0_ */
464 __le16 peer_id;
465 __le32 info1; /* %HTT_RX_INDICATION_INFO1_ */
466} __packed;
467
468#define HTT_RX_INDICATION_INFO0_PHY_ERR_VALID (1 << 0)
469#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_MASK (0x1E)
470#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_LSB (1)
471#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_CCK (1 << 5)
472#define HTT_RX_INDICATION_INFO0_END_VALID (1 << 6)
473#define HTT_RX_INDICATION_INFO0_START_VALID (1 << 7)
474
475#define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_MASK 0x00FFFFFF
476#define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_LSB 0
477#define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_MASK 0xFF000000
478#define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_LSB 24
479
480#define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_MASK 0x00FFFFFF
481#define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_LSB 0
482#define HTT_RX_INDICATION_INFO2_SERVICE_MASK 0xFF000000
483#define HTT_RX_INDICATION_INFO2_SERVICE_LSB 24
484
485enum htt_rx_legacy_rate {
486 HTT_RX_OFDM_48 = 0,
487 HTT_RX_OFDM_24 = 1,
488 HTT_RX_OFDM_12,
489 HTT_RX_OFDM_6,
490 HTT_RX_OFDM_54,
491 HTT_RX_OFDM_36,
492 HTT_RX_OFDM_18,
493 HTT_RX_OFDM_9,
494
495 /* long preamble */
496 HTT_RX_CCK_11_LP = 0,
497 HTT_RX_CCK_5_5_LP = 1,
498 HTT_RX_CCK_2_LP,
499 HTT_RX_CCK_1_LP,
500 /* short preamble */
501 HTT_RX_CCK_11_SP,
502 HTT_RX_CCK_5_5_SP,
503 HTT_RX_CCK_2_SP
504};
505
506enum htt_rx_legacy_rate_type {
507 HTT_RX_LEGACY_RATE_OFDM = 0,
508 HTT_RX_LEGACY_RATE_CCK
509};
510
511enum htt_rx_preamble_type {
512 HTT_RX_LEGACY = 0x4,
513 HTT_RX_HT = 0x8,
514 HTT_RX_HT_WITH_TXBF = 0x9,
515 HTT_RX_VHT = 0xC,
516 HTT_RX_VHT_WITH_TXBF = 0xD,
517};
518
519/*
520 * Fields: phy_err_valid, phy_err_code, tsf,
521 * usec_timestamp, sub_usec_timestamp
522 * ..are valid only if end_valid == 1.
523 *
524 * Fields: rssi_chains, legacy_rate_type,
525 * legacy_rate_cck, preamble_type, service,
526 * vht_sig_*
527 * ..are valid only if start_valid == 1;
528 */
529struct htt_rx_indication_ppdu {
530 u8 combined_rssi;
531 u8 sub_usec_timestamp;
532 u8 phy_err_code;
533 u8 info0; /* HTT_RX_INDICATION_INFO0_ */
534 struct {
535 u8 pri20_db;
536 u8 ext20_db;
537 u8 ext40_db;
538 u8 ext80_db;
539 } __packed rssi_chains[4];
540 __le32 tsf;
541 __le32 usec_timestamp;
542 __le32 info1; /* HTT_RX_INDICATION_INFO1_ */
543 __le32 info2; /* HTT_RX_INDICATION_INFO2_ */
544} __packed;
545
546enum htt_rx_mpdu_status {
547 HTT_RX_IND_MPDU_STATUS_UNKNOWN = 0x0,
548 HTT_RX_IND_MPDU_STATUS_OK,
549 HTT_RX_IND_MPDU_STATUS_ERR_FCS,
550 HTT_RX_IND_MPDU_STATUS_ERR_DUP,
551 HTT_RX_IND_MPDU_STATUS_ERR_REPLAY,
552 HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER,
553 /* only accept EAPOL frames */
554 HTT_RX_IND_MPDU_STATUS_UNAUTH_PEER,
555 HTT_RX_IND_MPDU_STATUS_OUT_OF_SYNC,
556 /* Non-data in promiscous mode */
557 HTT_RX_IND_MPDU_STATUS_MGMT_CTRL,
558 HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR,
559 HTT_RX_IND_MPDU_STATUS_DECRYPT_ERR,
560 HTT_RX_IND_MPDU_STATUS_MPDU_LENGTH_ERR,
561 HTT_RX_IND_MPDU_STATUS_ENCRYPT_REQUIRED_ERR,
562 HTT_RX_IND_MPDU_STATUS_PRIVACY_ERR,
563
564 /*
565 * MISC: discard for unspecified reasons.
566 * Leave this enum value last.
567 */
568 HTT_RX_IND_MPDU_STATUS_ERR_MISC = 0xFF
569};
570
571struct htt_rx_indication_mpdu_range {
572 u8 mpdu_count;
573 u8 mpdu_range_status; /* %htt_rx_mpdu_status */
574 u8 pad0;
575 u8 pad1;
576} __packed;
577
578struct htt_rx_indication_prefix {
579 __le16 fw_rx_desc_bytes;
580 u8 pad0;
581 u8 pad1;
582};
583
584struct htt_rx_indication {
585 struct htt_rx_indication_hdr hdr;
586 struct htt_rx_indication_ppdu ppdu;
587 struct htt_rx_indication_prefix prefix;
588
589 /*
590 * the following fields are both dynamically sized, so
591 * take care addressing them
592 */
593
594 /* the size of this is %fw_rx_desc_bytes */
595 struct fw_rx_desc_base fw_desc;
596
597 /*
598 * %mpdu_ranges starts after &%prefix + roundup(%fw_rx_desc_bytes, 4)
599 * and has %num_mpdu_ranges elements.
600 */
601 struct htt_rx_indication_mpdu_range mpdu_ranges[0];
602} __packed;
603
604static inline struct htt_rx_indication_mpdu_range *
605 htt_rx_ind_get_mpdu_ranges(struct htt_rx_indication *rx_ind)
606{
607 void *ptr = rx_ind;
608
609 ptr += sizeof(rx_ind->hdr)
610 + sizeof(rx_ind->ppdu)
611 + sizeof(rx_ind->prefix)
612 + roundup(__le16_to_cpu(rx_ind->prefix.fw_rx_desc_bytes), 4);
613 return ptr;
614}
615
616enum htt_rx_flush_mpdu_status {
617 HTT_RX_FLUSH_MPDU_DISCARD = 0,
618 HTT_RX_FLUSH_MPDU_REORDER = 1,
619};
620
621/*
622 * htt_rx_flush - discard or reorder given range of mpdus
623 *
624 * Note: host must check if all sequence numbers between
625 * [seq_num_start, seq_num_end-1] are valid.
626 */
627struct htt_rx_flush {
628 __le16 peer_id;
629 u8 tid;
630 u8 rsvd0;
631 u8 mpdu_status; /* %htt_rx_flush_mpdu_status */
632 u8 seq_num_start; /* it is 6 LSBs of 802.11 seq no */
633 u8 seq_num_end; /* it is 6 LSBs of 802.11 seq no */
634};
635
636struct htt_rx_peer_map {
637 u8 vdev_id;
638 __le16 peer_id;
639 u8 addr[6];
640 u8 rsvd0;
641 u8 rsvd1;
642} __packed;
643
644struct htt_rx_peer_unmap {
645 u8 rsvd0;
646 __le16 peer_id;
647} __packed;
648
649enum htt_security_types {
650 HTT_SECURITY_NONE,
651 HTT_SECURITY_WEP128,
652 HTT_SECURITY_WEP104,
653 HTT_SECURITY_WEP40,
654 HTT_SECURITY_TKIP,
655 HTT_SECURITY_TKIP_NOMIC,
656 HTT_SECURITY_AES_CCMP,
657 HTT_SECURITY_WAPI,
658
659 HTT_NUM_SECURITY_TYPES /* keep this last! */
660};
661
662enum htt_security_flags {
663#define HTT_SECURITY_TYPE_MASK 0x7F
664#define HTT_SECURITY_TYPE_LSB 0
665 HTT_SECURITY_IS_UNICAST = 1 << 7
666};
667
668struct htt_security_indication {
669 union {
670 /* dont use bitfields; undefined behaviour */
671 u8 flags; /* %htt_security_flags */
672 struct {
673 u8 security_type:7, /* %htt_security_types */
674 is_unicast:1;
675 } __packed;
676 } __packed;
677 __le16 peer_id;
678 u8 michael_key[8];
679 u8 wapi_rsc[16];
680} __packed;
681
682#define HTT_RX_BA_INFO0_TID_MASK 0x000F
683#define HTT_RX_BA_INFO0_TID_LSB 0
684#define HTT_RX_BA_INFO0_PEER_ID_MASK 0xFFF0
685#define HTT_RX_BA_INFO0_PEER_ID_LSB 4
686
687struct htt_rx_addba {
688 u8 window_size;
689 __le16 info0; /* %HTT_RX_BA_INFO0_ */
690} __packed;
691
692struct htt_rx_delba {
693 u8 rsvd0;
694 __le16 info0; /* %HTT_RX_BA_INFO0_ */
695} __packed;
696
697enum htt_data_tx_status {
698 HTT_DATA_TX_STATUS_OK = 0,
699 HTT_DATA_TX_STATUS_DISCARD = 1,
700 HTT_DATA_TX_STATUS_NO_ACK = 2,
701 HTT_DATA_TX_STATUS_POSTPONE = 3, /* HL only */
702 HTT_DATA_TX_STATUS_DOWNLOAD_FAIL = 128
703};
704
705enum htt_data_tx_flags {
706#define HTT_DATA_TX_STATUS_MASK 0x07
707#define HTT_DATA_TX_STATUS_LSB 0
708#define HTT_DATA_TX_TID_MASK 0x78
709#define HTT_DATA_TX_TID_LSB 3
710 HTT_DATA_TX_TID_INVALID = 1 << 7
711};
712
713#define HTT_TX_COMPL_INV_MSDU_ID 0xFFFF
714
715struct htt_data_tx_completion {
716 union {
717 u8 flags;
718 struct {
719 u8 status:3,
720 tid:4,
721 tid_invalid:1;
722 } __packed;
723 } __packed;
724 u8 num_msdus;
725 u8 rsvd0;
726 __le16 msdus[0]; /* variable length based on %num_msdus */
727} __packed;
728
729struct htt_tx_compl_ind_base {
730 u32 hdr;
731 u16 payload[1/*or more*/];
732} __packed;
733
734struct htt_rc_tx_done_params {
735 u32 rate_code;
736 u32 rate_code_flags;
737 u32 flags;
738 u32 num_enqued; /* 1 for non-AMPDU */
739 u32 num_retries;
740 u32 num_failed; /* for AMPDU */
741 u32 ack_rssi;
742 u32 time_stamp;
743 u32 is_probe;
744};
745
746struct htt_rc_update {
747 u8 vdev_id;
748 __le16 peer_id;
749 u8 addr[6];
750 u8 num_elems;
751 u8 rsvd0;
752 struct htt_rc_tx_done_params params[0]; /* variable length %num_elems */
753} __packed;
754
755/* see htt_rx_indication for similar fields and descriptions */
756struct htt_rx_fragment_indication {
757 union {
758 u8 info0; /* %HTT_RX_FRAG_IND_INFO0_ */
759 struct {
760 u8 ext_tid:5,
761 flush_valid:1;
762 } __packed;
763 } __packed;
764 __le16 peer_id;
765 __le32 info1; /* %HTT_RX_FRAG_IND_INFO1_ */
766 __le16 fw_rx_desc_bytes;
767 __le16 rsvd0;
768
769 u8 fw_msdu_rx_desc[0];
770} __packed;
771
772#define HTT_RX_FRAG_IND_INFO0_EXT_TID_MASK 0x1F
773#define HTT_RX_FRAG_IND_INFO0_EXT_TID_LSB 0
774#define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_MASK 0x20
775#define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_LSB 5
776
777#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_MASK 0x0000003F
778#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_LSB 0
779#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_MASK 0x00000FC0
780#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_LSB 6
781
Michal Kaziorc5450702015-01-24 12:14:48 +0200782struct htt_rx_pn_ind {
783 __le16 peer_id;
784 u8 tid;
785 u8 seqno_start;
786 u8 seqno_end;
787 u8 pn_ie_count;
788 u8 reserved;
789 u8 pn_ies[0];
790} __packed;
791
792struct htt_rx_offload_msdu {
793 __le16 msdu_len;
794 __le16 peer_id;
795 u8 vdev_id;
796 u8 tid;
797 u8 fw_desc;
798 u8 payload[0];
799} __packed;
800
801struct htt_rx_offload_ind {
802 u8 reserved;
803 __le16 msdu_count;
804} __packed;
805
806struct htt_rx_in_ord_msdu_desc {
807 __le32 msdu_paddr;
808 __le16 msdu_len;
809 u8 fw_desc;
810 u8 reserved;
811} __packed;
812
813struct htt_rx_in_ord_ind {
814 u8 info;
815 __le16 peer_id;
816 u8 vdev_id;
817 u8 reserved;
818 __le16 msdu_count;
819 struct htt_rx_in_ord_msdu_desc msdu_descs[0];
820} __packed;
821
822#define HTT_RX_IN_ORD_IND_INFO_TID_MASK 0x0000001f
823#define HTT_RX_IN_ORD_IND_INFO_TID_LSB 0
824#define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_MASK 0x00000020
825#define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_LSB 5
826#define HTT_RX_IN_ORD_IND_INFO_FRAG_MASK 0x00000040
827#define HTT_RX_IN_ORD_IND_INFO_FRAG_LSB 6
828
Kalle Valo5e3dd152013-06-12 20:52:10 +0300829/*
830 * target -> host test message definition
831 *
832 * The following field definitions describe the format of the test
833 * message sent from the target to the host.
834 * The message consists of a 4-octet header, followed by a variable
835 * number of 32-bit integer values, followed by a variable number
836 * of 8-bit character values.
837 *
838 * |31 16|15 8|7 0|
839 * |-----------------------------------------------------------|
840 * | num chars | num ints | msg type |
841 * |-----------------------------------------------------------|
842 * | int 0 |
843 * |-----------------------------------------------------------|
844 * | int 1 |
845 * |-----------------------------------------------------------|
846 * | ... |
847 * |-----------------------------------------------------------|
848 * | char 3 | char 2 | char 1 | char 0 |
849 * |-----------------------------------------------------------|
850 * | | | ... | char 4 |
851 * |-----------------------------------------------------------|
852 * - MSG_TYPE
853 * Bits 7:0
854 * Purpose: identifies this as a test message
855 * Value: HTT_MSG_TYPE_TEST
856 * - NUM_INTS
857 * Bits 15:8
858 * Purpose: indicate how many 32-bit integers follow the message header
859 * - NUM_CHARS
860 * Bits 31:16
861 * Purpose: indicate how many 8-bit charaters follow the series of integers
862 */
863struct htt_rx_test {
864 u8 num_ints;
865 __le16 num_chars;
866
867 /* payload consists of 2 lists:
868 * a) num_ints * sizeof(__le32)
869 * b) num_chars * sizeof(u8) aligned to 4bytes */
870 u8 payload[0];
871} __packed;
872
873static inline __le32 *htt_rx_test_get_ints(struct htt_rx_test *rx_test)
874{
875 return (__le32 *)rx_test->payload;
876}
877
878static inline u8 *htt_rx_test_get_chars(struct htt_rx_test *rx_test)
879{
880 return rx_test->payload + (rx_test->num_ints * sizeof(__le32));
881}
882
883/*
884 * target -> host packet log message
885 *
886 * The following field definitions describe the format of the packet log
887 * message sent from the target to the host.
888 * The message consists of a 4-octet header,followed by a variable number
889 * of 32-bit character values.
890 *
891 * |31 24|23 16|15 8|7 0|
892 * |-----------------------------------------------------------|
893 * | | | | msg type |
894 * |-----------------------------------------------------------|
895 * | payload |
896 * |-----------------------------------------------------------|
897 * - MSG_TYPE
898 * Bits 7:0
899 * Purpose: identifies this as a test message
900 * Value: HTT_MSG_TYPE_PACKETLOG
901 */
902struct htt_pktlog_msg {
903 u8 pad[3];
Rajkumar Manoharanbfdd7932014-10-03 08:02:40 +0300904 u8 payload[0];
Kalle Valo5e3dd152013-06-12 20:52:10 +0300905} __packed;
906
907struct htt_dbg_stats_rx_reorder_stats {
908 /* Non QoS MPDUs received */
909 __le32 deliver_non_qos;
910
911 /* MPDUs received in-order */
912 __le32 deliver_in_order;
913
914 /* Flush due to reorder timer expired */
915 __le32 deliver_flush_timeout;
916
917 /* Flush due to move out of window */
918 __le32 deliver_flush_oow;
919
920 /* Flush due to DELBA */
921 __le32 deliver_flush_delba;
922
923 /* MPDUs dropped due to FCS error */
924 __le32 fcs_error;
925
926 /* MPDUs dropped due to monitor mode non-data packet */
927 __le32 mgmt_ctrl;
928
929 /* MPDUs dropped due to invalid peer */
930 __le32 invalid_peer;
931
932 /* MPDUs dropped due to duplication (non aggregation) */
933 __le32 dup_non_aggr;
934
935 /* MPDUs dropped due to processed before */
936 __le32 dup_past;
937
938 /* MPDUs dropped due to duplicate in reorder queue */
939 __le32 dup_in_reorder;
940
941 /* Reorder timeout happened */
942 __le32 reorder_timeout;
943
944 /* invalid bar ssn */
945 __le32 invalid_bar_ssn;
946
947 /* reorder reset due to bar ssn */
948 __le32 ssn_reset;
949};
950
951struct htt_dbg_stats_wal_tx_stats {
952 /* Num HTT cookies queued to dispatch list */
953 __le32 comp_queued;
954
955 /* Num HTT cookies dispatched */
956 __le32 comp_delivered;
957
958 /* Num MSDU queued to WAL */
959 __le32 msdu_enqued;
960
961 /* Num MPDU queue to WAL */
962 __le32 mpdu_enqued;
963
964 /* Num MSDUs dropped by WMM limit */
965 __le32 wmm_drop;
966
967 /* Num Local frames queued */
968 __le32 local_enqued;
969
970 /* Num Local frames done */
971 __le32 local_freed;
972
973 /* Num queued to HW */
974 __le32 hw_queued;
975
976 /* Num PPDU reaped from HW */
977 __le32 hw_reaped;
978
979 /* Num underruns */
980 __le32 underrun;
981
982 /* Num PPDUs cleaned up in TX abort */
983 __le32 tx_abort;
984
985 /* Num MPDUs requed by SW */
986 __le32 mpdus_requed;
987
988 /* excessive retries */
989 __le32 tx_ko;
990
991 /* data hw rate code */
992 __le32 data_rc;
993
994 /* Scheduler self triggers */
995 __le32 self_triggers;
996
997 /* frames dropped due to excessive sw retries */
998 __le32 sw_retry_failure;
999
1000 /* illegal rate phy errors */
1001 __le32 illgl_rate_phy_err;
1002
1003 /* wal pdev continous xretry */
1004 __le32 pdev_cont_xretry;
1005
1006 /* wal pdev continous xretry */
1007 __le32 pdev_tx_timeout;
1008
1009 /* wal pdev resets */
1010 __le32 pdev_resets;
1011
1012 __le32 phy_underrun;
1013
1014 /* MPDU is more than txop limit */
1015 __le32 txop_ovf;
1016} __packed;
1017
1018struct htt_dbg_stats_wal_rx_stats {
1019 /* Cnts any change in ring routing mid-ppdu */
1020 __le32 mid_ppdu_route_change;
1021
1022 /* Total number of statuses processed */
1023 __le32 status_rcvd;
1024
1025 /* Extra frags on rings 0-3 */
1026 __le32 r0_frags;
1027 __le32 r1_frags;
1028 __le32 r2_frags;
1029 __le32 r3_frags;
1030
1031 /* MSDUs / MPDUs delivered to HTT */
1032 __le32 htt_msdus;
1033 __le32 htt_mpdus;
1034
1035 /* MSDUs / MPDUs delivered to local stack */
1036 __le32 loc_msdus;
1037 __le32 loc_mpdus;
1038
1039 /* AMSDUs that have more MSDUs than the status ring size */
1040 __le32 oversize_amsdu;
1041
1042 /* Number of PHY errors */
1043 __le32 phy_errs;
1044
1045 /* Number of PHY errors drops */
1046 __le32 phy_err_drop;
1047
1048 /* Number of mpdu errors - FCS, MIC, ENC etc. */
1049 __le32 mpdu_errs;
1050} __packed;
1051
1052struct htt_dbg_stats_wal_peer_stats {
1053 __le32 dummy; /* REMOVE THIS ONCE REAL PEER STAT COUNTERS ARE ADDED */
1054} __packed;
1055
1056struct htt_dbg_stats_wal_pdev_txrx {
1057 struct htt_dbg_stats_wal_tx_stats tx_stats;
1058 struct htt_dbg_stats_wal_rx_stats rx_stats;
1059 struct htt_dbg_stats_wal_peer_stats peer_stats;
1060} __packed;
1061
1062struct htt_dbg_stats_rx_rate_info {
1063 __le32 mcs[10];
1064 __le32 sgi[10];
1065 __le32 nss[4];
1066 __le32 stbc[10];
1067 __le32 bw[3];
1068 __le32 pream[6];
1069 __le32 ldpc;
1070 __le32 txbf;
1071};
1072
1073/*
1074 * htt_dbg_stats_status -
1075 * present - The requested stats have been delivered in full.
1076 * This indicates that either the stats information was contained
1077 * in its entirety within this message, or else this message
1078 * completes the delivery of the requested stats info that was
1079 * partially delivered through earlier STATS_CONF messages.
1080 * partial - The requested stats have been delivered in part.
1081 * One or more subsequent STATS_CONF messages with the same
1082 * cookie value will be sent to deliver the remainder of the
1083 * information.
1084 * error - The requested stats could not be delivered, for example due
1085 * to a shortage of memory to construct a message holding the
1086 * requested stats.
1087 * invalid - The requested stat type is either not recognized, or the
1088 * target is configured to not gather the stats type in question.
1089 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1090 * series_done - This special value indicates that no further stats info
1091 * elements are present within a series of stats info elems
1092 * (within a stats upload confirmation message).
1093 */
1094enum htt_dbg_stats_status {
1095 HTT_DBG_STATS_STATUS_PRESENT = 0,
1096 HTT_DBG_STATS_STATUS_PARTIAL = 1,
1097 HTT_DBG_STATS_STATUS_ERROR = 2,
1098 HTT_DBG_STATS_STATUS_INVALID = 3,
1099 HTT_DBG_STATS_STATUS_SERIES_DONE = 7
1100};
1101
1102/*
1103 * target -> host statistics upload
1104 *
1105 * The following field definitions describe the format of the HTT target
1106 * to host stats upload confirmation message.
1107 * The message contains a cookie echoed from the HTT host->target stats
1108 * upload request, which identifies which request the confirmation is
1109 * for, and a series of tag-length-value stats information elements.
1110 * The tag-length header for each stats info element also includes a
1111 * status field, to indicate whether the request for the stat type in
1112 * question was fully met, partially met, unable to be met, or invalid
1113 * (if the stat type in question is disabled in the target).
1114 * A special value of all 1's in this status field is used to indicate
1115 * the end of the series of stats info elements.
1116 *
1117 *
1118 * |31 16|15 8|7 5|4 0|
1119 * |------------------------------------------------------------|
1120 * | reserved | msg type |
1121 * |------------------------------------------------------------|
1122 * | cookie LSBs |
1123 * |------------------------------------------------------------|
1124 * | cookie MSBs |
1125 * |------------------------------------------------------------|
1126 * | stats entry length | reserved | S |stat type|
1127 * |------------------------------------------------------------|
1128 * | |
1129 * | type-specific stats info |
1130 * | |
1131 * |------------------------------------------------------------|
1132 * | stats entry length | reserved | S |stat type|
1133 * |------------------------------------------------------------|
1134 * | |
1135 * | type-specific stats info |
1136 * | |
1137 * |------------------------------------------------------------|
1138 * | n/a | reserved | 111 | n/a |
1139 * |------------------------------------------------------------|
1140 * Header fields:
1141 * - MSG_TYPE
1142 * Bits 7:0
1143 * Purpose: identifies this is a statistics upload confirmation message
1144 * Value: 0x9
1145 * - COOKIE_LSBS
1146 * Bits 31:0
1147 * Purpose: Provide a mechanism to match a target->host stats confirmation
1148 * message with its preceding host->target stats request message.
1149 * Value: LSBs of the opaque cookie specified by the host-side requestor
1150 * - COOKIE_MSBS
1151 * Bits 31:0
1152 * Purpose: Provide a mechanism to match a target->host stats confirmation
1153 * message with its preceding host->target stats request message.
1154 * Value: MSBs of the opaque cookie specified by the host-side requestor
1155 *
1156 * Stats Information Element tag-length header fields:
1157 * - STAT_TYPE
1158 * Bits 4:0
1159 * Purpose: identifies the type of statistics info held in the
1160 * following information element
1161 * Value: htt_dbg_stats_type
1162 * - STATUS
1163 * Bits 7:5
1164 * Purpose: indicate whether the requested stats are present
1165 * Value: htt_dbg_stats_status, including a special value (0x7) to mark
1166 * the completion of the stats entry series
1167 * - LENGTH
1168 * Bits 31:16
1169 * Purpose: indicate the stats information size
1170 * Value: This field specifies the number of bytes of stats information
1171 * that follows the element tag-length header.
1172 * It is expected but not required that this length is a multiple of
1173 * 4 bytes. Even if the length is not an integer multiple of 4, the
1174 * subsequent stats entry header will begin on a 4-byte aligned
1175 * boundary.
1176 */
1177
1178#define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_MASK 0x1F
1179#define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_LSB 0
1180#define HTT_STATS_CONF_ITEM_INFO_STATUS_MASK 0xE0
1181#define HTT_STATS_CONF_ITEM_INFO_STATUS_LSB 5
1182
1183struct htt_stats_conf_item {
1184 union {
1185 u8 info;
1186 struct {
1187 u8 stat_type:5; /* %HTT_DBG_STATS_ */
1188 u8 status:3; /* %HTT_DBG_STATS_STATUS_ */
1189 } __packed;
1190 } __packed;
1191 u8 pad;
1192 __le16 length;
1193 u8 payload[0]; /* roundup(length, 4) long */
1194} __packed;
1195
1196struct htt_stats_conf {
1197 u8 pad[3];
1198 __le32 cookie_lsb;
1199 __le32 cookie_msb;
1200
1201 /* each item has variable length! */
1202 struct htt_stats_conf_item items[0];
1203} __packed;
1204
1205static inline struct htt_stats_conf_item *htt_stats_conf_next_item(
1206 const struct htt_stats_conf_item *item)
1207{
1208 return (void *)item + sizeof(*item) + roundup(item->length, 4);
1209}
Kalle Valo8cc7f262014-09-14 12:50:39 +03001210
Kalle Valo5e3dd152013-06-12 20:52:10 +03001211/*
1212 * host -> target FRAG DESCRIPTOR/MSDU_EXT DESC bank
1213 *
1214 * The following field definitions describe the format of the HTT host
1215 * to target frag_desc/msdu_ext bank configuration message.
1216 * The message contains the based address and the min and max id of the
1217 * MSDU_EXT/FRAG_DESC that will be used by the HTT to map MSDU DESC and
1218 * MSDU_EXT/FRAG_DESC.
1219 * HTT will use id in HTT descriptor instead sending the frag_desc_ptr.
1220 * For QCA988X HW the firmware will use fragment_desc_ptr but in WIFI2.0
1221 * the hardware does the mapping/translation.
1222 *
1223 * Total banks that can be configured is configured to 16.
1224 *
1225 * This should be called before any TX has be initiated by the HTT
1226 *
1227 * |31 16|15 8|7 5|4 0|
1228 * |------------------------------------------------------------|
1229 * | DESC_SIZE | NUM_BANKS | RES |SWP|pdev| msg type |
1230 * |------------------------------------------------------------|
1231 * | BANK0_BASE_ADDRESS |
1232 * |------------------------------------------------------------|
1233 * | ... |
1234 * |------------------------------------------------------------|
1235 * | BANK15_BASE_ADDRESS |
1236 * |------------------------------------------------------------|
1237 * | BANK0_MAX_ID | BANK0_MIN_ID |
1238 * |------------------------------------------------------------|
1239 * | ... |
1240 * |------------------------------------------------------------|
1241 * | BANK15_MAX_ID | BANK15_MIN_ID |
1242 * |------------------------------------------------------------|
1243 * Header fields:
1244 * - MSG_TYPE
1245 * Bits 7:0
1246 * Value: 0x6
1247 * - BANKx_BASE_ADDRESS
1248 * Bits 31:0
1249 * Purpose: Provide a mechanism to specify the base address of the MSDU_EXT
1250 * bank physical/bus address.
1251 * - BANKx_MIN_ID
1252 * Bits 15:0
1253 * Purpose: Provide a mechanism to specify the min index that needs to
1254 * mapped.
1255 * - BANKx_MAX_ID
1256 * Bits 31:16
1257 * Purpose: Provide a mechanism to specify the max index that needs to
1258 *
1259 */
1260struct htt_frag_desc_bank_id {
1261 __le16 bank_min_id;
1262 __le16 bank_max_id;
1263} __packed;
1264
1265/* real is 16 but it wouldn't fit in the max htt message size
1266 * so we use a conservatively safe value for now */
1267#define HTT_FRAG_DESC_BANK_MAX 4
1268
1269#define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_MASK 0x03
1270#define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_LSB 0
1271#define HTT_FRAG_DESC_BANK_CFG_INFO_SWAP (1 << 2)
1272
1273struct htt_frag_desc_bank_cfg {
1274 u8 info; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */
1275 u8 num_banks;
1276 u8 desc_size;
1277 __le32 bank_base_addrs[HTT_FRAG_DESC_BANK_MAX];
1278 struct htt_frag_desc_bank_id bank_id[HTT_FRAG_DESC_BANK_MAX];
1279} __packed;
1280
1281union htt_rx_pn_t {
1282 /* WEP: 24-bit PN */
1283 u32 pn24;
1284
1285 /* TKIP or CCMP: 48-bit PN */
1286 u_int64_t pn48;
1287
1288 /* WAPI: 128-bit PN */
1289 u_int64_t pn128[2];
1290};
1291
1292struct htt_cmd {
1293 struct htt_cmd_hdr hdr;
1294 union {
1295 struct htt_ver_req ver_req;
1296 struct htt_mgmt_tx_desc mgmt_tx;
1297 struct htt_data_tx_desc data_tx;
1298 struct htt_rx_ring_setup rx_setup;
1299 struct htt_stats_req stats_req;
1300 struct htt_oob_sync_req oob_sync_req;
1301 struct htt_aggr_conf aggr_conf;
1302 struct htt_frag_desc_bank_cfg frag_desc_bank_cfg;
1303 };
1304} __packed;
1305
1306struct htt_resp {
1307 struct htt_resp_hdr hdr;
1308 union {
1309 struct htt_ver_resp ver_resp;
1310 struct htt_mgmt_tx_completion mgmt_tx_completion;
1311 struct htt_data_tx_completion data_tx_completion;
1312 struct htt_rx_indication rx_ind;
1313 struct htt_rx_fragment_indication rx_frag_ind;
1314 struct htt_rx_peer_map peer_map;
1315 struct htt_rx_peer_unmap peer_unmap;
1316 struct htt_rx_flush rx_flush;
1317 struct htt_rx_addba rx_addba;
1318 struct htt_rx_delba rx_delba;
1319 struct htt_security_indication security_indication;
1320 struct htt_rc_update rc_update;
1321 struct htt_rx_test rx_test;
1322 struct htt_pktlog_msg pktlog_msg;
1323 struct htt_stats_conf stats_conf;
Michal Kaziorc5450702015-01-24 12:14:48 +02001324 struct htt_rx_pn_ind rx_pn_ind;
1325 struct htt_rx_offload_ind rx_offload_ind;
1326 struct htt_rx_in_ord_ind rx_in_ord_ind;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001327 };
1328} __packed;
1329
Kalle Valo5e3dd152013-06-12 20:52:10 +03001330/*** host side structures follow ***/
1331
1332struct htt_tx_done {
1333 u32 msdu_id;
1334 bool discard;
1335 bool no_ack;
Sujith Manoharan55314fc2015-04-01 22:53:21 +03001336 bool success;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001337};
1338
1339struct htt_peer_map_event {
1340 u8 vdev_id;
1341 u16 peer_id;
1342 u8 addr[ETH_ALEN];
1343};
1344
1345struct htt_peer_unmap_event {
1346 u16 peer_id;
1347};
1348
Michal Kaziora16942e2014-02-27 18:50:04 +02001349struct ath10k_htt_txbuf {
1350 struct htt_data_tx_desc_frag frags[2];
1351 struct ath10k_htc_hdr htc_hdr;
1352 struct htt_cmd_hdr cmd_hdr;
1353 struct htt_data_tx_desc cmd_tx;
1354} __packed;
1355
Kalle Valo5e3dd152013-06-12 20:52:10 +03001356struct ath10k_htt {
1357 struct ath10k *ar;
1358 enum ath10k_htc_ep_id eid;
1359
Kalle Valo5e3dd152013-06-12 20:52:10 +03001360 u8 target_version_major;
1361 u8 target_version_minor;
1362 struct completion target_version_received;
Rajkumar Manoharan8348db22015-03-25 13:12:27 +02001363 enum ath10k_fw_htt_op_version op_version;
1364
1365 const enum htt_t2h_msg_type *t2h_msg_types;
1366 u32 t2h_msg_types_max;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001367
1368 struct {
1369 /*
1370 * Ring of network buffer objects - This ring is
1371 * used exclusively by the host SW. This ring
1372 * mirrors the dev_addrs_ring that is shared
1373 * between the host SW and the MAC HW. The host SW
1374 * uses this netbufs ring to locate the network
1375 * buffer objects whose data buffers the HW has
1376 * filled.
1377 */
1378 struct sk_buff **netbufs_ring;
Michal Kaziorc5450702015-01-24 12:14:48 +02001379
1380 /* This is used only with firmware supporting IN_ORD_IND.
1381 *
1382 * With Full Rx Reorder the HTT Rx Ring is more of a temporary
1383 * buffer ring from which buffer addresses are copied by the
1384 * firmware to MAC Rx ring. Firmware then delivers IN_ORD_IND
1385 * pointing to specific (re-ordered) buffers.
1386 *
1387 * FIXME: With kernel generic hashing functions there's a lot
1388 * of hash collisions for sk_buffs.
1389 */
1390 bool in_ord_rx;
1391 DECLARE_HASHTABLE(skb_table, 4);
1392
Kalle Valo5e3dd152013-06-12 20:52:10 +03001393 /*
1394 * Ring of buffer addresses -
1395 * This ring holds the "physical" device address of the
1396 * rx buffers the host SW provides for the MAC HW to
1397 * fill.
1398 */
1399 __le32 *paddrs_ring;
1400
1401 /*
1402 * Base address of ring, as a "physical" device address
1403 * rather than a CPU address.
1404 */
1405 dma_addr_t base_paddr;
1406
1407 /* how many elems in the ring (power of 2) */
1408 int size;
1409
1410 /* size - 1 */
1411 unsigned size_mask;
1412
1413 /* how many rx buffers to keep in the ring */
1414 int fill_level;
1415
1416 /* how many rx buffers (full+empty) are in the ring */
1417 int fill_cnt;
1418
1419 /*
1420 * alloc_idx - where HTT SW has deposited empty buffers
1421 * This is allocated in consistent mem, so that the FW can
1422 * read this variable, and program the HW's FW_IDX reg with
1423 * the value of this shadow register.
1424 */
1425 struct {
1426 __le32 *vaddr;
1427 dma_addr_t paddr;
1428 } alloc_idx;
1429
1430 /* where HTT SW has processed bufs filled by rx MAC DMA */
1431 struct {
1432 unsigned msdu_payld;
1433 } sw_rd_idx;
1434
1435 /*
1436 * refill_retry_timer - timer triggered when the ring is
1437 * not refilled to the level expected
1438 */
1439 struct timer_list refill_retry_timer;
1440
1441 /* Protects access to all rx ring buffer state variables */
1442 spinlock_t lock;
1443 } rx_ring;
1444
1445 unsigned int prefetch_len;
1446
Michal Kazior89d6d832015-01-24 12:14:51 +02001447 /* Protects access to pending_tx, num_pending_tx */
Kalle Valo5e3dd152013-06-12 20:52:10 +03001448 spinlock_t tx_lock;
1449 int max_num_pending_tx;
1450 int num_pending_tx;
Michal Kazior89d6d832015-01-24 12:14:51 +02001451 struct idr pending_tx;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001452 wait_queue_head_t empty_tx_wq;
Michal Kaziora16942e2014-02-27 18:50:04 +02001453 struct dma_pool *tx_pool;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001454
1455 /* set if host-fw communication goes haywire
1456 * used to avoid further failures */
1457 bool rx_confused;
Michal Kazior6e712d42013-09-24 10:18:36 +02001458 struct tasklet_struct rx_replenish_task;
Michal Kazior6c5151a2014-02-27 18:50:04 +02001459
1460 /* This is used to group tx/rx completions separately and process them
1461 * in batches to reduce cache stalls */
1462 struct tasklet_struct txrx_compl_task;
1463 struct sk_buff_head tx_compl_q;
1464 struct sk_buff_head rx_compl_q;
Michal Kaziorc5450702015-01-24 12:14:48 +02001465 struct sk_buff_head rx_in_ord_compl_q;
Janusz Dziedzic6df92a32014-03-24 21:24:57 +01001466
1467 /* rx_status template */
1468 struct ieee80211_rx_status rx_status;
Kalle Valo5e3dd152013-06-12 20:52:10 +03001469};
1470
1471#define RX_HTT_HDR_STATUS_LEN 64
1472
1473/* This structure layout is programmed via rx ring setup
1474 * so that FW knows how to transfer the rx descriptor to the host.
1475 * Buffers like this are placed on the rx ring. */
1476struct htt_rx_desc {
1477 union {
1478 /* This field is filled on the host using the msdu buffer
1479 * from htt_rx_indication */
1480 struct fw_rx_desc_base fw_desc;
1481 u32 pad;
1482 } __packed;
1483 struct {
1484 struct rx_attention attention;
1485 struct rx_frag_info frag_info;
1486 struct rx_mpdu_start mpdu_start;
1487 struct rx_msdu_start msdu_start;
1488 struct rx_msdu_end msdu_end;
1489 struct rx_mpdu_end mpdu_end;
1490 struct rx_ppdu_start ppdu_start;
1491 struct rx_ppdu_end ppdu_end;
1492 } __packed;
1493 u8 rx_hdr_status[RX_HTT_HDR_STATUS_LEN];
1494 u8 msdu_payload[0];
1495};
1496
1497#define HTT_RX_DESC_ALIGN 8
1498
1499#define HTT_MAC_ADDR_LEN 6
1500
1501/*
1502 * FIX THIS
1503 * Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size,
1504 * rounded up to a cache line size.
1505 */
1506#define HTT_RX_BUF_SIZE 1920
1507#define HTT_RX_MSDU_SIZE (HTT_RX_BUF_SIZE - (int)sizeof(struct htt_rx_desc))
1508
Michal Kazior6e712d42013-09-24 10:18:36 +02001509/* Refill a bunch of RX buffers for each refill round so that FW/HW can handle
1510 * aggregated traffic more nicely. */
1511#define ATH10K_HTT_MAX_NUM_REFILL 16
1512
Kalle Valo5e3dd152013-06-12 20:52:10 +03001513/*
1514 * DMA_MAP expects the buffer to be an integral number of cache lines.
1515 * Rather than checking the actual cache line size, this code makes a
1516 * conservative estimate of what the cache line size could be.
1517 */
1518#define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */
1519#define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1)
1520
Michal Kazior95bf21f2014-05-16 17:15:39 +03001521int ath10k_htt_connect(struct ath10k_htt *htt);
1522int ath10k_htt_init(struct ath10k *ar);
1523int ath10k_htt_setup(struct ath10k_htt *htt);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001524
Michal Kazior95bf21f2014-05-16 17:15:39 +03001525int ath10k_htt_tx_alloc(struct ath10k_htt *htt);
1526void ath10k_htt_tx_free(struct ath10k_htt *htt);
1527
1528int ath10k_htt_rx_alloc(struct ath10k_htt *htt);
Michal Kaziorc5450702015-01-24 12:14:48 +02001529int ath10k_htt_rx_ring_refill(struct ath10k *ar);
Michal Kazior95bf21f2014-05-16 17:15:39 +03001530void ath10k_htt_rx_free(struct ath10k_htt *htt);
1531
Kalle Valo5e3dd152013-06-12 20:52:10 +03001532void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb);
1533void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
1534int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
Kalle Valoa3d135e2013-09-03 11:44:10 +03001535int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u8 mask, u64 cookie);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001536int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt);
Janusz Dziedzicd3856232014-06-02 21:19:46 +03001537int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
1538 u8 max_subfrms_ampdu,
1539 u8 max_subfrms_amsdu);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001540
1541void __ath10k_htt_tx_dec_pending(struct ath10k_htt *htt);
Michal Kazior89d6d832015-01-24 12:14:51 +02001542int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt, struct sk_buff *skb);
Kalle Valo5e3dd152013-06-12 20:52:10 +03001543void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id);
1544int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *);
1545int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *);
Michal Kazior6c5151a2014-02-27 18:50:04 +02001546
Kalle Valo5e3dd152013-06-12 20:52:10 +03001547#endif