blob: b3612fc2412e63ef89224e6d148a16c6068adccc [file] [log] [blame]
Siddarth Poddarb2011f62016-04-27 20:45:42 +05301/*
Yun Park57b82632017-04-05 21:35:21 -07002 * Copyright (c) 2012-2013, 2016-2017 The Linux Foundation. All rights reserved.
Siddarth Poddarb2011f62016-04-27 20:45:42 +05303 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * @file ol_tx_sched.h
30 * @brief API definitions for the tx scheduler module within the data SW.
31 */
32#ifndef _OL_TX_SCHED__H_
33#define _OL_TX_SCHED__H_
34
35#include <qdf_types.h>
36
37enum ol_tx_queue_action {
38 OL_TX_ENQUEUE_FRAME,
39 OL_TX_DELETE_QUEUE,
40 OL_TX_PAUSE_QUEUE,
41 OL_TX_UNPAUSE_QUEUE,
42 OL_TX_DISCARD_FRAMES,
43};
44
45struct ol_tx_sched_notify_ctx_t {
46 int event;
47 struct ol_tx_frms_queue_t *txq;
48 union {
49 int ext_tid;
50 struct ol_txrx_msdu_info_t *tx_msdu_info;
51 } info;
52 int frames;
53 int bytes;
54};
55
56#if defined(CONFIG_HL_SUPPORT)
57
58void
59ol_tx_sched_notify(
60 struct ol_txrx_pdev_t *pdev,
61 struct ol_tx_sched_notify_ctx_t *ctx);
62
63void
64ol_tx_sched(struct ol_txrx_pdev_t *pdev);
65
66u_int16_t
67ol_tx_sched_discard_select(
68 struct ol_txrx_pdev_t *pdev,
69 u_int16_t frms,
70 ol_tx_desc_list *tx_descs,
71 bool force);
72
73void *
74ol_tx_sched_attach(struct ol_txrx_pdev_t *pdev);
75
76void
77ol_tx_sched_detach(struct ol_txrx_pdev_t *pdev);
78
79void ol_tx_sched_stats_display(struct ol_txrx_pdev_t *pdev);
80
81void ol_tx_sched_cur_state_display(struct ol_txrx_pdev_t *pdev);
82
83void ol_tx_sched_stats_clear(struct ol_txrx_pdev_t *pdev);
84
85#else
86
87static inline void
88ol_tx_sched_notify(
89 struct ol_txrx_pdev_t *pdev,
90 struct ol_tx_sched_notify_ctx_t *ctx)
91{
Siddarth Poddarb2011f62016-04-27 20:45:42 +053092}
93
94static inline void
95ol_tx_sched(struct ol_txrx_pdev_t *pdev)
96{
Siddarth Poddarb2011f62016-04-27 20:45:42 +053097}
98
99static inline u_int16_t
100ol_tx_sched_discard_select(
101 struct ol_txrx_pdev_t *pdev,
102 u_int16_t frms,
103 ol_tx_desc_list *tx_descs,
104 bool force)
105{
106 return 0;
107}
108
109static inline void *
110ol_tx_sched_attach(struct ol_txrx_pdev_t *pdev)
111{
112 return NULL;
113}
114
115static inline void
116ol_tx_sched_detach(struct ol_txrx_pdev_t *pdev)
117{
Siddarth Poddarb2011f62016-04-27 20:45:42 +0530118}
119
120static inline void ol_tx_sched_stats_display(struct ol_txrx_pdev_t *pdev)
121{
Siddarth Poddarb2011f62016-04-27 20:45:42 +0530122}
123
124static inline void ol_tx_sched_cur_state_display(struct ol_txrx_pdev_t *pdev)
125{
Siddarth Poddarb2011f62016-04-27 20:45:42 +0530126}
127
128static inline void ol_tx_sched_stats_clear(struct ol_txrx_pdev_t *pdev)
129{
Siddarth Poddarb2011f62016-04-27 20:45:42 +0530130}
131
132#endif /* defined(CONFIG_HL_SUPPORT) */
133
134#if defined(CONFIG_HL_SUPPORT) || defined(TX_CREDIT_RECLAIM_SUPPORT)
135/*
136 * HL needs to keep track of the amount of credit available to download
137 * tx frames to the target - the download scheduler decides when to
138 * download frames, and which frames to download, based on the credit
139 * availability.
140 * LL systems that use TX_CREDIT_RECLAIM_SUPPORT also need to keep track
141 * of the target_tx_credit, to determine when to poll for tx completion
142 * messages.
143 */
144
145static inline void
146ol_tx_target_credit_adjust(int factor,
147 struct ol_txrx_pdev_t *pdev,
148 qdf_nbuf_t msdu)
149{
150 qdf_atomic_add(factor * htt_tx_msdu_credit(msdu),
151 &pdev->target_tx_credit);
152}
153
154static inline void ol_tx_target_credit_decr(struct ol_txrx_pdev_t *pdev,
155 qdf_nbuf_t msdu)
156{
157 ol_tx_target_credit_adjust(-1, pdev, msdu);
158}
159
160static inline void ol_tx_target_credit_incr(struct ol_txrx_pdev_t *pdev,
161 qdf_nbuf_t msdu)
162{
163 ol_tx_target_credit_adjust(1, pdev, msdu);
164}
165#else
166/*
167 * LL does not need to keep track of target credit.
168 * Since the host tx descriptor pool size matches the target's,
169 * we know the target has space for the new tx frame if the host's
170 * tx descriptor allocation succeeded.
171 */
172static inline void
173ol_tx_target_credit_adjust(int factor,
174 struct ol_txrx_pdev_t *pdev,
175 qdf_nbuf_t msdu)
176{
Siddarth Poddarb2011f62016-04-27 20:45:42 +0530177}
178
179static inline void ol_tx_target_credit_decr(struct ol_txrx_pdev_t *pdev,
180 qdf_nbuf_t msdu)
181{
Siddarth Poddarb2011f62016-04-27 20:45:42 +0530182}
183
184static inline void ol_tx_target_credit_incr(struct ol_txrx_pdev_t *pdev,
185 qdf_nbuf_t msdu)
186{
Siddarth Poddarb2011f62016-04-27 20:45:42 +0530187}
188#endif
189#endif /* _OL_TX_SCHED__H_ */