xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/dp_htt.h (revision 5c57a8905ee57aab8b10cde048801372f46cc3c0)
1 /*
2  * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef _DP_HTT_H_
20 #define _DP_HTT_H_
21 
22 #include <qdf_types.h>
23 #include <qdf_lock.h>
24 #include <qdf_nbuf.h>
25 #include <htc_api.h>
26 
27 #define HTT_TX_MUTEX_TYPE qdf_spinlock_t
28 
29 #define HTT_TX_MUTEX_INIT(_mutex)				\
30 	qdf_spinlock_create(_mutex)
31 
32 #define HTT_TX_MUTEX_ACQUIRE(_mutex)			\
33 	qdf_spin_lock_bh(_mutex)
34 
35 #define HTT_TX_MUTEX_RELEASE(_mutex)			\
36 	qdf_spin_unlock_bh(_mutex)
37 
38 #define HTT_TX_MUTEX_DESTROY(_mutex)			\
39 	qdf_spinlock_destroy(_mutex)
40 
41 #define DP_HTT_MAX_SEND_QUEUE_DEPTH 64
42 
43 #ifndef HTT_MAC_ADDR_LEN
44 #define HTT_MAC_ADDR_LEN 6
45 #endif
46 
47 #define DP_HTT_HTC_PKT_MISCLIST_SIZE          256
48 
49 #define HTT_T2H_EXT_STATS_TLV_START_OFFSET    3
50 
51 struct dp_htt_htc_pkt {
52 	void *soc_ctxt;
53 	qdf_dma_addr_t nbuf_paddr;
54 	HTC_PACKET htc_pkt;
55 };
56 
57 struct dp_htt_htc_pkt_union {
58 	union {
59 		struct dp_htt_htc_pkt pkt;
60 		struct dp_htt_htc_pkt_union *next;
61 	} u;
62 };
63 
64 struct htt_soc {
65 	void *osif_soc;
66 	void *dp_soc;
67 	void *hal_soc;
68 	HTC_HANDLE htc_soc;
69 	qdf_device_t osdev;
70 	HTC_ENDPOINT_ID htc_endpoint;
71 	struct dp_htt_htc_pkt_union *htt_htc_pkt_freelist;
72 	struct dp_htt_htc_pkt_union *htt_htc_pkt_misclist;
73 	struct {
74 		u_int8_t major;
75 		u_int8_t minor;
76 	} tgt_ver;
77 	struct {
78 		u_int8_t major;
79 		u_int8_t minor;
80 	} wifi_ip_ver;
81 
82 	struct {
83 		int htc_err_cnt;
84 		int htc_pkt_free;
85 	} stats;
86 
87 	HTT_TX_MUTEX_TYPE htt_tx_mutex;
88 };
89 
90 /**
91  * struct htt_rx_ring_tlv_filter - Rx ring TLV filter
92  * enable/disable.
93  * @mpdu_start: enable/disable MPDU start TLV
94  * @msdu_start: enable/disable MSDU start TLV
95  * @packet: enable/disable PACKET TLV
96  * @msdu_end: enable/disable MSDU end TLV
97  * @mpdu_end: enable/disable MPDU end TLV
98  * @packet_header: enable/disable PACKET header TLV
99  * @attention: enable/disable ATTENTION TLV
100  * @ppdu_start: enable/disable PPDU start TLV
101  * @ppdu_end: enable/disable PPDU end TLV
102  * @ppdu_end_user_stats: enable/disable PPDU user stats TLV
103  * @ppdu_end_user_stats_ext: enable/disable PPDU user stats ext TLV
104  * @ppdu_end_status_done: enable/disable PPDU end status done TLV
105  * @enable_fp: enable/disable FP packet
106  * @enable_md: enable/disable MD packet
107  * @enable_mo: enable/disable MO packet
108  */
109 struct htt_rx_ring_tlv_filter {
110 	u_int32_t mpdu_start:1,
111 		msdu_start:1,
112 		packet:1,
113 		msdu_end:1,
114 		mpdu_end:1,
115 		packet_header:1,
116 		attention:1,
117 		ppdu_start:1,
118 		ppdu_end:1,
119 		ppdu_end_user_stats:1,
120 		ppdu_end_user_stats_ext:1,
121 		ppdu_end_status_done:1,
122 		header_per_msdu:1,
123 		enable_fp:1,
124 		enable_md:1,
125 		enable_mo:1;
126 };
127 
128 void *
129 htt_soc_attach(void *txrx_soc, void *osif_soc, HTC_HANDLE htc_soc,
130 	void *hal_soc, qdf_device_t osdev);
131 
132 void htt_soc_detach(void *soc);
133 
134 int htt_srng_setup(void *htt_soc, int pdev_id, void *hal_srng,
135 	int hal_ring_type);
136 
137 int htt_soc_attach_target(void *htt_soc);
138 
139 /*
140  * htt_h2t_rx_ring_cfg() - Send SRNG packet and TLV filter
141  * config message to target
142  * @htt_soc:	HTT SOC handle
143  * @pdev_id:	PDEV Id
144  * @hal_srng:	Opaque HAL SRNG pointer
145  * @hal_ring_type:	SRNG ring type
146  * @ring_buf_size:	SRNG buffer size
147  * @htt_tlv_filter:	Rx SRNG TLV and filter setting
148  *
149  * Return: 0 on success; error code on failure
150  */
151 int htt_h2t_rx_ring_cfg(void *htt_soc, int pdev_id, void *hal_srng,
152 	int hal_ring_type, int ring_buf_size,
153 	struct htt_rx_ring_tlv_filter *htt_tlv_filter);
154 
155 /*
156  * htt_t2h_stats_handler() - target to host stats work handler
157  * @context:	context (dp soc context)
158  *
159  * Return: void
160  */
161 void htt_t2h_stats_handler(void *context);
162 
163 /**
164  * struct htt_stats_context - htt stats information
165  * @soc: Size of each descriptor in the pool
166  * @msg: T2H Ext stats message queue
167  * @msg_len: T2H Ext stats message length
168  */
169 struct htt_stats_context {
170 	struct dp_soc *soc;
171 	qdf_nbuf_queue_t msg;
172 	uint32_t msg_len;
173 };
174 
175 #endif /* _DP_HTT_H_ */
176