This function is called from an interrupt handler */
| 247 | |
| 248 | /* This function is called from an interrupt handler */ |
| 249 | void |
| 250 | nlm_xlpsec_msgring_handler(int vc, int size, int code, int src_id, |
| 251 | struct nlm_fmn_msg *msg, void *data) |
| 252 | { |
| 253 | struct xlp_sec_command *cmd = NULL; |
| 254 | struct xlp_sec_softc *sc = NULL; |
| 255 | uint8_t hash[HASH_MAX_LEN]; |
| 256 | |
| 257 | KASSERT(code == FMN_SWCODE_CRYPTO, |
| 258 | ("%s: bad code = %d, expected code = %d\n", __FUNCTION__, |
| 259 | code, FMN_SWCODE_CRYPTO)); |
| 260 | |
| 261 | sc = (struct xlp_sec_softc *)data; |
| 262 | KASSERT(src_id >= sc->sec_vc_start && src_id <= sc->sec_vc_end, |
| 263 | ("%s: bad src_id = %d, expect %d - %d\n", __FUNCTION__, |
| 264 | src_id, sc->sec_vc_start, sc->sec_vc_end)); |
| 265 | |
| 266 | cmd = (struct xlp_sec_command *)(uintptr_t)msg->msg[0]; |
| 267 | KASSERT(cmd != NULL && cmd->crp != NULL, |
| 268 | ("%s :cmd not received properly\n",__FUNCTION__)); |
| 269 | |
| 270 | KASSERT(CRYPTO_ERROR(msg->msg[1]) == 0, |
| 271 | ("%s: Message rcv msg0 %llx msg1 %llx err %x \n", __FUNCTION__, |
| 272 | (unsigned long long)msg->msg[0], (unsigned long long)msg->msg[1], |
| 273 | (int)CRYPTO_ERROR(msg->msg[1]))); |
| 274 | |
| 275 | /* If there are not enough credits to send, then send request |
| 276 | * will fail with ERESTART and the driver will be blocked until it is |
| 277 | * unblocked here after knowing that there are sufficient credits to |
| 278 | * send the request again. |
| 279 | */ |
| 280 | if (sc->sc_needwakeup) { |
| 281 | atomic_add_int(&creditleft, sc->sec_msgsz); |
| 282 | if (creditleft >= (NLM_CRYPTO_LEFT_REQS)) { |
| 283 | crypto_unblock(sc->sc_cid, sc->sc_needwakeup); |
| 284 | sc->sc_needwakeup &= (~(CRYPTO_SYMQ | CRYPTO_ASYMQ)); |
| 285 | } |
| 286 | } |
| 287 | if (cmd->hash_dst_len != 0) { |
| 288 | if (cmd->crp->crp_op & CRYPTO_OP_VERIFY_DIGEST) { |
| 289 | crypto_copydata(cmd->crp, cmd->crp->crp_digest_start, |
| 290 | cmd->hash_dst_len, hash); |
| 291 | if (timingsafe_bcmp(cmd->hashdest, hash, |
| 292 | cmd->hash_dst_len) != 0) |
| 293 | cmd->crp->crp_etype = EBADMSG; |
| 294 | } else |
| 295 | crypto_copyback(cmd->crp, cmd->crp->crp_digest_start, |
| 296 | cmd->hash_dst_len, cmd->hashdest); |
| 297 | } |
| 298 | |
| 299 | /* This indicates completion of the crypto operation */ |
| 300 | crypto_done(cmd->crp); |
| 301 | |
| 302 | xlp_free_cmd_params(cmd); |
| 303 | |
| 304 | return; |
| 305 | } |
| 306 |
nothing calls this directly
no test coverage detected