Lines Matching full:req
34 static u8 nvmet_auth_negotiate(struct nvmet_req *req, void *d) in nvmet_auth_negotiate() argument
36 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_negotiate()
41 __func__, ctrl->cntlid, req->sq->qid, in nvmet_auth_negotiate()
45 req->sq->dhchap_tid = le16_to_cpu(data->t_id); in nvmet_auth_negotiate()
50 if (req->sq->qid) in nvmet_auth_negotiate()
54 if (nvmet_queue_tls_keyid(req->sq)) in nvmet_auth_negotiate()
58 if (!nvmet_queue_tls_keyid(req->sq)) in nvmet_auth_negotiate()
88 __func__, ctrl->cntlid, req->sq->qid); in nvmet_auth_negotiate()
92 __func__, ctrl->cntlid, req->sq->qid, in nvmet_auth_negotiate()
116 __func__, ctrl->cntlid, req->sq->qid); in nvmet_auth_negotiate()
120 __func__, ctrl->cntlid, req->sq->qid, in nvmet_auth_negotiate()
127 ctrl->cntlid, req->sq->qid); in nvmet_auth_negotiate()
131 __func__, ctrl->cntlid, req->sq->qid, in nvmet_auth_negotiate()
136 static u8 nvmet_auth_reply(struct nvmet_req *req, void *d) in nvmet_auth_reply() argument
138 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_reply()
144 __func__, ctrl->cntlid, req->sq->qid, in nvmet_auth_reply()
150 if (nvmet_auth_ctrl_sesskey(req, data->rval + 2 * data->hl, in nvmet_auth_reply()
161 ctrl->cntlid, req->sq->qid); in nvmet_auth_reply()
165 if (nvmet_auth_host_hash(req, response, data->hl) < 0) { in nvmet_auth_reply()
167 ctrl->cntlid, req->sq->qid); in nvmet_auth_reply()
174 ctrl->cntlid, req->sq->qid); in nvmet_auth_reply()
176 ctrl->cntlid, req->sq->qid, data->hl, data->rval); in nvmet_auth_reply()
178 ctrl->cntlid, req->sq->qid, data->hl, response); in nvmet_auth_reply()
184 __func__, ctrl->cntlid, req->sq->qid); in nvmet_auth_reply()
187 __func__, ctrl->cntlid, req->sq->qid); in nvmet_auth_reply()
190 req->sq->dhchap_s2 = le32_to_cpu(data->seqnum); in nvmet_auth_reply()
192 req->sq->dhchap_c2 = kmemdup(data->rval + data->hl, data->hl, in nvmet_auth_reply()
194 if (!req->sq->dhchap_c2) in nvmet_auth_reply()
198 __func__, ctrl->cntlid, req->sq->qid, data->hl, in nvmet_auth_reply()
199 req->sq->dhchap_c2); in nvmet_auth_reply()
209 if (req->sq->dhchap_s2 == 0) { in nvmet_auth_reply()
211 nvmet_auth_insert_psk(req->sq); in nvmet_auth_reply()
212 req->sq->authenticated = true; in nvmet_auth_reply()
213 kfree(req->sq->dhchap_c2); in nvmet_auth_reply()
214 req->sq->dhchap_c2 = NULL; in nvmet_auth_reply()
216 req->sq->authenticated = true; in nvmet_auth_reply()
228 u32 nvmet_auth_send_data_len(struct nvmet_req *req) in nvmet_auth_send_data_len() argument
230 return le32_to_cpu(req->cmd->auth_send.tl); in nvmet_auth_send_data_len()
233 void nvmet_execute_auth_send(struct nvmet_req *req) in nvmet_execute_auth_send() argument
235 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_auth_send()
242 if (req->cmd->auth_send.secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER) { in nvmet_execute_auth_send()
244 req->error_loc = in nvmet_execute_auth_send()
248 if (req->cmd->auth_send.spsp0 != 0x01) { in nvmet_execute_auth_send()
250 req->error_loc = in nvmet_execute_auth_send()
254 if (req->cmd->auth_send.spsp1 != 0x01) { in nvmet_execute_auth_send()
256 req->error_loc = in nvmet_execute_auth_send()
260 tl = nvmet_auth_send_data_len(req); in nvmet_execute_auth_send()
263 req->error_loc = in nvmet_execute_auth_send()
267 if (!nvmet_check_transfer_len(req, tl)) { in nvmet_execute_auth_send()
278 status = nvmet_copy_from_sgl(req, 0, d, tl); in nvmet_execute_auth_send()
284 ctrl->cntlid, req->sq->qid, data->auth_type, data->auth_id, in nvmet_execute_auth_send()
285 req->sq->dhchap_step); in nvmet_execute_auth_send()
293 __func__, ctrl->cntlid, req->sq->qid); in nvmet_execute_auth_send()
294 if (!req->sq->qid) { in nvmet_execute_auth_send()
295 dhchap_status = nvmet_setup_auth(ctrl, req->sq); in nvmet_execute_auth_send()
299 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
300 req->sq->dhchap_step = in nvmet_execute_auth_send()
305 req->sq->dhchap_step = in nvmet_execute_auth_send()
307 } else if (data->auth_id != req->sq->dhchap_step) in nvmet_execute_auth_send()
310 dhchap_status = nvmet_auth_negotiate(req, d); in nvmet_execute_auth_send()
312 req->sq->dhchap_step = in nvmet_execute_auth_send()
315 req->sq->dhchap_step = in nvmet_execute_auth_send()
317 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
321 if (data->auth_id != req->sq->dhchap_step) { in nvmet_execute_auth_send()
323 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
324 data->auth_id, req->sq->dhchap_step); in nvmet_execute_auth_send()
327 if (le16_to_cpu(data->t_id) != req->sq->dhchap_tid) { in nvmet_execute_auth_send()
329 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
331 req->sq->dhchap_tid); in nvmet_execute_auth_send()
332 req->sq->dhchap_step = in nvmet_execute_auth_send()
334 req->sq->dhchap_status = in nvmet_execute_auth_send()
341 dhchap_status = nvmet_auth_reply(req, d); in nvmet_execute_auth_send()
343 req->sq->dhchap_step = in nvmet_execute_auth_send()
346 req->sq->dhchap_step = in nvmet_execute_auth_send()
348 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
353 nvmet_auth_insert_psk(req->sq); in nvmet_execute_auth_send()
354 req->sq->authenticated = true; in nvmet_execute_auth_send()
356 __func__, ctrl->cntlid, req->sq->qid); in nvmet_execute_auth_send()
362 ctrl->cntlid, req->sq->qid, dhchap_status); in nvmet_execute_auth_send()
363 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
364 req->sq->authenticated = false; in nvmet_execute_auth_send()
368 req->sq->dhchap_status = in nvmet_execute_auth_send()
370 req->sq->dhchap_step = in nvmet_execute_auth_send()
372 req->sq->authenticated = false; in nvmet_execute_auth_send()
376 req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_MESSAGE; in nvmet_execute_auth_send()
377 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_FAILURE2; in nvmet_execute_auth_send()
383 ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
384 req->sq->dhchap_status, req->sq->dhchap_step); in nvmet_execute_auth_send()
387 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
388 status, req->error_loc); in nvmet_execute_auth_send()
389 if (req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 && in nvmet_execute_auth_send()
390 req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) { in nvmet_execute_auth_send()
393 mod_delayed_work(system_wq, &req->sq->auth_expired_work, in nvmet_execute_auth_send()
398 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_send()
399 if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) in nvmet_execute_auth_send()
403 nvmet_req_complete(req, status); in nvmet_execute_auth_send()
406 static int nvmet_auth_challenge(struct nvmet_req *req, void *d, int al) in nvmet_auth_challenge() argument
409 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_challenge()
422 req->sq->dhchap_s1 = nvme_auth_get_seqnum(); in nvmet_auth_challenge()
425 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_challenge()
428 data->seqnum = cpu_to_le32(req->sq->dhchap_s1); in nvmet_auth_challenge()
429 req->sq->dhchap_c1 = kmalloc(data->hl, GFP_KERNEL); in nvmet_auth_challenge()
430 if (!req->sq->dhchap_c1) in nvmet_auth_challenge()
432 get_random_bytes(req->sq->dhchap_c1, data->hl); in nvmet_auth_challenge()
433 memcpy(data->cval, req->sq->dhchap_c1, data->hl); in nvmet_auth_challenge()
437 ret = nvmet_auth_ctrl_exponential(req, data->cval + data->hl, in nvmet_auth_challenge()
441 __func__, ctrl->cntlid, req->sq->qid, req->sq->dhchap_s1, in nvmet_auth_challenge()
442 req->sq->dhchap_tid, data->hl, ctrl->dh_keysize); in nvmet_auth_challenge()
446 static int nvmet_auth_success1(struct nvmet_req *req, void *d, int al) in nvmet_auth_success1() argument
449 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_success1()
456 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_success1()
458 if (req->sq->dhchap_c2) { in nvmet_auth_success1()
461 ctrl->cntlid, req->sq->qid); in nvmet_auth_success1()
464 if (nvmet_auth_ctrl_hash(req, data->rval, data->hl)) in nvmet_auth_success1()
468 ctrl->cntlid, req->sq->qid, data->hl, data->rval); in nvmet_auth_success1()
473 static void nvmet_auth_failure1(struct nvmet_req *req, void *d, int al) in nvmet_auth_failure1() argument
480 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_failure1()
482 data->rescode_exp = req->sq->dhchap_status; in nvmet_auth_failure1()
485 u32 nvmet_auth_receive_data_len(struct nvmet_req *req) in nvmet_auth_receive_data_len() argument
487 return le32_to_cpu(req->cmd->auth_receive.al); in nvmet_auth_receive_data_len()
490 void nvmet_execute_auth_receive(struct nvmet_req *req) in nvmet_execute_auth_receive() argument
492 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_auth_receive()
497 if (req->cmd->auth_receive.secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER) { in nvmet_execute_auth_receive()
499 req->error_loc = in nvmet_execute_auth_receive()
503 if (req->cmd->auth_receive.spsp0 != 0x01) { in nvmet_execute_auth_receive()
505 req->error_loc = in nvmet_execute_auth_receive()
509 if (req->cmd->auth_receive.spsp1 != 0x01) { in nvmet_execute_auth_receive()
511 req->error_loc = in nvmet_execute_auth_receive()
515 al = nvmet_auth_receive_data_len(req); in nvmet_execute_auth_receive()
518 req->error_loc = in nvmet_execute_auth_receive()
522 if (!nvmet_check_transfer_len(req, al)) { in nvmet_execute_auth_receive()
533 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step); in nvmet_execute_auth_receive()
534 switch (req->sq->dhchap_step) { in nvmet_execute_auth_receive()
536 if (nvmet_auth_challenge(req, d, al) < 0) { in nvmet_execute_auth_receive()
538 ctrl->cntlid, req->sq->qid, status); in nvmet_execute_auth_receive()
542 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_REPLY; in nvmet_execute_auth_receive()
545 status = nvmet_auth_success1(req, d, al); in nvmet_execute_auth_receive()
547 req->sq->dhchap_status = status; in nvmet_execute_auth_receive()
548 req->sq->authenticated = false; in nvmet_execute_auth_receive()
549 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
551 ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_receive()
552 req->sq->dhchap_status); in nvmet_execute_auth_receive()
555 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2; in nvmet_execute_auth_receive()
558 req->sq->authenticated = false; in nvmet_execute_auth_receive()
559 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
561 ctrl->cntlid, req->sq->qid, req->sq->dhchap_status); in nvmet_execute_auth_receive()
565 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step); in nvmet_execute_auth_receive()
566 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; in nvmet_execute_auth_receive()
567 req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvmet_execute_auth_receive()
568 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
573 status = nvmet_copy_to_sgl(req, 0, d, al); in nvmet_execute_auth_receive()
576 if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2) in nvmet_execute_auth_receive()
577 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_receive()
578 else if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) { in nvmet_execute_auth_receive()
579 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_receive()
582 nvmet_req_complete(req, status); in nvmet_execute_auth_receive()