[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.2 / 0107-target-Set-additional-sense-length-field-in-sense-da.patch
1 From 894360c2f0b3fca21a3e663f60746476a185f100 Mon Sep 17 00:00:00 2001
2 From: Roland Dreier <roland@purestorage.com>
3 Date: Tue, 13 Dec 2011 14:55:33 -0800
4 Subject: [PATCH 107/130] target: Set additional sense length field in sense
5 data
7 commit 895f3022523361e9b383cf48f51feb1f7d5e7e53 upstream.
9 The target code was not setting the additional sense length field in the
10 sense data it returned, which meant that at least the Linux stack
11 ignored the ASC/ASCQ fields. For example, without this patch, on a
12 tcm_loop device:
14 # sg_raw -v /dev/sda 2 0 0 0 0 0
16 gives
18 cdb to send: 02 00 00 00 00 00
19 SCSI Status: Check Condition
21 Sense Information:
22 Fixed format, current; Sense key: Illegal Request
23 Raw sense data (in hex):
24 70 00 05 00 00 00 00 00
26 while after the patch we correctly get the following (which matches what
27 a regular disk returns):
29 cdb to send: 02 00 00 00 00 00
30 SCSI Status: Check Condition
32 Sense Information:
33 Fixed format, current; Sense key: Illegal Request
34 Additional sense: Invalid command operation code
35 Raw sense data (in hex):
36 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00
37 00 00
39 Signed-off-by: Roland Dreier <roland@purestorage.com>
40 Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
41 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
42 ---
43 drivers/target/target_core_transport.c | 14 ++++++++++++++
44 include/target/target_core_base.h | 1 +
45 2 files changed, 15 insertions(+), 0 deletions(-)
47 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
48 index 0257658..e87d0eb 100644
49 --- a/drivers/target/target_core_transport.c
50 +++ b/drivers/target/target_core_transport.c
51 @@ -4353,6 +4353,7 @@ int transport_send_check_condition_and_sense(
52 case TCM_NON_EXISTENT_LUN:
53 /* CURRENT ERROR */
54 buffer[offset] = 0x70;
55 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
56 /* ILLEGAL REQUEST */
57 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
58 /* LOGICAL UNIT NOT SUPPORTED */
59 @@ -4362,6 +4363,7 @@ int transport_send_check_condition_and_sense(
60 case TCM_SECTOR_COUNT_TOO_MANY:
61 /* CURRENT ERROR */
62 buffer[offset] = 0x70;
63 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
64 /* ILLEGAL REQUEST */
65 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
66 /* INVALID COMMAND OPERATION CODE */
67 @@ -4370,6 +4372,7 @@ int transport_send_check_condition_and_sense(
68 case TCM_UNKNOWN_MODE_PAGE:
69 /* CURRENT ERROR */
70 buffer[offset] = 0x70;
71 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
72 /* ILLEGAL REQUEST */
73 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
74 /* INVALID FIELD IN CDB */
75 @@ -4378,6 +4381,7 @@ int transport_send_check_condition_and_sense(
76 case TCM_CHECK_CONDITION_ABORT_CMD:
77 /* CURRENT ERROR */
78 buffer[offset] = 0x70;
79 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
80 /* ABORTED COMMAND */
81 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
82 /* BUS DEVICE RESET FUNCTION OCCURRED */
83 @@ -4387,6 +4391,7 @@ int transport_send_check_condition_and_sense(
84 case TCM_INCORRECT_AMOUNT_OF_DATA:
85 /* CURRENT ERROR */
86 buffer[offset] = 0x70;
87 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
88 /* ABORTED COMMAND */
89 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
90 /* WRITE ERROR */
91 @@ -4397,6 +4402,7 @@ int transport_send_check_condition_and_sense(
92 case TCM_INVALID_CDB_FIELD:
93 /* CURRENT ERROR */
94 buffer[offset] = 0x70;
95 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
96 /* ABORTED COMMAND */
97 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
98 /* INVALID FIELD IN CDB */
99 @@ -4405,6 +4411,7 @@ int transport_send_check_condition_and_sense(
100 case TCM_INVALID_PARAMETER_LIST:
101 /* CURRENT ERROR */
102 buffer[offset] = 0x70;
103 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
104 /* ABORTED COMMAND */
105 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
106 /* INVALID FIELD IN PARAMETER LIST */
107 @@ -4413,6 +4420,7 @@ int transport_send_check_condition_and_sense(
108 case TCM_UNEXPECTED_UNSOLICITED_DATA:
109 /* CURRENT ERROR */
110 buffer[offset] = 0x70;
111 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
112 /* ABORTED COMMAND */
113 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
114 /* WRITE ERROR */
115 @@ -4423,6 +4431,7 @@ int transport_send_check_condition_and_sense(
116 case TCM_SERVICE_CRC_ERROR:
117 /* CURRENT ERROR */
118 buffer[offset] = 0x70;
119 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
120 /* ABORTED COMMAND */
121 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
122 /* PROTOCOL SERVICE CRC ERROR */
123 @@ -4433,6 +4442,7 @@ int transport_send_check_condition_and_sense(
124 case TCM_SNACK_REJECTED:
125 /* CURRENT ERROR */
126 buffer[offset] = 0x70;
127 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
128 /* ABORTED COMMAND */
129 buffer[offset+SPC_SENSE_KEY_OFFSET] = ABORTED_COMMAND;
130 /* READ ERROR */
131 @@ -4443,6 +4453,7 @@ int transport_send_check_condition_and_sense(
132 case TCM_WRITE_PROTECTED:
133 /* CURRENT ERROR */
134 buffer[offset] = 0x70;
135 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
136 /* DATA PROTECT */
137 buffer[offset+SPC_SENSE_KEY_OFFSET] = DATA_PROTECT;
138 /* WRITE PROTECTED */
139 @@ -4451,6 +4462,7 @@ int transport_send_check_condition_and_sense(
140 case TCM_CHECK_CONDITION_UNIT_ATTENTION:
141 /* CURRENT ERROR */
142 buffer[offset] = 0x70;
143 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
144 /* UNIT ATTENTION */
145 buffer[offset+SPC_SENSE_KEY_OFFSET] = UNIT_ATTENTION;
146 core_scsi3_ua_for_check_condition(cmd, &asc, &ascq);
147 @@ -4460,6 +4472,7 @@ int transport_send_check_condition_and_sense(
148 case TCM_CHECK_CONDITION_NOT_READY:
149 /* CURRENT ERROR */
150 buffer[offset] = 0x70;
151 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
152 /* Not Ready */
153 buffer[offset+SPC_SENSE_KEY_OFFSET] = NOT_READY;
154 transport_get_sense_codes(cmd, &asc, &ascq);
155 @@ -4470,6 +4483,7 @@ int transport_send_check_condition_and_sense(
156 default:
157 /* CURRENT ERROR */
158 buffer[offset] = 0x70;
159 + buffer[offset+SPC_ADD_SENSE_LEN_OFFSET] = 10;
160 /* ILLEGAL REQUEST */
161 buffer[offset+SPC_SENSE_KEY_OFFSET] = ILLEGAL_REQUEST;
162 /* LOGICAL UNIT COMMUNICATION FAILURE */
163 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
164 index 6873c7d..a79886c 100644
165 --- a/include/target/target_core_base.h
166 +++ b/include/target/target_core_base.h
167 @@ -34,6 +34,7 @@
168 #define TRANSPORT_SENSE_BUFFER SCSI_SENSE_BUFFERSIZE
169 /* Used by transport_send_check_condition_and_sense() */
170 #define SPC_SENSE_KEY_OFFSET 2
171 +#define SPC_ADD_SENSE_LEN_OFFSET 7
172 #define SPC_ASC_KEY_OFFSET 12
173 #define SPC_ASCQ_KEY_OFFSET 13
174 #define TRANSPORT_IQN_LEN 224
175 --
176 1.7.7.4