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