Index: iet-0.4.9/kernel/Makefile diff -u iet-0.4.9/kernel/Makefile:1.1 iet-0.4.9/kernel/Makefile:1.3.4.1 --- iet-0.4.9/kernel/Makefile:1.1 Sun Jun 5 17:16:51 2005 +++ iet-0.4.9/kernel/Makefile Mon Jun 6 16:54:02 2005 @@ -7,7 +7,7 @@ # # Note 2! The CFLAGS definitions are now in the main makefile. -EXTRA_CFLAGS += -I$(src)/../include +EXTRA_CFLAGS += -I$(src)/../include -DCONNSTAT -DTRGTSTAT obj-m += iscsi_trgt.o iscsi_trgt-objs := tio.o iscsi.o nthread.o wthread.o config.o digest.o \ Index: iet-0.4.9/kernel/conn.c diff -u iet-0.4.9/kernel/conn.c:1.1 iet-0.4.9/kernel/conn.c:1.3.4.1 --- iet-0.4.9/kernel/conn.c:1.1 Sun Jun 5 17:16:51 2005 +++ iet-0.4.9/kernel/conn.c Mon Jun 6 16:54:02 2005 @@ -11,6 +11,9 @@ #include "iscsi.h" #include "iscsi_dbg.h" #include "digest.h" +#ifdef CONNSTAT +#include "scsiop.h" +#endif void print_conn_state(struct seq_file *seq, unsigned long state) { @@ -34,6 +37,20 @@ addr(dest,24), addr(dest,16), addr(dest, 8), addr(dest, 0)); print_conn_state(seq, conn->state); seq_printf(seq, " hd: %d dd: %d\n", conn->hdigest_type, conn->ddigest_type); + +#ifdef CONNSTAT + { + int i; + for (i = 0; i < sizeof(conn->opstat)/sizeof(conn->opstat[0]); i++) + if (atomic_read(&conn->opstat[i].success) + || atomic_read(&conn->opstat[i].failure)) + seq_printf(seq, " op %02x: %10u %10u, %s\n", + i, + atomic_read(&conn->opstat[i].success), + atomic_read(&conn->opstat[i].failure), + opstr(i)); + } +#endif } } Index: iet-0.4.9/kernel/iscsi.c diff -u iet-0.4.9/kernel/iscsi.c:1.1 iet-0.4.9/kernel/iscsi.c:1.3.4.1 --- iet-0.4.9/kernel/iscsi.c:1.1 Sun Jun 5 17:16:51 2005 +++ iet-0.4.9/kernel/iscsi.c Mon Jun 6 16:54:02 2005 @@ -318,8 +318,16 @@ rsp_hdr->residual_count = cpu_to_be32(size); } - if (func(req) < 0) + if (func(req) < 0) { +#ifdef CONNSTAT + atomic_inc(&req->conn->opstat[cmnd_hdr(req)->scb[0]].failure); +#endif eprintk("%x\n", cmnd_opcode(req)); + } +#ifdef CONNSTAT + else + atomic_inc(&req->conn->opstat[cmnd_hdr(req)->scb[0]].success); +#endif iscsi_cmnd_init_write(rsp); } @@ -364,10 +372,17 @@ struct iscsi_cmnd *rsp; if (func(req) < 0) { +#ifdef CONNSTAT + atomic_inc(&req->conn->opstat[cmnd_hdr(req)->scb[0]].failure); +#endif rsp = create_sense_rsp(req, ILLEGAL_REQUEST, 0x24, 0x0); iscsi_cmnd_init_write(rsp); - } else + } else { +#ifdef CONNSTAT + atomic_inc(&req->conn->opstat[cmnd_hdr(req)->scb[0]].success); +#endif do_send_data_rsp(req); + } } /** Index: iet-0.4.9/kernel/iscsi.h diff -u iet-0.4.9/kernel/iscsi.h:1.1 iet-0.4.9/kernel/iscsi.h:1.3.4.2 --- iet-0.4.9/kernel/iscsi.h:1.1 Sun Jun 5 17:16:51 2005 +++ iet-0.4.9/kernel/iscsi.h Mon Jun 6 17:46:41 2005 @@ -219,6 +219,13 @@ struct crypto_tfm *rx_digest_tfm; struct crypto_tfm *tx_digest_tfm; + +#ifdef CONNSTAT + /* statistics */ + struct { + atomic_t success, failure; + } opstat[0xff]; +#endif }; struct iscsi_pdu { Index: iet-0.4.9/kernel/scsiop.h diff -u /dev/null iet-0.4.9/kernel/scsiop.h:1.2.4.1 --- /dev/null Mon Jun 6 19:09:33 2005 +++ iet-0.4.9/kernel/scsiop.h Mon Jun 6 17:06:43 2005 @@ -0,0 +1,50 @@ + +#ifndef scsiop_h +#define scsiop_h + +static char scsiop__h[] __attribute__ ((unused, nocommon)) + = "@(#) $Id: scsiop.h,v 1.2.4.1 2005/06/06 08:06:43 jro Exp $"; + +#include +#include + +static inline char *opstr(unsigned int op) +{ + switch (op) { + case TEST_UNIT_READY: + return "TEST_UNIT_READY"; + case REPORT_LUNS: + return "REPORT_LUNS"; + case INQUIRY: + return "INQUIRY"; + case READ_CAPACITY: + return "READ_CAPACITY"; + case GPCMD_MODE_SENSE_10: + return "GPCMD_MODE_SENSE_10"; + case GPCMD_READ_TOC_PMA_ATIP: + return "GPCMD_READ_TOC_PMA_ATIP"; + case READ_10: + return "READ_10"; + case GPCMD_REPORT_KEY: + return "GPCMD_REPORT_KEY"; + case GPCMD_READ_DVD_STRUCTURE: + return "GPCMD_READ_DVD_STRUCTURE"; + case GPCMD_SEND_KEY: + return "GPCMD_SEND_KEY"; + case GPCMD_READ_DISC_INFO: + return "GPCMD_READ_DISC_INFO"; + case GPCMD_READ_SUBCHANNEL: + return "GPCMD_READ_SUBCHANNEL"; + case GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL: + return "GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL"; + case GPCMD_READ_TRACK_RZONE_INFO: + return "GPCMD_READ_TRACK_RZONE_INFO"; + case GPCMD_GET_EVENT_STATUS_NOTIFICATION: + return "GPCMD_GET_EVENT_STATUS_NOTIFICATION"; + case GPCMD_GET_CONFIGURATION: + return "GPCMD_GET_CONFIGURATION"; + } + return "unknown"; +} + +#endif /* scsiop_h */