51 ((cmd->
se_cmd.data_length >
52 conn->
sess->sess_ops->FirstBurstLength) ?
53 conn->
sess->sess_ops->FirstBurstLength : cmd->
se_cmd.data_length));
57 if (!conn->
sess->sess_ops->DataSequenceInOrder)
63 conn->
sess->sess_ops->MaxBurstLength) ?
65 conn->
sess->sess_ops->MaxBurstLength) : cmd->
se_cmd.data_length;
69 conn->
sess->sess_ops->MaxBurstLength) >=
72 conn->
sess->sess_ops->MaxBurstLength);
76 static int iscsit_dataout_within_command_recovery_check(
96 if (conn->
sess->sess_ops->DataSequenceInOrder) {
114 if (conn->
sess->sess_ops->DataPDUInOrder) {
137 pr_err(
"Dumping DataOUT PDU Offset: %u Length: %d DataSN:"
142 static int iscsit_dataout_check_unsolicited_sequence(
154 pr_err(
"Command ITT: 0x%08x with Offset: %u,"
155 " Length: %u outside of Unsolicited Sequence %u:%u while"
164 if (first_burst_len > conn->
sess->sess_ops->FirstBurstLength) {
165 pr_err(
"Total %u bytes exceeds FirstBurstLength: %u"
166 " for this Unsolicited DataOut Burst.\n",
167 first_burst_len, conn->
sess->sess_ops->FirstBurstLength);
183 if (!conn->
sess->sess_ops->DataPDUInOrder)
186 if ((first_burst_len != cmd->
se_cmd.data_length) &&
187 (first_burst_len != conn->
sess->sess_ops->FirstBurstLength)) {
188 pr_err(
"Unsolicited non-immediate data"
189 " received %u does not equal FirstBurstLength: %u, and"
190 " does not equal ExpXferLen %u.\n", first_burst_len,
191 conn->
sess->sess_ops->FirstBurstLength,
198 if (first_burst_len == conn->
sess->sess_ops->FirstBurstLength) {
199 pr_err(
"Command ITT: 0x%08x reached"
200 " FirstBurstLength: %u, but ISCSI_FLAG_CMD_FINAL is not set. protocol"
202 conn->
sess->sess_ops->FirstBurstLength);
205 if (first_burst_len == cmd->
se_cmd.data_length) {
206 pr_err(
"Command ITT: 0x%08x reached"
207 " ExpXferLen: %u, but ISCSI_FLAG_CMD_FINAL is not set. protocol"
217 static int iscsit_dataout_check_sequence(
234 if (conn->
sess->sess_ops->DataSequenceInOrder) {
242 pr_err(
"Command ITT: 0x%08x with Offset: %u,"
243 " Length: %u outside of Sequence %u:%u while"
273 if (next_burst_len > conn->
sess->sess_ops->MaxBurstLength) {
274 pr_err(
"Command ITT: 0x%08x, NextBurstLength: %u and"
275 " Length: %u exceeds MaxBurstLength: %u. protocol"
277 (next_burst_len - payload_length),
278 payload_length, conn->
sess->sess_ops->MaxBurstLength);
292 if (!conn->
sess->sess_ops->DataPDUInOrder)
295 if (conn->
sess->sess_ops->DataSequenceInOrder) {
296 if ((next_burst_len <
297 conn->
sess->sess_ops->MaxBurstLength) &&
299 cmd->
se_cmd.data_length)) {
300 pr_err(
"Command ITT: 0x%08x set ISCSI_FLAG_CMD_FINAL"
301 " before end of DataOUT sequence, protocol"
306 if (next_burst_len < seq->
xfer_len) {
307 pr_err(
"Command ITT: 0x%08x set ISCSI_FLAG_CMD_FINAL"
308 " before end of DataOUT sequence, protocol"
314 if (conn->
sess->sess_ops->DataSequenceInOrder) {
315 if (next_burst_len ==
316 conn->
sess->sess_ops->MaxBurstLength) {
317 pr_err(
"Command ITT: 0x%08x reached"
318 " MaxBurstLength: %u, but ISCSI_FLAG_CMD_FINAL is"
320 conn->
sess->sess_ops->MaxBurstLength);
324 cmd->
se_cmd.data_length) {
325 pr_err(
"Command ITT: 0x%08x reached"
326 " last DataOUT PDU in sequence but ISCSI_FLAG_"
327 "CMD_FINAL is not set, protocol error.\n",
332 if (next_burst_len == seq->
xfer_len) {
333 pr_err(
"Command ITT: 0x%08x reached"
334 " last DataOUT PDU in sequence but ISCSI_FLAG_"
335 "CMD_FINAL is not set, protocol error.\n",
346 static int iscsit_dataout_check_datasn(
350 int dump = 0, recovery = 0;
364 if (conn->
sess->sess_ops->DataSequenceInOrder)
372 pr_err(
"Command ITT: 0x%08x, received DataSN: 0x%08x"
378 pr_err(
"Command ITT: 0x%08x, received DataSN: 0x%08x"
379 " lower than expected 0x%08x, discarding payload.\n",
388 if (!conn->
sess->sess_ops->ErrorRecoveryLevel) {
389 pr_err(
"Unable to perform within-command recovery"
401 static int iscsit_dataout_pre_datapduinorder_yes(
405 int dump = 0, recovery = 0;
419 if (conn->
sess->sess_ops->DataSequenceInOrder) {
421 pr_err(
"Command ITT: 0x%08x, received offset"
431 pr_err(
"Command ITT: 0x%08x, received offset"
437 pr_err(
"Command ITT: 0x%08x, received offset"
438 " %u less than expected %u, discarding payload.\n",
449 if (!conn->
sess->sess_ops->ErrorRecoveryLevel) {
450 pr_err(
"Unable to perform within-command recovery"
463 static int iscsit_dataout_pre_datapduinorder_no(
484 pr_err(
"Command ITT: 0x%08x received already gotten"
514 static int iscsit_dataout_update_datapduinorder_no(
547 static int iscsit_dataout_post_crc_passed(
551 int ret, send_r2t = 0;
559 conn->
sess->sess_ops->FirstBurstLength) {
566 if (!conn->
sess->sess_ops->DataPDUInOrder) {
567 ret = iscsit_dataout_update_datapduinorder_no(cmd,
576 if (conn->
sess->sess_ops->DataSequenceInOrder)
591 if (conn->
sess->sess_ops->DataSequenceInOrder) {
593 conn->
sess->sess_ops->MaxBurstLength) {
594 if (iscsit_dataout_update_r2t(cmd,
601 if (!conn->
sess->sess_ops->DataPDUInOrder) {
602 ret = iscsit_dataout_update_datapduinorder_no(
619 if (iscsit_dataout_update_r2t(cmd,
626 if (!conn->
sess->sess_ops->DataPDUInOrder) {
627 ret = iscsit_dataout_update_datapduinorder_no(
645 if (send_r2t && conn->
sess->sess_ops->DataSequenceInOrder)
658 static int iscsit_dataout_post_crc_failed(
667 if (conn->
sess->sess_ops->DataPDUInOrder)
703 ret = iscsit_dataout_within_command_recovery_check(cmd, buf);
708 ret = iscsit_dataout_check_datasn(cmd, buf);
714 ret = iscsit_dataout_check_unsolicited_sequence(cmd, buf);
719 ret = iscsit_dataout_check_sequence(cmd, buf);
725 return (conn->
sess->sess_ops->DataPDUInOrder) ?
726 iscsit_dataout_pre_datapduinorder_yes(cmd, buf) :
727 iscsit_dataout_pre_datapduinorder_no(cmd, buf);
743 if (!data_crc_failed)
744 return iscsit_dataout_post_crc_passed(cmd, buf);
746 if (!conn->
sess->sess_ops->ErrorRecoveryLevel) {
747 pr_err(
"Unable to recover from DataOUT CRC"
748 " failure while ERL=0, closing session.\n");
756 return iscsit_dataout_post_crc_failed(cmd, buf);
760 static void iscsit_handle_time2retain_timeout(
unsigned long data)
772 pr_err(
"Exiting Time2Retain handler because"
773 " session_reinstatement=1\n");
779 pr_err(
"Time2Retain timer expired for SID: %u, cleaning up"
780 " iSCSI session.\n", sess->
sid);
787 (
void *)sess->
sess_ops->InitiatorName);
817 pr_debug(
"Starting Time2Retain timer for %u seconds on"
818 " SID: %u\n", sess->
sess_ops->DefaultTime2Retain, sess->
sid);
851 pr_debug(
"Stopped Time2Retain Timer for SID: %u\n",
915 pr_debug(
"Falling back to ErrorRecoveryLevel=0 for SID:"
921 static void iscsit_handle_connection_cleanup(
struct iscsi_conn *conn)
925 if ((sess->
sess_ops->ErrorRecoveryLevel == 2) &&
930 pr_debug(
"Performing cleanup for failed iSCSI"
931 " Connection ID: %hu from %s\n", conn->
cid,
957 pr_debug(
"Moving to TARG_CONN_STATE_CLEANUP_WAIT.\n");
961 iscsit_handle_connection_cleanup(conn);
986 pr_err(
"Remaining bytes to OFMarker: %u exceeds"
987 " OFMarkInt bytes: %u.\n", conn->
of_marker,
992 pr_debug(
"Advancing %u bytes in TCP stream to get to the"
1002 conn->
conn_ops->MaxRecvDataSegmentLength)) {
1003 pr_err(
"OfMarker offset value: %u exceeds limit.\n",
1008 pr_debug(
"Discarding %u bytes of TCP stream to get to the"