linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: vikas.chaudhary@qlogic.com
To: James.Bottomley@suse.de, michaelc@cs.wisc.edu
Cc: linux-scsi@vger.kernel.org, open-iscsi@googlegroups.com,
	vikas.chaudhary@qlogic.com, lalit.chandivade@qlogic.com,
	ravi.anand@qlogic.com
Subject: [RFC-V2 PATCH 5/5] qla4xxx: added support to show multiple iface in sysfs
Date: Sat,  2 Apr 2011 11:34:21 -0700	[thread overview]
Message-ID: <1301769261-29896-6-git-send-email-vikas.chaudhary@qlogic.com> (raw)
In-Reply-To: <1301769261-29896-1-git-send-email-vikas.chaudhary@qlogic.com>

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

Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
Reviewed-by: Lalit Chandivade <lalit.chandivade@qlogic.com>
Reviewed-by: Harish Zunjarrao <harish.zunjarrao@qlogic.com>
---
 drivers/scsi/qla4xxx/ql4_def.h |    3 +
 drivers/scsi/qla4xxx/ql4_os.c  |  112 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 115 insertions(+), 0 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index 74faf54..aa3ba03 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -588,6 +588,9 @@ struct scsi_qla_host {
 
 	struct completion mbx_intr_comp;
 	struct ipaddress_config ip_config;
+	struct iscsi_iface *iface_ipv4;
+	struct iscsi_iface *iface_ipv6_1;
+	struct iscsi_iface *iface_ipv6_2;
 };
 
 static inline int is_ipv4_enabled(struct scsi_qla_host *ha)
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 3ea19ac..211fef7 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -82,6 +82,8 @@ static int qla4xxx_host_get_param(struct Scsi_Host *shost,
 				  enum iscsi_host_param param, char *buf);
 static int qla4xxx_set_net_config(struct Scsi_Host *shost, char *data,
 				  int count);
+static int qla4xxx_get_iface_param(struct iscsi_iface *iface,
+				   enum iscsi_net_param_type param, char *buf);
 static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session);
 static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc);
 
@@ -139,16 +141,96 @@ static struct iscsi_transport qla4xxx_iscsi_transport = {
 	.host_param_mask	= ISCSI_HOST_HWADDRESS |
 				  ISCSI_HOST_IPADDRESS |
 				  ISCSI_HOST_INITIATOR_NAME,
+	.ipv4_iface_param_mask	= ISCSI_NET_IPV4_ADDR |
+				  ISCSI_NET_IPV4_SUBNET |
+				  ISCSI_NET_IPV4_GW |
+				  ISCSI_NET_IPV4_BOOTPROTO |
+				  ISCSI_NET_IFACE_STATE,
+	.ipv6_iface_param_mask	= ISCSI_NET_IPV6_LINKLOCAL |
+				  ISCSI_NET_IPV6_ADDR |
+				  ISCSI_NET_IPV6_ROUTER |
+				  ISCSI_NET_IPV6_ADDR_AUTOCFG |
+				  ISCSI_NET_IPV6_LINKLOCAL_AUTOCFG |
+				  ISCSI_NET_IFACE_STATE,
 	.tgt_dscvr		= qla4xxx_tgt_dscvr,
 	.get_conn_param		= qla4xxx_conn_get_param,
 	.get_session_param	= qla4xxx_sess_get_param,
 	.get_host_param		= qla4xxx_host_get_param,
 	.set_net_config		= qla4xxx_set_net_config,
 	.session_recovery_timedout = qla4xxx_recovery_timedout,
+	.get_iface_param	= qla4xxx_get_iface_param,
 };
 
 static struct scsi_transport_template *qla4xxx_scsi_transport;
 
+static int qla4xxx_get_iface_param(struct iscsi_iface *iface,
+				   enum iscsi_net_param_type param, char *buf)
+{
+	struct Scsi_Host *shost = iscsi_iface_to_shost(iface);
+	struct scsi_qla_host *ha = to_qla_host(shost);
+	int len = -ENOSYS;
+
+	switch (param) {
+	case ISCSI_NET_PARAM_IPV4_ADDR:
+		len = sprintf(buf, "%pI4\n", &ha->ip_config.ip_address);
+		break;
+	case ISCSI_NET_PARAM_IPV4_SUBNET:
+		len = sprintf(buf, "%pI4\n", &ha->ip_config.subnet_mask);
+		break;
+	case ISCSI_NET_PARAM_IPV4_GW:
+		len = sprintf(buf, "%pI4\n", &ha->ip_config.gateway);
+		break;
+	case ISCSI_NET_PARAM_IFACE_STATE:
+		if (iface->iface_type == IFACE_TYPE_IPV4)
+			len = sprintf(buf, "%s\n",
+			    (ha->ip_config.ipv4_options &
+			     IPOPT_IPv4_PROTOCOL_ENABLE) ?
+			     "enable" : "disable");
+		else if (iface->iface_type == IFACE_TYPE_IPV6)
+			len = sprintf(buf, "%s\n",
+			    (ha->ip_config.ipv6_options &
+			     IPV6_OPT_IPV6_PROTOCOL_ENABLE) ?
+			     "enable" : "disable");
+		break;
+	case ISCSI_NET_PARAM_IPV4_BOOTPROTO:
+		len = sprintf(buf, "%s\n",
+		    (ha->ip_config.tcp_options & TCPOPT_DHCP_ENABLE) ?
+		    "dhcp" : "static");
+		break;
+	case ISCSI_NET_PARAM_IPV6_ADDR:
+		if (iface->iface_num == 1)
+			len = sprintf(buf, "%pI6\n", &ha->ip_config.ipv6_addr0);
+		if (iface->iface_num == 2)
+			len = sprintf(buf, "%pI6\n", &ha->ip_config.ipv6_addr1);
+		break;
+	case ISCSI_NET_PARAM_IPV6_LINKLOCAL:
+		len = sprintf(buf, "%pI6\n",
+		    &ha->ip_config.ipv6_link_local_addr);
+		break;
+	case ISCSI_NET_PARAM_IPV6_ROUTER:
+		len = sprintf(buf, "%pI6\n",
+		    &ha->ip_config.ipv6_default_router_addr);
+		break;
+	case ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG:
+	    len = sprintf(buf, "%s\n",
+		(ha->ip_config.ipv6_addl_options &
+		IPV6_ADDOPT_NEIGHBOR_DISCOVERY_ADDR_ENABLE) ?
+		"nd" : "static");
+	    break;
+	case ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG:
+	    len = sprintf(buf, "%s\n",
+		(ha->ip_config.ipv6_addl_options &
+		IPV6_ADDOPT_AUTOCONFIG_LINK_LOCAL_ADDR) ?
+		"auto" : "static");
+	    break;
+	default:
+		len = -ENOSYS;
+	}
+
+	return len;
+}
+
+
 static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc)
 {
 	struct iscsi_cls_session *session;
@@ -1933,6 +2015,31 @@ uint16_t qla4_8xxx_rd_shdw_rsp_q_in(struct scsi_qla_host *ha)
 	return (uint16_t)le32_to_cpu(readl(&ha->qla4_8xxx_reg->rsp_q_in));
 }
 
+static void qla4xxx_create_iface(struct scsi_qla_host *ha)
+{
+	/* IPv4 */
+	ha->iface_ipv4 = iscsi_create_iface(ha->host,
+	    &qla4xxx_iscsi_transport, IFACE_TYPE_IPV4, 1, 0);
+
+	/* IPv6 iface-1 */
+	ha->iface_ipv6_1 = iscsi_create_iface(ha->host,
+	    &qla4xxx_iscsi_transport, IFACE_TYPE_IPV6, 1, 0);
+
+	/* IPv6 iface-2 */
+	ha->iface_ipv6_2 = iscsi_create_iface(ha->host,
+	    &qla4xxx_iscsi_transport, IFACE_TYPE_IPV6, 2, 0);
+}
+
+static void qla4xxx_destroy_iface(struct scsi_qla_host *ha)
+{
+	if (ha->iface_ipv4)
+		iscsi_destroy_iface(ha->iface_ipv4);
+	if (ha->iface_ipv6_1)
+		iscsi_destroy_iface(ha->iface_ipv6_1);
+	if (ha->iface_ipv6_2)
+		iscsi_destroy_iface(ha->iface_ipv6_2);
+}
+
 /**
  * qla4xxx_probe_adapter - callback function to probe HBA
  * @pdev: pointer to pci_dev structure
@@ -2133,6 +2240,8 @@ static int __devinit qla4xxx_probe_adapter(struct pci_dev *pdev,
 	       ha->host_no, ha->firmware_version[0], ha->firmware_version[1],
 	       ha->patch_number, ha->build_number);
 	scsi_scan_host(host);
+
+	qla4xxx_create_iface(ha);
 	return 0;
 
 probe_failed:
@@ -2202,6 +2311,9 @@ static void __devexit qla4xxx_remove_adapter(struct pci_dev *pdev)
 	/* remove devs from iscsi_sessions to scsi_devices */
 	qla4xxx_free_ddb_list(ha);
 
+	/* destroy iface from sysfs */
+	qla4xxx_destroy_iface(ha);
+
 	scsi_remove_host(ha->host);
 
 	qla4xxx_free_adapter(ha);
-- 
1.7.3.2


      parent reply	other threads:[~2011-04-02 18:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-02 18:34 [RFC-V2 PATCH 0/5] Proposal for iSCSI Network Configuration vikas.chaudhary
2011-04-02 18:34 ` [RFC-V2 PATCH 1/5] iscsi_transport: add support for set_net_config vikas.chaudhary
2011-04-13  3:41   ` Mike Christie
2011-04-02 18:34 ` [RFC-V2 PATCH 2/5] qla4xxx: " vikas.chaudhary
2011-04-13  3:55   ` Mike Christie
     [not found]     ` <4DA51ECA.1020507-hcNo3dDEHLuVc3sceRu5cw@public.gmane.org>
2011-04-13 14:40       ` Vikas Chaudhary
2011-04-02 18:34 ` [RFC-V2 PATCH 3/5] qla4xxx: Added new "struct ipaddress_config" vikas.chaudhary
2011-04-02 18:34 ` [RFC-V2 PATCH 4/5] iscsi_transport: show network configuration in sysfs vikas.chaudhary
2011-04-13  4:23   ` Mike Christie
2011-04-13  4:40     ` Mike Christie
2011-04-13 14:48       ` Vikas Chaudhary
     [not found]         ` <5E4F49720D0BAD499EE1F01232234BA8728A8CB623-HolNjIBXvBOXx9kJd3VG2h2eb7JE58TQ@public.gmane.org>
2011-04-13 16:44           ` Mike Christie
2011-04-14  4:15             ` Vikas Chaudhary
2011-04-14  5:18               ` Mike Christie
2011-04-14  5:54                 ` Vikas Chaudhary
2011-04-21 22:10     ` Jayamohan.Kallickal
2011-04-13 17:00   ` Mike Christie
2011-04-13 22:47     ` Shyam_Iyer
2011-04-14  3:07       ` Mike Christie
2011-04-13 22:53     ` Michael Chan
2011-04-14  3:24       ` Mike Christie
2011-04-19  2:41   ` Mike Christie
2011-04-19 13:47     ` Vikas Chaudhary
2011-04-02 18:34 ` vikas.chaudhary [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1301769261-29896-6-git-send-email-vikas.chaudhary@qlogic.com \
    --to=vikas.chaudhary@qlogic.com \
    --cc=James.Bottomley@suse.de \
    --cc=lalit.chandivade@qlogic.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=michaelc@cs.wisc.edu \
    --cc=open-iscsi@googlegroups.com \
    --cc=ravi.anand@qlogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).