1 /*
2 * Copyright (c) 2012-2013, 2016-2019 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_soc_t *soc_hdl, uint8_t pdev_id,
78 struct ol_tx_wmm_param_t wmm_param);
79
80 #else
81
82 static inline void
ol_tx_sched_notify(struct ol_txrx_pdev_t * pdev,struct ol_tx_sched_notify_ctx_t * ctx)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
ol_tx_sched(struct ol_txrx_pdev_t * pdev)90 ol_tx_sched(struct ol_txrx_pdev_t *pdev)
91 {
92 }
93
94 static inline u_int16_t
ol_tx_sched_discard_select(struct ol_txrx_pdev_t * pdev,u_int16_t frms,ol_tx_desc_list * tx_descs,bool force)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 *
ol_tx_sched_attach(struct ol_txrx_pdev_t * pdev)105 ol_tx_sched_attach(struct ol_txrx_pdev_t *pdev)
106 {
107 return NULL;
108 }
109
110 static inline void
ol_tx_sched_detach(struct ol_txrx_pdev_t * pdev)111 ol_tx_sched_detach(struct ol_txrx_pdev_t *pdev)
112 {
113 }
114
ol_tx_sched_stats_display(struct ol_txrx_pdev_t * pdev)115 static inline void ol_tx_sched_stats_display(struct ol_txrx_pdev_t *pdev)
116 {
117 }
118
ol_tx_sched_cur_state_display(struct ol_txrx_pdev_t * pdev)119 static inline void ol_tx_sched_cur_state_display(struct ol_txrx_pdev_t *pdev)
120 {
121 }
122
ol_tx_sched_stats_clear(struct ol_txrx_pdev_t * pdev)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
ol_tx_target_credit_adjust(int factor,struct ol_txrx_pdev_t * pdev,qdf_nbuf_t msdu)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
ol_tx_target_credit_decr(struct ol_txrx_pdev_t * pdev,qdf_nbuf_t msdu)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
ol_tx_target_credit_incr(struct ol_txrx_pdev_t * pdev,qdf_nbuf_t msdu)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
161 #ifdef QCA_TX_PADDING_CREDIT_SUPPORT
162
163 #define MIN_TX_PAD_CREDIT_THRESH 4
164 #define MAX_TX_PAD_CREDIT_THRESH 5
165
166 #endif /* QCA_TX_PADDING_CREDIT_SUPPORT */
167
168 #else
169 /*
170 * LL does not need to keep track of target credit.
171 * Since the host tx descriptor pool size matches the target's,
172 * we know the target has space for the new tx frame if the host's
173 * tx descriptor allocation succeeded.
174 */
175 static inline void
ol_tx_target_credit_adjust(int factor,struct ol_txrx_pdev_t * pdev,qdf_nbuf_t msdu)176 ol_tx_target_credit_adjust(int factor,
177 struct ol_txrx_pdev_t *pdev,
178 qdf_nbuf_t msdu)
179 {
180 }
181
ol_tx_target_credit_decr(struct ol_txrx_pdev_t * pdev,qdf_nbuf_t msdu)182 static inline void ol_tx_target_credit_decr(struct ol_txrx_pdev_t *pdev,
183 qdf_nbuf_t msdu)
184 {
185 }
186
ol_tx_target_credit_incr(struct ol_txrx_pdev_t * pdev,qdf_nbuf_t msdu)187 static inline void ol_tx_target_credit_incr(struct ol_txrx_pdev_t *pdev,
188 qdf_nbuf_t msdu)
189 {
190 }
191
192 #endif
193 #endif /* _OL_TX_SCHED__H_ */
194