Hello,

Attached is the patch for the first kernel TODO item in the TODO list
circulated earlier. I could not send the patch through git send-email, so
have attached it here.

Thanks,
Aastha.

-- 
Aastha Mehta
B.E. (Hons.) Computer Science
BITS Pilani
E-mail: [email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/open-iscsi?hl=en.

From ef75092e47544e126b259114ce87cdf395ca3d9d Mon Sep 17 00:00:00 2001
From: Aastha Mehta <[email protected]>
Date: Mon, 29 Aug 2011 10:18:17 -0700
Subject: [PATCH 1/1] added code to display verbose messages on session connection errors

---
 usr/Makefile                  |    2 +-
 usr/initiator.c               |    8 +++-
 usr/kern_error_table.c        |   81 +++++++++++++++++++++++++++++++++++++++++
 usr/kern_error_table.h        |    5 +++
 utils/fwparam_ibft/prom_lex.c |    2 +-
 5 files changed, 94 insertions(+), 4 deletions(-)
 create mode 100644 usr/kern_error_table.c
 create mode 100644 usr/kern_error_table.h

diff --git a/usr/Makefile b/usr/Makefile
index 3ee0cb4..382139a 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -44,7 +44,7 @@ ISCSI_LIB_SRCS = iscsi_util.o io.o auth.o iscsi_timer.o login.o log.o md5.o \
 	iscsi_net_util.o iscsid_req.o transport.o cxgbi.o be2iscsi.o \
 	initiator_common.o iscsi_err.o $(IPC_OBJ)  $(SYSDEPS_SRCS) $(DCB_OBJ)
 # core initiator files
-INITIATOR_SRCS = initiator.o scsi.o actor.o event_poll.o mgmt_ipc.o
+INITIATOR_SRCS = initiator.o scsi.o actor.o event_poll.o mgmt_ipc.o kern_error_table.o
 
 # fw boot files
 FW_BOOT_SRCS = $(wildcard ../utils/fwparam_ibft/*.o)
diff --git a/usr/initiator.c b/usr/initiator.c
index 0350ff8..a2f412a 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -48,6 +48,8 @@
 #include "sysdeps.h"
 #include "iscsi_err.h"
 
+#include "kern_error_table.h"
+
 #define ISCSI_CONN_ERR_REOPEN_DELAY	3
 #define ISCSI_INTERNAL_ERR_REOPEN_DELAY	5
 
@@ -847,8 +849,10 @@ static void session_conn_error(void *data)
 	iscsi_conn_t *conn = ev_context->conn;
 	iscsi_session_t *session = conn->session;
 
-	log_warning("Kernel reported iSCSI connection %d:%d error (%d) "
-		    "state (%d)", session->id, conn->id, error,
+	char *err_desc = err_code_to_string(error);
+
+	log_warning("Kernel reported iSCSI connection %d:%d error (%d) %s"
+		    "state (%d)", session->id, conn->id, error, err_desc, 
 		    conn->state);
 	iscsi_ev_context_put(ev_context);
 
diff --git a/usr/kern_error_table.c b/usr/kern_error_table.c
new file mode 100644
index 0000000..2815975
--- /dev/null
+++ b/usr/kern_error_table.c
@@ -0,0 +1,81 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<string.h>
+#include"kern_error_table.h"
+#define NUM_ERRORS 22
+
+char *err_table[NUM_ERRORS] = {
+	"ISCSI_OK: iscsi ok", 
+	"ISCSI_ERR_DATASN: Got invalid data sequence from iSCSI target", 
+	"ISCSI_ERR_DATA_OFFSET: Seeking offset beyond the size of the iscsi segment",
+	"ISCSI_ERR_MAX_CMDSN: Sequence no. is greater than the maximum allowed value", 
+	"ISCSI_ERR_EXP_CMDSN: not the expected sequence no. of the iscsi command", 
+	"ISCSI_ERR_BAD_OPCODE: Got an invalid iSCSI opcode",
+	"ISCSI_ERR_DATALEN: Invalid R2T, unexpected datalen value", 
+	"ISCSI_ERR_AHSLEN: Invalid AHS len", 
+	"ISCSI_ERR_PROTO: Some protocol not followed correctly",
+	"ISCSI_ERR_LUN: LUN mismatch", 
+	"ISCSI_ERR_BAD_ITT: Invalid invitation to transmit", 
+	"ISCSI_ERR_CONN_FAILED: iSCSI connection failed",
+	"ISCSI_ERR_R2TSN: Invalid sequence no. of iSCSI R2T response", 
+	"ISCSI_ERR_SESSION_FAILED: iSCSI session failed", 
+	"ISCSI_ERR_HDR_DGST: Header digest mismatch",
+	"ISCSI_ERR_DATA_DGST: Data digest mismatch", 
+	"ISCSI_ERR_PARAM_NOT_FOUND: Parameters not found", 
+	"ISCSI_ERR_NO_SCSI_CMD: No SCSI command to execute",
+	"ISCSI_ERR_INVALID_HOST: Got an invalid host", 
+	"ISCSI_ERR_XMIT_FAILED: Transmission of iSCSI packet failed", 
+	"ISCSI_ERR_TCP_CONN_CLOSE: TCP connection closed down",
+	"ISCSI_ERR_SCSI_EH_SESSION_RST"
+};
+
+char *err_code_to_string(int code){
+	char *err_string;
+	switch(code%1000){
+		case 0:	err_string = err_table[0];
+			break;
+		case 1: err_string = err_table[1];
+			break;
+		case 2: err_string = err_table[2];
+			break;
+		case 3: err_string = err_table[3];
+			break;
+		case 4: err_string = err_table[4];
+			break;
+		case 5: err_string = err_table[5];
+			break;
+		case 6: err_string = err_table[6];
+			break;
+		case 7: err_string = err_table[7];
+			break;
+		case 8: err_string = err_table[8];
+			break;
+		case 9: err_string = err_table[9];
+			break;
+		case 10:err_string = err_table[10];
+			break;
+		case 11:err_string = err_table[11];
+			break;
+		case 12:err_string = err_table[12];
+			break;
+		case 13:err_string = err_table[13];
+			break;
+		case 14:err_string = err_table[14];
+			break;
+		case 15:err_string = err_table[15];
+			break;
+		case 16:err_string = err_table[16];
+			break;
+		case 17:err_string = err_table[17];
+			break;
+		case 18:err_string = err_table[18];
+			break;
+		case 19:err_string = err_table[19];
+			break;
+		case 20:err_string = err_table[20];
+			break;
+		case 21:err_string = err_table[21];
+			break;
+	}
+	return err_string;
+}
diff --git a/usr/kern_error_table.h b/usr/kern_error_table.h
new file mode 100644
index 0000000..58cc82b
--- /dev/null
+++ b/usr/kern_error_table.h
@@ -0,0 +1,5 @@
+#ifndef __ERRTABLE_H__
+#define __ERRTABLE_H__
+
+extern char *err_code_to_string(int);
+#endif
diff --git a/utils/fwparam_ibft/prom_lex.c b/utils/fwparam_ibft/prom_lex.c
index c8ed9cb..04173ca 100644
--- a/utils/fwparam_ibft/prom_lex.c
+++ b/utils/fwparam_ibft/prom_lex.c
@@ -1974,7 +1974,7 @@ static void yyensure_buffer_stack (void)
 								);
 		if ( ! (yy_buffer_stack) )
 			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
+								  
 		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
 				
 		(yy_buffer_stack_max) = num_to_alloc;
-- 
1.7.4.1

Reply via email to