A bunch of small fixes and cleanups before 0.9.5
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 30 Nov 2006 16:44:59 +0000 (16:44 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Thu, 30 Nov 2006 16:44:59 +0000 (16:44 +0000)
git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@37 d57e44dd-8a1f-0410-8b47-8ef2f437770f

qla2x00t/qla2x00-target/Makefile
qla2x00t/qla2x00-target/README
qla2x00t/qla2x00-target/qla2x00t.c
qla2x00t/qla2x_tgt_def.h
qla2x00t/qla_attr.c

index e6fc55b..29586ec 100644 (file)
@@ -30,7 +30,6 @@
 SCST_INC_DIR := $(SUBDIRS)/../../scst/include
 SCST_DIR := $(shell pwd)/../../scst/src
 EXTRA_CFLAGS += -I$(SCST_INC_DIR) -DFC_TARGET_SUPPORT
-EXTRA_CFLAGS += -DFC_SCST_WWN_AUTH
 
 INSTALL_DIR := /lib/modules/$(shell uname -r)/extra
 
index 67dab42..9f71e1e 100644 (file)
@@ -56,10 +56,6 @@ Compilation options
 There are the following compilation options, that could be commented
 in/out in Makefile:
 
- - FC_SCST_WWN_AUTH - turns on using remote initiator's WWN as 
-   authentification name for scst_register_session_ex(). If it is off,
-   LOOP ID used instead of WWN.
-
  - DEBUG_TGT - turns on some debugging code, including some logging. Makes
    the driver considerably bigger and slower, producing large amount of
    log data.
index 6bfdd49..38e26c1 100644 (file)
@@ -953,7 +953,7 @@ static inline void q2t_free_cmd(struct q2t_cmd *cmd)
        kmem_cache_free(q2t_cmd_cachep, cmd);
 }
 
-void q2t_on_free_cmd(struct scst_cmd *scst_cmd)
+static void q2t_on_free_cmd(struct scst_cmd *scst_cmd)
 {
        struct q2t_cmd *cmd = (struct q2t_cmd *)scst_cmd_get_tgt_priv(scst_cmd);
 
@@ -1148,7 +1148,7 @@ static void q2t_send_busy(scsi_qla_host_t *ha, atio_entry_t *atio)
        ctio = (ctio_ret_entry_t *)tgt_data.req_pkt(ha);
        ctio->entry_type = CTIO_RET_TYPE;
        ctio->entry_count = 1;
-       ctio->handle = Q2T_BUSY_HANDLE;
+       ctio->handle = Q2T_BUSY_HANDLE | CTIO_COMPLETION_HANDLE_MARK;
        ctio->scsi_status = __constant_cpu_to_le16(BUSY << 1);
 
        /* Set IDs */
@@ -1263,8 +1263,7 @@ static void q2t_alloc_session_done(struct scst_session *scst_sess,
        return;
 }
 
-static char *q2t_make_name(scsi_qla_host_t *ha, int loop_id)
-#ifdef FC_SCST_WWN_AUTH
+static char *q2t_find_name(scsi_qla_host_t *ha, int loop_id)
 {
        int wwn_found = 0;
        char *wwn_str;
@@ -1291,31 +1290,32 @@ static char *q2t_make_name(scsi_qla_host_t *ha, int loop_id)
        }
 
        if (wwn_found == 0) {
-#if 0
-               PRINT_ERROR("qla2x00tgt(%ld): Unable to find wwn login for "
-                       "loop id %d, using loop id instead", ha->instance, loop_id);
-               snprintf(wwn_str, 2*WWN_SIZE, "%d", loop_id);
-#else
-               TRACE_DBG("qla2x00tgt(%ld): Unable to find wwn login for "
+               TRACE_MGMT_DBG("qla2x00tgt(%ld): Unable to find wwn login for "
                        "loop id %d", ha->instance, loop_id);
                kfree(wwn_str);
                wwn_str = NULL;
-#endif
        }
 
-
 out:
        return wwn_str;
 }
-#else
+
+static char *q2t_make_name(scsi_qla_host_t *ha, const uint8_t *name)
 {
-       char *s;
-       s = kmalloc(12, GFP_ATOMIC);
-       if (s != NULL)
-               snprintf(s, 12, "%d", loop_id);
-       return s;
+       char *wwn_str;
+
+       wwn_str = kmalloc(3*WWN_SIZE, GFP_ATOMIC);
+       if (wwn_str == NULL) {
+               TRACE(TRACE_OUT_OF_MEM, "%s", "Allocation of wwn_str failed");
+               goto out;
+       }
+       sprintf(wwn_str, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x",
+               name[1], name[0], name[3], name[2], name[5], name[4], 
+               name[7], name[6]);
+
+out:
+       return wwn_str;
 }
-#endif
 
 /* ha->hardware_lock supposed to be held on entry */
 static int q2t_send_cmd_to_scst(scsi_qla_host_t *ha, atio_entry_t *atio)
@@ -1378,11 +1378,18 @@ static int q2t_send_cmd_to_scst(scsi_qla_host_t *ha, atio_entry_t *atio)
 
                /* register session (remote initiator) */
                {
-                       char *name = q2t_make_name(ha, loop_id);
+                       char *name;
+                       if (IS_QLA2200(ha))
+                               name = q2t_find_name(ha, loop_id);
+                       else {
+                               name = q2t_make_name(ha,
+                                       atio->initiator_port_name);
+                       }
                        if (name == NULL) {
                                res = -ESRCH;
                                goto out_free_sess;
                        }
+
                        sess->scst_sess = scst_register_session(
                                tgt->scst_tgt, 1, name, sess,
                                q2t_alloc_session_done);
@@ -1744,7 +1751,11 @@ static void q2t_response_pkt(scsi_qla_host_t *ha, sts_entry_t *pkt)
                        rc = q2t_send_cmd_to_scst(ha, atio);
                        if (unlikely(rc != 0)) {
                                if (rc == -ESRCH) {
+#if 1 /* With TERM EXCHANGE some FC cards refuse to boot */
+                                       q2t_send_busy(ha, atio);
+#else
                                        q2t_send_term_exchange(ha, NULL, atio, 1);
+#endif
                                } else {
                                        PRINT_INFO("qla2x00tgt(%ld): Unable to "
                                            "send the command to SCSI target "
index de54310..c059495 100644 (file)
@@ -236,8 +236,8 @@ typedef struct
        uint8_t  cdb[MAX_CMDSZ];
        uint32_t data_length;
        uint16_t lun;
-       uint8_t initiator_port_name[WWN_SIZE]; /* on qla23xx */
-       uint16_t reserved_32[6];
+       uint8_t  initiator_port_name[WWN_SIZE]; /* on qla23xx */
+       uint8_t  reserved2[12];
        uint16_t ox_id;
 }atio_entry_t;
 #endif
index 11ea68c..3c07593 100644 (file)
@@ -7,6 +7,7 @@
 #include "qla_def.h"
 
 #include <linux/vmalloc.h>
+#include <linux/delay.h>
 #include <linux/version.h>
 
 #ifdef FC_TARGET_SUPPORT
@@ -61,17 +62,17 @@ qla2x00_store_tgt_enabled(struct class_device *cdev,
                if ((ha->flags.enable_target_mode) || force) {
                        qla_target.tgt_host_action(ha, DISABLE_TARGET_MODE);
                }
+               msleep_interruptible(3*1000);
                break;
        case '1' :
                if ((ha->flags.enable_target_mode == 0) || force) {
                        qla_target.tgt_host_action(ha, ENABLE_TARGET_MODE);
                }
+               msleep_interruptible(3*1000);
                break;
        default:
-#if defined(QL_DEBUG_LEVEL_9) || defined(QL_DEBUG_LEVEL_11)
                printk("%s: Requested action not understood: %s\n",
                       __func__, buffer);
-#endif
                break;
        }