diff options
author | Michael Brown <mcb30@ipxe.org> | 2014-06-02 02:17:28 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2014-06-03 02:04:46 +0100 |
commit | e047811c859bd11777c9a01d7ca89ca948567199 (patch) | |
tree | c84557d88a049527dfc80631dcc3d9cb3bed2380 /src/net | |
parent | d630052e6f44ce215503fb7f20819a1382ebfa9b (diff) | |
download | ipxe-e047811c859bd11777c9a01d7ca89ca948567199.zip ipxe-e047811c859bd11777c9a01d7ca89ca948567199.tar.gz ipxe-e047811c859bd11777c9a01d7ca89ca948567199.tar.bz2 |
[scsi] Improve sense code parsing
Parse the sense data to extract the reponse code, the sense key, the
additional sense code, and the additional sense code qualifier.
Originally-implemented-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/fcp.c | 5 | ||||
-rw-r--r-- | src/net/tcp/iscsi.c | 11 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/net/fcp.c b/src/net/fcp.c index 241b546..9c36a4c 100644 --- a/src/net/fcp.c +++ b/src/net/fcp.c @@ -551,7 +551,6 @@ static int fcpcmd_recv_rsp ( struct fcp_command *fcpcmd, struct fcp_device *fcpdev = fcpcmd->fcpdev; struct scsi_cmd *command = &fcpcmd->command; struct fcp_rsp *rsp = iobuf->data; - struct scsi_sense *sense; struct scsi_rsp response; int rc; @@ -607,8 +606,8 @@ static int fcpcmd_recv_rsp ( struct fcp_command *fcpcmd, if ( rsp->flags & FCP_RSP_RESIDUAL_UNDERRUN ) response.overrun = -response.overrun; } - if ( ( sense = fcp_rsp_sense_data ( rsp ) ) != NULL ) - memcpy ( &response.sense, sense, sizeof ( response.sense ) ); + scsi_parse_sense ( fcp_rsp_sense_data ( rsp ), + fcp_rsp_sense_data_len ( rsp ), &response.sense ); /* Free buffer before sending response, to minimise * out-of-memory errors. diff --git a/src/net/tcp/iscsi.c b/src/net/tcp/iscsi.c index a6fcd25..03c6d0f 100644 --- a/src/net/tcp/iscsi.c +++ b/src/net/tcp/iscsi.c @@ -412,11 +412,12 @@ static int iscsi_rx_scsi_response ( struct iscsi_session *iscsi, = &iscsi->rx_bhs.scsi_response; struct scsi_rsp rsp; uint32_t residual_count; + size_t data_len; int rc; /* Buffer up the PDU data */ if ( ( rc = iscsi_rx_buffered_data ( iscsi, data, len ) ) != 0 ) { - DBGC ( iscsi, "iSCSI %p could not buffer login response: %s\n", + DBGC ( iscsi, "iSCSI %p could not buffer SCSI response: %s\n", iscsi, strerror ( rc ) ); return rc; } @@ -432,9 +433,11 @@ static int iscsi_rx_scsi_response ( struct iscsi_session *iscsi, } else if ( response->flags & ISCSI_DATA_FLAG_UNDERFLOW ) { rsp.overrun = -(residual_count); } - if ( ISCSI_DATA_LEN ( response->lengths ) ) - memcpy ( &rsp.sense, ( iscsi->rx_buffer + 2 ), - sizeof ( rsp.sense ) ); + data_len = ISCSI_DATA_LEN ( response->lengths ); + if ( data_len ) { + scsi_parse_sense ( ( iscsi->rx_buffer + 2 ), ( data_len - 2 ), + &rsp.sense ); + } iscsi_rx_buffered_data_done ( iscsi ); /* Check for errors */ |