Loading...
1/* SPDX-License-Identifier: ISC */
2/*
3 * Copyright (c) 2005-2011 Atheros Communications Inc.
4 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
6 * Copyright (c) 2021, 2023 Qualcomm Innovation Center, Inc. All rights reserved.
7 */
8
9#ifndef _HTT_H_
10#define _HTT_H_
11
12#include <linux/bug.h>
13#include <linux/interrupt.h>
14#include <linux/dmapool.h>
15#include <linux/hashtable.h>
16#include <linux/kfifo.h>
17#include <net/mac80211.h>
18
19#include "htc.h"
20#include "hw.h"
21#include "rx_desc.h"
22
23enum htt_dbg_stats_type {
24 HTT_DBG_STATS_WAL_PDEV_TXRX = 1 << 0,
25 HTT_DBG_STATS_RX_REORDER = 1 << 1,
26 HTT_DBG_STATS_RX_RATE_INFO = 1 << 2,
27 HTT_DBG_STATS_TX_PPDU_LOG = 1 << 3,
28 HTT_DBG_STATS_TX_RATE_INFO = 1 << 4,
29 /* bits 5-23 currently reserved */
30
31 HTT_DBG_NUM_STATS /* keep this last */
32};
33
34enum htt_h2t_msg_type { /* host-to-target */
35 HTT_H2T_MSG_TYPE_VERSION_REQ = 0,
36 HTT_H2T_MSG_TYPE_TX_FRM = 1,
37 HTT_H2T_MSG_TYPE_RX_RING_CFG = 2,
38 HTT_H2T_MSG_TYPE_STATS_REQ = 3,
39 HTT_H2T_MSG_TYPE_SYNC = 4,
40 HTT_H2T_MSG_TYPE_AGGR_CFG = 5,
41 HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG = 6,
42
43 /* This command is used for sending management frames in HTT < 3.0.
44 * HTT >= 3.0 uses TX_FRM for everything.
45 */
46 HTT_H2T_MSG_TYPE_MGMT_TX = 7,
47 HTT_H2T_MSG_TYPE_TX_FETCH_RESP = 11,
48
49 HTT_H2T_NUM_MSGS /* keep this last */
50};
51
52struct htt_cmd_hdr {
53 u8 msg_type;
54} __packed;
55
56struct htt_ver_req {
57 u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
58} __packed;
59
60/*
61 * HTT tx MSDU descriptor
62 *
63 * The HTT tx MSDU descriptor is created by the host HTT SW for each
64 * tx MSDU. The HTT tx MSDU descriptor contains the information that
65 * the target firmware needs for the FW's tx processing, particularly
66 * for creating the HW msdu descriptor.
67 * The same HTT tx descriptor is used for HL and LL systems, though
68 * a few fields within the tx descriptor are used only by LL or
69 * only by HL.
70 * The HTT tx descriptor is defined in two manners: by a struct with
71 * bitfields, and by a series of [dword offset, bit mask, bit shift]
72 * definitions.
73 * The target should use the struct def, for simplicity and clarity,
74 * but the host shall use the bit-mast + bit-shift defs, to be endian-
75 * neutral. Specifically, the host shall use the get/set macros built
76 * around the mask + shift defs.
77 */
78struct htt_data_tx_desc_frag {
79 union {
80 struct double_word_addr {
81 __le32 paddr;
82 __le32 len;
83 } __packed dword_addr;
84 struct triple_word_addr {
85 __le32 paddr_lo;
86 __le16 paddr_hi;
87 __le16 len_16;
88 } __packed tword_addr;
89 } __packed;
90} __packed;
91
92struct htt_msdu_ext_desc {
93 __le32 tso_flag[3];
94 __le16 ip_identification;
95 u8 flags;
96 u8 reserved;
97 struct htt_data_tx_desc_frag frags[6];
98};
99
100struct htt_msdu_ext_desc_64 {
101 __le32 tso_flag[5];
102 __le16 ip_identification;
103 u8 flags;
104 u8 reserved;
105 struct htt_data_tx_desc_frag frags[6];
106};
107
108#define HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE BIT(0)
109#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE BIT(1)
110#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE BIT(2)
111#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE BIT(3)
112#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE BIT(4)
113
114#define HTT_MSDU_CHECKSUM_ENABLE (HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE \
115 | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE \
116 | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE \
117 | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE \
118 | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE)
119
120#define HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE_64 BIT(16)
121#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE_64 BIT(17)
122#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE_64 BIT(18)
123#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE_64 BIT(19)
124#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE_64 BIT(20)
125#define HTT_MSDU_EXT_DESC_FLAG_PARTIAL_CSUM_ENABLE_64 BIT(21)
126
127#define HTT_MSDU_CHECKSUM_ENABLE_64 (HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE_64 \
128 | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE_64 \
129 | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE_64 \
130 | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE_64 \
131 | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE_64)
132
133enum htt_data_tx_desc_flags0 {
134 HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT = 1 << 0,
135 HTT_DATA_TX_DESC_FLAGS0_NO_AGGR = 1 << 1,
136 HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT = 1 << 2,
137 HTT_DATA_TX_DESC_FLAGS0_NO_CLASSIFY = 1 << 3,
138 HTT_DATA_TX_DESC_FLAGS0_RSVD0 = 1 << 4
139#define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_MASK 0xE0
140#define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_LSB 5
141};
142
143enum htt_data_tx_desc_flags1 {
144#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_BITS 6
145#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_MASK 0x003F
146#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_LSB 0
147#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_BITS 5
148#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_MASK 0x07C0
149#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_LSB 6
150 HTT_DATA_TX_DESC_FLAGS1_POSTPONED = 1 << 11,
151 HTT_DATA_TX_DESC_FLAGS1_MORE_IN_BATCH = 1 << 12,
152 HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD = 1 << 13,
153 HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD = 1 << 14,
154 HTT_DATA_TX_DESC_FLAGS1_TX_COMPLETE = 1 << 15
155};
156
157#define HTT_TX_CREDIT_DELTA_ABS_M 0xffff0000
158#define HTT_TX_CREDIT_DELTA_ABS_S 16
159#define HTT_TX_CREDIT_DELTA_ABS_GET(word) \
160 (((word) & HTT_TX_CREDIT_DELTA_ABS_M) >> HTT_TX_CREDIT_DELTA_ABS_S)
161
162#define HTT_TX_CREDIT_SIGN_BIT_M 0x00000100
163#define HTT_TX_CREDIT_SIGN_BIT_S 8
164#define HTT_TX_CREDIT_SIGN_BIT_GET(word) \
165 (((word) & HTT_TX_CREDIT_SIGN_BIT_M) >> HTT_TX_CREDIT_SIGN_BIT_S)
166
167enum htt_data_tx_ext_tid {
168 HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST = 16,
169 HTT_DATA_TX_EXT_TID_MGMT = 17,
170 HTT_DATA_TX_EXT_TID_INVALID = 31
171};
172
173#define HTT_INVALID_PEERID 0xFFFF
174
175/*
176 * htt_data_tx_desc - used for data tx path
177 *
178 * Note: vdev_id irrelevant for pkt_type == raw and no_classify == 1.
179 * ext_tid: for qos-data frames (0-15), see %HTT_DATA_TX_EXT_TID_
180 * for special kinds of tids
181 * postponed: only for HL hosts. indicates if this is a resend
182 * (HL hosts manage queues on the host )
183 * more_in_batch: only for HL hosts. indicates if more packets are
184 * pending. this allows target to wait and aggregate
185 * freq: 0 means home channel of given vdev. intended for offchannel
186 */
187struct htt_data_tx_desc {
188 u8 flags0; /* %HTT_DATA_TX_DESC_FLAGS0_ */
189 __le16 flags1; /* %HTT_DATA_TX_DESC_FLAGS1_ */
190 __le16 len;
191 __le16 id;
192 __le32 frags_paddr;
193 union {
194 __le32 peerid;
195 struct {
196 __le16 peerid;
197 __le16 freq;
198 } __packed offchan_tx;
199 } __packed;
200 u8 prefetch[0]; /* start of frame, for FW classification engine */
201} __packed;
202
203struct htt_data_tx_desc_64 {
204 u8 flags0; /* %HTT_DATA_TX_DESC_FLAGS0_ */
205 __le16 flags1; /* %HTT_DATA_TX_DESC_FLAGS1_ */
206 __le16 len;
207 __le16 id;
208 __le64 frags_paddr;
209 union {
210 __le32 peerid;
211 struct {
212 __le16 peerid;
213 __le16 freq;
214 } __packed offchan_tx;
215 } __packed;
216 u8 prefetch[0]; /* start of frame, for FW classification engine */
217} __packed;
218
219enum htt_rx_ring_flags {
220 HTT_RX_RING_FLAGS_MAC80211_HDR = 1 << 0,
221 HTT_RX_RING_FLAGS_MSDU_PAYLOAD = 1 << 1,
222 HTT_RX_RING_FLAGS_PPDU_START = 1 << 2,
223 HTT_RX_RING_FLAGS_PPDU_END = 1 << 3,
224 HTT_RX_RING_FLAGS_MPDU_START = 1 << 4,
225 HTT_RX_RING_FLAGS_MPDU_END = 1 << 5,
226 HTT_RX_RING_FLAGS_MSDU_START = 1 << 6,
227 HTT_RX_RING_FLAGS_MSDU_END = 1 << 7,
228 HTT_RX_RING_FLAGS_RX_ATTENTION = 1 << 8,
229 HTT_RX_RING_FLAGS_FRAG_INFO = 1 << 9,
230 HTT_RX_RING_FLAGS_UNICAST_RX = 1 << 10,
231 HTT_RX_RING_FLAGS_MULTICAST_RX = 1 << 11,
232 HTT_RX_RING_FLAGS_CTRL_RX = 1 << 12,
233 HTT_RX_RING_FLAGS_MGMT_RX = 1 << 13,
234 HTT_RX_RING_FLAGS_NULL_RX = 1 << 14,
235 HTT_RX_RING_FLAGS_PHY_DATA_RX = 1 << 15
236};
237
238#define HTT_RX_RING_SIZE_MIN 128
239#define HTT_RX_RING_SIZE_MAX 2048
240#define HTT_RX_RING_SIZE HTT_RX_RING_SIZE_MAX
241#define HTT_RX_RING_FILL_LEVEL (((HTT_RX_RING_SIZE) / 2) - 1)
242#define HTT_RX_RING_FILL_LEVEL_DUAL_MAC (HTT_RX_RING_SIZE - 1)
243
244struct htt_rx_ring_rx_desc_offsets {
245 /* the following offsets are in 4-byte units */
246 __le16 mac80211_hdr_offset;
247 __le16 msdu_payload_offset;
248 __le16 ppdu_start_offset;
249 __le16 ppdu_end_offset;
250 __le16 mpdu_start_offset;
251 __le16 mpdu_end_offset;
252 __le16 msdu_start_offset;
253 __le16 msdu_end_offset;
254 __le16 rx_attention_offset;
255 __le16 frag_info_offset;
256} __packed;
257
258struct htt_rx_ring_setup_ring32 {
259 __le32 fw_idx_shadow_reg_paddr;
260 __le32 rx_ring_base_paddr;
261 __le16 rx_ring_len; /* in 4-byte words */
262 __le16 rx_ring_bufsize; /* rx skb size - in bytes */
263 __le16 flags; /* %HTT_RX_RING_FLAGS_ */
264 __le16 fw_idx_init_val;
265
266 struct htt_rx_ring_rx_desc_offsets offsets;
267} __packed;
268
269struct htt_rx_ring_setup_ring64 {
270 __le64 fw_idx_shadow_reg_paddr;
271 __le64 rx_ring_base_paddr;
272 __le16 rx_ring_len; /* in 4-byte words */
273 __le16 rx_ring_bufsize; /* rx skb size - in bytes */
274 __le16 flags; /* %HTT_RX_RING_FLAGS_ */
275 __le16 fw_idx_init_val;
276
277 struct htt_rx_ring_rx_desc_offsets offsets;
278} __packed;
279
280struct htt_rx_ring_setup_hdr {
281 u8 num_rings; /* supported values: 1, 2 */
282 __le16 rsvd0;
283} __packed;
284
285struct htt_rx_ring_setup_32 {
286 struct htt_rx_ring_setup_hdr hdr;
287 struct htt_rx_ring_setup_ring32 rings[];
288} __packed;
289
290struct htt_rx_ring_setup_64 {
291 struct htt_rx_ring_setup_hdr hdr;
292 struct htt_rx_ring_setup_ring64 rings[];
293} __packed;
294
295/*
296 * htt_stats_req - request target to send specified statistics
297 *
298 * @msg_type: hardcoded %HTT_H2T_MSG_TYPE_STATS_REQ
299 * @upload_types: see %htt_dbg_stats_type. this is 24bit field actually
300 * so make sure its little-endian.
301 * @reset_types: see %htt_dbg_stats_type. this is 24bit field actually
302 * so make sure its little-endian.
303 * @cfg_val: stat_type specific configuration
304 * @stat_type: see %htt_dbg_stats_type
305 * @cookie_lsb: used for confirmation message from target->host
306 * @cookie_msb: ditto as %cookie
307 */
308struct htt_stats_req {
309 u8 upload_types[3];
310 u8 rsvd0;
311 u8 reset_types[3];
312 struct {
313 u8 mpdu_bytes;
314 u8 mpdu_num_msdus;
315 u8 msdu_bytes;
316 } __packed;
317 u8 stat_type;
318 __le32 cookie_lsb;
319 __le32 cookie_msb;
320} __packed;
321
322#define HTT_STATS_REQ_CFG_STAT_TYPE_INVALID 0xff
323#define HTT_STATS_BIT_MASK GENMASK(16, 0)
324
325/*
326 * htt_oob_sync_req - request out-of-band sync
327 *
328 * The HTT SYNC tells the target to suspend processing of subsequent
329 * HTT host-to-target messages until some other target agent locally
330 * informs the target HTT FW that the current sync counter is equal to
331 * or greater than (in a modulo sense) the sync counter specified in
332 * the SYNC message.
333 *
334 * This allows other host-target components to synchronize their operation
335 * with HTT, e.g. to ensure that tx frames don't get transmitted until a
336 * security key has been downloaded to and activated by the target.
337 * In the absence of any explicit synchronization counter value
338 * specification, the target HTT FW will use zero as the default current
339 * sync value.
340 *
341 * The HTT target FW will suspend its host->target message processing as long
342 * as 0 < (in-band sync counter - out-of-band sync counter) & 0xff < 128.
343 */
344struct htt_oob_sync_req {
345 u8 sync_count;
346 __le16 rsvd0;
347} __packed;
348
349struct htt_aggr_conf {
350 u8 max_num_ampdu_subframes;
351 /* amsdu_subframes is limited by 0x1F mask */
352 u8 max_num_amsdu_subframes;
353} __packed;
354
355struct htt_aggr_conf_v2 {
356 u8 max_num_ampdu_subframes;
357 /* amsdu_subframes is limited by 0x1F mask */
358 u8 max_num_amsdu_subframes;
359 u8 reserved;
360} __packed;
361
362#define HTT_MGMT_FRM_HDR_DOWNLOAD_LEN 32
363struct htt_mgmt_tx_desc_qca99x0 {
364 __le32 rate;
365} __packed;
366
367struct htt_mgmt_tx_desc {
368 u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
369 __le32 msdu_paddr;
370 __le32 desc_id;
371 __le32 len;
372 __le32 vdev_id;
373 u8 hdr[HTT_MGMT_FRM_HDR_DOWNLOAD_LEN];
374 union {
375 struct htt_mgmt_tx_desc_qca99x0 qca99x0;
376 } __packed;
377} __packed;
378
379enum htt_mgmt_tx_status {
380 HTT_MGMT_TX_STATUS_OK = 0,
381 HTT_MGMT_TX_STATUS_RETRY = 1,
382 HTT_MGMT_TX_STATUS_DROP = 2
383};
384
385/*=== target -> host messages ===============================================*/
386
387enum htt_main_t2h_msg_type {
388 HTT_MAIN_T2H_MSG_TYPE_VERSION_CONF = 0x0,
389 HTT_MAIN_T2H_MSG_TYPE_RX_IND = 0x1,
390 HTT_MAIN_T2H_MSG_TYPE_RX_FLUSH = 0x2,
391 HTT_MAIN_T2H_MSG_TYPE_PEER_MAP = 0x3,
392 HTT_MAIN_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
393 HTT_MAIN_T2H_MSG_TYPE_RX_ADDBA = 0x5,
394 HTT_MAIN_T2H_MSG_TYPE_RX_DELBA = 0x6,
395 HTT_MAIN_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
396 HTT_MAIN_T2H_MSG_TYPE_PKTLOG = 0x8,
397 HTT_MAIN_T2H_MSG_TYPE_STATS_CONF = 0x9,
398 HTT_MAIN_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
399 HTT_MAIN_T2H_MSG_TYPE_SEC_IND = 0xb,
400 HTT_MAIN_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
401 HTT_MAIN_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
402 HTT_MAIN_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0xf,
403 HTT_MAIN_T2H_MSG_TYPE_RX_PN_IND = 0x10,
404 HTT_MAIN_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,
405 HTT_MAIN_T2H_MSG_TYPE_TEST,
406 /* keep this last */
407 HTT_MAIN_T2H_NUM_MSGS
408};
409
410enum htt_10x_t2h_msg_type {
411 HTT_10X_T2H_MSG_TYPE_VERSION_CONF = 0x0,
412 HTT_10X_T2H_MSG_TYPE_RX_IND = 0x1,
413 HTT_10X_T2H_MSG_TYPE_RX_FLUSH = 0x2,
414 HTT_10X_T2H_MSG_TYPE_PEER_MAP = 0x3,
415 HTT_10X_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
416 HTT_10X_T2H_MSG_TYPE_RX_ADDBA = 0x5,
417 HTT_10X_T2H_MSG_TYPE_RX_DELBA = 0x6,
418 HTT_10X_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
419 HTT_10X_T2H_MSG_TYPE_PKTLOG = 0x8,
420 HTT_10X_T2H_MSG_TYPE_STATS_CONF = 0x9,
421 HTT_10X_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
422 HTT_10X_T2H_MSG_TYPE_SEC_IND = 0xb,
423 HTT_10X_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,
424 HTT_10X_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
425 HTT_10X_T2H_MSG_TYPE_TEST = 0xe,
426 HTT_10X_T2H_MSG_TYPE_CHAN_CHANGE = 0xf,
427 HTT_10X_T2H_MSG_TYPE_AGGR_CONF = 0x11,
428 HTT_10X_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x12,
429 HTT_10X_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0x13,
430 /* keep this last */
431 HTT_10X_T2H_NUM_MSGS
432};
433
434enum htt_tlv_t2h_msg_type {
435 HTT_TLV_T2H_MSG_TYPE_VERSION_CONF = 0x0,
436 HTT_TLV_T2H_MSG_TYPE_RX_IND = 0x1,
437 HTT_TLV_T2H_MSG_TYPE_RX_FLUSH = 0x2,
438 HTT_TLV_T2H_MSG_TYPE_PEER_MAP = 0x3,
439 HTT_TLV_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
440 HTT_TLV_T2H_MSG_TYPE_RX_ADDBA = 0x5,
441 HTT_TLV_T2H_MSG_TYPE_RX_DELBA = 0x6,
442 HTT_TLV_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
443 HTT_TLV_T2H_MSG_TYPE_PKTLOG = 0x8,
444 HTT_TLV_T2H_MSG_TYPE_STATS_CONF = 0x9,
445 HTT_TLV_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
446 HTT_TLV_T2H_MSG_TYPE_SEC_IND = 0xb,
447 HTT_TLV_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc, /* deprecated */
448 HTT_TLV_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
449 HTT_TLV_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
450 HTT_TLV_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0xf,
451 HTT_TLV_T2H_MSG_TYPE_RX_PN_IND = 0x10,
452 HTT_TLV_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,
453 HTT_TLV_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND = 0x12,
454 /* 0x13 reservd */
455 HTT_TLV_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE = 0x14,
456 HTT_TLV_T2H_MSG_TYPE_CHAN_CHANGE = 0x15,
457 HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR = 0x16,
458 HTT_TLV_T2H_MSG_TYPE_TEST,
459 /* keep this last */
460 HTT_TLV_T2H_NUM_MSGS
461};
462
463enum htt_10_4_t2h_msg_type {
464 HTT_10_4_T2H_MSG_TYPE_VERSION_CONF = 0x0,
465 HTT_10_4_T2H_MSG_TYPE_RX_IND = 0x1,
466 HTT_10_4_T2H_MSG_TYPE_RX_FLUSH = 0x2,
467 HTT_10_4_T2H_MSG_TYPE_PEER_MAP = 0x3,
468 HTT_10_4_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
469 HTT_10_4_T2H_MSG_TYPE_RX_ADDBA = 0x5,
470 HTT_10_4_T2H_MSG_TYPE_RX_DELBA = 0x6,
471 HTT_10_4_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
472 HTT_10_4_T2H_MSG_TYPE_PKTLOG = 0x8,
473 HTT_10_4_T2H_MSG_TYPE_STATS_CONF = 0x9,
474 HTT_10_4_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
475 HTT_10_4_T2H_MSG_TYPE_SEC_IND = 0xb,
476 HTT_10_4_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,
477 HTT_10_4_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
478 HTT_10_4_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
479 HTT_10_4_T2H_MSG_TYPE_CHAN_CHANGE = 0xf,
480 HTT_10_4_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0x10,
481 HTT_10_4_T2H_MSG_TYPE_RX_PN_IND = 0x11,
482 HTT_10_4_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x12,
483 HTT_10_4_T2H_MSG_TYPE_TEST = 0x13,
484 HTT_10_4_T2H_MSG_TYPE_EN_STATS = 0x14,
485 HTT_10_4_T2H_MSG_TYPE_AGGR_CONF = 0x15,
486 HTT_10_4_T2H_MSG_TYPE_TX_FETCH_IND = 0x16,
487 HTT_10_4_T2H_MSG_TYPE_TX_FETCH_CONFIRM = 0x17,
488 HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x18,
489 /* 0x19 to 0x2f are reserved */
490 HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND = 0x30,
491 HTT_10_4_T2H_MSG_TYPE_PEER_STATS = 0x31,
492 /* keep this last */
493 HTT_10_4_T2H_NUM_MSGS
494};
495
496enum htt_t2h_msg_type {
497 HTT_T2H_MSG_TYPE_VERSION_CONF,
498 HTT_T2H_MSG_TYPE_RX_IND,
499 HTT_T2H_MSG_TYPE_RX_FLUSH,
500 HTT_T2H_MSG_TYPE_PEER_MAP,
501 HTT_T2H_MSG_TYPE_PEER_UNMAP,
502 HTT_T2H_MSG_TYPE_RX_ADDBA,
503 HTT_T2H_MSG_TYPE_RX_DELBA,
504 HTT_T2H_MSG_TYPE_TX_COMPL_IND,
505 HTT_T2H_MSG_TYPE_PKTLOG,
506 HTT_T2H_MSG_TYPE_STATS_CONF,
507 HTT_T2H_MSG_TYPE_RX_FRAG_IND,
508 HTT_T2H_MSG_TYPE_SEC_IND,
509 HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
510 HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
511 HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
512 HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
513 HTT_T2H_MSG_TYPE_RX_PN_IND,
514 HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
515 HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND,
516 HTT_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE,
517 HTT_T2H_MSG_TYPE_CHAN_CHANGE,
518 HTT_T2H_MSG_TYPE_RX_OFLD_PKT_ERR,
519 HTT_T2H_MSG_TYPE_AGGR_CONF,
520 HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
521 HTT_T2H_MSG_TYPE_TEST,
522 HTT_T2H_MSG_TYPE_EN_STATS,
523 HTT_T2H_MSG_TYPE_TX_FETCH_IND,
524 HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
525 HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
526 HTT_T2H_MSG_TYPE_PEER_STATS,
527 /* keep this last */
528 HTT_T2H_NUM_MSGS
529};
530
531/*
532 * htt_resp_hdr - header for target-to-host messages
533 *
534 * msg_type: see htt_t2h_msg_type
535 */
536struct htt_resp_hdr {
537 u8 msg_type;
538} __packed;
539
540#define HTT_RESP_HDR_MSG_TYPE_OFFSET 0
541#define HTT_RESP_HDR_MSG_TYPE_MASK 0xff
542#define HTT_RESP_HDR_MSG_TYPE_LSB 0
543
544/* htt_ver_resp - response sent for htt_ver_req */
545struct htt_ver_resp {
546 u8 minor;
547 u8 major;
548 u8 rsvd0;
549} __packed;
550
551#define HTT_MGMT_TX_CMPL_FLAG_ACK_RSSI BIT(0)
552
553#define HTT_MGMT_TX_CMPL_INFO_ACK_RSSI_MASK GENMASK(7, 0)
554
555struct htt_mgmt_tx_completion {
556 u8 rsvd0;
557 u8 rsvd1;
558 u8 flags;
559 __le32 desc_id;
560 __le32 status;
561 __le32 ppdu_id;
562 __le32 info;
563} __packed;
564
565#define HTT_RX_INDICATION_INFO0_EXT_TID_MASK (0x1F)
566#define HTT_RX_INDICATION_INFO0_EXT_TID_LSB (0)
567#define HTT_RX_INDICATION_INFO0_FLUSH_VALID (1 << 5)
568#define HTT_RX_INDICATION_INFO0_RELEASE_VALID (1 << 6)
569#define HTT_RX_INDICATION_INFO0_PPDU_DURATION BIT(7)
570
571#define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_MASK 0x0000003F
572#define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_LSB 0
573#define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_MASK 0x00000FC0
574#define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_LSB 6
575#define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_MASK 0x0003F000
576#define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_LSB 12
577#define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_MASK 0x00FC0000
578#define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_LSB 18
579#define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_MASK 0xFF000000
580#define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_LSB 24
581
582#define HTT_TX_CMPL_FLAG_DATA_RSSI BIT(0)
583#define HTT_TX_CMPL_FLAG_PPID_PRESENT BIT(1)
584#define HTT_TX_CMPL_FLAG_PA_PRESENT BIT(2)
585#define HTT_TX_CMPL_FLAG_PPDU_DURATION_PRESENT BIT(3)
586
587#define HTT_TX_DATA_RSSI_ENABLE_WCN3990 BIT(3)
588#define HTT_TX_DATA_APPEND_RETRIES BIT(0)
589#define HTT_TX_DATA_APPEND_TIMESTAMP BIT(1)
590
591struct htt_rx_indication_hdr {
592 u8 info0; /* %HTT_RX_INDICATION_INFO0_ */
593 __le16 peer_id;
594 __le32 info1; /* %HTT_RX_INDICATION_INFO1_ */
595} __packed;
596
597#define HTT_RX_INDICATION_INFO0_PHY_ERR_VALID (1 << 0)
598#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_MASK (0x1E)
599#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_LSB (1)
600#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_CCK (1 << 5)
601#define HTT_RX_INDICATION_INFO0_END_VALID (1 << 6)
602#define HTT_RX_INDICATION_INFO0_START_VALID (1 << 7)
603
604#define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_MASK 0x00FFFFFF
605#define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_LSB 0
606#define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_MASK 0xFF000000
607#define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_LSB 24
608
609#define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_MASK 0x00FFFFFF
610#define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_LSB 0
611#define HTT_RX_INDICATION_INFO2_SERVICE_MASK 0xFF000000
612#define HTT_RX_INDICATION_INFO2_SERVICE_LSB 24
613
614enum htt_rx_legacy_rate {
615 HTT_RX_OFDM_48 = 0,
616 HTT_RX_OFDM_24 = 1,
617 HTT_RX_OFDM_12,
618 HTT_RX_OFDM_6,
619 HTT_RX_OFDM_54,
620 HTT_RX_OFDM_36,
621 HTT_RX_OFDM_18,
622 HTT_RX_OFDM_9,
623
624 /* long preamble */
625 HTT_RX_CCK_11_LP = 0,
626 HTT_RX_CCK_5_5_LP = 1,
627 HTT_RX_CCK_2_LP,
628 HTT_RX_CCK_1_LP,
629 /* short preamble */
630 HTT_RX_CCK_11_SP,
631 HTT_RX_CCK_5_5_SP,
632 HTT_RX_CCK_2_SP
633};
634
635enum htt_rx_legacy_rate_type {
636 HTT_RX_LEGACY_RATE_OFDM = 0,
637 HTT_RX_LEGACY_RATE_CCK
638};
639
640enum htt_rx_preamble_type {
641 HTT_RX_LEGACY = 0x4,
642 HTT_RX_HT = 0x8,
643 HTT_RX_HT_WITH_TXBF = 0x9,
644 HTT_RX_VHT = 0xC,
645 HTT_RX_VHT_WITH_TXBF = 0xD,
646};
647
648/*
649 * Fields: phy_err_valid, phy_err_code, tsf,
650 * usec_timestamp, sub_usec_timestamp
651 * ..are valid only if end_valid == 1.
652 *
653 * Fields: rssi_chains, legacy_rate_type,
654 * legacy_rate_cck, preamble_type, service,
655 * vht_sig_*
656 * ..are valid only if start_valid == 1;
657 */
658struct htt_rx_indication_ppdu {
659 u8 combined_rssi;
660 u8 sub_usec_timestamp;
661 u8 phy_err_code;
662 u8 info0; /* HTT_RX_INDICATION_INFO0_ */
663 struct {
664 u8 pri20_db;
665 u8 ext20_db;
666 u8 ext40_db;
667 u8 ext80_db;
668 } __packed rssi_chains[4];
669 __le32 tsf;
670 __le32 usec_timestamp;
671 __le32 info1; /* HTT_RX_INDICATION_INFO1_ */
672 __le32 info2; /* HTT_RX_INDICATION_INFO2_ */
673} __packed;
674
675enum htt_rx_mpdu_status {
676 HTT_RX_IND_MPDU_STATUS_UNKNOWN = 0x0,
677 HTT_RX_IND_MPDU_STATUS_OK,
678 HTT_RX_IND_MPDU_STATUS_ERR_FCS,
679 HTT_RX_IND_MPDU_STATUS_ERR_DUP,
680 HTT_RX_IND_MPDU_STATUS_ERR_REPLAY,
681 HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER,
682 /* only accept EAPOL frames */
683 HTT_RX_IND_MPDU_STATUS_UNAUTH_PEER,
684 HTT_RX_IND_MPDU_STATUS_OUT_OF_SYNC,
685 /* Non-data in promiscuous mode */
686 HTT_RX_IND_MPDU_STATUS_MGMT_CTRL,
687 HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR,
688 HTT_RX_IND_MPDU_STATUS_DECRYPT_ERR,
689 HTT_RX_IND_MPDU_STATUS_MPDU_LENGTH_ERR,
690 HTT_RX_IND_MPDU_STATUS_ENCRYPT_REQUIRED_ERR,
691 HTT_RX_IND_MPDU_STATUS_PRIVACY_ERR,
692
693 /*
694 * MISC: discard for unspecified reasons.
695 * Leave this enum value last.
696 */
697 HTT_RX_IND_MPDU_STATUS_ERR_MISC = 0xFF
698};
699
700struct htt_rx_indication_mpdu_range {
701 u8 mpdu_count;
702 u8 mpdu_range_status; /* %htt_rx_mpdu_status */
703 u8 pad0;
704 u8 pad1;
705} __packed;
706
707struct htt_rx_indication_prefix {
708 __le16 fw_rx_desc_bytes;
709 u8 pad0;
710 u8 pad1;
711} __packed;
712
713struct htt_rx_indication {
714 struct htt_rx_indication_hdr hdr;
715 struct htt_rx_indication_ppdu ppdu;
716 struct htt_rx_indication_prefix prefix;
717
718 /*
719 * the following fields are both dynamically sized, so
720 * take care addressing them
721 */
722
723 /* the size of this is %fw_rx_desc_bytes */
724 struct fw_rx_desc_base fw_desc;
725
726 /*
727 * %mpdu_ranges starts after &%prefix + roundup(%fw_rx_desc_bytes, 4)
728 * and has %num_mpdu_ranges elements.
729 */
730 struct htt_rx_indication_mpdu_range mpdu_ranges[];
731} __packed;
732
733/* High latency version of the RX indication */
734struct htt_rx_indication_hl {
735 struct htt_rx_indication_hdr hdr;
736 struct htt_rx_indication_ppdu ppdu;
737 struct htt_rx_indication_prefix prefix;
738 struct fw_rx_desc_hl fw_desc;
739 struct htt_rx_indication_mpdu_range mpdu_ranges[];
740} __packed;
741
742struct htt_hl_rx_desc {
743 __le32 info;
744 __le32 pn_31_0;
745 union {
746 struct {
747 __le16 pn_47_32;
748 __le16 pn_63_48;
749 } pn16;
750 __le32 pn_63_32;
751 } u0;
752 __le32 pn_95_64;
753 __le32 pn_127_96;
754} __packed;
755
756static inline struct htt_rx_indication_mpdu_range *
757 htt_rx_ind_get_mpdu_ranges(struct htt_rx_indication *rx_ind)
758{
759 void *ptr = rx_ind;
760
761 ptr += sizeof(rx_ind->hdr)
762 + sizeof(rx_ind->ppdu)
763 + sizeof(rx_ind->prefix)
764 + roundup(__le16_to_cpu(rx_ind->prefix.fw_rx_desc_bytes), 4);
765 return ptr;
766}
767
768static inline struct htt_rx_indication_mpdu_range *
769 htt_rx_ind_get_mpdu_ranges_hl(struct htt_rx_indication_hl *rx_ind)
770{
771 void *ptr = rx_ind;
772
773 ptr += sizeof(rx_ind->hdr)
774 + sizeof(rx_ind->ppdu)
775 + sizeof(rx_ind->prefix)
776 + sizeof(rx_ind->fw_desc);
777 return ptr;
778}
779
780enum htt_rx_flush_mpdu_status {
781 HTT_RX_FLUSH_MPDU_DISCARD = 0,
782 HTT_RX_FLUSH_MPDU_REORDER = 1,
783};
784
785/*
786 * htt_rx_flush - discard or reorder given range of mpdus
787 *
788 * Note: host must check if all sequence numbers between
789 * [seq_num_start, seq_num_end-1] are valid.
790 */
791struct htt_rx_flush {
792 __le16 peer_id;
793 u8 tid;
794 u8 rsvd0;
795 u8 mpdu_status; /* %htt_rx_flush_mpdu_status */
796 u8 seq_num_start; /* it is 6 LSBs of 802.11 seq no */
797 u8 seq_num_end; /* it is 6 LSBs of 802.11 seq no */
798};
799
800struct htt_rx_peer_map {
801 u8 vdev_id;
802 __le16 peer_id;
803 u8 addr[6];
804 u8 rsvd0;
805 u8 rsvd1;
806} __packed;
807
808struct htt_rx_peer_unmap {
809 u8 rsvd0;
810 __le16 peer_id;
811} __packed;
812
813enum htt_txrx_sec_cast_type {
814 HTT_TXRX_SEC_MCAST = 0,
815 HTT_TXRX_SEC_UCAST
816};
817
818enum htt_rx_pn_check_type {
819 HTT_RX_NON_PN_CHECK = 0,
820 HTT_RX_PN_CHECK
821};
822
823enum htt_rx_tkip_demic_type {
824 HTT_RX_NON_TKIP_MIC = 0,
825 HTT_RX_TKIP_MIC
826};
827
828enum htt_security_types {
829 HTT_SECURITY_NONE,
830 HTT_SECURITY_WEP128,
831 HTT_SECURITY_WEP104,
832 HTT_SECURITY_WEP40,
833 HTT_SECURITY_TKIP,
834 HTT_SECURITY_TKIP_NOMIC,
835 HTT_SECURITY_AES_CCMP,
836 HTT_SECURITY_WAPI,
837
838 HTT_NUM_SECURITY_TYPES /* keep this last! */
839};
840
841#define ATH10K_HTT_TXRX_PEER_SECURITY_MAX 2
842#define ATH10K_TXRX_NUM_EXT_TIDS 19
843#define ATH10K_TXRX_NON_QOS_TID 16
844
845enum htt_security_flags {
846#define HTT_SECURITY_TYPE_MASK 0x7F
847#define HTT_SECURITY_TYPE_LSB 0
848 HTT_SECURITY_IS_UNICAST = 1 << 7
849};
850
851struct htt_security_indication {
852 union {
853 /* dont use bitfields; undefined behaviour */
854 u8 flags; /* %htt_security_flags */
855 struct {
856 u8 security_type:7, /* %htt_security_types */
857 is_unicast:1;
858 } __packed;
859 } __packed;
860 __le16 peer_id;
861 u8 michael_key[8];
862 u8 wapi_rsc[16];
863} __packed;
864
865#define HTT_RX_BA_INFO0_TID_MASK 0x000F
866#define HTT_RX_BA_INFO0_TID_LSB 0
867#define HTT_RX_BA_INFO0_PEER_ID_MASK 0xFFF0
868#define HTT_RX_BA_INFO0_PEER_ID_LSB 4
869
870struct htt_rx_addba {
871 u8 window_size;
872 __le16 info0; /* %HTT_RX_BA_INFO0_ */
873} __packed;
874
875struct htt_rx_delba {
876 u8 rsvd0;
877 __le16 info0; /* %HTT_RX_BA_INFO0_ */
878} __packed;
879
880enum htt_data_tx_status {
881 HTT_DATA_TX_STATUS_OK = 0,
882 HTT_DATA_TX_STATUS_DISCARD = 1,
883 HTT_DATA_TX_STATUS_NO_ACK = 2,
884 HTT_DATA_TX_STATUS_POSTPONE = 3 /* HL only */
885};
886
887enum htt_data_tx_flags {
888#define HTT_DATA_TX_STATUS_MASK 0x07
889#define HTT_DATA_TX_STATUS_LSB 0
890#define HTT_DATA_TX_TID_MASK 0x78
891#define HTT_DATA_TX_TID_LSB 3
892 HTT_DATA_TX_TID_INVALID = 1 << 7
893};
894
895#define HTT_TX_COMPL_INV_MSDU_ID 0xFFFF
896
897struct htt_append_retries {
898 __le16 msdu_id;
899 u8 tx_retries;
900 u8 flag;
901} __packed;
902
903struct htt_data_tx_completion_ext {
904 struct htt_append_retries a_retries;
905 __le32 t_stamp;
906 __le16 msdus_rssi[];
907} __packed;
908
909/**
910 * @brief target -> host TX completion indication message definition
911 *
912 * @details
913 * The following diagram shows the format of the TX completion indication sent
914 * from the target to the host
915 *
916 * |31 28|27|26|25|24|23 16| 15 |14 11|10 8|7 0|
917 * |-------------------------------------------------------------|
918 * header: |rsvd |A2|TP|A1|A0| num | t_i| tid |status| msg_type |
919 * |-------------------------------------------------------------|
920 * payload: | MSDU1 ID | MSDU0 ID |
921 * |-------------------------------------------------------------|
922 * : MSDU3 ID : MSDU2 ID :
923 * |-------------------------------------------------------------|
924 * | struct htt_tx_compl_ind_append_retries |
925 * |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
926 * | struct htt_tx_compl_ind_append_tx_tstamp |
927 * |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
928 * | MSDU1 ACK RSSI | MSDU0 ACK RSSI |
929 * |-------------------------------------------------------------|
930 * : MSDU3 ACK RSSI : MSDU2 ACK RSSI :
931 * |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
932 * -msg_type
933 * Bits 7:0
934 * Purpose: identifies this as HTT TX completion indication
935 * -status
936 * Bits 10:8
937 * Purpose: the TX completion status of payload fragmentations descriptors
938 * Value: could be HTT_TX_COMPL_IND_STAT_OK or HTT_TX_COMPL_IND_STAT_DISCARD
939 * -tid
940 * Bits 14:11
941 * Purpose: the tid associated with those fragmentation descriptors. It is
942 * valid or not, depending on the tid_invalid bit.
943 * Value: 0 to 15
944 * -tid_invalid
945 * Bits 15:15
946 * Purpose: this bit indicates whether the tid field is valid or not
947 * Value: 0 indicates valid, 1 indicates invalid
948 * -num
949 * Bits 23:16
950 * Purpose: the number of payload in this indication
951 * Value: 1 to 255
952 * -A0 = append
953 * Bits 24:24
954 * Purpose: append the struct htt_tx_compl_ind_append_retries which contains
955 * the number of tx retries for one MSDU at the end of this message
956 * Value: 0 indicates no appending, 1 indicates appending
957 * -A1 = append1
958 * Bits 25:25
959 * Purpose: Append the struct htt_tx_compl_ind_append_tx_tstamp which
960 * contains the timestamp info for each TX msdu id in payload.
961 * Value: 0 indicates no appending, 1 indicates appending
962 * -TP = MSDU tx power presence
963 * Bits 26:26
964 * Purpose: Indicate whether the TX_COMPL_IND includes a tx power report
965 * for each MSDU referenced by the TX_COMPL_IND message.
966 * The order of the per-MSDU tx power reports matches the order
967 * of the MSDU IDs.
968 * Value: 0 indicates not appending, 1 indicates appending
969 * -A2 = append2
970 * Bits 27:27
971 * Purpose: Indicate whether data ACK RSSI is appended for each MSDU in
972 * TX_COMP_IND message. The order of the per-MSDU ACK RSSI report
973 * matches the order of the MSDU IDs.
974 * The ACK RSSI values are valid when status is COMPLETE_OK (and
975 * this append2 bit is set).
976 * Value: 0 indicates not appending, 1 indicates appending
977 */
978
979struct htt_data_tx_completion {
980 union {
981 u8 flags;
982 struct {
983 u8 status:3,
984 tid:4,
985 tid_invalid:1;
986 } __packed;
987 } __packed;
988 u8 num_msdus;
989 u8 flags2; /* HTT_TX_CMPL_FLAG_DATA_RSSI */
990 __le16 msdus[]; /* variable length based on %num_msdus */
991} __packed;
992
993#define HTT_TX_PPDU_DUR_INFO0_PEER_ID_MASK GENMASK(15, 0)
994#define HTT_TX_PPDU_DUR_INFO0_TID_MASK GENMASK(20, 16)
995
996struct htt_data_tx_ppdu_dur {
997 __le32 info0; /* HTT_TX_PPDU_DUR_INFO0_ */
998 __le32 tx_duration; /* in usecs */
999} __packed;
1000
1001#define HTT_TX_COMPL_PPDU_DUR_INFO0_NUM_ENTRIES_MASK GENMASK(7, 0)
1002
1003struct htt_data_tx_compl_ppdu_dur {
1004 __le32 info0; /* HTT_TX_COMPL_PPDU_DUR_INFO0_ */
1005 struct htt_data_tx_ppdu_dur ppdu_dur[];
1006} __packed;
1007
1008struct htt_tx_compl_ind_base {
1009 u32 hdr;
1010 u16 payload[1/*or more*/];
1011} __packed;
1012
1013struct htt_rc_tx_done_params {
1014 u32 rate_code;
1015 u32 rate_code_flags;
1016 u32 flags;
1017 u32 num_enqued; /* 1 for non-AMPDU */
1018 u32 num_retries;
1019 u32 num_failed; /* for AMPDU */
1020 u32 ack_rssi;
1021 u32 time_stamp;
1022 u32 is_probe;
1023};
1024
1025struct htt_rc_update {
1026 u8 vdev_id;
1027 __le16 peer_id;
1028 u8 addr[6];
1029 u8 num_elems;
1030 u8 rsvd0;
1031 struct htt_rc_tx_done_params params[]; /* variable length %num_elems */
1032} __packed;
1033
1034/* see htt_rx_indication for similar fields and descriptions */
1035struct htt_rx_fragment_indication {
1036 union {
1037 u8 info0; /* %HTT_RX_FRAG_IND_INFO0_ */
1038 struct {
1039 u8 ext_tid:5,
1040 flush_valid:1;
1041 } __packed;
1042 } __packed;
1043 __le16 peer_id;
1044 __le32 info1; /* %HTT_RX_FRAG_IND_INFO1_ */
1045 __le16 fw_rx_desc_bytes;
1046 __le16 rsvd0;
1047
1048 u8 fw_msdu_rx_desc[];
1049} __packed;
1050
1051#define ATH10K_IEEE80211_EXTIV BIT(5)
1052#define ATH10K_IEEE80211_TKIP_MICLEN 8 /* trailing MIC */
1053
1054#define HTT_RX_FRAG_IND_INFO0_HEADER_LEN 16
1055
1056#define HTT_RX_FRAG_IND_INFO0_EXT_TID_MASK 0x1F
1057#define HTT_RX_FRAG_IND_INFO0_EXT_TID_LSB 0
1058#define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_MASK 0x20
1059#define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_LSB 5
1060
1061#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_MASK 0x0000003F
1062#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_LSB 0
1063#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_MASK 0x00000FC0
1064#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_LSB 6
1065
1066struct htt_rx_pn_ind {
1067 __le16 peer_id;
1068 u8 tid;
1069 u8 seqno_start;
1070 u8 seqno_end;
1071 u8 pn_ie_count;
1072 u8 reserved;
1073 u8 pn_ies[];
1074} __packed;
1075
1076struct htt_rx_offload_msdu {
1077 __le16 msdu_len;
1078 __le16 peer_id;
1079 u8 vdev_id;
1080 u8 tid;
1081 u8 fw_desc;
1082 u8 payload[];
1083} __packed;
1084
1085struct htt_rx_offload_ind {
1086 u8 reserved;
1087 __le16 msdu_count;
1088} __packed;
1089
1090struct htt_rx_in_ord_msdu_desc {
1091 __le32 msdu_paddr;
1092 __le16 msdu_len;
1093 u8 fw_desc;
1094 u8 reserved;
1095} __packed;
1096
1097struct htt_rx_in_ord_msdu_desc_ext {
1098 __le64 msdu_paddr;
1099 __le16 msdu_len;
1100 u8 fw_desc;
1101 u8 reserved;
1102} __packed;
1103
1104struct htt_rx_in_ord_ind {
1105 u8 info;
1106 __le16 peer_id;
1107 u8 vdev_id;
1108 u8 reserved;
1109 __le16 msdu_count;
1110 union {
1111 DECLARE_FLEX_ARRAY(struct htt_rx_in_ord_msdu_desc,
1112 msdu_descs32);
1113 DECLARE_FLEX_ARRAY(struct htt_rx_in_ord_msdu_desc_ext,
1114 msdu_descs64);
1115 } __packed;
1116} __packed;
1117
1118#define HTT_RX_IN_ORD_IND_INFO_TID_MASK 0x0000001f
1119#define HTT_RX_IN_ORD_IND_INFO_TID_LSB 0
1120#define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_MASK 0x00000020
1121#define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_LSB 5
1122#define HTT_RX_IN_ORD_IND_INFO_FRAG_MASK 0x00000040
1123#define HTT_RX_IN_ORD_IND_INFO_FRAG_LSB 6
1124
1125/*
1126 * target -> host test message definition
1127 *
1128 * The following field definitions describe the format of the test
1129 * message sent from the target to the host.
1130 * The message consists of a 4-octet header, followed by a variable
1131 * number of 32-bit integer values, followed by a variable number
1132 * of 8-bit character values.
1133 *
1134 * |31 16|15 8|7 0|
1135 * |-----------------------------------------------------------|
1136 * | num chars | num ints | msg type |
1137 * |-----------------------------------------------------------|
1138 * | int 0 |
1139 * |-----------------------------------------------------------|
1140 * | int 1 |
1141 * |-----------------------------------------------------------|
1142 * | ... |
1143 * |-----------------------------------------------------------|
1144 * | char 3 | char 2 | char 1 | char 0 |
1145 * |-----------------------------------------------------------|
1146 * | | | ... | char 4 |
1147 * |-----------------------------------------------------------|
1148 * - MSG_TYPE
1149 * Bits 7:0
1150 * Purpose: identifies this as a test message
1151 * Value: HTT_MSG_TYPE_TEST
1152 * - NUM_INTS
1153 * Bits 15:8
1154 * Purpose: indicate how many 32-bit integers follow the message header
1155 * - NUM_CHARS
1156 * Bits 31:16
1157 * Purpose: indicate how many 8-bit characters follow the series of integers
1158 */
1159struct htt_rx_test {
1160 u8 num_ints;
1161 __le16 num_chars;
1162
1163 /* payload consists of 2 lists:
1164 * a) num_ints * sizeof(__le32)
1165 * b) num_chars * sizeof(u8) aligned to 4bytes
1166 */
1167 u8 payload[];
1168} __packed;
1169
1170static inline __le32 *htt_rx_test_get_ints(struct htt_rx_test *rx_test)
1171{
1172 return (__le32 *)rx_test->payload;
1173}
1174
1175static inline u8 *htt_rx_test_get_chars(struct htt_rx_test *rx_test)
1176{
1177 return rx_test->payload + (rx_test->num_ints * sizeof(__le32));
1178}
1179
1180/*
1181 * target -> host packet log message
1182 *
1183 * The following field definitions describe the format of the packet log
1184 * message sent from the target to the host.
1185 * The message consists of a 4-octet header,followed by a variable number
1186 * of 32-bit character values.
1187 *
1188 * |31 24|23 16|15 8|7 0|
1189 * |-----------------------------------------------------------|
1190 * | | | | msg type |
1191 * |-----------------------------------------------------------|
1192 * | payload |
1193 * |-----------------------------------------------------------|
1194 * - MSG_TYPE
1195 * Bits 7:0
1196 * Purpose: identifies this as a test message
1197 * Value: HTT_MSG_TYPE_PACKETLOG
1198 */
1199struct htt_pktlog_msg {
1200 u8 pad[3];
1201 u8 payload[];
1202} __packed;
1203
1204struct htt_dbg_stats_rx_reorder_stats {
1205 /* Non QoS MPDUs received */
1206 __le32 deliver_non_qos;
1207
1208 /* MPDUs received in-order */
1209 __le32 deliver_in_order;
1210
1211 /* Flush due to reorder timer expired */
1212 __le32 deliver_flush_timeout;
1213
1214 /* Flush due to move out of window */
1215 __le32 deliver_flush_oow;
1216
1217 /* Flush due to DELBA */
1218 __le32 deliver_flush_delba;
1219
1220 /* MPDUs dropped due to FCS error */
1221 __le32 fcs_error;
1222
1223 /* MPDUs dropped due to monitor mode non-data packet */
1224 __le32 mgmt_ctrl;
1225
1226 /* MPDUs dropped due to invalid peer */
1227 __le32 invalid_peer;
1228
1229 /* MPDUs dropped due to duplication (non aggregation) */
1230 __le32 dup_non_aggr;
1231
1232 /* MPDUs dropped due to processed before */
1233 __le32 dup_past;
1234
1235 /* MPDUs dropped due to duplicate in reorder queue */
1236 __le32 dup_in_reorder;
1237
1238 /* Reorder timeout happened */
1239 __le32 reorder_timeout;
1240
1241 /* invalid bar ssn */
1242 __le32 invalid_bar_ssn;
1243
1244 /* reorder reset due to bar ssn */
1245 __le32 ssn_reset;
1246};
1247
1248struct htt_dbg_stats_wal_tx_stats {
1249 /* Num HTT cookies queued to dispatch list */
1250 __le32 comp_queued;
1251
1252 /* Num HTT cookies dispatched */
1253 __le32 comp_delivered;
1254
1255 /* Num MSDU queued to WAL */
1256 __le32 msdu_enqued;
1257
1258 /* Num MPDU queue to WAL */
1259 __le32 mpdu_enqued;
1260
1261 /* Num MSDUs dropped by WMM limit */
1262 __le32 wmm_drop;
1263
1264 /* Num Local frames queued */
1265 __le32 local_enqued;
1266
1267 /* Num Local frames done */
1268 __le32 local_freed;
1269
1270 /* Num queued to HW */
1271 __le32 hw_queued;
1272
1273 /* Num PPDU reaped from HW */
1274 __le32 hw_reaped;
1275
1276 /* Num underruns */
1277 __le32 underrun;
1278
1279 /* Num PPDUs cleaned up in TX abort */
1280 __le32 tx_abort;
1281
1282 /* Num MPDUs requeued by SW */
1283 __le32 mpdus_requeued;
1284
1285 /* excessive retries */
1286 __le32 tx_ko;
1287
1288 /* data hw rate code */
1289 __le32 data_rc;
1290
1291 /* Scheduler self triggers */
1292 __le32 self_triggers;
1293
1294 /* frames dropped due to excessive sw retries */
1295 __le32 sw_retry_failure;
1296
1297 /* illegal rate phy errors */
1298 __le32 illgl_rate_phy_err;
1299
1300 /* wal pdev continuous xretry */
1301 __le32 pdev_cont_xretry;
1302
1303 /* wal pdev continuous xretry */
1304 __le32 pdev_tx_timeout;
1305
1306 /* wal pdev resets */
1307 __le32 pdev_resets;
1308
1309 __le32 phy_underrun;
1310
1311 /* MPDU is more than txop limit */
1312 __le32 txop_ovf;
1313} __packed;
1314
1315struct htt_dbg_stats_wal_rx_stats {
1316 /* Cnts any change in ring routing mid-ppdu */
1317 __le32 mid_ppdu_route_change;
1318
1319 /* Total number of statuses processed */
1320 __le32 status_rcvd;
1321
1322 /* Extra frags on rings 0-3 */
1323 __le32 r0_frags;
1324 __le32 r1_frags;
1325 __le32 r2_frags;
1326 __le32 r3_frags;
1327
1328 /* MSDUs / MPDUs delivered to HTT */
1329 __le32 htt_msdus;
1330 __le32 htt_mpdus;
1331
1332 /* MSDUs / MPDUs delivered to local stack */
1333 __le32 loc_msdus;
1334 __le32 loc_mpdus;
1335
1336 /* AMSDUs that have more MSDUs than the status ring size */
1337 __le32 oversize_amsdu;
1338
1339 /* Number of PHY errors */
1340 __le32 phy_errs;
1341
1342 /* Number of PHY errors drops */
1343 __le32 phy_err_drop;
1344
1345 /* Number of mpdu errors - FCS, MIC, ENC etc. */
1346 __le32 mpdu_errs;
1347} __packed;
1348
1349struct htt_dbg_stats_wal_peer_stats {
1350 __le32 dummy; /* REMOVE THIS ONCE REAL PEER STAT COUNTERS ARE ADDED */
1351} __packed;
1352
1353struct htt_dbg_stats_wal_pdev_txrx {
1354 struct htt_dbg_stats_wal_tx_stats tx_stats;
1355 struct htt_dbg_stats_wal_rx_stats rx_stats;
1356 struct htt_dbg_stats_wal_peer_stats peer_stats;
1357} __packed;
1358
1359struct htt_dbg_stats_rx_rate_info {
1360 __le32 mcs[10];
1361 __le32 sgi[10];
1362 __le32 nss[4];
1363 __le32 stbc[10];
1364 __le32 bw[3];
1365 __le32 pream[6];
1366 __le32 ldpc;
1367 __le32 txbf;
1368};
1369
1370/*
1371 * htt_dbg_stats_status -
1372 * present - The requested stats have been delivered in full.
1373 * This indicates that either the stats information was contained
1374 * in its entirety within this message, or else this message
1375 * completes the delivery of the requested stats info that was
1376 * partially delivered through earlier STATS_CONF messages.
1377 * partial - The requested stats have been delivered in part.
1378 * One or more subsequent STATS_CONF messages with the same
1379 * cookie value will be sent to deliver the remainder of the
1380 * information.
1381 * error - The requested stats could not be delivered, for example due
1382 * to a shortage of memory to construct a message holding the
1383 * requested stats.
1384 * invalid - The requested stat type is either not recognized, or the
1385 * target is configured to not gather the stats type in question.
1386 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1387 * series_done - This special value indicates that no further stats info
1388 * elements are present within a series of stats info elems
1389 * (within a stats upload confirmation message).
1390 */
1391enum htt_dbg_stats_status {
1392 HTT_DBG_STATS_STATUS_PRESENT = 0,
1393 HTT_DBG_STATS_STATUS_PARTIAL = 1,
1394 HTT_DBG_STATS_STATUS_ERROR = 2,
1395 HTT_DBG_STATS_STATUS_INVALID = 3,
1396 HTT_DBG_STATS_STATUS_SERIES_DONE = 7
1397};
1398
1399/*
1400 * host -> target FRAG DESCRIPTOR/MSDU_EXT DESC bank
1401 *
1402 * The following field definitions describe the format of the HTT host
1403 * to target frag_desc/msdu_ext bank configuration message.
1404 * The message contains the based address and the min and max id of the
1405 * MSDU_EXT/FRAG_DESC that will be used by the HTT to map MSDU DESC and
1406 * MSDU_EXT/FRAG_DESC.
1407 * HTT will use id in HTT descriptor instead sending the frag_desc_ptr.
1408 * For QCA988X HW the firmware will use fragment_desc_ptr but in WIFI2.0
1409 * the hardware does the mapping/translation.
1410 *
1411 * Total banks that can be configured is configured to 16.
1412 *
1413 * This should be called before any TX has be initiated by the HTT
1414 *
1415 * |31 16|15 8|7 5|4 0|
1416 * |------------------------------------------------------------|
1417 * | DESC_SIZE | NUM_BANKS | RES |SWP|pdev| msg type |
1418 * |------------------------------------------------------------|
1419 * | BANK0_BASE_ADDRESS |
1420 * |------------------------------------------------------------|
1421 * | ... |
1422 * |------------------------------------------------------------|
1423 * | BANK15_BASE_ADDRESS |
1424 * |------------------------------------------------------------|
1425 * | BANK0_MAX_ID | BANK0_MIN_ID |
1426 * |------------------------------------------------------------|
1427 * | ... |
1428 * |------------------------------------------------------------|
1429 * | BANK15_MAX_ID | BANK15_MIN_ID |
1430 * |------------------------------------------------------------|
1431 * Header fields:
1432 * - MSG_TYPE
1433 * Bits 7:0
1434 * Value: 0x6
1435 * - BANKx_BASE_ADDRESS
1436 * Bits 31:0
1437 * Purpose: Provide a mechanism to specify the base address of the MSDU_EXT
1438 * bank physical/bus address.
1439 * - BANKx_MIN_ID
1440 * Bits 15:0
1441 * Purpose: Provide a mechanism to specify the min index that needs to
1442 * mapped.
1443 * - BANKx_MAX_ID
1444 * Bits 31:16
1445 * Purpose: Provide a mechanism to specify the max index that needs to
1446 *
1447 */
1448struct htt_frag_desc_bank_id {
1449 __le16 bank_min_id;
1450 __le16 bank_max_id;
1451} __packed;
1452
1453/* real is 16 but it wouldn't fit in the max htt message size
1454 * so we use a conservatively safe value for now
1455 */
1456#define HTT_FRAG_DESC_BANK_MAX 4
1457
1458#define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_MASK 0x03
1459#define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_LSB 0
1460#define HTT_FRAG_DESC_BANK_CFG_INFO_SWAP BIT(2)
1461#define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_VALID BIT(3)
1462#define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE_MASK BIT(4)
1463#define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE_LSB 4
1464
1465enum htt_q_depth_type {
1466 HTT_Q_DEPTH_TYPE_BYTES = 0,
1467 HTT_Q_DEPTH_TYPE_MSDUS = 1,
1468};
1469
1470#define HTT_TX_Q_STATE_NUM_PEERS (TARGET_10_4_NUM_QCACHE_PEERS_MAX + \
1471 TARGET_10_4_NUM_VDEVS)
1472#define HTT_TX_Q_STATE_NUM_TIDS 8
1473#define HTT_TX_Q_STATE_ENTRY_SIZE 1
1474#define HTT_TX_Q_STATE_ENTRY_MULTIPLIER 0
1475
1476/**
1477 * htt_q_state_conf - part of htt_frag_desc_bank_cfg for host q state config
1478 *
1479 * Defines host q state format and behavior. See htt_q_state.
1480 *
1481 * @record_size: Defines the size of each host q entry in bytes. In practice
1482 * however firmware (at least 10.4.3-00191) ignores this host
1483 * configuration value and uses hardcoded value of 1.
1484 * @record_multiplier: This is valid only when q depth type is MSDUs. It
1485 * defines the exponent for the power of 2 multiplication.
1486 */
1487struct htt_q_state_conf {
1488 __le32 paddr;
1489 __le16 num_peers;
1490 __le16 num_tids;
1491 u8 record_size;
1492 u8 record_multiplier;
1493 u8 pad[2];
1494} __packed;
1495
1496struct htt_frag_desc_bank_cfg32 {
1497 u8 info; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */
1498 u8 num_banks;
1499 u8 desc_size;
1500 __le32 bank_base_addrs[HTT_FRAG_DESC_BANK_MAX];
1501 struct htt_frag_desc_bank_id bank_id[HTT_FRAG_DESC_BANK_MAX];
1502 struct htt_q_state_conf q_state;
1503} __packed;
1504
1505struct htt_frag_desc_bank_cfg64 {
1506 u8 info; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */
1507 u8 num_banks;
1508 u8 desc_size;
1509 __le64 bank_base_addrs[HTT_FRAG_DESC_BANK_MAX];
1510 struct htt_frag_desc_bank_id bank_id[HTT_FRAG_DESC_BANK_MAX];
1511 struct htt_q_state_conf q_state;
1512} __packed;
1513
1514#define HTT_TX_Q_STATE_ENTRY_COEFFICIENT 128
1515#define HTT_TX_Q_STATE_ENTRY_FACTOR_MASK 0x3f
1516#define HTT_TX_Q_STATE_ENTRY_FACTOR_LSB 0
1517#define HTT_TX_Q_STATE_ENTRY_EXP_MASK 0xc0
1518#define HTT_TX_Q_STATE_ENTRY_EXP_LSB 6
1519
1520/**
1521 * htt_q_state - shared between host and firmware via DMA
1522 *
1523 * This structure is used for the host to expose it's software queue state to
1524 * firmware so that its rate control can schedule fetch requests for optimized
1525 * performance. This is most notably used for MU-MIMO aggregation when multiple
1526 * MU clients are connected.
1527 *
1528 * @count: Each element defines the host queue depth. When q depth type was
1529 * configured as HTT_Q_DEPTH_TYPE_BYTES then each entry is defined as:
1530 * FACTOR * 128 * 8^EXP (see HTT_TX_Q_STATE_ENTRY_FACTOR_MASK and
1531 * HTT_TX_Q_STATE_ENTRY_EXP_MASK). When q depth type was configured as
1532 * HTT_Q_DEPTH_TYPE_MSDUS the number of packets is scaled by 2 **
1533 * record_multiplier (see htt_q_state_conf).
1534 * @map: Used by firmware to quickly check which host queues are not empty. It
1535 * is a bitmap simply saying.
1536 * @seq: Used by firmware to quickly check if the host queues were updated
1537 * since it last checked.
1538 *
1539 * FIXME: Is the q_state map[] size calculation really correct?
1540 */
1541struct htt_q_state {
1542 u8 count[HTT_TX_Q_STATE_NUM_TIDS][HTT_TX_Q_STATE_NUM_PEERS];
1543 u32 map[HTT_TX_Q_STATE_NUM_TIDS][(HTT_TX_Q_STATE_NUM_PEERS + 31) / 32];
1544 __le32 seq;
1545} __packed;
1546
1547#define HTT_TX_FETCH_RECORD_INFO_PEER_ID_MASK 0x0fff
1548#define HTT_TX_FETCH_RECORD_INFO_PEER_ID_LSB 0
1549#define HTT_TX_FETCH_RECORD_INFO_TID_MASK 0xf000
1550#define HTT_TX_FETCH_RECORD_INFO_TID_LSB 12
1551
1552struct htt_tx_fetch_record {
1553 __le16 info; /* HTT_TX_FETCH_IND_RECORD_INFO_ */
1554 __le16 num_msdus;
1555 __le32 num_bytes;
1556} __packed;
1557
1558struct htt_tx_fetch_ind {
1559 u8 pad0;
1560 __le16 fetch_seq_num;
1561 __le32 token;
1562 __le16 num_resp_ids;
1563 __le16 num_records;
1564 union {
1565 /* ath10k_htt_get_tx_fetch_ind_resp_ids() */
1566 DECLARE_FLEX_ARRAY(__le32, resp_ids);
1567 DECLARE_FLEX_ARRAY(struct htt_tx_fetch_record, records);
1568 } __packed;
1569} __packed;
1570
1571static inline void *
1572ath10k_htt_get_tx_fetch_ind_resp_ids(struct htt_tx_fetch_ind *ind)
1573{
1574 return (void *)&ind->records[le16_to_cpu(ind->num_records)];
1575}
1576
1577struct htt_tx_fetch_resp {
1578 u8 pad0;
1579 __le16 resp_id;
1580 __le16 fetch_seq_num;
1581 __le16 num_records;
1582 __le32 token;
1583 struct htt_tx_fetch_record records[];
1584} __packed;
1585
1586struct htt_tx_fetch_confirm {
1587 u8 pad0;
1588 __le16 num_resp_ids;
1589 __le32 resp_ids[];
1590} __packed;
1591
1592enum htt_tx_mode_switch_mode {
1593 HTT_TX_MODE_SWITCH_PUSH = 0,
1594 HTT_TX_MODE_SWITCH_PUSH_PULL = 1,
1595};
1596
1597#define HTT_TX_MODE_SWITCH_IND_INFO0_ENABLE BIT(0)
1598#define HTT_TX_MODE_SWITCH_IND_INFO0_NUM_RECORDS_MASK 0xfffe
1599#define HTT_TX_MODE_SWITCH_IND_INFO0_NUM_RECORDS_LSB 1
1600
1601#define HTT_TX_MODE_SWITCH_IND_INFO1_MODE_MASK 0x0003
1602#define HTT_TX_MODE_SWITCH_IND_INFO1_MODE_LSB 0
1603#define HTT_TX_MODE_SWITCH_IND_INFO1_THRESHOLD_MASK 0xfffc
1604#define HTT_TX_MODE_SWITCH_IND_INFO1_THRESHOLD_LSB 2
1605
1606#define HTT_TX_MODE_SWITCH_RECORD_INFO0_PEER_ID_MASK 0x0fff
1607#define HTT_TX_MODE_SWITCH_RECORD_INFO0_PEER_ID_LSB 0
1608#define HTT_TX_MODE_SWITCH_RECORD_INFO0_TID_MASK 0xf000
1609#define HTT_TX_MODE_SWITCH_RECORD_INFO0_TID_LSB 12
1610
1611struct htt_tx_mode_switch_record {
1612 __le16 info0; /* HTT_TX_MODE_SWITCH_RECORD_INFO0_ */
1613 __le16 num_max_msdus;
1614} __packed;
1615
1616struct htt_tx_mode_switch_ind {
1617 u8 pad0;
1618 __le16 info0; /* HTT_TX_MODE_SWITCH_IND_INFO0_ */
1619 __le16 info1; /* HTT_TX_MODE_SWITCH_IND_INFO1_ */
1620 u8 pad1[2];
1621 struct htt_tx_mode_switch_record records[];
1622} __packed;
1623
1624struct htt_channel_change {
1625 u8 pad[3];
1626 __le32 freq;
1627 __le32 center_freq1;
1628 __le32 center_freq2;
1629 __le32 phymode;
1630} __packed;
1631
1632struct htt_per_peer_tx_stats_ind {
1633 __le32 succ_bytes;
1634 __le32 retry_bytes;
1635 __le32 failed_bytes;
1636 u8 ratecode;
1637 u8 flags;
1638 __le16 peer_id;
1639 __le16 succ_pkts;
1640 __le16 retry_pkts;
1641 __le16 failed_pkts;
1642 __le16 tx_duration;
1643 __le32 reserved1;
1644 __le32 reserved2;
1645} __packed;
1646
1647struct htt_peer_tx_stats {
1648 u8 num_ppdu;
1649 u8 ppdu_len;
1650 u8 version;
1651 u8 payload[];
1652} __packed;
1653
1654#define ATH10K_10_2_TX_STATS_OFFSET 136
1655#define PEER_STATS_FOR_NO_OF_PPDUS 4
1656
1657struct ath10k_10_2_peer_tx_stats {
1658 u8 ratecode[PEER_STATS_FOR_NO_OF_PPDUS];
1659 u8 success_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
1660 __le16 success_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
1661 u8 retry_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
1662 __le16 retry_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
1663 u8 failed_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
1664 __le16 failed_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
1665 u8 flags[PEER_STATS_FOR_NO_OF_PPDUS];
1666 __le32 tx_duration;
1667 u8 tx_ppdu_cnt;
1668 u8 peer_id;
1669} __packed;
1670
1671union htt_rx_pn_t {
1672 /* WEP: 24-bit PN */
1673 u32 pn24;
1674
1675 /* TKIP or CCMP: 48-bit PN */
1676 u64 pn48;
1677
1678 /* WAPI: 128-bit PN */
1679 u64 pn128[2];
1680};
1681
1682struct htt_cmd {
1683 struct htt_cmd_hdr hdr;
1684 union {
1685 struct htt_ver_req ver_req;
1686 struct htt_mgmt_tx_desc mgmt_tx;
1687 struct htt_data_tx_desc data_tx;
1688 struct htt_rx_ring_setup_32 rx_setup_32;
1689 struct htt_rx_ring_setup_64 rx_setup_64;
1690 struct htt_stats_req stats_req;
1691 struct htt_oob_sync_req oob_sync_req;
1692 struct htt_aggr_conf aggr_conf;
1693 struct htt_aggr_conf_v2 aggr_conf_v2;
1694 struct htt_frag_desc_bank_cfg32 frag_desc_bank_cfg32;
1695 struct htt_frag_desc_bank_cfg64 frag_desc_bank_cfg64;
1696 struct htt_tx_fetch_resp tx_fetch_resp;
1697 };
1698} __packed;
1699
1700struct htt_resp {
1701 struct htt_resp_hdr hdr;
1702 union {
1703 struct htt_ver_resp ver_resp;
1704 struct htt_mgmt_tx_completion mgmt_tx_completion;
1705 struct htt_data_tx_completion data_tx_completion;
1706 struct htt_rx_indication rx_ind;
1707 struct htt_rx_indication_hl rx_ind_hl;
1708 struct htt_rx_fragment_indication rx_frag_ind;
1709 struct htt_rx_peer_map peer_map;
1710 struct htt_rx_peer_unmap peer_unmap;
1711 struct htt_rx_flush rx_flush;
1712 struct htt_rx_addba rx_addba;
1713 struct htt_rx_delba rx_delba;
1714 struct htt_security_indication security_indication;
1715 struct htt_rc_update rc_update;
1716 struct htt_rx_test rx_test;
1717 struct htt_pktlog_msg pktlog_msg;
1718 struct htt_rx_pn_ind rx_pn_ind;
1719 struct htt_rx_offload_ind rx_offload_ind;
1720 struct htt_rx_in_ord_ind rx_in_ord_ind;
1721 struct htt_tx_fetch_ind tx_fetch_ind;
1722 struct htt_tx_fetch_confirm tx_fetch_confirm;
1723 struct htt_tx_mode_switch_ind tx_mode_switch_ind;
1724 struct htt_channel_change chan_change;
1725 struct htt_peer_tx_stats peer_tx_stats;
1726 } __packed;
1727} __packed;
1728
1729/*** host side structures follow ***/
1730
1731struct htt_tx_done {
1732 u16 msdu_id;
1733 u16 status;
1734 u8 ack_rssi;
1735};
1736
1737enum htt_tx_compl_state {
1738 HTT_TX_COMPL_STATE_NONE,
1739 HTT_TX_COMPL_STATE_ACK,
1740 HTT_TX_COMPL_STATE_NOACK,
1741 HTT_TX_COMPL_STATE_DISCARD,
1742};
1743
1744struct htt_peer_map_event {
1745 u8 vdev_id;
1746 u16 peer_id;
1747 u8 addr[ETH_ALEN];
1748};
1749
1750struct htt_peer_unmap_event {
1751 u16 peer_id;
1752};
1753
1754struct ath10k_htt_txbuf_32 {
1755 struct htt_data_tx_desc_frag frags[2];
1756 struct ath10k_htc_hdr htc_hdr;
1757 struct htt_cmd_hdr cmd_hdr;
1758 struct htt_data_tx_desc cmd_tx;
1759} __packed __aligned(4);
1760
1761struct ath10k_htt_txbuf_64 {
1762 struct htt_data_tx_desc_frag frags[2];
1763 struct ath10k_htc_hdr htc_hdr;
1764 struct htt_cmd_hdr cmd_hdr;
1765 struct htt_data_tx_desc_64 cmd_tx;
1766} __packed __aligned(4);
1767
1768struct ath10k_htt {
1769 struct ath10k *ar;
1770 enum ath10k_htc_ep_id eid;
1771
1772 struct sk_buff_head rx_indication_head;
1773
1774 u8 target_version_major;
1775 u8 target_version_minor;
1776 struct completion target_version_received;
1777 u8 max_num_amsdu;
1778 u8 max_num_ampdu;
1779
1780 const enum htt_t2h_msg_type *t2h_msg_types;
1781 u32 t2h_msg_types_max;
1782
1783 struct {
1784 /*
1785 * Ring of network buffer objects - This ring is
1786 * used exclusively by the host SW. This ring
1787 * mirrors the dev_addrs_ring that is shared
1788 * between the host SW and the MAC HW. The host SW
1789 * uses this netbufs ring to locate the network
1790 * buffer objects whose data buffers the HW has
1791 * filled.
1792 */
1793 struct sk_buff **netbufs_ring;
1794
1795 /* This is used only with firmware supporting IN_ORD_IND.
1796 *
1797 * With Full Rx Reorder the HTT Rx Ring is more of a temporary
1798 * buffer ring from which buffer addresses are copied by the
1799 * firmware to MAC Rx ring. Firmware then delivers IN_ORD_IND
1800 * pointing to specific (re-ordered) buffers.
1801 *
1802 * FIXME: With kernel generic hashing functions there's a lot
1803 * of hash collisions for sk_buffs.
1804 */
1805 bool in_ord_rx;
1806 DECLARE_HASHTABLE(skb_table, 4);
1807
1808 /*
1809 * Ring of buffer addresses -
1810 * This ring holds the "physical" device address of the
1811 * rx buffers the host SW provides for the MAC HW to
1812 * fill.
1813 */
1814 union {
1815 __le64 *paddrs_ring_64;
1816 __le32 *paddrs_ring_32;
1817 };
1818
1819 /*
1820 * Base address of ring, as a "physical" device address
1821 * rather than a CPU address.
1822 */
1823 dma_addr_t base_paddr;
1824
1825 /* how many elems in the ring (power of 2) */
1826 int size;
1827
1828 /* size - 1 */
1829 unsigned int size_mask;
1830
1831 /* how many rx buffers to keep in the ring */
1832 int fill_level;
1833
1834 /* how many rx buffers (full+empty) are in the ring */
1835 int fill_cnt;
1836
1837 /*
1838 * alloc_idx - where HTT SW has deposited empty buffers
1839 * This is allocated in consistent mem, so that the FW can
1840 * read this variable, and program the HW's FW_IDX reg with
1841 * the value of this shadow register.
1842 */
1843 struct {
1844 __le32 *vaddr;
1845 dma_addr_t paddr;
1846 } alloc_idx;
1847
1848 /* where HTT SW has processed bufs filled by rx MAC DMA */
1849 struct {
1850 unsigned int msdu_payld;
1851 } sw_rd_idx;
1852
1853 /*
1854 * refill_retry_timer - timer triggered when the ring is
1855 * not refilled to the level expected
1856 */
1857 struct timer_list refill_retry_timer;
1858
1859 /* Protects access to all rx ring buffer state variables */
1860 spinlock_t lock;
1861 } rx_ring;
1862
1863 unsigned int prefetch_len;
1864
1865 /* Protects access to pending_tx, num_pending_tx */
1866 spinlock_t tx_lock;
1867 int max_num_pending_tx;
1868 int num_pending_tx;
1869 int num_pending_mgmt_tx;
1870 struct idr pending_tx;
1871 wait_queue_head_t empty_tx_wq;
1872
1873 /* FIFO for storing tx done status {ack, no-ack, discard} and msdu id */
1874 DECLARE_KFIFO_PTR(txdone_fifo, struct htt_tx_done);
1875
1876 /* set if host-fw communication goes haywire
1877 * used to avoid further failures
1878 */
1879 bool rx_confused;
1880 atomic_t num_mpdus_ready;
1881
1882 /* This is used to group tx/rx completions separately and process them
1883 * in batches to reduce cache stalls
1884 */
1885 struct sk_buff_head rx_msdus_q;
1886 struct sk_buff_head rx_in_ord_compl_q;
1887 struct sk_buff_head tx_fetch_ind_q;
1888
1889 /* rx_status template */
1890 struct ieee80211_rx_status rx_status;
1891
1892 struct {
1893 dma_addr_t paddr;
1894 union {
1895 struct htt_msdu_ext_desc *vaddr_desc_32;
1896 struct htt_msdu_ext_desc_64 *vaddr_desc_64;
1897 };
1898 size_t size;
1899 } frag_desc;
1900
1901 struct {
1902 dma_addr_t paddr;
1903 union {
1904 struct ath10k_htt_txbuf_32 *vaddr_txbuff_32;
1905 struct ath10k_htt_txbuf_64 *vaddr_txbuff_64;
1906 };
1907 size_t size;
1908 } txbuf;
1909
1910 struct {
1911 bool enabled;
1912 struct htt_q_state *vaddr;
1913 dma_addr_t paddr;
1914 u16 num_push_allowed;
1915 u16 num_peers;
1916 u16 num_tids;
1917 enum htt_tx_mode_switch_mode mode;
1918 enum htt_q_depth_type type;
1919 } tx_q_state;
1920
1921 bool tx_mem_allocated;
1922 const struct ath10k_htt_tx_ops *tx_ops;
1923 const struct ath10k_htt_rx_ops *rx_ops;
1924 bool disable_tx_comp;
1925 bool bundle_tx;
1926 struct sk_buff_head tx_req_head;
1927 struct sk_buff_head tx_complete_head;
1928};
1929
1930struct ath10k_htt_tx_ops {
1931 int (*htt_send_rx_ring_cfg)(struct ath10k_htt *htt);
1932 int (*htt_send_frag_desc_bank_cfg)(struct ath10k_htt *htt);
1933 int (*htt_alloc_frag_desc)(struct ath10k_htt *htt);
1934 void (*htt_free_frag_desc)(struct ath10k_htt *htt);
1935 int (*htt_tx)(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
1936 struct sk_buff *msdu);
1937 int (*htt_alloc_txbuff)(struct ath10k_htt *htt);
1938 void (*htt_free_txbuff)(struct ath10k_htt *htt);
1939 int (*htt_h2t_aggr_cfg_msg)(struct ath10k_htt *htt,
1940 u8 max_subfrms_ampdu,
1941 u8 max_subfrms_amsdu);
1942 void (*htt_flush_tx)(struct ath10k_htt *htt);
1943};
1944
1945static inline int ath10k_htt_send_rx_ring_cfg(struct ath10k_htt *htt)
1946{
1947 if (!htt->tx_ops->htt_send_rx_ring_cfg)
1948 return -EOPNOTSUPP;
1949
1950 return htt->tx_ops->htt_send_rx_ring_cfg(htt);
1951}
1952
1953static inline int ath10k_htt_send_frag_desc_bank_cfg(struct ath10k_htt *htt)
1954{
1955 if (!htt->tx_ops->htt_send_frag_desc_bank_cfg)
1956 return -EOPNOTSUPP;
1957
1958 return htt->tx_ops->htt_send_frag_desc_bank_cfg(htt);
1959}
1960
1961static inline int ath10k_htt_alloc_frag_desc(struct ath10k_htt *htt)
1962{
1963 if (!htt->tx_ops->htt_alloc_frag_desc)
1964 return -EOPNOTSUPP;
1965
1966 return htt->tx_ops->htt_alloc_frag_desc(htt);
1967}
1968
1969static inline void ath10k_htt_free_frag_desc(struct ath10k_htt *htt)
1970{
1971 if (htt->tx_ops->htt_free_frag_desc)
1972 htt->tx_ops->htt_free_frag_desc(htt);
1973}
1974
1975static inline int ath10k_htt_tx(struct ath10k_htt *htt,
1976 enum ath10k_hw_txrx_mode txmode,
1977 struct sk_buff *msdu)
1978{
1979 return htt->tx_ops->htt_tx(htt, txmode, msdu);
1980}
1981
1982static inline void ath10k_htt_flush_tx(struct ath10k_htt *htt)
1983{
1984 if (htt->tx_ops->htt_flush_tx)
1985 htt->tx_ops->htt_flush_tx(htt);
1986}
1987
1988static inline int ath10k_htt_alloc_txbuff(struct ath10k_htt *htt)
1989{
1990 if (!htt->tx_ops->htt_alloc_txbuff)
1991 return -EOPNOTSUPP;
1992
1993 return htt->tx_ops->htt_alloc_txbuff(htt);
1994}
1995
1996static inline void ath10k_htt_free_txbuff(struct ath10k_htt *htt)
1997{
1998 if (htt->tx_ops->htt_free_txbuff)
1999 htt->tx_ops->htt_free_txbuff(htt);
2000}
2001
2002static inline int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
2003 u8 max_subfrms_ampdu,
2004 u8 max_subfrms_amsdu)
2005
2006{
2007 if (!htt->tx_ops->htt_h2t_aggr_cfg_msg)
2008 return -EOPNOTSUPP;
2009
2010 return htt->tx_ops->htt_h2t_aggr_cfg_msg(htt,
2011 max_subfrms_ampdu,
2012 max_subfrms_amsdu);
2013}
2014
2015struct ath10k_htt_rx_ops {
2016 size_t (*htt_get_rx_ring_size)(struct ath10k_htt *htt);
2017 void (*htt_config_paddrs_ring)(struct ath10k_htt *htt, void *vaddr);
2018 void (*htt_set_paddrs_ring)(struct ath10k_htt *htt, dma_addr_t paddr,
2019 int idx);
2020 void* (*htt_get_vaddr_ring)(struct ath10k_htt *htt);
2021 void (*htt_reset_paddrs_ring)(struct ath10k_htt *htt, int idx);
2022 bool (*htt_rx_proc_rx_frag_ind)(struct ath10k_htt *htt,
2023 struct htt_rx_fragment_indication *rx,
2024 struct sk_buff *skb);
2025};
2026
2027static inline size_t ath10k_htt_get_rx_ring_size(struct ath10k_htt *htt)
2028{
2029 if (!htt->rx_ops->htt_get_rx_ring_size)
2030 return 0;
2031
2032 return htt->rx_ops->htt_get_rx_ring_size(htt);
2033}
2034
2035static inline void ath10k_htt_config_paddrs_ring(struct ath10k_htt *htt,
2036 void *vaddr)
2037{
2038 if (htt->rx_ops->htt_config_paddrs_ring)
2039 htt->rx_ops->htt_config_paddrs_ring(htt, vaddr);
2040}
2041
2042static inline void ath10k_htt_set_paddrs_ring(struct ath10k_htt *htt,
2043 dma_addr_t paddr,
2044 int idx)
2045{
2046 if (htt->rx_ops->htt_set_paddrs_ring)
2047 htt->rx_ops->htt_set_paddrs_ring(htt, paddr, idx);
2048}
2049
2050static inline void *ath10k_htt_get_vaddr_ring(struct ath10k_htt *htt)
2051{
2052 if (!htt->rx_ops->htt_get_vaddr_ring)
2053 return NULL;
2054
2055 return htt->rx_ops->htt_get_vaddr_ring(htt);
2056}
2057
2058static inline void ath10k_htt_reset_paddrs_ring(struct ath10k_htt *htt, int idx)
2059{
2060 if (htt->rx_ops->htt_reset_paddrs_ring)
2061 htt->rx_ops->htt_reset_paddrs_ring(htt, idx);
2062}
2063
2064static inline bool ath10k_htt_rx_proc_rx_frag_ind(struct ath10k_htt *htt,
2065 struct htt_rx_fragment_indication *rx,
2066 struct sk_buff *skb)
2067{
2068 if (!htt->rx_ops->htt_rx_proc_rx_frag_ind)
2069 return true;
2070
2071 return htt->rx_ops->htt_rx_proc_rx_frag_ind(htt, rx, skb);
2072}
2073
2074/* the driver strongly assumes that the rx header status be 64 bytes long,
2075 * so all possible rx_desc structures must respect this assumption.
2076 */
2077#define RX_HTT_HDR_STATUS_LEN 64
2078
2079/* The rx descriptor structure layout is programmed via rx ring setup
2080 * so that FW knows how to transfer the rx descriptor to the host.
2081 * Unfortunately, though, QCA6174's firmware doesn't currently behave correctly
2082 * when modifying the structure layout of the rx descriptor beyond what it expects
2083 * (even if it correctly programmed during the rx ring setup).
2084 * Therefore we must keep two different memory layouts, abstract the rx descriptor
2085 * representation and use ath10k_rx_desc_ops
2086 * for correctly accessing rx descriptor data.
2087 */
2088
2089/* base struct used for abstracting the rx descriptor representation */
2090struct htt_rx_desc {
2091 union {
2092 /* This field is filled on the host using the msdu buffer
2093 * from htt_rx_indication
2094 */
2095 struct fw_rx_desc_base fw_desc;
2096 u32 pad;
2097 } __packed;
2098} __packed;
2099
2100/* rx descriptor for wcn3990 and possibly extensible for newer cards
2101 * Buffers like this are placed on the rx ring.
2102 */
2103struct htt_rx_desc_v2 {
2104 struct htt_rx_desc base;
2105 struct {
2106 struct rx_attention attention;
2107 struct rx_frag_info frag_info;
2108 struct rx_mpdu_start mpdu_start;
2109 struct rx_msdu_start msdu_start;
2110 struct rx_msdu_end msdu_end;
2111 struct rx_mpdu_end mpdu_end;
2112 struct rx_ppdu_start ppdu_start;
2113 struct rx_ppdu_end ppdu_end;
2114 } __packed;
2115 u8 rx_hdr_status[RX_HTT_HDR_STATUS_LEN];
2116 u8 msdu_payload[];
2117};
2118
2119/* QCA6174, QCA988x, QCA99x0 dedicated rx descriptor to make sure their firmware
2120 * works correctly. We keep a single rx descriptor for all these three
2121 * families of cards because from tests it seems to be the most stable solution,
2122 * e.g. having a rx descriptor only for QCA6174 seldom caused firmware crashes
2123 * during some tests.
2124 * Buffers like this are placed on the rx ring.
2125 */
2126struct htt_rx_desc_v1 {
2127 struct htt_rx_desc base;
2128 struct {
2129 struct rx_attention attention;
2130 struct rx_frag_info_v1 frag_info;
2131 struct rx_mpdu_start mpdu_start;
2132 struct rx_msdu_start_v1 msdu_start;
2133 struct rx_msdu_end_v1 msdu_end;
2134 struct rx_mpdu_end mpdu_end;
2135 struct rx_ppdu_start ppdu_start;
2136 struct rx_ppdu_end_v1 ppdu_end;
2137 } __packed;
2138 u8 rx_hdr_status[RX_HTT_HDR_STATUS_LEN];
2139 u8 msdu_payload[];
2140};
2141
2142/* rx_desc abstraction */
2143struct ath10k_htt_rx_desc_ops {
2144 /* These fields are mandatory, they must be specified in any instance */
2145
2146 /* sizeof() of the rx_desc structure used by this hw */
2147 size_t rx_desc_size;
2148
2149 /* offset of msdu_payload inside the rx_desc structure used by this hw */
2150 size_t rx_desc_msdu_payload_offset;
2151
2152 /* These fields are options.
2153 * When a field is not provided the default implementation gets used
2154 * (see the ath10k_rx_desc_* operations below for more info about the defaults)
2155 */
2156 bool (*rx_desc_get_msdu_limit_error)(struct htt_rx_desc *rxd);
2157 int (*rx_desc_get_l3_pad_bytes)(struct htt_rx_desc *rxd);
2158
2159 /* Safely cast from a void* buffer containing an rx descriptor
2160 * to the proper rx_desc structure
2161 */
2162 struct htt_rx_desc *(*rx_desc_from_raw_buffer)(void *buff);
2163
2164 void (*rx_desc_get_offsets)(struct htt_rx_ring_rx_desc_offsets *offs);
2165 struct rx_attention *(*rx_desc_get_attention)(struct htt_rx_desc *rxd);
2166 struct rx_frag_info_common *(*rx_desc_get_frag_info)(struct htt_rx_desc *rxd);
2167 struct rx_mpdu_start *(*rx_desc_get_mpdu_start)(struct htt_rx_desc *rxd);
2168 struct rx_mpdu_end *(*rx_desc_get_mpdu_end)(struct htt_rx_desc *rxd);
2169 struct rx_msdu_start_common *(*rx_desc_get_msdu_start)(struct htt_rx_desc *rxd);
2170 struct rx_msdu_end_common *(*rx_desc_get_msdu_end)(struct htt_rx_desc *rxd);
2171 struct rx_ppdu_start *(*rx_desc_get_ppdu_start)(struct htt_rx_desc *rxd);
2172 struct rx_ppdu_end_common *(*rx_desc_get_ppdu_end)(struct htt_rx_desc *rxd);
2173 u8 *(*rx_desc_get_rx_hdr_status)(struct htt_rx_desc *rxd);
2174 u8 *(*rx_desc_get_msdu_payload)(struct htt_rx_desc *rxd);
2175};
2176
2177extern const struct ath10k_htt_rx_desc_ops qca988x_rx_desc_ops;
2178extern const struct ath10k_htt_rx_desc_ops qca99x0_rx_desc_ops;
2179extern const struct ath10k_htt_rx_desc_ops wcn3990_rx_desc_ops;
2180
2181static inline int
2182ath10k_htt_rx_desc_get_l3_pad_bytes(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2183{
2184 if (hw->rx_desc_ops->rx_desc_get_l3_pad_bytes)
2185 return hw->rx_desc_ops->rx_desc_get_l3_pad_bytes(rxd);
2186 return 0;
2187}
2188
2189static inline bool
2190ath10k_htt_rx_desc_msdu_limit_error(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2191{
2192 if (hw->rx_desc_ops->rx_desc_get_msdu_limit_error)
2193 return hw->rx_desc_ops->rx_desc_get_msdu_limit_error(rxd);
2194 return false;
2195}
2196
2197/* The default implementation of all these getters is using the old rx_desc,
2198 * so that it is easier to define the ath10k_htt_rx_desc_ops instances.
2199 * But probably, if new wireless cards must be supported, it would be better
2200 * to switch the default implementation to the new rx_desc, since this would
2201 * make the extension easier .
2202 */
2203static inline struct htt_rx_desc *
2204ath10k_htt_rx_desc_from_raw_buffer(struct ath10k_hw_params *hw, void *buff)
2205{
2206 if (hw->rx_desc_ops->rx_desc_from_raw_buffer)
2207 return hw->rx_desc_ops->rx_desc_from_raw_buffer(buff);
2208 return &((struct htt_rx_desc_v1 *)buff)->base;
2209}
2210
2211static inline void
2212ath10k_htt_rx_desc_get_offsets(struct ath10k_hw_params *hw,
2213 struct htt_rx_ring_rx_desc_offsets *off)
2214{
2215 if (hw->rx_desc_ops->rx_desc_get_offsets) {
2216 hw->rx_desc_ops->rx_desc_get_offsets(off);
2217 } else {
2218#define desc_offset(x) (offsetof(struct htt_rx_desc_v1, x) / 4)
2219 off->mac80211_hdr_offset = __cpu_to_le16(desc_offset(rx_hdr_status));
2220 off->msdu_payload_offset = __cpu_to_le16(desc_offset(msdu_payload));
2221 off->ppdu_start_offset = __cpu_to_le16(desc_offset(ppdu_start));
2222 off->ppdu_end_offset = __cpu_to_le16(desc_offset(ppdu_end));
2223 off->mpdu_start_offset = __cpu_to_le16(desc_offset(mpdu_start));
2224 off->mpdu_end_offset = __cpu_to_le16(desc_offset(mpdu_end));
2225 off->msdu_start_offset = __cpu_to_le16(desc_offset(msdu_start));
2226 off->msdu_end_offset = __cpu_to_le16(desc_offset(msdu_end));
2227 off->rx_attention_offset = __cpu_to_le16(desc_offset(attention));
2228 off->frag_info_offset = __cpu_to_le16(desc_offset(frag_info));
2229#undef desc_offset
2230 }
2231}
2232
2233static inline struct rx_attention *
2234ath10k_htt_rx_desc_get_attention(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2235{
2236 struct htt_rx_desc_v1 *rx_desc;
2237
2238 if (hw->rx_desc_ops->rx_desc_get_attention)
2239 return hw->rx_desc_ops->rx_desc_get_attention(rxd);
2240
2241 rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);
2242 return &rx_desc->attention;
2243}
2244
2245static inline struct rx_frag_info_common *
2246ath10k_htt_rx_desc_get_frag_info(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2247{
2248 struct htt_rx_desc_v1 *rx_desc;
2249
2250 if (hw->rx_desc_ops->rx_desc_get_frag_info)
2251 return hw->rx_desc_ops->rx_desc_get_frag_info(rxd);
2252
2253 rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);
2254 return &rx_desc->frag_info.common;
2255}
2256
2257static inline struct rx_mpdu_start *
2258ath10k_htt_rx_desc_get_mpdu_start(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2259{
2260 struct htt_rx_desc_v1 *rx_desc;
2261
2262 if (hw->rx_desc_ops->rx_desc_get_mpdu_start)
2263 return hw->rx_desc_ops->rx_desc_get_mpdu_start(rxd);
2264
2265 rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);
2266 return &rx_desc->mpdu_start;
2267}
2268
2269static inline struct rx_mpdu_end *
2270ath10k_htt_rx_desc_get_mpdu_end(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2271{
2272 struct htt_rx_desc_v1 *rx_desc;
2273
2274 if (hw->rx_desc_ops->rx_desc_get_mpdu_end)
2275 return hw->rx_desc_ops->rx_desc_get_mpdu_end(rxd);
2276
2277 rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);
2278 return &rx_desc->mpdu_end;
2279}
2280
2281static inline struct rx_msdu_start_common *
2282ath10k_htt_rx_desc_get_msdu_start(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2283{
2284 struct htt_rx_desc_v1 *rx_desc;
2285
2286 if (hw->rx_desc_ops->rx_desc_get_msdu_start)
2287 return hw->rx_desc_ops->rx_desc_get_msdu_start(rxd);
2288
2289 rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);
2290 return &rx_desc->msdu_start.common;
2291}
2292
2293static inline struct rx_msdu_end_common *
2294ath10k_htt_rx_desc_get_msdu_end(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2295{
2296 struct htt_rx_desc_v1 *rx_desc;
2297
2298 if (hw->rx_desc_ops->rx_desc_get_msdu_end)
2299 return hw->rx_desc_ops->rx_desc_get_msdu_end(rxd);
2300
2301 rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);
2302 return &rx_desc->msdu_end.common;
2303}
2304
2305static inline struct rx_ppdu_start *
2306ath10k_htt_rx_desc_get_ppdu_start(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2307{
2308 struct htt_rx_desc_v1 *rx_desc;
2309
2310 if (hw->rx_desc_ops->rx_desc_get_ppdu_start)
2311 return hw->rx_desc_ops->rx_desc_get_ppdu_start(rxd);
2312
2313 rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);
2314 return &rx_desc->ppdu_start;
2315}
2316
2317static inline struct rx_ppdu_end_common *
2318ath10k_htt_rx_desc_get_ppdu_end(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2319{
2320 struct htt_rx_desc_v1 *rx_desc;
2321
2322 if (hw->rx_desc_ops->rx_desc_get_ppdu_end)
2323 return hw->rx_desc_ops->rx_desc_get_ppdu_end(rxd);
2324
2325 rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);
2326 return &rx_desc->ppdu_end.common;
2327}
2328
2329static inline u8 *
2330ath10k_htt_rx_desc_get_rx_hdr_status(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2331{
2332 struct htt_rx_desc_v1 *rx_desc;
2333
2334 if (hw->rx_desc_ops->rx_desc_get_rx_hdr_status)
2335 return hw->rx_desc_ops->rx_desc_get_rx_hdr_status(rxd);
2336
2337 rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);
2338 return rx_desc->rx_hdr_status;
2339}
2340
2341static inline u8 *
2342ath10k_htt_rx_desc_get_msdu_payload(struct ath10k_hw_params *hw, struct htt_rx_desc *rxd)
2343{
2344 struct htt_rx_desc_v1 *rx_desc;
2345
2346 if (hw->rx_desc_ops->rx_desc_get_msdu_payload)
2347 return hw->rx_desc_ops->rx_desc_get_msdu_payload(rxd);
2348
2349 rx_desc = container_of(rxd, struct htt_rx_desc_v1, base);
2350 return rx_desc->msdu_payload;
2351}
2352
2353#define HTT_RX_DESC_HL_INFO_SEQ_NUM_MASK 0x00000fff
2354#define HTT_RX_DESC_HL_INFO_SEQ_NUM_LSB 0
2355#define HTT_RX_DESC_HL_INFO_ENCRYPTED_MASK 0x00001000
2356#define HTT_RX_DESC_HL_INFO_ENCRYPTED_LSB 12
2357#define HTT_RX_DESC_HL_INFO_CHAN_INFO_PRESENT_MASK 0x00002000
2358#define HTT_RX_DESC_HL_INFO_CHAN_INFO_PRESENT_LSB 13
2359#define HTT_RX_DESC_HL_INFO_MCAST_BCAST_MASK 0x00010000
2360#define HTT_RX_DESC_HL_INFO_MCAST_BCAST_LSB 16
2361#define HTT_RX_DESC_HL_INFO_KEY_ID_OCT_MASK 0x01fe0000
2362#define HTT_RX_DESC_HL_INFO_KEY_ID_OCT_LSB 17
2363
2364struct htt_rx_desc_base_hl {
2365 __le32 info; /* HTT_RX_DESC_HL_INFO_ */
2366};
2367
2368struct htt_rx_chan_info {
2369 __le16 primary_chan_center_freq_mhz;
2370 __le16 contig_chan1_center_freq_mhz;
2371 __le16 contig_chan2_center_freq_mhz;
2372 u8 phy_mode;
2373 u8 reserved;
2374} __packed;
2375
2376#define HTT_RX_DESC_ALIGN 8
2377
2378#define HTT_MAC_ADDR_LEN 6
2379
2380/*
2381 * FIX THIS
2382 * Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size,
2383 * rounded up to a cache line size.
2384 */
2385#define HTT_RX_BUF_SIZE 2048
2386
2387/* The HTT_RX_MSDU_SIZE can't be statically computed anymore,
2388 * because it depends on the underlying device rx_desc representation
2389 */
2390static inline int ath10k_htt_rx_msdu_size(struct ath10k_hw_params *hw)
2391{
2392 return HTT_RX_BUF_SIZE - (int)hw->rx_desc_ops->rx_desc_size;
2393}
2394
2395/* Refill a bunch of RX buffers for each refill round so that FW/HW can handle
2396 * aggregated traffic more nicely.
2397 */
2398#define ATH10K_HTT_MAX_NUM_REFILL 100
2399
2400/*
2401 * DMA_MAP expects the buffer to be an integral number of cache lines.
2402 * Rather than checking the actual cache line size, this code makes a
2403 * conservative estimate of what the cache line size could be.
2404 */
2405#define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */
2406#define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1)
2407
2408/* These values are default in most firmware revisions and apparently are a
2409 * sweet spot performance wise.
2410 */
2411#define ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT 3
2412#define ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT 64
2413
2414int ath10k_htt_connect(struct ath10k_htt *htt);
2415int ath10k_htt_init(struct ath10k *ar);
2416int ath10k_htt_setup(struct ath10k_htt *htt);
2417
2418int ath10k_htt_tx_start(struct ath10k_htt *htt);
2419void ath10k_htt_tx_stop(struct ath10k_htt *htt);
2420void ath10k_htt_tx_destroy(struct ath10k_htt *htt);
2421void ath10k_htt_tx_free(struct ath10k_htt *htt);
2422
2423int ath10k_htt_rx_alloc(struct ath10k_htt *htt);
2424int ath10k_htt_rx_ring_refill(struct ath10k *ar);
2425void ath10k_htt_rx_free(struct ath10k_htt *htt);
2426
2427void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb);
2428void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
2429bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
2430int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
2431int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u32 mask, u32 reset_mask,
2432 u64 cookie);
2433void ath10k_htt_hif_tx_complete(struct ath10k *ar, struct sk_buff *skb);
2434int ath10k_htt_tx_fetch_resp(struct ath10k *ar,
2435 __le32 token,
2436 __le16 fetch_seq_num,
2437 struct htt_tx_fetch_record *records,
2438 size_t num_records);
2439void ath10k_htt_op_ep_tx_credits(struct ath10k *ar);
2440
2441void ath10k_htt_tx_txq_update(struct ieee80211_hw *hw,
2442 struct ieee80211_txq *txq);
2443void ath10k_htt_tx_txq_recalc(struct ieee80211_hw *hw,
2444 struct ieee80211_txq *txq);
2445void ath10k_htt_tx_txq_sync(struct ath10k *ar);
2446void ath10k_htt_tx_dec_pending(struct ath10k_htt *htt);
2447int ath10k_htt_tx_inc_pending(struct ath10k_htt *htt);
2448void ath10k_htt_tx_mgmt_dec_pending(struct ath10k_htt *htt);
2449int ath10k_htt_tx_mgmt_inc_pending(struct ath10k_htt *htt, bool is_mgmt,
2450 bool is_presp);
2451
2452int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt, struct sk_buff *skb);
2453void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id);
2454int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu);
2455void ath10k_htt_rx_pktlog_completion_handler(struct ath10k *ar,
2456 struct sk_buff *skb);
2457int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget);
2458int ath10k_htt_rx_hl_indication(struct ath10k *ar, int budget);
2459void ath10k_htt_set_tx_ops(struct ath10k_htt *htt);
2460void ath10k_htt_set_rx_ops(struct ath10k_htt *htt);
2461#endif
1/* SPDX-License-Identifier: ISC */
2/*
3 * Copyright (c) 2005-2011 Atheros Communications Inc.
4 * Copyright (c) 2011-2017 Qualcomm Atheros, Inc.
5 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
6 */
7
8#ifndef _HTT_H_
9#define _HTT_H_
10
11#include <linux/bug.h>
12#include <linux/interrupt.h>
13#include <linux/dmapool.h>
14#include <linux/hashtable.h>
15#include <linux/kfifo.h>
16#include <net/mac80211.h>
17
18#include "htc.h"
19#include "hw.h"
20#include "rx_desc.h"
21
22enum htt_dbg_stats_type {
23 HTT_DBG_STATS_WAL_PDEV_TXRX = 1 << 0,
24 HTT_DBG_STATS_RX_REORDER = 1 << 1,
25 HTT_DBG_STATS_RX_RATE_INFO = 1 << 2,
26 HTT_DBG_STATS_TX_PPDU_LOG = 1 << 3,
27 HTT_DBG_STATS_TX_RATE_INFO = 1 << 4,
28 /* bits 5-23 currently reserved */
29
30 HTT_DBG_NUM_STATS /* keep this last */
31};
32
33enum htt_h2t_msg_type { /* host-to-target */
34 HTT_H2T_MSG_TYPE_VERSION_REQ = 0,
35 HTT_H2T_MSG_TYPE_TX_FRM = 1,
36 HTT_H2T_MSG_TYPE_RX_RING_CFG = 2,
37 HTT_H2T_MSG_TYPE_STATS_REQ = 3,
38 HTT_H2T_MSG_TYPE_SYNC = 4,
39 HTT_H2T_MSG_TYPE_AGGR_CFG = 5,
40 HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG = 6,
41
42 /* This command is used for sending management frames in HTT < 3.0.
43 * HTT >= 3.0 uses TX_FRM for everything.
44 */
45 HTT_H2T_MSG_TYPE_MGMT_TX = 7,
46 HTT_H2T_MSG_TYPE_TX_FETCH_RESP = 11,
47
48 HTT_H2T_NUM_MSGS /* keep this last */
49};
50
51struct htt_cmd_hdr {
52 u8 msg_type;
53} __packed;
54
55struct htt_ver_req {
56 u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
57} __packed;
58
59/*
60 * HTT tx MSDU descriptor
61 *
62 * The HTT tx MSDU descriptor is created by the host HTT SW for each
63 * tx MSDU. The HTT tx MSDU descriptor contains the information that
64 * the target firmware needs for the FW's tx processing, particularly
65 * for creating the HW msdu descriptor.
66 * The same HTT tx descriptor is used for HL and LL systems, though
67 * a few fields within the tx descriptor are used only by LL or
68 * only by HL.
69 * The HTT tx descriptor is defined in two manners: by a struct with
70 * bitfields, and by a series of [dword offset, bit mask, bit shift]
71 * definitions.
72 * The target should use the struct def, for simplicitly and clarity,
73 * but the host shall use the bit-mast + bit-shift defs, to be endian-
74 * neutral. Specifically, the host shall use the get/set macros built
75 * around the mask + shift defs.
76 */
77struct htt_data_tx_desc_frag {
78 union {
79 struct double_word_addr {
80 __le32 paddr;
81 __le32 len;
82 } __packed dword_addr;
83 struct triple_word_addr {
84 __le32 paddr_lo;
85 __le16 paddr_hi;
86 __le16 len_16;
87 } __packed tword_addr;
88 } __packed;
89} __packed;
90
91struct htt_msdu_ext_desc {
92 __le32 tso_flag[3];
93 __le16 ip_identification;
94 u8 flags;
95 u8 reserved;
96 struct htt_data_tx_desc_frag frags[6];
97};
98
99struct htt_msdu_ext_desc_64 {
100 __le32 tso_flag[5];
101 __le16 ip_identification;
102 u8 flags;
103 u8 reserved;
104 struct htt_data_tx_desc_frag frags[6];
105};
106
107#define HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE BIT(0)
108#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE BIT(1)
109#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE BIT(2)
110#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE BIT(3)
111#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE BIT(4)
112
113#define HTT_MSDU_CHECKSUM_ENABLE (HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE \
114 | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE \
115 | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE \
116 | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE \
117 | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE)
118
119#define HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE_64 BIT(16)
120#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE_64 BIT(17)
121#define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE_64 BIT(18)
122#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE_64 BIT(19)
123#define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE_64 BIT(20)
124#define HTT_MSDU_EXT_DESC_FLAG_PARTIAL_CSUM_ENABLE_64 BIT(21)
125
126#define HTT_MSDU_CHECKSUM_ENABLE_64 (HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE_64 \
127 | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE_64 \
128 | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE_64 \
129 | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE_64 \
130 | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE_64)
131
132enum htt_data_tx_desc_flags0 {
133 HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT = 1 << 0,
134 HTT_DATA_TX_DESC_FLAGS0_NO_AGGR = 1 << 1,
135 HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT = 1 << 2,
136 HTT_DATA_TX_DESC_FLAGS0_NO_CLASSIFY = 1 << 3,
137 HTT_DATA_TX_DESC_FLAGS0_RSVD0 = 1 << 4
138#define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_MASK 0xE0
139#define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_LSB 5
140};
141
142enum htt_data_tx_desc_flags1 {
143#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_BITS 6
144#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_MASK 0x003F
145#define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_LSB 0
146#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_BITS 5
147#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_MASK 0x07C0
148#define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_LSB 6
149 HTT_DATA_TX_DESC_FLAGS1_POSTPONED = 1 << 11,
150 HTT_DATA_TX_DESC_FLAGS1_MORE_IN_BATCH = 1 << 12,
151 HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD = 1 << 13,
152 HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD = 1 << 14,
153 HTT_DATA_TX_DESC_FLAGS1_TX_COMPLETE = 1 << 15
154};
155
156#define HTT_TX_CREDIT_DELTA_ABS_M 0xffff0000
157#define HTT_TX_CREDIT_DELTA_ABS_S 16
158#define HTT_TX_CREDIT_DELTA_ABS_GET(word) \
159 (((word) & HTT_TX_CREDIT_DELTA_ABS_M) >> HTT_TX_CREDIT_DELTA_ABS_S)
160
161#define HTT_TX_CREDIT_SIGN_BIT_M 0x00000100
162#define HTT_TX_CREDIT_SIGN_BIT_S 8
163#define HTT_TX_CREDIT_SIGN_BIT_GET(word) \
164 (((word) & HTT_TX_CREDIT_SIGN_BIT_M) >> HTT_TX_CREDIT_SIGN_BIT_S)
165
166enum htt_data_tx_ext_tid {
167 HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST = 16,
168 HTT_DATA_TX_EXT_TID_MGMT = 17,
169 HTT_DATA_TX_EXT_TID_INVALID = 31
170};
171
172#define HTT_INVALID_PEERID 0xFFFF
173
174/*
175 * htt_data_tx_desc - used for data tx path
176 *
177 * Note: vdev_id irrelevant for pkt_type == raw and no_classify == 1.
178 * ext_tid: for qos-data frames (0-15), see %HTT_DATA_TX_EXT_TID_
179 * for special kinds of tids
180 * postponed: only for HL hosts. indicates if this is a resend
181 * (HL hosts manage queues on the host )
182 * more_in_batch: only for HL hosts. indicates if more packets are
183 * pending. this allows target to wait and aggregate
184 * freq: 0 means home channel of given vdev. intended for offchannel
185 */
186struct htt_data_tx_desc {
187 u8 flags0; /* %HTT_DATA_TX_DESC_FLAGS0_ */
188 __le16 flags1; /* %HTT_DATA_TX_DESC_FLAGS1_ */
189 __le16 len;
190 __le16 id;
191 __le32 frags_paddr;
192 union {
193 __le32 peerid;
194 struct {
195 __le16 peerid;
196 __le16 freq;
197 } __packed offchan_tx;
198 } __packed;
199 u8 prefetch[0]; /* start of frame, for FW classification engine */
200} __packed;
201
202struct htt_data_tx_desc_64 {
203 u8 flags0; /* %HTT_DATA_TX_DESC_FLAGS0_ */
204 __le16 flags1; /* %HTT_DATA_TX_DESC_FLAGS1_ */
205 __le16 len;
206 __le16 id;
207 __le64 frags_paddr;
208 union {
209 __le32 peerid;
210 struct {
211 __le16 peerid;
212 __le16 freq;
213 } __packed offchan_tx;
214 } __packed;
215 u8 prefetch[0]; /* start of frame, for FW classification engine */
216} __packed;
217
218enum htt_rx_ring_flags {
219 HTT_RX_RING_FLAGS_MAC80211_HDR = 1 << 0,
220 HTT_RX_RING_FLAGS_MSDU_PAYLOAD = 1 << 1,
221 HTT_RX_RING_FLAGS_PPDU_START = 1 << 2,
222 HTT_RX_RING_FLAGS_PPDU_END = 1 << 3,
223 HTT_RX_RING_FLAGS_MPDU_START = 1 << 4,
224 HTT_RX_RING_FLAGS_MPDU_END = 1 << 5,
225 HTT_RX_RING_FLAGS_MSDU_START = 1 << 6,
226 HTT_RX_RING_FLAGS_MSDU_END = 1 << 7,
227 HTT_RX_RING_FLAGS_RX_ATTENTION = 1 << 8,
228 HTT_RX_RING_FLAGS_FRAG_INFO = 1 << 9,
229 HTT_RX_RING_FLAGS_UNICAST_RX = 1 << 10,
230 HTT_RX_RING_FLAGS_MULTICAST_RX = 1 << 11,
231 HTT_RX_RING_FLAGS_CTRL_RX = 1 << 12,
232 HTT_RX_RING_FLAGS_MGMT_RX = 1 << 13,
233 HTT_RX_RING_FLAGS_NULL_RX = 1 << 14,
234 HTT_RX_RING_FLAGS_PHY_DATA_RX = 1 << 15
235};
236
237#define HTT_RX_RING_SIZE_MIN 128
238#define HTT_RX_RING_SIZE_MAX 2048
239#define HTT_RX_RING_SIZE HTT_RX_RING_SIZE_MAX
240#define HTT_RX_RING_FILL_LEVEL (((HTT_RX_RING_SIZE) / 2) - 1)
241#define HTT_RX_RING_FILL_LEVEL_DUAL_MAC (HTT_RX_RING_SIZE - 1)
242
243struct htt_rx_ring_setup_ring32 {
244 __le32 fw_idx_shadow_reg_paddr;
245 __le32 rx_ring_base_paddr;
246 __le16 rx_ring_len; /* in 4-byte words */
247 __le16 rx_ring_bufsize; /* rx skb size - in bytes */
248 __le16 flags; /* %HTT_RX_RING_FLAGS_ */
249 __le16 fw_idx_init_val;
250
251 /* the following offsets are in 4-byte units */
252 __le16 mac80211_hdr_offset;
253 __le16 msdu_payload_offset;
254 __le16 ppdu_start_offset;
255 __le16 ppdu_end_offset;
256 __le16 mpdu_start_offset;
257 __le16 mpdu_end_offset;
258 __le16 msdu_start_offset;
259 __le16 msdu_end_offset;
260 __le16 rx_attention_offset;
261 __le16 frag_info_offset;
262} __packed;
263
264struct htt_rx_ring_setup_ring64 {
265 __le64 fw_idx_shadow_reg_paddr;
266 __le64 rx_ring_base_paddr;
267 __le16 rx_ring_len; /* in 4-byte words */
268 __le16 rx_ring_bufsize; /* rx skb size - in bytes */
269 __le16 flags; /* %HTT_RX_RING_FLAGS_ */
270 __le16 fw_idx_init_val;
271
272 /* the following offsets are in 4-byte units */
273 __le16 mac80211_hdr_offset;
274 __le16 msdu_payload_offset;
275 __le16 ppdu_start_offset;
276 __le16 ppdu_end_offset;
277 __le16 mpdu_start_offset;
278 __le16 mpdu_end_offset;
279 __le16 msdu_start_offset;
280 __le16 msdu_end_offset;
281 __le16 rx_attention_offset;
282 __le16 frag_info_offset;
283} __packed;
284
285struct htt_rx_ring_setup_hdr {
286 u8 num_rings; /* supported values: 1, 2 */
287 __le16 rsvd0;
288} __packed;
289
290struct htt_rx_ring_setup_32 {
291 struct htt_rx_ring_setup_hdr hdr;
292 struct htt_rx_ring_setup_ring32 rings[];
293} __packed;
294
295struct htt_rx_ring_setup_64 {
296 struct htt_rx_ring_setup_hdr hdr;
297 struct htt_rx_ring_setup_ring64 rings[];
298} __packed;
299
300/*
301 * htt_stats_req - request target to send specified statistics
302 *
303 * @msg_type: hardcoded %HTT_H2T_MSG_TYPE_STATS_REQ
304 * @upload_types: see %htt_dbg_stats_type. this is 24bit field actually
305 * so make sure its little-endian.
306 * @reset_types: see %htt_dbg_stats_type. this is 24bit field actually
307 * so make sure its little-endian.
308 * @cfg_val: stat_type specific configuration
309 * @stat_type: see %htt_dbg_stats_type
310 * @cookie_lsb: used for confirmation message from target->host
311 * @cookie_msb: ditto as %cookie
312 */
313struct htt_stats_req {
314 u8 upload_types[3];
315 u8 rsvd0;
316 u8 reset_types[3];
317 struct {
318 u8 mpdu_bytes;
319 u8 mpdu_num_msdus;
320 u8 msdu_bytes;
321 } __packed;
322 u8 stat_type;
323 __le32 cookie_lsb;
324 __le32 cookie_msb;
325} __packed;
326
327#define HTT_STATS_REQ_CFG_STAT_TYPE_INVALID 0xff
328#define HTT_STATS_BIT_MASK GENMASK(16, 0)
329
330/*
331 * htt_oob_sync_req - request out-of-band sync
332 *
333 * The HTT SYNC tells the target to suspend processing of subsequent
334 * HTT host-to-target messages until some other target agent locally
335 * informs the target HTT FW that the current sync counter is equal to
336 * or greater than (in a modulo sense) the sync counter specified in
337 * the SYNC message.
338 *
339 * This allows other host-target components to synchronize their operation
340 * with HTT, e.g. to ensure that tx frames don't get transmitted until a
341 * security key has been downloaded to and activated by the target.
342 * In the absence of any explicit synchronization counter value
343 * specification, the target HTT FW will use zero as the default current
344 * sync value.
345 *
346 * The HTT target FW will suspend its host->target message processing as long
347 * as 0 < (in-band sync counter - out-of-band sync counter) & 0xff < 128.
348 */
349struct htt_oob_sync_req {
350 u8 sync_count;
351 __le16 rsvd0;
352} __packed;
353
354struct htt_aggr_conf {
355 u8 max_num_ampdu_subframes;
356 /* amsdu_subframes is limited by 0x1F mask */
357 u8 max_num_amsdu_subframes;
358} __packed;
359
360struct htt_aggr_conf_v2 {
361 u8 max_num_ampdu_subframes;
362 /* amsdu_subframes is limited by 0x1F mask */
363 u8 max_num_amsdu_subframes;
364 u8 reserved;
365} __packed;
366
367#define HTT_MGMT_FRM_HDR_DOWNLOAD_LEN 32
368struct htt_mgmt_tx_desc_qca99x0 {
369 __le32 rate;
370} __packed;
371
372struct htt_mgmt_tx_desc {
373 u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
374 __le32 msdu_paddr;
375 __le32 desc_id;
376 __le32 len;
377 __le32 vdev_id;
378 u8 hdr[HTT_MGMT_FRM_HDR_DOWNLOAD_LEN];
379 union {
380 struct htt_mgmt_tx_desc_qca99x0 qca99x0;
381 } __packed;
382} __packed;
383
384enum htt_mgmt_tx_status {
385 HTT_MGMT_TX_STATUS_OK = 0,
386 HTT_MGMT_TX_STATUS_RETRY = 1,
387 HTT_MGMT_TX_STATUS_DROP = 2
388};
389
390/*=== target -> host messages ===============================================*/
391
392enum htt_main_t2h_msg_type {
393 HTT_MAIN_T2H_MSG_TYPE_VERSION_CONF = 0x0,
394 HTT_MAIN_T2H_MSG_TYPE_RX_IND = 0x1,
395 HTT_MAIN_T2H_MSG_TYPE_RX_FLUSH = 0x2,
396 HTT_MAIN_T2H_MSG_TYPE_PEER_MAP = 0x3,
397 HTT_MAIN_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
398 HTT_MAIN_T2H_MSG_TYPE_RX_ADDBA = 0x5,
399 HTT_MAIN_T2H_MSG_TYPE_RX_DELBA = 0x6,
400 HTT_MAIN_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
401 HTT_MAIN_T2H_MSG_TYPE_PKTLOG = 0x8,
402 HTT_MAIN_T2H_MSG_TYPE_STATS_CONF = 0x9,
403 HTT_MAIN_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
404 HTT_MAIN_T2H_MSG_TYPE_SEC_IND = 0xb,
405 HTT_MAIN_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
406 HTT_MAIN_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
407 HTT_MAIN_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0xf,
408 HTT_MAIN_T2H_MSG_TYPE_RX_PN_IND = 0x10,
409 HTT_MAIN_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,
410 HTT_MAIN_T2H_MSG_TYPE_TEST,
411 /* keep this last */
412 HTT_MAIN_T2H_NUM_MSGS
413};
414
415enum htt_10x_t2h_msg_type {
416 HTT_10X_T2H_MSG_TYPE_VERSION_CONF = 0x0,
417 HTT_10X_T2H_MSG_TYPE_RX_IND = 0x1,
418 HTT_10X_T2H_MSG_TYPE_RX_FLUSH = 0x2,
419 HTT_10X_T2H_MSG_TYPE_PEER_MAP = 0x3,
420 HTT_10X_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
421 HTT_10X_T2H_MSG_TYPE_RX_ADDBA = 0x5,
422 HTT_10X_T2H_MSG_TYPE_RX_DELBA = 0x6,
423 HTT_10X_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
424 HTT_10X_T2H_MSG_TYPE_PKTLOG = 0x8,
425 HTT_10X_T2H_MSG_TYPE_STATS_CONF = 0x9,
426 HTT_10X_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
427 HTT_10X_T2H_MSG_TYPE_SEC_IND = 0xb,
428 HTT_10X_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,
429 HTT_10X_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
430 HTT_10X_T2H_MSG_TYPE_TEST = 0xe,
431 HTT_10X_T2H_MSG_TYPE_CHAN_CHANGE = 0xf,
432 HTT_10X_T2H_MSG_TYPE_AGGR_CONF = 0x11,
433 HTT_10X_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x12,
434 HTT_10X_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0x13,
435 /* keep this last */
436 HTT_10X_T2H_NUM_MSGS
437};
438
439enum htt_tlv_t2h_msg_type {
440 HTT_TLV_T2H_MSG_TYPE_VERSION_CONF = 0x0,
441 HTT_TLV_T2H_MSG_TYPE_RX_IND = 0x1,
442 HTT_TLV_T2H_MSG_TYPE_RX_FLUSH = 0x2,
443 HTT_TLV_T2H_MSG_TYPE_PEER_MAP = 0x3,
444 HTT_TLV_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
445 HTT_TLV_T2H_MSG_TYPE_RX_ADDBA = 0x5,
446 HTT_TLV_T2H_MSG_TYPE_RX_DELBA = 0x6,
447 HTT_TLV_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
448 HTT_TLV_T2H_MSG_TYPE_PKTLOG = 0x8,
449 HTT_TLV_T2H_MSG_TYPE_STATS_CONF = 0x9,
450 HTT_TLV_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
451 HTT_TLV_T2H_MSG_TYPE_SEC_IND = 0xb,
452 HTT_TLV_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc, /* deprecated */
453 HTT_TLV_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
454 HTT_TLV_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
455 HTT_TLV_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0xf,
456 HTT_TLV_T2H_MSG_TYPE_RX_PN_IND = 0x10,
457 HTT_TLV_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,
458 HTT_TLV_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND = 0x12,
459 /* 0x13 reservd */
460 HTT_TLV_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE = 0x14,
461 HTT_TLV_T2H_MSG_TYPE_CHAN_CHANGE = 0x15,
462 HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR = 0x16,
463 HTT_TLV_T2H_MSG_TYPE_TEST,
464 /* keep this last */
465 HTT_TLV_T2H_NUM_MSGS
466};
467
468enum htt_10_4_t2h_msg_type {
469 HTT_10_4_T2H_MSG_TYPE_VERSION_CONF = 0x0,
470 HTT_10_4_T2H_MSG_TYPE_RX_IND = 0x1,
471 HTT_10_4_T2H_MSG_TYPE_RX_FLUSH = 0x2,
472 HTT_10_4_T2H_MSG_TYPE_PEER_MAP = 0x3,
473 HTT_10_4_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
474 HTT_10_4_T2H_MSG_TYPE_RX_ADDBA = 0x5,
475 HTT_10_4_T2H_MSG_TYPE_RX_DELBA = 0x6,
476 HTT_10_4_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
477 HTT_10_4_T2H_MSG_TYPE_PKTLOG = 0x8,
478 HTT_10_4_T2H_MSG_TYPE_STATS_CONF = 0x9,
479 HTT_10_4_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
480 HTT_10_4_T2H_MSG_TYPE_SEC_IND = 0xb,
481 HTT_10_4_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,
482 HTT_10_4_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
483 HTT_10_4_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
484 HTT_10_4_T2H_MSG_TYPE_CHAN_CHANGE = 0xf,
485 HTT_10_4_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0x10,
486 HTT_10_4_T2H_MSG_TYPE_RX_PN_IND = 0x11,
487 HTT_10_4_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x12,
488 HTT_10_4_T2H_MSG_TYPE_TEST = 0x13,
489 HTT_10_4_T2H_MSG_TYPE_EN_STATS = 0x14,
490 HTT_10_4_T2H_MSG_TYPE_AGGR_CONF = 0x15,
491 HTT_10_4_T2H_MSG_TYPE_TX_FETCH_IND = 0x16,
492 HTT_10_4_T2H_MSG_TYPE_TX_FETCH_CONFIRM = 0x17,
493 HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x18,
494 /* 0x19 to 0x2f are reserved */
495 HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND = 0x30,
496 HTT_10_4_T2H_MSG_TYPE_PEER_STATS = 0x31,
497 /* keep this last */
498 HTT_10_4_T2H_NUM_MSGS
499};
500
501enum htt_t2h_msg_type {
502 HTT_T2H_MSG_TYPE_VERSION_CONF,
503 HTT_T2H_MSG_TYPE_RX_IND,
504 HTT_T2H_MSG_TYPE_RX_FLUSH,
505 HTT_T2H_MSG_TYPE_PEER_MAP,
506 HTT_T2H_MSG_TYPE_PEER_UNMAP,
507 HTT_T2H_MSG_TYPE_RX_ADDBA,
508 HTT_T2H_MSG_TYPE_RX_DELBA,
509 HTT_T2H_MSG_TYPE_TX_COMPL_IND,
510 HTT_T2H_MSG_TYPE_PKTLOG,
511 HTT_T2H_MSG_TYPE_STATS_CONF,
512 HTT_T2H_MSG_TYPE_RX_FRAG_IND,
513 HTT_T2H_MSG_TYPE_SEC_IND,
514 HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
515 HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
516 HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
517 HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
518 HTT_T2H_MSG_TYPE_RX_PN_IND,
519 HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
520 HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND,
521 HTT_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE,
522 HTT_T2H_MSG_TYPE_CHAN_CHANGE,
523 HTT_T2H_MSG_TYPE_RX_OFLD_PKT_ERR,
524 HTT_T2H_MSG_TYPE_AGGR_CONF,
525 HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
526 HTT_T2H_MSG_TYPE_TEST,
527 HTT_T2H_MSG_TYPE_EN_STATS,
528 HTT_T2H_MSG_TYPE_TX_FETCH_IND,
529 HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
530 HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
531 HTT_T2H_MSG_TYPE_PEER_STATS,
532 /* keep this last */
533 HTT_T2H_NUM_MSGS
534};
535
536/*
537 * htt_resp_hdr - header for target-to-host messages
538 *
539 * msg_type: see htt_t2h_msg_type
540 */
541struct htt_resp_hdr {
542 u8 msg_type;
543} __packed;
544
545#define HTT_RESP_HDR_MSG_TYPE_OFFSET 0
546#define HTT_RESP_HDR_MSG_TYPE_MASK 0xff
547#define HTT_RESP_HDR_MSG_TYPE_LSB 0
548
549/* htt_ver_resp - response sent for htt_ver_req */
550struct htt_ver_resp {
551 u8 minor;
552 u8 major;
553 u8 rsvd0;
554} __packed;
555
556#define HTT_MGMT_TX_CMPL_FLAG_ACK_RSSI BIT(0)
557
558#define HTT_MGMT_TX_CMPL_INFO_ACK_RSSI_MASK GENMASK(7, 0)
559
560struct htt_mgmt_tx_completion {
561 u8 rsvd0;
562 u8 rsvd1;
563 u8 flags;
564 __le32 desc_id;
565 __le32 status;
566 __le32 ppdu_id;
567 __le32 info;
568} __packed;
569
570#define HTT_RX_INDICATION_INFO0_EXT_TID_MASK (0x1F)
571#define HTT_RX_INDICATION_INFO0_EXT_TID_LSB (0)
572#define HTT_RX_INDICATION_INFO0_FLUSH_VALID (1 << 5)
573#define HTT_RX_INDICATION_INFO0_RELEASE_VALID (1 << 6)
574#define HTT_RX_INDICATION_INFO0_PPDU_DURATION BIT(7)
575
576#define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_MASK 0x0000003F
577#define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_LSB 0
578#define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_MASK 0x00000FC0
579#define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_LSB 6
580#define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_MASK 0x0003F000
581#define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_LSB 12
582#define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_MASK 0x00FC0000
583#define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_LSB 18
584#define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_MASK 0xFF000000
585#define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_LSB 24
586
587#define HTT_TX_CMPL_FLAG_DATA_RSSI BIT(0)
588#define HTT_TX_CMPL_FLAG_PPID_PRESENT BIT(1)
589#define HTT_TX_CMPL_FLAG_PA_PRESENT BIT(2)
590#define HTT_TX_CMPL_FLAG_PPDU_DURATION_PRESENT BIT(3)
591
592#define HTT_TX_DATA_RSSI_ENABLE_WCN3990 BIT(3)
593#define HTT_TX_DATA_APPEND_RETRIES BIT(0)
594#define HTT_TX_DATA_APPEND_TIMESTAMP BIT(1)
595
596struct htt_rx_indication_hdr {
597 u8 info0; /* %HTT_RX_INDICATION_INFO0_ */
598 __le16 peer_id;
599 __le32 info1; /* %HTT_RX_INDICATION_INFO1_ */
600} __packed;
601
602#define HTT_RX_INDICATION_INFO0_PHY_ERR_VALID (1 << 0)
603#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_MASK (0x1E)
604#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_LSB (1)
605#define HTT_RX_INDICATION_INFO0_LEGACY_RATE_CCK (1 << 5)
606#define HTT_RX_INDICATION_INFO0_END_VALID (1 << 6)
607#define HTT_RX_INDICATION_INFO0_START_VALID (1 << 7)
608
609#define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_MASK 0x00FFFFFF
610#define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_LSB 0
611#define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_MASK 0xFF000000
612#define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_LSB 24
613
614#define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_MASK 0x00FFFFFF
615#define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_LSB 0
616#define HTT_RX_INDICATION_INFO2_SERVICE_MASK 0xFF000000
617#define HTT_RX_INDICATION_INFO2_SERVICE_LSB 24
618
619enum htt_rx_legacy_rate {
620 HTT_RX_OFDM_48 = 0,
621 HTT_RX_OFDM_24 = 1,
622 HTT_RX_OFDM_12,
623 HTT_RX_OFDM_6,
624 HTT_RX_OFDM_54,
625 HTT_RX_OFDM_36,
626 HTT_RX_OFDM_18,
627 HTT_RX_OFDM_9,
628
629 /* long preamble */
630 HTT_RX_CCK_11_LP = 0,
631 HTT_RX_CCK_5_5_LP = 1,
632 HTT_RX_CCK_2_LP,
633 HTT_RX_CCK_1_LP,
634 /* short preamble */
635 HTT_RX_CCK_11_SP,
636 HTT_RX_CCK_5_5_SP,
637 HTT_RX_CCK_2_SP
638};
639
640enum htt_rx_legacy_rate_type {
641 HTT_RX_LEGACY_RATE_OFDM = 0,
642 HTT_RX_LEGACY_RATE_CCK
643};
644
645enum htt_rx_preamble_type {
646 HTT_RX_LEGACY = 0x4,
647 HTT_RX_HT = 0x8,
648 HTT_RX_HT_WITH_TXBF = 0x9,
649 HTT_RX_VHT = 0xC,
650 HTT_RX_VHT_WITH_TXBF = 0xD,
651};
652
653/*
654 * Fields: phy_err_valid, phy_err_code, tsf,
655 * usec_timestamp, sub_usec_timestamp
656 * ..are valid only if end_valid == 1.
657 *
658 * Fields: rssi_chains, legacy_rate_type,
659 * legacy_rate_cck, preamble_type, service,
660 * vht_sig_*
661 * ..are valid only if start_valid == 1;
662 */
663struct htt_rx_indication_ppdu {
664 u8 combined_rssi;
665 u8 sub_usec_timestamp;
666 u8 phy_err_code;
667 u8 info0; /* HTT_RX_INDICATION_INFO0_ */
668 struct {
669 u8 pri20_db;
670 u8 ext20_db;
671 u8 ext40_db;
672 u8 ext80_db;
673 } __packed rssi_chains[4];
674 __le32 tsf;
675 __le32 usec_timestamp;
676 __le32 info1; /* HTT_RX_INDICATION_INFO1_ */
677 __le32 info2; /* HTT_RX_INDICATION_INFO2_ */
678} __packed;
679
680enum htt_rx_mpdu_status {
681 HTT_RX_IND_MPDU_STATUS_UNKNOWN = 0x0,
682 HTT_RX_IND_MPDU_STATUS_OK,
683 HTT_RX_IND_MPDU_STATUS_ERR_FCS,
684 HTT_RX_IND_MPDU_STATUS_ERR_DUP,
685 HTT_RX_IND_MPDU_STATUS_ERR_REPLAY,
686 HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER,
687 /* only accept EAPOL frames */
688 HTT_RX_IND_MPDU_STATUS_UNAUTH_PEER,
689 HTT_RX_IND_MPDU_STATUS_OUT_OF_SYNC,
690 /* Non-data in promiscuous mode */
691 HTT_RX_IND_MPDU_STATUS_MGMT_CTRL,
692 HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR,
693 HTT_RX_IND_MPDU_STATUS_DECRYPT_ERR,
694 HTT_RX_IND_MPDU_STATUS_MPDU_LENGTH_ERR,
695 HTT_RX_IND_MPDU_STATUS_ENCRYPT_REQUIRED_ERR,
696 HTT_RX_IND_MPDU_STATUS_PRIVACY_ERR,
697
698 /*
699 * MISC: discard for unspecified reasons.
700 * Leave this enum value last.
701 */
702 HTT_RX_IND_MPDU_STATUS_ERR_MISC = 0xFF
703};
704
705struct htt_rx_indication_mpdu_range {
706 u8 mpdu_count;
707 u8 mpdu_range_status; /* %htt_rx_mpdu_status */
708 u8 pad0;
709 u8 pad1;
710} __packed;
711
712struct htt_rx_indication_prefix {
713 __le16 fw_rx_desc_bytes;
714 u8 pad0;
715 u8 pad1;
716};
717
718struct htt_rx_indication {
719 struct htt_rx_indication_hdr hdr;
720 struct htt_rx_indication_ppdu ppdu;
721 struct htt_rx_indication_prefix prefix;
722
723 /*
724 * the following fields are both dynamically sized, so
725 * take care addressing them
726 */
727
728 /* the size of this is %fw_rx_desc_bytes */
729 struct fw_rx_desc_base fw_desc;
730
731 /*
732 * %mpdu_ranges starts after &%prefix + roundup(%fw_rx_desc_bytes, 4)
733 * and has %num_mpdu_ranges elements.
734 */
735 struct htt_rx_indication_mpdu_range mpdu_ranges[];
736} __packed;
737
738/* High latency version of the RX indication */
739struct htt_rx_indication_hl {
740 struct htt_rx_indication_hdr hdr;
741 struct htt_rx_indication_ppdu ppdu;
742 struct htt_rx_indication_prefix prefix;
743 struct fw_rx_desc_hl fw_desc;
744 struct htt_rx_indication_mpdu_range mpdu_ranges[];
745} __packed;
746
747struct htt_hl_rx_desc {
748 __le32 info;
749 __le32 pn_31_0;
750 union {
751 struct {
752 __le16 pn_47_32;
753 __le16 pn_63_48;
754 } pn16;
755 __le32 pn_63_32;
756 } u0;
757 __le32 pn_95_64;
758 __le32 pn_127_96;
759} __packed;
760
761static inline struct htt_rx_indication_mpdu_range *
762 htt_rx_ind_get_mpdu_ranges(struct htt_rx_indication *rx_ind)
763{
764 void *ptr = rx_ind;
765
766 ptr += sizeof(rx_ind->hdr)
767 + sizeof(rx_ind->ppdu)
768 + sizeof(rx_ind->prefix)
769 + roundup(__le16_to_cpu(rx_ind->prefix.fw_rx_desc_bytes), 4);
770 return ptr;
771}
772
773static inline struct htt_rx_indication_mpdu_range *
774 htt_rx_ind_get_mpdu_ranges_hl(struct htt_rx_indication_hl *rx_ind)
775{
776 void *ptr = rx_ind;
777
778 ptr += sizeof(rx_ind->hdr)
779 + sizeof(rx_ind->ppdu)
780 + sizeof(rx_ind->prefix)
781 + sizeof(rx_ind->fw_desc);
782 return ptr;
783}
784
785enum htt_rx_flush_mpdu_status {
786 HTT_RX_FLUSH_MPDU_DISCARD = 0,
787 HTT_RX_FLUSH_MPDU_REORDER = 1,
788};
789
790/*
791 * htt_rx_flush - discard or reorder given range of mpdus
792 *
793 * Note: host must check if all sequence numbers between
794 * [seq_num_start, seq_num_end-1] are valid.
795 */
796struct htt_rx_flush {
797 __le16 peer_id;
798 u8 tid;
799 u8 rsvd0;
800 u8 mpdu_status; /* %htt_rx_flush_mpdu_status */
801 u8 seq_num_start; /* it is 6 LSBs of 802.11 seq no */
802 u8 seq_num_end; /* it is 6 LSBs of 802.11 seq no */
803};
804
805struct htt_rx_peer_map {
806 u8 vdev_id;
807 __le16 peer_id;
808 u8 addr[6];
809 u8 rsvd0;
810 u8 rsvd1;
811} __packed;
812
813struct htt_rx_peer_unmap {
814 u8 rsvd0;
815 __le16 peer_id;
816} __packed;
817
818enum htt_txrx_sec_cast_type {
819 HTT_TXRX_SEC_MCAST = 0,
820 HTT_TXRX_SEC_UCAST
821};
822
823enum htt_rx_pn_check_type {
824 HTT_RX_NON_PN_CHECK = 0,
825 HTT_RX_PN_CHECK
826};
827
828enum htt_rx_tkip_demic_type {
829 HTT_RX_NON_TKIP_MIC = 0,
830 HTT_RX_TKIP_MIC
831};
832
833enum htt_security_types {
834 HTT_SECURITY_NONE,
835 HTT_SECURITY_WEP128,
836 HTT_SECURITY_WEP104,
837 HTT_SECURITY_WEP40,
838 HTT_SECURITY_TKIP,
839 HTT_SECURITY_TKIP_NOMIC,
840 HTT_SECURITY_AES_CCMP,
841 HTT_SECURITY_WAPI,
842
843 HTT_NUM_SECURITY_TYPES /* keep this last! */
844};
845
846#define ATH10K_HTT_TXRX_PEER_SECURITY_MAX 2
847#define ATH10K_TXRX_NUM_EXT_TIDS 19
848
849enum htt_security_flags {
850#define HTT_SECURITY_TYPE_MASK 0x7F
851#define HTT_SECURITY_TYPE_LSB 0
852 HTT_SECURITY_IS_UNICAST = 1 << 7
853};
854
855struct htt_security_indication {
856 union {
857 /* dont use bitfields; undefined behaviour */
858 u8 flags; /* %htt_security_flags */
859 struct {
860 u8 security_type:7, /* %htt_security_types */
861 is_unicast:1;
862 } __packed;
863 } __packed;
864 __le16 peer_id;
865 u8 michael_key[8];
866 u8 wapi_rsc[16];
867} __packed;
868
869#define HTT_RX_BA_INFO0_TID_MASK 0x000F
870#define HTT_RX_BA_INFO0_TID_LSB 0
871#define HTT_RX_BA_INFO0_PEER_ID_MASK 0xFFF0
872#define HTT_RX_BA_INFO0_PEER_ID_LSB 4
873
874struct htt_rx_addba {
875 u8 window_size;
876 __le16 info0; /* %HTT_RX_BA_INFO0_ */
877} __packed;
878
879struct htt_rx_delba {
880 u8 rsvd0;
881 __le16 info0; /* %HTT_RX_BA_INFO0_ */
882} __packed;
883
884enum htt_data_tx_status {
885 HTT_DATA_TX_STATUS_OK = 0,
886 HTT_DATA_TX_STATUS_DISCARD = 1,
887 HTT_DATA_TX_STATUS_NO_ACK = 2,
888 HTT_DATA_TX_STATUS_POSTPONE = 3, /* HL only */
889 HTT_DATA_TX_STATUS_DOWNLOAD_FAIL = 128
890};
891
892enum htt_data_tx_flags {
893#define HTT_DATA_TX_STATUS_MASK 0x07
894#define HTT_DATA_TX_STATUS_LSB 0
895#define HTT_DATA_TX_TID_MASK 0x78
896#define HTT_DATA_TX_TID_LSB 3
897 HTT_DATA_TX_TID_INVALID = 1 << 7
898};
899
900#define HTT_TX_COMPL_INV_MSDU_ID 0xFFFF
901
902struct htt_append_retries {
903 __le16 msdu_id;
904 u8 tx_retries;
905 u8 flag;
906} __packed;
907
908struct htt_data_tx_completion_ext {
909 struct htt_append_retries a_retries;
910 __le32 t_stamp;
911 __le16 msdus_rssi[];
912} __packed;
913
914/**
915 * @brief target -> host TX completion indication message definition
916 *
917 * @details
918 * The following diagram shows the format of the TX completion indication sent
919 * from the target to the host
920 *
921 * |31 28|27|26|25|24|23 16| 15 |14 11|10 8|7 0|
922 * |-------------------------------------------------------------|
923 * header: |rsvd |A2|TP|A1|A0| num | t_i| tid |status| msg_type |
924 * |-------------------------------------------------------------|
925 * payload: | MSDU1 ID | MSDU0 ID |
926 * |-------------------------------------------------------------|
927 * : MSDU3 ID : MSDU2 ID :
928 * |-------------------------------------------------------------|
929 * | struct htt_tx_compl_ind_append_retries |
930 * |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
931 * | struct htt_tx_compl_ind_append_tx_tstamp |
932 * |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
933 * | MSDU1 ACK RSSI | MSDU0 ACK RSSI |
934 * |-------------------------------------------------------------|
935 * : MSDU3 ACK RSSI : MSDU2 ACK RSSI :
936 * |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
937 * -msg_type
938 * Bits 7:0
939 * Purpose: identifies this as HTT TX completion indication
940 * -status
941 * Bits 10:8
942 * Purpose: the TX completion status of payload fragmentations descriptors
943 * Value: could be HTT_TX_COMPL_IND_STAT_OK or HTT_TX_COMPL_IND_STAT_DISCARD
944 * -tid
945 * Bits 14:11
946 * Purpose: the tid associated with those fragmentation descriptors. It is
947 * valid or not, depending on the tid_invalid bit.
948 * Value: 0 to 15
949 * -tid_invalid
950 * Bits 15:15
951 * Purpose: this bit indicates whether the tid field is valid or not
952 * Value: 0 indicates valid, 1 indicates invalid
953 * -num
954 * Bits 23:16
955 * Purpose: the number of payload in this indication
956 * Value: 1 to 255
957 * -A0 = append
958 * Bits 24:24
959 * Purpose: append the struct htt_tx_compl_ind_append_retries which contains
960 * the number of tx retries for one MSDU at the end of this message
961 * Value: 0 indicates no appending, 1 indicates appending
962 * -A1 = append1
963 * Bits 25:25
964 * Purpose: Append the struct htt_tx_compl_ind_append_tx_tstamp which
965 * contains the timestamp info for each TX msdu id in payload.
966 * Value: 0 indicates no appending, 1 indicates appending
967 * -TP = MSDU tx power presence
968 * Bits 26:26
969 * Purpose: Indicate whether the TX_COMPL_IND includes a tx power report
970 * for each MSDU referenced by the TX_COMPL_IND message.
971 * The order of the per-MSDU tx power reports matches the order
972 * of the MSDU IDs.
973 * Value: 0 indicates not appending, 1 indicates appending
974 * -A2 = append2
975 * Bits 27:27
976 * Purpose: Indicate whether data ACK RSSI is appended for each MSDU in
977 * TX_COMP_IND message. The order of the per-MSDU ACK RSSI report
978 * matches the order of the MSDU IDs.
979 * The ACK RSSI values are valid when status is COMPLETE_OK (and
980 * this append2 bit is set).
981 * Value: 0 indicates not appending, 1 indicates appending
982 */
983
984struct htt_data_tx_completion {
985 union {
986 u8 flags;
987 struct {
988 u8 status:3,
989 tid:4,
990 tid_invalid:1;
991 } __packed;
992 } __packed;
993 u8 num_msdus;
994 u8 flags2; /* HTT_TX_CMPL_FLAG_DATA_RSSI */
995 __le16 msdus[]; /* variable length based on %num_msdus */
996} __packed;
997
998#define HTT_TX_PPDU_DUR_INFO0_PEER_ID_MASK GENMASK(15, 0)
999#define HTT_TX_PPDU_DUR_INFO0_TID_MASK GENMASK(20, 16)
1000
1001struct htt_data_tx_ppdu_dur {
1002 __le32 info0; /* HTT_TX_PPDU_DUR_INFO0_ */
1003 __le32 tx_duration; /* in usecs */
1004} __packed;
1005
1006#define HTT_TX_COMPL_PPDU_DUR_INFO0_NUM_ENTRIES_MASK GENMASK(7, 0)
1007
1008struct htt_data_tx_compl_ppdu_dur {
1009 __le32 info0; /* HTT_TX_COMPL_PPDU_DUR_INFO0_ */
1010 struct htt_data_tx_ppdu_dur ppdu_dur[];
1011} __packed;
1012
1013struct htt_tx_compl_ind_base {
1014 u32 hdr;
1015 u16 payload[1/*or more*/];
1016} __packed;
1017
1018struct htt_rc_tx_done_params {
1019 u32 rate_code;
1020 u32 rate_code_flags;
1021 u32 flags;
1022 u32 num_enqued; /* 1 for non-AMPDU */
1023 u32 num_retries;
1024 u32 num_failed; /* for AMPDU */
1025 u32 ack_rssi;
1026 u32 time_stamp;
1027 u32 is_probe;
1028};
1029
1030struct htt_rc_update {
1031 u8 vdev_id;
1032 __le16 peer_id;
1033 u8 addr[6];
1034 u8 num_elems;
1035 u8 rsvd0;
1036 struct htt_rc_tx_done_params params[]; /* variable length %num_elems */
1037} __packed;
1038
1039/* see htt_rx_indication for similar fields and descriptions */
1040struct htt_rx_fragment_indication {
1041 union {
1042 u8 info0; /* %HTT_RX_FRAG_IND_INFO0_ */
1043 struct {
1044 u8 ext_tid:5,
1045 flush_valid:1;
1046 } __packed;
1047 } __packed;
1048 __le16 peer_id;
1049 __le32 info1; /* %HTT_RX_FRAG_IND_INFO1_ */
1050 __le16 fw_rx_desc_bytes;
1051 __le16 rsvd0;
1052
1053 u8 fw_msdu_rx_desc[];
1054} __packed;
1055
1056#define ATH10K_IEEE80211_EXTIV BIT(5)
1057#define ATH10K_IEEE80211_TKIP_MICLEN 8 /* trailing MIC */
1058
1059#define HTT_RX_FRAG_IND_INFO0_HEADER_LEN 16
1060
1061#define HTT_RX_FRAG_IND_INFO0_EXT_TID_MASK 0x1F
1062#define HTT_RX_FRAG_IND_INFO0_EXT_TID_LSB 0
1063#define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_MASK 0x20
1064#define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_LSB 5
1065
1066#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_MASK 0x0000003F
1067#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_LSB 0
1068#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_MASK 0x00000FC0
1069#define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_LSB 6
1070
1071struct htt_rx_pn_ind {
1072 __le16 peer_id;
1073 u8 tid;
1074 u8 seqno_start;
1075 u8 seqno_end;
1076 u8 pn_ie_count;
1077 u8 reserved;
1078 u8 pn_ies[];
1079} __packed;
1080
1081struct htt_rx_offload_msdu {
1082 __le16 msdu_len;
1083 __le16 peer_id;
1084 u8 vdev_id;
1085 u8 tid;
1086 u8 fw_desc;
1087 u8 payload[];
1088} __packed;
1089
1090struct htt_rx_offload_ind {
1091 u8 reserved;
1092 __le16 msdu_count;
1093} __packed;
1094
1095struct htt_rx_in_ord_msdu_desc {
1096 __le32 msdu_paddr;
1097 __le16 msdu_len;
1098 u8 fw_desc;
1099 u8 reserved;
1100} __packed;
1101
1102struct htt_rx_in_ord_msdu_desc_ext {
1103 __le64 msdu_paddr;
1104 __le16 msdu_len;
1105 u8 fw_desc;
1106 u8 reserved;
1107} __packed;
1108
1109struct htt_rx_in_ord_ind {
1110 u8 info;
1111 __le16 peer_id;
1112 u8 vdev_id;
1113 u8 reserved;
1114 __le16 msdu_count;
1115 union {
1116 struct htt_rx_in_ord_msdu_desc msdu_descs32[0];
1117 struct htt_rx_in_ord_msdu_desc_ext msdu_descs64[0];
1118 } __packed;
1119} __packed;
1120
1121#define HTT_RX_IN_ORD_IND_INFO_TID_MASK 0x0000001f
1122#define HTT_RX_IN_ORD_IND_INFO_TID_LSB 0
1123#define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_MASK 0x00000020
1124#define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_LSB 5
1125#define HTT_RX_IN_ORD_IND_INFO_FRAG_MASK 0x00000040
1126#define HTT_RX_IN_ORD_IND_INFO_FRAG_LSB 6
1127
1128/*
1129 * target -> host test message definition
1130 *
1131 * The following field definitions describe the format of the test
1132 * message sent from the target to the host.
1133 * The message consists of a 4-octet header, followed by a variable
1134 * number of 32-bit integer values, followed by a variable number
1135 * of 8-bit character values.
1136 *
1137 * |31 16|15 8|7 0|
1138 * |-----------------------------------------------------------|
1139 * | num chars | num ints | msg type |
1140 * |-----------------------------------------------------------|
1141 * | int 0 |
1142 * |-----------------------------------------------------------|
1143 * | int 1 |
1144 * |-----------------------------------------------------------|
1145 * | ... |
1146 * |-----------------------------------------------------------|
1147 * | char 3 | char 2 | char 1 | char 0 |
1148 * |-----------------------------------------------------------|
1149 * | | | ... | char 4 |
1150 * |-----------------------------------------------------------|
1151 * - MSG_TYPE
1152 * Bits 7:0
1153 * Purpose: identifies this as a test message
1154 * Value: HTT_MSG_TYPE_TEST
1155 * - NUM_INTS
1156 * Bits 15:8
1157 * Purpose: indicate how many 32-bit integers follow the message header
1158 * - NUM_CHARS
1159 * Bits 31:16
1160 * Purpose: indicate how many 8-bit characters follow the series of integers
1161 */
1162struct htt_rx_test {
1163 u8 num_ints;
1164 __le16 num_chars;
1165
1166 /* payload consists of 2 lists:
1167 * a) num_ints * sizeof(__le32)
1168 * b) num_chars * sizeof(u8) aligned to 4bytes
1169 */
1170 u8 payload[];
1171} __packed;
1172
1173static inline __le32 *htt_rx_test_get_ints(struct htt_rx_test *rx_test)
1174{
1175 return (__le32 *)rx_test->payload;
1176}
1177
1178static inline u8 *htt_rx_test_get_chars(struct htt_rx_test *rx_test)
1179{
1180 return rx_test->payload + (rx_test->num_ints * sizeof(__le32));
1181}
1182
1183/*
1184 * target -> host packet log message
1185 *
1186 * The following field definitions describe the format of the packet log
1187 * message sent from the target to the host.
1188 * The message consists of a 4-octet header,followed by a variable number
1189 * of 32-bit character values.
1190 *
1191 * |31 24|23 16|15 8|7 0|
1192 * |-----------------------------------------------------------|
1193 * | | | | msg type |
1194 * |-----------------------------------------------------------|
1195 * | payload |
1196 * |-----------------------------------------------------------|
1197 * - MSG_TYPE
1198 * Bits 7:0
1199 * Purpose: identifies this as a test message
1200 * Value: HTT_MSG_TYPE_PACKETLOG
1201 */
1202struct htt_pktlog_msg {
1203 u8 pad[3];
1204 u8 payload[];
1205} __packed;
1206
1207struct htt_dbg_stats_rx_reorder_stats {
1208 /* Non QoS MPDUs received */
1209 __le32 deliver_non_qos;
1210
1211 /* MPDUs received in-order */
1212 __le32 deliver_in_order;
1213
1214 /* Flush due to reorder timer expired */
1215 __le32 deliver_flush_timeout;
1216
1217 /* Flush due to move out of window */
1218 __le32 deliver_flush_oow;
1219
1220 /* Flush due to DELBA */
1221 __le32 deliver_flush_delba;
1222
1223 /* MPDUs dropped due to FCS error */
1224 __le32 fcs_error;
1225
1226 /* MPDUs dropped due to monitor mode non-data packet */
1227 __le32 mgmt_ctrl;
1228
1229 /* MPDUs dropped due to invalid peer */
1230 __le32 invalid_peer;
1231
1232 /* MPDUs dropped due to duplication (non aggregation) */
1233 __le32 dup_non_aggr;
1234
1235 /* MPDUs dropped due to processed before */
1236 __le32 dup_past;
1237
1238 /* MPDUs dropped due to duplicate in reorder queue */
1239 __le32 dup_in_reorder;
1240
1241 /* Reorder timeout happened */
1242 __le32 reorder_timeout;
1243
1244 /* invalid bar ssn */
1245 __le32 invalid_bar_ssn;
1246
1247 /* reorder reset due to bar ssn */
1248 __le32 ssn_reset;
1249};
1250
1251struct htt_dbg_stats_wal_tx_stats {
1252 /* Num HTT cookies queued to dispatch list */
1253 __le32 comp_queued;
1254
1255 /* Num HTT cookies dispatched */
1256 __le32 comp_delivered;
1257
1258 /* Num MSDU queued to WAL */
1259 __le32 msdu_enqued;
1260
1261 /* Num MPDU queue to WAL */
1262 __le32 mpdu_enqued;
1263
1264 /* Num MSDUs dropped by WMM limit */
1265 __le32 wmm_drop;
1266
1267 /* Num Local frames queued */
1268 __le32 local_enqued;
1269
1270 /* Num Local frames done */
1271 __le32 local_freed;
1272
1273 /* Num queued to HW */
1274 __le32 hw_queued;
1275
1276 /* Num PPDU reaped from HW */
1277 __le32 hw_reaped;
1278
1279 /* Num underruns */
1280 __le32 underrun;
1281
1282 /* Num PPDUs cleaned up in TX abort */
1283 __le32 tx_abort;
1284
1285 /* Num MPDUs requed by SW */
1286 __le32 mpdus_requed;
1287
1288 /* excessive retries */
1289 __le32 tx_ko;
1290
1291 /* data hw rate code */
1292 __le32 data_rc;
1293
1294 /* Scheduler self triggers */
1295 __le32 self_triggers;
1296
1297 /* frames dropped due to excessive sw retries */
1298 __le32 sw_retry_failure;
1299
1300 /* illegal rate phy errors */
1301 __le32 illgl_rate_phy_err;
1302
1303 /* wal pdev continuous xretry */
1304 __le32 pdev_cont_xretry;
1305
1306 /* wal pdev continuous xretry */
1307 __le32 pdev_tx_timeout;
1308
1309 /* wal pdev resets */
1310 __le32 pdev_resets;
1311
1312 __le32 phy_underrun;
1313
1314 /* MPDU is more than txop limit */
1315 __le32 txop_ovf;
1316} __packed;
1317
1318struct htt_dbg_stats_wal_rx_stats {
1319 /* Cnts any change in ring routing mid-ppdu */
1320 __le32 mid_ppdu_route_change;
1321
1322 /* Total number of statuses processed */
1323 __le32 status_rcvd;
1324
1325 /* Extra frags on rings 0-3 */
1326 __le32 r0_frags;
1327 __le32 r1_frags;
1328 __le32 r2_frags;
1329 __le32 r3_frags;
1330
1331 /* MSDUs / MPDUs delivered to HTT */
1332 __le32 htt_msdus;
1333 __le32 htt_mpdus;
1334
1335 /* MSDUs / MPDUs delivered to local stack */
1336 __le32 loc_msdus;
1337 __le32 loc_mpdus;
1338
1339 /* AMSDUs that have more MSDUs than the status ring size */
1340 __le32 oversize_amsdu;
1341
1342 /* Number of PHY errors */
1343 __le32 phy_errs;
1344
1345 /* Number of PHY errors drops */
1346 __le32 phy_err_drop;
1347
1348 /* Number of mpdu errors - FCS, MIC, ENC etc. */
1349 __le32 mpdu_errs;
1350} __packed;
1351
1352struct htt_dbg_stats_wal_peer_stats {
1353 __le32 dummy; /* REMOVE THIS ONCE REAL PEER STAT COUNTERS ARE ADDED */
1354} __packed;
1355
1356struct htt_dbg_stats_wal_pdev_txrx {
1357 struct htt_dbg_stats_wal_tx_stats tx_stats;
1358 struct htt_dbg_stats_wal_rx_stats rx_stats;
1359 struct htt_dbg_stats_wal_peer_stats peer_stats;
1360} __packed;
1361
1362struct htt_dbg_stats_rx_rate_info {
1363 __le32 mcs[10];
1364 __le32 sgi[10];
1365 __le32 nss[4];
1366 __le32 stbc[10];
1367 __le32 bw[3];
1368 __le32 pream[6];
1369 __le32 ldpc;
1370 __le32 txbf;
1371};
1372
1373/*
1374 * htt_dbg_stats_status -
1375 * present - The requested stats have been delivered in full.
1376 * This indicates that either the stats information was contained
1377 * in its entirety within this message, or else this message
1378 * completes the delivery of the requested stats info that was
1379 * partially delivered through earlier STATS_CONF messages.
1380 * partial - The requested stats have been delivered in part.
1381 * One or more subsequent STATS_CONF messages with the same
1382 * cookie value will be sent to deliver the remainder of the
1383 * information.
1384 * error - The requested stats could not be delivered, for example due
1385 * to a shortage of memory to construct a message holding the
1386 * requested stats.
1387 * invalid - The requested stat type is either not recognized, or the
1388 * target is configured to not gather the stats type in question.
1389 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1390 * series_done - This special value indicates that no further stats info
1391 * elements are present within a series of stats info elems
1392 * (within a stats upload confirmation message).
1393 */
1394enum htt_dbg_stats_status {
1395 HTT_DBG_STATS_STATUS_PRESENT = 0,
1396 HTT_DBG_STATS_STATUS_PARTIAL = 1,
1397 HTT_DBG_STATS_STATUS_ERROR = 2,
1398 HTT_DBG_STATS_STATUS_INVALID = 3,
1399 HTT_DBG_STATS_STATUS_SERIES_DONE = 7
1400};
1401
1402/*
1403 * target -> host statistics upload
1404 *
1405 * The following field definitions describe the format of the HTT target
1406 * to host stats upload confirmation message.
1407 * The message contains a cookie echoed from the HTT host->target stats
1408 * upload request, which identifies which request the confirmation is
1409 * for, and a series of tag-length-value stats information elements.
1410 * The tag-length header for each stats info element also includes a
1411 * status field, to indicate whether the request for the stat type in
1412 * question was fully met, partially met, unable to be met, or invalid
1413 * (if the stat type in question is disabled in the target).
1414 * A special value of all 1's in this status field is used to indicate
1415 * the end of the series of stats info elements.
1416 *
1417 *
1418 * |31 16|15 8|7 5|4 0|
1419 * |------------------------------------------------------------|
1420 * | reserved | msg type |
1421 * |------------------------------------------------------------|
1422 * | cookie LSBs |
1423 * |------------------------------------------------------------|
1424 * | cookie MSBs |
1425 * |------------------------------------------------------------|
1426 * | stats entry length | reserved | S |stat type|
1427 * |------------------------------------------------------------|
1428 * | |
1429 * | type-specific stats info |
1430 * | |
1431 * |------------------------------------------------------------|
1432 * | stats entry length | reserved | S |stat type|
1433 * |------------------------------------------------------------|
1434 * | |
1435 * | type-specific stats info |
1436 * | |
1437 * |------------------------------------------------------------|
1438 * | n/a | reserved | 111 | n/a |
1439 * |------------------------------------------------------------|
1440 * Header fields:
1441 * - MSG_TYPE
1442 * Bits 7:0
1443 * Purpose: identifies this is a statistics upload confirmation message
1444 * Value: 0x9
1445 * - COOKIE_LSBS
1446 * Bits 31:0
1447 * Purpose: Provide a mechanism to match a target->host stats confirmation
1448 * message with its preceding host->target stats request message.
1449 * Value: LSBs of the opaque cookie specified by the host-side requestor
1450 * - COOKIE_MSBS
1451 * Bits 31:0
1452 * Purpose: Provide a mechanism to match a target->host stats confirmation
1453 * message with its preceding host->target stats request message.
1454 * Value: MSBs of the opaque cookie specified by the host-side requestor
1455 *
1456 * Stats Information Element tag-length header fields:
1457 * - STAT_TYPE
1458 * Bits 4:0
1459 * Purpose: identifies the type of statistics info held in the
1460 * following information element
1461 * Value: htt_dbg_stats_type
1462 * - STATUS
1463 * Bits 7:5
1464 * Purpose: indicate whether the requested stats are present
1465 * Value: htt_dbg_stats_status, including a special value (0x7) to mark
1466 * the completion of the stats entry series
1467 * - LENGTH
1468 * Bits 31:16
1469 * Purpose: indicate the stats information size
1470 * Value: This field specifies the number of bytes of stats information
1471 * that follows the element tag-length header.
1472 * It is expected but not required that this length is a multiple of
1473 * 4 bytes. Even if the length is not an integer multiple of 4, the
1474 * subsequent stats entry header will begin on a 4-byte aligned
1475 * boundary.
1476 */
1477
1478#define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_MASK 0x1F
1479#define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_LSB 0
1480#define HTT_STATS_CONF_ITEM_INFO_STATUS_MASK 0xE0
1481#define HTT_STATS_CONF_ITEM_INFO_STATUS_LSB 5
1482
1483struct htt_stats_conf_item {
1484 union {
1485 u8 info;
1486 struct {
1487 u8 stat_type:5; /* %HTT_DBG_STATS_ */
1488 u8 status:3; /* %HTT_DBG_STATS_STATUS_ */
1489 } __packed;
1490 } __packed;
1491 u8 pad;
1492 __le16 length;
1493 u8 payload[]; /* roundup(length, 4) long */
1494} __packed;
1495
1496struct htt_stats_conf {
1497 u8 pad[3];
1498 __le32 cookie_lsb;
1499 __le32 cookie_msb;
1500
1501 /* each item has variable length! */
1502 struct htt_stats_conf_item items[];
1503} __packed;
1504
1505static inline struct htt_stats_conf_item *htt_stats_conf_next_item(
1506 const struct htt_stats_conf_item *item)
1507{
1508 return (void *)item + sizeof(*item) + roundup(item->length, 4);
1509}
1510
1511/*
1512 * host -> target FRAG DESCRIPTOR/MSDU_EXT DESC bank
1513 *
1514 * The following field definitions describe the format of the HTT host
1515 * to target frag_desc/msdu_ext bank configuration message.
1516 * The message contains the based address and the min and max id of the
1517 * MSDU_EXT/FRAG_DESC that will be used by the HTT to map MSDU DESC and
1518 * MSDU_EXT/FRAG_DESC.
1519 * HTT will use id in HTT descriptor instead sending the frag_desc_ptr.
1520 * For QCA988X HW the firmware will use fragment_desc_ptr but in WIFI2.0
1521 * the hardware does the mapping/translation.
1522 *
1523 * Total banks that can be configured is configured to 16.
1524 *
1525 * This should be called before any TX has be initiated by the HTT
1526 *
1527 * |31 16|15 8|7 5|4 0|
1528 * |------------------------------------------------------------|
1529 * | DESC_SIZE | NUM_BANKS | RES |SWP|pdev| msg type |
1530 * |------------------------------------------------------------|
1531 * | BANK0_BASE_ADDRESS |
1532 * |------------------------------------------------------------|
1533 * | ... |
1534 * |------------------------------------------------------------|
1535 * | BANK15_BASE_ADDRESS |
1536 * |------------------------------------------------------------|
1537 * | BANK0_MAX_ID | BANK0_MIN_ID |
1538 * |------------------------------------------------------------|
1539 * | ... |
1540 * |------------------------------------------------------------|
1541 * | BANK15_MAX_ID | BANK15_MIN_ID |
1542 * |------------------------------------------------------------|
1543 * Header fields:
1544 * - MSG_TYPE
1545 * Bits 7:0
1546 * Value: 0x6
1547 * - BANKx_BASE_ADDRESS
1548 * Bits 31:0
1549 * Purpose: Provide a mechanism to specify the base address of the MSDU_EXT
1550 * bank physical/bus address.
1551 * - BANKx_MIN_ID
1552 * Bits 15:0
1553 * Purpose: Provide a mechanism to specify the min index that needs to
1554 * mapped.
1555 * - BANKx_MAX_ID
1556 * Bits 31:16
1557 * Purpose: Provide a mechanism to specify the max index that needs to
1558 *
1559 */
1560struct htt_frag_desc_bank_id {
1561 __le16 bank_min_id;
1562 __le16 bank_max_id;
1563} __packed;
1564
1565/* real is 16 but it wouldn't fit in the max htt message size
1566 * so we use a conservatively safe value for now
1567 */
1568#define HTT_FRAG_DESC_BANK_MAX 4
1569
1570#define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_MASK 0x03
1571#define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_LSB 0
1572#define HTT_FRAG_DESC_BANK_CFG_INFO_SWAP BIT(2)
1573#define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_VALID BIT(3)
1574#define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE_MASK BIT(4)
1575#define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE_LSB 4
1576
1577enum htt_q_depth_type {
1578 HTT_Q_DEPTH_TYPE_BYTES = 0,
1579 HTT_Q_DEPTH_TYPE_MSDUS = 1,
1580};
1581
1582#define HTT_TX_Q_STATE_NUM_PEERS (TARGET_10_4_NUM_QCACHE_PEERS_MAX + \
1583 TARGET_10_4_NUM_VDEVS)
1584#define HTT_TX_Q_STATE_NUM_TIDS 8
1585#define HTT_TX_Q_STATE_ENTRY_SIZE 1
1586#define HTT_TX_Q_STATE_ENTRY_MULTIPLIER 0
1587
1588/**
1589 * htt_q_state_conf - part of htt_frag_desc_bank_cfg for host q state config
1590 *
1591 * Defines host q state format and behavior. See htt_q_state.
1592 *
1593 * @record_size: Defines the size of each host q entry in bytes. In practice
1594 * however firmware (at least 10.4.3-00191) ignores this host
1595 * configuration value and uses hardcoded value of 1.
1596 * @record_multiplier: This is valid only when q depth type is MSDUs. It
1597 * defines the exponent for the power of 2 multiplication.
1598 */
1599struct htt_q_state_conf {
1600 __le32 paddr;
1601 __le16 num_peers;
1602 __le16 num_tids;
1603 u8 record_size;
1604 u8 record_multiplier;
1605 u8 pad[2];
1606} __packed;
1607
1608struct htt_frag_desc_bank_cfg32 {
1609 u8 info; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */
1610 u8 num_banks;
1611 u8 desc_size;
1612 __le32 bank_base_addrs[HTT_FRAG_DESC_BANK_MAX];
1613 struct htt_frag_desc_bank_id bank_id[HTT_FRAG_DESC_BANK_MAX];
1614 struct htt_q_state_conf q_state;
1615} __packed;
1616
1617struct htt_frag_desc_bank_cfg64 {
1618 u8 info; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */
1619 u8 num_banks;
1620 u8 desc_size;
1621 __le64 bank_base_addrs[HTT_FRAG_DESC_BANK_MAX];
1622 struct htt_frag_desc_bank_id bank_id[HTT_FRAG_DESC_BANK_MAX];
1623 struct htt_q_state_conf q_state;
1624} __packed;
1625
1626#define HTT_TX_Q_STATE_ENTRY_COEFFICIENT 128
1627#define HTT_TX_Q_STATE_ENTRY_FACTOR_MASK 0x3f
1628#define HTT_TX_Q_STATE_ENTRY_FACTOR_LSB 0
1629#define HTT_TX_Q_STATE_ENTRY_EXP_MASK 0xc0
1630#define HTT_TX_Q_STATE_ENTRY_EXP_LSB 6
1631
1632/**
1633 * htt_q_state - shared between host and firmware via DMA
1634 *
1635 * This structure is used for the host to expose it's software queue state to
1636 * firmware so that its rate control can schedule fetch requests for optimized
1637 * performance. This is most notably used for MU-MIMO aggregation when multiple
1638 * MU clients are connected.
1639 *
1640 * @count: Each element defines the host queue depth. When q depth type was
1641 * configured as HTT_Q_DEPTH_TYPE_BYTES then each entry is defined as:
1642 * FACTOR * 128 * 8^EXP (see HTT_TX_Q_STATE_ENTRY_FACTOR_MASK and
1643 * HTT_TX_Q_STATE_ENTRY_EXP_MASK). When q depth type was configured as
1644 * HTT_Q_DEPTH_TYPE_MSDUS the number of packets is scaled by 2 **
1645 * record_multiplier (see htt_q_state_conf).
1646 * @map: Used by firmware to quickly check which host queues are not empty. It
1647 * is a bitmap simply saying.
1648 * @seq: Used by firmware to quickly check if the host queues were updated
1649 * since it last checked.
1650 *
1651 * FIXME: Is the q_state map[] size calculation really correct?
1652 */
1653struct htt_q_state {
1654 u8 count[HTT_TX_Q_STATE_NUM_TIDS][HTT_TX_Q_STATE_NUM_PEERS];
1655 u32 map[HTT_TX_Q_STATE_NUM_TIDS][(HTT_TX_Q_STATE_NUM_PEERS + 31) / 32];
1656 __le32 seq;
1657} __packed;
1658
1659#define HTT_TX_FETCH_RECORD_INFO_PEER_ID_MASK 0x0fff
1660#define HTT_TX_FETCH_RECORD_INFO_PEER_ID_LSB 0
1661#define HTT_TX_FETCH_RECORD_INFO_TID_MASK 0xf000
1662#define HTT_TX_FETCH_RECORD_INFO_TID_LSB 12
1663
1664struct htt_tx_fetch_record {
1665 __le16 info; /* HTT_TX_FETCH_IND_RECORD_INFO_ */
1666 __le16 num_msdus;
1667 __le32 num_bytes;
1668} __packed;
1669
1670struct htt_tx_fetch_ind {
1671 u8 pad0;
1672 __le16 fetch_seq_num;
1673 __le32 token;
1674 __le16 num_resp_ids;
1675 __le16 num_records;
1676 __le32 resp_ids[0]; /* ath10k_htt_get_tx_fetch_ind_resp_ids() */
1677 struct htt_tx_fetch_record records[];
1678} __packed;
1679
1680static inline void *
1681ath10k_htt_get_tx_fetch_ind_resp_ids(struct htt_tx_fetch_ind *ind)
1682{
1683 return (void *)&ind->records[le16_to_cpu(ind->num_records)];
1684}
1685
1686struct htt_tx_fetch_resp {
1687 u8 pad0;
1688 __le16 resp_id;
1689 __le16 fetch_seq_num;
1690 __le16 num_records;
1691 __le32 token;
1692 struct htt_tx_fetch_record records[];
1693} __packed;
1694
1695struct htt_tx_fetch_confirm {
1696 u8 pad0;
1697 __le16 num_resp_ids;
1698 __le32 resp_ids[];
1699} __packed;
1700
1701enum htt_tx_mode_switch_mode {
1702 HTT_TX_MODE_SWITCH_PUSH = 0,
1703 HTT_TX_MODE_SWITCH_PUSH_PULL = 1,
1704};
1705
1706#define HTT_TX_MODE_SWITCH_IND_INFO0_ENABLE BIT(0)
1707#define HTT_TX_MODE_SWITCH_IND_INFO0_NUM_RECORDS_MASK 0xfffe
1708#define HTT_TX_MODE_SWITCH_IND_INFO0_NUM_RECORDS_LSB 1
1709
1710#define HTT_TX_MODE_SWITCH_IND_INFO1_MODE_MASK 0x0003
1711#define HTT_TX_MODE_SWITCH_IND_INFO1_MODE_LSB 0
1712#define HTT_TX_MODE_SWITCH_IND_INFO1_THRESHOLD_MASK 0xfffc
1713#define HTT_TX_MODE_SWITCH_IND_INFO1_THRESHOLD_LSB 2
1714
1715#define HTT_TX_MODE_SWITCH_RECORD_INFO0_PEER_ID_MASK 0x0fff
1716#define HTT_TX_MODE_SWITCH_RECORD_INFO0_PEER_ID_LSB 0
1717#define HTT_TX_MODE_SWITCH_RECORD_INFO0_TID_MASK 0xf000
1718#define HTT_TX_MODE_SWITCH_RECORD_INFO0_TID_LSB 12
1719
1720struct htt_tx_mode_switch_record {
1721 __le16 info0; /* HTT_TX_MODE_SWITCH_RECORD_INFO0_ */
1722 __le16 num_max_msdus;
1723} __packed;
1724
1725struct htt_tx_mode_switch_ind {
1726 u8 pad0;
1727 __le16 info0; /* HTT_TX_MODE_SWITCH_IND_INFO0_ */
1728 __le16 info1; /* HTT_TX_MODE_SWITCH_IND_INFO1_ */
1729 u8 pad1[2];
1730 struct htt_tx_mode_switch_record records[];
1731} __packed;
1732
1733struct htt_channel_change {
1734 u8 pad[3];
1735 __le32 freq;
1736 __le32 center_freq1;
1737 __le32 center_freq2;
1738 __le32 phymode;
1739} __packed;
1740
1741struct htt_per_peer_tx_stats_ind {
1742 __le32 succ_bytes;
1743 __le32 retry_bytes;
1744 __le32 failed_bytes;
1745 u8 ratecode;
1746 u8 flags;
1747 __le16 peer_id;
1748 __le16 succ_pkts;
1749 __le16 retry_pkts;
1750 __le16 failed_pkts;
1751 __le16 tx_duration;
1752 __le32 reserved1;
1753 __le32 reserved2;
1754} __packed;
1755
1756struct htt_peer_tx_stats {
1757 u8 num_ppdu;
1758 u8 ppdu_len;
1759 u8 version;
1760 u8 payload[];
1761} __packed;
1762
1763#define ATH10K_10_2_TX_STATS_OFFSET 136
1764#define PEER_STATS_FOR_NO_OF_PPDUS 4
1765
1766struct ath10k_10_2_peer_tx_stats {
1767 u8 ratecode[PEER_STATS_FOR_NO_OF_PPDUS];
1768 u8 success_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
1769 __le16 success_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
1770 u8 retry_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
1771 __le16 retry_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
1772 u8 failed_pkts[PEER_STATS_FOR_NO_OF_PPDUS];
1773 __le16 failed_bytes[PEER_STATS_FOR_NO_OF_PPDUS];
1774 u8 flags[PEER_STATS_FOR_NO_OF_PPDUS];
1775 __le32 tx_duration;
1776 u8 tx_ppdu_cnt;
1777 u8 peer_id;
1778} __packed;
1779
1780union htt_rx_pn_t {
1781 /* WEP: 24-bit PN */
1782 u32 pn24;
1783
1784 /* TKIP or CCMP: 48-bit PN */
1785 u64 pn48;
1786
1787 /* WAPI: 128-bit PN */
1788 u64 pn128[2];
1789};
1790
1791struct htt_cmd {
1792 struct htt_cmd_hdr hdr;
1793 union {
1794 struct htt_ver_req ver_req;
1795 struct htt_mgmt_tx_desc mgmt_tx;
1796 struct htt_data_tx_desc data_tx;
1797 struct htt_rx_ring_setup_32 rx_setup_32;
1798 struct htt_rx_ring_setup_64 rx_setup_64;
1799 struct htt_stats_req stats_req;
1800 struct htt_oob_sync_req oob_sync_req;
1801 struct htt_aggr_conf aggr_conf;
1802 struct htt_aggr_conf_v2 aggr_conf_v2;
1803 struct htt_frag_desc_bank_cfg32 frag_desc_bank_cfg32;
1804 struct htt_frag_desc_bank_cfg64 frag_desc_bank_cfg64;
1805 struct htt_tx_fetch_resp tx_fetch_resp;
1806 };
1807} __packed;
1808
1809struct htt_resp {
1810 struct htt_resp_hdr hdr;
1811 union {
1812 struct htt_ver_resp ver_resp;
1813 struct htt_mgmt_tx_completion mgmt_tx_completion;
1814 struct htt_data_tx_completion data_tx_completion;
1815 struct htt_rx_indication rx_ind;
1816 struct htt_rx_indication_hl rx_ind_hl;
1817 struct htt_rx_fragment_indication rx_frag_ind;
1818 struct htt_rx_peer_map peer_map;
1819 struct htt_rx_peer_unmap peer_unmap;
1820 struct htt_rx_flush rx_flush;
1821 struct htt_rx_addba rx_addba;
1822 struct htt_rx_delba rx_delba;
1823 struct htt_security_indication security_indication;
1824 struct htt_rc_update rc_update;
1825 struct htt_rx_test rx_test;
1826 struct htt_pktlog_msg pktlog_msg;
1827 struct htt_stats_conf stats_conf;
1828 struct htt_rx_pn_ind rx_pn_ind;
1829 struct htt_rx_offload_ind rx_offload_ind;
1830 struct htt_rx_in_ord_ind rx_in_ord_ind;
1831 struct htt_tx_fetch_ind tx_fetch_ind;
1832 struct htt_tx_fetch_confirm tx_fetch_confirm;
1833 struct htt_tx_mode_switch_ind tx_mode_switch_ind;
1834 struct htt_channel_change chan_change;
1835 struct htt_peer_tx_stats peer_tx_stats;
1836 };
1837} __packed;
1838
1839/*** host side structures follow ***/
1840
1841struct htt_tx_done {
1842 u16 msdu_id;
1843 u16 status;
1844 u8 ack_rssi;
1845};
1846
1847enum htt_tx_compl_state {
1848 HTT_TX_COMPL_STATE_NONE,
1849 HTT_TX_COMPL_STATE_ACK,
1850 HTT_TX_COMPL_STATE_NOACK,
1851 HTT_TX_COMPL_STATE_DISCARD,
1852};
1853
1854struct htt_peer_map_event {
1855 u8 vdev_id;
1856 u16 peer_id;
1857 u8 addr[ETH_ALEN];
1858};
1859
1860struct htt_peer_unmap_event {
1861 u16 peer_id;
1862};
1863
1864struct ath10k_htt_txbuf_32 {
1865 struct htt_data_tx_desc_frag frags[2];
1866 struct ath10k_htc_hdr htc_hdr;
1867 struct htt_cmd_hdr cmd_hdr;
1868 struct htt_data_tx_desc cmd_tx;
1869} __packed __aligned(4);
1870
1871struct ath10k_htt_txbuf_64 {
1872 struct htt_data_tx_desc_frag frags[2];
1873 struct ath10k_htc_hdr htc_hdr;
1874 struct htt_cmd_hdr cmd_hdr;
1875 struct htt_data_tx_desc_64 cmd_tx;
1876} __packed __aligned(4);
1877
1878struct ath10k_htt {
1879 struct ath10k *ar;
1880 enum ath10k_htc_ep_id eid;
1881
1882 struct sk_buff_head rx_indication_head;
1883
1884 u8 target_version_major;
1885 u8 target_version_minor;
1886 struct completion target_version_received;
1887 u8 max_num_amsdu;
1888 u8 max_num_ampdu;
1889
1890 const enum htt_t2h_msg_type *t2h_msg_types;
1891 u32 t2h_msg_types_max;
1892
1893 struct {
1894 /*
1895 * Ring of network buffer objects - This ring is
1896 * used exclusively by the host SW. This ring
1897 * mirrors the dev_addrs_ring that is shared
1898 * between the host SW and the MAC HW. The host SW
1899 * uses this netbufs ring to locate the network
1900 * buffer objects whose data buffers the HW has
1901 * filled.
1902 */
1903 struct sk_buff **netbufs_ring;
1904
1905 /* This is used only with firmware supporting IN_ORD_IND.
1906 *
1907 * With Full Rx Reorder the HTT Rx Ring is more of a temporary
1908 * buffer ring from which buffer addresses are copied by the
1909 * firmware to MAC Rx ring. Firmware then delivers IN_ORD_IND
1910 * pointing to specific (re-ordered) buffers.
1911 *
1912 * FIXME: With kernel generic hashing functions there's a lot
1913 * of hash collisions for sk_buffs.
1914 */
1915 bool in_ord_rx;
1916 DECLARE_HASHTABLE(skb_table, 4);
1917
1918 /*
1919 * Ring of buffer addresses -
1920 * This ring holds the "physical" device address of the
1921 * rx buffers the host SW provides for the MAC HW to
1922 * fill.
1923 */
1924 union {
1925 __le64 *paddrs_ring_64;
1926 __le32 *paddrs_ring_32;
1927 };
1928
1929 /*
1930 * Base address of ring, as a "physical" device address
1931 * rather than a CPU address.
1932 */
1933 dma_addr_t base_paddr;
1934
1935 /* how many elems in the ring (power of 2) */
1936 int size;
1937
1938 /* size - 1 */
1939 unsigned int size_mask;
1940
1941 /* how many rx buffers to keep in the ring */
1942 int fill_level;
1943
1944 /* how many rx buffers (full+empty) are in the ring */
1945 int fill_cnt;
1946
1947 /*
1948 * alloc_idx - where HTT SW has deposited empty buffers
1949 * This is allocated in consistent mem, so that the FW can
1950 * read this variable, and program the HW's FW_IDX reg with
1951 * the value of this shadow register.
1952 */
1953 struct {
1954 __le32 *vaddr;
1955 dma_addr_t paddr;
1956 } alloc_idx;
1957
1958 /* where HTT SW has processed bufs filled by rx MAC DMA */
1959 struct {
1960 unsigned int msdu_payld;
1961 } sw_rd_idx;
1962
1963 /*
1964 * refill_retry_timer - timer triggered when the ring is
1965 * not refilled to the level expected
1966 */
1967 struct timer_list refill_retry_timer;
1968
1969 /* Protects access to all rx ring buffer state variables */
1970 spinlock_t lock;
1971 } rx_ring;
1972
1973 unsigned int prefetch_len;
1974
1975 /* Protects access to pending_tx, num_pending_tx */
1976 spinlock_t tx_lock;
1977 int max_num_pending_tx;
1978 int num_pending_tx;
1979 int num_pending_mgmt_tx;
1980 struct idr pending_tx;
1981 wait_queue_head_t empty_tx_wq;
1982
1983 /* FIFO for storing tx done status {ack, no-ack, discard} and msdu id */
1984 DECLARE_KFIFO_PTR(txdone_fifo, struct htt_tx_done);
1985
1986 /* set if host-fw communication goes haywire
1987 * used to avoid further failures
1988 */
1989 bool rx_confused;
1990 atomic_t num_mpdus_ready;
1991
1992 /* This is used to group tx/rx completions separately and process them
1993 * in batches to reduce cache stalls
1994 */
1995 struct sk_buff_head rx_msdus_q;
1996 struct sk_buff_head rx_in_ord_compl_q;
1997 struct sk_buff_head tx_fetch_ind_q;
1998
1999 /* rx_status template */
2000 struct ieee80211_rx_status rx_status;
2001
2002 struct {
2003 dma_addr_t paddr;
2004 union {
2005 struct htt_msdu_ext_desc *vaddr_desc_32;
2006 struct htt_msdu_ext_desc_64 *vaddr_desc_64;
2007 };
2008 size_t size;
2009 } frag_desc;
2010
2011 struct {
2012 dma_addr_t paddr;
2013 union {
2014 struct ath10k_htt_txbuf_32 *vaddr_txbuff_32;
2015 struct ath10k_htt_txbuf_64 *vaddr_txbuff_64;
2016 };
2017 size_t size;
2018 } txbuf;
2019
2020 struct {
2021 bool enabled;
2022 struct htt_q_state *vaddr;
2023 dma_addr_t paddr;
2024 u16 num_push_allowed;
2025 u16 num_peers;
2026 u16 num_tids;
2027 enum htt_tx_mode_switch_mode mode;
2028 enum htt_q_depth_type type;
2029 } tx_q_state;
2030
2031 bool tx_mem_allocated;
2032 const struct ath10k_htt_tx_ops *tx_ops;
2033 const struct ath10k_htt_rx_ops *rx_ops;
2034 bool disable_tx_comp;
2035 bool bundle_tx;
2036 struct sk_buff_head tx_req_head;
2037 struct sk_buff_head tx_complete_head;
2038};
2039
2040struct ath10k_htt_tx_ops {
2041 int (*htt_send_rx_ring_cfg)(struct ath10k_htt *htt);
2042 int (*htt_send_frag_desc_bank_cfg)(struct ath10k_htt *htt);
2043 int (*htt_alloc_frag_desc)(struct ath10k_htt *htt);
2044 void (*htt_free_frag_desc)(struct ath10k_htt *htt);
2045 int (*htt_tx)(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmode,
2046 struct sk_buff *msdu);
2047 int (*htt_alloc_txbuff)(struct ath10k_htt *htt);
2048 void (*htt_free_txbuff)(struct ath10k_htt *htt);
2049 int (*htt_h2t_aggr_cfg_msg)(struct ath10k_htt *htt,
2050 u8 max_subfrms_ampdu,
2051 u8 max_subfrms_amsdu);
2052 void (*htt_flush_tx)(struct ath10k_htt *htt);
2053};
2054
2055static inline int ath10k_htt_send_rx_ring_cfg(struct ath10k_htt *htt)
2056{
2057 if (!htt->tx_ops->htt_send_rx_ring_cfg)
2058 return -EOPNOTSUPP;
2059
2060 return htt->tx_ops->htt_send_rx_ring_cfg(htt);
2061}
2062
2063static inline int ath10k_htt_send_frag_desc_bank_cfg(struct ath10k_htt *htt)
2064{
2065 if (!htt->tx_ops->htt_send_frag_desc_bank_cfg)
2066 return -EOPNOTSUPP;
2067
2068 return htt->tx_ops->htt_send_frag_desc_bank_cfg(htt);
2069}
2070
2071static inline int ath10k_htt_alloc_frag_desc(struct ath10k_htt *htt)
2072{
2073 if (!htt->tx_ops->htt_alloc_frag_desc)
2074 return -EOPNOTSUPP;
2075
2076 return htt->tx_ops->htt_alloc_frag_desc(htt);
2077}
2078
2079static inline void ath10k_htt_free_frag_desc(struct ath10k_htt *htt)
2080{
2081 if (htt->tx_ops->htt_free_frag_desc)
2082 htt->tx_ops->htt_free_frag_desc(htt);
2083}
2084
2085static inline int ath10k_htt_tx(struct ath10k_htt *htt,
2086 enum ath10k_hw_txrx_mode txmode,
2087 struct sk_buff *msdu)
2088{
2089 return htt->tx_ops->htt_tx(htt, txmode, msdu);
2090}
2091
2092static inline void ath10k_htt_flush_tx(struct ath10k_htt *htt)
2093{
2094 if (htt->tx_ops->htt_flush_tx)
2095 htt->tx_ops->htt_flush_tx(htt);
2096}
2097
2098static inline int ath10k_htt_alloc_txbuff(struct ath10k_htt *htt)
2099{
2100 if (!htt->tx_ops->htt_alloc_txbuff)
2101 return -EOPNOTSUPP;
2102
2103 return htt->tx_ops->htt_alloc_txbuff(htt);
2104}
2105
2106static inline void ath10k_htt_free_txbuff(struct ath10k_htt *htt)
2107{
2108 if (htt->tx_ops->htt_free_txbuff)
2109 htt->tx_ops->htt_free_txbuff(htt);
2110}
2111
2112static inline int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
2113 u8 max_subfrms_ampdu,
2114 u8 max_subfrms_amsdu)
2115
2116{
2117 if (!htt->tx_ops->htt_h2t_aggr_cfg_msg)
2118 return -EOPNOTSUPP;
2119
2120 return htt->tx_ops->htt_h2t_aggr_cfg_msg(htt,
2121 max_subfrms_ampdu,
2122 max_subfrms_amsdu);
2123}
2124
2125struct ath10k_htt_rx_ops {
2126 size_t (*htt_get_rx_ring_size)(struct ath10k_htt *htt);
2127 void (*htt_config_paddrs_ring)(struct ath10k_htt *htt, void *vaddr);
2128 void (*htt_set_paddrs_ring)(struct ath10k_htt *htt, dma_addr_t paddr,
2129 int idx);
2130 void* (*htt_get_vaddr_ring)(struct ath10k_htt *htt);
2131 void (*htt_reset_paddrs_ring)(struct ath10k_htt *htt, int idx);
2132 bool (*htt_rx_proc_rx_frag_ind)(struct ath10k_htt *htt,
2133 struct htt_rx_fragment_indication *rx,
2134 struct sk_buff *skb);
2135};
2136
2137static inline size_t ath10k_htt_get_rx_ring_size(struct ath10k_htt *htt)
2138{
2139 if (!htt->rx_ops->htt_get_rx_ring_size)
2140 return 0;
2141
2142 return htt->rx_ops->htt_get_rx_ring_size(htt);
2143}
2144
2145static inline void ath10k_htt_config_paddrs_ring(struct ath10k_htt *htt,
2146 void *vaddr)
2147{
2148 if (htt->rx_ops->htt_config_paddrs_ring)
2149 htt->rx_ops->htt_config_paddrs_ring(htt, vaddr);
2150}
2151
2152static inline void ath10k_htt_set_paddrs_ring(struct ath10k_htt *htt,
2153 dma_addr_t paddr,
2154 int idx)
2155{
2156 if (htt->rx_ops->htt_set_paddrs_ring)
2157 htt->rx_ops->htt_set_paddrs_ring(htt, paddr, idx);
2158}
2159
2160static inline void *ath10k_htt_get_vaddr_ring(struct ath10k_htt *htt)
2161{
2162 if (!htt->rx_ops->htt_get_vaddr_ring)
2163 return NULL;
2164
2165 return htt->rx_ops->htt_get_vaddr_ring(htt);
2166}
2167
2168static inline void ath10k_htt_reset_paddrs_ring(struct ath10k_htt *htt, int idx)
2169{
2170 if (htt->rx_ops->htt_reset_paddrs_ring)
2171 htt->rx_ops->htt_reset_paddrs_ring(htt, idx);
2172}
2173
2174static inline bool ath10k_htt_rx_proc_rx_frag_ind(struct ath10k_htt *htt,
2175 struct htt_rx_fragment_indication *rx,
2176 struct sk_buff *skb)
2177{
2178 if (!htt->rx_ops->htt_rx_proc_rx_frag_ind)
2179 return true;
2180
2181 return htt->rx_ops->htt_rx_proc_rx_frag_ind(htt, rx, skb);
2182}
2183
2184#define RX_HTT_HDR_STATUS_LEN 64
2185
2186/* This structure layout is programmed via rx ring setup
2187 * so that FW knows how to transfer the rx descriptor to the host.
2188 * Buffers like this are placed on the rx ring.
2189 */
2190struct htt_rx_desc {
2191 union {
2192 /* This field is filled on the host using the msdu buffer
2193 * from htt_rx_indication
2194 */
2195 struct fw_rx_desc_base fw_desc;
2196 u32 pad;
2197 } __packed;
2198 struct {
2199 struct rx_attention attention;
2200 struct rx_frag_info frag_info;
2201 struct rx_mpdu_start mpdu_start;
2202 struct rx_msdu_start msdu_start;
2203 struct rx_msdu_end msdu_end;
2204 struct rx_mpdu_end mpdu_end;
2205 struct rx_ppdu_start ppdu_start;
2206 struct rx_ppdu_end ppdu_end;
2207 } __packed;
2208 u8 rx_hdr_status[RX_HTT_HDR_STATUS_LEN];
2209 u8 msdu_payload[];
2210};
2211
2212#define HTT_RX_DESC_HL_INFO_SEQ_NUM_MASK 0x00000fff
2213#define HTT_RX_DESC_HL_INFO_SEQ_NUM_LSB 0
2214#define HTT_RX_DESC_HL_INFO_ENCRYPTED_MASK 0x00001000
2215#define HTT_RX_DESC_HL_INFO_ENCRYPTED_LSB 12
2216#define HTT_RX_DESC_HL_INFO_CHAN_INFO_PRESENT_MASK 0x00002000
2217#define HTT_RX_DESC_HL_INFO_CHAN_INFO_PRESENT_LSB 13
2218#define HTT_RX_DESC_HL_INFO_MCAST_BCAST_MASK 0x00010000
2219#define HTT_RX_DESC_HL_INFO_MCAST_BCAST_LSB 16
2220#define HTT_RX_DESC_HL_INFO_KEY_ID_OCT_MASK 0x01fe0000
2221#define HTT_RX_DESC_HL_INFO_KEY_ID_OCT_LSB 17
2222
2223struct htt_rx_desc_base_hl {
2224 __le32 info; /* HTT_RX_DESC_HL_INFO_ */
2225};
2226
2227struct htt_rx_chan_info {
2228 __le16 primary_chan_center_freq_mhz;
2229 __le16 contig_chan1_center_freq_mhz;
2230 __le16 contig_chan2_center_freq_mhz;
2231 u8 phy_mode;
2232 u8 reserved;
2233} __packed;
2234
2235#define HTT_RX_DESC_ALIGN 8
2236
2237#define HTT_MAC_ADDR_LEN 6
2238
2239/*
2240 * FIX THIS
2241 * Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size,
2242 * rounded up to a cache line size.
2243 */
2244#define HTT_RX_BUF_SIZE 1920
2245#define HTT_RX_MSDU_SIZE (HTT_RX_BUF_SIZE - (int)sizeof(struct htt_rx_desc))
2246
2247/* Refill a bunch of RX buffers for each refill round so that FW/HW can handle
2248 * aggregated traffic more nicely.
2249 */
2250#define ATH10K_HTT_MAX_NUM_REFILL 100
2251
2252/*
2253 * DMA_MAP expects the buffer to be an integral number of cache lines.
2254 * Rather than checking the actual cache line size, this code makes a
2255 * conservative estimate of what the cache line size could be.
2256 */
2257#define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */
2258#define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1)
2259
2260/* These values are default in most firmware revisions and apparently are a
2261 * sweet spot performance wise.
2262 */
2263#define ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT 3
2264#define ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT 64
2265
2266int ath10k_htt_connect(struct ath10k_htt *htt);
2267int ath10k_htt_init(struct ath10k *ar);
2268int ath10k_htt_setup(struct ath10k_htt *htt);
2269
2270int ath10k_htt_tx_start(struct ath10k_htt *htt);
2271void ath10k_htt_tx_stop(struct ath10k_htt *htt);
2272void ath10k_htt_tx_destroy(struct ath10k_htt *htt);
2273void ath10k_htt_tx_free(struct ath10k_htt *htt);
2274
2275int ath10k_htt_rx_alloc(struct ath10k_htt *htt);
2276int ath10k_htt_rx_ring_refill(struct ath10k *ar);
2277void ath10k_htt_rx_free(struct ath10k_htt *htt);
2278
2279void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb);
2280void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
2281bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
2282int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
2283int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u32 mask, u32 reset_mask,
2284 u64 cookie);
2285void ath10k_htt_hif_tx_complete(struct ath10k *ar, struct sk_buff *skb);
2286int ath10k_htt_tx_fetch_resp(struct ath10k *ar,
2287 __le32 token,
2288 __le16 fetch_seq_num,
2289 struct htt_tx_fetch_record *records,
2290 size_t num_records);
2291void ath10k_htt_op_ep_tx_credits(struct ath10k *ar);
2292
2293void ath10k_htt_tx_txq_update(struct ieee80211_hw *hw,
2294 struct ieee80211_txq *txq);
2295void ath10k_htt_tx_txq_recalc(struct ieee80211_hw *hw,
2296 struct ieee80211_txq *txq);
2297void ath10k_htt_tx_txq_sync(struct ath10k *ar);
2298void ath10k_htt_tx_dec_pending(struct ath10k_htt *htt);
2299int ath10k_htt_tx_inc_pending(struct ath10k_htt *htt);
2300void ath10k_htt_tx_mgmt_dec_pending(struct ath10k_htt *htt);
2301int ath10k_htt_tx_mgmt_inc_pending(struct ath10k_htt *htt, bool is_mgmt,
2302 bool is_presp);
2303
2304int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt, struct sk_buff *skb);
2305void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id);
2306int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *msdu);
2307void ath10k_htt_rx_pktlog_completion_handler(struct ath10k *ar,
2308 struct sk_buff *skb);
2309int ath10k_htt_txrx_compl_task(struct ath10k *ar, int budget);
2310int ath10k_htt_rx_hl_indication(struct ath10k *ar, int budget);
2311void ath10k_htt_set_tx_ops(struct ath10k_htt *htt);
2312void ath10k_htt_set_rx_ops(struct ath10k_htt *htt);
2313#endif