1 /*
2 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef _CDP_TXRX_PPE_H_
18 #define _CDP_TXRX_PPE_H_
19
20 /**
21 * cdp_ppesds_vp_setup_fw_recovery() - Setup DS VP on FW recovery.
22 * @soc: data path soc handle
23 * @vdev_id: vdev id
24 * @profile_idx: DS profile index.
25 *
26 * return: qdf_status where DS VP setup is done or not.
27 */
28 static inline
cdp_ppesds_vp_setup_fw_recovery(struct cdp_soc_t * soc,uint8_t vdev_id,uint16_t profile_idx)29 QDF_STATUS cdp_ppesds_vp_setup_fw_recovery(struct cdp_soc_t *soc,
30 uint8_t vdev_id,
31 uint16_t profile_idx)
32 {
33 if (!soc || !soc->ops || !soc->ops->ppeds_ops) {
34 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
35 "%s invalid instance", __func__);
36 return QDF_STATUS_E_NOSUPPORT;
37 }
38
39 if (soc->ops->ppeds_ops->ppeds_vp_setup_recovery)
40 return soc->ops->ppeds_ops->ppeds_vp_setup_recovery(soc,
41 vdev_id,
42 profile_idx);
43
44 return QDF_STATUS_E_INVAL;
45 }
46
47 /*
48 * cdp_ppesds_update_dev_stats() - Update dev stats for PPE-DS mode.
49 * @soc: data path soc handle
50 * @vp_params: VP params
51 * @vdev_id: vdev id
52 * @stats: stats pointer from ppe
53 *
54 * return: void
55 */
56 static inline
cdp_ppesds_update_dev_stats(struct cdp_soc_t * soc,struct cdp_ds_vp_params * vp_params,uint16_t vdev_id,void * stats)57 void cdp_ppesds_update_dev_stats(struct cdp_soc_t *soc,
58 struct cdp_ds_vp_params *vp_params,
59 uint16_t vdev_id, void *stats)
60 {
61 if (!soc || !soc->ops || !soc->ops->ppeds_ops) {
62 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
63 "%s invalid instance", __func__);
64 return;
65 }
66
67 if (soc->ops->ppeds_ops->ppeds_stats_sync)
68 return soc->ops->ppeds_ops->ppeds_stats_sync(soc,
69 vdev_id,
70 vp_params,
71 stats);
72 }
73
74 /**
75 * cdp_ppesds_entry_attach() - attach the ppe vp interface.
76 * @soc: data path soc handle
77 * @vdev_id: vdev id
78 * @vpai: PPE VP opaque
79 * @ppe_vp_num: Allocated VP Port number
80 * @vp_params: VP params
81 *
82 * return: qdf_status where vp entry got allocated or not.
83 */
84 static inline
cdp_ppesds_entry_attach(struct cdp_soc_t * soc,uint8_t vdev_id,void * vpai,int32_t * ppe_vp_num,struct cdp_ds_vp_params * vp_params)85 QDF_STATUS cdp_ppesds_entry_attach(struct cdp_soc_t *soc, uint8_t vdev_id,
86 void *vpai, int32_t *ppe_vp_num,
87 struct cdp_ds_vp_params *vp_params)
88 {
89 if (!soc || !soc->ops || !soc->ops->ppeds_ops) {
90 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
91 "%s invalid instance", __func__);
92 return QDF_STATUS_E_NOSUPPORT;
93 }
94
95 if (soc->ops->ppeds_ops->ppeds_entry_attach)
96 return soc->ops->ppeds_ops->ppeds_entry_attach(soc, vdev_id,
97 vpai,
98 ppe_vp_num,
99 vp_params);
100
101 return QDF_STATUS_E_INVAL;
102 }
103
104 /**
105 * cdp_ppesds_entry_detach() - Detach the PPE VP interface.
106 * @soc: data path soc handle
107 * @vdev_id: vdev ID
108 * @vp_params: VP params
109 *
110 * return: void
111 */
112 static inline
cdp_ppesds_entry_detach(struct cdp_soc_t * soc,uint8_t vdev_id,struct cdp_ds_vp_params * vp_params)113 void cdp_ppesds_entry_detach(struct cdp_soc_t *soc, uint8_t vdev_id,
114 struct cdp_ds_vp_params *vp_params)
115 {
116 if (!soc || !soc->ops || !soc->ops->ppeds_ops) {
117 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
118 "%s invalid instance", __func__);
119 return;
120 }
121
122 if (soc->ops->ppeds_ops->ppeds_entry_detach)
123 return soc->ops->ppeds_ops->ppeds_entry_detach(soc,
124 vdev_id,
125 vp_params);
126 }
127
128 /**
129 * cdp_ppeds_attached() - Check whether ppeds attached
130 * @soc: data path soc handle
131 *
132 * return: true for ppeds attached otherwise false.
133 */
134 static inline
cdp_ppeds_attached(struct cdp_soc_t * soc)135 QDF_STATUS cdp_ppeds_attached(struct cdp_soc_t *soc)
136 {
137 if (!soc || !soc->ops || !soc->ops->ppeds_ops)
138 return false;
139
140 return true;
141 }
142
143 /**
144 * cdp_ppesds_set_int_pri2tid() - Set the INT_PRI to TID
145 * @soc: data path soc handle
146 * @pri2tid: PRI2TID table
147 *
148 * return: void
149 */
150 static inline
cdp_ppesds_set_int_pri2tid(struct cdp_soc_t * soc,uint8_t * pri2tid)151 void cdp_ppesds_set_int_pri2tid(struct cdp_soc_t *soc,
152 uint8_t *pri2tid)
153 {
154 if (!soc || !soc->ops || !soc->ops->ppeds_ops) {
155 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
156 "%s invalid instance", __func__);
157 return;
158 }
159
160 if (soc->ops->ppeds_ops->ppeds_set_int_pri2tid)
161 return soc->ops->ppeds_ops->ppeds_set_int_pri2tid(soc, pri2tid);
162 }
163
164 /**
165 * cdp_ppesds_update_int_pri2tid() - Update the INT_PRI to TID
166 * @soc: data path soc handle
167 * @pri: Priority index
168 * @tid: TID mapped to the input priority
169 *
170 * return: void
171 */
172 static inline
cdp_ppesds_update_int_pri2tid(struct cdp_soc_t * soc,uint8_t pri,uint8_t tid)173 void cdp_ppesds_update_int_pri2tid(struct cdp_soc_t *soc,
174 uint8_t pri, uint8_t tid)
175 {
176 if (!soc || !soc->ops || !soc->ops->ppeds_ops) {
177 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
178 "%s invalid instance", __func__);
179 }
180
181 if (soc->ops->ppeds_ops->ppeds_update_int_pri2tid)
182 return soc->ops->ppeds_ops->ppeds_update_int_pri2tid(soc, pri,
183 tid);
184 }
185
186 /**
187 * cdp_ppesds_entry_dump() - Dump the PPE VP entries
188 * @soc: data path soc handle
189 *
190 * return: void
191 */
192 static inline
cdp_ppesds_entry_dump(struct cdp_soc_t * soc)193 void cdp_ppesds_entry_dump(struct cdp_soc_t *soc)
194 {
195 if (!soc || !soc->ops || !soc->ops->ppeds_ops) {
196 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
197 "%s invalid instance", __func__);
198 return;
199 }
200
201 if (soc->ops->ppeds_ops->ppeds_entry_dump)
202 soc->ops->ppeds_ops->ppeds_entry_dump(soc);
203 }
204
205 /**
206 * cdp_ppesds_enable_pri2tid() - Enable PPE VP PRI2TID table
207 * @soc: data path soc handle
208 * @vdev_id: vdev id
209 * @val: Boolean value to enable/disable
210 *
211 * return: QDF_STATUS
212 */
213 static inline
cdp_ppesds_enable_pri2tid(struct cdp_soc_t * soc,uint8_t vdev_id,bool val)214 QDF_STATUS cdp_ppesds_enable_pri2tid(struct cdp_soc_t *soc,
215 uint8_t vdev_id, bool val)
216 {
217 if (!soc || !soc->ops || !soc->ops->ppeds_ops) {
218 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
219 "%s invalid instance", __func__);
220 return QDF_STATUS_E_INVAL;
221 }
222
223 if (soc->ops->ppeds_ops->ppeds_enable_pri2tid)
224 return soc->ops->ppeds_ops->ppeds_enable_pri2tid(soc, vdev_id,
225 val);
226
227 return QDF_STATUS_E_NOSUPPORT;
228 }
229 #endif /* _CDP_TXRX_PPE_H_ */
230