Lines Matching full:srp

181 static int sg_start_req(Sg_request *srp, unsigned char *cmd);
182 static int sg_finish_rem_req(Sg_request * srp);
185 Sg_request * srp);
189 static int sg_common_write(Sg_fd * sfp, Sg_request * srp,
191 static int sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer);
194 static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size);
195 static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp);
200 static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
445 Sg_request *srp; in sg_read() local
470 srp = sg_get_rq_mark(sfp, req_pack_id, &busy); in sg_read()
471 if (!srp) { /* now wait on packet to arrive */ in sg_read()
475 ((srp = sg_get_rq_mark(sfp, req_pack_id, &busy)) || in sg_read()
477 if (!srp) in sg_read()
481 if (srp->header.interface_id != '\0') in sg_read()
482 return sg_new_read(sfp, buf, count, srp); in sg_read()
484 hp = &srp->header; in sg_read()
493 ((srp->data.cmd_opcode >= 0xc0) && (12 == hp->cmd_len)) ? 1 : 0; in sg_read()
498 (srp->sense_b[0] & 0x70) == 0x70) { in sg_read()
500 memcpy(old_hdr->sense_buffer, srp->sense_b, in sg_read()
524 old_hdr->result = (srp->sense_b[0] == 0 && in sg_read()
542 if (sg_read_oxfer(srp, buf, count - SZ_SG_HEADER)) { in sg_read()
549 sg_finish_rem_req(srp); in sg_read()
550 sg_remove_request(sfp, srp); in sg_read()
558 sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) in sg_new_read() argument
560 sg_io_hdr_t *hp = &srp->header; in sg_new_read()
576 (srp->sense_b[0] & 0x70) == 0x70) { in sg_new_read()
579 len = 8 + (int) srp->sense_b[7]; /* Additional sense length field */ in sg_new_read()
581 if (copy_to_user(hp->sbp, srp->sense_b, len)) { in sg_new_read()
593 err2 = sg_finish_rem_req(srp); in sg_new_read()
594 sg_remove_request(sfp, srp); in sg_new_read()
606 Sg_request *srp; in sg_write() local
641 if (!(srp = sg_add_request(sfp))) { in sg_write()
664 sg_remove_request(sfp, srp); in sg_write()
667 hp = &srp->header; in sg_write()
689 sg_remove_request(sfp, srp); in sg_write()
707 k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking); in sg_write()
717 Sg_request *srp; in sg_new_write() local
727 if (!(srp = sg_add_request(sfp))) { in sg_new_write()
732 srp->sg_io_owned = sg_io_owned; in sg_new_write()
733 hp = &srp->header; in sg_new_write()
735 sg_remove_request(sfp, srp); in sg_new_write()
739 sg_remove_request(sfp, srp); in sg_new_write()
744 sg_remove_request(sfp, srp); in sg_new_write()
748 sg_remove_request(sfp, srp); in sg_new_write()
752 sg_remove_request(sfp, srp); in sg_new_write()
756 ul_timeout = msecs_to_jiffies(srp->header.timeout); in sg_new_write()
759 sg_remove_request(sfp, srp); in sg_new_write()
763 sg_remove_request(sfp, srp); in sg_new_write()
767 sg_remove_request(sfp, srp); in sg_new_write()
770 k = sg_common_write(sfp, srp, cmnd, timeout, blocking); in sg_new_write()
774 *o_srp = srp; in sg_new_write()
779 sg_common_write(Sg_fd * sfp, Sg_request * srp, in sg_common_write() argument
784 sg_io_hdr_t *hp = &srp->header; in sg_common_write()
786 srp->data.cmd_opcode = cmnd[0]; /* hold opcode of command */ in sg_common_write()
799 sg_remove_request(sfp, srp); in sg_common_write()
803 k = sg_start_req(srp, cmnd); in sg_common_write()
807 sg_finish_rem_req(srp); in sg_common_write()
808 sg_remove_request(sfp, srp); in sg_common_write()
812 if (srp->bio) { in sg_common_write()
813 blk_mq_free_request(srp->rq); in sg_common_write()
814 srp->rq = NULL; in sg_common_write()
817 sg_finish_rem_req(srp); in sg_common_write()
818 sg_remove_request(sfp, srp); in sg_common_write()
829 srp->rq->timeout = timeout; in sg_common_write()
831 srp->rq->end_io = sg_rq_end_io; in sg_common_write()
832 blk_execute_rq_nowait(srp->rq, at_head); in sg_common_write()
836 static int srp_done(Sg_fd *sfp, Sg_request *srp) in srp_done() argument
842 ret = srp->done; in srp_done()
859 Sg_request *srp; in sg_fill_request_table() local
864 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_fill_request_table()
867 rinfo[val].req_state = srp->done + 1; in sg_fill_request_table()
869 srp->header.masked_status & in sg_fill_request_table()
870 srp->header.host_status & in sg_fill_request_table()
871 srp->header.driver_status; in sg_fill_request_table()
872 if (srp->done) in sg_fill_request_table()
874 srp->header.duration; in sg_fill_request_table()
878 (ms > srp->header.duration) ? in sg_fill_request_table()
879 (ms - srp->header.duration) : 0; in sg_fill_request_table()
881 rinfo[val].orphan = srp->orphan; in sg_fill_request_table()
882 rinfo[val].sg_io_owned = srp->sg_io_owned; in sg_fill_request_table()
883 rinfo[val].pack_id = srp->header.pack_id; in sg_fill_request_table()
884 rinfo[val].usr_ptr = srp->header.usr_ptr; in sg_fill_request_table()
922 Sg_request *srp; in sg_ioctl_common() local
936 1, read_only, 1, &srp); in sg_ioctl_common()
940 srp_done(sfp, srp)); in sg_ioctl_common()
942 if (srp->done) { in sg_ioctl_common()
943 srp->done = 2; in sg_ioctl_common()
945 result = sg_new_read(sfp, p, SZ_SG_IO_HDR, srp); in sg_ioctl_common()
948 srp->orphan = 1; in sg_ioctl_common()
1002 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_ioctl_common()
1003 if ((1 == srp->done) && (!srp->sg_io_owned)) { in sg_ioctl_common()
1006 return put_user(srp->header.pack_id, ip); in sg_ioctl_common()
1014 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_ioctl_common()
1015 if ((1 == srp->done) && (!srp->sg_io_owned)) in sg_ioctl_common()
1172 Sg_request *srp; in sg_poll() local
1184 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_poll()
1186 if ((0 == res) && (1 == srp->done) && (!srp->sg_io_owned)) in sg_poll()
1303 struct sg_request *srp = container_of(work, struct sg_request, ew.work); in sg_rq_end_io_usercontext() local
1304 struct sg_fd *sfp = srp->parentfp; in sg_rq_end_io_usercontext()
1306 sg_finish_rem_req(srp); in sg_rq_end_io_usercontext()
1307 sg_remove_request(sfp, srp); in sg_rq_end_io_usercontext()
1319 struct sg_request *srp = rq->end_io_data; in sg_rq_end_io() local
1327 if (WARN_ON(srp->done != 0)) in sg_rq_end_io()
1330 sfp = srp->parentfp; in sg_rq_end_io()
1344 srp->header.pack_id, result)); in sg_rq_end_io()
1345 srp->header.resid = resid; in sg_rq_end_io()
1347 srp->header.duration = (ms > srp->header.duration) ? in sg_rq_end_io()
1348 (ms - srp->header.duration) : 0; in sg_rq_end_io()
1352 srp->header.status = 0xff & result; in sg_rq_end_io()
1353 srp->header.masked_status = sg_status_byte(result); in sg_rq_end_io()
1354 srp->header.msg_status = COMMAND_COMPLETE; in sg_rq_end_io()
1355 srp->header.host_status = host_byte(result); in sg_rq_end_io()
1356 srp->header.driver_status = driver_byte(result); in sg_rq_end_io()
1358 ((CHECK_CONDITION == srp->header.masked_status) || in sg_rq_end_io()
1359 (COMMAND_TERMINATED == srp->header.masked_status))) in sg_rq_end_io()
1376 memcpy(srp->sense_b, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); in sg_rq_end_io()
1378 /* Rely on write phase to clean out srp status values, so no "else" */ in sg_rq_end_io()
1386 srp->rq = NULL; in sg_rq_end_io()
1390 if (unlikely(srp->orphan)) { in sg_rq_end_io()
1392 srp->sg_io_owned = 0; in sg_rq_end_io()
1396 srp->done = done; in sg_rq_end_io()
1407 INIT_WORK(&srp->ew.work, sg_rq_end_io_usercontext); in sg_rq_end_io()
1408 schedule_work(&srp->ew.work); in sg_rq_end_io()
1727 sg_start_req(Sg_request *srp, unsigned char *cmd) in sg_start_req() argument
1731 Sg_fd *sfp = srp->parentfp; in sg_start_req()
1732 sg_io_hdr_t *hp = &srp->header; in sg_start_req()
1736 Sg_scatter_hold *req_schp = &srp->data; in sg_start_req()
1772 srp->rq = rq; in sg_start_req()
1773 rq->end_io_data = srp; in sg_start_req()
1791 sg_link_reserve(sfp, srp, dxfer_len); in sg_start_req()
1821 srp->bio = rq->bio; in sg_start_req()
1832 sg_finish_rem_req(Sg_request *srp) in sg_finish_rem_req() argument
1836 Sg_fd *sfp = srp->parentfp; in sg_finish_rem_req()
1837 Sg_scatter_hold *req_schp = &srp->data; in sg_finish_rem_req()
1841 (int) srp->res_used)); in sg_finish_rem_req()
1842 if (srp->bio) in sg_finish_rem_req()
1843 ret = blk_rq_unmap_user(srp->bio); in sg_finish_rem_req()
1845 if (srp->rq) in sg_finish_rem_req()
1846 blk_mq_free_request(srp->rq); in sg_finish_rem_req()
1848 if (srp->res_used) in sg_finish_rem_req()
1849 sg_unlink_reserve(sfp, srp); in sg_finish_rem_req()
1971 sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) in sg_read_oxfer() argument
1973 Sg_scatter_hold *schp = &srp->data; in sg_read_oxfer()
1976 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, srp->parentfp->parentdp, in sg_read_oxfer()
2022 sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) in sg_link_reserve() argument
2024 Sg_scatter_hold *req_schp = &srp->data; in sg_link_reserve()
2028 srp->res_used = 1; in sg_link_reserve()
2053 sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) in sg_unlink_reserve() argument
2055 Sg_scatter_hold *req_schp = &srp->data; in sg_unlink_reserve()
2057 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, srp->parentfp->parentdp, in sg_unlink_reserve()
2065 srp->res_used = 0; in sg_unlink_reserve()
2132 sg_remove_request(Sg_fd * sfp, Sg_request * srp) in sg_remove_request() argument
2137 if (!sfp || !srp || list_empty(&sfp->rq_list)) in sg_remove_request()
2140 if (!list_empty(&srp->entry)) { in sg_remove_request()
2141 list_del(&srp->entry); in sg_remove_request()
2142 srp->parentfp = NULL; in sg_remove_request()
2211 Sg_request *srp; in sg_remove_sfp_usercontext() local
2217 srp = list_first_entry(&sfp->rq_list, Sg_request, entry); in sg_remove_sfp_usercontext()
2218 sg_finish_rem_req(srp); in sg_remove_sfp_usercontext()
2219 list_del(&srp->entry); in sg_remove_sfp_usercontext()
2220 srp->parentfp = NULL; in sg_remove_sfp_usercontext()
2530 Sg_request *srp; in sg_proc_debug_helper() local
2548 list_for_each_entry(srp, &fp->rq_list, entry) { in sg_proc_debug_helper()
2549 hp = &srp->header; in sg_proc_debug_helper()
2551 if (srp->res_used) { in sg_proc_debug_helper()
2564 blen = srp->data.bufflen; in sg_proc_debug_helper()
2565 usg = srp->data.k_use_sg; in sg_proc_debug_helper()
2566 seq_puts(s, srp->done ? in sg_proc_debug_helper()
2567 ((1 == srp->done) ? "rcv:" : "fin:") in sg_proc_debug_helper()
2570 srp->header.pack_id, blen); in sg_proc_debug_helper()
2571 if (srp->done) in sg_proc_debug_helper()
2581 (int) srp->data.cmd_opcode); in sg_proc_debug_helper()