Lines Matching refs:req
34 static u16 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()
70 __func__, ctrl->cntlid, req->sq->qid); in nvmet_auth_negotiate()
74 __func__, ctrl->cntlid, req->sq->qid, in nvmet_auth_negotiate()
98 __func__, ctrl->cntlid, req->sq->qid); in nvmet_auth_negotiate()
102 __func__, ctrl->cntlid, req->sq->qid, in nvmet_auth_negotiate()
107 __func__, ctrl->cntlid, req->sq->qid, in nvmet_auth_negotiate()
112 static u16 nvmet_auth_reply(struct nvmet_req *req, void *d) in nvmet_auth_reply() argument
114 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_reply()
120 __func__, ctrl->cntlid, req->sq->qid, in nvmet_auth_reply()
126 if (nvmet_auth_ctrl_sesskey(req, data->rval + 2 * data->hl, in nvmet_auth_reply()
137 ctrl->cntlid, req->sq->qid); in nvmet_auth_reply()
141 if (nvmet_auth_host_hash(req, response, data->hl) < 0) { in nvmet_auth_reply()
143 ctrl->cntlid, req->sq->qid); in nvmet_auth_reply()
150 ctrl->cntlid, req->sq->qid); in nvmet_auth_reply()
156 __func__, ctrl->cntlid, req->sq->qid); in nvmet_auth_reply()
158 req->sq->dhchap_c2 = kmemdup(data->rval + data->hl, data->hl, in nvmet_auth_reply()
160 if (!req->sq->dhchap_c2) in nvmet_auth_reply()
164 __func__, ctrl->cntlid, req->sq->qid, data->hl, in nvmet_auth_reply()
165 req->sq->dhchap_c2); in nvmet_auth_reply()
166 req->sq->dhchap_s2 = le32_to_cpu(data->seqnum); in nvmet_auth_reply()
168 req->sq->authenticated = true; in nvmet_auth_reply()
169 req->sq->dhchap_c2 = NULL; in nvmet_auth_reply()
182 void nvmet_execute_auth_send(struct nvmet_req *req) in nvmet_execute_auth_send() argument
184 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_auth_send()
190 if (req->cmd->auth_send.secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER) { in nvmet_execute_auth_send()
192 req->error_loc = in nvmet_execute_auth_send()
196 if (req->cmd->auth_send.spsp0 != 0x01) { in nvmet_execute_auth_send()
198 req->error_loc = in nvmet_execute_auth_send()
202 if (req->cmd->auth_send.spsp1 != 0x01) { in nvmet_execute_auth_send()
204 req->error_loc = in nvmet_execute_auth_send()
208 tl = le32_to_cpu(req->cmd->auth_send.tl); in nvmet_execute_auth_send()
211 req->error_loc = in nvmet_execute_auth_send()
215 if (!nvmet_check_transfer_len(req, tl)) { in nvmet_execute_auth_send()
226 status = nvmet_copy_from_sgl(req, 0, d, tl); in nvmet_execute_auth_send()
232 ctrl->cntlid, req->sq->qid, data->auth_type, data->auth_id, in nvmet_execute_auth_send()
233 req->sq->dhchap_step); in nvmet_execute_auth_send()
241 ctrl->cntlid, req->sq->qid); in nvmet_execute_auth_send()
242 if (!req->sq->qid) { in nvmet_execute_auth_send()
251 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE; in nvmet_execute_auth_send()
252 } else if (data->auth_id != req->sq->dhchap_step) in nvmet_execute_auth_send()
255 status = nvmet_auth_negotiate(req, d); in nvmet_execute_auth_send()
257 req->sq->dhchap_step = in nvmet_execute_auth_send()
260 req->sq->dhchap_step = in nvmet_execute_auth_send()
262 req->sq->dhchap_status = status; in nvmet_execute_auth_send()
267 if (data->auth_id != req->sq->dhchap_step) { in nvmet_execute_auth_send()
269 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
270 data->auth_id, req->sq->dhchap_step); in nvmet_execute_auth_send()
273 if (le16_to_cpu(data->t_id) != req->sq->dhchap_tid) { in nvmet_execute_auth_send()
275 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
277 req->sq->dhchap_tid); in nvmet_execute_auth_send()
278 req->sq->dhchap_step = in nvmet_execute_auth_send()
280 req->sq->dhchap_status = in nvmet_execute_auth_send()
287 status = nvmet_auth_reply(req, d); in nvmet_execute_auth_send()
289 req->sq->dhchap_step = in nvmet_execute_auth_send()
292 req->sq->dhchap_step = in nvmet_execute_auth_send()
294 req->sq->dhchap_status = status; in nvmet_execute_auth_send()
300 req->sq->authenticated = true; in nvmet_execute_auth_send()
302 __func__, ctrl->cntlid, req->sq->qid); in nvmet_execute_auth_send()
309 ctrl->cntlid, req->sq->qid, status); in nvmet_execute_auth_send()
310 req->sq->dhchap_status = status; in nvmet_execute_auth_send()
311 req->sq->authenticated = false; in nvmet_execute_auth_send()
317 req->sq->dhchap_status = in nvmet_execute_auth_send()
319 req->sq->dhchap_step = in nvmet_execute_auth_send()
321 req->sq->authenticated = false; in nvmet_execute_auth_send()
326 req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_MESSAGE; in nvmet_execute_auth_send()
327 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_FAILURE2; in nvmet_execute_auth_send()
333 ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
334 req->sq->dhchap_status, req->sq->dhchap_step); in nvmet_execute_auth_send()
337 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
338 status, req->error_loc); in nvmet_execute_auth_send()
339 req->cqe->result.u64 = 0; in nvmet_execute_auth_send()
340 nvmet_req_complete(req, status); in nvmet_execute_auth_send()
341 if (req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 && in nvmet_execute_auth_send()
342 req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) { in nvmet_execute_auth_send()
345 mod_delayed_work(system_wq, &req->sq->auth_expired_work, in nvmet_execute_auth_send()
350 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_send()
351 if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) in nvmet_execute_auth_send()
355 static int nvmet_auth_challenge(struct nvmet_req *req, void *d, int al) in nvmet_auth_challenge() argument
358 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_challenge()
371 req->sq->dhchap_s1 = nvme_auth_get_seqnum(); in nvmet_auth_challenge()
374 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_challenge()
377 data->seqnum = cpu_to_le32(req->sq->dhchap_s1); in nvmet_auth_challenge()
378 req->sq->dhchap_c1 = kmalloc(data->hl, GFP_KERNEL); in nvmet_auth_challenge()
379 if (!req->sq->dhchap_c1) in nvmet_auth_challenge()
381 get_random_bytes(req->sq->dhchap_c1, data->hl); in nvmet_auth_challenge()
382 memcpy(data->cval, req->sq->dhchap_c1, data->hl); in nvmet_auth_challenge()
386 ret = nvmet_auth_ctrl_exponential(req, data->cval + data->hl, in nvmet_auth_challenge()
390 __func__, ctrl->cntlid, req->sq->qid, req->sq->dhchap_s1, in nvmet_auth_challenge()
391 req->sq->dhchap_tid, data->hl, ctrl->dh_keysize); in nvmet_auth_challenge()
395 static int nvmet_auth_success1(struct nvmet_req *req, void *d, int al) in nvmet_auth_success1() argument
398 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_success1()
405 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_success1()
407 if (req->sq->dhchap_c2) { in nvmet_auth_success1()
410 ctrl->cntlid, req->sq->qid); in nvmet_auth_success1()
413 if (nvmet_auth_ctrl_hash(req, data->rval, data->hl)) in nvmet_auth_success1()
417 ctrl->cntlid, req->sq->qid, data->hl, data->rval); in nvmet_auth_success1()
422 static void nvmet_auth_failure1(struct nvmet_req *req, void *d, int al) in nvmet_auth_failure1() argument
429 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_failure1()
431 data->rescode_exp = req->sq->dhchap_status; in nvmet_auth_failure1()
434 void nvmet_execute_auth_receive(struct nvmet_req *req) in nvmet_execute_auth_receive() argument
436 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_auth_receive()
441 if (req->cmd->auth_receive.secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER) { in nvmet_execute_auth_receive()
443 req->error_loc = in nvmet_execute_auth_receive()
447 if (req->cmd->auth_receive.spsp0 != 0x01) { in nvmet_execute_auth_receive()
449 req->error_loc = in nvmet_execute_auth_receive()
453 if (req->cmd->auth_receive.spsp1 != 0x01) { in nvmet_execute_auth_receive()
455 req->error_loc = in nvmet_execute_auth_receive()
459 al = le32_to_cpu(req->cmd->auth_receive.al); in nvmet_execute_auth_receive()
462 req->error_loc = in nvmet_execute_auth_receive()
466 if (!nvmet_check_transfer_len(req, al)) { in nvmet_execute_auth_receive()
477 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step); in nvmet_execute_auth_receive()
478 switch (req->sq->dhchap_step) { in nvmet_execute_auth_receive()
480 if (nvmet_auth_challenge(req, d, al) < 0) { in nvmet_execute_auth_receive()
482 ctrl->cntlid, req->sq->qid, status); in nvmet_execute_auth_receive()
487 req->sq->dhchap_status = status; in nvmet_execute_auth_receive()
488 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
490 ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_receive()
491 req->sq->dhchap_status); in nvmet_execute_auth_receive()
495 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_REPLY; in nvmet_execute_auth_receive()
498 status = nvmet_auth_success1(req, d, al); in nvmet_execute_auth_receive()
500 req->sq->dhchap_status = status; in nvmet_execute_auth_receive()
501 req->sq->authenticated = false; in nvmet_execute_auth_receive()
502 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
504 ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_receive()
505 req->sq->dhchap_status); in nvmet_execute_auth_receive()
508 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2; in nvmet_execute_auth_receive()
511 req->sq->authenticated = false; in nvmet_execute_auth_receive()
512 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
514 ctrl->cntlid, req->sq->qid, req->sq->dhchap_status); in nvmet_execute_auth_receive()
518 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step); in nvmet_execute_auth_receive()
519 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; in nvmet_execute_auth_receive()
520 req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvmet_execute_auth_receive()
521 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
526 status = nvmet_copy_to_sgl(req, 0, d, al); in nvmet_execute_auth_receive()
529 req->cqe->result.u64 = 0; in nvmet_execute_auth_receive()
530 nvmet_req_complete(req, status); in nvmet_execute_auth_receive()
531 if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2) in nvmet_execute_auth_receive()
532 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_receive()
533 else if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) { in nvmet_execute_auth_receive()
534 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_receive()