1 /* 2 * Copyright (c) 2017-2018 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_vdev_param - called by ucfg to set crypto param 28 * @vdev: vdev 29 * @param: param to be set. 30 * @value: value 31 * 32 * This function gets called from ucfg to set param 33 * 34 * Return: QDF_STATUS_SUCCESS - in case of success 35 */ 36 QDF_STATUS wlan_crypto_set_vdev_param(struct wlan_objmgr_vdev *vdev, 37 wlan_crypto_param_type param, 38 uint32_t value); 39 40 /** 41 * wlan_crypto_set_peer_param - called by ucfg to set crypto param 42 * 43 * @peer: peer 44 * @param: param to be set. 45 * @value: value 46 * 47 * This function gets called from ucfg to set param 48 * 49 * Return: QDF_STATUS_SUCCESS - in case of success 50 */ 51 QDF_STATUS wlan_crypto_set_peer_param(struct wlan_objmgr_peer *peer, 52 wlan_crypto_param_type param, 53 uint32_t value); 54 55 /** 56 * wlan_crypto_get_param - called by ucfg to get crypto param 57 * @vdev: vdev 58 * @param: param to be get. 59 * 60 * This function gets called from ucfg to get param 61 * 62 * Return: value or -1 for failure 63 */ 64 int32_t wlan_crypto_get_param(struct wlan_objmgr_vdev *vdev, 65 wlan_crypto_param_type param); 66 /** 67 * wlan_crypto_get_peer_param - called by ucfg to get crypto peer param 68 * @peer: peer 69 * @param: param to be get. 70 * 71 * This function gets called from ucfg to get peer param 72 * 73 * Return: value or -1 for failure 74 */ 75 int32_t wlan_crypto_get_peer_param(struct wlan_objmgr_peer *peer, 76 wlan_crypto_param_type param); 77 78 /** 79 * wlan_crypto_is_htallowed - called by ucfg to check if HT rates is allowed 80 * @vdev: Vdev 81 * @peer: Peer 82 * 83 * This function is called to check if HT rates is allowed 84 * 85 * Return: 0 for not allowed and +ve for allowed 86 */ 87 uint8_t wlan_crypto_is_htallowed(struct wlan_objmgr_vdev *vdev, 88 struct wlan_objmgr_peer *peer); 89 /** 90 * wlan_crypto_setkey - called by ucfg to setkey 91 * @vdev: vdev 92 * @req_key: req_key with cipher type, key macaddress 93 * 94 * This function gets called from ucfg to sey key 95 * 96 * Return: QDF_STATUS_SUCCESS - in case of success 97 */ 98 QDF_STATUS wlan_crypto_setkey(struct wlan_objmgr_vdev *vdev, 99 struct wlan_crypto_req_key *req_key); 100 101 /** 102 * wlan_crypto_getkey - called by ucfg to get key 103 * @vdev: vdev 104 * @req_key: key value will be copied in this req_key 105 * @mac_address: mac address of the peer for unicast key 106 * or broadcast address if group key is requested. 107 * 108 * This function gets called from ucfg to get key 109 * 110 * Return: QDF_STATUS_SUCCESS - in case of success 111 */ 112 QDF_STATUS wlan_crypto_getkey(struct wlan_objmgr_vdev *vdev, 113 struct wlan_crypto_req_key *req_key, 114 uint8_t *mac_addr); 115 116 /** 117 * wlan_crypto_delkey - called by ucfg to delete key 118 * @vdev: vdev 119 * @mac_address: mac address of the peer for unicast key 120 * or broadcast address if group key is deleted. 121 * @key_idx: key index to be deleted 122 * 123 * This function gets called from ucfg to delete key 124 * 125 * Return: QDF_STATUS_SUCCESS - in case of success 126 */ 127 QDF_STATUS wlan_crypto_delkey(struct wlan_objmgr_vdev *vdev, 128 uint8_t *macaddr, 129 uint8_t key_idx); 130 131 /** 132 * wlan_crypto_default_key - called by ucfg to set default tx key 133 * @vdev: vdev 134 * @mac_address: mac address of the peer for unicast key 135 * or broadcast address if group key need to made default. 136 * @key_idx: key index to be made as default key 137 * @unicast: is key was unicast or group key. 138 * 139 * This function gets called from ucfg to set default key 140 * 141 * Return: QDF_STATUS_SUCCESS - in case of success 142 */ 143 QDF_STATUS wlan_crypto_default_key(struct wlan_objmgr_vdev *vdev, 144 uint8_t *macaddr, 145 uint8_t key_idx, 146 bool unicast); 147 148 /** 149 * wlan_crypto_encap - called by mgmt for encap the frame based on cipher 150 * @vdev: vdev 151 * @wbuf: wbuf 152 * @macaddr: macaddr 153 * @encapdone: is encapdone already or not. 154 * 155 * This function gets called from mgmt txrx to encap frame. 156 * 157 * Return: QDF_STATUS_SUCCESS - in case of success 158 */ 159 QDF_STATUS wlan_crypto_encap(struct wlan_objmgr_vdev *vdev, 160 qdf_nbuf_t wbuf, 161 uint8_t *macaddr, 162 uint8_t encapdone); 163 164 /** 165 * wlan_crypto_decap - called by mgmt for decap the frame based on cipher 166 * @vdev: vdev 167 * @wbuf: wbuf 168 * @macaddr: macaddr 169 * @tid: tid of the packet. 170 * 171 * This function gets called from mgmt txrx to decap frame. 172 * 173 * Return: QDF_STATUS_SUCCESS - in case of success 174 */ 175 QDF_STATUS wlan_crypto_decap(struct wlan_objmgr_vdev *vdev, 176 qdf_nbuf_t wbuf, 177 uint8_t *macaddr, 178 uint8_t tid); 179 180 /** 181 * wlan_crypto_enmic - called by mgmt for adding mic in frame based on cipher 182 * @vdev: vdev 183 * @wbuf: wbuf 184 * @macaddr: macaddr 185 * @encapdone: is encapdone already or not. 186 * 187 * This function gets called from mgmt txrx to adding mic to the frame. 188 * 189 * Return: QDF_STATUS_SUCCESS - in case of success 190 */ 191 QDF_STATUS wlan_crypto_enmic(struct wlan_objmgr_vdev *vdev, 192 qdf_nbuf_t wbuf, 193 uint8_t *macaddr, 194 uint8_t encapdone); 195 196 /** 197 * wlan_crypto_demic - called by mgmt for remove and check mic for 198 * the frame based on cipher 199 * @vdev: vdev 200 * @wbuf: wbuf 201 * @macaddr: macaddr 202 * @tid: tid of the frame 203 * 204 * This function gets called from mgmt txrx to decap frame. 205 * 206 * Return: QDF_STATUS_SUCCESS - in case of success 207 */ 208 QDF_STATUS wlan_crypto_demic(struct wlan_objmgr_vdev *vdev, 209 qdf_nbuf_t wbuf, 210 uint8_t *macaddr, 211 uint8_t tid); 212 213 /** 214 * wlan_crypto_vdev_is_pmf_enabled - called to check is pmf enabled in vdev 215 * @vdev: vdev 216 * 217 * This function gets called to check is pmf enabled or not in vdev. 218 * 219 * Return: true or false 220 */ 221 bool wlan_crypto_vdev_is_pmf_enabled(struct wlan_objmgr_vdev *vdev); 222 223 /** 224 * wlan_crypto_is_pmf_enabled - called by mgmt txrx to check is pmf enabled 225 * @vdev: vdev 226 * @peer: peer 227 * 228 * This function gets called by mgmt txrx to check is pmf enabled or not. 229 * 230 * Return: true or false 231 */ 232 bool wlan_crypto_is_pmf_enabled(struct wlan_objmgr_vdev *vdev, 233 struct wlan_objmgr_peer *peer); 234 235 /** 236 * wlan_crypto_add_mmie - called by mgmt txrx to add mmie in frame 237 * @vdev: vdev 238 * @frm: frame starting pointer 239 * @len: length of the frame 240 * 241 * This function gets called by mgmt txrx to add mmie in frame 242 * 243 * Return: end of frame or NULL in case failure 244 */ 245 uint8_t *wlan_crypto_add_mmie(struct wlan_objmgr_vdev *vdev, 246 uint8_t *frm, 247 uint32_t len); 248 249 /** 250 * wlan_crypto_is_mmie_valid - called by mgmt txrx to check mmie of the frame 251 * @vdev: vdev 252 * @frm: frame starting pointer 253 * @efrm: end of frame pointer 254 * 255 * This function gets called by mgmt txrx to check mmie of the frame 256 * 257 * Return: true or false 258 */ 259 bool wlan_crypto_is_mmie_valid(struct wlan_objmgr_vdev *vdev, 260 uint8_t *frm, 261 uint8_t *efrm); 262 263 /** 264 * wlan_crypto_wpaie_check - called by mlme to check the wpaie 265 * @crypto params: crypto params 266 * @iebuf: ie buffer 267 * 268 * This function gets called by mlme to check the contents of wpa is 269 * matching with given crypto params 270 * 271 * Return: QDF_STATUS_SUCCESS - in case of success 272 */ 273 QDF_STATUS wlan_crypto_wpaie_check(struct wlan_crypto_params *, uint8_t *frm); 274 275 /** 276 * wlan_crypto_rsnie_check - called by mlme to check the rsnie 277 * @crypto params: crypto params 278 * @iebuf: ie buffer 279 * 280 * This function gets called by mlme to check the contents of rsn is 281 * matching with given crypto params 282 * 283 * Return: QDF_STATUS_SUCCESS - in case of success 284 */ 285 QDF_STATUS wlan_crypto_rsnie_check(struct wlan_crypto_params *, uint8_t *frm); 286 /** 287 * wlan_crypto_build_wpaie - called by mlme to build wpaie 288 * @vdev: vdev 289 * @iebuf: ie buffer 290 * 291 * This function gets called by mlme to build wpaie from given vdev 292 * 293 * Return: end of buffer 294 */ 295 uint8_t *wlan_crypto_build_wpaie(struct wlan_objmgr_vdev *vdev, 296 uint8_t *iebuf); 297 /** 298 * wlan_crypto_build_rsnie - called by mlme to build rsnie 299 * @vdev: vdev 300 * @iebuf: ie buffer 301 * 302 * This function gets called by mlme to build rsnie from given vdev 303 * 304 * Return: end of buffer 305 */ 306 uint8_t *wlan_crypto_build_rsnie(struct wlan_objmgr_vdev *vdev, 307 uint8_t *iebuf); 308 309 /** 310 * wlan_crypto_wapiie_check - called by mlme to check the wapiie 311 * @crypto params: crypto params 312 * @iebuf: ie buffer 313 * 314 * This function gets called by mlme to check the contents of wapi is 315 * matching with given crypto params 316 * 317 * Return: QDF_STATUS_SUCCESS - in case of success 318 */ 319 QDF_STATUS wlan_crypto_wapiie_check(struct wlan_crypto_params *crypto_params, 320 uint8_t *frm); 321 322 /** 323 * wlan_crypto_build_wapiie - called by mlme to build wapi ie 324 * @vdev: vdev 325 * @iebuf: ie buffer 326 * 327 * This function gets called by mlme to build wapi ie from given vdev 328 * 329 * Return: end of buffer 330 */ 331 uint8_t *wlan_crypto_build_wapiie(struct wlan_objmgr_vdev *vdev, 332 uint8_t *iebuf); 333 /** 334 * wlan_crypto_rsn_info - check is given params matching with vdev params. 335 * @vdev: vdev 336 * @crypto params: crypto params 337 * 338 * This function gets called by mlme to check is given params matching with 339 * vdev params. 340 * 341 * Return: true success or false for failure. 342 */ 343 bool wlan_crypto_rsn_info(struct wlan_objmgr_vdev *vdev, 344 struct wlan_crypto_params *crypto_params); 345 /** 346 * wlan_crypto_pn_check - called by data patch for PN check 347 * @vdev: vdev 348 * @wbuf: wbuf 349 * 350 * This function gets called by data patch for PN check 351 * 352 * Return: QDF_STATUS 353 */ 354 QDF_STATUS wlan_crypto_pn_check(struct wlan_objmgr_vdev *vdev, 355 qdf_nbuf_t wbuf); 356 /** 357 * wlan_crypto_vdev_get_crypto_params - called by mlme to get crypto params 358 * @vdev:vdev 359 * 360 * This function gets called by mlme to get crypto params 361 * 362 * Return: wlan_crypto_params or NULL in case of failure 363 */ 364 struct wlan_crypto_params *wlan_crypto_vdev_get_crypto_params( 365 struct wlan_objmgr_vdev *vdev); 366 /** 367 * wlan_crypto_peer_get_crypto_params - called by mlme to get crypto params 368 * @peer:peer 369 * 370 * This function gets called by mlme to get crypto params 371 * 372 * Return: wlan_crypto_params or NULL in case of failure 373 */ 374 struct wlan_crypto_params *wlan_crypto_peer_get_crypto_params( 375 struct wlan_objmgr_peer *peer); 376 377 /** 378 * wlan_crypto_set_peer_wep_keys - set wep keys into peer entries 379 * @vdev:vdev 380 * @peer:peer 381 * 382 * This function gets called by mlme, when auth frame is received. 383 * this helps in setting wep keys into peer data structure. 384 * 385 * Return: QDF_STATUS 386 */ 387 QDF_STATUS wlan_crypto_set_peer_wep_keys(struct wlan_objmgr_vdev *vdev, 388 struct wlan_objmgr_peer *peer); 389 390 /** 391 * wlan_crypto_register_crypto_rx_ops - set crypto_rx_ops 392 * @crypto_rx_ops: crypto_rx_ops 393 * 394 * This function gets called by object manger to register crypto rx ops. 395 * 396 * Return: QDF_STATUS 397 */ 398 QDF_STATUS wlan_crypto_register_crypto_rx_ops( 399 struct wlan_lmac_if_crypto_rx_ops *crypto_rx_ops); 400 401 /** 402 * wlan_crypto_get_crypto_rx_ops - get crypto_rx_ops from psoc 403 * @psoc: psoc 404 * 405 * This function gets called by umac to get the crypto_rx_ops 406 * 407 * Return: crypto_rx_ops 408 */ 409 struct wlan_lmac_if_crypto_rx_ops *wlan_crypto_get_crypto_rx_ops( 410 struct wlan_objmgr_psoc *psoc); 411 /** 412 * wlan_crypto_vdev_has_auth_mode - check authmode for vdev 413 * @vdev: vdev 414 * @authvalue: authvalue to be checked 415 * 416 * This function check is authvalue passed is set in vdev or not 417 * 418 * Return: true or false 419 */ 420 bool wlan_crypto_vdev_has_auth_mode(struct wlan_objmgr_vdev *vdev, 421 wlan_crypto_auth_mode authmode); 422 423 /** 424 * wlan_crypto_peer_has_auth_mode - check authmode for peer 425 * @peer: peer 426 * @authvalue: authvalue to be checked 427 * 428 * This function check is authvalue passed is set in peer or not 429 * 430 * Return: true or false 431 */ 432 bool wlan_crypto_peer_has_auth_mode(struct wlan_objmgr_peer *peer, 433 wlan_crypto_auth_mode authvalue); 434 435 /** 436 * wlan_crypto_vdev_has_ucastcipher - check ucastcipher for vdev 437 * @vdev: vdev 438 * @ucastcipher: ucastcipher to be checked 439 * 440 * This function check is ucastcipher passed is set in vdev or not 441 * 442 * Return: true or false 443 */ 444 bool wlan_crypto_vdev_has_ucastcipher(struct wlan_objmgr_vdev *vdev, 445 wlan_crypto_cipher_type ucastcipher); 446 447 /** 448 * wlan_crypto_peer_has_ucastcipher - check ucastcipher for peer 449 * @peer: peer 450 * @ucastcipher: ucastcipher to be checked 451 * 452 * This function check is ucastcipher passed is set in peer or not 453 * 454 * Return: true or false 455 */ 456 bool wlan_crypto_peer_has_ucastcipher(struct wlan_objmgr_peer *peer, 457 wlan_crypto_cipher_type ucastcipher); 458 459 460 /** 461 * wlan_crypto_vdev_has_mcastcipher - check mcastcipher for vdev 462 * @vdev: vdev 463 * @mcastcipher: mcastcipher to be checked 464 * 465 * This function check is mcastcipher passed is set in vdev or not 466 * 467 * Return: true or false 468 */ 469 bool wlan_crypto_vdev_has_mcastcipher(struct wlan_objmgr_vdev *vdev, 470 wlan_crypto_cipher_type mcastcipher); 471 472 /** 473 * wlan_crypto_peer_has_mcastcipher - check mcastcipher for peer 474 * @peer: peer 475 * @mcastcipher: mcastcipher to be checked 476 * 477 * This function check is mcastcipher passed is set in peer or not 478 * 479 * Return: true or false 480 */ 481 bool wlan_crypto_peer_has_mcastcipher(struct wlan_objmgr_peer *peer, 482 wlan_crypto_cipher_type mcastcipher); 483 484 /** 485 * wlan_crypto_vdev_getkey - get key from vdev 486 * @vdev: vdev 487 * @keyix: keyix 488 * 489 * This function gets key from vdev 490 * 491 * Return: key or NULL 492 */ 493 struct wlan_crypto_key *wlan_crypto_vdev_getkey(struct wlan_objmgr_vdev *vdev, 494 uint16_t keyix); 495 /** 496 * wlan_crypto_peer_getkey - get key from peer 497 * @peer: peer 498 * @keyix: keyix 499 * 500 * This function gets key from peer 501 * 502 * Return: key or NULL 503 */ 504 struct wlan_crypto_key *wlan_crypto_peer_getkey(struct wlan_objmgr_peer *peer, 505 uint16_t keyix); 506 /** 507 * wlan_crypto_get_peer_fils_aead - Get peer fils aead set flag 508 * @peer: Peer object 509 * 510 * This function returns the peer fils aead set flag value. 511 * 512 * Return: 1 for enabled, 0 for disabled 513 */ 514 uint8_t wlan_crypto_get_peer_fils_aead(struct wlan_objmgr_peer *peer); 515 516 /** 517 * wlan_crypto_set_peer_fils_aead - Set peer fils aead set flag 518 * @peer: Peer object 519 * @value: Value to set the flag 520 * 521 * This function set the peer fils aead set flag once FILS AUTH received. 522 * 523 * Return: None 524 */ 525 void wlan_crypto_set_peer_fils_aead( 526 struct wlan_objmgr_peer *peer, uint8_t value); 527 #endif /* end of _WLAN_CRYPTO_GLOBAL_API_H_ */ 528