xref: /wlan-dirver/qcacld-3.0/core/dp/txrx/ol_tx_sched.h (revision bb8e47c200751dd274982fa7d00566e04456aa23)
1 /*
2  * Copyright (c) 2012-2013, 2016-2018 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 /**
20  * @file ol_tx_sched.h
21  * @brief API definitions for the tx scheduler module within the data SW.
22  */
23 #ifndef _OL_TX_SCHED__H_
24 #define _OL_TX_SCHED__H_
25 
26 #include <qdf_types.h>
27 
28 enum ol_tx_queue_action {
29 	OL_TX_ENQUEUE_FRAME,
30 	OL_TX_DELETE_QUEUE,
31 	OL_TX_PAUSE_QUEUE,
32 	OL_TX_UNPAUSE_QUEUE,
33 	OL_TX_DISCARD_FRAMES,
34 };
35 
36 struct ol_tx_sched_notify_ctx_t {
37 	int event;
38 	struct ol_tx_frms_queue_t *txq;
39 	union {
40 		int ext_tid;
41 		struct ol_txrx_msdu_info_t *tx_msdu_info;
42 	} info;
43 	int frames;
44 	int bytes;
45 };
46 
47 #if defined(CONFIG_HL_SUPPORT)
48 
49 void
50 ol_tx_sched_notify(
51 		struct ol_txrx_pdev_t *pdev,
52 		struct ol_tx_sched_notify_ctx_t *ctx);
53 
54 void
55 ol_tx_sched(struct ol_txrx_pdev_t *pdev);
56 
57 u_int16_t
58 ol_tx_sched_discard_select(
59 		struct ol_txrx_pdev_t *pdev,
60 		u_int16_t frms,
61 		ol_tx_desc_list *tx_descs,
62 		bool force);
63 
64 void *
65 ol_tx_sched_attach(struct ol_txrx_pdev_t *pdev);
66 
67 void
68 ol_tx_sched_detach(struct ol_txrx_pdev_t *pdev);
69 
70 void ol_tx_sched_stats_display(struct ol_txrx_pdev_t *pdev);
71 
72 void ol_tx_sched_cur_state_display(struct ol_txrx_pdev_t *pdev);
73 
74 void ol_tx_sched_stats_clear(struct ol_txrx_pdev_t *pdev);
75 
76 void
77 ol_txrx_set_wmm_param(struct cdp_pdev *data_pdev,
78 		      struct ol_tx_wmm_param_t wmm_param);
79 
80 #else
81 
82 static inline void
83 ol_tx_sched_notify(
84 		struct ol_txrx_pdev_t *pdev,
85 		struct ol_tx_sched_notify_ctx_t *ctx)
86 {
87 }
88 
89 static inline void
90 ol_tx_sched(struct ol_txrx_pdev_t *pdev)
91 {
92 }
93 
94 static inline u_int16_t
95 ol_tx_sched_discard_select(
96 		struct ol_txrx_pdev_t *pdev,
97 		u_int16_t frms,
98 		ol_tx_desc_list *tx_descs,
99 		bool force)
100 {
101 	return 0;
102 }
103 
104 static inline void *
105 ol_tx_sched_attach(struct ol_txrx_pdev_t *pdev)
106 {
107 	return NULL;
108 }
109 
110 static inline void
111 ol_tx_sched_detach(struct ol_txrx_pdev_t *pdev)
112 {
113 }
114 
115 static inline void ol_tx_sched_stats_display(struct ol_txrx_pdev_t *pdev)
116 {
117 }
118 
119 static inline void ol_tx_sched_cur_state_display(struct ol_txrx_pdev_t *pdev)
120 {
121 }
122 
123 static inline void ol_tx_sched_stats_clear(struct ol_txrx_pdev_t *pdev)
124 {
125 }
126 
127 #endif /* defined(CONFIG_HL_SUPPORT) */
128 
129 #if defined(CONFIG_HL_SUPPORT) || defined(TX_CREDIT_RECLAIM_SUPPORT)
130 /*
131  * HL needs to keep track of the amount of credit available to download
132  * tx frames to the target - the download scheduler decides when to
133  * download frames, and which frames to download, based on the credit
134  * availability.
135  * LL systems that use TX_CREDIT_RECLAIM_SUPPORT also need to keep track
136  * of the target_tx_credit, to determine when to poll for tx completion
137  * messages.
138  */
139 
140 static inline void
141 ol_tx_target_credit_adjust(int factor,
142 			   struct ol_txrx_pdev_t *pdev,
143 			   qdf_nbuf_t msdu)
144 {
145 	qdf_atomic_add(factor * htt_tx_msdu_credit(msdu),
146 		       &pdev->target_tx_credit);
147 }
148 
149 static inline void ol_tx_target_credit_decr(struct ol_txrx_pdev_t *pdev,
150 					    qdf_nbuf_t msdu)
151 {
152 	ol_tx_target_credit_adjust(-1, pdev, msdu);
153 }
154 
155 static inline void ol_tx_target_credit_incr(struct ol_txrx_pdev_t *pdev,
156 					    qdf_nbuf_t msdu)
157 {
158 	ol_tx_target_credit_adjust(1, pdev, msdu);
159 }
160 #else
161 /*
162  * LL does not need to keep track of target credit.
163  * Since the host tx descriptor pool size matches the target's,
164  * we know the target has space for the new tx frame if the host's
165  * tx descriptor allocation succeeded.
166  */
167 static inline void
168 ol_tx_target_credit_adjust(int factor,
169 			   struct ol_txrx_pdev_t *pdev,
170 			   qdf_nbuf_t msdu)
171 {
172 }
173 
174 static inline void ol_tx_target_credit_decr(struct ol_txrx_pdev_t *pdev,
175 					    qdf_nbuf_t msdu)
176 {
177 }
178 
179 static inline void ol_tx_target_credit_incr(struct ol_txrx_pdev_t *pdev,
180 					    qdf_nbuf_t msdu)
181 {
182 }
183 #endif
184 #endif /* _OL_TX_SCHED__H_ */
185