21 #include <linux/list.h>
40 #define PRINT_BUFF(buff, len) \
44 pr_debug("%d:\n", __LINE__); \
45 for (zzz = 0; zzz < len; zzz++) { \
46 if (zzz % 16 == 0) { \
49 pr_debug("%4i: ", zzz); \
51 pr_debug("%02x ", (unsigned char) (buff)[zzz]); \
74 pr_err(
"Unable to allocate memory for struct iscsi_r2t.\n");
101 if ((r2t->
offset <= offset) &&
109 pr_err(
"Unable to locate R2T for Offset: %u, Length:"
110 " %u\n", offset, length);
127 pr_err(
"Unable to locate next R2T to send for ITT:"
161 pr_err(
"Unable to allocate memory for struct iscsi_cmd.\n");
186 if (cmd->
seq_list[i].seq_send_order == seq_send_order)
197 pr_err(
"struct iscsi_cmd->seq_list is NULL!\n");
221 if (r2t->
r2t_sn == r2t_sn) {
231 static inline int iscsit_check_received_cmdsn(
struct iscsi_session *sess,
u32 cmdsn)
242 pr_err(
"Received CmdSN: 0x%08x is greater than"
243 " MaxCmdSN: 0x%08x, protocol error.\n", cmdsn,
249 pr_debug(
"Received CmdSN matches ExpCmdSN,"
250 " incremented ExpCmdSN to: 0x%08x\n",
254 }
else if (iscsi_sna_gt(cmdsn, sess->
exp_cmd_sn)) {
255 pr_debug(
"Received CmdSN: 0x%08x is greater"
256 " than ExpCmdSN: 0x%08x, not acknowledging.\n",
261 pr_err(
"Received CmdSN: 0x%08x is less than"
262 " ExpCmdSN: 0x%08x, ignoring.\n", cmdsn,
284 cmdsn_ret = iscsit_check_received_cmdsn(conn->
sess,
be32_to_cpu(cmdsn));
288 if ((ret >= 0) && !list_empty(&conn->
sess->sess_ooo_cmdsn_list))
315 if (conn->
sess->sess_ops->InitialR2T) {
316 pr_err(
"Received unexpected unsolicited data"
317 " while InitialR2T=Yes, protocol error.\n");
324 conn->
sess->sess_ops->FirstBurstLength) {
325 pr_err(
"Total %u bytes exceeds FirstBurstLength: %u"
326 " for this Unsolicited DataOut Burst.\n",
328 conn->
sess->sess_ops->FirstBurstLength);
339 conn->
sess->sess_ops->FirstBurstLength)) {
340 pr_err(
"Unsolicited non-immediate data received %u"
341 " does not equal FirstBurstLength: %u, and does"
342 " not equal ExpXferLen %u.\n",
344 conn->
sess->sess_ops->FirstBurstLength, cmd->
se_cmd.data_length);
367 pr_err(
"Unable to locate ITT: 0x%08x on CID: %hu",
368 init_task_tag, conn->
cid);
388 pr_err(
"Unable to locate ITT: 0x%08x on CID: %hu,"
389 " dumping payload\n", init_task_tag, conn->
cid);
411 pr_err(
"Unable to locate TTT: 0x%08x on CID: %hu\n",
412 targ_xfer_tag, conn->
cid);
477 pr_err(
"Unable to allocate memory for"
478 " struct iscsi_queue_req\n");
514 static void iscsit_remove_cmd_from_immediate_queue(
537 pr_err(
"ITT: 0x%08x immed_queue_count: %d\n",
552 pr_err(
"Unable to allocate memory for"
553 " struct iscsi_queue_req\n");
589 static void iscsit_remove_cmd_from_response_queue(
613 pr_err(
"ITT: 0x%08x response_queue_count: %d\n",
677 iscsit_remove_cmd_from_immediate_queue(cmd, conn);
678 iscsit_remove_cmd_from_response_queue(cmd, conn);
753 int login_ifmarker_count = 0, login_ofmarker_count = 0, next_marker = 0;
769 login_ofmarker_count = (conn->
of_marker / OFMarkInt);
770 next_marker = (OFMarkInt * (login_ofmarker_count + 1)) +
775 pr_debug(
"Setting OFMarker value to %u based on Initial"
776 " Markerless Interval.\n", conn->
of_marker);
783 login_ifmarker_count = (conn->
if_marker / IFMarkInt);
784 next_marker = (IFMarkInt * (login_ifmarker_count + 1)) +
788 pr_debug(
"Setting IFMarker value to %u based on Initial"
789 " Markerless Interval.\n", conn->
if_marker);
801 if ((conn->
cid == cid) &&
819 if (conn->
cid == cid) {
864 static int iscsit_add_nopin(
struct iscsi_conn *conn,
int want_response)
877 spin_lock_bh(&conn->
sess->ttt_lock);
882 spin_unlock_bh(&conn->
sess->ttt_lock);
895 static void iscsit_handle_nopin_response_timeout(
unsigned long data)
908 pr_debug(
"Did not receive response to NOPIN on CID: %hu on"
909 " SID: %u, failing connection.\n", conn->
cid,
921 conn->
sess->sess_ops->InitiatorName);
925 conn->
sess->conn_timeout_errors++;
973 pr_debug(
"Started NOPIN Response Timer on CID: %d to %u"
995 static void iscsit_handle_nopin_timeout(
unsigned long data)
1010 iscsit_add_nopin(conn, 1);
1033 conn->
nopin_timer.function = iscsit_handle_nopin_timeout;
1038 pr_debug(
"Started NOPIN Timer on CID: %d at %u second"
1061 conn->
nopin_timer.function = iscsit_handle_nopin_timeout;
1066 pr_debug(
"Started NOPIN Timer on CID: %d at %u second"
1093 int tx_sent, tx_size;
1108 tx_sent =
tx_data(conn, &iov[0], iov_count, tx_size);
1109 if (tx_size != tx_sent) {
1110 if (tx_sent == -
EAGAIN) {
1111 pr_err(
"tx_data() returned -EAGAIN\n");
1129 int tx_sent, iov_off;
1139 tx_sent =
tx_data(conn, &iov, 1, tx_hdr_size);
1140 if (tx_hdr_size != tx_sent) {
1141 if (tx_sent == -
EAGAIN) {
1142 pr_err(
"tx_data() returned -EAGAIN\n");
1169 tx_sent = conn->
sock->ops->sendpage(conn->
sock,
1170 sg_page(sg), sg->
offset + offset, sub_len, 0);
1171 if (tx_sent != sub_len) {
1172 if (tx_sent == -
EAGAIN) {
1173 pr_err(
"tcp_sendpage() returned"
1178 pr_err(
"tcp_sendpage() failure: %d\n",
1183 data_len -= sub_len;
1193 if (cmd->
padding != tx_sent) {
1194 if (tx_sent == -
EAGAIN) {
1195 pr_err(
"tx_data() returned -EAGAIN\n");
1208 if (tx_sent == -
EAGAIN) {
1209 pr_err(
"tx_data() returned -EAGAIN\n");
1252 pr_err(
"tx_data returned less than expected\n");
1263 pr_debug(
"-----------------------------[Session Params for"
1264 " SID: %u]-----------------------------\n", sess->
sid);
1273 static int iscsit_do_rx_data(
1277 int data = count->
data_length, rx_loop = 0, total_rx = 0, iov_len;
1289 while (total_rx < data) {
1293 pr_debug(
"rx_loop: %d total_rx: %d\n",
1297 total_rx += rx_loop;
1298 pr_debug(
"rx_loop: %d, total_rx: %d, data: %d\n",
1299 rx_loop, total_rx, data);
1305 static int iscsit_do_tx_data(
1309 int data = count->
data_length, total_tx = 0, tx_loop = 0, iov_len;
1317 pr_err(
"Data length is: %d\n", data);
1326 while (total_tx < data) {
1330 pr_debug(
"tx_loop: %d total_tx %d\n",
1334 total_tx += tx_loop;
1335 pr_debug(
"tx_loop: %d, total_tx: %d, data: %d\n",
1336 tx_loop, total_tx, data);
1359 return iscsit_do_rx_data(conn, &c);
1379 return iscsit_do_tx_data(conn, &c);
1397 spin_lock(&ls->
lock);
1401 spin_unlock(&ls->
lock);
1433 (intrname ? intrname->
value :
"Unknown"));
1441 spin_unlock(&ls->
lock);
1448 if (!conn || !conn->
sess)
1451 tpg = conn->
sess->tpg;