xref: /wlan-driver/qcacld-3.0/components/dsc/inc/wlan_dsc_vdev.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2018-2019, 2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name /**
21*5113495bSYour Name  * DOC: Driver Synchronization Core (DSC) vdev-level APIs
22*5113495bSYour Name  */
23*5113495bSYour Name 
24*5113495bSYour Name #ifndef __WLAN_DSC_VDEV_H
25*5113495bSYour Name #define __WLAN_DSC_VDEV_H
26*5113495bSYour Name 
27*5113495bSYour Name #include "qdf_status.h"
28*5113495bSYour Name #include "wlan_dsc_psoc.h"
29*5113495bSYour Name 
30*5113495bSYour Name /*
31*5113495bSYour Name  * struct dsc_vdev - opaque dsc vdev context
32*5113495bSYour Name  */
33*5113495bSYour Name struct dsc_vdev;
34*5113495bSYour Name 
35*5113495bSYour Name /**
36*5113495bSYour Name  * dsc_vdev_create() - create a dsc vdev context
37*5113495bSYour Name  * @psoc: parent dsc psoc context
38*5113495bSYour Name  * @out_vdev: opaque double pointer to assign the new context to
39*5113495bSYour Name  *
40*5113495bSYour Name  * Note: this attaches @out_vdev to @psoc
41*5113495bSYour Name  *
42*5113495bSYour Name  * Return: QDF_STATUS
43*5113495bSYour Name  */
44*5113495bSYour Name QDF_STATUS dsc_vdev_create(struct dsc_psoc *psoc, struct dsc_vdev **out_vdev);
45*5113495bSYour Name 
46*5113495bSYour Name /**
47*5113495bSYour Name  * dsc_vdev_destroy() - destroy a dsc vdev context
48*5113495bSYour Name  * @out_vdev: opaque double pointer to context to destroy and NULL
49*5113495bSYour Name  *
50*5113495bSYour Name  * Note, this:
51*5113495bSYour Name  *	- detaches @out_vdev from its parent psoc context
52*5113495bSYour Name  *	- aborts all queued transitions on @vdev
53*5113495bSYour Name  *	- asserts @vdev has no operations in flight
54*5113495bSYour Name  *
55*5113495bSYour Name  * Return: None
56*5113495bSYour Name  */
57*5113495bSYour Name void dsc_vdev_destroy(struct dsc_vdev **out_vdev);
58*5113495bSYour Name 
59*5113495bSYour Name /**
60*5113495bSYour Name  * dsc_vdev_trans_start() - start a transition on @vdev
61*5113495bSYour Name  * @vdev: the vdev to start a transition on
62*5113495bSYour Name  * @desc: a unique description of the transition to start
63*5113495bSYour Name  *
64*5113495bSYour Name  * This API immediately aborts if a transition on @vdev is already in flight
65*5113495bSYour Name  *
66*5113495bSYour Name  * Call dsc_vdev_trans_stop() to complete the transition.
67*5113495bSYour Name  *
68*5113495bSYour Name  * Return:
69*5113495bSYour Name  *	QDF_STATUS_SUCCESS - transition started successfully
70*5113495bSYour Name  *	QDF_STATUS_E_INVAL - invalid request (causes debug panic)
71*5113495bSYour Name  *	QDF_STATUS_E_AGAIN - transition cannot currently be started
72*5113495bSYour Name  *	QDF_STATUS_E_ALREADY - transition with @desc already in flight
73*5113495bSYour Name  */
74*5113495bSYour Name QDF_STATUS dsc_vdev_trans_start(struct dsc_vdev *vdev, const char *desc);
75*5113495bSYour Name 
76*5113495bSYour Name /**
77*5113495bSYour Name  * dsc_vdev_trans_start_wait() - start a transition on @vdev, blocking if a
78*5113495bSYour Name  *	transition is already in flight
79*5113495bSYour Name  * @vdev: the vdev to start a transition on
80*5113495bSYour Name  * @desc: a unique description of the transition to start
81*5113495bSYour Name  *
82*5113495bSYour Name  * Call dsc_vdev_trans_stop() to complete the transition.
83*5113495bSYour Name  *
84*5113495bSYour Name  * Return:
85*5113495bSYour Name  *	QDF_STATUS_SUCCESS - transition started successfully
86*5113495bSYour Name  *	QDF_STATUS_E_INVAL - invalid request (causes debug panic)
87*5113495bSYour Name  *	QDF_STATUS_E_AGAIN - transition cannot currently be started
88*5113495bSYour Name  *	QDF_STATUS_E_ALREADY - transition with @desc already queued or in flight
89*5113495bSYour Name  *	QDF_STATUS_E_ABORTED - transition was aborted
90*5113495bSYour Name  */
91*5113495bSYour Name QDF_STATUS dsc_vdev_trans_start_wait(struct dsc_vdev *vdev, const char *desc);
92*5113495bSYour Name 
93*5113495bSYour Name /**
94*5113495bSYour Name  * dsc_vdev_trans_stop() - complete current transition in flight on @vdev
95*5113495bSYour Name  * @vdev: the vdev to complete the transition on
96*5113495bSYour Name  *
97*5113495bSYour Name  * Note: this asserts a transition is currently in flight on @vdev
98*5113495bSYour Name  *
99*5113495bSYour Name  * Return: None
100*5113495bSYour Name  */
101*5113495bSYour Name void dsc_vdev_trans_stop(struct dsc_vdev *vdev);
102*5113495bSYour Name 
103*5113495bSYour Name /**
104*5113495bSYour Name  * dsc_vdev_assert_trans_protected() - assert @vdev is protected by a transition
105*5113495bSYour Name  * @vdev: the vdev to check
106*5113495bSYour Name  *
107*5113495bSYour Name  * The protecting transition may be in flight on @vdev or its ancestors.
108*5113495bSYour Name  *
109*5113495bSYour Name  * Return: None
110*5113495bSYour Name  */
111*5113495bSYour Name void dsc_vdev_assert_trans_protected(struct dsc_vdev *vdev);
112*5113495bSYour Name 
113*5113495bSYour Name /**
114*5113495bSYour Name  * dsc_vdev_op_start() - start an operation on @vdev
115*5113495bSYour Name  * @vdev: the vdev to start an operation on
116*5113495bSYour Name  *
117*5113495bSYour Name  * Return:
118*5113495bSYour Name  *	QDF_STATUS_SUCCESS - operation started successfully
119*5113495bSYour Name  *	QDF_STATUS_E_INVAL - invalid request (causes debug panic)
120*5113495bSYour Name  *	QDF_STATUS_E_AGAIN - operation cannot currently be started
121*5113495bSYour Name  *	QDF_STATUS_E_NOMEM - out of memory
122*5113495bSYour Name  */
123*5113495bSYour Name #define dsc_vdev_op_start(vdev) _dsc_vdev_op_start(vdev, __func__)
124*5113495bSYour Name QDF_STATUS _dsc_vdev_op_start(struct dsc_vdev *vdev, const char *func);
125*5113495bSYour Name 
126*5113495bSYour Name /**
127*5113495bSYour Name  * dsc_vdev_op_stop() - complete operation with matching @func on @vdev
128*5113495bSYour Name  * @vdev: the vdev to stop an operation on
129*5113495bSYour Name  *
130*5113495bSYour Name  * Note: this asserts @func was previously started
131*5113495bSYour Name  *
132*5113495bSYour Name  * Return: None
133*5113495bSYour Name  */
134*5113495bSYour Name #define dsc_vdev_op_stop(vdev) _dsc_vdev_op_stop(vdev, __func__)
135*5113495bSYour Name void _dsc_vdev_op_stop(struct dsc_vdev *vdev, const char *func);
136*5113495bSYour Name 
137*5113495bSYour Name /**
138*5113495bSYour Name  * dsc_vdev_wait_for_ops() - blocks until all operations on @vdev have stopped
139*5113495bSYour Name  * @vdev: the vdev to wait for operations on
140*5113495bSYour Name  *
141*5113495bSYour Name  * Note: this asserts that @vdev cannot currently transition
142*5113495bSYour Name  *
143*5113495bSYour Name  * Return: None
144*5113495bSYour Name  */
145*5113495bSYour Name void dsc_vdev_wait_for_ops(struct dsc_vdev *vdev);
146*5113495bSYour Name 
147*5113495bSYour Name /**
148*5113495bSYour Name  * dsc_vdev_get_cached_cmd() - Get north bound cmd cached during SSR
149*5113495bSYour Name  * @vdev: Pointer to the dsc vdev
150*5113495bSYour Name  *
151*5113495bSYour Name  * This api will be invoked after completion of SSR re-initialization to get
152*5113495bSYour Name  * the last north bound command received during SSR
153*5113495bSYour Name  *
154*5113495bSYour Name  * Return: North bound command ID
155*5113495bSYour Name  */
156*5113495bSYour Name uint8_t dsc_vdev_get_cached_cmd(struct dsc_vdev *vdev);
157*5113495bSYour Name 
158*5113495bSYour Name /**
159*5113495bSYour Name  * dsc_vdev_cache_command() - Cache north bound command during SSR
160*5113495bSYour Name  * @vdev: Pointer to the dsc vdev corresponding to the network interface
161*5113495bSYour Name  * @cmd_id: North bound command ID
162*5113495bSYour Name  *
163*5113495bSYour Name  * This api will be invoked when a north bound command is received during SSR
164*5113495bSYour Name  * and it should be handled after SSR re-initialization.
165*5113495bSYour Name  *
166*5113495bSYour Name  * Return: None
167*5113495bSYour Name  */
168*5113495bSYour Name void dsc_vdev_cache_command(struct dsc_vdev *vdev, uint8_t cmd_id);
169*5113495bSYour Name 
170*5113495bSYour Name /*
171*5113495bSYour Name  * dsc_vdev_wait_for_uptree_ops() - Wait for any uptree operations
172*5113495bSYour Name  * @vdev: The DSC vdev
173*5113495bSYour Name  *
174*5113495bSYour Name  * This function checks and waits for any uptree operations if there is any
175*5113495bSYour Name  * uptree operation is in progress.
176*5113495bSYour Name  *
177*5113495bSYour Name  * Return: None.
178*5113495bSYour Name  */
179*5113495bSYour Name 
180*5113495bSYour Name void dsc_vdev_wait_for_uptree_ops(struct dsc_vdev *vdev);
181*5113495bSYour Name 
182*5113495bSYour Name #endif /* __WLAN_DSC_VDEV_H */
183