Lines Matching refs:hdr
369 static int nvme_trans_copy_to_user(struct sg_io_hdr *hdr, void *from, in nvme_trans_copy_to_user() argument
379 if (hdr->iovec_count > 0) { in nvme_trans_copy_to_user()
382 for (i = 0; i < hdr->iovec_count; i++) { in nvme_trans_copy_to_user()
383 not_copied = copy_from_user(&sgl, hdr->dxferp + in nvme_trans_copy_to_user()
402 not_copied = copy_to_user(hdr->dxferp, from, n); in nvme_trans_copy_to_user()
410 static int nvme_trans_copy_from_user(struct sg_io_hdr *hdr, void *to, in nvme_trans_copy_from_user() argument
420 if (hdr->iovec_count > 0) { in nvme_trans_copy_from_user()
423 for (i = 0; i < hdr->iovec_count; i++) { in nvme_trans_copy_from_user()
424 not_copied = copy_from_user(&sgl, hdr->dxferp + in nvme_trans_copy_from_user()
444 not_copied = copy_from_user(to, hdr->dxferp, n); in nvme_trans_copy_from_user()
452 static int nvme_trans_completion(struct sg_io_hdr *hdr, u8 status, u8 sense_key, in nvme_trans_completion() argument
460 hdr->status = SAM_STAT_GOOD; in nvme_trans_completion()
461 hdr->masked_status = GOOD; in nvme_trans_completion()
462 hdr->host_status = DID_OK; in nvme_trans_completion()
463 hdr->driver_status = DRIVER_OK; in nvme_trans_completion()
464 hdr->sb_len_wr = 0; in nvme_trans_completion()
466 hdr->status = status; in nvme_trans_completion()
467 hdr->masked_status = status >> 1; in nvme_trans_completion()
468 hdr->host_status = DID_OK; in nvme_trans_completion()
469 hdr->driver_status = DRIVER_OK; in nvme_trans_completion()
477 xfer_len = min_t(u8, hdr->mx_sb_len, DESC_FMT_SENSE_DATA_SIZE); in nvme_trans_completion()
478 hdr->sb_len_wr = xfer_len; in nvme_trans_completion()
479 if (copy_to_user(hdr->sbp, resp, xfer_len) > 0) in nvme_trans_completion()
486 static int nvme_trans_status_code(struct sg_io_hdr *hdr, int nvme_sc) in nvme_trans_status_code() argument
664 res = nvme_trans_completion(hdr, status, sense_key, asc, ascq); in nvme_trans_status_code()
672 struct sg_io_hdr *hdr, u8 *inq_response, in nvme_trans_standard_inquiry_page() argument
696 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_standard_inquiry_page()
728 res = nvme_trans_copy_to_user(hdr, inq_response, xfer_len); in nvme_trans_standard_inquiry_page()
738 struct sg_io_hdr *hdr, u8 *inq_response, in nvme_trans_supported_vpd_pages() argument
755 res = nvme_trans_copy_to_user(hdr, inq_response, xfer_len); in nvme_trans_supported_vpd_pages()
761 struct sg_io_hdr *hdr, u8 *inq_response, in nvme_trans_unit_serial_page() argument
774 res = nvme_trans_copy_to_user(hdr, inq_response, xfer_len); in nvme_trans_unit_serial_page()
779 static int nvme_trans_device_id_page(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_device_id_page() argument
805 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_device_id_page()
832 res = nvme_trans_completion(hdr, in nvme_trans_device_id_page()
851 res = nvme_trans_copy_to_user(hdr, inq_response, xfer_len); in nvme_trans_device_id_page()
860 static int nvme_trans_ext_inq_page(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_ext_inq_page() argument
895 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_ext_inq_page()
911 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_ext_inq_page()
933 res = nvme_trans_copy_to_user(hdr, inq_response, xfer_len); in nvme_trans_ext_inq_page()
944 static int nvme_trans_bdev_limits_page(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_bdev_limits_page() argument
961 return nvme_trans_copy_to_user(hdr, inq_response, 0x3c); in nvme_trans_bdev_limits_page()
964 static int nvme_trans_bdev_char_page(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_bdev_char_page() argument
985 res = nvme_trans_copy_to_user(hdr, inq_response, xfer_len); in nvme_trans_bdev_char_page()
994 static int nvme_trans_log_supp_pages(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_log_supp_pages() argument
1015 res = nvme_trans_copy_to_user(hdr, log_response, xfer_len); in nvme_trans_log_supp_pages()
1023 struct sg_io_hdr *hdr, int alloc_len) in nvme_trans_log_info_exceptions() argument
1079 res = nvme_trans_copy_to_user(hdr, log_response, xfer_len); in nvme_trans_log_info_exceptions()
1089 static int nvme_trans_log_temperature(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_log_temperature() argument
1160 res = nvme_trans_copy_to_user(hdr, log_response, xfer_len); in nvme_trans_log_temperature()
1196 static int nvme_trans_fill_blk_desc(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_fill_blk_desc() argument
1222 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_fill_blk_desc()
1257 struct sg_io_hdr *hdr, u8 *resp, in nvme_trans_fill_control_page() argument
1279 struct sg_io_hdr *hdr, in nvme_trans_fill_caching_page() argument
1293 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_fill_caching_page()
1311 struct sg_io_hdr *hdr, u8 *resp, in nvme_trans_fill_pow_cnd_page() argument
1327 struct sg_io_hdr *hdr, u8 *resp, in nvme_trans_fill_inf_exc_page() argument
1343 static int nvme_trans_fill_all_pages(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_fill_all_pages() argument
1354 res = nvme_trans_fill_caching_page(ns, hdr, &resp[mode_pages_offset_1], in nvme_trans_fill_all_pages()
1358 res = nvme_trans_fill_control_page(ns, hdr, &resp[mode_pages_offset_2], in nvme_trans_fill_all_pages()
1362 res = nvme_trans_fill_pow_cnd_page(ns, hdr, &resp[mode_pages_offset_3], in nvme_trans_fill_all_pages()
1366 res = nvme_trans_fill_inf_exc_page(ns, hdr, &resp[mode_pages_offset_4], in nvme_trans_fill_all_pages()
1386 struct sg_io_hdr *hdr, u8 *cmd, in nvme_trans_mode_page_create() argument
1390 struct sg_io_hdr *hdr, u8 *, int), in nvme_trans_mode_page_create()
1425 res = nvme_trans_fill_blk_desc(ns, hdr, in nvme_trans_mode_page_create()
1431 res = mode_page_fill_func(ns, hdr, &response[mode_pages_offset_1], in nvme_trans_mode_page_create()
1437 res = nvme_trans_copy_to_user(hdr, response, xfer_len); in nvme_trans_mode_page_create()
1485 static int nvme_trans_power_state(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_power_state() argument
1506 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_power_state()
1547 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_power_state()
1554 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_power_state()
1569 static int nvme_trans_send_fw_cmd(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_send_fw_cmd() argument
1583 if (hdr->iovec_count > 0) { in nvme_trans_send_fw_cmd()
1585 res = nvme_trans_completion(hdr, in nvme_trans_send_fw_cmd()
1593 (unsigned long)hdr->dxferp, tot_len); in nvme_trans_send_fw_cmd()
1614 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_send_fw_cmd()
1686 static int nvme_trans_modesel_get_mp(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_modesel_get_mp() argument
1699 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_modesel_get_mp()
1712 res = nvme_trans_completion(hdr, in nvme_trans_modesel_get_mp()
1723 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_modesel_get_mp()
1734 static int nvme_trans_modesel_data(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_modesel_data() argument
1753 res = nvme_trans_copy_from_user(hdr, parm_list, parm_list_len); in nvme_trans_modesel_data()
1775 res = nvme_trans_completion(hdr, in nvme_trans_modesel_data()
1790 res = nvme_trans_modesel_get_mp(ns, hdr, &parm_list[index], in nvme_trans_modesel_data()
1806 struct sg_io_hdr *hdr) in nvme_trans_fmt_set_blk_size_count() argument
1832 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_fmt_set_blk_size_count()
1856 static int nvme_trans_fmt_get_parm_header(struct sg_io_hdr *hdr, u8 len, in nvme_trans_fmt_get_parm_header() argument
1868 res = nvme_trans_copy_from_user(hdr, parm_list, len); in nvme_trans_fmt_get_parm_header()
1874 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_fmt_get_parm_header()
1882 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_fmt_get_parm_header()
1904 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_fmt_get_parm_header()
1916 static int nvme_trans_fmt_send_cmd(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_fmt_send_cmd() argument
1940 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_fmt_send_cmd()
1958 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_fmt_send_cmd()
1963 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_fmt_send_cmd()
1976 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_fmt_send_cmd()
2038 static inline u32 nvme_trans_io_get_num_cmds(struct sg_io_hdr *hdr, in nvme_trans_io_get_num_cmds() argument
2043 if (hdr->iovec_count > 0) in nvme_trans_io_get_num_cmds()
2044 return hdr->iovec_count; in nvme_trans_io_get_num_cmds()
2064 static int nvme_trans_do_nvme_io(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_do_nvme_io() argument
2083 num_cmds = nvme_trans_io_get_num_cmds(hdr, cdb_info, max_blocks); in nvme_trans_do_nvme_io()
2096 if (hdr->iovec_count > 0) { in nvme_trans_do_nvme_io()
2099 retcode = copy_from_user(&sgl, hdr->dxferp + in nvme_trans_do_nvme_io()
2111 next_mapping_addr = hdr->dxferp + in nvme_trans_do_nvme_io()
2149 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_do_nvme_io()
2157 res = nvme_trans_status_code(hdr, NVME_SC_SUCCESS); in nvme_trans_do_nvme_io()
2166 static int nvme_trans_io(struct nvme_ns *ns, struct sg_io_hdr *hdr, u8 is_write, in nvme_trans_io() argument
2203 if (hdr->iovec_count > 0) { in nvme_trans_io()
2204 for (i = 0; i < hdr->iovec_count; i++) { in nvme_trans_io()
2205 not_copied = copy_from_user(&sgl, hdr->dxferp + in nvme_trans_io()
2213 res = nvme_trans_completion(hdr, in nvme_trans_io()
2222 sum_iov_len = hdr->dxfer_len; in nvme_trans_io()
2226 xfer_bytes = min(((u64)hdr->dxfer_len), sum_iov_len); in nvme_trans_io()
2239 res = nvme_trans_do_nvme_io(ns, hdr, &cdb_info, is_write); in nvme_trans_io()
2247 static int nvme_trans_inquiry(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_inquiry() argument
2269 res = nvme_trans_standard_inquiry_page(ns, hdr, in nvme_trans_inquiry()
2272 res = nvme_trans_completion(hdr, in nvme_trans_inquiry()
2281 res = nvme_trans_supported_vpd_pages(ns, hdr, in nvme_trans_inquiry()
2285 res = nvme_trans_unit_serial_page(ns, hdr, inq_response, in nvme_trans_inquiry()
2289 res = nvme_trans_device_id_page(ns, hdr, inq_response, in nvme_trans_inquiry()
2293 res = nvme_trans_ext_inq_page(ns, hdr, alloc_len); in nvme_trans_inquiry()
2296 res = nvme_trans_bdev_limits_page(ns, hdr, inq_response, in nvme_trans_inquiry()
2300 res = nvme_trans_bdev_char_page(ns, hdr, alloc_len); in nvme_trans_inquiry()
2303 res = nvme_trans_completion(hdr, in nvme_trans_inquiry()
2316 static int nvme_trans_log_sense(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_log_sense() argument
2327 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_log_sense()
2336 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_log_sense()
2344 res = nvme_trans_log_supp_pages(ns, hdr, alloc_len); in nvme_trans_log_sense()
2347 res = nvme_trans_log_info_exceptions(ns, hdr, alloc_len); in nvme_trans_log_sense()
2350 res = nvme_trans_log_temperature(ns, hdr, alloc_len); in nvme_trans_log_sense()
2353 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_log_sense()
2363 static int nvme_trans_mode_select(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_mode_select() argument
2392 res = nvme_trans_modesel_data(ns, hdr, cmd, parm_list_len, in nvme_trans_mode_select()
2399 static int nvme_trans_mode_sense(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_mode_sense() argument
2419 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_mode_sense()
2429 res = nvme_trans_mode_page_create(ns, hdr, cmd, alloc_len, in nvme_trans_mode_sense()
2435 res = nvme_trans_mode_page_create(ns, hdr, cmd, alloc_len, in nvme_trans_mode_sense()
2441 res = nvme_trans_mode_page_create(ns, hdr, cmd, alloc_len, in nvme_trans_mode_sense()
2447 res = nvme_trans_mode_page_create(ns, hdr, cmd, alloc_len, in nvme_trans_mode_sense()
2453 res = nvme_trans_mode_page_create(ns, hdr, cmd, alloc_len, in nvme_trans_mode_sense()
2459 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_mode_sense()
2469 static int nvme_trans_read_capacity(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_read_capacity() argument
2498 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_read_capacity()
2515 res = nvme_trans_copy_to_user(hdr, response, xfer_len); in nvme_trans_read_capacity()
2525 static int nvme_trans_report_luns(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_report_luns() argument
2547 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_report_luns()
2561 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_report_luns()
2573 res = nvme_trans_completion(hdr, in nvme_trans_report_luns()
2601 res = nvme_trans_copy_to_user(hdr, response, xfer_len); in nvme_trans_report_luns()
2611 static int nvme_trans_request_sense(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_request_sense() argument
2654 res = nvme_trans_copy_to_user(hdr, response, xfer_len); in nvme_trans_request_sense()
2662 struct sg_io_hdr *hdr, in nvme_trans_security_protocol() argument
2665 return nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_security_protocol()
2670 static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_start_stop() argument
2691 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_start_stop()
2702 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_start_stop()
2711 res = nvme_trans_power_state(ns, hdr, pc, pcmod, start); in nvme_trans_start_stop()
2719 struct sg_io_hdr *hdr, u8 *cmd) in nvme_trans_synchronize_cache() argument
2731 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_synchronize_cache()
2741 static int nvme_trans_format_unit(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_format_unit() argument
2768 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_format_unit()
2780 res = nvme_trans_fmt_get_parm_header(hdr, parm_hdr_len, in nvme_trans_format_unit()
2787 res = nvme_trans_send_fw_cmd(ns, hdr, nvme_admin_activate_fw, 0, 0, 0); in nvme_trans_format_unit()
2790 res = nvme_trans_fmt_set_blk_size_count(ns, hdr); in nvme_trans_format_unit()
2794 res = nvme_trans_fmt_send_cmd(ns, hdr, nvme_pf_code); in nvme_trans_format_unit()
2801 struct sg_io_hdr *hdr, in nvme_trans_test_unit_ready() argument
2808 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_test_unit_ready()
2812 res = nvme_trans_completion(hdr, SAM_STAT_GOOD, NO_SENSE, 0, 0); in nvme_trans_test_unit_ready()
2817 static int nvme_trans_write_buffer(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_write_buffer() argument
2828 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_write_buffer()
2835 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_write_buffer()
2847 res = nvme_trans_send_fw_cmd(ns, hdr, nvme_admin_download_fw, in nvme_trans_write_buffer()
2852 res = nvme_trans_send_fw_cmd(ns, hdr, nvme_admin_activate_fw, in nvme_trans_write_buffer()
2857 res = nvme_trans_send_fw_cmd(ns, hdr, nvme_admin_download_fw, in nvme_trans_write_buffer()
2862 res = nvme_trans_send_fw_cmd(ns, hdr, nvme_admin_activate_fw, in nvme_trans_write_buffer()
2867 res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_trans_write_buffer()
2890 static int nvme_trans_unmap(struct nvme_ns *ns, struct sg_io_hdr *hdr, in nvme_trans_unmap() argument
2909 res = nvme_trans_copy_from_user(hdr, plist, list_len); in nvme_trans_unmap()
2938 res = nvme_trans_status_code(hdr, nvme_sc); in nvme_trans_unmap()
2947 static int nvme_scsi_translate(struct nvme_ns *ns, struct sg_io_hdr *hdr) in nvme_scsi_translate() argument
2953 if (hdr->cmdp == NULL) in nvme_scsi_translate()
2955 if (copy_from_user(cmd, hdr->cmdp, hdr->cmd_len)) in nvme_scsi_translate()
2962 retcode = nvme_trans_status_code(hdr, NVME_SC_SUCCESS); in nvme_scsi_translate()
2973 retcode = nvme_trans_io(ns, hdr, 0, cmd); in nvme_scsi_translate()
2979 retcode = nvme_trans_io(ns, hdr, 1, cmd); in nvme_scsi_translate()
2982 retcode = nvme_trans_inquiry(ns, hdr, cmd); in nvme_scsi_translate()
2985 retcode = nvme_trans_log_sense(ns, hdr, cmd); in nvme_scsi_translate()
2989 retcode = nvme_trans_mode_select(ns, hdr, cmd); in nvme_scsi_translate()
2993 retcode = nvme_trans_mode_sense(ns, hdr, cmd); in nvme_scsi_translate()
2996 retcode = nvme_trans_read_capacity(ns, hdr, cmd); in nvme_scsi_translate()
3000 retcode = nvme_trans_read_capacity(ns, hdr, cmd); in nvme_scsi_translate()
3005 retcode = nvme_trans_report_luns(ns, hdr, cmd); in nvme_scsi_translate()
3008 retcode = nvme_trans_request_sense(ns, hdr, cmd); in nvme_scsi_translate()
3012 retcode = nvme_trans_security_protocol(ns, hdr, cmd); in nvme_scsi_translate()
3015 retcode = nvme_trans_start_stop(ns, hdr, cmd); in nvme_scsi_translate()
3018 retcode = nvme_trans_synchronize_cache(ns, hdr, cmd); in nvme_scsi_translate()
3021 retcode = nvme_trans_format_unit(ns, hdr, cmd); in nvme_scsi_translate()
3024 retcode = nvme_trans_test_unit_ready(ns, hdr, cmd); in nvme_scsi_translate()
3027 retcode = nvme_trans_write_buffer(ns, hdr, cmd); in nvme_scsi_translate()
3030 retcode = nvme_trans_unmap(ns, hdr, cmd); in nvme_scsi_translate()
3034 retcode = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, in nvme_scsi_translate()
3044 struct sg_io_hdr hdr; in nvme_sg_io() local
3049 if (copy_from_user(&hdr, u_hdr, sizeof(hdr))) in nvme_sg_io()
3051 if (hdr.interface_id != 'S') in nvme_sg_io()
3053 if (hdr.cmd_len > BLK_MAX_CDB) in nvme_sg_io()
3056 retcode = nvme_scsi_translate(ns, &hdr); in nvme_sg_io()
3061 if (copy_to_user(u_hdr, &hdr, sizeof(sg_io_hdr_t)) > 0) in nvme_sg_io()