xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/crypto/inc/wlan_crypto_global_api.h (revision c8039e3fa439b838b525783fb76d6bdc0259257c)
1 /*
2  * Copyright (c) 2017 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: Public APIs for crypto service
21  */
22 #ifndef _WLAN_CRYPTO_GLOBAL_API_H_
23 #define _WLAN_CRYPTO_GLOBAL_API_H_
24 
25 
26 /**
27  * wlan_crypto_set_param - called by ucfg to set crypto param
28  *
29  * @vdev: vdev
30  * @param: param to be set.
31  * @value: value
32  *
33  * This function gets called from ucfg to set param
34  *
35  * Return: QDF_STATUS_SUCCESS - in case of success
36  */
37 QDF_STATUS wlan_crypto_set_param(struct wlan_objmgr_vdev *vdev,
38 					wlan_crypto_param_type param,
39 					uint32_t value);
40 
41 /**
42  * wlan_crypto_get_param - called by ucfg to get crypto param
43  *
44  * @vdev: vdev
45  * @param: param to be get.
46  *
47  * This function gets called from ucfg to get param
48  *
49  * Return: value or -1 for failure
50  */
51 int32_t wlan_crypto_get_param(struct wlan_objmgr_vdev *vdev,
52 					wlan_crypto_param_type param);
53 /**
54  * wlan_crypto_setkey - called by ucfg to setkey
55  *
56  * @vdev: vdev
57  * @req_key: req_key with cipher type, key macaddress
58  *
59  * This function gets called from ucfg to sey key
60  *
61  * Return: QDF_STATUS_SUCCESS - in case of success
62  */
63 QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev,
64 					struct wlan_crypto_req_key *req_key);
65 
66 /**
67  * wlan_crypto_getkey - called by ucfg to get key
68  *
69  * @vdev: vdev
70  * @req_key: key value will be copied in this req_key
71  * @mac_address: mac address of the peer for unicast key
72  *                   or broadcast address if group key is requested.
73  * This function gets called from ucfg to get key
74  *
75  * Return: QDF_STATUS_SUCCESS - in case of success
76  */
77 QDF_STATUS wlan_crypto_getkey(struct wlan_objmgr_vdev *vdev,
78 					struct wlan_crypto_req_key *req_key,
79 					uint8_t *mac_addr);
80 
81 /**
82  * wlan_crypto_delkey - called by ucfg to delete key
83  *
84  * @vdev: vdev
85  * @mac_address: mac address of the peer for unicast key
86  *                   or broadcast address if group key is deleted.
87  * @key_idx: key index to be deleted
88  * This function gets called from ucfg to delete key
89  *
90  * Return: QDF_STATUS_SUCCESS - in case of success
91  */
92 QDF_STATUS wlan_crypto_delkey(struct wlan_objmgr_vdev *vdev,
93 					uint8_t *macaddr,
94 					uint8_t key_idx);
95 
96 /**
97  * wlan_crypto_default_key - called by ucfg to set default tx key
98  *
99  * @vdev: vdev
100  * @mac_address: mac address of the peer for unicast key
101  *                   or broadcast address if group key need to made default.
102  * @key_idx: key index to be made as default key
103  * @unicast: is key was unicast or group key.
104  * This function gets called from ucfg to set default key
105  *
106  * Return: QDF_STATUS_SUCCESS - in case of success
107  */
108 QDF_STATUS wlan_crypto_default_key(struct wlan_objmgr_vdev *vdev,
109 					uint8_t *macaddr,
110 					uint8_t key_idx,
111 					bool unicast);
112 
113 /**
114  * wlan_crypto_encap - called by mgmt for encap the frame based on cipher
115  *
116  * @vdev: vdev
117  * @wbuf: wbuf
118  * @macaddr: macaddr
119  * @encapdone: is encapdone already or not.
120  * This function gets called from mgmt txrx to encap frame.
121  *
122  * Return: QDF_STATUS_SUCCESS - in case of success
123  */
124 QDF_STATUS wlan_crypto_encap(struct wlan_objmgr_vdev *vdev,
125 					qdf_nbuf_t wbuf,
126 					uint8_t *macaddr,
127 					uint8_t encapdone);
128 
129 /**
130  * wlan_crypto_decap - called by mgmt for decap the frame based on cipher
131  *
132  * @vdev: vdev
133  * @wbuf: wbuf
134  * @macaddr: macaddr
135  * @tid: tid of the packet.
136  * This function gets called from mgmt txrx to decap frame.
137  *
138  * Return: QDF_STATUS_SUCCESS - in case of success
139  */
140 QDF_STATUS wlan_crypto_decap(struct wlan_objmgr_vdev *vdev,
141 					qdf_nbuf_t wbuf,
142 					uint8_t *macaddr,
143 					uint8_t tid);
144 
145 /**
146  * wlan_crypto_enmic - called by mgmt for adding mic in frame based on cipher
147  *
148  * @vdev: vdev
149  * @wbuf: wbuf
150  * @macaddr: macaddr
151  * @encapdone: is encapdone already or not.
152  * This function gets called from mgmt txrx to adding mic to the frame.
153  *
154  * Return: QDF_STATUS_SUCCESS - in case of success
155  */
156 QDF_STATUS wlan_crypto_enmic(struct wlan_objmgr_vdev *vdev,
157 					qdf_nbuf_t wbuf,
158 					uint8_t *macaddr,
159 					uint8_t encapdone);
160 
161 /**
162  * wlan_crypto_demic - called by mgmt for remove and check mic for
163  *                                    the frame based on cipher
164  *
165  * @vdev: vdev
166  * @wbuf: wbuf
167  * @macaddr: macaddr
168  * @tid: tid of the frame
169  * This function gets called from mgmt txrx to decap frame.
170  *
171  * Return: QDF_STATUS_SUCCESS - in case of success
172  */
173 QDF_STATUS wlan_crypto_demic(struct wlan_objmgr_vdev *vdev,
174 					qdf_nbuf_t wbuf,
175 					uint8_t *macaddr,
176 					uint8_t tid);
177 
178 /**
179  * wlan_crypto_is_pmf_enabled - called by mgmt txrx to check is pmf enabled
180  *
181  * @vdev: vdev
182  * @peer: peer
183  *
184  * This function gets called by mgmt txrx to check is pmf enabled or not.
185  *
186  * Return: true or false
187  */
188 bool wlan_crypto_is_pmf_enabled(struct wlan_objmgr_vdev *vdev,
189 					struct wlan_objmgr_peer *peer);
190 
191 /**
192  * wlan_crypto_add_mmie - called by mgmt txrx to add mmie in frame
193  *
194  * @vdev: vdev
195  * @frm:  frame starting pointer
196  * @len: length of the frame
197  *
198  * This function gets called by mgmt txrx to add mmie in frame
199  *
200  * Return: end of frame or NULL in case failure
201  */
202 uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev,
203 					uint8_t *frm,
204 					uint32_t len);
205 
206 /**
207  * wlan_crypto_is_mmie_valid - called by mgmt txrx to check mmie of the frame
208  *
209  * @vdev: vdev
210  * @frm:  frame starting pointer
211  * @efrm: end of frame pointer
212  *
213  * This function gets called by mgmt txrx to check mmie of the frame
214  *
215  * Return: true or false
216  */
217 bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev,
218 					uint8_t *frm,
219 					uint8_t *efrm);
220 
221 /**
222  * wlan_crypto_wpaie_check - called by mlme to check the wpaie
223  *
224  *
225  * @crypto params: crypto params
226  * @iebuf: ie buffer
227  *
228  * This function gets called by mlme to check the contents of wpa is
229  * matching with given crypto params
230  *
231  * Return: QDF_STATUS_SUCCESS - in case of success
232  */
233 QDF_STATUS wlan_crypto_wpaie_check(struct wlan_crypto_params *, uint8_t *frm);
234 
235 /**
236  * wlan_crypto_rsnie_check - called by mlme to check the rsnie
237  *
238  * @crypto params: crypto params
239  * @iebuf: ie buffer
240  *
241  * This function gets called by mlme to check the contents of rsn is
242  * matching with given crypto params
243  *
244  * Return: QDF_STATUS_SUCCESS - in case of success
245  */
246 QDF_STATUS wlan_crypto_rsnie_check(struct wlan_crypto_params *, uint8_t *frm);
247 /**
248  * wlan_crypto_build_wpaie - called by mlme to build wpaie
249  *
250  * @crypto params: crypto params
251  * @iebuf: ie buffer
252  *
253  * This function gets called by mlme to build wpaie from given crypto params
254  *
255  * Return: end of buffer
256  */
257 uint8_t *wlan_crypto_build_wpaie(struct wlan_crypto_params *,
258 					uint8_t *iebuf);
259 /**
260  * wlan_crypto_build_rsnie - called by mlme to build rsnie
261  *
262  * @crypto params: crypto params
263  * @iebuf: ie buffer
264  *
265  * This function gets called by mlme to build rsnie from given crypto params
266  *
267  * Return: end of buffer
268  */
269 uint8_t *wlan_crypto_build_rsnie(struct wlan_crypto_params *,
270 					uint8_t *iebuf);
271 
272 /**
273  * wlan_crypto_rsn_info - check is given params matching with vdev params.
274  *
275  * @vdev: vdev
276  * @crypto params: crypto params
277  *
278  * This function gets called by mlme to check is given params matching with
279  * vdev params.
280  *
281  * Return: true success or false for failure.
282  */
283 bool wlan_crypto_rsn_info(struct wlan_objmgr_vdev *vdev,
284 				struct wlan_crypto_params *crypto_params);
285 /**
286  * wlan_crypto_pn_check - called by data patch for PN check
287  *
288  * @vdev: vdev
289  * @wbuf: wbuf
290  *
291  * This function gets called by data patch for PN check
292  *
293  * Return: QDF_STATUS
294  */
295 QDF_STATUS wlan_crypto_pn_check(struct wlan_objmgr_vdev *vdev,
296 					qdf_nbuf_t wbuf);
297 /**
298  * wlan_crypto_vdev_get_crypto_params - called by mlme to get crypto params
299  *
300  * @vdev:vdev
301  *
302  * This function gets called by mlme to get crypto params
303  *
304  * Return: wlan_crypto_params or NULL in case of failure
305  */
306 struct wlan_crypto_params *wlan_crypto_vdev_get_crypto_params(
307 						struct wlan_objmgr_vdev *vdev);
308 /**
309  * wlan_crypto_peer_get_crypto_params - called by mlme to get crypto params
310  *
311  * @peer:peer
312  *
313  * This function gets called by mlme to get crypto params
314  *
315  * Return: wlan_crypto_params or NULL in case of failure
316  */
317 struct wlan_crypto_params *wlan_crypto_peer_get_crypto_params(
318 						struct wlan_objmgr_peer *peer);
319 
320 /**
321  * wlan_crypto_set_peer_wep_keys - set wep keys into peer entries
322  *
323  * @peer:peer
324  *
325  * This function gets called by mlme, when auth frame is received.
326  * this helps in setting wep keys into peer data structure.
327  *
328  * Return: QDF_STATUS
329  */
330 QDF_STATUS wlan_crypto_set_peer_wep_keys(struct wlan_objmgr_vdev *vdev,
331 						uint8_t *mac_addr);
332 
333 /**
334  * wlan_crypto_register_crypto_rx_ops - set crypto_rx_ops
335  *
336  * @crypto_rx_ops: crypto_rx_ops
337  *
338  * This function gets called by object manger to register crypto rx ops.
339  *
340  * Return: QDF_STATUS
341  */
342 QDF_STATUS wlan_crypto_register_crypto_rx_ops(
343 			struct wlan_lmac_if_crypto_rx_ops *crypto_rx_ops);
344 
345 /**
346  * wlan_crypto_get_crypto_rx_ops - get crypto_rx_ops from psoc
347  *
348  * @psoc: psoc
349  *
350  * This function gets called by umac to get the crypto_rx_ops
351  *
352  * Return: crypto_rx_ops
353  */
354 struct wlan_lmac_if_crypto_rx_ops *wlan_crypto_get_crypto_rx_ops(
355 			struct wlan_objmgr_psoc *psoc);
356 #endif /* end of _WLAN_CRYPTO_GLOBAL_API_H_ */
357