2 * iSCSI transport class definitions
4 * Copyright (C) IBM Corporation, 2004
5 * Copyright (C) Mike Christie, 2004 - 2005
6 * Copyright (C) Dmitry Yusupov, 2004 - 2005
7 * Copyright (C) Alex Aizman, 2004 - 2005
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include <linux/module.h>
24 #include <linux/mutex.h>
25 #include <linux/slab.h>
27 #include <scsi/scsi.h>
28 #include <scsi/scsi_host.h>
29 #include <scsi/scsi_device.h>
30 #include <scsi/scsi_transport.h>
31 #include <scsi/scsi_transport_iscsi.h>
32 #include <scsi/iscsi_if.h>
33 #include <scsi/scsi_cmnd.h>
35 #define ISCSI_SESSION_ATTRS 23
36 #define ISCSI_CONN_ATTRS 13
37 #define ISCSI_HOST_ATTRS 4
39 #define ISCSI_TRANSPORT_VERSION "2.0-870"
41 static int dbg_session;
42 module_param_named(debug_session, dbg_session, int,
44 MODULE_PARM_DESC(debug_session,
45 "Turn on debugging for sessions in scsi_transport_iscsi "
46 "module. Set to 1 to turn on, and zero to turn off. Default "
50 module_param_named(debug_conn, dbg_conn, int,
52 MODULE_PARM_DESC(debug_conn,
53 "Turn on debugging for connections in scsi_transport_iscsi "
54 "module. Set to 1 to turn on, and zero to turn off. Default "
57 #define ISCSI_DBG_TRANS_SESSION(_session, dbg_fmt, arg...) \
60 iscsi_cls_session_printk(KERN_INFO, _session, \
65 #define ISCSI_DBG_TRANS_CONN(_conn, dbg_fmt, arg...) \
68 iscsi_cls_conn_printk(KERN_INFO, _conn, \
73 struct iscsi_internal {
74 struct scsi_transport_template t;
75 struct iscsi_transport *iscsi_transport;
76 struct list_head list;
79 struct device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1];
80 struct transport_container conn_cont;
81 struct device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1];
82 struct transport_container session_cont;
83 struct device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1];
86 static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
87 static struct workqueue_struct *iscsi_eh_timer_workq;
90 * list of registered transports and lock that must
91 * be held while accessing list. The iscsi_transport_lock must
92 * be acquired after the rx_queue_mutex.
94 static LIST_HEAD(iscsi_transports);
95 static DEFINE_SPINLOCK(iscsi_transport_lock);
97 #define to_iscsi_internal(tmpl) \
98 container_of(tmpl, struct iscsi_internal, t)
100 #define dev_to_iscsi_internal(_dev) \
101 container_of(_dev, struct iscsi_internal, dev)
103 static void iscsi_transport_release(struct device *dev)
105 struct iscsi_internal *priv = dev_to_iscsi_internal(dev);
110 * iscsi_transport_class represents the iscsi_transports that are
113 static struct class iscsi_transport_class = {
114 .name = "iscsi_transport",
115 .dev_release = iscsi_transport_release,
119 show_transport_handle(struct device *dev, struct device_attribute *attr,
122 struct iscsi_internal *priv = dev_to_iscsi_internal(dev);
123 return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport));
125 static DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL);
127 #define show_transport_attr(name, format) \
129 show_transport_##name(struct device *dev, \
130 struct device_attribute *attr,char *buf) \
132 struct iscsi_internal *priv = dev_to_iscsi_internal(dev); \
133 return sprintf(buf, format"\n", priv->iscsi_transport->name); \
135 static DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL);
137 show_transport_attr(caps, "0x%x");
139 static struct attribute *iscsi_transport_attrs[] = {
140 &dev_attr_handle.attr,
145 static struct attribute_group iscsi_transport_group = {
146 .attrs = iscsi_transport_attrs,
150 * iSCSI endpoint attrs
152 #define iscsi_dev_to_endpoint(_dev) \
153 container_of(_dev, struct iscsi_endpoint, dev)
155 #define ISCSI_ATTR(_prefix,_name,_mode,_show,_store) \
156 struct device_attribute dev_attr_##_prefix##_##_name = \
157 __ATTR(_name,_mode,_show,_store)
159 static void iscsi_endpoint_release(struct device *dev)
161 struct iscsi_endpoint *ep = iscsi_dev_to_endpoint(dev);
165 static struct class iscsi_endpoint_class = {
166 .name = "iscsi_endpoint",
167 .dev_release = iscsi_endpoint_release,
171 show_ep_handle(struct device *dev, struct device_attribute *attr, char *buf)
173 struct iscsi_endpoint *ep = iscsi_dev_to_endpoint(dev);
174 return sprintf(buf, "%llu\n", (unsigned long long) ep->id);
176 static ISCSI_ATTR(ep, handle, S_IRUGO, show_ep_handle, NULL);
178 static struct attribute *iscsi_endpoint_attrs[] = {
179 &dev_attr_ep_handle.attr,
183 static struct attribute_group iscsi_endpoint_group = {
184 .attrs = iscsi_endpoint_attrs,
187 #define ISCSI_MAX_EPID -1
189 static int iscsi_match_epid(struct device *dev, void *data)
191 struct iscsi_endpoint *ep = iscsi_dev_to_endpoint(dev);
192 uint64_t *epid = (uint64_t *) data;
194 return *epid == ep->id;
197 struct iscsi_endpoint *
198 iscsi_create_endpoint(int dd_size)
201 struct iscsi_endpoint *ep;
205 for (id = 1; id < ISCSI_MAX_EPID; id++) {
206 dev = class_find_device(&iscsi_endpoint_class, NULL, &id,
211 if (id == ISCSI_MAX_EPID) {
212 printk(KERN_ERR "Too many connections. Max supported %u\n",
217 ep = kzalloc(sizeof(*ep) + dd_size, GFP_KERNEL);
222 ep->dev.class = &iscsi_endpoint_class;
223 dev_set_name(&ep->dev, "ep-%llu", (unsigned long long) id);
224 err = device_register(&ep->dev);
228 err = sysfs_create_group(&ep->dev.kobj, &iscsi_endpoint_group);
233 ep->dd_data = &ep[1];
237 device_unregister(&ep->dev);
244 EXPORT_SYMBOL_GPL(iscsi_create_endpoint);
246 void iscsi_destroy_endpoint(struct iscsi_endpoint *ep)
248 sysfs_remove_group(&ep->dev.kobj, &iscsi_endpoint_group);
249 device_unregister(&ep->dev);
251 EXPORT_SYMBOL_GPL(iscsi_destroy_endpoint);
253 struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle)
255 struct iscsi_endpoint *ep;
258 dev = class_find_device(&iscsi_endpoint_class, NULL, &handle,
263 ep = iscsi_dev_to_endpoint(dev);
265 * we can drop this now because the interface will prevent
266 * removals and lookups from racing.
271 EXPORT_SYMBOL_GPL(iscsi_lookup_endpoint);
273 static int iscsi_setup_host(struct transport_container *tc, struct device *dev,
276 struct Scsi_Host *shost = dev_to_shost(dev);
277 struct iscsi_cls_host *ihost = shost->shost_data;
279 memset(ihost, 0, sizeof(*ihost));
280 atomic_set(&ihost->nr_scans, 0);
281 mutex_init(&ihost->mutex);
285 static DECLARE_TRANSPORT_CLASS(iscsi_host_class,
291 static DECLARE_TRANSPORT_CLASS(iscsi_session_class,
297 static DECLARE_TRANSPORT_CLASS(iscsi_connection_class,
303 static struct sock *nls;
304 static DEFINE_MUTEX(rx_queue_mutex);
306 static LIST_HEAD(sesslist);
307 static DEFINE_SPINLOCK(sesslock);
308 static LIST_HEAD(connlist);
309 static DEFINE_SPINLOCK(connlock);
311 static uint32_t iscsi_conn_get_sid(struct iscsi_cls_conn *conn)
313 struct iscsi_cls_session *sess = iscsi_dev_to_session(conn->dev.parent);
318 * Returns the matching session to a given sid
320 static struct iscsi_cls_session *iscsi_session_lookup(uint32_t sid)
323 struct iscsi_cls_session *sess;
325 spin_lock_irqsave(&sesslock, flags);
326 list_for_each_entry(sess, &sesslist, sess_list) {
327 if (sess->sid == sid) {
328 spin_unlock_irqrestore(&sesslock, flags);
332 spin_unlock_irqrestore(&sesslock, flags);
337 * Returns the matching connection to a given sid / cid tuple
339 static struct iscsi_cls_conn *iscsi_conn_lookup(uint32_t sid, uint32_t cid)
342 struct iscsi_cls_conn *conn;
344 spin_lock_irqsave(&connlock, flags);
345 list_for_each_entry(conn, &connlist, conn_list) {
346 if ((conn->cid == cid) && (iscsi_conn_get_sid(conn) == sid)) {
347 spin_unlock_irqrestore(&connlock, flags);
351 spin_unlock_irqrestore(&connlock, flags);
356 * The following functions can be used by LLDs that allocate
357 * their own scsi_hosts or by software iscsi LLDs
362 } iscsi_session_state_names[] = {
363 { ISCSI_SESSION_LOGGED_IN, "LOGGED_IN" },
364 { ISCSI_SESSION_FAILED, "FAILED" },
365 { ISCSI_SESSION_FREE, "FREE" },
368 static const char *iscsi_session_state_name(int state)
373 for (i = 0; i < ARRAY_SIZE(iscsi_session_state_names); i++) {
374 if (iscsi_session_state_names[i].value == state) {
375 name = iscsi_session_state_names[i].name;
382 int iscsi_session_chkready(struct iscsi_cls_session *session)
387 spin_lock_irqsave(&session->lock, flags);
388 switch (session->state) {
389 case ISCSI_SESSION_LOGGED_IN:
392 case ISCSI_SESSION_FAILED:
393 err = DID_IMM_RETRY << 16;
395 case ISCSI_SESSION_FREE:
396 err = DID_TRANSPORT_FAILFAST << 16;
399 err = DID_NO_CONNECT << 16;
402 spin_unlock_irqrestore(&session->lock, flags);
405 EXPORT_SYMBOL_GPL(iscsi_session_chkready);
407 static void iscsi_session_release(struct device *dev)
409 struct iscsi_cls_session *session = iscsi_dev_to_session(dev);
410 struct Scsi_Host *shost;
412 shost = iscsi_session_to_shost(session);
413 scsi_host_put(shost);
414 ISCSI_DBG_TRANS_SESSION(session, "Completing session release\n");
418 static int iscsi_is_session_dev(const struct device *dev)
420 return dev->release == iscsi_session_release;
423 static int iscsi_iter_session_fn(struct device *dev, void *data)
425 void (* fn) (struct iscsi_cls_session *) = data;
427 if (!iscsi_is_session_dev(dev))
429 fn(iscsi_dev_to_session(dev));
433 void iscsi_host_for_each_session(struct Scsi_Host *shost,
434 void (*fn)(struct iscsi_cls_session *))
436 device_for_each_child(&shost->shost_gendev, fn,
437 iscsi_iter_session_fn);
439 EXPORT_SYMBOL_GPL(iscsi_host_for_each_session);
442 * iscsi_scan_finished - helper to report when running scans are done
444 * @time: scan run time
446 * This function can be used by drives like qla4xxx to report to the scsi
447 * layer when the scans it kicked off at module load time are done.
449 int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time)
451 struct iscsi_cls_host *ihost = shost->shost_data;
453 * qla4xxx will have kicked off some session unblocks before calling
454 * scsi_scan_host, so just wait for them to complete.
456 return !atomic_read(&ihost->nr_scans);
458 EXPORT_SYMBOL_GPL(iscsi_scan_finished);
460 struct iscsi_scan_data {
461 unsigned int channel;
466 static int iscsi_user_scan_session(struct device *dev, void *data)
468 struct iscsi_scan_data *scan_data = data;
469 struct iscsi_cls_session *session;
470 struct Scsi_Host *shost;
471 struct iscsi_cls_host *ihost;
475 if (!iscsi_is_session_dev(dev))
478 session = iscsi_dev_to_session(dev);
480 ISCSI_DBG_TRANS_SESSION(session, "Scanning session\n");
482 shost = iscsi_session_to_shost(session);
483 ihost = shost->shost_data;
485 mutex_lock(&ihost->mutex);
486 spin_lock_irqsave(&session->lock, flags);
487 if (session->state != ISCSI_SESSION_LOGGED_IN) {
488 spin_unlock_irqrestore(&session->lock, flags);
491 id = session->target_id;
492 spin_unlock_irqrestore(&session->lock, flags);
494 if (id != ISCSI_MAX_TARGET) {
495 if ((scan_data->channel == SCAN_WILD_CARD ||
496 scan_data->channel == 0) &&
497 (scan_data->id == SCAN_WILD_CARD ||
498 scan_data->id == id))
499 scsi_scan_target(&session->dev, 0, id,
504 mutex_unlock(&ihost->mutex);
505 ISCSI_DBG_TRANS_SESSION(session, "Completed session scan\n");
509 static int iscsi_user_scan(struct Scsi_Host *shost, uint channel,
512 struct iscsi_scan_data scan_data;
514 scan_data.channel = channel;
518 return device_for_each_child(&shost->shost_gendev, &scan_data,
519 iscsi_user_scan_session);
522 static void iscsi_scan_session(struct work_struct *work)
524 struct iscsi_cls_session *session =
525 container_of(work, struct iscsi_cls_session, scan_work);
526 struct Scsi_Host *shost = iscsi_session_to_shost(session);
527 struct iscsi_cls_host *ihost = shost->shost_data;
528 struct iscsi_scan_data scan_data;
530 scan_data.channel = 0;
531 scan_data.id = SCAN_WILD_CARD;
532 scan_data.lun = SCAN_WILD_CARD;
534 iscsi_user_scan_session(&session->dev, &scan_data);
535 atomic_dec(&ihost->nr_scans);
539 * iscsi_block_scsi_eh - block scsi eh until session state has transistioned
540 * @cmd: scsi cmd passed to scsi eh handler
542 * If the session is down this function will wait for the recovery
543 * timer to fire or for the session to be logged back in. If the
544 * recovery timer fires then FAST_IO_FAIL is returned. The caller
545 * should pass this error value to the scsi eh.
547 int iscsi_block_scsi_eh(struct scsi_cmnd *cmd)
549 struct iscsi_cls_session *session =
550 starget_to_session(scsi_target(cmd->device));
554 spin_lock_irqsave(&session->lock, flags);
555 while (session->state != ISCSI_SESSION_LOGGED_IN) {
556 if (session->state == ISCSI_SESSION_FREE) {
560 spin_unlock_irqrestore(&session->lock, flags);
562 spin_lock_irqsave(&session->lock, flags);
564 spin_unlock_irqrestore(&session->lock, flags);
567 EXPORT_SYMBOL_GPL(iscsi_block_scsi_eh);
569 static void session_recovery_timedout(struct work_struct *work)
571 struct iscsi_cls_session *session =
572 container_of(work, struct iscsi_cls_session,
576 iscsi_cls_session_printk(KERN_INFO, session,
577 "session recovery timed out after %d secs\n",
578 session->recovery_tmo);
580 spin_lock_irqsave(&session->lock, flags);
581 switch (session->state) {
582 case ISCSI_SESSION_FAILED:
583 session->state = ISCSI_SESSION_FREE;
585 case ISCSI_SESSION_LOGGED_IN:
586 case ISCSI_SESSION_FREE:
587 /* we raced with the unblock's flush */
588 spin_unlock_irqrestore(&session->lock, flags);
591 spin_unlock_irqrestore(&session->lock, flags);
593 if (session->transport->session_recovery_timedout)
594 session->transport->session_recovery_timedout(session);
596 ISCSI_DBG_TRANS_SESSION(session, "Unblocking SCSI target\n");
597 scsi_target_unblock(&session->dev);
598 ISCSI_DBG_TRANS_SESSION(session, "Completed unblocking SCSI target\n");
601 static void __iscsi_unblock_session(struct work_struct *work)
603 struct iscsi_cls_session *session =
604 container_of(work, struct iscsi_cls_session,
606 struct Scsi_Host *shost = iscsi_session_to_shost(session);
607 struct iscsi_cls_host *ihost = shost->shost_data;
610 ISCSI_DBG_TRANS_SESSION(session, "Unblocking session\n");
612 * The recovery and unblock work get run from the same workqueue,
613 * so try to cancel it if it was going to run after this unblock.
615 cancel_delayed_work(&session->recovery_work);
616 spin_lock_irqsave(&session->lock, flags);
617 session->state = ISCSI_SESSION_LOGGED_IN;
618 spin_unlock_irqrestore(&session->lock, flags);
620 scsi_target_unblock(&session->dev);
622 * Only do kernel scanning if the driver is properly hooked into
623 * the async scanning code (drivers like iscsi_tcp do login and
624 * scanning from userspace).
626 if (shost->hostt->scan_finished) {
627 if (scsi_queue_work(shost, &session->scan_work))
628 atomic_inc(&ihost->nr_scans);
630 ISCSI_DBG_TRANS_SESSION(session, "Completed unblocking session\n");
634 * iscsi_unblock_session - set a session as logged in and start IO.
635 * @session: iscsi session
637 * Mark a session as ready to accept IO.
639 void iscsi_unblock_session(struct iscsi_cls_session *session)
641 queue_work(iscsi_eh_timer_workq, &session->unblock_work);
643 * make sure all the events have completed before tell the driver
646 flush_workqueue(iscsi_eh_timer_workq);
648 EXPORT_SYMBOL_GPL(iscsi_unblock_session);
650 static void __iscsi_block_session(struct work_struct *work)
652 struct iscsi_cls_session *session =
653 container_of(work, struct iscsi_cls_session,
657 ISCSI_DBG_TRANS_SESSION(session, "Blocking session\n");
658 spin_lock_irqsave(&session->lock, flags);
659 session->state = ISCSI_SESSION_FAILED;
660 spin_unlock_irqrestore(&session->lock, flags);
661 scsi_target_block(&session->dev);
662 ISCSI_DBG_TRANS_SESSION(session, "Completed SCSI target blocking\n");
663 if (session->recovery_tmo >= 0)
664 queue_delayed_work(iscsi_eh_timer_workq,
665 &session->recovery_work,
666 session->recovery_tmo * HZ);
669 void iscsi_block_session(struct iscsi_cls_session *session)
671 queue_work(iscsi_eh_timer_workq, &session->block_work);
673 EXPORT_SYMBOL_GPL(iscsi_block_session);
675 static void __iscsi_unbind_session(struct work_struct *work)
677 struct iscsi_cls_session *session =
678 container_of(work, struct iscsi_cls_session,
680 struct Scsi_Host *shost = iscsi_session_to_shost(session);
681 struct iscsi_cls_host *ihost = shost->shost_data;
684 ISCSI_DBG_TRANS_SESSION(session, "Unbinding session\n");
686 /* Prevent new scans and make sure scanning is not in progress */
687 mutex_lock(&ihost->mutex);
688 spin_lock_irqsave(&session->lock, flags);
689 if (session->target_id == ISCSI_MAX_TARGET) {
690 spin_unlock_irqrestore(&session->lock, flags);
691 mutex_unlock(&ihost->mutex);
694 session->target_id = ISCSI_MAX_TARGET;
695 spin_unlock_irqrestore(&session->lock, flags);
696 mutex_unlock(&ihost->mutex);
698 scsi_remove_target(&session->dev);
699 iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION);
700 ISCSI_DBG_TRANS_SESSION(session, "Completed target removal\n");
703 struct iscsi_cls_session *
704 iscsi_alloc_session(struct Scsi_Host *shost, struct iscsi_transport *transport,
707 struct iscsi_cls_session *session;
709 session = kzalloc(sizeof(*session) + dd_size,
714 session->transport = transport;
715 session->recovery_tmo = 120;
716 session->state = ISCSI_SESSION_FREE;
717 INIT_DELAYED_WORK(&session->recovery_work, session_recovery_timedout);
718 INIT_LIST_HEAD(&session->sess_list);
719 INIT_WORK(&session->unblock_work, __iscsi_unblock_session);
720 INIT_WORK(&session->block_work, __iscsi_block_session);
721 INIT_WORK(&session->unbind_work, __iscsi_unbind_session);
722 INIT_WORK(&session->scan_work, iscsi_scan_session);
723 spin_lock_init(&session->lock);
725 /* this is released in the dev's release function */
726 scsi_host_get(shost);
727 session->dev.parent = &shost->shost_gendev;
728 session->dev.release = iscsi_session_release;
729 device_initialize(&session->dev);
731 session->dd_data = &session[1];
733 ISCSI_DBG_TRANS_SESSION(session, "Completed session allocation\n");
736 EXPORT_SYMBOL_GPL(iscsi_alloc_session);
738 static int iscsi_get_next_target_id(struct device *dev, void *data)
740 struct iscsi_cls_session *session;
744 if (!iscsi_is_session_dev(dev))
747 session = iscsi_dev_to_session(dev);
748 spin_lock_irqsave(&session->lock, flags);
749 if (*((unsigned int *) data) == session->target_id)
751 spin_unlock_irqrestore(&session->lock, flags);
755 int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
757 struct Scsi_Host *shost = iscsi_session_to_shost(session);
758 struct iscsi_cls_host *ihost;
760 unsigned int id = target_id;
763 ihost = shost->shost_data;
764 session->sid = atomic_add_return(1, &iscsi_session_nr);
766 if (id == ISCSI_MAX_TARGET) {
767 for (id = 0; id < ISCSI_MAX_TARGET; id++) {
768 err = device_for_each_child(&shost->shost_gendev, &id,
769 iscsi_get_next_target_id);
774 if (id == ISCSI_MAX_TARGET) {
775 iscsi_cls_session_printk(KERN_ERR, session,
776 "Too many iscsi targets. Max "
777 "number of targets is %d.\n",
778 ISCSI_MAX_TARGET - 1);
783 session->target_id = id;
785 dev_set_name(&session->dev, "session%u", session->sid);
786 err = device_add(&session->dev);
788 iscsi_cls_session_printk(KERN_ERR, session,
789 "could not register session's dev\n");
792 transport_register_device(&session->dev);
794 spin_lock_irqsave(&sesslock, flags);
795 list_add(&session->sess_list, &sesslist);
796 spin_unlock_irqrestore(&sesslock, flags);
798 iscsi_session_event(session, ISCSI_KEVENT_CREATE_SESSION);
799 ISCSI_DBG_TRANS_SESSION(session, "Completed session adding\n");
803 scsi_host_put(shost);
806 EXPORT_SYMBOL_GPL(iscsi_add_session);
809 * iscsi_create_session - create iscsi class session
811 * @transport: iscsi transport
812 * @dd_size: private driver data size
813 * @target_id: which target
815 * This can be called from a LLD or iscsi_transport.
817 struct iscsi_cls_session *
818 iscsi_create_session(struct Scsi_Host *shost, struct iscsi_transport *transport,
819 int dd_size, unsigned int target_id)
821 struct iscsi_cls_session *session;
823 session = iscsi_alloc_session(shost, transport, dd_size);
827 if (iscsi_add_session(session, target_id)) {
828 iscsi_free_session(session);
833 EXPORT_SYMBOL_GPL(iscsi_create_session);
835 static void iscsi_conn_release(struct device *dev)
837 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev);
838 struct device *parent = conn->dev.parent;
840 ISCSI_DBG_TRANS_CONN(conn, "Releasing conn\n");
845 static int iscsi_is_conn_dev(const struct device *dev)
847 return dev->release == iscsi_conn_release;
850 static int iscsi_iter_destroy_conn_fn(struct device *dev, void *data)
852 if (!iscsi_is_conn_dev(dev))
854 return iscsi_destroy_conn(iscsi_dev_to_conn(dev));
857 void iscsi_remove_session(struct iscsi_cls_session *session)
859 struct Scsi_Host *shost = iscsi_session_to_shost(session);
863 ISCSI_DBG_TRANS_SESSION(session, "Removing session\n");
865 spin_lock_irqsave(&sesslock, flags);
866 list_del(&session->sess_list);
867 spin_unlock_irqrestore(&sesslock, flags);
869 /* make sure there are no blocks/unblocks queued */
870 flush_workqueue(iscsi_eh_timer_workq);
871 /* make sure the timedout callout is not running */
872 if (!cancel_delayed_work(&session->recovery_work))
873 flush_workqueue(iscsi_eh_timer_workq);
875 * If we are blocked let commands flow again. The lld or iscsi
876 * layer should set up the queuecommand to fail commands.
877 * We assume that LLD will not be calling block/unblock while
878 * removing the session.
880 spin_lock_irqsave(&session->lock, flags);
881 session->state = ISCSI_SESSION_FREE;
882 spin_unlock_irqrestore(&session->lock, flags);
884 scsi_target_unblock(&session->dev);
885 /* flush running scans then delete devices */
886 scsi_flush_work(shost);
887 __iscsi_unbind_session(&session->unbind_work);
889 /* hw iscsi may not have removed all connections from session */
890 err = device_for_each_child(&session->dev, NULL,
891 iscsi_iter_destroy_conn_fn);
893 iscsi_cls_session_printk(KERN_ERR, session,
894 "Could not delete all connections "
895 "for session. Error %d.\n", err);
897 transport_unregister_device(&session->dev);
899 ISCSI_DBG_TRANS_SESSION(session, "Completing session removal\n");
900 device_del(&session->dev);
902 EXPORT_SYMBOL_GPL(iscsi_remove_session);
904 void iscsi_free_session(struct iscsi_cls_session *session)
906 ISCSI_DBG_TRANS_SESSION(session, "Freeing session\n");
907 iscsi_session_event(session, ISCSI_KEVENT_DESTROY_SESSION);
908 put_device(&session->dev);
910 EXPORT_SYMBOL_GPL(iscsi_free_session);
913 * iscsi_destroy_session - destroy iscsi session
914 * @session: iscsi_session
916 * Can be called by a LLD or iscsi_transport. There must not be
917 * any running connections.
919 int iscsi_destroy_session(struct iscsi_cls_session *session)
921 iscsi_remove_session(session);
922 ISCSI_DBG_TRANS_SESSION(session, "Completing session destruction\n");
923 iscsi_free_session(session);
926 EXPORT_SYMBOL_GPL(iscsi_destroy_session);
929 * iscsi_create_conn - create iscsi class connection
930 * @session: iscsi cls session
931 * @dd_size: private driver data size
932 * @cid: connection id
934 * This can be called from a LLD or iscsi_transport. The connection
935 * is child of the session so cid must be unique for all connections
938 * Since we do not support MCS, cid will normally be zero. In some cases
939 * for software iscsi we could be trying to preallocate a connection struct
940 * in which case there could be two connection structs and cid would be
943 struct iscsi_cls_conn *
944 iscsi_create_conn(struct iscsi_cls_session *session, int dd_size, uint32_t cid)
946 struct iscsi_transport *transport = session->transport;
947 struct iscsi_cls_conn *conn;
951 conn = kzalloc(sizeof(*conn) + dd_size, GFP_KERNEL);
955 conn->dd_data = &conn[1];
957 mutex_init(&conn->ep_mutex);
958 INIT_LIST_HEAD(&conn->conn_list);
959 conn->transport = transport;
962 /* this is released in the dev's release function */
963 if (!get_device(&session->dev))
966 dev_set_name(&conn->dev, "connection%d:%u", session->sid, cid);
967 conn->dev.parent = &session->dev;
968 conn->dev.release = iscsi_conn_release;
969 err = device_register(&conn->dev);
971 iscsi_cls_session_printk(KERN_ERR, session, "could not "
972 "register connection's dev\n");
973 goto release_parent_ref;
975 transport_register_device(&conn->dev);
977 spin_lock_irqsave(&connlock, flags);
978 list_add(&conn->conn_list, &connlist);
980 spin_unlock_irqrestore(&connlock, flags);
982 ISCSI_DBG_TRANS_CONN(conn, "Completed conn creation\n");
986 put_device(&session->dev);
992 EXPORT_SYMBOL_GPL(iscsi_create_conn);
995 * iscsi_destroy_conn - destroy iscsi class connection
996 * @conn: iscsi cls session
998 * This can be called from a LLD or iscsi_transport.
1000 int iscsi_destroy_conn(struct iscsi_cls_conn *conn)
1002 unsigned long flags;
1004 spin_lock_irqsave(&connlock, flags);
1006 list_del(&conn->conn_list);
1007 spin_unlock_irqrestore(&connlock, flags);
1009 transport_unregister_device(&conn->dev);
1010 ISCSI_DBG_TRANS_CONN(conn, "Completing conn destruction\n");
1011 device_unregister(&conn->dev);
1014 EXPORT_SYMBOL_GPL(iscsi_destroy_conn);
1017 * iscsi interface functions
1019 static struct iscsi_internal *
1020 iscsi_if_transport_lookup(struct iscsi_transport *tt)
1022 struct iscsi_internal *priv;
1023 unsigned long flags;
1025 spin_lock_irqsave(&iscsi_transport_lock, flags);
1026 list_for_each_entry(priv, &iscsi_transports, list) {
1027 if (tt == priv->iscsi_transport) {
1028 spin_unlock_irqrestore(&iscsi_transport_lock, flags);
1032 spin_unlock_irqrestore(&iscsi_transport_lock, flags);
1037 iscsi_multicast_skb(struct sk_buff *skb, uint32_t group, gfp_t gfp)
1039 return nlmsg_multicast(nls, skb, 0, group, gfp);
1042 int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
1043 char *data, uint32_t data_size)
1045 struct nlmsghdr *nlh;
1046 struct sk_buff *skb;
1047 struct iscsi_uevent *ev;
1049 struct iscsi_internal *priv;
1050 int len = NLMSG_SPACE(sizeof(*ev) + sizeof(struct iscsi_hdr) +
1053 priv = iscsi_if_transport_lookup(conn->transport);
1057 skb = alloc_skb(len, GFP_ATOMIC);
1059 iscsi_conn_error_event(conn, ISCSI_ERR_CONN_FAILED);
1060 iscsi_cls_conn_printk(KERN_ERR, conn, "can not deliver "
1061 "control PDU: OOM\n");
1065 nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
1066 ev = NLMSG_DATA(nlh);
1067 memset(ev, 0, sizeof(*ev));
1068 ev->transport_handle = iscsi_handle(conn->transport);
1069 ev->type = ISCSI_KEVENT_RECV_PDU;
1070 ev->r.recv_req.cid = conn->cid;
1071 ev->r.recv_req.sid = iscsi_conn_get_sid(conn);
1072 pdu = (char*)ev + sizeof(*ev);
1073 memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
1074 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);
1076 return iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
1078 EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
1080 int iscsi_offload_mesg(struct Scsi_Host *shost,
1081 struct iscsi_transport *transport, uint32_t type,
1082 char *data, uint16_t data_size)
1084 struct nlmsghdr *nlh;
1085 struct sk_buff *skb;
1086 struct iscsi_uevent *ev;
1087 int len = NLMSG_SPACE(sizeof(*ev) + data_size);
1089 skb = alloc_skb(len, GFP_ATOMIC);
1091 printk(KERN_ERR "can not deliver iscsi offload message:OOM\n");
1095 nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
1096 ev = NLMSG_DATA(nlh);
1097 memset(ev, 0, sizeof(*ev));
1099 ev->transport_handle = iscsi_handle(transport);
1101 case ISCSI_KEVENT_PATH_REQ:
1102 ev->r.req_path.host_no = shost->host_no;
1104 case ISCSI_KEVENT_IF_DOWN:
1105 ev->r.notify_if_down.host_no = shost->host_no;
1109 memcpy((char *)ev + sizeof(*ev), data, data_size);
1111 return iscsi_multicast_skb(skb, ISCSI_NL_GRP_UIP, GFP_ATOMIC);
1113 EXPORT_SYMBOL_GPL(iscsi_offload_mesg);
1115 void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)
1117 struct nlmsghdr *nlh;
1118 struct sk_buff *skb;
1119 struct iscsi_uevent *ev;
1120 struct iscsi_internal *priv;
1121 int len = NLMSG_SPACE(sizeof(*ev));
1123 priv = iscsi_if_transport_lookup(conn->transport);
1127 skb = alloc_skb(len, GFP_ATOMIC);
1129 iscsi_cls_conn_printk(KERN_ERR, conn, "gracefully ignored "
1130 "conn error (%d)\n", error);
1134 nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
1135 ev = NLMSG_DATA(nlh);
1136 ev->transport_handle = iscsi_handle(conn->transport);
1137 ev->type = ISCSI_KEVENT_CONN_ERROR;
1138 ev->r.connerror.error = error;
1139 ev->r.connerror.cid = conn->cid;
1140 ev->r.connerror.sid = iscsi_conn_get_sid(conn);
1142 iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
1144 iscsi_cls_conn_printk(KERN_INFO, conn, "detected conn error (%d)\n",
1147 EXPORT_SYMBOL_GPL(iscsi_conn_error_event);
1150 iscsi_if_send_reply(uint32_t group, int seq, int type, int done, int multi,
1151 void *payload, int size)
1153 struct sk_buff *skb;
1154 struct nlmsghdr *nlh;
1155 int len = NLMSG_SPACE(size);
1156 int flags = multi ? NLM_F_MULTI : 0;
1157 int t = done ? NLMSG_DONE : type;
1159 skb = alloc_skb(len, GFP_ATOMIC);
1161 printk(KERN_ERR "Could not allocate skb to send reply.\n");
1165 nlh = __nlmsg_put(skb, 0, 0, t, (len - sizeof(*nlh)), 0);
1166 nlh->nlmsg_flags = flags;
1167 memcpy(NLMSG_DATA(nlh), payload, size);
1168 return iscsi_multicast_skb(skb, group, GFP_ATOMIC);
1172 iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
1174 struct iscsi_uevent *ev = NLMSG_DATA(nlh);
1175 struct iscsi_stats *stats;
1176 struct sk_buff *skbstat;
1177 struct iscsi_cls_conn *conn;
1178 struct nlmsghdr *nlhstat;
1179 struct iscsi_uevent *evstat;
1180 struct iscsi_internal *priv;
1181 int len = NLMSG_SPACE(sizeof(*ev) +
1182 sizeof(struct iscsi_stats) +
1183 sizeof(struct iscsi_stats_custom) *
1184 ISCSI_STATS_CUSTOM_MAX);
1187 priv = iscsi_if_transport_lookup(transport);
1191 conn = iscsi_conn_lookup(ev->u.get_stats.sid, ev->u.get_stats.cid);
1198 skbstat = alloc_skb(len, GFP_ATOMIC);
1200 iscsi_cls_conn_printk(KERN_ERR, conn, "can not "
1201 "deliver stats: OOM\n");
1205 nlhstat = __nlmsg_put(skbstat, 0, 0, 0,
1206 (len - sizeof(*nlhstat)), 0);
1207 evstat = NLMSG_DATA(nlhstat);
1208 memset(evstat, 0, sizeof(*evstat));
1209 evstat->transport_handle = iscsi_handle(conn->transport);
1210 evstat->type = nlh->nlmsg_type;
1211 evstat->u.get_stats.cid =
1212 ev->u.get_stats.cid;
1213 evstat->u.get_stats.sid =
1214 ev->u.get_stats.sid;
1215 stats = (struct iscsi_stats *)
1216 ((char*)evstat + sizeof(*evstat));
1217 memset(stats, 0, sizeof(*stats));
1219 transport->get_stats(conn, stats);
1220 actual_size = NLMSG_SPACE(sizeof(struct iscsi_uevent) +
1221 sizeof(struct iscsi_stats) +
1222 sizeof(struct iscsi_stats_custom) *
1223 stats->custom_length);
1224 actual_size -= sizeof(*nlhstat);
1225 actual_size = NLMSG_LENGTH(actual_size);
1226 skb_trim(skbstat, NLMSG_ALIGN(actual_size));
1227 nlhstat->nlmsg_len = actual_size;
1229 err = iscsi_multicast_skb(skbstat, ISCSI_NL_GRP_ISCSID,
1231 } while (err < 0 && err != -ECONNREFUSED);
1237 * iscsi_session_event - send session destr. completion event
1238 * @session: iscsi class session
1239 * @event: type of event
1241 int iscsi_session_event(struct iscsi_cls_session *session,
1242 enum iscsi_uevent_e event)
1244 struct iscsi_internal *priv;
1245 struct Scsi_Host *shost;
1246 struct iscsi_uevent *ev;
1247 struct sk_buff *skb;
1248 struct nlmsghdr *nlh;
1249 int rc, len = NLMSG_SPACE(sizeof(*ev));
1251 priv = iscsi_if_transport_lookup(session->transport);
1254 shost = iscsi_session_to_shost(session);
1256 skb = alloc_skb(len, GFP_KERNEL);
1258 iscsi_cls_session_printk(KERN_ERR, session,
1259 "Cannot notify userspace of session "
1260 "event %u\n", event);
1264 nlh = __nlmsg_put(skb, 0, 0, 0, (len - sizeof(*nlh)), 0);
1265 ev = NLMSG_DATA(nlh);
1266 ev->transport_handle = iscsi_handle(session->transport);
1270 case ISCSI_KEVENT_DESTROY_SESSION:
1271 ev->r.d_session.host_no = shost->host_no;
1272 ev->r.d_session.sid = session->sid;
1274 case ISCSI_KEVENT_CREATE_SESSION:
1275 ev->r.c_session_ret.host_no = shost->host_no;
1276 ev->r.c_session_ret.sid = session->sid;
1278 case ISCSI_KEVENT_UNBIND_SESSION:
1279 ev->r.unbind_session.host_no = shost->host_no;
1280 ev->r.unbind_session.sid = session->sid;
1283 iscsi_cls_session_printk(KERN_ERR, session, "Invalid event "
1290 * this will occur if the daemon is not up, so we just warn
1291 * the user and when the daemon is restarted it will handle it
1293 rc = iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_KERNEL);
1295 iscsi_cls_session_printk(KERN_ERR, session,
1296 "Cannot notify userspace of session "
1297 "event %u. Check iscsi daemon\n",
1300 ISCSI_DBG_TRANS_SESSION(session, "Completed handling event %d rc %d\n",
1304 EXPORT_SYMBOL_GPL(iscsi_session_event);
1307 iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_endpoint *ep,
1308 struct iscsi_uevent *ev, uint32_t initial_cmdsn,
1309 uint16_t cmds_max, uint16_t queue_depth)
1311 struct iscsi_transport *transport = priv->iscsi_transport;
1312 struct iscsi_cls_session *session;
1313 struct Scsi_Host *shost;
1315 session = transport->create_session(ep, cmds_max, queue_depth,
1320 shost = iscsi_session_to_shost(session);
1321 ev->r.c_session_ret.host_no = shost->host_no;
1322 ev->r.c_session_ret.sid = session->sid;
1323 ISCSI_DBG_TRANS_SESSION(session,
1324 "Completed creating transport session\n");
1329 iscsi_if_create_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev)
1331 struct iscsi_cls_conn *conn;
1332 struct iscsi_cls_session *session;
1334 session = iscsi_session_lookup(ev->u.c_conn.sid);
1336 printk(KERN_ERR "iscsi: invalid session %d.\n",
1341 conn = transport->create_conn(session, ev->u.c_conn.cid);
1343 iscsi_cls_session_printk(KERN_ERR, session,
1344 "couldn't create a new connection.");
1348 ev->r.c_conn_ret.sid = session->sid;
1349 ev->r.c_conn_ret.cid = conn->cid;
1351 ISCSI_DBG_TRANS_CONN(conn, "Completed creating transport conn\n");
1356 iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev)
1358 struct iscsi_cls_conn *conn;
1360 conn = iscsi_conn_lookup(ev->u.d_conn.sid, ev->u.d_conn.cid);
1364 ISCSI_DBG_TRANS_CONN(conn, "Destroying transport conn\n");
1365 if (transport->destroy_conn)
1366 transport->destroy_conn(conn);
1372 iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev)
1374 char *data = (char*)ev + sizeof(*ev);
1375 struct iscsi_cls_conn *conn;
1376 struct iscsi_cls_session *session;
1377 int err = 0, value = 0;
1379 session = iscsi_session_lookup(ev->u.set_param.sid);
1380 conn = iscsi_conn_lookup(ev->u.set_param.sid, ev->u.set_param.cid);
1381 if (!conn || !session)
1384 switch (ev->u.set_param.param) {
1385 case ISCSI_PARAM_SESS_RECOVERY_TMO:
1386 sscanf(data, "%d", &value);
1387 session->recovery_tmo = value;
1390 err = transport->set_param(conn, ev->u.set_param.param,
1391 data, ev->u.set_param.len);
1397 static int iscsi_if_ep_connect(struct iscsi_transport *transport,
1398 struct iscsi_uevent *ev, int msg_type)
1400 struct iscsi_endpoint *ep;
1401 struct sockaddr *dst_addr;
1402 struct Scsi_Host *shost = NULL;
1403 int non_blocking, err = 0;
1405 if (!transport->ep_connect)
1408 if (msg_type == ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST) {
1409 shost = scsi_host_lookup(ev->u.ep_connect_through_host.host_no);
1411 printk(KERN_ERR "ep connect failed. Could not find "
1413 ev->u.ep_connect_through_host.host_no);
1416 non_blocking = ev->u.ep_connect_through_host.non_blocking;
1418 non_blocking = ev->u.ep_connect.non_blocking;
1420 dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev));
1421 ep = transport->ep_connect(shost, dst_addr, non_blocking);
1427 ev->r.ep_connect_ret.handle = ep->id;
1430 scsi_host_put(shost);
1434 static int iscsi_if_ep_disconnect(struct iscsi_transport *transport,
1437 struct iscsi_cls_conn *conn;
1438 struct iscsi_endpoint *ep;
1440 if (!transport->ep_disconnect)
1443 ep = iscsi_lookup_endpoint(ep_handle);
1448 mutex_lock(&conn->ep_mutex);
1450 mutex_unlock(&conn->ep_mutex);
1453 transport->ep_disconnect(ep);
1458 iscsi_if_transport_ep(struct iscsi_transport *transport,
1459 struct iscsi_uevent *ev, int msg_type)
1461 struct iscsi_endpoint *ep;
1465 case ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST:
1466 case ISCSI_UEVENT_TRANSPORT_EP_CONNECT:
1467 rc = iscsi_if_ep_connect(transport, ev, msg_type);
1469 case ISCSI_UEVENT_TRANSPORT_EP_POLL:
1470 if (!transport->ep_poll)
1473 ep = iscsi_lookup_endpoint(ev->u.ep_poll.ep_handle);
1477 ev->r.retcode = transport->ep_poll(ep,
1478 ev->u.ep_poll.timeout_ms);
1480 case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:
1481 rc = iscsi_if_ep_disconnect(transport,
1482 ev->u.ep_disconnect.ep_handle);
1489 iscsi_tgt_dscvr(struct iscsi_transport *transport,
1490 struct iscsi_uevent *ev)
1492 struct Scsi_Host *shost;
1493 struct sockaddr *dst_addr;
1496 if (!transport->tgt_dscvr)
1499 shost = scsi_host_lookup(ev->u.tgt_dscvr.host_no);
1501 printk(KERN_ERR "target discovery could not find host no %u\n",
1502 ev->u.tgt_dscvr.host_no);
1507 dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev));
1508 err = transport->tgt_dscvr(shost, ev->u.tgt_dscvr.type,
1509 ev->u.tgt_dscvr.enable, dst_addr);
1510 scsi_host_put(shost);
1515 iscsi_set_host_param(struct iscsi_transport *transport,
1516 struct iscsi_uevent *ev)
1518 char *data = (char*)ev + sizeof(*ev);
1519 struct Scsi_Host *shost;
1522 if (!transport->set_host_param)
1525 shost = scsi_host_lookup(ev->u.set_host_param.host_no);
1527 printk(KERN_ERR "set_host_param could not find host no %u\n",
1528 ev->u.set_host_param.host_no);
1532 err = transport->set_host_param(shost, ev->u.set_host_param.param,
1533 data, ev->u.set_host_param.len);
1534 scsi_host_put(shost);
1539 iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
1541 struct Scsi_Host *shost;
1542 struct iscsi_path *params;
1545 if (!transport->set_path)
1548 shost = scsi_host_lookup(ev->u.set_path.host_no);
1550 printk(KERN_ERR "set path could not find host no %u\n",
1551 ev->u.set_path.host_no);
1555 params = (struct iscsi_path *)((char *)ev + sizeof(*ev));
1556 err = transport->set_path(shost, params);
1558 scsi_host_put(shost);
1563 iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
1566 struct iscsi_uevent *ev = NLMSG_DATA(nlh);
1567 struct iscsi_transport *transport = NULL;
1568 struct iscsi_internal *priv;
1569 struct iscsi_cls_session *session;
1570 struct iscsi_cls_conn *conn;
1571 struct iscsi_endpoint *ep = NULL;
1573 if (nlh->nlmsg_type == ISCSI_UEVENT_PATH_UPDATE)
1574 *group = ISCSI_NL_GRP_UIP;
1576 *group = ISCSI_NL_GRP_ISCSID;
1578 priv = iscsi_if_transport_lookup(iscsi_ptr(ev->transport_handle));
1581 transport = priv->iscsi_transport;
1583 if (!try_module_get(transport->owner))
1586 switch (nlh->nlmsg_type) {
1587 case ISCSI_UEVENT_CREATE_SESSION:
1588 err = iscsi_if_create_session(priv, ep, ev,
1589 ev->u.c_session.initial_cmdsn,
1590 ev->u.c_session.cmds_max,
1591 ev->u.c_session.queue_depth);
1593 case ISCSI_UEVENT_CREATE_BOUND_SESSION:
1594 ep = iscsi_lookup_endpoint(ev->u.c_bound_session.ep_handle);
1600 err = iscsi_if_create_session(priv, ep, ev,
1601 ev->u.c_bound_session.initial_cmdsn,
1602 ev->u.c_bound_session.cmds_max,
1603 ev->u.c_bound_session.queue_depth);
1605 case ISCSI_UEVENT_DESTROY_SESSION:
1606 session = iscsi_session_lookup(ev->u.d_session.sid);
1608 transport->destroy_session(session);
1612 case ISCSI_UEVENT_UNBIND_SESSION:
1613 session = iscsi_session_lookup(ev->u.d_session.sid);
1615 scsi_queue_work(iscsi_session_to_shost(session),
1616 &session->unbind_work);
1620 case ISCSI_UEVENT_CREATE_CONN:
1621 err = iscsi_if_create_conn(transport, ev);
1623 case ISCSI_UEVENT_DESTROY_CONN:
1624 err = iscsi_if_destroy_conn(transport, ev);
1626 case ISCSI_UEVENT_BIND_CONN:
1627 session = iscsi_session_lookup(ev->u.b_conn.sid);
1628 conn = iscsi_conn_lookup(ev->u.b_conn.sid, ev->u.b_conn.cid);
1630 if (conn && conn->ep)
1631 iscsi_if_ep_disconnect(transport, conn->ep->id);
1633 if (!session || !conn) {
1638 ev->r.retcode = transport->bind_conn(session, conn,
1639 ev->u.b_conn.transport_eph,
1640 ev->u.b_conn.is_leading);
1641 if (ev->r.retcode || !transport->ep_connect)
1644 ep = iscsi_lookup_endpoint(ev->u.b_conn.transport_eph);
1648 mutex_lock(&conn->ep_mutex);
1650 mutex_unlock(&conn->ep_mutex);
1652 iscsi_cls_conn_printk(KERN_ERR, conn,
1653 "Could not set ep conn "
1656 case ISCSI_UEVENT_SET_PARAM:
1657 err = iscsi_set_param(transport, ev);
1659 case ISCSI_UEVENT_START_CONN:
1660 conn = iscsi_conn_lookup(ev->u.start_conn.sid, ev->u.start_conn.cid);
1662 ev->r.retcode = transport->start_conn(conn);
1666 case ISCSI_UEVENT_STOP_CONN:
1667 conn = iscsi_conn_lookup(ev->u.stop_conn.sid, ev->u.stop_conn.cid);
1669 transport->stop_conn(conn, ev->u.stop_conn.flag);
1673 case ISCSI_UEVENT_SEND_PDU:
1674 conn = iscsi_conn_lookup(ev->u.send_pdu.sid, ev->u.send_pdu.cid);
1676 ev->r.retcode = transport->send_pdu(conn,
1677 (struct iscsi_hdr*)((char*)ev + sizeof(*ev)),
1678 (char*)ev + sizeof(*ev) + ev->u.send_pdu.hdr_size,
1679 ev->u.send_pdu.data_size);
1683 case ISCSI_UEVENT_GET_STATS:
1684 err = iscsi_if_get_stats(transport, nlh);
1686 case ISCSI_UEVENT_TRANSPORT_EP_CONNECT:
1687 case ISCSI_UEVENT_TRANSPORT_EP_POLL:
1688 case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:
1689 case ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST:
1690 err = iscsi_if_transport_ep(transport, ev, nlh->nlmsg_type);
1692 case ISCSI_UEVENT_TGT_DSCVR:
1693 err = iscsi_tgt_dscvr(transport, ev);
1695 case ISCSI_UEVENT_SET_HOST_PARAM:
1696 err = iscsi_set_host_param(transport, ev);
1698 case ISCSI_UEVENT_PATH_UPDATE:
1699 err = iscsi_set_path(transport, ev);
1706 module_put(transport->owner);
1711 * Get message from skb. Each message is processed by iscsi_if_recv_msg.
1712 * Malformed skbs with wrong lengths or invalid creds are not processed.
1715 iscsi_if_rx(struct sk_buff *skb)
1717 mutex_lock(&rx_queue_mutex);
1718 while (skb->len >= NLMSG_SPACE(0)) {
1721 struct nlmsghdr *nlh;
1722 struct iscsi_uevent *ev;
1725 nlh = nlmsg_hdr(skb);
1726 if (nlh->nlmsg_len < sizeof(*nlh) ||
1727 skb->len < nlh->nlmsg_len) {
1731 ev = NLMSG_DATA(nlh);
1732 rlen = NLMSG_ALIGN(nlh->nlmsg_len);
1733 if (rlen > skb->len)
1736 err = iscsi_if_recv_msg(skb, nlh, &group);
1738 ev->type = ISCSI_KEVENT_IF_ERROR;
1743 * special case for GET_STATS:
1744 * on success - sending reply and stats from
1745 * inside of if_recv_msg(),
1746 * on error - fall through.
1748 if (ev->type == ISCSI_UEVENT_GET_STATS && !err)
1750 err = iscsi_if_send_reply(group, nlh->nlmsg_seq,
1751 nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
1752 } while (err < 0 && err != -ECONNREFUSED);
1753 skb_pull(skb, rlen);
1755 mutex_unlock(&rx_queue_mutex);
1758 #define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \
1759 struct device_attribute dev_attr_##_prefix##_##_name = \
1760 __ATTR(_name,_mode,_show,_store)
1763 * iSCSI connection attrs
1765 #define iscsi_conn_attr_show(param) \
1767 show_conn_param_##param(struct device *dev, \
1768 struct device_attribute *attr, char *buf) \
1770 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); \
1771 struct iscsi_transport *t = conn->transport; \
1772 return t->get_conn_param(conn, param, buf); \
1775 #define iscsi_conn_attr(field, param) \
1776 iscsi_conn_attr_show(param) \
1777 static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, show_conn_param_##param, \
1780 iscsi_conn_attr(max_recv_dlength, ISCSI_PARAM_MAX_RECV_DLENGTH);
1781 iscsi_conn_attr(max_xmit_dlength, ISCSI_PARAM_MAX_XMIT_DLENGTH);
1782 iscsi_conn_attr(header_digest, ISCSI_PARAM_HDRDGST_EN);
1783 iscsi_conn_attr(data_digest, ISCSI_PARAM_DATADGST_EN);
1784 iscsi_conn_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN);
1785 iscsi_conn_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN);
1786 iscsi_conn_attr(persistent_port, ISCSI_PARAM_PERSISTENT_PORT);
1787 iscsi_conn_attr(port, ISCSI_PARAM_CONN_PORT);
1788 iscsi_conn_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN);
1789 iscsi_conn_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS);
1790 iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS);
1791 iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO);
1792 iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO);
1795 * iSCSI session attrs
1797 #define iscsi_session_attr_show(param, perm) \
1799 show_session_param_##param(struct device *dev, \
1800 struct device_attribute *attr, char *buf) \
1802 struct iscsi_cls_session *session = \
1803 iscsi_dev_to_session(dev->parent); \
1804 struct iscsi_transport *t = session->transport; \
1806 if (perm && !capable(CAP_SYS_ADMIN)) \
1808 return t->get_session_param(session, param, buf); \
1811 #define iscsi_session_attr(field, param, perm) \
1812 iscsi_session_attr_show(param, perm) \
1813 static ISCSI_CLASS_ATTR(sess, field, S_IRUGO, show_session_param_##param, \
1816 iscsi_session_attr(targetname, ISCSI_PARAM_TARGET_NAME, 0);
1817 iscsi_session_attr(initial_r2t, ISCSI_PARAM_INITIAL_R2T_EN, 0);
1818 iscsi_session_attr(max_outstanding_r2t, ISCSI_PARAM_MAX_R2T, 0);
1819 iscsi_session_attr(immediate_data, ISCSI_PARAM_IMM_DATA_EN, 0);
1820 iscsi_session_attr(first_burst_len, ISCSI_PARAM_FIRST_BURST, 0);
1821 iscsi_session_attr(max_burst_len, ISCSI_PARAM_MAX_BURST, 0);
1822 iscsi_session_attr(data_pdu_in_order, ISCSI_PARAM_PDU_INORDER_EN, 0);
1823 iscsi_session_attr(data_seq_in_order, ISCSI_PARAM_DATASEQ_INORDER_EN, 0);
1824 iscsi_session_attr(erl, ISCSI_PARAM_ERL, 0);
1825 iscsi_session_attr(tpgt, ISCSI_PARAM_TPGT, 0);
1826 iscsi_session_attr(username, ISCSI_PARAM_USERNAME, 1);
1827 iscsi_session_attr(username_in, ISCSI_PARAM_USERNAME_IN, 1);
1828 iscsi_session_attr(password, ISCSI_PARAM_PASSWORD, 1);
1829 iscsi_session_attr(password_in, ISCSI_PARAM_PASSWORD_IN, 1);
1830 iscsi_session_attr(fast_abort, ISCSI_PARAM_FAST_ABORT, 0);
1831 iscsi_session_attr(abort_tmo, ISCSI_PARAM_ABORT_TMO, 0);
1832 iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0);
1833 iscsi_session_attr(tgt_reset_tmo, ISCSI_PARAM_TGT_RESET_TMO, 0);
1834 iscsi_session_attr(ifacename, ISCSI_PARAM_IFACE_NAME, 0);
1835 iscsi_session_attr(initiatorname, ISCSI_PARAM_INITIATOR_NAME, 0);
1836 iscsi_session_attr(targetalias, ISCSI_PARAM_TARGET_ALIAS, 0);
1839 show_priv_session_state(struct device *dev, struct device_attribute *attr,
1842 struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent);
1843 return sprintf(buf, "%s\n", iscsi_session_state_name(session->state));
1845 static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state,
1848 #define iscsi_priv_session_attr_show(field, format) \
1850 show_priv_session_##field(struct device *dev, \
1851 struct device_attribute *attr, char *buf) \
1853 struct iscsi_cls_session *session = \
1854 iscsi_dev_to_session(dev->parent); \
1855 if (session->field == -1) \
1856 return sprintf(buf, "off\n"); \
1857 return sprintf(buf, format"\n", session->field); \
1860 #define iscsi_priv_session_attr_store(field) \
1862 store_priv_session_##field(struct device *dev, \
1863 struct device_attribute *attr, \
1864 const char *buf, size_t count) \
1868 struct iscsi_cls_session *session = \
1869 iscsi_dev_to_session(dev->parent); \
1870 if ((session->state == ISCSI_SESSION_FREE) || \
1871 (session->state == ISCSI_SESSION_FAILED)) \
1873 if (strncmp(buf, "off", 3) == 0) \
1874 session->field = -1; \
1876 val = simple_strtoul(buf, &cp, 0); \
1877 if (*cp != '\0' && *cp != '\n') \
1879 session->field = val; \
1884 #define iscsi_priv_session_rw_attr(field, format) \
1885 iscsi_priv_session_attr_show(field, format) \
1886 iscsi_priv_session_attr_store(field) \
1887 static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO | S_IWUGO, \
1888 show_priv_session_##field, \
1889 store_priv_session_##field)
1890 iscsi_priv_session_rw_attr(recovery_tmo, "%d");
1895 #define iscsi_host_attr_show(param) \
1897 show_host_param_##param(struct device *dev, \
1898 struct device_attribute *attr, char *buf) \
1900 struct Scsi_Host *shost = transport_class_to_shost(dev); \
1901 struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \
1902 return priv->iscsi_transport->get_host_param(shost, param, buf); \
1905 #define iscsi_host_attr(field, param) \
1906 iscsi_host_attr_show(param) \
1907 static ISCSI_CLASS_ATTR(host, field, S_IRUGO, show_host_param_##param, \
1910 iscsi_host_attr(netdev, ISCSI_HOST_PARAM_NETDEV_NAME);
1911 iscsi_host_attr(hwaddress, ISCSI_HOST_PARAM_HWADDRESS);
1912 iscsi_host_attr(ipaddress, ISCSI_HOST_PARAM_IPADDRESS);
1913 iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME);
1915 #define SETUP_PRIV_SESSION_RD_ATTR(field) \
1917 priv->session_attrs[count] = &dev_attr_priv_sess_##field; \
1921 #define SETUP_PRIV_SESSION_RW_ATTR(field) \
1923 priv->session_attrs[count] = &dev_attr_priv_sess_##field; \
1927 #define SETUP_SESSION_RD_ATTR(field, param_flag) \
1929 if (tt->param_mask & param_flag) { \
1930 priv->session_attrs[count] = &dev_attr_sess_##field; \
1935 #define SETUP_CONN_RD_ATTR(field, param_flag) \
1937 if (tt->param_mask & param_flag) { \
1938 priv->conn_attrs[count] = &dev_attr_conn_##field; \
1943 #define SETUP_HOST_RD_ATTR(field, param_flag) \
1945 if (tt->host_param_mask & param_flag) { \
1946 priv->host_attrs[count] = &dev_attr_host_##field; \
1951 static int iscsi_session_match(struct attribute_container *cont,
1954 struct iscsi_cls_session *session;
1955 struct Scsi_Host *shost;
1956 struct iscsi_internal *priv;
1958 if (!iscsi_is_session_dev(dev))
1961 session = iscsi_dev_to_session(dev);
1962 shost = iscsi_session_to_shost(session);
1963 if (!shost->transportt)
1966 priv = to_iscsi_internal(shost->transportt);
1967 if (priv->session_cont.ac.class != &iscsi_session_class.class)
1970 return &priv->session_cont.ac == cont;
1973 static int iscsi_conn_match(struct attribute_container *cont,
1976 struct iscsi_cls_session *session;
1977 struct iscsi_cls_conn *conn;
1978 struct Scsi_Host *shost;
1979 struct iscsi_internal *priv;
1981 if (!iscsi_is_conn_dev(dev))
1984 conn = iscsi_dev_to_conn(dev);
1985 session = iscsi_dev_to_session(conn->dev.parent);
1986 shost = iscsi_session_to_shost(session);
1988 if (!shost->transportt)
1991 priv = to_iscsi_internal(shost->transportt);
1992 if (priv->conn_cont.ac.class != &iscsi_connection_class.class)
1995 return &priv->conn_cont.ac == cont;
1998 static int iscsi_host_match(struct attribute_container *cont,
2001 struct Scsi_Host *shost;
2002 struct iscsi_internal *priv;
2004 if (!scsi_is_host_device(dev))
2007 shost = dev_to_shost(dev);
2008 if (!shost->transportt ||
2009 shost->transportt->host_attrs.ac.class != &iscsi_host_class.class)
2012 priv = to_iscsi_internal(shost->transportt);
2013 return &priv->t.host_attrs.ac == cont;
2016 struct scsi_transport_template *
2017 iscsi_register_transport(struct iscsi_transport *tt)
2019 struct iscsi_internal *priv;
2020 unsigned long flags;
2025 priv = iscsi_if_transport_lookup(tt);
2029 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
2032 INIT_LIST_HEAD(&priv->list);
2033 priv->iscsi_transport = tt;
2034 priv->t.user_scan = iscsi_user_scan;
2035 priv->t.create_work_queue = 1;
2037 priv->dev.class = &iscsi_transport_class;
2038 dev_set_name(&priv->dev, "%s", tt->name);
2039 err = device_register(&priv->dev);
2043 err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group);
2045 goto unregister_dev;
2047 /* host parameters */
2048 priv->t.host_attrs.ac.attrs = &priv->host_attrs[0];
2049 priv->t.host_attrs.ac.class = &iscsi_host_class.class;
2050 priv->t.host_attrs.ac.match = iscsi_host_match;
2051 priv->t.host_size = sizeof(struct iscsi_cls_host);
2052 transport_container_register(&priv->t.host_attrs);
2054 SETUP_HOST_RD_ATTR(netdev, ISCSI_HOST_NETDEV_NAME);
2055 SETUP_HOST_RD_ATTR(ipaddress, ISCSI_HOST_IPADDRESS);
2056 SETUP_HOST_RD_ATTR(hwaddress, ISCSI_HOST_HWADDRESS);
2057 SETUP_HOST_RD_ATTR(initiatorname, ISCSI_HOST_INITIATOR_NAME);
2058 BUG_ON(count > ISCSI_HOST_ATTRS);
2059 priv->host_attrs[count] = NULL;
2062 /* connection parameters */
2063 priv->conn_cont.ac.attrs = &priv->conn_attrs[0];
2064 priv->conn_cont.ac.class = &iscsi_connection_class.class;
2065 priv->conn_cont.ac.match = iscsi_conn_match;
2066 transport_container_register(&priv->conn_cont);
2068 SETUP_CONN_RD_ATTR(max_recv_dlength, ISCSI_MAX_RECV_DLENGTH);
2069 SETUP_CONN_RD_ATTR(max_xmit_dlength, ISCSI_MAX_XMIT_DLENGTH);
2070 SETUP_CONN_RD_ATTR(header_digest, ISCSI_HDRDGST_EN);
2071 SETUP_CONN_RD_ATTR(data_digest, ISCSI_DATADGST_EN);
2072 SETUP_CONN_RD_ATTR(ifmarker, ISCSI_IFMARKER_EN);
2073 SETUP_CONN_RD_ATTR(ofmarker, ISCSI_OFMARKER_EN);
2074 SETUP_CONN_RD_ATTR(address, ISCSI_CONN_ADDRESS);
2075 SETUP_CONN_RD_ATTR(port, ISCSI_CONN_PORT);
2076 SETUP_CONN_RD_ATTR(exp_statsn, ISCSI_EXP_STATSN);
2077 SETUP_CONN_RD_ATTR(persistent_address, ISCSI_PERSISTENT_ADDRESS);
2078 SETUP_CONN_RD_ATTR(persistent_port, ISCSI_PERSISTENT_PORT);
2079 SETUP_CONN_RD_ATTR(ping_tmo, ISCSI_PING_TMO);
2080 SETUP_CONN_RD_ATTR(recv_tmo, ISCSI_RECV_TMO);
2082 BUG_ON(count > ISCSI_CONN_ATTRS);
2083 priv->conn_attrs[count] = NULL;
2086 /* session parameters */
2087 priv->session_cont.ac.attrs = &priv->session_attrs[0];
2088 priv->session_cont.ac.class = &iscsi_session_class.class;
2089 priv->session_cont.ac.match = iscsi_session_match;
2090 transport_container_register(&priv->session_cont);
2092 SETUP_SESSION_RD_ATTR(initial_r2t, ISCSI_INITIAL_R2T_EN);
2093 SETUP_SESSION_RD_ATTR(max_outstanding_r2t, ISCSI_MAX_R2T);
2094 SETUP_SESSION_RD_ATTR(immediate_data, ISCSI_IMM_DATA_EN);
2095 SETUP_SESSION_RD_ATTR(first_burst_len, ISCSI_FIRST_BURST);
2096 SETUP_SESSION_RD_ATTR(max_burst_len, ISCSI_MAX_BURST);
2097 SETUP_SESSION_RD_ATTR(data_pdu_in_order, ISCSI_PDU_INORDER_EN);
2098 SETUP_SESSION_RD_ATTR(data_seq_in_order, ISCSI_DATASEQ_INORDER_EN);
2099 SETUP_SESSION_RD_ATTR(erl, ISCSI_ERL);
2100 SETUP_SESSION_RD_ATTR(targetname, ISCSI_TARGET_NAME);
2101 SETUP_SESSION_RD_ATTR(tpgt, ISCSI_TPGT);
2102 SETUP_SESSION_RD_ATTR(password, ISCSI_USERNAME);
2103 SETUP_SESSION_RD_ATTR(password_in, ISCSI_USERNAME_IN);
2104 SETUP_SESSION_RD_ATTR(username, ISCSI_PASSWORD);
2105 SETUP_SESSION_RD_ATTR(username_in, ISCSI_PASSWORD_IN);
2106 SETUP_SESSION_RD_ATTR(fast_abort, ISCSI_FAST_ABORT);
2107 SETUP_SESSION_RD_ATTR(abort_tmo, ISCSI_ABORT_TMO);
2108 SETUP_SESSION_RD_ATTR(lu_reset_tmo,ISCSI_LU_RESET_TMO);
2109 SETUP_SESSION_RD_ATTR(tgt_reset_tmo,ISCSI_TGT_RESET_TMO);
2110 SETUP_SESSION_RD_ATTR(ifacename, ISCSI_IFACE_NAME);
2111 SETUP_SESSION_RD_ATTR(initiatorname, ISCSI_INITIATOR_NAME);
2112 SETUP_SESSION_RD_ATTR(targetalias, ISCSI_TARGET_ALIAS);
2113 SETUP_PRIV_SESSION_RW_ATTR(recovery_tmo);
2114 SETUP_PRIV_SESSION_RD_ATTR(state);
2116 BUG_ON(count > ISCSI_SESSION_ATTRS);
2117 priv->session_attrs[count] = NULL;
2119 spin_lock_irqsave(&iscsi_transport_lock, flags);
2120 list_add(&priv->list, &iscsi_transports);
2121 spin_unlock_irqrestore(&iscsi_transport_lock, flags);
2123 printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name);
2127 device_unregister(&priv->dev);
2133 EXPORT_SYMBOL_GPL(iscsi_register_transport);
2135 int iscsi_unregister_transport(struct iscsi_transport *tt)
2137 struct iscsi_internal *priv;
2138 unsigned long flags;
2142 mutex_lock(&rx_queue_mutex);
2144 priv = iscsi_if_transport_lookup(tt);
2147 spin_lock_irqsave(&iscsi_transport_lock, flags);
2148 list_del(&priv->list);
2149 spin_unlock_irqrestore(&iscsi_transport_lock, flags);
2151 transport_container_unregister(&priv->conn_cont);
2152 transport_container_unregister(&priv->session_cont);
2153 transport_container_unregister(&priv->t.host_attrs);
2155 sysfs_remove_group(&priv->dev.kobj, &iscsi_transport_group);
2156 device_unregister(&priv->dev);
2157 mutex_unlock(&rx_queue_mutex);
2161 EXPORT_SYMBOL_GPL(iscsi_unregister_transport);
2163 static __init int iscsi_transport_init(void)
2167 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
2168 ISCSI_TRANSPORT_VERSION);
2170 atomic_set(&iscsi_session_nr, 0);
2172 err = class_register(&iscsi_transport_class);
2176 err = class_register(&iscsi_endpoint_class);
2178 goto unregister_transport_class;
2180 err = transport_class_register(&iscsi_host_class);
2182 goto unregister_endpoint_class;
2184 err = transport_class_register(&iscsi_connection_class);
2186 goto unregister_host_class;
2188 err = transport_class_register(&iscsi_session_class);
2190 goto unregister_conn_class;
2192 nls = netlink_kernel_create(&init_net, NETLINK_ISCSI, 1, iscsi_if_rx,
2196 goto unregister_session_class;
2199 iscsi_eh_timer_workq = create_singlethread_workqueue("iscsi_eh");
2200 if (!iscsi_eh_timer_workq)
2206 netlink_kernel_release(nls);
2207 unregister_session_class:
2208 transport_class_unregister(&iscsi_session_class);
2209 unregister_conn_class:
2210 transport_class_unregister(&iscsi_connection_class);
2211 unregister_host_class:
2212 transport_class_unregister(&iscsi_host_class);
2213 unregister_endpoint_class:
2214 class_unregister(&iscsi_endpoint_class);
2215 unregister_transport_class:
2216 class_unregister(&iscsi_transport_class);
2220 static void __exit iscsi_transport_exit(void)
2222 destroy_workqueue(iscsi_eh_timer_workq);
2223 netlink_kernel_release(nls);
2224 transport_class_unregister(&iscsi_connection_class);
2225 transport_class_unregister(&iscsi_session_class);
2226 transport_class_unregister(&iscsi_host_class);
2227 class_unregister(&iscsi_endpoint_class);
2228 class_unregister(&iscsi_transport_class);
2231 module_init(iscsi_transport_init);
2232 module_exit(iscsi_transport_exit);
2234 MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu>, "
2235 "Dmitry Yusupov <dmitry_yus@yahoo.com>, "
2236 "Alex Aizman <itn780@yahoo.com>");
2237 MODULE_DESCRIPTION("iSCSI Transport Interface");
2238 MODULE_LICENSE("GPL");
2239 MODULE_VERSION(ISCSI_TRANSPORT_VERSION);
2240 MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_ISCSI);