Re: [RFC_V3 PATCH 2/2] qla4xxx: Add flash target mgmt support through sysfs.

2013-01-11 Thread Vikas Chaudhary


-Original Message-
From: Eddie Wai eddie@broadcom.com
Reply-To: open-iscsi@googlegroups.com open-iscsi@googlegroups.com
Date: Friday 11 January 2013 6:32 AM
To: open-iscsi@googlegroups.com open-iscsi@googlegroups.com
Cc: Mike Christie micha...@cs.wisc.edu, Vikas
vikas.chaudh...@qlogic.com, Lalit Chandivade
lalit.chandiv...@qlogic.com, Ravi Anand ravi.an...@qlogic.com,
Poornima Vonti poornima.vo...@qlogic.com, Manish Rangankar
manish.rangan...@qlogic.com, Adheer Chandravanshi
adheer.chandravan...@qlogic.com
Subject: Re: [RFC_V3 PATCH 2/2] qla4xxx: Add flash target mgmt support
through sysfs.

This looks to be a bug where tgt is being dereferenced prior to the
existence check.

On Fri, 2012-11-30 at 07:16 -0500, vikas.chaudh...@qlogic.com wrote:
 +static int qla4xxx_sysfs_ddb_is_non_persistent(struct device *dev,
 void *data)
 +{
 +   struct iscsi_flash_tgt *tgt = iscsi_dev_to_flash_tgt(dev);
 +   struct ddb_sysfs_entry *ddb_sysfs = tgt-dd_data;
 +   int *valid_cookie = data;
 +
 +   if (!iscsi_is_flash_tgt_dev(dev))
 +   return 0;
 +
 +   tgt = iscsi_dev_to_flash_tgt(dev);
 +   ddb_sysfs = tgt-dd_data;
 +
 +   return !(ddb_sysfs-fw_ddb.cookie == *valid_cookie);
 +}

We fix this issue in updated patch send on open-iscsi list today.

Thanks for pointing out this.
-Vikas.




This message and any attached documents contain information from QLogic 
Corporation or its wholly-owned subsidiaries that may be confidential. If you 
are not the intended recipient, you may not read, copy, distribute, or use this 
information. If you have received this transmission in error, please notify the 
sender immediately by reply e-mail and then delete this message.

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



Re: [RFC_V3 PATCH 2/2] qla4xxx: Add flash target mgmt support through sysfs.

2013-01-10 Thread Eddie Wai
This looks to be a bug where tgt is being dereferenced prior to the
existence check.

On Fri, 2012-11-30 at 07:16 -0500, vikas.chaudh...@qlogic.com wrote:
 +static int qla4xxx_sysfs_ddb_is_non_persistent(struct device *dev,
 void *data)
 +{
 +   struct iscsi_flash_tgt *tgt = iscsi_dev_to_flash_tgt(dev);
 +   struct ddb_sysfs_entry *ddb_sysfs = tgt-dd_data;
 +   int *valid_cookie = data;
 +
 +   if (!iscsi_is_flash_tgt_dev(dev))
 +   return 0;
 +
 +   tgt = iscsi_dev_to_flash_tgt(dev);
 +   ddb_sysfs = tgt-dd_data;
 +
 +   return !(ddb_sysfs-fw_ddb.cookie == *valid_cookie);
 +}


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



[RFC_V3 PATCH 2/2] qla4xxx: Add flash target mgmt support through sysfs.

2012-11-30 Thread vikas . chaudhary
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

This patch allows iscsiadm to manage iSCSI target information stored on
qla4xxx adapter flash on per host basis.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/ql4_def.h  |   12 +
 drivers/scsi/qla4xxx/ql4_fw.h   |   33 +-
 drivers/scsi/qla4xxx/ql4_glbl.h |2 +
 drivers/scsi/qla4xxx/ql4_mbx.c  |4 +-
 drivers/scsi/qla4xxx/ql4_os.c   | 1324 ++-
 5 files changed, 1369 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index 329d553..d099c89 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -280,6 +280,14 @@ struct ddb_entry {
uint16_t chap_tbl_idx;
 };
 
+struct ddb_sysfs_entry {
+   struct scsi_qla_host *ha;
+   struct dev_db_entry fw_ddb;
+   uint16_t tgt_flash_idx;
+   uint16_t tgt_sess_idx;
+   uint8_t is_dirty;
+};
+
 struct qla_ddb_index {
struct list_head list;
uint16_t fw_ddb_idx;
@@ -498,6 +506,7 @@ struct scsi_qla_host {
 #define AF_INIT_DONE   1 /* 0x0002 */
 #define AF_MBOX_COMMAND2 /* 0x0004 */
 #define AF_MBOX_COMMAND_DONE   3 /* 0x0008 */
+#define AF_ST_DISCOVERY_IN_PROGRESS4 /* 0x0010 */
 #define AF_INTERRUPTS_ON   6 /* 0x0040 */
 #define AF_GET_CRASH_RECORD7 /* 0x0080 */
 #define AF_LINK_UP 8 /* 0x0100 */
@@ -658,6 +667,9 @@ struct scsi_qla_host {
/* FW ddb index map */
struct ddb_entry *fw_ddb_index_map[MAX_DDB_ENTRIES];
 
+   /* kobj of host sysfs entry holding flash ddbs */
+   struct iscsi_host_kobj *host_kobj;
+
/* Saved srb for status continuation entry processing */
struct srb *status_srb;
 
diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h
index 1c47950..50f1f93 100644
--- a/drivers/scsi/qla4xxx/ql4_fw.h
+++ b/drivers/scsi/qla4xxx/ql4_fw.h
@@ -766,6 +766,36 @@ struct ql4_chap_table {
uint16_t cookie;
 };
 
+/* Options bits */
+#define OPT_AUTO_SEND_TARGET_DISABLE   (1  6)
+#define OPT_DISCOVERY_SESSION  (1  4)
+#define OPT_DDB_ENTRY_STATE(1  3)
+#define OPT_DEV_ASSOC_TARGET   (1  1)
+#define OPT_DEV_ASSOC_INITIATOR(1  0)
+
+/* iSCSI Options bits */
+#define ISCSIOPT_ENABLE_HEADER_DIGEST  (1  13)
+#define ISCSIOPT_ENABLE_DATA_DIGEST(1  12)
+#define ISCSIOPT_ENABLE_IMMEDIATE_DATA (1  11)
+#define ISCSIOPT_ENABLE_INITIAL_R2T(1  10)
+#define ISCSIOPT_DATA_SEQ_IN_ORDER (1  9)
+#define ISCSIOPT_DATA_PDU_IN_ORDER (1  8)
+#define ISCSIOPT_CHAP_AUTH_ENABLE  (1  7)
+#define ISCSIOPT_SNACK_REQ_ENABLE  (1  6)
+#define ISCSIOPT_DISCOVERY_LOGOUT_ENABLE   (1  5)
+#define ISCSIOPT_BIDI_CHAP_CHALLENGE_ENABLE(1  4)
+#define ISCSIOPT_DISCOVERY_AUTH_OPTIONAL   (1  3)
+
+/* TCP Options bits */
+#define TCPOPT_NAGLE_DISABLE   (1  5)
+#define TCPOPT_TCP_TIMER_SCALE3(1  3)
+#define TCPOPT_TCP_TIMER_SCALE2(1  2)
+#define TCPOPT_TCP_TIMER_SCALE1(1  1)
+#define TCPOPT_TIMESTAMP_ENABLE(1  0)
+
+/* IP Options bits */
+#define IPOPT_FRAGMENTATION_DISABLE(1  4)
+
 struct dev_db_entry {
uint16_t options;   /* 00-01 */
 #define DDB_OPT_DISC_SESSION  0x10
@@ -777,7 +807,8 @@ struct dev_db_entry {
 
uint16_t exec_throttle; /* 02-03 */
uint16_t exec_count;/* 04-05 */
-   uint16_t res0;  /* 06-07 */
+   uint8_t retry_count;/* 06 */
+   uint8_t retry_delay;/* 07 */
uint16_t iscsi_options; /* 08-09 */
uint16_t tcp_options;   /* 0A-0B */
uint16_t ip_options;/* 0C-0D */
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index 57a5a3c..3de6e73 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -259,6 +259,8 @@ int qla4_8xxx_set_param(struct scsi_qla_host *ha, int 
param);
 int qla4_8xxx_update_idc_reg(struct scsi_qla_host *ha);
 int qla4_83xx_post_idc_ack(struct scsi_qla_host *ha);
 void qla4_83xx_disable_pause(struct scsi_qla_host *ha);
+int qla4xxx_get_default_ddb(struct scsi_qla_host *ha, uint32_t options,
+   dma_addr_t dma_addr);
 
 extern int ql4xextended_error_logging;
 extern int ql4xdontresethba;
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 3d41034..efb1488 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1246,8 +1246,8 @@ exit_about_fw:
return status;
 }
 
-static int qla4xxx_get_default_ddb(struct scsi_qla_host *ha, uint32_t options,
-  dma_addr_t dma_addr)
+int qla4xxx_get_default_ddb(struct scsi_qla_host *ha, uint32_t options,
+  

[RFC_V2 PATCH 2/2] qla4xxx: Add flash target mgmt support through sysfs.

2012-11-09 Thread vikas . chaudhary
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

This patch allows iscsiadm to manage iSCSI target information stored on
qla4xxx adapter flash on per host basis.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/Kconfig|1 +
 drivers/scsi/qla4xxx/ql4_def.h  |   12 +
 drivers/scsi/qla4xxx/ql4_fw.h   |   28 +
 drivers/scsi/qla4xxx/ql4_glbl.h |2 +
 drivers/scsi/qla4xxx/ql4_mbx.c  |4 +-
 drivers/scsi/qla4xxx/ql4_os.c   | 1154 ++-
 6 files changed, 1196 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/qla4xxx/Kconfig b/drivers/scsi/qla4xxx/Kconfig
index e4dc7c7..16f2b58 100644
--- a/drivers/scsi/qla4xxx/Kconfig
+++ b/drivers/scsi/qla4xxx/Kconfig
@@ -3,6 +3,7 @@ config SCSI_QLA_ISCSI
depends on PCI  SCSI  NET
select SCSI_ISCSI_ATTRS
select ISCSI_BOOT_SYSFS
+   select ISCSI_FLASH_SYSFS
---help---
This driver supports the QLogic 40xx (ISP4XXX), 8022 (ISP82XX)
and 8032 (ISP83XX) iSCSI host adapter family.
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index 8e061ea..15aee02 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -280,6 +280,14 @@ struct ddb_entry {
uint16_t chap_tbl_idx;
 };
 
+struct ddb_sysfs_entry {
+   struct scsi_qla_host *ha;
+   struct dev_db_entry fw_ddb;
+   uint16_t tgt_flash_idx;
+   uint16_t tgt_sess_idx;
+   uint8_t is_dirty;
+};
+
 struct qla_ddb_index {
struct list_head list;
uint16_t fw_ddb_idx;
@@ -498,6 +506,7 @@ struct scsi_qla_host {
 #define AF_INIT_DONE   1 /* 0x0002 */
 #define AF_MBOX_COMMAND2 /* 0x0004 */
 #define AF_MBOX_COMMAND_DONE   3 /* 0x0008 */
+#define AF_ST_DISCOVERY_IN_PROGRESS4 /* 0x0010 */
 #define AF_INTERRUPTS_ON   6 /* 0x0040 */
 #define AF_GET_CRASH_RECORD7 /* 0x0080 */
 #define AF_LINK_UP 8 /* 0x0100 */
@@ -658,6 +667,9 @@ struct scsi_qla_host {
/* FW ddb index map */
struct ddb_entry *fw_ddb_index_map[MAX_DDB_ENTRIES];
 
+   /* kobj of host sysfs entry holding flash ddbs */
+   struct iscsi_host_kobj *host_kobj;
+
/* Saved srb for status continuation entry processing */
struct srb *status_srb;
 
diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h
index 1ef954f..f41419c 100644
--- a/drivers/scsi/qla4xxx/ql4_fw.h
+++ b/drivers/scsi/qla4xxx/ql4_fw.h
@@ -757,6 +757,34 @@ struct ql4_chap_table {
uint16_t cookie;
 };
 
+/* Options bits */
+#define OPT_AUTO_SEND_TARGET_DISABLE   (1  6)
+#define OPT_DISCOVERY_SESSION  (1  4)
+#define OPT_DDB_ENTRY_STATE(1  3)
+
+/* iSCSI Options bits */
+#define ISCSIOPT_ENABLE_HEADER_DIGEST  (1  13)
+#define ISCSIOPT_ENABLE_DATA_DIGEST(1  12)
+#define ISCSIOPT_ENABLE_IMMEDIATE_DATA (1  11)
+#define ISCSIOPT_ENABLE_INITIAL_R2T(1  10)
+#define ISCSIOPT_DATA_SEQ_IN_ORDER (1  9)
+#define ISCSIOPT_DATA_PDU_IN_ORDER (1  8)
+#define ISCSIOPT_CHAP_AUTH_ENABLE  (1  7)
+#define ISCSIOPT_SNACK_REQ_ENABLE  (1  6)
+#define ISCSIOPT_DISCOVERY_LOGOUT_ENABLE   (1  5)
+#define ISCSIOPT_BI_CHAP_CHALLENGE_ENABLE  (1  4)
+#define ISCSIOPT_DISCOVERY_AUTH_OPT(1  3)
+
+/* TCP Options bits */
+#define TCPOPT_NAGLE_DISABLE   (1  5)
+#define TCPOPT_TCP_TIMER_SCALE3(1  3)
+#define TCPOPT_TCP_TIMER_SCALE2(1  2)
+#define TCPOPT_TCP_TIMER_SCALE1(1  1)
+#define TCPOPT_TIMESTAMP_ENABLE(1  0)
+
+/* IP Options bits */
+#define IPOPT_FRAGMENTATION_DISABLE(1  4)
+
 struct dev_db_entry {
uint16_t options;   /* 00-01 */
 #define DDB_OPT_DISC_SESSION  0x10
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index b5655ac..e884efe 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -255,6 +255,8 @@ int qla4_8xxx_device_bootstrap(struct scsi_qla_host *ha);
 void qla4_8xxx_get_minidump(struct scsi_qla_host *ha);
 int qla4_8xxx_mbx_intr_disable(struct scsi_qla_host *ha);
 int qla4_8xxx_mbx_intr_enable(struct scsi_qla_host *ha);
+int qla4xxx_get_default_ddb(struct scsi_qla_host *ha, uint32_t options,
+   dma_addr_t dma_addr);
 
 extern int ql4xextended_error_logging;
 extern int ql4xdontresethba;
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 0375132..2789d5f 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1247,8 +1247,8 @@ exit_about_fw:
return status;
 }
 
-static int qla4xxx_get_default_ddb(struct scsi_qla_host *ha, uint32_t options,
-  dma_addr_t dma_addr)
+int 

[PATCH 2/2] qla4xxx: Add flash target mgmt support through sysfs.

2012-10-15 Thread vikas . chaudhary
From: Adheer Chandravanshi adheer.chandravan...@qlogic.com

This patch allows iscsiadm to manage iSCSI target information stored on
qla4xxx adapter flash on per host basis.

Signed-off-by: Adheer Chandravanshi adheer.chandravan...@qlogic.com
Signed-off-by: Vikas Chaudhary vikas.chaudh...@qlogic.com
---
 drivers/scsi/qla4xxx/Kconfig|1 +
 drivers/scsi/qla4xxx/ql4_def.h  |   13 +
 drivers/scsi/qla4xxx/ql4_glbl.h |2 +
 drivers/scsi/qla4xxx/ql4_mbx.c  |4 +-
 drivers/scsi/qla4xxx/ql4_os.c   |  939 ++-
 5 files changed, 956 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qla4xxx/Kconfig b/drivers/scsi/qla4xxx/Kconfig
index e4dc7c7..16f2b58 100644
--- a/drivers/scsi/qla4xxx/Kconfig
+++ b/drivers/scsi/qla4xxx/Kconfig
@@ -3,6 +3,7 @@ config SCSI_QLA_ISCSI
depends on PCI  SCSI  NET
select SCSI_ISCSI_ATTRS
select ISCSI_BOOT_SYSFS
+   select ISCSI_FLASH_SYSFS
---help---
This driver supports the QLogic 40xx (ISP4XXX), 8022 (ISP82XX)
and 8032 (ISP83XX) iSCSI host adapter family.
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index 8e061ea..9c996c3 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -280,6 +280,13 @@ struct ddb_entry {
uint16_t chap_tbl_idx;
 };
 
+struct ddb_sysfs_entry {
+   struct scsi_qla_host *ha;
+   struct dev_db_entry fw_ddb;
+   uint16_t tgt_flash_idx;
+   uint16_t tgt_sess_idx;
+};
+
 struct qla_ddb_index {
struct list_head list;
uint16_t fw_ddb_idx;
@@ -658,6 +665,9 @@ struct scsi_qla_host {
/* FW ddb index map */
struct ddb_entry *fw_ddb_index_map[MAX_DDB_ENTRIES];
 
+   /* kobj of host sysfs entry holding flash ddbs */
+   struct iscsi_host_kobj *host_kobj;
+
/* Saved srb for status continuation entry processing */
struct srb *status_srb;
 
@@ -1003,4 +1013,7 @@ static inline void qla4_8xxx_wr_direct(struct 
scsi_qla_host *ha,
 /* Defines for udev events */
 #define QL4_UEVENT_CODE_FW_DUMP0
 
+/* Flag to denote ST discovery in progress */
+#define DISCOVERY_IN_PROGRESS  0
+
 #endif /*_QLA4XXX_H */
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index b5655ac..e884efe 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -255,6 +255,8 @@ int qla4_8xxx_device_bootstrap(struct scsi_qla_host *ha);
 void qla4_8xxx_get_minidump(struct scsi_qla_host *ha);
 int qla4_8xxx_mbx_intr_disable(struct scsi_qla_host *ha);
 int qla4_8xxx_mbx_intr_enable(struct scsi_qla_host *ha);
+int qla4xxx_get_default_ddb(struct scsi_qla_host *ha, uint32_t options,
+   dma_addr_t dma_addr);
 
 extern int ql4xextended_error_logging;
 extern int ql4xdontresethba;
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 0375132..2789d5f 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1247,8 +1247,8 @@ exit_about_fw:
return status;
 }
 
-static int qla4xxx_get_default_ddb(struct scsi_qla_host *ha, uint32_t options,
-  dma_addr_t dma_addr)
+int qla4xxx_get_default_ddb(struct scsi_qla_host *ha, uint32_t options,
+   dma_addr_t dma_addr)
 {
uint32_t mbox_cmd[MBOX_REG_COUNT];
uint32_t mbox_sts[MBOX_REG_COUNT];
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index b0b11c5..a7ab53e 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -12,6 +12,7 @@
 
 #include scsi/scsi_tcq.h
 #include scsi/scsicam.h
+#include scsi/iscsi_flash_sysfs.h
 
 #include ql4_def.h
 #include ql4_version.h
@@ -166,6 +167,16 @@ static int qla4xxx_host_reset(struct Scsi_Host *shost, int 
reset_type);
 static int qla4xxx_change_queue_depth(struct scsi_device *sdev, int qdepth,
  int reason);
 
+/*
+ * iSCSI Flash DDB sysfs entry points
+ */
+static ssize_t qla4xxx_sysfs_ddb_set_param(void *data, int type,
+  const char *buf, size_t size);
+static ssize_t qla4xxx_sysfs_ddb_get_param(void *data, int type, char *buf);
+static umode_t qla4xxx_sysfs_ddb_attr_visibility(void *data, int type);
+static ssize_t qla4xxx_sysfs_ddb_add(void *data, const char *buf, size_t len);
+static void qla4xxx_sysfs_ddb_release(void *data);
+
 static struct qla4_8xxx_legacy_intr_set legacy_intr[] =
 QLA82XX_LEGACY_INTR_CONFIG;
 
@@ -5028,6 +5039,927 @@ exit_nt_list:
dma_pool_free(ha-fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma);
 }
 
+static void qla4xxx_build_new_nt_list(struct scsi_qla_host *ha,
+ struct list_head *list_nt)
+{
+   struct dev_db_entry *fw_ddb_entry;
+   dma_addr_t fw_ddb_dma;
+   int max_ddbs;
+   int fw_idx_size;
+   int ret;
+   uint32_t idx = 0, next_idx = 0;
+