diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2019-01-14 02:42:05 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2019-01-14 02:42:05 +0000 |
commit | 0b07dc9a41e495604add3b006c040b36e4ea50c7 (patch) | |
tree | 0cb11adaa2f3f93c3be95cf28de486d7dbe716d9 /include | |
parent | 2433a22138f1b508c2765aa8499456cd6138a200 (diff) | |
download | sg3_utils-0b07dc9a41e495604add3b006c040b36e4ea50c7.tar.gz |
sg_lib: tweak sg_pt interface to better handle bidi; sg_cmds_process_resp(): two arguments removed
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@805 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'include')
-rw-r--r-- | include/sg_cmds_basic.h | 6 | ||||
-rw-r--r-- | include/sg_lib_data.h | 10 | ||||
-rw-r--r-- | include/sg_pt.h | 21 |
3 files changed, 29 insertions, 8 deletions
diff --git a/include/sg_cmds_basic.h b/include/sg_cmds_basic.h index d6ded5a4..e40d1011 100644 --- a/include/sg_cmds_basic.h +++ b/include/sg_cmds_basic.h @@ -2,7 +2,7 @@ #define SG_CMDS_BASIC_H /* - * Copyright (c) 2004-2018 Douglas Gilbert. + * Copyright (c) 2004-2019 Douglas Gilbert. * All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the BSD_LICENSE file. @@ -343,8 +343,8 @@ const char * sg_cmds_version(); * output via 'o_sense_cat' pointer (if not NULL). Note that several sense * categories also have data in bytes received; -2 is still returned. */ int sg_cmds_process_resp(struct sg_pt_base * ptvp, const char * leadin, - int pt_res, int mx_di_len, const uint8_t * sense_b, - bool noisy, int verbose, int * o_sense_cat); + int pt_res, bool noisy, int verbose, + int * o_sense_cat); /* NVMe devices use a different command set. This function will return true * if the device associated with 'pvtp' is a NVME device, else it will diff --git a/include/sg_lib_data.h b/include/sg_lib_data.h index 9f573b97..2f142a22 100644 --- a/include/sg_lib_data.h +++ b/include/sg_lib_data.h @@ -2,7 +2,7 @@ #define SG_LIB_DATA_H /* - * Copyright (c) 2007-2018 Douglas Gilbert. + * Copyright (c) 2007-2019 Douglas Gilbert. * All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the BSD_LICENSE file. @@ -88,6 +88,14 @@ struct sg_lib_4tuple_u8 { uint8_t t4; }; +struct sg_cmd_response_t { + int din_len; + int dout_len; + int resid; + int resid2; + const uint8_t * sbp; +}; + extern const char * sg_lib_version_str; diff --git a/include/sg_pt.h b/include/sg_pt.h index b75a8d46..00a43096 100644 --- a/include/sg_pt.h +++ b/include/sg_pt.h @@ -2,7 +2,7 @@ #define SG_PT_H /* - * Copyright (c) 2005-2018 Douglas Gilbert. + * Copyright (c) 2005-2019 Douglas Gilbert. * All rights reserved. * Use of this source code is governed by a BSD-style * license that can be found in the BSD_LICENSE file. @@ -172,9 +172,12 @@ int do_scsi_pt(struct sg_pt_base * objp, int fd, int timeout_secs, * belongs to. */ int get_scsi_pt_result_category(const struct sg_pt_base * objp); -/* If not available return 0 which implies there is no residual - * value. If supported the number of bytes actually sent back by - * the device is 'dxfer_ilen - get_scsi_pt_len()' bytes. */ +/* If not available return 0 which implies there is no residual value. If + * supported it is the number of bytes requested to transfer less the + * number actually transferred. This it typically important for data-in + * transfers. For data-out (only) transfers, the 'dout_req_len - + * dout_act_len' is returned. For bidi transfer the data-in residual is + * returned. */ int get_scsi_pt_resid(const struct sg_pt_base * objp); /* Returns SCSI status value (from device that received the command). If an @@ -190,6 +193,7 @@ uint32_t get_pt_result(const struct sg_pt_base * objp); /* Actual sense length returned. If sense data is present but actual sense length is not known, return 'max_sense_len' */ int get_scsi_pt_sense_len(const struct sg_pt_base * objp); +uint8_t * get_scsi_pt_sense_buf(const struct sg_pt_base * objp); /* If not available return 0 (for success). */ int get_scsi_pt_os_err(const struct sg_pt_base * objp); @@ -207,6 +211,15 @@ char * get_scsi_pt_transport_err_str(const struct sg_pt_base * objp, * command. */ int get_scsi_pt_duration_ms(const struct sg_pt_base * objp); +/* The two functions yield requested and actual data transfer lengths in + * bytes. The second argument is a pointer to the data-in length; the third + * argument is a pointer to the data-out length. The pointers may be NULL. + * The _actual_ values are related to resid (residual count from DMA) */ +void get_pt_req_lengths(const struct sg_pt_base * objp, int * req_dinp, + int * req_doutp); +void get_pt_actual_lengths(const struct sg_pt_base * objp, int * act_dinp, + int * act_doutp); + /* Return true if device associated with 'objp' uses NVMe command set. To * be useful (in modifying the type of command sent (SCSI or NVMe) then * construct_scsi_pt_obj_with_fd() should be used followed by an invocation |