[SCSI] libiscsi, iscsi_tcp, ib_iser : add sw iscsi host get/set params helpers
authorMike Christie <michaelc@cs.wisc.edu>
Wed, 30 May 2007 17:57:12 +0000 (12:57 -0500)
committerJames Bottomley <jejb@mulgrave.(none)>
Fri, 1 Jun 2007 16:55:23 +0000 (12:55 -0400)
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>
Cc: Roland Dreier <rdreier@cisco.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/infiniband/ulp/iser/iscsi_iser.c
drivers/scsi/iscsi_tcp.c
drivers/scsi/libiscsi.c
include/scsi/libiscsi.h

index dd221eda3ea63c9a648146d38d5a9269172f9485..2a99b7b6c9065baad329999c12f733bb9720d663 100644 (file)
@@ -576,6 +576,7 @@ static struct iscsi_transport iscsi_iser_transport = {
                                  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_transport = {
        .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,
index c9a3abf9e7b6eee62f17d58e4f76f661615ef028..9a42fc074b76d9bc4f4bab44be0c790e69ba9494 100644 (file)
@@ -2181,6 +2181,7 @@ static struct iscsi_transport iscsi_tcp_transport = {
                                  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_transport = {
        .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,
index 3f5b9b445b29b1dcc4da21cfee9367fea9d532fa..d430e227e9b7d21f13df413526ba219300728024 100644 (file)
@@ -1462,6 +1462,7 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
        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_cls_conn *cls_conn,
 }
 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");
index ea0816d4904d4d00a0b9af8be6e68f09f484be79..e202cc00c8e781c78e9446c8c2b06bdd4c7ce582 100644 (file)
@@ -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 scsi_cmnd *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
  */