public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] qla4xxx feature update
@ 2011-08-01 10:26 vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 1/8] scsi_transport_iscsi: Added support to update mtu vikas.chaudhary
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: vikas.chaudhary @ 2011-08-01 10:26 UTC (permalink / raw)
  To: JBottomley, michaelc
  Cc: linux-scsi, vikas.chaudhary, lalit.chandivade, ravi.anand

From: Vikas Chaudhary <vikas.chaudhary@qlogic.com>

James,

Following patches are made over scsi-misc and Mike Christie's patchset
posted here: http://marc.info/?l=linux-scsi&m=131161955801957&w=2

Harish Zunjarrao (3):
	qla4xxx: Code cleanup for read/update flash using BSG
	qla4xxx: Add get ACB state support using BSG
	qla4xxx: Add read/update NVRAM support for 40xx adapters using BSG

Vikas Chaudhary (5):
	scsi_transport_iscsi: Added support to update mtu
	qla4xxx: Added support to update mtu
	qla4xxx: Added vendor specific sysfs attributes
	scsi_transport_iscsi: Added support to update initiator iscsi port
	qla4xxx: added support to update initiator iscsi port

drivers/scsi/qla4xxx/ql4_attr.c     |   76 ++++++++
drivers/scsi/qla4xxx/ql4_bsg.c      |  331 +++++++++++++++++++++++++++--------
drivers/scsi/qla4xxx/ql4_bsg.h      |    3 +
drivers/scsi/qla4xxx/ql4_def.h      |   17 ++
drivers/scsi/qla4xxx/ql4_fw.h       |    5 +
drivers/scsi/qla4xxx/ql4_glbl.h     |    6 +
drivers/scsi/qla4xxx/ql4_init.c     |   21 +++
drivers/scsi/qla4xxx/ql4_mbx.c      |   79 +++++++++
drivers/scsi/qla4xxx/ql4_nx.c       |    5 +
drivers/scsi/qla4xxx/ql4_os.c       |   31 ++++
drivers/scsi/scsi_transport_iscsi.c |    8 +
include/scsi/iscsi_if.h             |    2 +


Thanks,
Vikas.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/8] scsi_transport_iscsi: Added support to update mtu
  2011-08-01 10:26 [PATCH 0/8] qla4xxx feature update vikas.chaudhary
@ 2011-08-01 10:26 ` vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 2/8] qla4xxx: " vikas.chaudhary
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vikas.chaudhary @ 2011-08-01 10:26 UTC (permalink / raw)
  To: JBottomley, michaelc
  Cc: linux-scsi, vikas.chaudhary, lalit.chandivade, ravi.anand

From: Vikas Chaudhary <vikas.chaudhary@qlogic.com>

Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
---
 drivers/scsi/scsi_transport_iscsi.c |    4 ++++
 include/scsi/iscsi_if.h             |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index b85f8a4..b3a2515 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -323,6 +323,7 @@ iscsi_iface_net_attr(iface, enabled, ISCSI_NET_PARAM_IFACE_ENABLE);
 iscsi_iface_net_attr(iface, vlan, ISCSI_NET_PARAM_VLAN_ID);
 iscsi_iface_net_attr(iface, vlan_priority, ISCSI_NET_PARAM_VLAN_PRIORITY);
 iscsi_iface_net_attr(iface, vlan_enabled, ISCSI_NET_PARAM_VLAN_ENABLED);
+iscsi_iface_net_attr(iface, mtu, ISCSI_NET_PARAM_MTU);
 
 static mode_t iscsi_iface_attr_is_visible(struct kobject *kobj,
 					  struct attribute *attr, int i)
@@ -340,6 +341,8 @@ static mode_t iscsi_iface_attr_is_visible(struct kobject *kobj,
 		param = ISCSI_NET_PARAM_VLAN_PRIORITY;
 	else if (attr == &dev_attr_iface_vlan_enabled.attr)
 		param = ISCSI_NET_PARAM_VLAN_ENABLED;
+	else if (attr == &dev_attr_iface_mtu.attr)
+		param = ISCSI_NET_PARAM_MTU;
 	else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
 		if (attr == &dev_attr_ipv4_iface_ipaddress.attr)
 			param = ISCSI_NET_PARAM_IPV4_ADDR;
@@ -386,6 +389,7 @@ static struct attribute *iscsi_iface_attrs[] = {
 	&dev_attr_ipv6_iface_router_addr.attr,
 	&dev_attr_ipv6_iface_ipaddr_autocfg.attr,
 	&dev_attr_ipv6_iface_linklocal_autocfg.attr,
+	&dev_attr_iface_mtu.attr,
 	NULL,
 };
 
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 629ca42..d1f0927 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -313,6 +313,7 @@ enum iscsi_net_param {
 	ISCSI_NET_PARAM_VLAN_ENABLED		= 15,
 	ISCSI_NET_PARAM_IFACE_TYPE		= 16,
 	ISCSI_NET_PARAM_IFACE_NAME		= 17,
+	ISCSI_NET_PARAM_MTU			= 18,
 };
 
 enum iscsi_conn_state {
-- 
1.7.6



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/8] qla4xxx: Added support to update mtu
  2011-08-01 10:26 [PATCH 0/8] qla4xxx feature update vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 1/8] scsi_transport_iscsi: Added support to update mtu vikas.chaudhary
@ 2011-08-01 10:26 ` vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 3/8] qla4xxx: Code cleanup for read/update flash using BSG vikas.chaudhary
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vikas.chaudhary @ 2011-08-01 10:26 UTC (permalink / raw)
  To: JBottomley, michaelc
  Cc: linux-scsi, vikas.chaudhary, lalit.chandivade, ravi.anand

From: Vikas Chaudhary <vikas.chaudhary@qlogic.com>

Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
---
 drivers/scsi/qla4xxx/ql4_def.h |    1 +
 drivers/scsi/qla4xxx/ql4_mbx.c |    2 ++
 drivers/scsi/qla4xxx/ql4_os.c  |   12 ++++++++++++
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index 30efb6c..90dc621 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -343,6 +343,7 @@ struct ipaddress_config {
 	struct in6_addr ipv6_addr0;
 	struct in6_addr ipv6_addr1;
 	struct in6_addr ipv6_default_router_addr;
+	uint16_t eth_mtu_size;
 };
 
 #define QL4_CHAP_MAX_NAME_LEN 256
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 72ec7e0..8741cfa 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -333,6 +333,8 @@ qla4xxx_update_local_ip(struct scsi_qla_host *ha,
 	ha->ip_config.ipv4_options = le16_to_cpu(init_fw_cb->ipv4_ip_opts);
 	ha->ip_config.ipv4_addr_state =
 				le16_to_cpu(init_fw_cb->ipv4_addr_state);
+	ha->ip_config.eth_mtu_size =
+				le16_to_cpu(init_fw_cb->eth_mtu_size);
 
 	if (ha->acb_version == ACB_SUPPORTED) {
 		ha->ip_config.ipv6_options = le16_to_cpu(init_fw_cb->ipv6_opts);
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 15355f9..58a270b 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -230,6 +230,7 @@ static mode_t ql4_attr_is_visible(int param_type, int param)
 		case ISCSI_NET_PARAM_VLAN_ID:
 		case ISCSI_NET_PARAM_VLAN_PRIORITY:
 		case ISCSI_NET_PARAM_VLAN_ENABLED:
+		case ISCSI_NET_PARAM_MTU:
 			return S_IRUGO;
 		default:
 			return 0;
@@ -335,6 +336,9 @@ static int qla4xxx_get_iface_param(struct iscsi_iface *iface,
 				       IPV6_OPT_VLAN_TAGGING_ENABLE) ?
 				       "enabled" : "disabled");
 		break;
+	case ISCSI_NET_PARAM_MTU:
+		len = sprintf(buf, "%d\n", ha->ip_config.eth_mtu_size);
+		break;
 	default:
 		len = -ENOSYS;
 	}
@@ -718,6 +722,10 @@ static void qla4xxx_set_ipv6(struct scsi_qla_host *ha,
 			init_fw_cb->ipv6_opts &=
 				cpu_to_le16(~IPV6_OPT_VLAN_TAGGING_ENABLE);
 		break;
+	case ISCSI_NET_PARAM_MTU:
+		init_fw_cb->eth_mtu_size =
+				cpu_to_le16(*(uint16_t *)iface_param->value);
+		break;
 	default:
 		ql4_printk(KERN_ERR, ha, "Unknown IPv6 param = %d\n",
 			   iface_param->param);
@@ -778,6 +786,10 @@ static void qla4xxx_set_ipv4(struct scsi_qla_host *ha,
 			init_fw_cb->ipv4_ip_opts &=
 					cpu_to_le16(~IPOPT_VLAN_TAGGING_ENABLE);
 		break;
+	case ISCSI_NET_PARAM_MTU:
+		init_fw_cb->eth_mtu_size =
+				cpu_to_le16(*(uint16_t *)iface_param->value);
+		break;
 	default:
 		ql4_printk(KERN_ERR, ha, "Unknown IPv4 param = %d\n",
 			   iface_param->param);
-- 
1.7.6



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/8] qla4xxx: Code cleanup for read/update flash using BSG
  2011-08-01 10:26 [PATCH 0/8] qla4xxx feature update vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 1/8] scsi_transport_iscsi: Added support to update mtu vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 2/8] qla4xxx: " vikas.chaudhary
@ 2011-08-01 10:26 ` vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 4/8] qla4xxx: Add get ACB state support " vikas.chaudhary
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vikas.chaudhary @ 2011-08-01 10:26 UTC (permalink / raw)
  To: JBottomley, michaelc
  Cc: linux-scsi, vikas.chaudhary, lalit.chandivade, ravi.anand,
	Harish Zunjarrao

From: Harish Zunjarrao <harish.zunjarrao@qlogic.com>

- Corrected return status
- Added reset active check
- Removed unused dma_map_sg calls
- Added debug prints on failure

Signed-off-by: Harish Zunjarrao <harish.zunjarrao@qlogic.com>
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
---
 drivers/scsi/qla4xxx/ql4_bsg.c |  128 +++++++++++++++++-----------------------
 drivers/scsi/qla4xxx/ql4_def.h |   10 +++
 2 files changed, 65 insertions(+), 73 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_bsg.c b/drivers/scsi/qla4xxx/ql4_bsg.c
index daa2b0f..15032f1 100644
--- a/drivers/scsi/qla4xxx/ql4_bsg.c
+++ b/drivers/scsi/qla4xxx/ql4_bsg.c
@@ -16,36 +16,31 @@ qla4xxx_read_flash(struct bsg_job *bsg_job)
 	struct scsi_qla_host *ha = to_qla_host(host);
 	struct iscsi_bsg_reply *bsg_reply = bsg_job->reply;
 	struct iscsi_bsg_request *bsg_req = bsg_job->request;
-	uint32_t sg_cnt;
 	uint32_t offset = 0;
 	uint32_t length = 0;
 	dma_addr_t flash_dma;
 	uint8_t *flash = NULL;
-	int rval = 0;
+	int rval = -EINVAL;
 
 	bsg_reply->reply_payload_rcv_len = 0;
 
 	if (unlikely(pci_channel_offline(ha->pdev)))
-		return -EINVAL;
+		goto leave;
 
-	if (ha->flash_state != QLFLASH_WAITING)
-		return -EBUSY;
-
-	/* TODO: Add check for adapter online, reset active?? */
-	sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
-			    bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
-
-	if (!sg_cnt)
-		return -ENOMEM;
+	if (ql4xxx_reset_active(ha)) {
+		ql4_printk(KERN_ERR, ha, "%s: reset active\n", __func__);
+		rval = -EBUSY;
+		goto leave;
+	}
 
-	if (sg_cnt != bsg_job->reply_payload.sg_cnt) {
-		ql4_printk(KERN_ERR, ha, "dma mapping resulted in different"
-			   " sg counts, sg_cnt: %x dma_sg_cnt: %x\n",
-			   bsg_job->reply_payload.sg_cnt, sg_cnt);
-		rval = -EAGAIN;
-		goto unmap_sg;
+	if (ha->flash_state != QLFLASH_WAITING) {
+		ql4_printk(KERN_ERR, ha, "%s: another flash operation "
+			   "active\n", __func__);
+		rval = -EBUSY;
+		goto leave;
 	}
 
+	ha->flash_state = QLFLASH_READING;
 	offset = bsg_req->rqst_data.h_vendor.vendor_cmd[1];
 	length = bsg_job->reply_payload.payload_len;
 
@@ -55,31 +50,27 @@ qla4xxx_read_flash(struct bsg_job *bsg_job)
 		ql4_printk(KERN_ERR, ha, "%s: dma alloc failed for flash "
 			   "data\n", __func__);
 		rval = -ENOMEM;
-		goto unmap_sg;
+		goto leave;
 	}
 
-	ha->flash_state = QLFLASH_READING;
-	if (qla4xxx_get_flash(ha, flash_dma, offset, length))
-		bsg_reply->result = (DID_ERROR << 16);
-	else {
-		sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
-				    bsg_job->reply_payload.sg_cnt,
-				    flash, length);
-
-		bsg_reply->result = DID_OK;
-		bsg_reply->reply_payload_rcv_len = length;
+	rval = qla4xxx_get_flash(ha, flash_dma, offset, length);
+	if (rval) {
+		ql4_printk(KERN_ERR, ha, "%s: get flash failed\n", __func__);
+		bsg_reply->result = DID_ERROR << 16;
+		rval = -EIO;
+	} else {
+		bsg_reply->reply_payload_rcv_len =
+			sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
+					    bsg_job->reply_payload.sg_cnt,
+					    flash, length);
+		bsg_reply->result = DID_OK << 16;
 	}
 
-	if (flash)
-		dma_free_coherent(&ha->pdev->dev, length, flash, flash_dma);
-
+	bsg_job_done(bsg_job, bsg_reply->result,
+		     bsg_reply->reply_payload_rcv_len);
+	dma_free_coherent(&ha->pdev->dev, length, flash, flash_dma);
+leave:
 	ha->flash_state = QLFLASH_WAITING;
-unmap_sg:
-	dma_unmap_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
-		     bsg_job->reply_payload.sg_cnt, DMA_FROM_DEVICE);
-	if (!rval)
-		bsg_job_done(bsg_job, bsg_reply->result,
-			     bsg_reply->reply_payload_rcv_len);
 	return rval;
 }
 
@@ -90,36 +81,32 @@ qla4xxx_update_flash(struct bsg_job *bsg_job)
 	struct scsi_qla_host *ha = to_qla_host(host);
 	struct iscsi_bsg_reply *bsg_reply = bsg_job->reply;
 	struct iscsi_bsg_request *bsg_req = bsg_job->request;
-	uint32_t sg_cnt;
 	uint32_t length = 0;
 	uint32_t offset = 0;
 	uint32_t options = 0;
 	dma_addr_t flash_dma;
 	uint8_t *flash = NULL;
-	int rval = 0;
+	int rval = -EINVAL;
 
 	bsg_reply->reply_payload_rcv_len = 0;
 
 	if (unlikely(pci_channel_offline(ha->pdev)))
-		return -EINVAL;
-
-	if (ha->flash_state != QLFLASH_WAITING)
-		return -EBUSY;
+		goto leave;
 
-	sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list,
-			    bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE);
-
-	if (!sg_cnt)
-		return -ENOMEM;
+	if (ql4xxx_reset_active(ha)) {
+		ql4_printk(KERN_ERR, ha, "%s: reset active\n", __func__);
+		rval = -EBUSY;
+		goto leave;
+	}
 
-	if (sg_cnt != bsg_job->request_payload.sg_cnt) {
-		ql4_printk(KERN_ERR, ha, "dma mapping resulted in different "
-			   "sg counts request_sg_cnt: %x dma_request_sg_cnt: "
-			   "%x\n", bsg_job->request_payload.sg_cnt, sg_cnt);
-		rval = -EAGAIN;
-		goto unmap_sg;
+	if (ha->flash_state != QLFLASH_WAITING) {
+		ql4_printk(KERN_ERR, ha, "%s: another flash operation "
+			   "active\n", __func__);
+		rval = -EBUSY;
+		goto leave;
 	}
 
+	ha->flash_state = QLFLASH_WRITING;
 	length = bsg_job->request_payload.payload_len;
 	offset = bsg_req->rqst_data.h_vendor.vendor_cmd[1];
 	options = bsg_req->rqst_data.h_vendor.vendor_cmd[2];
@@ -130,30 +117,25 @@ qla4xxx_update_flash(struct bsg_job *bsg_job)
 		ql4_printk(KERN_ERR, ha, "%s: dma alloc failed for flash "
 			   "data\n", __func__);
 		rval = -ENOMEM;
-		goto unmap_sg;
+		goto leave;
 	}
 
-	ha->flash_state = QLFLASH_WRITING;
 	sg_copy_to_buffer(bsg_job->request_payload.sg_list,
 			  bsg_job->request_payload.sg_cnt, flash, length);
 
-	if (qla4xxx_set_flash(ha, flash_dma, offset, length, options))
-		bsg_reply->result = (DID_ERROR << 16);
-	else {
-		bsg_reply->result = DID_OK;
-		bsg_reply->reply_payload_rcv_len = length;
-	}
-
-	if (flash)
-		dma_free_coherent(&ha->pdev->dev, length, flash, flash_dma);
+	rval = qla4xxx_set_flash(ha, flash_dma, offset, length, options);
+	if (rval) {
+		ql4_printk(KERN_ERR, ha, "%s: set flash failed\n", __func__);
+		bsg_reply->result = DID_ERROR << 16;
+		rval = -EIO;
+	} else
+		bsg_reply->result = DID_OK << 16;
+
+	bsg_job_done(bsg_job, bsg_reply->result,
+		     bsg_reply->reply_payload_rcv_len);
+	dma_free_coherent(&ha->pdev->dev, length, flash, flash_dma);
+leave:
 	ha->flash_state = QLFLASH_WAITING;
-unmap_sg:
-	dma_unmap_sg(&ha->pdev->dev, bsg_job->reply_payload.sg_list,
-		     bsg_job->reply_payload.sg_cnt, DMA_TO_DEVICE);
-
-	if (!rval)
-		bsg_job_done(bsg_job, bsg_reply->result,
-			     bsg_reply->reply_payload_rcv_len);
 	return rval;
 }
 
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index 90dc621..74c71af 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -803,6 +803,16 @@ static inline void ql4xxx_unlock_drvr(struct scsi_qla_host *a)
 		ql4xxx_sem_unlock(a, QL4022_DRVR_SEM_MASK);
 }
 
+static inline int ql4xxx_reset_active(struct scsi_qla_host *ha)
+{
+	return test_bit(DPC_RESET_ACTIVE, &ha->dpc_flags) ||
+	       test_bit(DPC_RESET_HA, &ha->dpc_flags) ||
+	       test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags) ||
+	       test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) ||
+	       test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags) ||
+	       test_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags);
+
+}
 /*---------------------------------------------------------------------------*/
 
 /* Defines for qla4xxx_initialize_adapter() and qla4xxx_recover_adapter() */
-- 
1.7.6



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/8] qla4xxx: Add get ACB state support using BSG
  2011-08-01 10:26 [PATCH 0/8] qla4xxx feature update vikas.chaudhary
                   ` (2 preceding siblings ...)
  2011-08-01 10:26 ` [PATCH 3/8] qla4xxx: Code cleanup for read/update flash using BSG vikas.chaudhary
@ 2011-08-01 10:26 ` vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 5/8] qla4xxx: Add read/update NVRAM support for 40xx adapters " vikas.chaudhary
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vikas.chaudhary @ 2011-08-01 10:26 UTC (permalink / raw)
  To: JBottomley, michaelc
  Cc: linux-scsi, vikas.chaudhary, lalit.chandivade, ravi.anand,
	Harish Zunjarrao

From: Harish Zunjarrao <harish.zunjarrao@qlogic.com>

Signed-off-by: Harish Zunjarrao <harish.zunjarrao@qlogic.com>
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
---
 drivers/scsi/qla4xxx/ql4_bsg.c  |   60 +++++++++++++++++++++++++++++++++++++++
 drivers/scsi/qla4xxx/ql4_bsg.h  |    1 +
 drivers/scsi/qla4xxx/ql4_glbl.h |    2 +
 drivers/scsi/qla4xxx/ql4_mbx.c  |   23 +++++++++++++++
 4 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_bsg.c b/drivers/scsi/qla4xxx/ql4_bsg.c
index 15032f1..de4db29 100644
--- a/drivers/scsi/qla4xxx/ql4_bsg.c
+++ b/drivers/scsi/qla4xxx/ql4_bsg.c
@@ -139,6 +139,63 @@ leave:
 	return rval;
 }
 
+static int
+qla4xxx_get_acb_state(struct bsg_job *bsg_job)
+{
+	struct Scsi_Host *host = iscsi_job_to_shost(bsg_job);
+	struct scsi_qla_host *ha = to_qla_host(host);
+	struct iscsi_bsg_request *bsg_req = bsg_job->request;
+	struct iscsi_bsg_reply *bsg_reply = bsg_job->reply;
+	uint32_t status[MBOX_REG_COUNT];
+	uint32_t acb_idx;
+	uint32_t ip_idx;
+	int rval = -EINVAL;
+
+	bsg_reply->reply_payload_rcv_len = 0;
+
+	if (unlikely(pci_channel_offline(ha->pdev)))
+		goto leave;
+
+	/* Only 4022 and above adapters are supported */
+	if (is_qla4010(ha))
+		goto leave;
+
+	if (ql4xxx_reset_active(ha)) {
+		ql4_printk(KERN_ERR, ha, "%s: reset active\n", __func__);
+		rval = -EBUSY;
+		goto leave;
+	}
+
+	if (bsg_job->reply_payload.payload_len < sizeof(status)) {
+		ql4_printk(KERN_ERR, ha, "%s: invalid payload len %d\n",
+			   __func__, bsg_job->reply_payload.payload_len);
+		rval = -EINVAL;
+		goto leave;
+	}
+
+	acb_idx = bsg_req->rqst_data.h_vendor.vendor_cmd[1];
+	ip_idx = bsg_req->rqst_data.h_vendor.vendor_cmd[2];
+
+	rval = qla4xxx_get_ip_state(ha, acb_idx, ip_idx, status);
+	if (rval) {
+		ql4_printk(KERN_ERR, ha, "%s: get ip state failed\n",
+			   __func__);
+		bsg_reply->result = DID_ERROR << 16;
+		rval = -EIO;
+	} else {
+		bsg_reply->reply_payload_rcv_len =
+			sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
+					    bsg_job->reply_payload.sg_cnt,
+					    status, sizeof(status));
+		bsg_reply->result = DID_OK << 16;
+	}
+
+	bsg_job_done(bsg_job, bsg_reply->result,
+		     bsg_reply->reply_payload_rcv_len);
+leave:
+	return rval;
+}
+
 /**
  * qla4xxx_process_vendor_specific - handle vendor specific bsg request
  * @job: iscsi_bsg_job to handle
@@ -157,6 +214,9 @@ int qla4xxx_process_vendor_specific(struct bsg_job *bsg_job)
 	case QLISCSI_VND_UPDATE_FLASH:
 		return qla4xxx_update_flash(bsg_job);
 
+	case QLISCSI_VND_GET_ACB_STATE:
+		return qla4xxx_get_acb_state(bsg_job);
+
 	default:
 		ql4_printk(KERN_ERR, ha, "%s: invalid BSG vendor command: "
 			   "0x%x\n", __func__, bsg_req->msgcode);
diff --git a/drivers/scsi/qla4xxx/ql4_bsg.h b/drivers/scsi/qla4xxx/ql4_bsg.h
index 5f6424e..0400e1a 100644
--- a/drivers/scsi/qla4xxx/ql4_bsg.h
+++ b/drivers/scsi/qla4xxx/ql4_bsg.h
@@ -10,5 +10,6 @@
 /* BSG Vendor specific commands */
 #define QLISCSI_VND_READ_FLASH		1
 #define QLISCSI_VND_UPDATE_FLASH	2
+#define QLISCSI_VND_GET_ACB_STATE	3
 
 #endif
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index 98d4b17..5c87696 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -58,6 +58,8 @@ int qla4xxx_set_acb(struct scsi_qla_host *ha, uint32_t *mbox_cmd,
 		    uint32_t *mbox_sts, dma_addr_t acb_dma);
 int qla4xxx_get_acb(struct scsi_qla_host *ha, uint32_t *mbox_cmd,
 		    uint32_t *mbox_sts, dma_addr_t acb_dma);
+int qla4xxx_get_ip_state(struct scsi_qla_host *ha, uint32_t acb_idx,
+			 uint32_t ip_idx, uint32_t *sts);
 void qla4xxx_mark_device_missing(struct iscsi_cls_session *cls_session);
 u16 rd_nvram_word(struct scsi_qla_host *ha, int offset);
 u8 rd_nvram_byte(struct scsi_qla_host *ha, int offset);
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 8741cfa..aec7230 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1667,3 +1667,26 @@ int qla4xxx_get_mgmt_data(struct scsi_qla_host *ha, uint16_t fw_ddb_index,
 	}
 	return status;
 }
+
+int qla4xxx_get_ip_state(struct scsi_qla_host *ha, uint32_t acb_idx,
+			 uint32_t ip_idx, uint32_t *sts)
+{
+	uint32_t mbox_cmd[MBOX_REG_COUNT];
+	uint32_t mbox_sts[MBOX_REG_COUNT];
+	int status = QLA_SUCCESS;
+
+	memset(&mbox_cmd, 0, sizeof(mbox_cmd));
+	memset(&mbox_sts, 0, sizeof(mbox_sts));
+	mbox_cmd[0] = MBOX_CMD_GET_IP_ADDR_STATE;
+	mbox_cmd[1] = acb_idx;
+	mbox_cmd[2] = ip_idx;
+
+	status = qla4xxx_mailbox_command(ha, 3, 8, &mbox_cmd[0], &mbox_sts[0]);
+	if (status != QLA_SUCCESS) {
+		DEBUG2(ql4_printk(KERN_WARNING, ha,  "%s: "
+				  "MBOX_CMD_GET_IP_ADDR_STATE failed w/ "
+				  "status %04X\n", __func__, mbox_sts[0]));
+	}
+	memcpy(sts, mbox_sts, sizeof(mbox_sts));
+	return status;
+}
-- 
1.7.6



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/8] qla4xxx: Add read/update NVRAM support for 40xx adapters using BSG
  2011-08-01 10:26 [PATCH 0/8] qla4xxx feature update vikas.chaudhary
                   ` (3 preceding siblings ...)
  2011-08-01 10:26 ` [PATCH 4/8] qla4xxx: Add get ACB state support " vikas.chaudhary
@ 2011-08-01 10:26 ` vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 6/8] qla4xxx: Added vendor specific sysfs attributes vikas.chaudhary
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vikas.chaudhary @ 2011-08-01 10:26 UTC (permalink / raw)
  To: JBottomley, michaelc
  Cc: linux-scsi, vikas.chaudhary, lalit.chandivade, ravi.anand,
	Harish Zunjarrao

From: Harish Zunjarrao <harish.zunjarrao@qlogic.com>

Signed-off-by: Harish Zunjarrao <harish.zunjarrao@qlogic.com>
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
---
 drivers/scsi/qla4xxx/ql4_bsg.c  |  147 +++++++++++++++++++++++++++++++++++++++
 drivers/scsi/qla4xxx/ql4_bsg.h  |    2 +
 drivers/scsi/qla4xxx/ql4_fw.h   |    5 ++
 drivers/scsi/qla4xxx/ql4_glbl.h |    4 +
 drivers/scsi/qla4xxx/ql4_mbx.c  |   52 ++++++++++++++
 5 files changed, 210 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_bsg.c b/drivers/scsi/qla4xxx/ql4_bsg.c
index de4db29..c475453 100644
--- a/drivers/scsi/qla4xxx/ql4_bsg.c
+++ b/drivers/scsi/qla4xxx/ql4_bsg.c
@@ -196,6 +196,147 @@ leave:
 	return rval;
 }
 
+static int
+qla4xxx_read_nvram(struct bsg_job *bsg_job)
+{
+	struct Scsi_Host *host = iscsi_job_to_shost(bsg_job);
+	struct scsi_qla_host *ha = to_qla_host(host);
+	struct iscsi_bsg_request *bsg_req = bsg_job->request;
+	struct iscsi_bsg_reply *bsg_reply = bsg_job->reply;
+	uint32_t offset = 0;
+	uint32_t len = 0;
+	uint32_t total_len = 0;
+	dma_addr_t nvram_dma;
+	uint8_t *nvram = NULL;
+	int rval = -EINVAL;
+
+	bsg_reply->reply_payload_rcv_len = 0;
+
+	if (unlikely(pci_channel_offline(ha->pdev)))
+		goto leave;
+
+	/* Only 40xx adapters are supported */
+	if (!(is_qla4010(ha) || is_qla4022(ha) || is_qla4032(ha)))
+		goto leave;
+
+	if (ql4xxx_reset_active(ha)) {
+		ql4_printk(KERN_ERR, ha, "%s: reset active\n", __func__);
+		rval = -EBUSY;
+		goto leave;
+	}
+
+	offset = bsg_req->rqst_data.h_vendor.vendor_cmd[1];
+	len = bsg_job->reply_payload.payload_len;
+	total_len = offset + len;
+
+	/* total len should not be greater than max NVRAM size */
+	if ((is_qla4010(ha) && total_len > QL4010_NVRAM_SIZE) ||
+	    ((is_qla4022(ha) || is_qla4032(ha)) &&
+	     total_len > QL40X2_NVRAM_SIZE)) {
+		ql4_printk(KERN_ERR, ha, "%s: offset+len greater than max"
+			   " nvram size, offset=%d len=%d\n",
+			   __func__, offset, len);
+		goto leave;
+	}
+
+	nvram = dma_alloc_coherent(&ha->pdev->dev, len, &nvram_dma,
+				   GFP_KERNEL);
+	if (!nvram) {
+		ql4_printk(KERN_ERR, ha, "%s: dma alloc failed for nvram "
+			   "data\n", __func__);
+		rval = -ENOMEM;
+		goto leave;
+	}
+
+	rval = qla4xxx_get_nvram(ha, nvram_dma, offset, len);
+	if (rval) {
+		ql4_printk(KERN_ERR, ha, "%s: get nvram failed\n", __func__);
+		bsg_reply->result = DID_ERROR << 16;
+		rval = -EIO;
+	} else {
+		bsg_reply->reply_payload_rcv_len =
+			sg_copy_from_buffer(bsg_job->reply_payload.sg_list,
+					    bsg_job->reply_payload.sg_cnt,
+					    nvram, len);
+		bsg_reply->result = DID_OK << 16;
+	}
+
+	bsg_job_done(bsg_job, bsg_reply->result,
+		     bsg_reply->reply_payload_rcv_len);
+	dma_free_coherent(&ha->pdev->dev, len, nvram, nvram_dma);
+leave:
+	return rval;
+}
+
+static int
+qla4xxx_update_nvram(struct bsg_job *bsg_job)
+{
+	struct Scsi_Host *host = iscsi_job_to_shost(bsg_job);
+	struct scsi_qla_host *ha = to_qla_host(host);
+	struct iscsi_bsg_request *bsg_req = bsg_job->request;
+	struct iscsi_bsg_reply *bsg_reply = bsg_job->reply;
+	uint32_t offset = 0;
+	uint32_t len = 0;
+	uint32_t total_len = 0;
+	dma_addr_t nvram_dma;
+	uint8_t *nvram = NULL;
+	int rval = -EINVAL;
+
+	bsg_reply->reply_payload_rcv_len = 0;
+
+	if (unlikely(pci_channel_offline(ha->pdev)))
+		goto leave;
+
+	if (!(is_qla4010(ha) || is_qla4022(ha) || is_qla4032(ha)))
+		goto leave;
+
+	if (ql4xxx_reset_active(ha)) {
+		ql4_printk(KERN_ERR, ha, "%s: reset active\n", __func__);
+		rval = -EBUSY;
+		goto leave;
+	}
+
+	offset = bsg_req->rqst_data.h_vendor.vendor_cmd[1];
+	len = bsg_job->request_payload.payload_len;
+	total_len = offset + len;
+
+	/* total len should not be greater than max NVRAM size */
+	if ((is_qla4010(ha) && total_len > QL4010_NVRAM_SIZE) ||
+	    ((is_qla4022(ha) || is_qla4032(ha)) &&
+	     total_len > QL40X2_NVRAM_SIZE)) {
+		ql4_printk(KERN_ERR, ha, "%s: offset+len greater than max"
+			   " nvram size, offset=%d len=%d\n",
+			   __func__, offset, len);
+		goto leave;
+	}
+
+	nvram = dma_alloc_coherent(&ha->pdev->dev, len, &nvram_dma,
+				   GFP_KERNEL);
+	if (!nvram) {
+		ql4_printk(KERN_ERR, ha, "%s: dma alloc failed for flash "
+			   "data\n", __func__);
+		rval = -ENOMEM;
+		goto leave;
+	}
+
+	sg_copy_to_buffer(bsg_job->request_payload.sg_list,
+			  bsg_job->request_payload.sg_cnt, nvram, len);
+
+	rval = qla4xxx_set_nvram(ha, nvram_dma, offset, len);
+	if (rval) {
+		ql4_printk(KERN_ERR, ha, "%s: set nvram failed\n", __func__);
+		bsg_reply->result = DID_ERROR << 16;
+		rval = -EIO;
+	} else
+		bsg_reply->result = DID_OK << 16;
+
+	bsg_job_done(bsg_job, bsg_reply->result,
+		     bsg_reply->reply_payload_rcv_len);
+	dma_free_coherent(&ha->pdev->dev, len, nvram, nvram_dma);
+leave:
+	return rval;
+}
+
 /**
  * qla4xxx_process_vendor_specific - handle vendor specific bsg request
  * @job: iscsi_bsg_job to handle
@@ -217,6 +358,12 @@ int qla4xxx_process_vendor_specific(struct bsg_job *bsg_job)
 	case QLISCSI_VND_GET_ACB_STATE:
 		return qla4xxx_get_acb_state(bsg_job);
 
+	case QLISCSI_VND_READ_NVRAM:
+		return qla4xxx_read_nvram(bsg_job);
+
+	case QLISCSI_VND_UPDATE_NVRAM:
+		return qla4xxx_update_nvram(bsg_job);
+
 	default:
 		ql4_printk(KERN_ERR, ha, "%s: invalid BSG vendor command: "
 			   "0x%x\n", __func__, bsg_req->msgcode);
diff --git a/drivers/scsi/qla4xxx/ql4_bsg.h b/drivers/scsi/qla4xxx/ql4_bsg.h
index 0400e1a..71df80d 100644
--- a/drivers/scsi/qla4xxx/ql4_bsg.h
+++ b/drivers/scsi/qla4xxx/ql4_bsg.h
@@ -11,5 +11,7 @@
 #define QLISCSI_VND_READ_FLASH		1
 #define QLISCSI_VND_UPDATE_FLASH	2
 #define QLISCSI_VND_GET_ACB_STATE	3
+#define QLISCSI_VND_READ_NVRAM		4
+#define QLISCSI_VND_UPDATE_NVRAM	5
 
 #endif
diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h
index 9dc439b..581ff7e 100644
--- a/drivers/scsi/qla4xxx/ql4_fw.h
+++ b/drivers/scsi/qla4xxx/ql4_fw.h
@@ -201,6 +201,9 @@ static inline uint32_t clr_rmask(uint32_t val)
 /* ISP 4022 nvram definitions */
 #define NVR_WRITE_ENABLE			0x00000010	/* 4022 */
 
+#define QL4010_NVRAM_SIZE			0x200
+#define QL40X2_NVRAM_SIZE			0x800
+
 /*  ISP port_status definitions */
 
 /*  ISP Semaphore definitions */
@@ -359,6 +362,8 @@ struct qla_flt_region {
 #define MBOX_CMD_GET_FW_STATE			0x0069
 #define MBOX_CMD_GET_INIT_FW_CTRL_BLOCK_DEFAULTS 0x006A
 #define MBOX_CMD_GET_SYS_INFO			0x0078
+#define MBOX_CMD_GET_NVRAM			0x0078	/* For 40xx */
+#define MBOX_CMD_SET_NVRAM			0x0079	/* For 40xx */
 #define MBOX_CMD_RESTORE_FACTORY_DEFAULTS	0x0087
 #define MBOX_CMD_SET_ACB			0x0088
 #define MBOX_CMD_GET_ACB			0x0089
diff --git a/drivers/scsi/qla4xxx/ql4_glbl.h b/drivers/scsi/qla4xxx/ql4_glbl.h
index 5c87696..35bd0c1 100644
--- a/drivers/scsi/qla4xxx/ql4_glbl.h
+++ b/drivers/scsi/qla4xxx/ql4_glbl.h
@@ -162,6 +162,10 @@ int qla4xxx_bootdb_by_index(struct scsi_qla_host *ha,
 			    dma_addr_t fw_ddb_entry_dma, uint16_t ddb_index);
 int qla4xxx_get_chap(struct scsi_qla_host *ha, char *username,
 		     char *password, uint16_t idx);
+int qla4xxx_get_nvram(struct scsi_qla_host *ha, dma_addr_t nvram_dma,
+		      uint32_t offset, uint32_t size);
+int qla4xxx_set_nvram(struct scsi_qla_host *ha, dma_addr_t nvram_dma,
+		      uint32_t offset, uint32_t size);
 
 /* BSG Functions */
 int qla4xxx_bsg_request(struct bsg_job *bsg_job);
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index aec7230..011c822 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -1690,3 +1690,55 @@ int qla4xxx_get_ip_state(struct scsi_qla_host *ha, uint32_t acb_idx,
 	memcpy(sts, mbox_sts, sizeof(mbox_sts));
 	return status;
 }
+
+int qla4xxx_get_nvram(struct scsi_qla_host *ha, dma_addr_t nvram_dma,
+		      uint32_t offset, uint32_t size)
+{
+	int status = QLA_SUCCESS;
+	uint32_t mbox_cmd[MBOX_REG_COUNT];
+	uint32_t mbox_sts[MBOX_REG_COUNT];
+
+	memset(&mbox_cmd, 0, sizeof(mbox_cmd));
+	memset(&mbox_sts, 0, sizeof(mbox_sts));
+
+	mbox_cmd[0] = MBOX_CMD_GET_NVRAM;
+	mbox_cmd[1] = LSDW(nvram_dma);
+	mbox_cmd[2] = MSDW(nvram_dma);
+	mbox_cmd[3] = offset;
+	mbox_cmd[4] = size;
+
+	status = qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0],
+					 &mbox_sts[0]);
+	if (status != QLA_SUCCESS) {
+		DEBUG2(ql4_printk(KERN_ERR, ha, "scsi%ld: %s: failed "
+				  "status %04X\n", ha->host_no, __func__,
+				  mbox_sts[0]));
+	}
+	return status;
+}
+
+int qla4xxx_set_nvram(struct scsi_qla_host *ha, dma_addr_t nvram_dma,
+		      uint32_t offset, uint32_t size)
+{
+	int status = QLA_SUCCESS;
+	uint32_t mbox_cmd[MBOX_REG_COUNT];
+	uint32_t mbox_sts[MBOX_REG_COUNT];
+
+	memset(&mbox_cmd, 0, sizeof(mbox_cmd));
+	memset(&mbox_sts, 0, sizeof(mbox_sts));
+
+	mbox_cmd[0] = MBOX_CMD_SET_NVRAM;
+	mbox_cmd[1] = LSDW(nvram_dma);
+	mbox_cmd[2] = MSDW(nvram_dma);
+	mbox_cmd[3] = offset;
+	mbox_cmd[4] = size;
+
+	status = qla4xxx_mailbox_command(ha, MBOX_REG_COUNT, 1, &mbox_cmd[0],
+					 &mbox_sts[0]);
+	if (status != QLA_SUCCESS) {
+		DEBUG2(ql4_printk(KERN_ERR, ha, "scsi%ld: %s: failed "
+				  "status %04X\n", ha->host_no, __func__,
+				  mbox_sts[0]));
+	}
+	return status;
+}
-- 
1.7.6



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/8] qla4xxx: Added vendor specific sysfs attributes
  2011-08-01 10:26 [PATCH 0/8] qla4xxx feature update vikas.chaudhary
                   ` (4 preceding siblings ...)
  2011-08-01 10:26 ` [PATCH 5/8] qla4xxx: Add read/update NVRAM support for 40xx adapters " vikas.chaudhary
@ 2011-08-01 10:26 ` vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 7/8] scsi_transport_iscsi: Added support to update initiator iscsi port vikas.chaudhary
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: vikas.chaudhary @ 2011-08-01 10:26 UTC (permalink / raw)
  To: JBottomley, michaelc
  Cc: linux-scsi, vikas.chaudhary, lalit.chandivade, ravi.anand,
	Harish Zunjarrao

From: Vikas Chaudhary <vikas.chaudhary@qlogic.com>

Added board_id, fw_state, phy_port_cnt, phy_port_num,
iscsi_func_cnt, hba_model

Signed-off-by: Harish Zunjarrao <harish.zunjarrao@qlogic.com>
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
---
 drivers/scsi/qla4xxx/ql4_attr.c |   76 +++++++++++++++++++++++++++++++++++++++
 drivers/scsi/qla4xxx/ql4_def.h  |    4 ++
 drivers/scsi/qla4xxx/ql4_init.c |   21 +++++++++++
 drivers/scsi/qla4xxx/ql4_nx.c   |    5 +++
 4 files changed, 106 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_attr.c b/drivers/scsi/qla4xxx/ql4_attr.c
index 864d018..0b0a7d4 100644
--- a/drivers/scsi/qla4xxx/ql4_attr.c
+++ b/drivers/scsi/qla4xxx/ql4_attr.c
@@ -55,15 +55,91 @@ qla4xxx_optrom_version_show(struct device *dev, struct device_attribute *attr,
 			ha->bootload_patch, ha->bootload_build);
 }
 
+static ssize_t
+qla4xxx_board_id_show(struct device *dev, struct device_attribute *attr,
+		      char *buf)
+{
+	struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+	return snprintf(buf, PAGE_SIZE, "0x%08X\n", ha->board_id);
+}
+
+static ssize_t
+qla4xxx_fw_state_show(struct device *dev, struct device_attribute *attr,
+		      char *buf)
+{
+	struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+
+	qla4xxx_get_firmware_state(ha);
+	return snprintf(buf, PAGE_SIZE, "0x%08X%8X\n", ha->firmware_state,
+			ha->addl_fw_state);
+}
+
+static ssize_t
+qla4xxx_phy_port_cnt_show(struct device *dev, struct device_attribute *attr,
+		      char *buf)
+{
+	struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+
+	if (!is_qla8022(ha))
+		return -ENOSYS;
+
+	return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_cnt);
+}
+
+static ssize_t
+qla4xxx_phy_port_num_show(struct device *dev, struct device_attribute *attr,
+		      char *buf)
+{
+	struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+
+	if (!is_qla8022(ha))
+		return -ENOSYS;
+
+	return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->phy_port_num);
+}
+
+static ssize_t
+qla4xxx_iscsi_func_cnt_show(struct device *dev, struct device_attribute *attr,
+		      char *buf)
+{
+	struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+
+	if (!is_qla8022(ha))
+		return -ENOSYS;
+
+	return snprintf(buf, PAGE_SIZE, "0x%04X\n", ha->iscsi_pci_func_cnt);
+}
+
+static ssize_t
+qla4xxx_hba_model_show(struct device *dev, struct device_attribute *attr,
+		       char *buf)
+{
+	struct scsi_qla_host *ha = to_qla_host(class_to_shost(dev));
+
+	return snprintf(buf, PAGE_SIZE, "%s\n", ha->model_name);
+}
+
 static DEVICE_ATTR(fw_version, S_IRUGO, qla4xxx_fw_version_show, NULL);
 static DEVICE_ATTR(serial_num, S_IRUGO, qla4xxx_serial_num_show, NULL);
 static DEVICE_ATTR(iscsi_version, S_IRUGO, qla4xxx_iscsi_version_show, NULL);
 static DEVICE_ATTR(optrom_version, S_IRUGO, qla4xxx_optrom_version_show, NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, qla4xxx_board_id_show, NULL);
+static DEVICE_ATTR(fw_state, S_IRUGO, qla4xxx_fw_state_show, NULL);
+static DEVICE_ATTR(phy_port_cnt, S_IRUGO, qla4xxx_phy_port_cnt_show, NULL);
+static DEVICE_ATTR(phy_port_num, S_IRUGO, qla4xxx_phy_port_num_show, NULL);
+static DEVICE_ATTR(iscsi_func_cnt, S_IRUGO, qla4xxx_iscsi_func_cnt_show, NULL);
+static DEVICE_ATTR(hba_model, S_IRUGO, qla4xxx_hba_model_show, NULL);
 
 struct device_attribute *qla4xxx_host_attrs[] = {
 	&dev_attr_fw_version,
 	&dev_attr_serial_num,
 	&dev_attr_iscsi_version,
 	&dev_attr_optrom_version,
+	&dev_attr_board_id,
+	&dev_attr_fw_state,
+	&dev_attr_phy_port_cnt,
+	&dev_attr_phy_port_num,
+	&dev_attr_iscsi_func_cnt,
+	&dev_attr_hba_model,
 	NULL,
 };
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index 74c71af..17a29ce 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -610,6 +610,10 @@ struct scsi_qla_host {
 #define SYSFS_FLAG_FW_SEL_BOOT 2
 	struct iscsi_boot_kset *boot_kset;
 	struct ql4_boot_tgt_info boot_tgt;
+	uint16_t phy_port_num;
+	uint16_t phy_port_cnt;
+	uint16_t iscsi_pci_func_cnt;
+	uint8_t model_name[16];
 };
 
 struct ql4_task_data {
diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c
index 21f6f4b..b0bffe1 100644
--- a/drivers/scsi/qla4xxx/ql4_init.c
+++ b/drivers/scsi/qla4xxx/ql4_init.c
@@ -446,6 +446,21 @@ static int qla4xxx_init_firmware(struct scsi_qla_host *ha)
 	return qla4xxx_get_firmware_status(ha);
 }
 
+static void qla4xxx_set_model_info(struct scsi_qla_host *ha)
+{
+	uint16_t board_id_string[8];
+	int i;
+	int size = sizeof(ha->nvram->isp4022.boardIdStr);
+	int offset = offsetof(struct eeprom_data, isp4022.boardIdStr) / 2;
+
+	for (i = 0; i < (size / 2) ; i++) {
+		board_id_string[i] = rd_nvram_word(ha, offset);
+		offset += 1;
+	}
+
+	memcpy(ha->model_name, board_id_string, size);
+}
+
 static int qla4xxx_config_nvram(struct scsi_qla_host *ha)
 {
 	unsigned long flags;
@@ -481,6 +496,12 @@ static int qla4xxx_config_nvram(struct scsi_qla_host *ha)
 		else
 			return QLA_ERROR;
 	}
+
+	if (is_qla4022(ha) || is_qla4032(ha))
+		qla4xxx_set_model_info(ha);
+	else
+		strcpy(ha->model_name, "QLA4010");
+
 	DEBUG(printk("scsi%ld: %s: Setting extHwConfig to 0xFFFF%04x\n",
 		     ha->host_no, __func__, extHwConfig.Asuint32_t));
 
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c
index 52a1063..a539e17 100644
--- a/drivers/scsi/qla4xxx/ql4_nx.c
+++ b/drivers/scsi/qla4xxx/ql4_nx.c
@@ -2266,6 +2266,11 @@ int qla4_8xxx_get_sys_info(struct scsi_qla_host *ha)
 	    min(sizeof(ha->my_mac), sizeof(sys_info->mac_addr)));
 	memcpy(ha->serial_number, &sys_info->serial_number,
 	    min(sizeof(ha->serial_number), sizeof(sys_info->serial_number)));
+	memcpy(ha->model_name, &sys_info->board_id_str,
+	       min(sizeof(ha->model_name), sizeof(sys_info->board_id_str)));
+	ha->phy_port_cnt = sys_info->phys_port_cnt;
+	ha->phy_port_num = sys_info->port_num;
+	ha->iscsi_pci_func_cnt = sys_info->iscsi_pci_func_cnt;
 
 	DEBUG2(printk("scsi%ld: %s: "
 	    "mac %02x:%02x:%02x:%02x:%02x:%02x "
-- 
1.7.6



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/8] scsi_transport_iscsi: Added support to update initiator iscsi port
  2011-08-01 10:26 [PATCH 0/8] qla4xxx feature update vikas.chaudhary
                   ` (5 preceding siblings ...)
  2011-08-01 10:26 ` [PATCH 6/8] qla4xxx: Added vendor specific sysfs attributes vikas.chaudhary
@ 2011-08-01 10:26 ` vikas.chaudhary
  2011-08-01 10:26 ` [PATCH 8/8] qla4xxx: added " vikas.chaudhary
  2011-08-01 17:28 ` [PATCH 0/8] qla4xxx feature update Mike Christie
  8 siblings, 0 replies; 10+ messages in thread
From: vikas.chaudhary @ 2011-08-01 10:26 UTC (permalink / raw)
  To: JBottomley, michaelc
  Cc: linux-scsi, vikas.chaudhary, lalit.chandivade, ravi.anand

From: Vikas Chaudhary <vikas.chaudhary@qlogic.com>

Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
---
 drivers/scsi/scsi_transport_iscsi.c |    4 ++++
 include/scsi/iscsi_if.h             |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index b3a2515..c58f676 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -324,6 +324,7 @@ iscsi_iface_net_attr(iface, vlan, ISCSI_NET_PARAM_VLAN_ID);
 iscsi_iface_net_attr(iface, vlan_priority, ISCSI_NET_PARAM_VLAN_PRIORITY);
 iscsi_iface_net_attr(iface, vlan_enabled, ISCSI_NET_PARAM_VLAN_ENABLED);
 iscsi_iface_net_attr(iface, mtu, ISCSI_NET_PARAM_MTU);
+iscsi_iface_net_attr(iface, port, ISCSI_NET_PARAM_PORT);
 
 static mode_t iscsi_iface_attr_is_visible(struct kobject *kobj,
 					  struct attribute *attr, int i)
@@ -343,6 +344,8 @@ static mode_t iscsi_iface_attr_is_visible(struct kobject *kobj,
 		param = ISCSI_NET_PARAM_VLAN_ENABLED;
 	else if (attr == &dev_attr_iface_mtu.attr)
 		param = ISCSI_NET_PARAM_MTU;
+	else if (attr == &dev_attr_iface_port.attr)
+		param = ISCSI_NET_PARAM_PORT;
 	else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4) {
 		if (attr == &dev_attr_ipv4_iface_ipaddress.attr)
 			param = ISCSI_NET_PARAM_IPV4_ADDR;
@@ -390,6 +393,7 @@ static struct attribute *iscsi_iface_attrs[] = {
 	&dev_attr_ipv6_iface_ipaddr_autocfg.attr,
 	&dev_attr_ipv6_iface_linklocal_autocfg.attr,
 	&dev_attr_iface_mtu.attr,
+	&dev_attr_iface_port.attr,
 	NULL,
 };
 
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index d1f0927..706a1bb 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -314,6 +314,7 @@ enum iscsi_net_param {
 	ISCSI_NET_PARAM_IFACE_TYPE		= 16,
 	ISCSI_NET_PARAM_IFACE_NAME		= 17,
 	ISCSI_NET_PARAM_MTU			= 18,
+	ISCSI_NET_PARAM_PORT			= 19,
 };
 
 enum iscsi_conn_state {
-- 
1.7.6



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 8/8] qla4xxx: added support to update initiator iscsi port
  2011-08-01 10:26 [PATCH 0/8] qla4xxx feature update vikas.chaudhary
                   ` (6 preceding siblings ...)
  2011-08-01 10:26 ` [PATCH 7/8] scsi_transport_iscsi: Added support to update initiator iscsi port vikas.chaudhary
@ 2011-08-01 10:26 ` vikas.chaudhary
  2011-08-01 17:28 ` [PATCH 0/8] qla4xxx feature update Mike Christie
  8 siblings, 0 replies; 10+ messages in thread
From: vikas.chaudhary @ 2011-08-01 10:26 UTC (permalink / raw)
  To: JBottomley, michaelc
  Cc: linux-scsi, vikas.chaudhary, lalit.chandivade, ravi.anand

From: Vikas Chaudhary <vikas.chaudhary@qlogic.com>

Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
---
 drivers/scsi/qla4xxx/ql4_def.h |    2 ++
 drivers/scsi/qla4xxx/ql4_mbx.c |    2 ++
 drivers/scsi/qla4xxx/ql4_os.c  |   19 +++++++++++++++++++
 3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index 17a29ce..c3190eb 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -344,6 +344,8 @@ struct ipaddress_config {
 	struct in6_addr ipv6_addr1;
 	struct in6_addr ipv6_default_router_addr;
 	uint16_t eth_mtu_size;
+	uint16_t ipv4_port;
+	uint16_t ipv6_port;
 };
 
 #define QL4_CHAP_MAX_NAME_LEN 256
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 011c822..e843758 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -335,6 +335,7 @@ qla4xxx_update_local_ip(struct scsi_qla_host *ha,
 				le16_to_cpu(init_fw_cb->ipv4_addr_state);
 	ha->ip_config.eth_mtu_size =
 				le16_to_cpu(init_fw_cb->eth_mtu_size);
+	ha->ip_config.ipv4_port = le16_to_cpu(init_fw_cb->ipv4_port);
 
 	if (ha->acb_version == ACB_SUPPORTED) {
 		ha->ip_config.ipv6_options = le16_to_cpu(init_fw_cb->ipv6_opts);
@@ -384,6 +385,7 @@ qla4xxx_update_local_ip(struct scsi_qla_host *ha,
 			   sizeof(init_fw_cb->ipv6_dflt_rtr_addr)));
 		ha->ip_config.ipv6_vlan_tag =
 				be16_to_cpu(init_fw_cb->ipv6_vlan_tag);
+		ha->ip_config.ipv6_port = le16_to_cpu(init_fw_cb->ipv6_port);
 	}
 }
 
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 58a270b..489d7cd 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -231,6 +231,7 @@ static mode_t ql4_attr_is_visible(int param_type, int param)
 		case ISCSI_NET_PARAM_VLAN_PRIORITY:
 		case ISCSI_NET_PARAM_VLAN_ENABLED:
 		case ISCSI_NET_PARAM_MTU:
+		case ISCSI_NET_PARAM_PORT:
 			return S_IRUGO;
 		default:
 			return 0;
@@ -339,6 +340,12 @@ static int qla4xxx_get_iface_param(struct iscsi_iface *iface,
 	case ISCSI_NET_PARAM_MTU:
 		len = sprintf(buf, "%d\n", ha->ip_config.eth_mtu_size);
 		break;
+	case ISCSI_NET_PARAM_PORT:
+		if (iface->iface_type == ISCSI_IFACE_TYPE_IPV4)
+			len = sprintf(buf, "%d\n", ha->ip_config.ipv4_port);
+		else if (iface->iface_type == ISCSI_IFACE_TYPE_IPV6)
+			len = sprintf(buf, "%d\n", ha->ip_config.ipv6_port);
+		break;
 	default:
 		len = -ENOSYS;
 	}
@@ -726,6 +733,14 @@ static void qla4xxx_set_ipv6(struct scsi_qla_host *ha,
 		init_fw_cb->eth_mtu_size =
 				cpu_to_le16(*(uint16_t *)iface_param->value);
 		break;
+	case ISCSI_NET_PARAM_PORT:
+		/* Autocfg applies to even interface */
+		if (iface_param->iface_num & 0x1)
+			break;
+
+		init_fw_cb->ipv6_port =
+				cpu_to_le16(*(uint16_t *)iface_param->value);
+		break;
 	default:
 		ql4_printk(KERN_ERR, ha, "Unknown IPv6 param = %d\n",
 			   iface_param->param);
@@ -790,6 +805,10 @@ static void qla4xxx_set_ipv4(struct scsi_qla_host *ha,
 		init_fw_cb->eth_mtu_size =
 				cpu_to_le16(*(uint16_t *)iface_param->value);
 		break;
+	case ISCSI_NET_PARAM_PORT:
+		init_fw_cb->ipv4_port =
+				cpu_to_le16(*(uint16_t *)iface_param->value);
+		break;
 	default:
 		ql4_printk(KERN_ERR, ha, "Unknown IPv4 param = %d\n",
 			   iface_param->param);
-- 
1.7.6



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/8] qla4xxx feature update
  2011-08-01 10:26 [PATCH 0/8] qla4xxx feature update vikas.chaudhary
                   ` (7 preceding siblings ...)
  2011-08-01 10:26 ` [PATCH 8/8] qla4xxx: added " vikas.chaudhary
@ 2011-08-01 17:28 ` Mike Christie
  8 siblings, 0 replies; 10+ messages in thread
From: Mike Christie @ 2011-08-01 17:28 UTC (permalink / raw)
  To: vikas.chaudhary; +Cc: JBottomley, linux-scsi, lalit.chandivade, ravi.anand

On 08/01/2011 05:26 AM, vikas.chaudhary@qlogic.com wrote:
> From: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
> 
> James,
> 
> Following patches are made over scsi-misc and Mike Christie's patchset
> posted here: http://marc.info/?l=linux-scsi&m=131161955801957&w=2
> 
> Harish Zunjarrao (3):
> 	qla4xxx: Code cleanup for read/update flash using BSG
> 	qla4xxx: Add get ACB state support using BSG
> 	qla4xxx: Add read/update NVRAM support for 40xx adapters using BSG
> 
> Vikas Chaudhary (5):
> 	scsi_transport_iscsi: Added support to update mtu
> 	qla4xxx: Added support to update mtu
> 	qla4xxx: Added vendor specific sysfs attributes
> 	scsi_transport_iscsi: Added support to update initiator iscsi port
> 	qla4xxx: added support to update initiator iscsi port
> 

Patches look ok.

Reviewed-by: Mike Christie <michaelc@cs.wisc.edu>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-08-01 17:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-01 10:26 [PATCH 0/8] qla4xxx feature update vikas.chaudhary
2011-08-01 10:26 ` [PATCH 1/8] scsi_transport_iscsi: Added support to update mtu vikas.chaudhary
2011-08-01 10:26 ` [PATCH 2/8] qla4xxx: " vikas.chaudhary
2011-08-01 10:26 ` [PATCH 3/8] qla4xxx: Code cleanup for read/update flash using BSG vikas.chaudhary
2011-08-01 10:26 ` [PATCH 4/8] qla4xxx: Add get ACB state support " vikas.chaudhary
2011-08-01 10:26 ` [PATCH 5/8] qla4xxx: Add read/update NVRAM support for 40xx adapters " vikas.chaudhary
2011-08-01 10:26 ` [PATCH 6/8] qla4xxx: Added vendor specific sysfs attributes vikas.chaudhary
2011-08-01 10:26 ` [PATCH 7/8] scsi_transport_iscsi: Added support to update initiator iscsi port vikas.chaudhary
2011-08-01 10:26 ` [PATCH 8/8] qla4xxx: added " vikas.chaudhary
2011-08-01 17:28 ` [PATCH 0/8] qla4xxx feature update Mike Christie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox