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()
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 u8 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()
167 req->sq->authenticated = true; in nvmet_auth_reply()
168 req->sq->dhchap_c2 = NULL; in nvmet_auth_reply()
170 req->sq->dhchap_s2 = le32_to_cpu(data->seqnum); 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()
191 if (req->cmd->auth_send.secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER) { in nvmet_execute_auth_send()
193 req->error_loc = in nvmet_execute_auth_send()
197 if (req->cmd->auth_send.spsp0 != 0x01) { in nvmet_execute_auth_send()
199 req->error_loc = in nvmet_execute_auth_send()
203 if (req->cmd->auth_send.spsp1 != 0x01) { in nvmet_execute_auth_send()
205 req->error_loc = in nvmet_execute_auth_send()
209 tl = le32_to_cpu(req->cmd->auth_send.tl); in nvmet_execute_auth_send()
212 req->error_loc = in nvmet_execute_auth_send()
216 if (!nvmet_check_transfer_len(req, tl)) { in nvmet_execute_auth_send()
227 status = nvmet_copy_from_sgl(req, 0, d, tl); in nvmet_execute_auth_send()
233 ctrl->cntlid, req->sq->qid, data->auth_type, data->auth_id, in nvmet_execute_auth_send()
234 req->sq->dhchap_step); in nvmet_execute_auth_send()
242 __func__, ctrl->cntlid, req->sq->qid); in nvmet_execute_auth_send()
243 if (!req->sq->qid) { in nvmet_execute_auth_send()
248 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
249 req->sq->dhchap_step = in nvmet_execute_auth_send()
254 req->sq->dhchap_step = in nvmet_execute_auth_send()
256 } else if (data->auth_id != req->sq->dhchap_step) in nvmet_execute_auth_send()
259 dhchap_status = nvmet_auth_negotiate(req, d); in nvmet_execute_auth_send()
261 req->sq->dhchap_step = in nvmet_execute_auth_send()
264 req->sq->dhchap_step = in nvmet_execute_auth_send()
266 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
270 if (data->auth_id != req->sq->dhchap_step) { in nvmet_execute_auth_send()
272 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
273 data->auth_id, req->sq->dhchap_step); in nvmet_execute_auth_send()
276 if (le16_to_cpu(data->t_id) != req->sq->dhchap_tid) { in nvmet_execute_auth_send()
278 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
280 req->sq->dhchap_tid); in nvmet_execute_auth_send()
281 req->sq->dhchap_step = in nvmet_execute_auth_send()
283 req->sq->dhchap_status = in nvmet_execute_auth_send()
290 dhchap_status = nvmet_auth_reply(req, d); in nvmet_execute_auth_send()
292 req->sq->dhchap_step = in nvmet_execute_auth_send()
295 req->sq->dhchap_step = in nvmet_execute_auth_send()
297 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
301 req->sq->authenticated = true; in nvmet_execute_auth_send()
303 __func__, ctrl->cntlid, req->sq->qid); in nvmet_execute_auth_send()
309 ctrl->cntlid, req->sq->qid, dhchap_status); in nvmet_execute_auth_send()
310 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
311 req->sq->authenticated = false; in nvmet_execute_auth_send()
315 req->sq->dhchap_status = in nvmet_execute_auth_send()
317 req->sq->dhchap_step = in nvmet_execute_auth_send()
319 req->sq->authenticated = false; in nvmet_execute_auth_send()
323 req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_MESSAGE; in nvmet_execute_auth_send()
324 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_FAILURE2; in nvmet_execute_auth_send()
330 ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
331 req->sq->dhchap_status, req->sq->dhchap_step); in nvmet_execute_auth_send()
334 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
335 status, req->error_loc); in nvmet_execute_auth_send()
336 if (req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 && in nvmet_execute_auth_send()
337 req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) { in nvmet_execute_auth_send()
340 mod_delayed_work(system_wq, &req->sq->auth_expired_work, in nvmet_execute_auth_send()
345 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_send()
346 if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) in nvmet_execute_auth_send()
350 nvmet_req_complete(req, status); in nvmet_execute_auth_send()
353 static int nvmet_auth_challenge(struct nvmet_req *req, void *d, int al) in nvmet_auth_challenge() argument
356 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_challenge()
369 req->sq->dhchap_s1 = nvme_auth_get_seqnum(); in nvmet_auth_challenge()
372 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_challenge()
375 data->seqnum = cpu_to_le32(req->sq->dhchap_s1); in nvmet_auth_challenge()
376 req->sq->dhchap_c1 = kmalloc(data->hl, GFP_KERNEL); in nvmet_auth_challenge()
377 if (!req->sq->dhchap_c1) in nvmet_auth_challenge()
379 get_random_bytes(req->sq->dhchap_c1, data->hl); in nvmet_auth_challenge()
380 memcpy(data->cval, req->sq->dhchap_c1, data->hl); in nvmet_auth_challenge()
384 ret = nvmet_auth_ctrl_exponential(req, data->cval + data->hl, in nvmet_auth_challenge()
388 __func__, ctrl->cntlid, req->sq->qid, req->sq->dhchap_s1, in nvmet_auth_challenge()
389 req->sq->dhchap_tid, data->hl, ctrl->dh_keysize); in nvmet_auth_challenge()
393 static int nvmet_auth_success1(struct nvmet_req *req, void *d, int al) in nvmet_auth_success1() argument
396 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_success1()
403 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_success1()
405 if (req->sq->dhchap_c2) { in nvmet_auth_success1()
408 ctrl->cntlid, req->sq->qid); in nvmet_auth_success1()
411 if (nvmet_auth_ctrl_hash(req, data->rval, data->hl)) in nvmet_auth_success1()
415 ctrl->cntlid, req->sq->qid, data->hl, data->rval); in nvmet_auth_success1()
420 static void nvmet_auth_failure1(struct nvmet_req *req, void *d, int al) in nvmet_auth_failure1() argument
427 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_failure1()
429 data->rescode_exp = req->sq->dhchap_status; in nvmet_auth_failure1()
432 void nvmet_execute_auth_receive(struct nvmet_req *req) in nvmet_execute_auth_receive() argument
434 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_auth_receive()
439 if (req->cmd->auth_receive.secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER) { in nvmet_execute_auth_receive()
441 req->error_loc = in nvmet_execute_auth_receive()
445 if (req->cmd->auth_receive.spsp0 != 0x01) { in nvmet_execute_auth_receive()
447 req->error_loc = in nvmet_execute_auth_receive()
451 if (req->cmd->auth_receive.spsp1 != 0x01) { in nvmet_execute_auth_receive()
453 req->error_loc = in nvmet_execute_auth_receive()
457 al = le32_to_cpu(req->cmd->auth_receive.al); in nvmet_execute_auth_receive()
460 req->error_loc = in nvmet_execute_auth_receive()
464 if (!nvmet_check_transfer_len(req, al)) { in nvmet_execute_auth_receive()
475 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step); in nvmet_execute_auth_receive()
476 switch (req->sq->dhchap_step) { in nvmet_execute_auth_receive()
478 if (nvmet_auth_challenge(req, d, al) < 0) { in nvmet_execute_auth_receive()
480 ctrl->cntlid, req->sq->qid, status); in nvmet_execute_auth_receive()
484 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_REPLY; in nvmet_execute_auth_receive()
487 status = nvmet_auth_success1(req, d, al); in nvmet_execute_auth_receive()
489 req->sq->dhchap_status = status; in nvmet_execute_auth_receive()
490 req->sq->authenticated = false; in nvmet_execute_auth_receive()
491 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
493 ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_receive()
494 req->sq->dhchap_status); in nvmet_execute_auth_receive()
497 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2; in nvmet_execute_auth_receive()
500 req->sq->authenticated = false; in nvmet_execute_auth_receive()
501 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
503 ctrl->cntlid, req->sq->qid, req->sq->dhchap_status); in nvmet_execute_auth_receive()
507 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step); in nvmet_execute_auth_receive()
508 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; in nvmet_execute_auth_receive()
509 req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvmet_execute_auth_receive()
510 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
515 status = nvmet_copy_to_sgl(req, 0, d, al); in nvmet_execute_auth_receive()
518 if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2) in nvmet_execute_auth_receive()
519 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_receive()
520 else if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) { in nvmet_execute_auth_receive()
521 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_receive()
524 nvmet_req_complete(req, status); in nvmet_execute_auth_receive()