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 u32 nvmet_auth_send_data_len(struct nvmet_req *req) in nvmet_auth_send_data_len() argument
184 return le32_to_cpu(req->cmd->auth_send.tl); in nvmet_auth_send_data_len()
187 void nvmet_execute_auth_send(struct nvmet_req *req) in nvmet_execute_auth_send() argument
189 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_auth_send()
196 if (req->cmd->auth_send.secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER) { in nvmet_execute_auth_send()
198 req->error_loc = in nvmet_execute_auth_send()
202 if (req->cmd->auth_send.spsp0 != 0x01) { in nvmet_execute_auth_send()
204 req->error_loc = in nvmet_execute_auth_send()
208 if (req->cmd->auth_send.spsp1 != 0x01) { in nvmet_execute_auth_send()
210 req->error_loc = in nvmet_execute_auth_send()
214 tl = nvmet_auth_send_data_len(req); in nvmet_execute_auth_send()
217 req->error_loc = in nvmet_execute_auth_send()
221 if (!nvmet_check_transfer_len(req, tl)) { in nvmet_execute_auth_send()
232 status = nvmet_copy_from_sgl(req, 0, d, tl); in nvmet_execute_auth_send()
238 ctrl->cntlid, req->sq->qid, data->auth_type, data->auth_id, in nvmet_execute_auth_send()
239 req->sq->dhchap_step); in nvmet_execute_auth_send()
247 __func__, ctrl->cntlid, req->sq->qid); in nvmet_execute_auth_send()
248 if (!req->sq->qid) { in nvmet_execute_auth_send()
253 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
254 req->sq->dhchap_step = in nvmet_execute_auth_send()
259 req->sq->dhchap_step = in nvmet_execute_auth_send()
261 } else if (data->auth_id != req->sq->dhchap_step) in nvmet_execute_auth_send()
264 dhchap_status = nvmet_auth_negotiate(req, d); in nvmet_execute_auth_send()
266 req->sq->dhchap_step = in nvmet_execute_auth_send()
269 req->sq->dhchap_step = in nvmet_execute_auth_send()
271 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
275 if (data->auth_id != req->sq->dhchap_step) { in nvmet_execute_auth_send()
277 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
278 data->auth_id, req->sq->dhchap_step); in nvmet_execute_auth_send()
281 if (le16_to_cpu(data->t_id) != req->sq->dhchap_tid) { in nvmet_execute_auth_send()
283 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
285 req->sq->dhchap_tid); in nvmet_execute_auth_send()
286 req->sq->dhchap_step = in nvmet_execute_auth_send()
288 req->sq->dhchap_status = in nvmet_execute_auth_send()
295 dhchap_status = nvmet_auth_reply(req, d); in nvmet_execute_auth_send()
297 req->sq->dhchap_step = in nvmet_execute_auth_send()
300 req->sq->dhchap_step = in nvmet_execute_auth_send()
302 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
306 req->sq->authenticated = true; in nvmet_execute_auth_send()
308 __func__, ctrl->cntlid, req->sq->qid); in nvmet_execute_auth_send()
314 ctrl->cntlid, req->sq->qid, dhchap_status); in nvmet_execute_auth_send()
315 req->sq->dhchap_status = dhchap_status; in nvmet_execute_auth_send()
316 req->sq->authenticated = false; in nvmet_execute_auth_send()
320 req->sq->dhchap_status = in nvmet_execute_auth_send()
322 req->sq->dhchap_step = in nvmet_execute_auth_send()
324 req->sq->authenticated = false; in nvmet_execute_auth_send()
328 req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_INCORRECT_MESSAGE; in nvmet_execute_auth_send()
329 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_FAILURE2; in nvmet_execute_auth_send()
335 ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
336 req->sq->dhchap_status, req->sq->dhchap_step); in nvmet_execute_auth_send()
339 __func__, ctrl->cntlid, req->sq->qid, in nvmet_execute_auth_send()
340 status, req->error_loc); 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 nvmet_req_complete(req, status); in nvmet_execute_auth_send()
358 static int nvmet_auth_challenge(struct nvmet_req *req, void *d, int al) in nvmet_auth_challenge() argument
361 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_challenge()
374 req->sq->dhchap_s1 = nvme_auth_get_seqnum(); in nvmet_auth_challenge()
377 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_challenge()
380 data->seqnum = cpu_to_le32(req->sq->dhchap_s1); in nvmet_auth_challenge()
381 req->sq->dhchap_c1 = kmalloc(data->hl, GFP_KERNEL); in nvmet_auth_challenge()
382 if (!req->sq->dhchap_c1) in nvmet_auth_challenge()
384 get_random_bytes(req->sq->dhchap_c1, data->hl); in nvmet_auth_challenge()
385 memcpy(data->cval, req->sq->dhchap_c1, data->hl); in nvmet_auth_challenge()
389 ret = nvmet_auth_ctrl_exponential(req, data->cval + data->hl, in nvmet_auth_challenge()
393 __func__, ctrl->cntlid, req->sq->qid, req->sq->dhchap_s1, in nvmet_auth_challenge()
394 req->sq->dhchap_tid, data->hl, ctrl->dh_keysize); in nvmet_auth_challenge()
398 static int nvmet_auth_success1(struct nvmet_req *req, void *d, int al) in nvmet_auth_success1() argument
401 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_auth_success1()
408 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_success1()
410 if (req->sq->dhchap_c2) { in nvmet_auth_success1()
413 ctrl->cntlid, req->sq->qid); in nvmet_auth_success1()
416 if (nvmet_auth_ctrl_hash(req, data->rval, data->hl)) in nvmet_auth_success1()
420 ctrl->cntlid, req->sq->qid, data->hl, data->rval); in nvmet_auth_success1()
425 static void nvmet_auth_failure1(struct nvmet_req *req, void *d, int al) in nvmet_auth_failure1() argument
432 data->t_id = cpu_to_le16(req->sq->dhchap_tid); in nvmet_auth_failure1()
434 data->rescode_exp = req->sq->dhchap_status; in nvmet_auth_failure1()
437 u32 nvmet_auth_receive_data_len(struct nvmet_req *req) in nvmet_auth_receive_data_len() argument
439 return le32_to_cpu(req->cmd->auth_receive.al); in nvmet_auth_receive_data_len()
442 void nvmet_execute_auth_receive(struct nvmet_req *req) in nvmet_execute_auth_receive() argument
444 struct nvmet_ctrl *ctrl = req->sq->ctrl; in nvmet_execute_auth_receive()
449 if (req->cmd->auth_receive.secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER) { in nvmet_execute_auth_receive()
451 req->error_loc = in nvmet_execute_auth_receive()
455 if (req->cmd->auth_receive.spsp0 != 0x01) { in nvmet_execute_auth_receive()
457 req->error_loc = in nvmet_execute_auth_receive()
461 if (req->cmd->auth_receive.spsp1 != 0x01) { in nvmet_execute_auth_receive()
463 req->error_loc = in nvmet_execute_auth_receive()
467 al = nvmet_auth_receive_data_len(req); in nvmet_execute_auth_receive()
470 req->error_loc = in nvmet_execute_auth_receive()
474 if (!nvmet_check_transfer_len(req, al)) { in nvmet_execute_auth_receive()
485 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step); in nvmet_execute_auth_receive()
486 switch (req->sq->dhchap_step) { in nvmet_execute_auth_receive()
488 if (nvmet_auth_challenge(req, d, al) < 0) { in nvmet_execute_auth_receive()
490 ctrl->cntlid, req->sq->qid, status); in nvmet_execute_auth_receive()
494 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_REPLY; in nvmet_execute_auth_receive()
497 status = nvmet_auth_success1(req, d, al); in nvmet_execute_auth_receive()
499 req->sq->dhchap_status = status; 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, in nvmet_execute_auth_receive()
504 req->sq->dhchap_status); in nvmet_execute_auth_receive()
507 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2; in nvmet_execute_auth_receive()
510 req->sq->authenticated = false; in nvmet_execute_auth_receive()
511 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
513 ctrl->cntlid, req->sq->qid, req->sq->dhchap_status); in nvmet_execute_auth_receive()
517 ctrl->cntlid, req->sq->qid, req->sq->dhchap_step); in nvmet_execute_auth_receive()
518 req->sq->dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_FAILURE1; in nvmet_execute_auth_receive()
519 req->sq->dhchap_status = NVME_AUTH_DHCHAP_FAILURE_FAILED; in nvmet_execute_auth_receive()
520 nvmet_auth_failure1(req, d, al); in nvmet_execute_auth_receive()
525 status = nvmet_copy_to_sgl(req, 0, d, al); in nvmet_execute_auth_receive()
528 if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2) in nvmet_execute_auth_receive()
529 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_receive()
530 else if (req->sq->dhchap_step == NVME_AUTH_DHCHAP_MESSAGE_FAILURE1) { in nvmet_execute_auth_receive()
531 nvmet_auth_sq_free(req->sq); in nvmet_execute_auth_receive()
534 nvmet_req_complete(req, status); in nvmet_execute_auth_receive()