2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
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.
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.
21 #include <linux/bug.h>
22 #include <linux/interrupt.h>
23 #include <linux/dmapool.h>
24 #include <linux/hashtable.h>
25 #include <net/mac80211.h>
30 enum htt_dbg_stats_type
{
31 HTT_DBG_STATS_WAL_PDEV_TXRX
= 1 << 0,
32 HTT_DBG_STATS_RX_REORDER
= 1 << 1,
33 HTT_DBG_STATS_RX_RATE_INFO
= 1 << 2,
34 HTT_DBG_STATS_TX_PPDU_LOG
= 1 << 3,
35 HTT_DBG_STATS_TX_RATE_INFO
= 1 << 4,
36 /* bits 5-23 currently reserved */
38 HTT_DBG_NUM_STATS
/* keep this last */
41 enum htt_h2t_msg_type
{ /* host-to-target */
42 HTT_H2T_MSG_TYPE_VERSION_REQ
= 0,
43 HTT_H2T_MSG_TYPE_TX_FRM
= 1,
44 HTT_H2T_MSG_TYPE_RX_RING_CFG
= 2,
45 HTT_H2T_MSG_TYPE_STATS_REQ
= 3,
46 HTT_H2T_MSG_TYPE_SYNC
= 4,
47 HTT_H2T_MSG_TYPE_AGGR_CFG
= 5,
48 HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG
= 6,
50 /* This command is used for sending management frames in HTT < 3.0.
51 * HTT >= 3.0 uses TX_FRM for everything. */
52 HTT_H2T_MSG_TYPE_MGMT_TX
= 7,
54 HTT_H2T_NUM_MSGS
/* keep this last */
62 u8 pad
[sizeof(u32
) - sizeof(struct htt_cmd_hdr
)];
66 * HTT tx MSDU descriptor
68 * The HTT tx MSDU descriptor is created by the host HTT SW for each
69 * tx MSDU. The HTT tx MSDU descriptor contains the information that
70 * the target firmware needs for the FW's tx processing, particularly
71 * for creating the HW msdu descriptor.
72 * The same HTT tx descriptor is used for HL and LL systems, though
73 * a few fields within the tx descriptor are used only by LL or
75 * The HTT tx descriptor is defined in two manners: by a struct with
76 * bitfields, and by a series of [dword offset, bit mask, bit shift]
78 * The target should use the struct def, for simplicitly and clarity,
79 * but the host shall use the bit-mast + bit-shift defs, to be endian-
80 * neutral. Specifically, the host shall use the get/set macros built
81 * around the mask + shift defs.
83 struct htt_data_tx_desc_frag
{
88 enum htt_data_tx_desc_flags0
{
89 HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT
= 1 << 0,
90 HTT_DATA_TX_DESC_FLAGS0_NO_AGGR
= 1 << 1,
91 HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT
= 1 << 2,
92 HTT_DATA_TX_DESC_FLAGS0_NO_CLASSIFY
= 1 << 3,
93 HTT_DATA_TX_DESC_FLAGS0_RSVD0
= 1 << 4
94 #define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_MASK 0xE0
95 #define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_LSB 5
98 enum htt_data_tx_desc_flags1
{
99 #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_BITS 6
100 #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_MASK 0x003F
101 #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_LSB 0
102 #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_BITS 5
103 #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_MASK 0x07C0
104 #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_LSB 6
105 HTT_DATA_TX_DESC_FLAGS1_POSTPONED
= 1 << 11,
106 HTT_DATA_TX_DESC_FLAGS1_MORE_IN_BATCH
= 1 << 12,
107 HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD
= 1 << 13,
108 HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD
= 1 << 14,
109 HTT_DATA_TX_DESC_FLAGS1_RSVD1
= 1 << 15
112 enum htt_data_tx_ext_tid
{
113 HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST
= 16,
114 HTT_DATA_TX_EXT_TID_MGMT
= 17,
115 HTT_DATA_TX_EXT_TID_INVALID
= 31
118 #define HTT_INVALID_PEERID 0xFFFF
121 * htt_data_tx_desc - used for data tx path
123 * Note: vdev_id irrelevant for pkt_type == raw and no_classify == 1.
124 * ext_tid: for qos-data frames (0-15), see %HTT_DATA_TX_EXT_TID_
125 * for special kinds of tids
126 * postponed: only for HL hosts. indicates if this is a resend
127 * (HL hosts manage queues on the host )
128 * more_in_batch: only for HL hosts. indicates if more packets are
129 * pending. this allows target to wait and aggregate
130 * freq: 0 means home channel of given vdev. intended for offchannel
132 struct htt_data_tx_desc
{
133 u8 flags0
; /* %HTT_DATA_TX_DESC_FLAGS0_ */
134 __le16 flags1
; /* %HTT_DATA_TX_DESC_FLAGS1_ */
140 u8 prefetch
[0]; /* start of frame, for FW classification engine */
143 enum htt_rx_ring_flags
{
144 HTT_RX_RING_FLAGS_MAC80211_HDR
= 1 << 0,
145 HTT_RX_RING_FLAGS_MSDU_PAYLOAD
= 1 << 1,
146 HTT_RX_RING_FLAGS_PPDU_START
= 1 << 2,
147 HTT_RX_RING_FLAGS_PPDU_END
= 1 << 3,
148 HTT_RX_RING_FLAGS_MPDU_START
= 1 << 4,
149 HTT_RX_RING_FLAGS_MPDU_END
= 1 << 5,
150 HTT_RX_RING_FLAGS_MSDU_START
= 1 << 6,
151 HTT_RX_RING_FLAGS_MSDU_END
= 1 << 7,
152 HTT_RX_RING_FLAGS_RX_ATTENTION
= 1 << 8,
153 HTT_RX_RING_FLAGS_FRAG_INFO
= 1 << 9,
154 HTT_RX_RING_FLAGS_UNICAST_RX
= 1 << 10,
155 HTT_RX_RING_FLAGS_MULTICAST_RX
= 1 << 11,
156 HTT_RX_RING_FLAGS_CTRL_RX
= 1 << 12,
157 HTT_RX_RING_FLAGS_MGMT_RX
= 1 << 13,
158 HTT_RX_RING_FLAGS_NULL_RX
= 1 << 14,
159 HTT_RX_RING_FLAGS_PHY_DATA_RX
= 1 << 15
162 #define HTT_RX_RING_SIZE_MIN 128
163 #define HTT_RX_RING_SIZE_MAX 2048
165 struct htt_rx_ring_setup_ring
{
166 __le32 fw_idx_shadow_reg_paddr
;
167 __le32 rx_ring_base_paddr
;
168 __le16 rx_ring_len
; /* in 4-byte words */
169 __le16 rx_ring_bufsize
; /* rx skb size - in bytes */
170 __le16 flags
; /* %HTT_RX_RING_FLAGS_ */
171 __le16 fw_idx_init_val
;
173 /* the following offsets are in 4-byte units */
174 __le16 mac80211_hdr_offset
;
175 __le16 msdu_payload_offset
;
176 __le16 ppdu_start_offset
;
177 __le16 ppdu_end_offset
;
178 __le16 mpdu_start_offset
;
179 __le16 mpdu_end_offset
;
180 __le16 msdu_start_offset
;
181 __le16 msdu_end_offset
;
182 __le16 rx_attention_offset
;
183 __le16 frag_info_offset
;
186 struct htt_rx_ring_setup_hdr
{
187 u8 num_rings
; /* supported values: 1, 2 */
191 struct htt_rx_ring_setup
{
192 struct htt_rx_ring_setup_hdr hdr
;
193 struct htt_rx_ring_setup_ring rings
[0];
197 * htt_stats_req - request target to send specified statistics
199 * @msg_type: hardcoded %HTT_H2T_MSG_TYPE_STATS_REQ
200 * @upload_types: see %htt_dbg_stats_type. this is 24bit field actually
201 * so make sure its little-endian.
202 * @reset_types: see %htt_dbg_stats_type. this is 24bit field actually
203 * so make sure its little-endian.
204 * @cfg_val: stat_type specific configuration
205 * @stat_type: see %htt_dbg_stats_type
206 * @cookie_lsb: used for confirmation message from target->host
207 * @cookie_msb: ditto as %cookie
209 struct htt_stats_req
{
223 #define HTT_STATS_REQ_CFG_STAT_TYPE_INVALID 0xff
226 * htt_oob_sync_req - request out-of-band sync
228 * The HTT SYNC tells the target to suspend processing of subsequent
229 * HTT host-to-target messages until some other target agent locally
230 * informs the target HTT FW that the current sync counter is equal to
231 * or greater than (in a modulo sense) the sync counter specified in
234 * This allows other host-target components to synchronize their operation
235 * with HTT, e.g. to ensure that tx frames don't get transmitted until a
236 * security key has been downloaded to and activated by the target.
237 * In the absence of any explicit synchronization counter value
238 * specification, the target HTT FW will use zero as the default current
241 * The HTT target FW will suspend its host->target message processing as long
242 * as 0 < (in-band sync counter - out-of-band sync counter) & 0xff < 128.
244 struct htt_oob_sync_req
{
249 struct htt_aggr_conf
{
250 u8 max_num_ampdu_subframes
;
251 /* amsdu_subframes is limited by 0x1F mask */
252 u8 max_num_amsdu_subframes
;
255 #define HTT_MGMT_FRM_HDR_DOWNLOAD_LEN 32
257 struct htt_mgmt_tx_desc
{
258 u8 pad
[sizeof(u32
) - sizeof(struct htt_cmd_hdr
)];
263 u8 hdr
[HTT_MGMT_FRM_HDR_DOWNLOAD_LEN
];
266 enum htt_mgmt_tx_status
{
267 HTT_MGMT_TX_STATUS_OK
= 0,
268 HTT_MGMT_TX_STATUS_RETRY
= 1,
269 HTT_MGMT_TX_STATUS_DROP
= 2
272 /*=== target -> host messages ===============================================*/
274 enum htt_t2h_msg_type
{
275 HTT_T2H_MSG_TYPE_VERSION_CONF
= 0x0,
276 HTT_T2H_MSG_TYPE_RX_IND
= 0x1,
277 HTT_T2H_MSG_TYPE_RX_FLUSH
= 0x2,
278 HTT_T2H_MSG_TYPE_PEER_MAP
= 0x3,
279 HTT_T2H_MSG_TYPE_PEER_UNMAP
= 0x4,
280 HTT_T2H_MSG_TYPE_RX_ADDBA
= 0x5,
281 HTT_T2H_MSG_TYPE_RX_DELBA
= 0x6,
282 HTT_T2H_MSG_TYPE_TX_COMPL_IND
= 0x7,
283 HTT_T2H_MSG_TYPE_PKTLOG
= 0x8,
284 HTT_T2H_MSG_TYPE_STATS_CONF
= 0x9,
285 HTT_T2H_MSG_TYPE_RX_FRAG_IND
= 0xa,
286 HTT_T2H_MSG_TYPE_SEC_IND
= 0xb,
287 HTT_T2H_MSG_TYPE_RC_UPDATE_IND
= 0xc,
288 HTT_T2H_MSG_TYPE_TX_INSPECT_IND
= 0xd,
289 HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION
= 0xe,
290 HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND
= 0xf,
291 HTT_T2H_MSG_TYPE_RX_PN_IND
= 0x10,
292 HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND
= 0x11,
293 HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND
= 0x12,
295 HTT_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE
= 0x14,
297 /* FIXME: Do not depend on this event id. Numbering of this event id is
298 * broken across different firmware revisions and HTT version fails to
301 HTT_T2H_MSG_TYPE_TEST
,
308 * htt_resp_hdr - header for target-to-host messages
310 * msg_type: see htt_t2h_msg_type
312 struct htt_resp_hdr
{
316 #define HTT_RESP_HDR_MSG_TYPE_OFFSET 0
317 #define HTT_RESP_HDR_MSG_TYPE_MASK 0xff
318 #define HTT_RESP_HDR_MSG_TYPE_LSB 0
320 /* htt_ver_resp - response sent for htt_ver_req */
321 struct htt_ver_resp
{
327 struct htt_mgmt_tx_completion
{
335 #define HTT_RX_INDICATION_INFO0_EXT_TID_MASK (0x3F)
336 #define HTT_RX_INDICATION_INFO0_EXT_TID_LSB (0)
337 #define HTT_RX_INDICATION_INFO0_FLUSH_VALID (1 << 6)
338 #define HTT_RX_INDICATION_INFO0_RELEASE_VALID (1 << 7)
340 #define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_MASK 0x0000003F
341 #define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_LSB 0
342 #define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_MASK 0x00000FC0
343 #define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_LSB 6
344 #define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_MASK 0x0003F000
345 #define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_LSB 12
346 #define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_MASK 0x00FC0000
347 #define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_LSB 18
348 #define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_MASK 0xFF000000
349 #define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_LSB 24
351 struct htt_rx_indication_hdr
{
352 u8 info0
; /* %HTT_RX_INDICATION_INFO0_ */
354 __le32 info1
; /* %HTT_RX_INDICATION_INFO1_ */
357 #define HTT_RX_INDICATION_INFO0_PHY_ERR_VALID (1 << 0)
358 #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_MASK (0x1E)
359 #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_LSB (1)
360 #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_CCK (1 << 5)
361 #define HTT_RX_INDICATION_INFO0_END_VALID (1 << 6)
362 #define HTT_RX_INDICATION_INFO0_START_VALID (1 << 7)
364 #define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_MASK 0x00FFFFFF
365 #define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_LSB 0
366 #define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_MASK 0xFF000000
367 #define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_LSB 24
369 #define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_MASK 0x00FFFFFF
370 #define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_LSB 0
371 #define HTT_RX_INDICATION_INFO2_SERVICE_MASK 0xFF000000
372 #define HTT_RX_INDICATION_INFO2_SERVICE_LSB 24
374 enum htt_rx_legacy_rate
{
385 HTT_RX_CCK_11_LP
= 0,
386 HTT_RX_CCK_5_5_LP
= 1,
395 enum htt_rx_legacy_rate_type
{
396 HTT_RX_LEGACY_RATE_OFDM
= 0,
397 HTT_RX_LEGACY_RATE_CCK
400 enum htt_rx_preamble_type
{
403 HTT_RX_HT_WITH_TXBF
= 0x9,
405 HTT_RX_VHT_WITH_TXBF
= 0xD,
409 * Fields: phy_err_valid, phy_err_code, tsf,
410 * usec_timestamp, sub_usec_timestamp
411 * ..are valid only if end_valid == 1.
413 * Fields: rssi_chains, legacy_rate_type,
414 * legacy_rate_cck, preamble_type, service,
416 * ..are valid only if start_valid == 1;
418 struct htt_rx_indication_ppdu
{
420 u8 sub_usec_timestamp
;
422 u8 info0
; /* HTT_RX_INDICATION_INFO0_ */
428 } __packed rssi_chains
[4];
430 __le32 usec_timestamp
;
431 __le32 info1
; /* HTT_RX_INDICATION_INFO1_ */
432 __le32 info2
; /* HTT_RX_INDICATION_INFO2_ */
435 enum htt_rx_mpdu_status
{
436 HTT_RX_IND_MPDU_STATUS_UNKNOWN
= 0x0,
437 HTT_RX_IND_MPDU_STATUS_OK
,
438 HTT_RX_IND_MPDU_STATUS_ERR_FCS
,
439 HTT_RX_IND_MPDU_STATUS_ERR_DUP
,
440 HTT_RX_IND_MPDU_STATUS_ERR_REPLAY
,
441 HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER
,
442 /* only accept EAPOL frames */
443 HTT_RX_IND_MPDU_STATUS_UNAUTH_PEER
,
444 HTT_RX_IND_MPDU_STATUS_OUT_OF_SYNC
,
445 /* Non-data in promiscous mode */
446 HTT_RX_IND_MPDU_STATUS_MGMT_CTRL
,
447 HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR
,
448 HTT_RX_IND_MPDU_STATUS_DECRYPT_ERR
,
449 HTT_RX_IND_MPDU_STATUS_MPDU_LENGTH_ERR
,
450 HTT_RX_IND_MPDU_STATUS_ENCRYPT_REQUIRED_ERR
,
451 HTT_RX_IND_MPDU_STATUS_PRIVACY_ERR
,
454 * MISC: discard for unspecified reasons.
455 * Leave this enum value last.
457 HTT_RX_IND_MPDU_STATUS_ERR_MISC
= 0xFF
460 struct htt_rx_indication_mpdu_range
{
462 u8 mpdu_range_status
; /* %htt_rx_mpdu_status */
467 struct htt_rx_indication_prefix
{
468 __le16 fw_rx_desc_bytes
;
473 struct htt_rx_indication
{
474 struct htt_rx_indication_hdr hdr
;
475 struct htt_rx_indication_ppdu ppdu
;
476 struct htt_rx_indication_prefix prefix
;
479 * the following fields are both dynamically sized, so
480 * take care addressing them
483 /* the size of this is %fw_rx_desc_bytes */
484 struct fw_rx_desc_base fw_desc
;
487 * %mpdu_ranges starts after &%prefix + roundup(%fw_rx_desc_bytes, 4)
488 * and has %num_mpdu_ranges elements.
490 struct htt_rx_indication_mpdu_range mpdu_ranges
[0];
493 static inline struct htt_rx_indication_mpdu_range
*
494 htt_rx_ind_get_mpdu_ranges(struct htt_rx_indication
*rx_ind
)
498 ptr
+= sizeof(rx_ind
->hdr
)
499 + sizeof(rx_ind
->ppdu
)
500 + sizeof(rx_ind
->prefix
)
501 + roundup(__le16_to_cpu(rx_ind
->prefix
.fw_rx_desc_bytes
), 4);
505 enum htt_rx_flush_mpdu_status
{
506 HTT_RX_FLUSH_MPDU_DISCARD
= 0,
507 HTT_RX_FLUSH_MPDU_REORDER
= 1,
511 * htt_rx_flush - discard or reorder given range of mpdus
513 * Note: host must check if all sequence numbers between
514 * [seq_num_start, seq_num_end-1] are valid.
516 struct htt_rx_flush
{
520 u8 mpdu_status
; /* %htt_rx_flush_mpdu_status */
521 u8 seq_num_start
; /* it is 6 LSBs of 802.11 seq no */
522 u8 seq_num_end
; /* it is 6 LSBs of 802.11 seq no */
525 struct htt_rx_peer_map
{
533 struct htt_rx_peer_unmap
{
538 enum htt_security_types
{
544 HTT_SECURITY_TKIP_NOMIC
,
545 HTT_SECURITY_AES_CCMP
,
548 HTT_NUM_SECURITY_TYPES
/* keep this last! */
551 enum htt_security_flags
{
552 #define HTT_SECURITY_TYPE_MASK 0x7F
553 #define HTT_SECURITY_TYPE_LSB 0
554 HTT_SECURITY_IS_UNICAST
= 1 << 7
557 struct htt_security_indication
{
559 /* dont use bitfields; undefined behaviour */
560 u8 flags
; /* %htt_security_flags */
562 u8 security_type
:7, /* %htt_security_types */
571 #define HTT_RX_BA_INFO0_TID_MASK 0x000F
572 #define HTT_RX_BA_INFO0_TID_LSB 0
573 #define HTT_RX_BA_INFO0_PEER_ID_MASK 0xFFF0
574 #define HTT_RX_BA_INFO0_PEER_ID_LSB 4
576 struct htt_rx_addba
{
578 __le16 info0
; /* %HTT_RX_BA_INFO0_ */
581 struct htt_rx_delba
{
583 __le16 info0
; /* %HTT_RX_BA_INFO0_ */
586 enum htt_data_tx_status
{
587 HTT_DATA_TX_STATUS_OK
= 0,
588 HTT_DATA_TX_STATUS_DISCARD
= 1,
589 HTT_DATA_TX_STATUS_NO_ACK
= 2,
590 HTT_DATA_TX_STATUS_POSTPONE
= 3, /* HL only */
591 HTT_DATA_TX_STATUS_DOWNLOAD_FAIL
= 128
594 enum htt_data_tx_flags
{
595 #define HTT_DATA_TX_STATUS_MASK 0x07
596 #define HTT_DATA_TX_STATUS_LSB 0
597 #define HTT_DATA_TX_TID_MASK 0x78
598 #define HTT_DATA_TX_TID_LSB 3
599 HTT_DATA_TX_TID_INVALID
= 1 << 7
602 #define HTT_TX_COMPL_INV_MSDU_ID 0xFFFF
604 struct htt_data_tx_completion
{
615 __le16 msdus
[0]; /* variable length based on %num_msdus */
618 struct htt_tx_compl_ind_base
{
620 u16 payload
[1/*or more*/];
623 struct htt_rc_tx_done_params
{
627 u32 num_enqued
; /* 1 for non-AMPDU */
629 u32 num_failed
; /* for AMPDU */
635 struct htt_rc_update
{
641 struct htt_rc_tx_done_params params
[0]; /* variable length %num_elems */
644 /* see htt_rx_indication for similar fields and descriptions */
645 struct htt_rx_fragment_indication
{
647 u8 info0
; /* %HTT_RX_FRAG_IND_INFO0_ */
654 __le32 info1
; /* %HTT_RX_FRAG_IND_INFO1_ */
655 __le16 fw_rx_desc_bytes
;
658 u8 fw_msdu_rx_desc
[0];
661 #define HTT_RX_FRAG_IND_INFO0_EXT_TID_MASK 0x1F
662 #define HTT_RX_FRAG_IND_INFO0_EXT_TID_LSB 0
663 #define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_MASK 0x20
664 #define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_LSB 5
666 #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_MASK 0x0000003F
667 #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_LSB 0
668 #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_MASK 0x00000FC0
669 #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_LSB 6
671 struct htt_rx_pn_ind
{
681 struct htt_rx_offload_msdu
{
690 struct htt_rx_offload_ind
{
695 struct htt_rx_in_ord_msdu_desc
{
702 struct htt_rx_in_ord_ind
{
708 struct htt_rx_in_ord_msdu_desc msdu_descs
[0];
711 #define HTT_RX_IN_ORD_IND_INFO_TID_MASK 0x0000001f
712 #define HTT_RX_IN_ORD_IND_INFO_TID_LSB 0
713 #define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_MASK 0x00000020
714 #define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_LSB 5
715 #define HTT_RX_IN_ORD_IND_INFO_FRAG_MASK 0x00000040
716 #define HTT_RX_IN_ORD_IND_INFO_FRAG_LSB 6
719 * target -> host test message definition
721 * The following field definitions describe the format of the test
722 * message sent from the target to the host.
723 * The message consists of a 4-octet header, followed by a variable
724 * number of 32-bit integer values, followed by a variable number
725 * of 8-bit character values.
728 * |-----------------------------------------------------------|
729 * | num chars | num ints | msg type |
730 * |-----------------------------------------------------------|
732 * |-----------------------------------------------------------|
734 * |-----------------------------------------------------------|
736 * |-----------------------------------------------------------|
737 * | char 3 | char 2 | char 1 | char 0 |
738 * |-----------------------------------------------------------|
739 * | | | ... | char 4 |
740 * |-----------------------------------------------------------|
743 * Purpose: identifies this as a test message
744 * Value: HTT_MSG_TYPE_TEST
747 * Purpose: indicate how many 32-bit integers follow the message header
750 * Purpose: indicate how many 8-bit charaters follow the series of integers
756 /* payload consists of 2 lists:
757 * a) num_ints * sizeof(__le32)
758 * b) num_chars * sizeof(u8) aligned to 4bytes */
762 static inline __le32
*htt_rx_test_get_ints(struct htt_rx_test
*rx_test
)
764 return (__le32
*)rx_test
->payload
;
767 static inline u8
*htt_rx_test_get_chars(struct htt_rx_test
*rx_test
)
769 return rx_test
->payload
+ (rx_test
->num_ints
* sizeof(__le32
));
773 * target -> host packet log message
775 * The following field definitions describe the format of the packet log
776 * message sent from the target to the host.
777 * The message consists of a 4-octet header,followed by a variable number
778 * of 32-bit character values.
780 * |31 24|23 16|15 8|7 0|
781 * |-----------------------------------------------------------|
783 * |-----------------------------------------------------------|
785 * |-----------------------------------------------------------|
788 * Purpose: identifies this as a test message
789 * Value: HTT_MSG_TYPE_PACKETLOG
791 struct htt_pktlog_msg
{
796 struct htt_dbg_stats_rx_reorder_stats
{
797 /* Non QoS MPDUs received */
798 __le32 deliver_non_qos
;
800 /* MPDUs received in-order */
801 __le32 deliver_in_order
;
803 /* Flush due to reorder timer expired */
804 __le32 deliver_flush_timeout
;
806 /* Flush due to move out of window */
807 __le32 deliver_flush_oow
;
809 /* Flush due to DELBA */
810 __le32 deliver_flush_delba
;
812 /* MPDUs dropped due to FCS error */
815 /* MPDUs dropped due to monitor mode non-data packet */
818 /* MPDUs dropped due to invalid peer */
821 /* MPDUs dropped due to duplication (non aggregation) */
824 /* MPDUs dropped due to processed before */
827 /* MPDUs dropped due to duplicate in reorder queue */
828 __le32 dup_in_reorder
;
830 /* Reorder timeout happened */
831 __le32 reorder_timeout
;
833 /* invalid bar ssn */
834 __le32 invalid_bar_ssn
;
836 /* reorder reset due to bar ssn */
840 struct htt_dbg_stats_wal_tx_stats
{
841 /* Num HTT cookies queued to dispatch list */
844 /* Num HTT cookies dispatched */
845 __le32 comp_delivered
;
847 /* Num MSDU queued to WAL */
850 /* Num MPDU queue to WAL */
853 /* Num MSDUs dropped by WMM limit */
856 /* Num Local frames queued */
859 /* Num Local frames done */
862 /* Num queued to HW */
865 /* Num PPDU reaped from HW */
871 /* Num PPDUs cleaned up in TX abort */
874 /* Num MPDUs requed by SW */
877 /* excessive retries */
880 /* data hw rate code */
883 /* Scheduler self triggers */
884 __le32 self_triggers
;
886 /* frames dropped due to excessive sw retries */
887 __le32 sw_retry_failure
;
889 /* illegal rate phy errors */
890 __le32 illgl_rate_phy_err
;
892 /* wal pdev continous xretry */
893 __le32 pdev_cont_xretry
;
895 /* wal pdev continous xretry */
896 __le32 pdev_tx_timeout
;
898 /* wal pdev resets */
903 /* MPDU is more than txop limit */
907 struct htt_dbg_stats_wal_rx_stats
{
908 /* Cnts any change in ring routing mid-ppdu */
909 __le32 mid_ppdu_route_change
;
911 /* Total number of statuses processed */
914 /* Extra frags on rings 0-3 */
920 /* MSDUs / MPDUs delivered to HTT */
924 /* MSDUs / MPDUs delivered to local stack */
928 /* AMSDUs that have more MSDUs than the status ring size */
929 __le32 oversize_amsdu
;
931 /* Number of PHY errors */
934 /* Number of PHY errors drops */
937 /* Number of mpdu errors - FCS, MIC, ENC etc. */
941 struct htt_dbg_stats_wal_peer_stats
{
942 __le32 dummy
; /* REMOVE THIS ONCE REAL PEER STAT COUNTERS ARE ADDED */
945 struct htt_dbg_stats_wal_pdev_txrx
{
946 struct htt_dbg_stats_wal_tx_stats tx_stats
;
947 struct htt_dbg_stats_wal_rx_stats rx_stats
;
948 struct htt_dbg_stats_wal_peer_stats peer_stats
;
951 struct htt_dbg_stats_rx_rate_info
{
963 * htt_dbg_stats_status -
964 * present - The requested stats have been delivered in full.
965 * This indicates that either the stats information was contained
966 * in its entirety within this message, or else this message
967 * completes the delivery of the requested stats info that was
968 * partially delivered through earlier STATS_CONF messages.
969 * partial - The requested stats have been delivered in part.
970 * One or more subsequent STATS_CONF messages with the same
971 * cookie value will be sent to deliver the remainder of the
973 * error - The requested stats could not be delivered, for example due
974 * to a shortage of memory to construct a message holding the
976 * invalid - The requested stat type is either not recognized, or the
977 * target is configured to not gather the stats type in question.
978 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
979 * series_done - This special value indicates that no further stats info
980 * elements are present within a series of stats info elems
981 * (within a stats upload confirmation message).
983 enum htt_dbg_stats_status
{
984 HTT_DBG_STATS_STATUS_PRESENT
= 0,
985 HTT_DBG_STATS_STATUS_PARTIAL
= 1,
986 HTT_DBG_STATS_STATUS_ERROR
= 2,
987 HTT_DBG_STATS_STATUS_INVALID
= 3,
988 HTT_DBG_STATS_STATUS_SERIES_DONE
= 7
992 * target -> host statistics upload
994 * The following field definitions describe the format of the HTT target
995 * to host stats upload confirmation message.
996 * The message contains a cookie echoed from the HTT host->target stats
997 * upload request, which identifies which request the confirmation is
998 * for, and a series of tag-length-value stats information elements.
999 * The tag-length header for each stats info element also includes a
1000 * status field, to indicate whether the request for the stat type in
1001 * question was fully met, partially met, unable to be met, or invalid
1002 * (if the stat type in question is disabled in the target).
1003 * A special value of all 1's in this status field is used to indicate
1004 * the end of the series of stats info elements.
1007 * |31 16|15 8|7 5|4 0|
1008 * |------------------------------------------------------------|
1009 * | reserved | msg type |
1010 * |------------------------------------------------------------|
1012 * |------------------------------------------------------------|
1014 * |------------------------------------------------------------|
1015 * | stats entry length | reserved | S |stat type|
1016 * |------------------------------------------------------------|
1018 * | type-specific stats info |
1020 * |------------------------------------------------------------|
1021 * | stats entry length | reserved | S |stat type|
1022 * |------------------------------------------------------------|
1024 * | type-specific stats info |
1026 * |------------------------------------------------------------|
1027 * | n/a | reserved | 111 | n/a |
1028 * |------------------------------------------------------------|
1032 * Purpose: identifies this is a statistics upload confirmation message
1036 * Purpose: Provide a mechanism to match a target->host stats confirmation
1037 * message with its preceding host->target stats request message.
1038 * Value: LSBs of the opaque cookie specified by the host-side requestor
1041 * Purpose: Provide a mechanism to match a target->host stats confirmation
1042 * message with its preceding host->target stats request message.
1043 * Value: MSBs of the opaque cookie specified by the host-side requestor
1045 * Stats Information Element tag-length header fields:
1048 * Purpose: identifies the type of statistics info held in the
1049 * following information element
1050 * Value: htt_dbg_stats_type
1053 * Purpose: indicate whether the requested stats are present
1054 * Value: htt_dbg_stats_status, including a special value (0x7) to mark
1055 * the completion of the stats entry series
1058 * Purpose: indicate the stats information size
1059 * Value: This field specifies the number of bytes of stats information
1060 * that follows the element tag-length header.
1061 * It is expected but not required that this length is a multiple of
1062 * 4 bytes. Even if the length is not an integer multiple of 4, the
1063 * subsequent stats entry header will begin on a 4-byte aligned
1067 #define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_MASK 0x1F
1068 #define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_LSB 0
1069 #define HTT_STATS_CONF_ITEM_INFO_STATUS_MASK 0xE0
1070 #define HTT_STATS_CONF_ITEM_INFO_STATUS_LSB 5
1072 struct htt_stats_conf_item
{
1076 u8 stat_type
:5; /* %HTT_DBG_STATS_ */
1077 u8 status
:3; /* %HTT_DBG_STATS_STATUS_ */
1082 u8 payload
[0]; /* roundup(length, 4) long */
1085 struct htt_stats_conf
{
1090 /* each item has variable length! */
1091 struct htt_stats_conf_item items
[0];
1094 static inline struct htt_stats_conf_item
*htt_stats_conf_next_item(
1095 const struct htt_stats_conf_item
*item
)
1097 return (void *)item
+ sizeof(*item
) + roundup(item
->length
, 4);
1101 * host -> target FRAG DESCRIPTOR/MSDU_EXT DESC bank
1103 * The following field definitions describe the format of the HTT host
1104 * to target frag_desc/msdu_ext bank configuration message.
1105 * The message contains the based address and the min and max id of the
1106 * MSDU_EXT/FRAG_DESC that will be used by the HTT to map MSDU DESC and
1107 * MSDU_EXT/FRAG_DESC.
1108 * HTT will use id in HTT descriptor instead sending the frag_desc_ptr.
1109 * For QCA988X HW the firmware will use fragment_desc_ptr but in WIFI2.0
1110 * the hardware does the mapping/translation.
1112 * Total banks that can be configured is configured to 16.
1114 * This should be called before any TX has be initiated by the HTT
1116 * |31 16|15 8|7 5|4 0|
1117 * |------------------------------------------------------------|
1118 * | DESC_SIZE | NUM_BANKS | RES |SWP|pdev| msg type |
1119 * |------------------------------------------------------------|
1120 * | BANK0_BASE_ADDRESS |
1121 * |------------------------------------------------------------|
1123 * |------------------------------------------------------------|
1124 * | BANK15_BASE_ADDRESS |
1125 * |------------------------------------------------------------|
1126 * | BANK0_MAX_ID | BANK0_MIN_ID |
1127 * |------------------------------------------------------------|
1129 * |------------------------------------------------------------|
1130 * | BANK15_MAX_ID | BANK15_MIN_ID |
1131 * |------------------------------------------------------------|
1136 * - BANKx_BASE_ADDRESS
1138 * Purpose: Provide a mechanism to specify the base address of the MSDU_EXT
1139 * bank physical/bus address.
1142 * Purpose: Provide a mechanism to specify the min index that needs to
1146 * Purpose: Provide a mechanism to specify the max index that needs to
1149 struct htt_frag_desc_bank_id
{
1154 /* real is 16 but it wouldn't fit in the max htt message size
1155 * so we use a conservatively safe value for now */
1156 #define HTT_FRAG_DESC_BANK_MAX 4
1158 #define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_MASK 0x03
1159 #define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_LSB 0
1160 #define HTT_FRAG_DESC_BANK_CFG_INFO_SWAP (1 << 2)
1162 struct htt_frag_desc_bank_cfg
{
1163 u8 info
; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */
1166 __le32 bank_base_addrs
[HTT_FRAG_DESC_BANK_MAX
];
1167 struct htt_frag_desc_bank_id bank_id
[HTT_FRAG_DESC_BANK_MAX
];
1171 /* WEP: 24-bit PN */
1174 /* TKIP or CCMP: 48-bit PN */
1177 /* WAPI: 128-bit PN */
1182 struct htt_cmd_hdr hdr
;
1184 struct htt_ver_req ver_req
;
1185 struct htt_mgmt_tx_desc mgmt_tx
;
1186 struct htt_data_tx_desc data_tx
;
1187 struct htt_rx_ring_setup rx_setup
;
1188 struct htt_stats_req stats_req
;
1189 struct htt_oob_sync_req oob_sync_req
;
1190 struct htt_aggr_conf aggr_conf
;
1191 struct htt_frag_desc_bank_cfg frag_desc_bank_cfg
;
1196 struct htt_resp_hdr hdr
;
1198 struct htt_ver_resp ver_resp
;
1199 struct htt_mgmt_tx_completion mgmt_tx_completion
;
1200 struct htt_data_tx_completion data_tx_completion
;
1201 struct htt_rx_indication rx_ind
;
1202 struct htt_rx_fragment_indication rx_frag_ind
;
1203 struct htt_rx_peer_map peer_map
;
1204 struct htt_rx_peer_unmap peer_unmap
;
1205 struct htt_rx_flush rx_flush
;
1206 struct htt_rx_addba rx_addba
;
1207 struct htt_rx_delba rx_delba
;
1208 struct htt_security_indication security_indication
;
1209 struct htt_rc_update rc_update
;
1210 struct htt_rx_test rx_test
;
1211 struct htt_pktlog_msg pktlog_msg
;
1212 struct htt_stats_conf stats_conf
;
1213 struct htt_rx_pn_ind rx_pn_ind
;
1214 struct htt_rx_offload_ind rx_offload_ind
;
1215 struct htt_rx_in_ord_ind rx_in_ord_ind
;
1219 /*** host side structures follow ***/
1221 struct htt_tx_done
{
1227 struct htt_peer_map_event
{
1233 struct htt_peer_unmap_event
{
1237 struct ath10k_htt_txbuf
{
1238 struct htt_data_tx_desc_frag frags
[2];
1239 struct ath10k_htc_hdr htc_hdr
;
1240 struct htt_cmd_hdr cmd_hdr
;
1241 struct htt_data_tx_desc cmd_tx
;
1246 enum ath10k_htc_ep_id eid
;
1248 u8 target_version_major
;
1249 u8 target_version_minor
;
1250 struct completion target_version_received
;
1254 * Ring of network buffer objects - This ring is
1255 * used exclusively by the host SW. This ring
1256 * mirrors the dev_addrs_ring that is shared
1257 * between the host SW and the MAC HW. The host SW
1258 * uses this netbufs ring to locate the network
1259 * buffer objects whose data buffers the HW has
1262 struct sk_buff
**netbufs_ring
;
1264 /* This is used only with firmware supporting IN_ORD_IND.
1266 * With Full Rx Reorder the HTT Rx Ring is more of a temporary
1267 * buffer ring from which buffer addresses are copied by the
1268 * firmware to MAC Rx ring. Firmware then delivers IN_ORD_IND
1269 * pointing to specific (re-ordered) buffers.
1271 * FIXME: With kernel generic hashing functions there's a lot
1272 * of hash collisions for sk_buffs.
1275 DECLARE_HASHTABLE(skb_table
, 4);
1278 * Ring of buffer addresses -
1279 * This ring holds the "physical" device address of the
1280 * rx buffers the host SW provides for the MAC HW to
1283 __le32
*paddrs_ring
;
1286 * Base address of ring, as a "physical" device address
1287 * rather than a CPU address.
1289 dma_addr_t base_paddr
;
1291 /* how many elems in the ring (power of 2) */
1297 /* how many rx buffers to keep in the ring */
1300 /* how many rx buffers (full+empty) are in the ring */
1304 * alloc_idx - where HTT SW has deposited empty buffers
1305 * This is allocated in consistent mem, so that the FW can
1306 * read this variable, and program the HW's FW_IDX reg with
1307 * the value of this shadow register.
1314 /* where HTT SW has processed bufs filled by rx MAC DMA */
1316 unsigned msdu_payld
;
1320 * refill_retry_timer - timer triggered when the ring is
1321 * not refilled to the level expected
1323 struct timer_list refill_retry_timer
;
1325 /* Protects access to all rx ring buffer state variables */
1329 unsigned int prefetch_len
;
1331 /* Protects access to pending_tx, num_pending_tx */
1333 int max_num_pending_tx
;
1335 struct idr pending_tx
;
1336 wait_queue_head_t empty_tx_wq
;
1337 struct dma_pool
*tx_pool
;
1339 /* set if host-fw communication goes haywire
1340 * used to avoid further failures */
1342 struct tasklet_struct rx_replenish_task
;
1344 /* This is used to group tx/rx completions separately and process them
1345 * in batches to reduce cache stalls */
1346 struct tasklet_struct txrx_compl_task
;
1347 struct sk_buff_head tx_compl_q
;
1348 struct sk_buff_head rx_compl_q
;
1349 struct sk_buff_head rx_in_ord_compl_q
;
1351 /* rx_status template */
1352 struct ieee80211_rx_status rx_status
;
1355 #define RX_HTT_HDR_STATUS_LEN 64
1357 /* This structure layout is programmed via rx ring setup
1358 * so that FW knows how to transfer the rx descriptor to the host.
1359 * Buffers like this are placed on the rx ring. */
1360 struct htt_rx_desc
{
1362 /* This field is filled on the host using the msdu buffer
1363 * from htt_rx_indication */
1364 struct fw_rx_desc_base fw_desc
;
1368 struct rx_attention attention
;
1369 struct rx_frag_info frag_info
;
1370 struct rx_mpdu_start mpdu_start
;
1371 struct rx_msdu_start msdu_start
;
1372 struct rx_msdu_end msdu_end
;
1373 struct rx_mpdu_end mpdu_end
;
1374 struct rx_ppdu_start ppdu_start
;
1375 struct rx_ppdu_end ppdu_end
;
1377 u8 rx_hdr_status
[RX_HTT_HDR_STATUS_LEN
];
1381 #define HTT_RX_DESC_ALIGN 8
1383 #define HTT_MAC_ADDR_LEN 6
1387 * Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size,
1388 * rounded up to a cache line size.
1390 #define HTT_RX_BUF_SIZE 1920
1391 #define HTT_RX_MSDU_SIZE (HTT_RX_BUF_SIZE - (int)sizeof(struct htt_rx_desc))
1393 /* Refill a bunch of RX buffers for each refill round so that FW/HW can handle
1394 * aggregated traffic more nicely. */
1395 #define ATH10K_HTT_MAX_NUM_REFILL 16
1398 * DMA_MAP expects the buffer to be an integral number of cache lines.
1399 * Rather than checking the actual cache line size, this code makes a
1400 * conservative estimate of what the cache line size could be.
1402 #define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */
1403 #define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1)
1405 int ath10k_htt_connect(struct ath10k_htt
*htt
);
1406 int ath10k_htt_init(struct ath10k
*ar
);
1407 int ath10k_htt_setup(struct ath10k_htt
*htt
);
1409 int ath10k_htt_tx_alloc(struct ath10k_htt
*htt
);
1410 void ath10k_htt_tx_free(struct ath10k_htt
*htt
);
1412 int ath10k_htt_rx_alloc(struct ath10k_htt
*htt
);
1413 int ath10k_htt_rx_ring_refill(struct ath10k
*ar
);
1414 void ath10k_htt_rx_free(struct ath10k_htt
*htt
);
1416 void ath10k_htt_htc_tx_complete(struct ath10k
*ar
, struct sk_buff
*skb
);
1417 void ath10k_htt_t2h_msg_handler(struct ath10k
*ar
, struct sk_buff
*skb
);
1418 int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt
*htt
);
1419 int ath10k_htt_h2t_stats_req(struct ath10k_htt
*htt
, u8 mask
, u64 cookie
);
1420 int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt
*htt
);
1421 int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt
*htt
,
1422 u8 max_subfrms_ampdu
,
1423 u8 max_subfrms_amsdu
);
1425 void __ath10k_htt_tx_dec_pending(struct ath10k_htt
*htt
);
1426 int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt
*htt
, struct sk_buff
*skb
);
1427 void ath10k_htt_tx_free_msdu_id(struct ath10k_htt
*htt
, u16 msdu_id
);
1428 int ath10k_htt_mgmt_tx(struct ath10k_htt
*htt
, struct sk_buff
*);
1429 int ath10k_htt_tx(struct ath10k_htt
*htt
, struct sk_buff
*);