Lines Matching full: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()
299 req->sq->authenticated = true; in nvmet_execute_auth_send()
301 __func__, ctrl->cntlid, req->sq->qid); in nvmet_execute_auth_send()
307 ctrl->cntlid, req->sq->qid, status); in nvmet_execute_auth_send()
308 req->sq->dhchap_status = status; in nvmet_execute_auth_send()
309 req->sq->authenticated = false; in nvmet_execute_auth_send()
314 req->sq->dhchap_status = in nvmet_execute_auth_send()
316 req->sq->dhchap_step = in nvmet_execute_auth_send()
318 req->sq->authenticated = false; in nvmet_execute_auth_send()
322 req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_MESSAGE; in nvmet_execute_auth_send()
323 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_FAILURE2; in nvmet_execute_auth_send()
329 ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
330 req->sq->dhchap_status, req->sq->dhchap_step); in nvmet_execute_auth_send()
333 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
334 status, req->error_loc); in nvmet_execute_auth_send()
335 if (req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 && in nvmet_execute_auth_send()
336 req->sq->dhchap_step != NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) { in nvmet_execute_auth_send()
339 mod_delayed_work(system_wq, &req->sq->auth_expired_work, in nvmet_execute_auth_send()
344 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_send()
345 if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE2) in nvmet_execute_auth_send()
349 nvmet_req_complete(req, status); in nvmet_execute_auth_send()
352 static int nvmet_auth_challenge(struct nvmet_req *req, void *d, int al) in nvmet_auth_challenge() argument
355 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_challenge()
368 req->sq->dhchap_s1 = nvme_auth_get_seqnum(); in nvmet_auth_challenge()
371 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_challenge()
374 data->seqnum = cpu_to_le32(req->sq->dhchap_s1); in nvmet_auth_challenge()
375 req->sq->dhchap_c1 = kmalloc(data->hl, GFP_KERNEL); in nvmet_auth_challenge()
376 if (!req->sq->dhchap_c1) in nvmet_auth_challenge()
378 get_random_bytes(req->sq->dhchap_c1, data->hl); in nvmet_auth_challenge()
379 memcpy(data->cval, req->sq->dhchap_c1, data->hl); in nvmet_auth_challenge()
383 ret = nvmet_auth_ctrl_exponential(req, data->cval + data->hl, in nvmet_auth_challenge()
387 __func__, ctrl->cntlid, req->sq->qid, req->sq->dhchap_s1, in nvmet_auth_challenge()
388 req->sq->dhchap_tid, data->hl, ctrl->dh_keysize); in nvmet_auth_challenge()
392 static int nvmet_auth_success1(struct nvmet_req *req, void *d, int al) in nvmet_auth_success1() argument
395 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_success1()
402 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_success1()
404 if (req->sq->dhchap_c2) { in nvmet_auth_success1()
407 ctrl->cntlid, req->sq->qid); in nvmet_auth_success1()
410 if (nvmet_auth_ctrl_hash(req, data->rval, data->hl)) in nvmet_auth_success1()
414 ctrl->cntlid, req->sq->qid, data->hl, data->rval); in nvmet_auth_success1()
419 static void nvmet_auth_failure1(struct nvmet_req *req, void *d, int al) in nvmet_auth_failure1() argument
426 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_failure1()
428 data->rescode_exp = req->sq->dhchap_status; in nvmet_auth_failure1()
431 void nvmet_execute_auth_receive(struct nvmet_req *req) in nvmet_execute_auth_receive() argument
433 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_auth_receive()
438 if (req->cmd->auth_receive.secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER) { in nvmet_execute_auth_receive()
440 req->error_loc = in nvmet_execute_auth_receive()
444 if (req->cmd->auth_receive.spsp0 != 0x01) { in nvmet_execute_auth_receive()
446 req->error_loc = in nvmet_execute_auth_receive()
450 if (req->cmd->auth_receive.spsp1 != 0x01) { in nvmet_execute_auth_receive()
452 req->error_loc = in nvmet_execute_auth_receive()
456 al = le32_to_cpu(req->cmd->auth_receive.al); in nvmet_execute_auth_receive()
459 req->error_loc = in nvmet_execute_auth_receive()
463 if (!nvmet_check_transfer_len(req, al)) { in nvmet_execute_auth_receive()
474 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step); in nvmet_execute_auth_receive()
475 switch (req->sq->dhchap_step) { in nvmet_execute_auth_receive()
477 if (nvmet_auth_challenge(req, d, al) < 0) { in nvmet_execute_auth_receive()
479 ctrl->cntlid, req->sq->qid, status); in nvmet_execute_auth_receive()
483 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_REPLY; in nvmet_execute_auth_receive()
486 status = nvmet_auth_success1(req, d, al); in nvmet_execute_auth_receive()
488 req->sq->dhchap_status = status; in nvmet_execute_auth_receive()
489 req->sq->authenticated = false; in nvmet_execute_auth_receive()
490 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
492 ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_receive()
493 req->sq->dhchap_status); in nvmet_execute_auth_receive()
496 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2; in nvmet_execute_auth_receive()
499 req->sq->authenticated = false; in nvmet_execute_auth_receive()
500 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
502 ctrl->cntlid, req->sq->qid, req->sq->dhchap_status); in nvmet_execute_auth_receive()
506 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step); in nvmet_execute_auth_receive()
507 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; in nvmet_execute_auth_receive()
508 req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvmet_execute_auth_receive()
509 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
514 status = nvmet_copy_to_sgl(req, 0, d, al); in nvmet_execute_auth_receive()
517 if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2) in nvmet_execute_auth_receive()
518 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_receive()
519 else if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) { in nvmet_execute_auth_receive()
520 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_receive()
523 nvmet_req_complete(req, status); in nvmet_execute_auth_receive()