1 /* 2 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved. 3 * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. 4 * 5 * Permission to use, copy, modify, and/or distribute this software for 6 * any purpose with or without fee is hereby granted, provided that the 7 * above copyright notice and this permission notice appear in all 8 * copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 11 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 12 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 13 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 16 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 * PERFORMANCE OF THIS SOFTWARE. 18 */ 19 /** 20 * DOC: Public APIs to perform operations on Global objects 21 */ 22 #ifndef _WLAN_OBJMGR_PSOC_OBJ_I_H_ 23 #define _WLAN_OBJMGR_PSOC_OBJ_I_H_ 24 25 /** 26 * wlan_objmgr_for_each_psoc_pdev() - iterate over each pdev for @psoc 27 * @psoc: the psoc whose pdevs should be iterated 28 * @pdev_id: pdev Id index cursor 29 * @pdev: pdev object cursor 30 * 31 * Note: The caller is responsible for grabbing @psoc's object lock before 32 * using this iterator 33 */ 34 #define wlan_objmgr_for_each_psoc_pdev(psoc, pdev_id, pdev) \ 35 for (pdev_id = 0; pdev_id < WLAN_UMAC_MAX_PDEVS; pdev_id++) \ 36 if ((pdev = (psoc)->soc_objmgr.wlan_pdev_list[pdev_id])) 37 38 /** 39 * wlan_objmgr_for_each_psoc_vdev() - iterate over each vdev for @psoc 40 * @psoc: the psoc whose vdevs should be iterated 41 * @vdev_id: vdev Id index cursor 42 * @vdev: vdev object cursor 43 * 44 * Note: The caller is responsible for grabbing @psoc's object lock before 45 * using this iterator 46 */ 47 #define wlan_objmgr_for_each_psoc_vdev(psoc, vdev_id, vdev) \ 48 for (vdev_id = 0; vdev_id < WLAN_UMAC_PSOC_MAX_VDEVS; vdev_id++) \ 49 if ((vdev = (psoc)->soc_objmgr.wlan_vdev_list[vdev_id])) 50 51 /** 52 * wlan_objmgr_for_each_refs() - iterate non-zero ref counts in @ref_id_dbg 53 * @ref_id_dbg: the ref count array to iterate 54 * @ref_id: the reference Id index cursor 55 * @refs: the ref count cursor 56 * 57 * Note: The caller is responsible for grabbing @ref_id_dbg's parent object lock 58 * before using this iterator 59 */ 60 #define wlan_objmgr_for_each_refs(ref_id_dbg, ref_id, refs) \ 61 for (ref_id = 0; ref_id < WLAN_REF_ID_MAX; ref_id++) \ 62 if ((refs = qdf_atomic_read(&(ref_id_dbg)[ref_id])) > 0) 63 64 /** 65 * wlan_objmgr_psoc_pdev_attach() - store pdev in psoc's pdev list 66 * @psoc: PSOC object 67 * @pdev: PDEV object 68 * 69 * Attaches PDEV to PSOC, allocates PDEV id 70 * 71 * Return: SUCCESS 72 * Failure (Max PDEVs are exceeded) 73 */ 74 QDF_STATUS wlan_objmgr_psoc_pdev_attach(struct wlan_objmgr_psoc *psoc, 75 struct wlan_objmgr_pdev *pdev); 76 77 /** 78 * wlan_objmgr_psoc_pdev_detach() - remove pdev from psoc's pdev list 79 * @psoc: PSOC object 80 * @pdev: PDEV object 81 * 82 * detaches PDEV to PSOC, frees PDEV id 83 * 84 * Return: SUCCESS 85 * Failure (No PDEVs are present) 86 */ 87 QDF_STATUS wlan_objmgr_psoc_pdev_detach(struct wlan_objmgr_psoc *psoc, 88 struct wlan_objmgr_pdev *pdev); 89 90 /** 91 * wlan_objmgr_psoc_vdev_attach() - store vdev in psoc's vdev list 92 * @psoc: PSOC object 93 * @vdev: VDEV object 94 * 95 * Attaches VDEV to PSOC, allocates VDEV id 96 * 97 * Return: SUCCESS 98 * Failure (Max VDEVs are exceeded) 99 */ 100 QDF_STATUS wlan_objmgr_psoc_vdev_attach(struct wlan_objmgr_psoc *psoc, 101 struct wlan_objmgr_vdev *vdev); 102 103 /** 104 * wlan_objmgr_psoc_vdev_detach() - remove vdev from psoc's vdev list 105 * @psoc: PSOC object 106 * @vdev: VDEV object 107 * 108 * detaches VDEV to PSOC, frees VDEV id 109 * 110 * Return: SUCCESS 111 * Failure (No VDEVs are present) 112 */ 113 QDF_STATUS wlan_objmgr_psoc_vdev_detach(struct wlan_objmgr_psoc *psoc, 114 struct wlan_objmgr_vdev *vdev); 115 116 /** 117 * wlan_objmgr_psoc_peer_attach() - store peer in psoc's peer table 118 * @psoc: PSOC object 119 * @peer: PEER object 120 * 121 * Attaches PEER to PSOC, derives the HASH, add peer to its peer list 122 * 123 * Return: SUCCESS 124 * Failure (Max PEERs are exceeded) 125 */ 126 QDF_STATUS wlan_objmgr_psoc_peer_attach(struct wlan_objmgr_psoc *psoc, 127 struct wlan_objmgr_peer *peer); 128 129 /** 130 * wlan_objmgr_psoc_peer_detach() - remove peer from psoc's peer table 131 * @psoc: PSOC object 132 * @peer: PEER object 133 * 134 * detaches PEER to PSOC, removes the peer from the peer list 135 * 136 * Return: SUCCESS 137 * Failure (PEER is not present) 138 */ 139 QDF_STATUS wlan_objmgr_psoc_peer_detach(struct wlan_objmgr_psoc *psoc, 140 struct wlan_objmgr_peer *peer); 141 #endif /* _WLAN_OBJMGR_PSOC_OBJ_I_H_ */ 142