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 /**
18 * DOC: This file contains various object manager related wrappers and helpers
19 */
20
21 #ifndef __WLAN_DP_OBJMGR_H
22 #define __WLAN_DP_OBJMGR_H
23
24 #include "wlan_cmn.h"
25 #include "wlan_objmgr_cmn.h"
26 #include "wlan_objmgr_peer_obj.h"
27 #include "wlan_objmgr_vdev_obj.h"
28 #include "wlan_objmgr_pdev_obj.h"
29 #include "wlan_objmgr_psoc_obj.h"
30 #include "wlan_utility.h"
31
32 struct wlan_dp_intf;
33 struct wlan_dp_link;
34
35 /* Get/Put Ref */
36
37 #define dp_comp_peer_get_ref(peer) wlan_objmgr_peer_try_get_ref(peer, WLAN_DP_ID)
38 #define dp_comp_peer_put_ref(peer) wlan_objmgr_peer_release_ref(peer, WLAN_DP_ID)
39
40 #define dp_comp_vdev_get_ref(vdev) wlan_objmgr_vdev_try_get_ref(vdev, WLAN_DP_ID)
41 #define dp_comp_vdev_put_ref(vdev) wlan_objmgr_vdev_release_ref(vdev, WLAN_DP_ID)
42
43 #define dp_comp_pdev_get_ref(pdev) wlan_objmgr_pdev_try_get_ref(pdev, WLAN_DP_ID)
44 #define dp_comp_pdev_put_ref(pdev) wlan_objmgr_pdev_release_ref(pdev, WLAN_DP_ID)
45
46 #define dp_comp_psoc_get_ref(psoc) wlan_objmgr_psoc_try_get_ref(psoc, WLAN_DP_ID)
47 #define dp_comp_psoc_put_ref(psoc) wlan_objmgr_psoc_release_ref(psoc, WLAN_DP_ID)
48
49 /**
50 * dp_get_peer_priv_obj: get DP priv object from peer object
51 * @peer: pointer to peer object
52 *
53 * Return: pointer to DP peer private object
54 */
55 static inline struct wlan_dp_sta_info *
dp_get_peer_priv_obj(struct wlan_objmgr_peer * peer)56 dp_get_peer_priv_obj(struct wlan_objmgr_peer *peer)
57 {
58 struct wlan_dp_sta_info *peer_info;
59
60 peer_info = wlan_objmgr_peer_get_comp_private_obj(peer, WLAN_COMP_DP);
61 if (!peer_info) {
62 dp_err("peer is null");
63 return NULL;
64 }
65
66 return peer_info;
67 }
68
69 /**
70 * dp_get_vdev_priv_obj() - Wrapper to retrieve vdev priv obj
71 * @vdev: vdev pointer
72 *
73 * Return: DP vdev private object
74 */
75 static inline struct wlan_dp_link *
dp_get_vdev_priv_obj(struct wlan_objmgr_vdev * vdev)76 dp_get_vdev_priv_obj(struct wlan_objmgr_vdev *vdev)
77 {
78 struct wlan_dp_link *obj;
79
80 if (!vdev) {
81 dp_err("vdev is null");
82 return NULL;
83 }
84
85 obj = wlan_objmgr_vdev_get_comp_private_obj(vdev, WLAN_COMP_DP);
86
87 return obj;
88 }
89
90 /**
91 * dp_psoc_get_priv() - Wrapper to retrieve psoc priv obj
92 * @psoc: psoc pointer
93 *
94 * Return: DP psoc private object
95 */
96 static inline struct wlan_dp_psoc_context *
dp_psoc_get_priv(struct wlan_objmgr_psoc * psoc)97 dp_psoc_get_priv(struct wlan_objmgr_psoc *psoc)
98 {
99 struct wlan_dp_psoc_context *dp_ctx;
100
101 dp_ctx = wlan_objmgr_psoc_get_comp_private_obj(psoc, WLAN_COMP_DP);
102 QDF_BUG(dp_ctx);
103
104 return dp_ctx;
105 }
106
107 /**
108 * dp_objmgr_get_vdev_by_user() - Get reference of vdev from dp_link
109 * with user id
110 * @dp_link: DP link handle
111 * @dbgid: reference count dbg id
112 *
113 * Return: pointer to vdev object for success, NULL for failure
114 */
115 #ifdef WLAN_OBJMGR_REF_ID_TRACE
116 #define dp_objmgr_get_vdev_by_user(dp_link, dbgid) \
117 __dp_objmgr_get_vdev_by_user(dp_link, dbgid, __func__, __LINE__)
118 struct wlan_objmgr_vdev *
119 __dp_objmgr_get_vdev_by_user(struct wlan_dp_link *dp_link,
120 wlan_objmgr_ref_dbgid id,
121 const char *func,
122 int line);
123 #else
124 #define dp_objmgr_get_vdev_by_user(dp_link, dbgid) \
125 __dp_objmgr_get_vdev_by_user(dp_link, dbgid, __func__)
126 struct wlan_objmgr_vdev *
127 __dp_objmgr_get_vdev_by_user(struct wlan_dp_link *dp_link,
128 wlan_objmgr_ref_dbgid id,
129 const char *func);
130 #endif
131
132 /**
133 * dp_objmgr_put_vdev_by_user() - Release reference of vdev object with
134 * user id
135 * @vdev: pointer to vdev object
136 * @dbgid: reference count dbg id
137 *
138 * This API releases vdev object reference which was acquired using
139 * dp_objmgr_get_vdev_by_user().
140 *
141 * Return: void
142 */
143 #ifdef WLAN_OBJMGR_REF_ID_TRACE
144 #define dp_objmgr_put_vdev_by_user(vdev, dbgid) \
145 __dp_objmgr_put_vdev_by_user(vdev, dbgid, __func__, __LINE__)
146 void
147 __dp_objmgr_put_vdev_by_user(struct wlan_objmgr_vdev *vdev,
148 wlan_objmgr_ref_dbgid id, const char *func,
149 int line);
150 #else
151 #define dp_objmgr_put_vdev_by_user(vdev, dbgid) \
152 __dp_objmgr_put_vdev_by_user(vdev, dbgid, __func__)
153 void
154 __dp_objmgr_put_vdev_by_user(struct wlan_objmgr_vdev *vdev,
155 wlan_objmgr_ref_dbgid id, const char *func);
156 #endif
157
158 #endif /* __WLAN_DP_OBJMGR_H */
159