All of lore.kernel.org
 help / color / mirror / Atom feed
From: michaelc@cs.wisc.edu
To: linux-scsi@vger.kernel.org
Cc: Mike Christie <michaelc@cs.wisc.edu>
Subject: [PATCH 6/19] libiscsi, iscsi_tcp, ib_iser : add sw iscsi host get/set params helpers
Date: Wed, 30 May 2007 12:57:12 -0500	[thread overview]
Message-ID: <11805478523188-git-send-email-michaelc@cs.wisc.edu> (raw)
In-Reply-To: <11805478511328-git-send-email-michaelc@cs.wisc.edu>

From: Mike Christie <michaelc@cs.wisc.edu>

iscsid and udev need to key off the hw address being
used so add some helpers for iser and iscsi tcp.

Also convert them.
Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
---
 drivers/infiniband/ulp/iser/iscsi_iser.c |    4 +++
 drivers/scsi/iscsi_tcp.c                 |    4 +++
 drivers/scsi/libiscsi.c                  |   40 ++++++++++++++++++++++++++++++
 include/scsi/libiscsi.h                  |   13 +++++++++-
 4 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index dd221ed..2a99b7b 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -576,6 +576,7 @@ static struct iscsi_transport iscsi_iser
 				  ISCSI_PERSISTENT_ADDRESS |
 				  ISCSI_TARGET_NAME |
 				  ISCSI_TPGT,
+	.host_param_mask	= ISCSI_HOST_HWADDRESS,
 	.host_template          = &iscsi_iser_sht,
 	.conndata_size		= sizeof(struct iscsi_conn),
 	.max_lun                = ISCSI_ISER_MAX_LUN,
@@ -592,6 +593,9 @@ static struct iscsi_transport iscsi_iser
 	.get_session_param	= iscsi_session_get_param,
 	.start_conn             = iscsi_iser_conn_start,
 	.stop_conn              = iscsi_conn_stop,
+	/* iscsi host params */
+	.get_host_param		= iscsi_host_get_param,
+	.set_host_param		= iscsi_host_set_param,
 	/* IO */
 	.send_pdu		= iscsi_conn_send_pdu,
 	.get_stats		= iscsi_iser_conn_get_stats,
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index c9a3abf..9a42fc0 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -2181,6 +2181,7 @@ static struct iscsi_transport iscsi_tcp_
 				  ISCSI_PERSISTENT_ADDRESS |
 				  ISCSI_TARGET_NAME |
 				  ISCSI_TPGT,
+	.host_param_mask	= ISCSI_HOST_HWADDRESS,
 	.host_template		= &iscsi_sht,
 	.conndata_size		= sizeof(struct iscsi_conn),
 	.max_conn		= 1,
@@ -2197,6 +2198,9 @@ static struct iscsi_transport iscsi_tcp_
 	.get_session_param	= iscsi_session_get_param,
 	.start_conn		= iscsi_conn_start,
 	.stop_conn		= iscsi_tcp_conn_stop,
+	/* iscsi host params */
+	.get_host_param		= iscsi_host_get_param,
+	.set_host_param		= iscsi_host_set_param,
 	/* IO */
 	.send_pdu		= iscsi_conn_send_pdu,
 	.get_stats		= iscsi_conn_get_stats,
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 3f5b9b4..d430e22 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1462,6 +1462,7 @@ void iscsi_session_teardown(struct iscsi
 	iscsi_pool_free(&session->cmdpool, (void**)session->cmds);
 
 	kfree(session->targetname);
+	kfree(session->hwaddress);
 
 	iscsi_destroy_session(cls_session);
 	scsi_host_put(shost);
@@ -1990,6 +1991,45 @@ int iscsi_conn_get_param(struct iscsi_cl
 }
 EXPORT_SYMBOL_GPL(iscsi_conn_get_param);
 
+int iscsi_host_get_param(struct Scsi_Host *shost, enum iscsi_host_param param,
+			 char *buf)
+{
+	struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
+	int len;
+
+	switch (param) {
+	case ISCSI_HOST_PARAM_HWADDRESS:
+		if (!session->hwaddress)
+			len = sprintf(buf, "%s\n", "default");
+		else
+			len = sprintf(buf, "%s\n", session->hwaddress);
+		break;
+	default:
+		return -ENOSYS;
+	}
+
+	return len;
+}
+EXPORT_SYMBOL_GPL(iscsi_host_get_param);
+
+int iscsi_host_set_param(struct Scsi_Host *shost, enum iscsi_host_param param,
+			 char *buf, int buflen)
+{
+	struct iscsi_session *session = iscsi_hostdata(shost->hostdata);
+
+	switch (param) {
+	case ISCSI_HOST_PARAM_HWADDRESS:
+		if (!session->hwaddress)
+			session->hwaddress = kstrdup(buf, GFP_KERNEL);
+		break;
+	default:
+		return -ENOSYS;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(iscsi_host_set_param);
+
 MODULE_AUTHOR("Mike Christie");
 MODULE_DESCRIPTION("iSCSI library functions");
 MODULE_LICENSE("GPL");
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index ea0816d..e202cc0 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -224,7 +224,8 @@ struct iscsi_session {
 	int			erl;
 	int			tpgt;
 	char			*targetname;
-
+	/* hw address being used for iscsi connection */
+	char			*hwaddress;
 	/* control data */
 	struct iscsi_transport	*tt;
 	struct Scsi_Host	*host;
@@ -255,6 +256,16 @@ extern int iscsi_eh_host_reset(struct sc
 extern int iscsi_queuecommand(struct scsi_cmnd *sc,
 			      void (*done)(struct scsi_cmnd *));
 
+
+/*
+ * iSCSI host helpers.
+ */
+extern int iscsi_host_set_param(struct Scsi_Host *shost,
+				enum iscsi_host_param param, char *buf,
+				int buflen);
+extern int iscsi_host_get_param(struct Scsi_Host *shost,
+				enum iscsi_host_param param, char *buf);
+
 /*
  * session management
  */
-- 
1.4.1.1


  reply	other threads:[~2007-05-30 17:57 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-30 17:57 iscsi features bugfixes michaelc
2007-05-30 17:57 ` [PATCH 1/19] Check iscsi interface skb allocation return value michaelc
2007-05-30 17:57   ` [PATCH 2/19] iscsi class: export hw address michaelc
2007-05-30 17:57     ` [PATCH 3/19] qla4xxx: export mac as " michaelc
2007-05-30 17:57       ` [PATCH 4/19] iscsi class, qla4xxx: have class lookup host for drivers michaelc
2007-05-30 17:57         ` [PATCH 5/19] iscsi class: add iscsi host set param event michaelc
2007-05-30 17:57           ` michaelc [this message]
2007-05-30 17:57             ` [PATCH 7/19] iscsi class, qla4xxx, iscsi_tcp, ib_iser: export/set initiator name michaelc
2007-05-30 17:57               ` [PATCH 8/19] iscsi: Some fixes in preparation for bidirectional support - exp_datasn michaelc
2007-05-30 17:57                 ` [PATCH 9/19] iscsi: Some fixes in preparation for bidirectional support - total_length michaelc
2007-05-30 17:57                   ` [PATCH 10/19] iscsi class, iscsi_tcp, ib_iser: add sysfs chap file michaelc
2007-05-30 17:57                     ` [PATCH 11/19] iscsi tcp: fix iscsi xmit state machine michaelc
2007-05-30 17:57                       ` [PATCH 12/19] libiscsi: fix iscsi cmdsn allocation michaelc
2007-05-30 17:57                         ` [PATCH 13/19] libiscsi: make can_queue configurable michaelc
2007-05-30 17:57                           ` [PATCH 14/19] iscsi_tcp: fix handling of data buffer padding michaelc
2007-05-30 17:57                             ` [PATCH 15/19] iscsi_tcp: remove DMA alignment restriction michaelc
2007-05-30 17:57                               ` [PATCH 16/19] qla4xxx: add iscsi_transport capps for fw capacilities michaelc
2007-05-30 17:57                                 ` [PATCH 17/19] iscsi_tcp: fix fd leak michaelc
2007-05-30 17:57                                   ` [PATCH 18/19] iscsi class, qla4xxx, iscsi_tcp: export local address michaelc
2007-05-30 17:57                                     ` [PATCH 19/19] iscsi class, iscsi_tcp, iser, qla4xxx: add netdevname sysfs attr michaelc

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=11805478523188-git-send-email-michaelc@cs.wisc.edu \
    --to=michaelc@cs.wisc.edu \
    --cc=linux-scsi@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.