1 /*
2 * Copyright (c) 2020 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 * DOC: This file contains various object manager related wrappers and helpers
21 */
22
23 #ifndef _WLAN_PKT_CAPTURE_OBJMGR_H
24 #define _WLAN_PKT_CAPTURE_OBJMGR_H
25
26 #include "wlan_cmn.h"
27 #include "wlan_objmgr_cmn.h"
28 #include "wlan_objmgr_vdev_obj.h"
29 #include "wlan_objmgr_global_obj.h"
30
31 /**
32 * pkt_capture_vdev_get_ref() - Wrapper to increment pkt_capture ref count
33 * @vdev: vdev object
34 *
35 * Wrapper for pkt_capture to increment ref count after checking valid
36 * object state.
37 *
38 * Return: SUCCESS/FAILURE
39 */
40 static inline
pkt_capture_vdev_get_ref(struct wlan_objmgr_vdev * vdev)41 QDF_STATUS pkt_capture_vdev_get_ref(struct wlan_objmgr_vdev *vdev)
42 {
43 return wlan_objmgr_vdev_try_get_ref(vdev, WLAN_PKT_CAPTURE_ID);
44 }
45
46 /**
47 * pkt_capture_vdev_put_ref() - Wrapper to decrement pkt_capture ref count
48 * @vdev: vdev object
49 *
50 * Wrapper for pkt_capture to decrement ref count of vdev.
51 *
52 * Return: SUCCESS/FAILURE
53 */
54 static inline
pkt_capture_vdev_put_ref(struct wlan_objmgr_vdev * vdev)55 void pkt_capture_vdev_put_ref(struct wlan_objmgr_vdev *vdev)
56 {
57 wlan_objmgr_vdev_release_ref(vdev, WLAN_PKT_CAPTURE_ID);
58 }
59
60 /**
61 * pkt_capture_vdev_get_priv() - Wrapper to retrieve vdev priv obj
62 * @vdev: vdev pointer
63 *
64 * Wrapper for pkt_capture to get vdev private object pointer.
65 *
66 * Return: Private object of vdev
67 */
68 static inline struct pkt_capture_vdev_priv *
pkt_capture_vdev_get_priv(struct wlan_objmgr_vdev * vdev)69 pkt_capture_vdev_get_priv(struct wlan_objmgr_vdev *vdev)
70 {
71 struct pkt_capture_vdev_priv *vdev_priv;
72
73 vdev_priv = wlan_objmgr_vdev_get_comp_private_obj(
74 vdev,
75 WLAN_UMAC_COMP_PKT_CAPTURE);
76 QDF_BUG(vdev_priv);
77
78 return vdev_priv;
79 }
80
81 /**
82 * pkt_capture_psoc_get_ref() - Wrapper to increment pkt_capture ref count
83 * @psoc: psoc object
84 *
85 * Wrapper for pkt_capture to increment ref count after checking valid
86 * object state.
87 *
88 * Return: QDF_STATUS
89 */
90 static inline
pkt_capture_psoc_get_ref(struct wlan_objmgr_psoc * psoc)91 QDF_STATUS pkt_capture_psoc_get_ref(struct wlan_objmgr_psoc *psoc)
92 {
93 return wlan_objmgr_psoc_try_get_ref(psoc, WLAN_PKT_CAPTURE_ID);
94 }
95
96 /**
97 * pkt_capture_psoc_put_ref() - Wrapper to decrement pkt_capture ref count
98 * @psoc: psoc object
99 *
100 * Wrapper for pkt_capture to decrement ref count of psoc.
101 *
102 * Return: None
103 */
104 static inline
pkt_capture_psoc_put_ref(struct wlan_objmgr_psoc * psoc)105 void pkt_capture_psoc_put_ref(struct wlan_objmgr_psoc *psoc)
106 {
107 wlan_objmgr_psoc_release_ref(psoc, WLAN_PKT_CAPTURE_ID);
108 }
109
110 /**
111 * pkt_capture_psoc_get_priv(): Wrapper to retrieve psoc priv obj
112 * @psoc: psoc pointer
113 *
114 * Wrapper for pkt_capture to get psoc private object pointer.
115 *
116 * Return: pkt_capture psoc private object
117 */
118 static inline struct pkt_psoc_priv *
pkt_capture_psoc_get_priv(struct wlan_objmgr_psoc * psoc)119 pkt_capture_psoc_get_priv(struct wlan_objmgr_psoc *psoc)
120 {
121 struct pkt_psoc_priv *psoc_priv;
122
123 psoc_priv = wlan_objmgr_psoc_get_comp_private_obj(psoc,
124 WLAN_UMAC_COMP_PKT_CAPTURE);
125 QDF_BUG(psoc_priv);
126
127 return psoc_priv;
128 }
129 #endif /* _WLAN_PKT_CAPTURE_OBJMGR_H */
130