xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/crypto/src/wlan_crypto_obj_mgr_i.h (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-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 /**
21  * DOC: Public API initialization of crypto service with object manager
22  */
23 
24 #ifndef __WLAN_CRYPTO_OBJ_MGR_I_
25 #define __WLAN_CRYPTO_OBJ_MGR_I_
26 
27 #ifdef WLAN_CRYPTO_WEP_OS_DERIVATIVE
28 static inline const struct wlan_crypto_cipher *wep_register(void)
29 {
30 	return NULL;
31 }
32 #else
33 const struct wlan_crypto_cipher *wep_register(void);
34 #endif
35 
36 #ifdef WLAN_CRYPTO_TKIP_OS_DERIVATIVE
37 static inline const struct wlan_crypto_cipher *tkip_register(void)
38 {
39 	return NULL;
40 }
41 #else
42 const struct wlan_crypto_cipher *tkip_register(void);
43 #endif
44 
45 #ifdef WLAN_CRYPTO_CCMP_OS_DERIVATIVE
46 static inline const struct wlan_crypto_cipher *ccmp_register(void)
47 {
48 	return NULL;
49 }
50 
51 static inline const struct wlan_crypto_cipher *ccmp256_register(void)
52 {
53 	return NULL;
54 }
55 #else
56 const struct wlan_crypto_cipher *ccmp_register(void);
57 const struct wlan_crypto_cipher *ccmp256_register(void);
58 #endif
59 
60 #ifdef WLAN_CRYPTO_GCMP_OS_DERIVATIVE
61 static inline const struct wlan_crypto_cipher *gcmp_register(void)
62 {
63 	return NULL;
64 }
65 
66 static inline const struct wlan_crypto_cipher *gcmp256_register(void)
67 {
68 	return NULL;
69 }
70 #else
71 const struct wlan_crypto_cipher *gcmp_register(void);
72 const struct wlan_crypto_cipher *gcmp256_register(void);
73 #endif
74 
75 #ifdef WLAN_CRYPTO_WAPI_OS_DERIVATIVE
76 static inline const struct wlan_crypto_cipher *wapi_register(void)
77 {
78 	return NULL;
79 }
80 #else
81 const struct wlan_crypto_cipher *wapi_register(void);
82 #endif
83 
84 #ifdef WLAN_CRYPTO_FILS_OS_DERIVATIVE
85 static inline const struct wlan_crypto_cipher *fils_register(void)
86 {
87 	return NULL;
88 }
89 #else
90 /**
91  * fils_register() - Register all callback functions to Crypto manager
92  *
93  * This function is invoked from crypto object manager to register
94  * FILS specific callbacks.
95  *
96  * Return: Pointer to wlan_crypto_cipher Object
97  */
98 const struct wlan_crypto_cipher *fils_register(void);
99 #endif
100 
101 
102 static inline void *wlan_get_vdev_crypto_obj(struct wlan_objmgr_vdev *vdev)
103 {
104 	void *crypto_priv;
105 	crypto_priv = wlan_objmgr_vdev_get_comp_private_obj(vdev,
106 							WLAN_UMAC_COMP_CRYPTO);
107 
108 	return crypto_priv;
109 }
110 
111 static inline void *wlan_get_peer_crypto_obj(struct wlan_objmgr_peer *peer)
112 {
113 	void *crypto_priv;
114 	crypto_priv = wlan_objmgr_peer_get_comp_private_obj(peer,
115 							WLAN_UMAC_COMP_CRYPTO);
116 
117 	return crypto_priv;
118 }
119 #endif /* end of __WLAN_CRYPTO_OBJ_MGR_I_*/
120