From: <vl...@us...> - 2006-12-15 15:59:26
|
Revision: 62 http://svn.sourceforge.net/scst/?rev=62&view=rev Author: vlnb Date: 2006-12-15 07:59:21 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Update to allow SCST built inside Linux kernel. Done together with Erik Habbinga. --This line, and below, will be ignored-- _M trunk/mpt _M trunk/mpt/in-tree M trunk/mpt/in-tree/Makefile.diff M trunk/mpt/mpt_scst.c M trunk/mpt/Makefile M trunk/qla2x00t/qla2x00-target/qla2x00t.c M trunk/scst/kernel/in-tree/Makefile.scsi_tgt D trunk/scst/include/scst_debug.c M trunk/scst/include/scst_debug.h M trunk/scst/src/scst_proc.c M trunk/scst/src/scst_priv.h A trunk/scst/src/scst_debug.c M trunk/scst/src/scst_targ.c M trunk/scst/src/scst_mem.c M trunk/scst/src/Makefile M trunk/scst/src/scst.c M trunk/scst/src/dev_handlers/scst_cdrom.c M trunk/scst/src/dev_handlers/scst_modisk.c M trunk/scst/src/dev_handlers/scst_changer.c M trunk/scst/src/dev_handlers/scst_fileio.c M trunk/scst/src/dev_handlers/scst_tape.c M trunk/scst/src/dev_handlers/scst_disk.c M trunk/scst/src/dev_handlers/scst_processor.c M trunk/scst/src/dev_handlers/scst_raid.c M trunk/scst/src/dev_handlers/Makefile M trunk/scst/src/dev_handlers/scst_dev_handler.h M trunk/scst/README Modified Paths: -------------- trunk/mpt/Makefile trunk/mpt/in-tree/Makefile.diff trunk/mpt/mpt_scst.c trunk/qla2x00t/qla2x00-target/qla2x00t.c trunk/scst/README trunk/scst/include/scst_debug.h trunk/scst/kernel/in-tree/Makefile.scsi_tgt trunk/scst/src/Makefile trunk/scst/src/dev_handlers/Makefile trunk/scst/src/dev_handlers/scst_cdrom.c trunk/scst/src/dev_handlers/scst_changer.c trunk/scst/src/dev_handlers/scst_dev_handler.h trunk/scst/src/dev_handlers/scst_disk.c trunk/scst/src/dev_handlers/scst_fileio.c trunk/scst/src/dev_handlers/scst_modisk.c trunk/scst/src/dev_handlers/scst_processor.c trunk/scst/src/dev_handlers/scst_raid.c trunk/scst/src/dev_handlers/scst_tape.c trunk/scst/src/scst.c trunk/scst/src/scst_mem.c trunk/scst/src/scst_priv.h trunk/scst/src/scst_proc.c trunk/scst/src/scst_targ.c Added Paths: ----------- trunk/scst/src/scst_debug.c Removed Paths: ------------- trunk/scst/include/scst_debug.c Property Changed: ---------------- trunk/mpt/ trunk/mpt/in-tree/ Property changes on: trunk/mpt ___________________________________________________________________ Name: svn:ignore + *.o *.mod.c *.ko *.ko.cmd *.o.cmd .tmp_versions Modules.symvers Module.symvers Modified: trunk/mpt/Makefile =================================================================== --- trunk/mpt/Makefile 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/mpt/Makefile 2006-12-15 15:59:21 UTC (rev 62) @@ -25,8 +25,10 @@ SCST_INC_DIR := $(SUBDIRS)/../scst/include SCST_DIR := $(shell pwd)/../scst/src -EXTRA_CFLAGS += -I$(SCST_INC_DIR) +FUSION_INC_DIR := drivers/message/fusion +EXTRA_CFLAGS += -I$(SCST_INC_DIR) -I$(FUSION_INC_DIR) -Iinclude/scsi + EXTRA_CFLAGS += -DEXTRACHECKS #EXTRA_CFLAGS += -DTRACING #EXTRA_CFLAGS += -DDEBUG @@ -44,7 +46,7 @@ EXTRA_CFLAGS += -I$(LSI_INC_DIR) ifneq ($(KERNELRELEASE),) -obj-m := mpt_scst.o +obj-$(CONFIG_FUSION_SCST) += mpt_scst.o else Property changes on: trunk/mpt/in-tree ___________________________________________________________________ Name: svn:ignore + *.o *.mod.c *.ko *.ko.cmd *.o.cmd .tmp_versions Modules.symvers Module.symvers Modified: trunk/mpt/in-tree/Makefile.diff =================================================================== --- trunk/mpt/in-tree/Makefile.diff 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/mpt/in-tree/Makefile.diff 2006-12-15 15:59:21 UTC (rev 62) @@ -1,21 +1,10 @@ ---- Makefile_orig 2006-03-05 22:07:54.000000000 +0300 -+++ Makefile 2006-12-13 14:50:36.000000000 +0300 -@@ -30,9 +30,18 @@ - #CFLAGS_mptctl.o += -DMPT_DEBUG_IOCTL - # - -+SCST_INC_DIR := /usr/local/include/scst -+ -+CFLAGS_mpt_scst.o += -I$(SCST_INC_DIR) -I$(src) -+CFLAGS_mpt_scst.o += -DEXTRACHECKS -+#CFLAGS_mpt_scst.o += -DTRACING -+#CFLAGS_mpt_scst.o += -DDEBUG -+#CFLAGS_mpt_scst.o += -DDEBUG_WORK_IN_THREAD -+ +--- Makefile.orig 2006-01-02 20:21:10.000000000 -0700 ++++ Makefile 2006-12-14 10:24:53.000000000 -0700 +@@ -33,6 +33,7 @@ #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-} LSI_LOGIC obj-$(CONFIG_FUSION_SPI) += mptbase.o mptscsih.o mptspi.o -+obj-$(CONFIG_FUSION_SCST) += mpt_scst/mpt_scst.o ++obj-$(CONFIG_FUSION_SCST) += mpt_scst/ obj-$(CONFIG_FUSION_FC) += mptbase.o mptscsih.o mptfc.o obj-$(CONFIG_FUSION_SAS) += mptbase.o mptscsih.o mptsas.o obj-$(CONFIG_FUSION_CTL) += mptctl.o Modified: trunk/mpt/mpt_scst.c =================================================================== --- trunk/mpt/mpt_scst.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/mpt/mpt_scst.c 2006-12-15 15:59:21 UTC (rev 62) @@ -29,6 +29,7 @@ #include <linux/blkdev.h> #include <linux/interrupt.h> #include <scsi/scsi.h> +#include <linux/seq_file.h> #include <scsi/scsi_host.h> #if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) @@ -39,9 +40,6 @@ #include <scst_debug.h> -#include <scst_debug.c> -#include <linux/proc_fs.h> - #include "mpt_scst.h" #define MYNAM "mpt_scst" @@ -62,6 +60,17 @@ }; #endif +#ifdef DEBUG +#define SCST_DEFAULT_MPT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ + TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MGMT_DEBUG | \ + TRACE_MINOR | TRACE_SPECIAL) +#else +# ifdef TRACING +#define SCST_DEFAULT_MPT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ + TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MINOR | TRACE_SPECIAL) +# endif +#endif + static MPT_STM_PRIV *mpt_stm_priv[MPT_MAX_ADAPTERS+1]; static int set_aliases_in_fcportpage1 = 1; @@ -113,48 +122,45 @@ static void stmapp_srr_process(MPT_STM_PRIV *priv, int rx_id, int r_ctl, u32 offset, LinkServiceBufferPostReply_t *rep, int index); +#ifdef DEBUG +#define trace_flag mpt_trace_flag +unsigned long mpt_trace_flag = TRACE_FUNCTION | TRACE_OUT_OF_MEM | TRACE_SPECIAL; +#else +# ifdef TRACING +#define trace_flag mpt_trace_flag +unsigned long mpt_trace_flag = TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_SPECIAL; +# endif +#endif + static int -mpt_proc_read(char *buffer, char **start, off_t offset, int length, int *eof, - struct scst_tgt *scst_tgt) +mpt_target_show(struct seq_file *seq, void *v) { - struct mpt_tgt *tgt = scst_tgt_get_tgt_priv(scst_tgt); + struct mpt_tgt *tgt = (struct mpt_tgt *)seq->private; MPT_ADAPTER *ioc = tgt->priv->ioc; - int res = 0, len = 0; MPT_STM_PRIV *priv = tgt->priv; TRACE_ENTRY(); - TRACE_DBG("res %d, buffer %p, length %d, %d, priv %p, tgt %p", - res, buffer, length, len, priv, tgt); + TRACE_DBG("priv %p, tgt %p", priv, tgt); sBUG_ON(tgt == NULL); sBUG_ON(ioc == NULL); - len = snprintf(buffer, length, - "ProductID :0x%04x (%s)\n" + seq_printf(seq, "ProductID :0x%04x (%s)\n" "Target Enable :%s\n", ioc->facts.ProductID, ioc->prod_name, tgt->target_enable ? "True" : "False"); -#define LEN_CHECK(res, buffer, length) \ - TRACE_DBG("res %d, buffer %p, length %d, %d", res, buffer, length, len); \ - res += len; buffer += len; length -= len; \ - if (length <= 0) goto out; - LEN_CHECK(res, buffer, length) - if (ioc->bus_type == SCSI) { int i = 0; - len = snprintf(buffer, length, - "Target ID :%d\n" + seq_printf(seq, "Target ID :%d\n" "Capabilities :0x%x\n" "PhysicalInterface:0x%x\n", tgt->target_id, priv->SCSIPortPage0.Capabilities, priv->SCSIPortPage0.PhysicalInterface); - LEN_CHECK(res, buffer, length) - len = snprintf(buffer, length, - "Configuration :0x%x\n" + seq_printf(seq, "Configuration :0x%x\n" "OnBusTimerValue :0x%x\n" "TargetConfig :0x%x\n" "IDConfig :0x%x\n", @@ -162,63 +168,55 @@ priv->SCSIPortPage1.OnBusTimerValue, priv->SCSIPortPage1.TargetConfig, priv->SCSIPortPage1.IDConfig); - LEN_CHECK(res, buffer, length); - len = snprintf(buffer, length, - "PortFlags :0x%x\n" + seq_printf(seq, "PortFlags :0x%x\n" "PortSettings :0x%x\n", priv->SCSIPortPage2.PortFlags, priv->SCSIPortPage2.PortSettings); - LEN_CHECK(res, buffer, length); #if 0 for (i = 0; i < 16; i++) { - len = snprintf(buffer, length, - " DeviceSeting %02d: 0x%x 0x%x 0x%x\n", + seq_printf(seq, " DeviceSeting %02d: 0x%x 0x%x 0x%x\n", priv->SCSIPortPage2.DeviceSettings[i].Timeout, priv->SCSIPortPage2.DeviceSettings[i].SyncFactor, priv->SCSIPortPage2.DeviceSettings[i].DeviceFlags); - LEN_CHECK(res, buffer, length); } #endif for (i = 0; i < NUM_SCSI_DEVICES; i++) { - len = snprintf(buffer, length, - " Device %02d: 0x%x, 0x%x\n", + seq_printf(seq, " Device %02d: 0x%x, 0x%x\n", i, priv->SCSIDevicePage1[i].RequestedParameters, priv->SCSIDevicePage1[i].Configuration); - LEN_CHECK(res, buffer, length); } } if (ioc->bus_type == FC) { - len = snprintf(buffer, length, - "WWN :%08X%08X:%08X%08X\n", + seq_printf(seq, "WWN :%08X%08X:%08X%08X\n", ioc->fc_port_page0[0].WWNN.High, ioc->fc_port_page0[0].WWNN.Low, ioc->fc_port_page0[0].WWPN.High, ioc->fc_port_page0[0].WWPN.Low); - LEN_CHECK(res, buffer, length); } -#undef LEN_CHECK -out: - TRACE_EXIT_RES(res); - return res; + TRACE_EXIT(); + return 0; } static int -mpt_proc_write(struct file *file, const char *buf, unsigned long length, - struct scst_tgt *scst_tgt) +mpt_proc_target_write(struct file *file, const char __user *buf, + size_t length, loff_t *off) { - struct mpt_tgt *tgt = scst_tgt_get_tgt_priv(scst_tgt); + struct mpt_tgt *tgt = (struct mpt_tgt *)PDE(file->f_dentry->d_inode)->data; MPT_ADAPTER *ioc = tgt->priv->ioc; int res = 0; char tmp[32+1]; TRACE_ENTRY(); res = min(32, (int)length); - memcpy(tmp, buf, res); + if (copy_from_user(tmp, buf, res)) { + res = -EFAULT; + goto out; + } tmp[res] = 0; TRACE_DBG("buff '%s'", tmp); @@ -245,21 +243,17 @@ } #endif +out: TRACE_EXIT_RES(res); return length; } -static int mpt_proc_info(char *buffer, char **start, off_t offset, - int length, int *eof, struct scst_tgt *tgt, int inout) -{ - if (inout) { - return mpt_proc_write(NULL, buffer, length, tgt); - } - return mpt_proc_read(buffer, start, offset, length, eof, tgt); -} +static struct scst_proc_data mpt_target_proc_data = { + SCST_DEF_RW_SEQ_OP(mpt_proc_target_write) + .show = mpt_target_show, +}; - static int mpt_target_detect(struct scst_tgt_template *temp1); static int mpt_target_release(struct scst_tgt *scst_tgt); static int mpt_xmit_response(struct scst_cmd *scst_cmd); @@ -287,7 +281,6 @@ .rdy_to_xfer = mpt_rdy_to_xfer, .on_free_cmd = mpt_on_free_cmd, .task_mgmt_fn_done = mpt_task_mgmt_fn_done, -//ToDo: .proc_info = mpt_proc_info, }; static inline void @@ -339,6 +332,9 @@ MPT_ADAPTER *ioc = pci_get_drvdata(pdev); int ret = 0; struct mpt_tgt *tgt; + struct proc_dir_entry *p; + struct proc_dir_entry *root; + char name[4]; TRACE_ENTRY(); ret = mpt_stm_adapter_install(ioc); @@ -370,9 +366,23 @@ ret = -ENODEV; goto out; } + + root = scst_proc_get_tgt_root(&tgt_template); + scnprintf(name, sizeof(name), "%d", ioc->id); + mpt_target_proc_data.data = (void *)tgt; + p = scst_create_proc_entry(root, name, + &mpt_target_proc_data); + if (p == NULL) { + PRINT_ERROR("Not enough memory to register " + "target driver %s entry %s in /proc", + tgt_template.name, name); + scst_unregister(tgt->scst_tgt); + ret = -ENOMEM; + goto out; + } + scst_tgt_set_tgt_priv(tgt->scst_tgt, tgt); mpt_stm_priv[ioc->id]->tgt = tgt; - _mpt_ada_nums ++; out: @@ -5102,48 +5112,44 @@ TRACE_EXIT(); } +#if defined(DEBUG) || defined(TRACING) + #define MPT_PROC_LOG_ENTRY_NAME "trace_level" -#ifdef TRACING -static struct scst_proc_log mpt_spec_tbl[] = -{ - { TRACE_MPI, "mpt_mpi" }, - { 0, NULL } -}; -#endif -static int mpt_proc_log_entry_read(char *buffer, char **start, - off_t offset, int length, int *eof, - void *data) +#include <linux/proc_fs.h> + +static int mpt_log_info_show(struct seq_file *seq, void *v) { int res = 0; TRACE_ENTRY(); -#ifdef TRACING - res = scst_proc_log_entry_read(buffer, start, offset, length, eof, - data, trace_flag, mpt_spec_tbl); -#endif + res = scst_proc_log_entry_read(seq, trace_flag, NULL); + TRACE_EXIT_RES(res); return res; } -static int mpt_proc_log_entry_write(struct file *file, const char *buf, - unsigned long length, void *data) +static int mpt_proc_log_entry_write(struct file *file, const char __user *buf, + size_t length, loff_t *off) { int res = 0; TRACE_ENTRY(); -#ifdef TRACING - res = scst_proc_log_entry_write(file, buf, length, data, - &trace_flag, (TRACE_FUNCTION | TRACE_OUT_OF_MEM | TRACE_MGMT | \ - TRACE_MINOR | TRACE_SPECIAL), mpt_spec_tbl); -#endif + res = scst_proc_log_entry_write(file, buf, length, &trace_flag, + SCST_DEFAULT_MPT_LOG_FLAGS, NULL); TRACE_EXIT_RES(res); return res; } +static struct scst_proc_data mpt_log_proc_data = { + SCST_DEF_RW_SEQ_OP(mpt_proc_log_entry_write) + .show = mpt_log_info_show, +}; +#endif + static int mpt_proc_log_entry_build(struct scst_tgt_template *templ) { int res = 0; @@ -5153,10 +5159,10 @@ root = scst_proc_get_tgt_root(templ); if (root) { - p = create_proc_read_entry(MPT_PROC_LOG_ENTRY_NAME, - S_IFREG | S_IRUGO | S_IWUSR, root, - mpt_proc_log_entry_read, - (void *)templ->name); +#if defined(DEBUG) || defined(TRACING) + mpt_log_proc_data.data = (void *)templ->name; + p = scst_create_proc_entry(root, MPT_PROC_LOG_ENTRY_NAME, + &mpt_log_proc_data); if (p == NULL) { PRINT_ERROR("Not enough memory to register " "target driver %s entry %s in /proc", @@ -5164,7 +5170,7 @@ res = -ENOMEM; goto out; } - p->write_proc = mpt_proc_log_entry_write; +#endif } out: @@ -5175,16 +5181,18 @@ static void mpt_proc_log_entry_clean(struct scst_tgt_template *templ) { +#if defined(DEBUG) || defined(TRACING) struct proc_dir_entry *root; TRACE_ENTRY(); + root = scst_proc_get_tgt_root(templ); if (root) { remove_proc_entry(MPT_PROC_LOG_ENTRY_NAME, root); } - TRACE_EXIT(); +#endif } static int __init mpt_target_init(void) @@ -5225,14 +5233,6 @@ return; } -#ifdef DEBUG -unsigned long trace_flag = TRACE_FUNCTION | TRACE_OUT_OF_MEM | TRACE_SPECIAL; -#else -# ifdef TRACING -unsigned long trace_flag = TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_SPECIAL; -# endif -#endif - module_init(mpt_target_init); module_exit(mpt_target_exit); Modified: trunk/qla2x00t/qla2x00-target/qla2x00t.c =================================================================== --- trunk/qla2x00t/qla2x00-target/qla2x00t.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/qla2x00t/qla2x00-target/qla2x00t.c 2006-12-15 15:59:21 UTC (rev 62) @@ -43,8 +43,6 @@ #include "qla2x00t.h" -#include <scst_debug.c> - #ifndef FC_TARGET_SUPPORT #error "FC_TARGET_SUPPORT is NOT DEFINED" #endif @@ -59,12 +57,12 @@ #endif #ifdef DEBUG -#define SCST_DEFAULT_QLA_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ +#define Q2T_DEFAULT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MGMT_DEBUG | \ TRACE_MINOR | TRACE_SPECIAL) #else # ifdef TRACING -#define SCST_DEFAULT_QLA_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ +#define Q2T_DEFAULT_LOG_FLAGS (TRACE_FUNCTION | TRACE_PID | \ TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MINOR | TRACE_SPECIAL) # endif #endif @@ -93,7 +91,8 @@ */ #if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_QLA_LOG_FLAGS; +#define trace_flag q2t_trace_flag +unsigned long q2t_trace_flag = Q2T_DEFAULT_LOG_FLAGS; #endif struct scst_tgt_template tgt_template = { @@ -2074,7 +2073,7 @@ TRACE_ENTRY(); res = scst_proc_log_entry_write(file, buf, length, &trace_flag, - SCST_DEFAULT_QLA_LOG_FLAGS, NULL); + Q2T_DEFAULT_LOG_FLAGS, NULL); TRACE_EXIT_RES(res); return res; Modified: trunk/scst/README =================================================================== --- trunk/scst/README 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/README 2006-12-15 15:59:21 UTC (rev 62) @@ -40,10 +40,10 @@ To compile SCST type 'make'. It will build SCST itself and its device handlers. To install them type 'make install'. The driver modules will be installed in '/lib/modules/`you_kernel_version`/extra'. In addition, -scsi_tgt.h, scst_debug.h and scst_debug.c will be copied to -'/usr/local/include/scst'. The first file contains all SCST's public -data definition, which are used by target drivers. The other ones -support debug messages logging. +scsi_tgt.h, scst_debug.h as well as Module.symvers or Modules.symvers +will be copied to '/usr/local/include/scst'. The first file contains all +SCST's public data definition, which are used by target drivers. The +other ones support debug messages logging and build process. Then you can load any module by typing 'modprobe drive_name'. The names are: Deleted: trunk/scst/include/scst_debug.c =================================================================== --- trunk/scst/include/scst_debug.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/include/scst_debug.c 2006-12-15 15:59:21 UTC (rev 62) @@ -1,108 +0,0 @@ -/* - * include/scst_debug.c - * - * Copyright (C) 2004-2006 Vladislav Bolkhovitin <vs...@vl...> - * and Leonid Stoljar - * - * Contains helper functions for execution tracing and error reporting. - * Intended to be included in main .c file. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, version 2 - * of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#if defined(DEBUG) || defined(TRACING) - -unsigned long trace_flag; - -#define TRACE_BUF_SIZE 512 - -static char trace_buf[TRACE_BUF_SIZE]; -static spinlock_t trace_buf_lock = SPIN_LOCK_UNLOCKED; - -int debug_print_prefix(const char *func, int line) -{ - int i = 0; - unsigned long flags; - - spin_lock_irqsave(&trace_buf_lock, flags); - - if (trace_flag & TRACE_PID) - i += snprintf(&trace_buf[i], TRACE_BUF_SIZE, "[%d]: ", - current->pid); - if (trace_flag & TRACE_FUNCTION) - i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "%s:", func); - if (trace_flag & TRACE_LINE) - i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "%i:", line); - - if (i > 0) - PRINTN(LOG_FLAG, "%s", trace_buf); - - spin_unlock_irqrestore(&trace_buf_lock, flags); - - return i; -} - -void debug_print_buffer(const void *data, int len) -{ - int z, z1, i; - const unsigned char *buf = (const unsigned char *) data; - int f = 0; - unsigned long flags; - - if (buf == NULL) - return; - - spin_lock_irqsave(&trace_buf_lock, flags); - - PRINT(NO_FLAG, " (h)___0__1__2__3__4__5__6__7__8__9__A__B__C__D__E__F"); - for (z = 0, z1 = 0, i = 0; z < len; z++) { - if (z % 16 == 0) { - if (z != 0) { - i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, - " "); - for (; (z1 < z) && (i < TRACE_BUF_SIZE - 1); - z1++) { - if ((buf[z1] >= 0x20) && - (buf[z1] < 0x80)) - trace_buf[i++] = buf[z1]; - else - trace_buf[i++] = '.'; - } - trace_buf[i] = '\0'; - PRINT(NO_FLAG, "%s", trace_buf); - i = 0; - f = 1; - } - i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, - "%4x: ", z); - } - i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "%02x ", - buf[z]); - } - i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, " "); - for (; (z1 < z) && (i < TRACE_BUF_SIZE - 1); z1++) { - if ((buf[z1] > 0x20) && (buf[z1] < 0x80)) - trace_buf[i++] = buf[z1]; - else - trace_buf[i++] = '.'; - } - trace_buf[i] = '\0'; - if (f) { - PRINT(LOG_FLAG, "%s", trace_buf) - } else { - PRINT(NO_FLAG, "%s", trace_buf); - } - - spin_unlock_irqrestore(&trace_buf_lock, flags); - return; -} - -#endif /* DEBUG || TRACING */ Modified: trunk/scst/include/scst_debug.h =================================================================== --- trunk/scst/include/scst_debug.h 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/include/scst_debug.h 2006-12-15 15:59:21 UTC (rev 62) @@ -99,63 +99,61 @@ #if defined(DEBUG) || defined(TRACING) -extern unsigned long trace_flag; +extern int debug_print_prefix(unsigned long trace_flag, const char *func, int line); +extern void debug_print_buffer(unsigned long trace_flag, const void *data, int len); -extern int debug_print_prefix(const char *func, int line); -extern void debug_print_buffer(const void *data, int len); - -#define TRACE(trace, format, args...) \ -do { \ - if (trace_flag & (trace)) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ - } \ +#define TRACE(trace, format, args...) \ +do { \ + if (trace_flag & (trace)) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ + } \ } while(0) -#define TRACE_LOG_FLAG(log_flag, trace, format, args...) \ -do { \ - char *__tflag = log_flag; \ - if (trace_flag & (trace)) \ - { \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ +#define TRACE_LOG_FLAG(log_flag, trace, format, args...) \ +do { \ + char *__tflag = log_flag; \ + if (trace_flag & (trace)) \ + { \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ } while(0) -#define TRACE_BUFFER(message, buff, len) \ -do { \ - if (trace_flag & TRACE_BUFF) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s%s:", __tflag, message); \ - debug_print_buffer(buff, len); \ - } \ +#define TRACE_BUFFER(message, buff, len) \ +do { \ + if (trace_flag & TRACE_BUFF) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s%s:", __tflag, message); \ + debug_print_buffer(trace_flag, buff, len); \ + } \ } while(0) -#define TRACE_BUFF_FLAG(flag, message, buff, len) \ -do { \ - if (trace_flag & (flag)) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s%s:", __tflag, message); \ - debug_print_buffer(buff, len); \ - } \ +#define TRACE_BUFF_FLAG(flag, message, buff, len) \ +do { \ + if (trace_flag & (flag)) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s%s:", __tflag, message); \ + debug_print_buffer(trace_flag, buff, len); \ + } \ } while(0) #else /* DEBUG || TRACING */ @@ -168,54 +166,54 @@ #ifdef DEBUG -#define TRACE_MEM(format, args...) \ -do { \ - if (trace_flag & TRACE_MEMORY) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ - } \ +#define TRACE_MEM(format, args...) \ +do { \ + if (trace_flag & TRACE_MEMORY) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ + } \ } while(0) -#define TRACE_DBG(format, args...) \ -do { \ - if (trace_flag & TRACE_DEBUG) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ - } \ +#define TRACE_DBG(format, args...) \ +do { \ + if (trace_flag & TRACE_DEBUG) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ + } \ } while(0) -#define TRACE_MGMT_DBG(format, args...) \ -do { \ - if (trace_flag & TRACE_MGMT_DEBUG) \ - { \ - char *__tflag = LOG_FLAG; \ - if (debug_print_prefix(__FUNCTION__, __LINE__) > 0) \ - { \ - __tflag = NO_FLAG; \ - } \ - PRINT(NO_FLAG, "%s" format, __tflag, args); \ - } \ +#define TRACE_MGMT_DBG(format, args...) \ +do { \ + if (trace_flag & TRACE_MGMT_DEBUG) \ + { \ + char *__tflag = LOG_FLAG; \ + if (debug_print_prefix(trace_flag, __FUNCTION__, __LINE__) > 0) \ + { \ + __tflag = NO_FLAG; \ + } \ + PRINT(NO_FLAG, "%s" format, __tflag, args); \ + } \ } while(0) -#define PRINT_ERROR_PR(format, args...) \ -do { \ - if (ERROR_FLAG != LOG_FLAG) \ - { \ +#define PRINT_ERROR_PR(format, args...) \ +do { \ + if (ERROR_FLAG != LOG_FLAG) \ + { \ TRACE_LOG_FLAG(LOG_FLAG, trace_flag, "%s: ***ERROR*** " format, \ - LOG_PREFIX, args); \ - } \ + LOG_PREFIX, args); \ + } \ TRACE_LOG_FLAG(ERROR_FLAG, trace_flag, "%s: ***ERROR*** " format, \ - LOG_PREFIX, args); \ + LOG_PREFIX, args); \ } while(0) #define PRINT_INFO_PR(format, args...) \ @@ -229,86 +227,86 @@ format, LOG_PREFIX, args); \ } while(0) -#define PRINT_ERROR(format, args...) \ -do { \ - if (ERROR_FLAG != LOG_FLAG) \ - { \ +#define PRINT_ERROR(format, args...) \ +do { \ + if (ERROR_FLAG != LOG_FLAG) \ + { \ TRACE_LOG_FLAG(LOG_FLAG, trace_flag, "***ERROR*** " format, args); \ - } \ + } \ TRACE_LOG_FLAG(ERROR_FLAG, trace_flag, "***ERROR*** " format, args); \ } while(0) -#define PRINT_INFO(format, args...) \ -do { \ - if (INFO_FLAG != LOG_FLAG) \ - { \ +#define PRINT_INFO(format, args...) \ +do { \ + if (INFO_FLAG != LOG_FLAG) \ + { \ TRACE_LOG_FLAG(LOG_FLAG, trace_flag, format, args); \ - } \ - TRACE_LOG_FLAG(INFO_FLAG, trace_flag, format, args); \ + } \ + TRACE_LOG_FLAG(INFO_FLAG, trace_flag, format, args); \ } while(0) -#define TRACE_ENTRY() \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ +#define TRACE_ENTRY() \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ PRINT(LOG_FLAG, "[%d]: ENTRY %s", current->pid, \ - __FUNCTION__); \ - } \ - else \ - { \ - PRINT(LOG_FLAG, "ENTRY %s", __FUNCTION__); \ - } \ - } \ + __FUNCTION__); \ + } \ + else \ + { \ + PRINT(LOG_FLAG, "ENTRY %s", __FUNCTION__); \ + } \ + } \ } while(0) -#define TRACE_EXIT() \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ +#define TRACE_EXIT() \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ PRINT(LOG_FLAG, "[%d]: EXIT %s", current->pid, \ - __FUNCTION__); \ - } \ - else \ - { \ - PRINT(LOG_FLAG, "EXIT %s", __FUNCTION__); \ - } \ - } \ + __FUNCTION__); \ + } \ + else \ + { \ + PRINT(LOG_FLAG, "EXIT %s", __FUNCTION__); \ + } \ + } \ } while(0) -#define TRACE_EXIT_RES(res) \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ - PRINT(LOG_FLAG, "[%d]: EXIT %s: %ld", current->pid, \ - __FUNCTION__, (long)(res)); \ - } \ - else \ - { \ +#define TRACE_EXIT_RES(res) \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ + PRINT(LOG_FLAG, "[%d]: EXIT %s: %ld", current->pid, \ + __FUNCTION__, (long)(res)); \ + } \ + else \ + { \ PRINT(LOG_FLAG, "EXIT %s: %ld", __FUNCTION__, (long)(res)); \ - } \ - } \ + } \ + } \ } while(0) -#define TRACE_EXIT_HRES(res) \ -do { \ - if (trace_flag & TRACE_ENTRYEXIT) \ - { \ - if (trace_flag & TRACE_PID) \ - { \ - PRINT(LOG_FLAG, "[%d]: EXIT %s: 0x%lx", current->pid, \ - __FUNCTION__, (long)(res)); \ - } \ - else \ - { \ +#define TRACE_EXIT_HRES(res) \ +do { \ + if (trace_flag & TRACE_ENTRYEXIT) \ + { \ + if (trace_flag & TRACE_PID) \ + { \ + PRINT(LOG_FLAG, "[%d]: EXIT %s: 0x%lx", current->pid, \ + __FUNCTION__, (long)(res)); \ + } \ + else \ + { \ PRINT(LOG_FLAG, "EXIT %s: %lx", __FUNCTION__, (long)(res)); \ - } \ - } \ + } \ + } \ } while(0) #else /* DEBUG */ @@ -321,8 +319,8 @@ #define TRACE_EXIT_RES(res) {} #define TRACE_EXIT_HRES(res) {} -#define PRINT_INFO_PR(format, args...) \ -do { \ +#define PRINT_INFO_PR(format, args...) \ +do { \ PRINT(INFO_FLAG, "%s: " format, LOG_PREFIX, args); \ } while(0) Modified: trunk/scst/kernel/in-tree/Makefile.scsi_tgt =================================================================== --- trunk/scst/kernel/in-tree/Makefile.scsi_tgt 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/kernel/in-tree/Makefile.scsi_tgt 2006-12-15 15:59:21 UTC (rev 62) @@ -5,6 +5,7 @@ scsi_tgt-y += scst_targ.o scsi_tgt-y += scst_lib.o scsi_tgt-y += scst_proc.o +scsi_tgt-y += scst_mem.o obj-$(CONFIG_SCSI_TARGET) += scsi_tgt.o obj-$(CONFIG_SCSI_TARGET_DISK) += scst_disk.o Modified: trunk/scst/src/Makefile =================================================================== --- trunk/scst/src/Makefile 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/Makefile 2006-12-15 15:59:21 UTC (rev 62) @@ -29,9 +29,19 @@ DEV_HANDLERS_DIR = dev_handlers ifneq ($(KERNELRELEASE),) +SCST_INC_DIR := $(SUBDIRS)/../include + obj-m := scsi_tgt.o scsi_tgt-objs := scst.o scst_targ.o scst_lib.o scst_mem.o scst_proc.o +scsi_tgt-y += scst.o +scsi_tgt-y += scst_targ.o +scsi_tgt-y += scst_lib.o +scsi_tgt-y += scst_proc.o +scsi_tgt-y += scst_mem.o +scsi_tgt-y += scst_debug.o +obj-$(CONFIG_SCSI_TARGET) += scsi_tgt.o dev_handlers/ + obj-$(BUILD_DEV) += $(DEV_HANDLERS_DIR)/ else @@ -59,7 +69,6 @@ install -d $(INSTALL_DIR_H) install -m 644 ../include/scsi_tgt.h $(INSTALL_DIR_H) install -m 644 ../include/scst_debug.h $(INSTALL_DIR_H) - install -m 644 ../include/scst_debug.c $(INSTALL_DIR_H) ifneq ($(MODS_VERS),) rm -f $(INSTALL_DIR_H)/Module.symvers install -m 644 Modules.symvers $(INSTALL_DIR_H) @@ -81,10 +90,8 @@ INSTALL_DIR := /lib/modules/$(shell uname -r)/extra INSTALL_DIR_H := /usr/local/include/scst -INC_DIR := $(SUBDIRS)/../include +EXTRA_CFLAGS += -I$(SCST_INC_DIR) -EXTRA_CFLAGS += -I$(INC_DIR) - #EXTRA_CFLAGS += -DSTRICT_SERIALIZING EXTRA_CFLAGS += -DEXTRACHECKS Modified: trunk/scst/src/dev_handlers/Makefile =================================================================== --- trunk/scst/src/dev_handlers/Makefile 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/dev_handlers/Makefile 2006-12-15 15:59:21 UTC (rev 62) @@ -27,8 +27,20 @@ # ifneq ($(KERNELRELEASE),) +SCST_INC_DIR := $(SUBDIRS)/../include + obj-m := scst_cdrom.o scst_changer.o scst_disk.o scst_modisk.o scst_tape.o \ scst_fileio.o scst_raid.o scst_processor.o + +obj-$(CONFIG_SCSI_TARGET_DISK) += scst_disk.o +obj-$(CONFIG_SCSI_TARGET_TAPE) += scst_tape.o +obj-$(CONFIG_SCSI_TARGET_CDROM) += scst_cdrom.o +obj-$(CONFIG_SCSI_TARGET_MODISK) += scst_modisk.o +obj-$(CONFIG_SCSI_TARGET_CHANGER) += scst_changer.o +obj-$(CONFIG_SCSI_TARGET_RAID) += scst_raid.o +obj-$(CONFIG_SCSI_TARGET_PROCESSOR) += scst_processor.o +obj-$(CONFIG_SCSI_TARGET_FILEIO) += scst_fileio.o + else ifeq ($(KDIR),) KDIR := /lib/modules/$(shell uname -r)/build @@ -48,11 +60,9 @@ INSTALL_DIR := /lib/modules/$(shell uname -r)/extra -EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SUBDIRS)/../include -#EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SUBDIRS)/../../include -I$(SUBDIRS)/.. +EXTRA_CFLAGS += -I$(SUBDIRS) -I$(SCST_INC_DIR) #EXTRA_CFLAGS += -DTRACING - EXTRA_CFLAGS += -DDEBUG clean: Modified: trunk/scst/src/dev_handlers/scst_cdrom.c =================================================================== --- trunk/scst/src/dev_handlers/scst_cdrom.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/dev_handlers/scst_cdrom.c 2006-12-15 15:59:21 UTC (rev 62) @@ -20,12 +20,10 @@ #include <linux/cdrom.h> #define LOG_PREFIX "dev_cdrom" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - #define CDROM_NAME "dev_cdrom" #define CDROM_TYPE { \ @@ -58,10 +56,6 @@ int cdrom_parse(struct scst_cmd *, const struct scst_info_cdb *); int cdrom_done(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type cdrom_devtype = CDROM_TYPE; /************************************************************** Modified: trunk/scst/src/dev_handlers/scst_changer.c =================================================================== --- trunk/scst/src/dev_handlers/scst_changer.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/dev_handlers/scst_changer.c 2006-12-15 15:59:21 UTC (rev 62) @@ -18,12 +18,10 @@ */ #define LOG_PREFIX "dev_changer" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - #define CHANGER_NAME "dev_changer" #define CHANGER_TYPE { \ @@ -47,10 +45,6 @@ int changer_parse(struct scst_cmd *, const struct scst_info_cdb *); int changer_done(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type changer_devtype = CHANGER_TYPE; /************************************************************** Modified: trunk/scst/src/dev_handlers/scst_dev_handler.h =================================================================== --- trunk/scst/src/dev_handlers/scst_dev_handler.h 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/dev_handlers/scst_dev_handler.h 2006-12-15 15:59:21 UTC (rev 62) @@ -1,3 +1,6 @@ +#ifndef __SCST_DEV_HANDLER_H +#define __SCST_DEV_HANDLER_H + #include <scsi/scsi_eh.h> #define SCST_DEV_UA_RETRIES 5 @@ -10,6 +13,8 @@ #include <linux/proc_fs.h> #include <linux/seq_file.h> +#include "scst_debug.h" + #ifdef DEBUG #define SCST_DEFAULT_DEV_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_PID | \ TRACE_FUNCTION | TRACE_MGMT | TRACE_MINOR | TRACE_MGMT_DEBUG | \ @@ -18,6 +23,9 @@ #define SCST_DEFAULT_DEV_LOG_FLAGS (TRACE_OUT_OF_MEM | TRACE_MGMT | TRACE_MINOR) #endif +static unsigned long dh_trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; +#define trace_flag dh_trace_flag + static struct scst_proc_data dev_handler_log_proc_data; static int dev_handler_log_info_show(struct seq_file *seq, void *v) @@ -25,6 +33,7 @@ int res = 0; TRACE_ENTRY(); + res = scst_proc_log_entry_read(seq, trace_flag, NULL); TRACE_EXIT_RES(res); @@ -55,7 +64,6 @@ TRACE_ENTRY(); root = scst_proc_get_dev_type_root(dev_type); - if (root) { /* create the proc file entry for the device */ dev_handler_log_proc_data.data = (void *)dev_type->name; @@ -84,10 +92,10 @@ TRACE_ENTRY(); root = scst_proc_get_dev_type_root(dev_type); - if (root) { remove_proc_entry(DEV_HANDLER_LOG_ENTRY_NAME, root); } + TRACE_EXIT(); #endif } @@ -98,3 +106,5 @@ .show = dev_handler_log_info_show, }; #endif + +#endif /* __SCST_DEV_HANDLER_H */ Modified: trunk/scst/src/dev_handlers/scst_disk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_disk.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/dev_handlers/scst_disk.c 2006-12-15 15:59:21 UTC (rev 62) @@ -24,12 +24,10 @@ #include <linux/init.h> #define LOG_PREFIX "dev_disk" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - # define DISK_NAME "dev_disk" # define DISK_PERF_NAME "dev_disk_perf" @@ -78,10 +76,6 @@ int disk_done(struct scst_cmd *cmd); int disk_exec(struct scst_cmd *cmd); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type disk_devtype = DISK_TYPE; static struct scst_dev_type disk_devtype_perf = DISK_PERF_TYPE; @@ -90,7 +84,7 @@ int res = 0; TRACE_ENTRY(); - + disk_devtype.module = THIS_MODULE; if (scst_register_dev_driver(&disk_devtype) < 0) { res = -ENODEV; Modified: trunk/scst/src/dev_handlers/scst_fileio.c =================================================================== --- trunk/scst/src/dev_handlers/scst_fileio.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/dev_handlers/scst_fileio.c 2006-12-15 15:59:21 UTC (rev 62) @@ -37,12 +37,10 @@ #include <linux/kthread.h> #define LOG_PREFIX "dev_fileio" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - /* 8 byte ASCII Vendor of the FILE IO target */ #define SCST_FIO_VENDOR "SCST_FIO" /* 4 byte ASCII Product Revision Level of the FILE IO target - left aligned */ @@ -81,10 +79,6 @@ #define FILEIO_PROC_HELP "help" -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - struct scst_fileio_dev { uint32_t block_size; uint64_t nblocks; @@ -3109,7 +3103,6 @@ TRACE_ENTRY(); devtype->module = THIS_MODULE; - res = scst_register_virtual_dev_driver(devtype); if (res < 0) goto out; Modified: trunk/scst/src/dev_handlers/scst_modisk.c =================================================================== --- trunk/scst/src/dev_handlers/scst_modisk.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/dev_handlers/scst_modisk.c 2006-12-15 15:59:21 UTC (rev 62) @@ -24,12 +24,10 @@ #include <linux/init.h> #define LOG_PREFIX "dev_modisk" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - # define MODISK_NAME "dev_modisk" # define MODISK_PERF_NAME "dev_modisk_perf" @@ -78,10 +76,6 @@ int modisk_done(struct scst_cmd *); int modisk_exec(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type modisk_devtype = MODISK_TYPE; static struct scst_dev_type modisk_devtype_perf = MODISK_PERF_TYPE; Modified: trunk/scst/src/dev_handlers/scst_processor.c =================================================================== --- trunk/scst/src/dev_handlers/scst_processor.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/dev_handlers/scst_processor.c 2006-12-15 15:59:21 UTC (rev 62) @@ -18,12 +18,10 @@ */ #define LOG_PREFIX "dev_processor" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - #define PROCESSOR_NAME "dev_processor" #define PROCESSOR_TYPE { \ @@ -47,10 +45,6 @@ int processor_parse(struct scst_cmd *, const struct scst_info_cdb *); int processor_done(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type processor_devtype = PROCESSOR_TYPE; /************************************************************** @@ -211,7 +205,7 @@ int res = 0; TRACE_ENTRY(); - + processor_devtype.module = THIS_MODULE; if (scst_register_dev_driver(&processor_devtype) < 0) { res = -ENODEV; Modified: trunk/scst/src/dev_handlers/scst_raid.c =================================================================== --- trunk/scst/src/dev_handlers/scst_raid.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/dev_handlers/scst_raid.c 2006-12-15 15:59:21 UTC (rev 62) @@ -18,12 +18,10 @@ */ #define LOG_PREFIX "dev_raid" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - #define RAID_NAME "dev_raid" #define RAID_TYPE { \ @@ -47,10 +45,6 @@ int raid_parse(struct scst_cmd *, const struct scst_info_cdb *); int raid_done(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type raid_devtype = RAID_TYPE; /************************************************************** @@ -211,7 +205,7 @@ int res = 0; TRACE_ENTRY(); - + raid_devtype.module = THIS_MODULE; if (scst_register_dev_driver(&raid_devtype) < 0) { res = -ENODEV; Modified: trunk/scst/src/dev_handlers/scst_tape.c =================================================================== --- trunk/scst/src/dev_handlers/scst_tape.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/dev_handlers/scst_tape.c 2006-12-15 15:59:21 UTC (rev 62) @@ -24,12 +24,10 @@ #include <linux/init.h> #define LOG_PREFIX "dev_tape" -#include "scst_debug.h" + #include "scsi_tgt.h" #include "scst_dev_handler.h" -#include "scst_debug.c" - # define TAPE_NAME "dev_tape" # define TAPE_PERF_NAME "dev_tape_perf" @@ -91,10 +89,6 @@ int tape_done(struct scst_cmd *); int tape_exec(struct scst_cmd *); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_DEV_LOG_FLAGS; -#endif - static struct scst_dev_type tape_devtype = TAPE_TYPE; static struct scst_dev_type tape_devtype_perf = TAPE_PERF_TYPE; @@ -103,7 +97,7 @@ int res = 0; TRACE_ENTRY(); - + tape_devtype.module = THIS_MODULE; if (scst_register_dev_driver(&tape_devtype) < 0) { res = -ENODEV; Modified: trunk/scst/src/scst.c =================================================================== --- trunk/scst/src/scst.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/scst.c 2006-12-15 15:59:21 UTC (rev 62) @@ -28,12 +28,13 @@ #include <asm/string.h> #include <linux/kthread.h> -#include "scst_debug.h" #include "scsi_tgt.h" #include "scst_priv.h" #include "scst_mem.h" -#include "scst_debug.c" +#if defined(DEBUG) || defined(TRACING) +unsigned long scst_trace_flag = SCST_DEFAULT_LOG_FLAGS; +#endif /* * All targets, devices and dev_types management is done under @@ -70,10 +71,6 @@ LIST_HEAD(scst_cmd_list); DECLARE_WAIT_QUEUE_HEAD(scst_list_waitQ); -#if defined(DEBUG) || defined(TRACING) -unsigned long trace_flag = SCST_DEFAULT_LOG_FLAGS; -#endif - spinlock_t scst_cmd_mem_lock = SPIN_LOCK_UNLOCKED; unsigned long scst_cur_cmd_mem, scst_cur_max_cmd_mem; Added: trunk/scst/src/scst_debug.c =================================================================== --- trunk/scst/src/scst_debug.c (rev 0) +++ trunk/scst/src/scst_debug.c 2006-12-15 15:59:21 UTC (rev 62) @@ -0,0 +1,113 @@ +/* + * include/scst_debug.c + * + * Copyright (C) 2004-2006 Vladislav Bolkhovitin <vs...@vl...> + * and Leonid Stoljar + * + * Contains helper functions for execution tracing and error reporting. + * Intended to be included in main .c file. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, version 2 + * of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "scst_debug.h" +#include "scsi_tgt.h" + +#if defined(DEBUG) || defined(TRACING) + +#define TRACE_BUF_SIZE 512 + +static char trace_buf[TRACE_BUF_SIZE]; +static spinlock_t trace_buf_lock = SPIN_LOCK_UNLOCKED; + +int debug_print_prefix(unsigned long trace_flag, const char *func, + int line) +{ + int i = 0; + unsigned long flags; + + spin_lock_irqsave(&trace_buf_lock, flags); + + if (trace_flag & TRACE_PID) + i += snprintf(&trace_buf[i], TRACE_BUF_SIZE, "[%d]: ", + current->pid); + if (trace_flag & TRACE_FUNCTION) + i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "%s:", func); + if (trace_flag & TRACE_LINE) + i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "%i:", line); + + if (i > 0) + PRINTN(LOG_FLAG, "%s", trace_buf); + + spin_unlock_irqrestore(&trace_buf_lock, flags); + + return i; +} + +void debug_print_buffer(unsigned long trace_flag, const void *data, + int len) +{ + int z, z1, i; + const unsigned char *buf = (const unsigned char *) data; + int f = 0; + unsigned long flags; + + if (buf == NULL) + return; + + spin_lock_irqsave(&trace_buf_lock, flags); + + PRINT(NO_FLAG, " (h)___0__1__2__3__4__5__6__7__8__9__A__B__C__D__E__F"); + for (z = 0, z1 = 0, i = 0; z < len; z++) { + if (z % 16 == 0) { + if (z != 0) { + i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, + " "); + for (; (z1 < z) && (i < TRACE_BUF_SIZE - 1); + z1++) { + if ((buf[z1] >= 0x20) && + (buf[z1] < 0x80)) + trace_buf[i++] = buf[z1]; + else + trace_buf[i++] = '.'; + } + trace_buf[i] = '\0'; + PRINT(NO_FLAG, "%s", trace_buf); + i = 0; + f = 1; + } + i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, + "%4x: ", z); + } + i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, "%02x ", + buf[z]); + } + i += snprintf(&trace_buf[i], TRACE_BUF_SIZE - i, " "); + for (; (z1 < z) && (i < TRACE_BUF_SIZE - 1); z1++) { + if ((buf[z1] > 0x20) && (buf[z1] < 0x80)) + trace_buf[i++] = buf[z1]; + else + trace_buf[i++] = '.'; + } + trace_buf[i] = '\0'; + if (f) { + PRINT(LOG_FLAG, "%s", trace_buf) + } else { + PRINT(NO_FLAG, "%s", trace_buf); + } + + spin_unlock_irqrestore(&trace_buf_lock, flags); + return; +} + +EXPORT_SYMBOL(debug_print_prefix); +EXPORT_SYMBOL(debug_print_buffer); +#endif /* DEBUG || TRACING */ Modified: trunk/scst/src/scst_mem.c =================================================================== --- trunk/scst/src/scst_mem.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/scst_mem.c 2006-12-15 15:59:21 UTC (rev 62) @@ -30,8 +30,8 @@ #endif #include "scsi_tgt.h" +#include "scst_priv.h" #include "scst_debug.h" -#include "scst_priv.h" #include "scst_mem.h" /* Modified: trunk/scst/src/scst_priv.h =================================================================== --- trunk/scst/src/scst_priv.h 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/scst_priv.h 2006-12-15 15:59:21 UTC (rev 62) @@ -30,6 +30,8 @@ #include <scsi/scsi_request.h> #endif +#include "scst_debug.h" + #define SCST_MAJOR 177 #define TRACE_RETRY 0x80000000 @@ -41,6 +43,11 @@ #define LOG_PREFIX "scst" +#if defined(DEBUG) || defined(TRACING) +#define trace_flag scst_trace_flag +extern unsigned long scst_trace_flag; +#endif + #ifdef DEBUG /*#define SCST_DEFAULT_LOG_FLAGS (TRACE_ALL & ~TRACE_MEMORY & ~TRACE_BUFF \ & ~TRACE_FUNCTION) Modified: trunk/scst/src/scst_proc.c =================================================================== --- trunk/scst/src/scst_proc.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/scst_proc.c 2006-12-15 15:59:21 UTC (rev 62) @@ -30,7 +30,6 @@ #include <linux/proc_fs.h> #include <linux/seq_file.h> -#include "scst_debug.h" #include "scsi_tgt.h" #include "scst_mem.h" #include "scst_priv.h" Modified: trunk/scst/src/scst_targ.c =================================================================== --- trunk/scst/src/scst_targ.c 2006-12-15 11:45:24 UTC (rev 61) +++ trunk/scst/src/scst_targ.c 2006-12-15 15:59:21 UTC (rev 62) @@ -27,7 +27,6 @@ #include <asm/string.h> #include <linux/kthread.h> -#include "scst_debug.h" #include "scsi_tgt.h" #include "scst_priv.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |