Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * iSCSI transport class definitions |
| 3 | * |
| 4 | * Copyright (C) IBM Corporation, 2004 |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 5 | * Copyright (C) Mike Christie, 2004 - 2005 |
| 6 | * Copyright (C) Dmitry Yusupov, 2004 - 2005 |
| 7 | * Copyright (C) Alex Aizman, 2004 - 2005 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
| 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. |
| 13 | * |
| 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. |
| 18 | * |
| 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. |
| 22 | */ |
| 23 | #include <linux/module.h> |
Arjan van de Ven | 0b95067 | 2006-01-11 13:16:10 +0100 | [diff] [blame] | 24 | #include <linux/mutex.h> |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 25 | #include <net/tcp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <scsi/scsi.h> |
| 27 | #include <scsi/scsi_host.h> |
| 28 | #include <scsi/scsi_device.h> |
| 29 | #include <scsi/scsi_transport.h> |
| 30 | #include <scsi/scsi_transport_iscsi.h> |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 31 | #include <scsi/iscsi_if.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 33 | #define ISCSI_SESSION_ATTRS 19 |
Mike Christie | 8d2860b | 2006-05-02 19:46:47 -0500 | [diff] [blame] | 34 | #define ISCSI_CONN_ATTRS 11 |
Mike Christie | d8196ed | 2007-05-30 12:57:25 -0500 | [diff] [blame] | 35 | #define ISCSI_HOST_ATTRS 4 |
Mike Christie | 1039623 | 2007-12-13 12:43:43 -0600 | [diff] [blame] | 36 | #define ISCSI_TRANSPORT_VERSION "2.0-867" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
| 38 | struct iscsi_internal { |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 39 | int daemon_pid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | struct scsi_transport_template t; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 41 | struct iscsi_transport *iscsi_transport; |
| 42 | struct list_head list; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 43 | struct class_device cdev; |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 44 | |
| 45 | struct class_device_attribute *host_attrs[ISCSI_HOST_ATTRS + 1]; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 46 | struct transport_container conn_cont; |
| 47 | struct class_device_attribute *conn_attrs[ISCSI_CONN_ATTRS + 1]; |
| 48 | struct transport_container session_cont; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
Mike Christie | 41be144 | 2007-02-28 17:32:18 -0600 | [diff] [blame] | 52 | static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ |
Mike Christie | d8bf541 | 2007-12-13 12:43:27 -0600 | [diff] [blame] | 53 | static struct workqueue_struct *iscsi_eh_timer_workq; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 54 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 55 | /* |
| 56 | * list of registered transports and lock that must |
| 57 | * be held while accessing list. The iscsi_transport_lock must |
Arjan van de Ven | 0b95067 | 2006-01-11 13:16:10 +0100 | [diff] [blame] | 58 | * be acquired after the rx_queue_mutex. |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 59 | */ |
| 60 | static LIST_HEAD(iscsi_transports); |
| 61 | static DEFINE_SPINLOCK(iscsi_transport_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 63 | #define to_iscsi_internal(tmpl) \ |
| 64 | container_of(tmpl, struct iscsi_internal, t) |
| 65 | |
| 66 | #define cdev_to_iscsi_internal(_cdev) \ |
| 67 | container_of(_cdev, struct iscsi_internal, cdev) |
| 68 | |
| 69 | static void iscsi_transport_release(struct class_device *cdev) |
| 70 | { |
| 71 | struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); |
| 72 | kfree(priv); |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | * iscsi_transport_class represents the iscsi_transports that are |
| 77 | * registered. |
| 78 | */ |
| 79 | static struct class iscsi_transport_class = { |
| 80 | .name = "iscsi_transport", |
| 81 | .release = iscsi_transport_release, |
| 82 | }; |
| 83 | |
| 84 | static ssize_t |
| 85 | show_transport_handle(struct class_device *cdev, char *buf) |
| 86 | { |
| 87 | struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); |
Mike Christie | 762e2bf | 2005-09-12 21:01:46 -0500 | [diff] [blame] | 88 | return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport)); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 89 | } |
| 90 | static CLASS_DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL); |
| 91 | |
| 92 | #define show_transport_attr(name, format) \ |
| 93 | static ssize_t \ |
| 94 | show_transport_##name(struct class_device *cdev, char *buf) \ |
| 95 | { \ |
| 96 | struct iscsi_internal *priv = cdev_to_iscsi_internal(cdev); \ |
| 97 | return sprintf(buf, format"\n", priv->iscsi_transport->name); \ |
| 98 | } \ |
| 99 | static CLASS_DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL); |
| 100 | |
| 101 | show_transport_attr(caps, "0x%x"); |
| 102 | show_transport_attr(max_lun, "%d"); |
| 103 | show_transport_attr(max_conn, "%d"); |
| 104 | show_transport_attr(max_cmd_len, "%d"); |
| 105 | |
| 106 | static struct attribute *iscsi_transport_attrs[] = { |
| 107 | &class_device_attr_handle.attr, |
| 108 | &class_device_attr_caps.attr, |
| 109 | &class_device_attr_max_lun.attr, |
| 110 | &class_device_attr_max_conn.attr, |
| 111 | &class_device_attr_max_cmd_len.attr, |
| 112 | NULL, |
| 113 | }; |
| 114 | |
| 115 | static struct attribute_group iscsi_transport_group = { |
| 116 | .attrs = iscsi_transport_attrs, |
| 117 | }; |
| 118 | |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 119 | |
| 120 | |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 121 | static int iscsi_setup_host(struct transport_container *tc, struct device *dev, |
| 122 | struct class_device *cdev) |
| 123 | { |
| 124 | struct Scsi_Host *shost = dev_to_shost(dev); |
| 125 | struct iscsi_host *ihost = shost->shost_data; |
| 126 | |
| 127 | memset(ihost, 0, sizeof(*ihost)); |
| 128 | INIT_LIST_HEAD(&ihost->sessions); |
| 129 | mutex_init(&ihost->mutex); |
Mike Christie | 8aae18a | 2008-01-31 13:36:48 -0600 | [diff] [blame^] | 130 | atomic_set(&ihost->nr_scans, 0); |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 131 | |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 132 | snprintf(ihost->scan_workq_name, KOBJ_NAME_LEN, "iscsi_scan_%d", |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 133 | shost->host_no); |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 134 | ihost->scan_workq = create_singlethread_workqueue( |
| 135 | ihost->scan_workq_name); |
| 136 | if (!ihost->scan_workq) |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 137 | return -ENOMEM; |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | static int iscsi_remove_host(struct transport_container *tc, struct device *dev, |
| 142 | struct class_device *cdev) |
| 143 | { |
| 144 | struct Scsi_Host *shost = dev_to_shost(dev); |
| 145 | struct iscsi_host *ihost = shost->shost_data; |
| 146 | |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 147 | destroy_workqueue(ihost->scan_workq); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | static DECLARE_TRANSPORT_CLASS(iscsi_host_class, |
| 152 | "iscsi_host", |
| 153 | iscsi_setup_host, |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 154 | iscsi_remove_host, |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 155 | NULL); |
| 156 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 157 | static DECLARE_TRANSPORT_CLASS(iscsi_session_class, |
| 158 | "iscsi_session", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | NULL, |
| 160 | NULL, |
| 161 | NULL); |
| 162 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 163 | static DECLARE_TRANSPORT_CLASS(iscsi_connection_class, |
| 164 | "iscsi_connection", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | NULL, |
| 166 | NULL, |
| 167 | NULL); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 168 | |
| 169 | static struct sock *nls; |
Arjan van de Ven | 0b95067 | 2006-01-11 13:16:10 +0100 | [diff] [blame] | 170 | static DEFINE_MUTEX(rx_queue_mutex); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 171 | |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 172 | static LIST_HEAD(sesslist); |
| 173 | static DEFINE_SPINLOCK(sesslock); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 174 | static LIST_HEAD(connlist); |
| 175 | static DEFINE_SPINLOCK(connlock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 177 | static uint32_t iscsi_conn_get_sid(struct iscsi_cls_conn *conn) |
| 178 | { |
| 179 | struct iscsi_cls_session *sess = iscsi_dev_to_session(conn->dev.parent); |
| 180 | return sess->sid; |
| 181 | } |
| 182 | |
| 183 | /* |
| 184 | * Returns the matching session to a given sid |
| 185 | */ |
| 186 | static struct iscsi_cls_session *iscsi_session_lookup(uint32_t sid) |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 187 | { |
| 188 | unsigned long flags; |
| 189 | struct iscsi_cls_session *sess; |
| 190 | |
| 191 | spin_lock_irqsave(&sesslock, flags); |
| 192 | list_for_each_entry(sess, &sesslist, sess_list) { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 193 | if (sess->sid == sid) { |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 194 | spin_unlock_irqrestore(&sesslock, flags); |
| 195 | return sess; |
| 196 | } |
| 197 | } |
| 198 | spin_unlock_irqrestore(&sesslock, flags); |
| 199 | return NULL; |
| 200 | } |
| 201 | |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 202 | /* |
| 203 | * Returns the matching connection to a given sid / cid tuple |
| 204 | */ |
| 205 | static struct iscsi_cls_conn *iscsi_conn_lookup(uint32_t sid, uint32_t cid) |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 206 | { |
| 207 | unsigned long flags; |
| 208 | struct iscsi_cls_conn *conn; |
| 209 | |
| 210 | spin_lock_irqsave(&connlock, flags); |
| 211 | list_for_each_entry(conn, &connlist, conn_list) { |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 212 | if ((conn->cid == cid) && (iscsi_conn_get_sid(conn) == sid)) { |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 213 | spin_unlock_irqrestore(&connlock, flags); |
| 214 | return conn; |
| 215 | } |
| 216 | } |
| 217 | spin_unlock_irqrestore(&connlock, flags); |
| 218 | return NULL; |
| 219 | } |
| 220 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 221 | /* |
| 222 | * The following functions can be used by LLDs that allocate |
| 223 | * their own scsi_hosts or by software iscsi LLDs |
| 224 | */ |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 225 | static struct { |
| 226 | int value; |
| 227 | char *name; |
| 228 | } iscsi_session_state_names[] = { |
| 229 | { ISCSI_SESSION_LOGGED_IN, "LOGGED_IN" }, |
| 230 | { ISCSI_SESSION_FAILED, "FAILED" }, |
| 231 | { ISCSI_SESSION_FREE, "FREE" }, |
| 232 | }; |
| 233 | |
| 234 | const char *iscsi_session_state_name(int state) |
| 235 | { |
| 236 | int i; |
| 237 | char *name = NULL; |
| 238 | |
| 239 | for (i = 0; i < ARRAY_SIZE(iscsi_session_state_names); i++) { |
| 240 | if (iscsi_session_state_names[i].value == state) { |
| 241 | name = iscsi_session_state_names[i].name; |
| 242 | break; |
| 243 | } |
| 244 | } |
| 245 | return name; |
| 246 | } |
| 247 | |
| 248 | int iscsi_session_chkready(struct iscsi_cls_session *session) |
| 249 | { |
| 250 | unsigned long flags; |
| 251 | int err; |
| 252 | |
| 253 | spin_lock_irqsave(&session->lock, flags); |
| 254 | switch (session->state) { |
| 255 | case ISCSI_SESSION_LOGGED_IN: |
| 256 | err = 0; |
| 257 | break; |
| 258 | case ISCSI_SESSION_FAILED: |
| 259 | err = DID_IMM_RETRY << 16; |
| 260 | break; |
| 261 | case ISCSI_SESSION_FREE: |
| 262 | err = DID_NO_CONNECT << 16; |
| 263 | break; |
| 264 | default: |
| 265 | err = DID_NO_CONNECT << 16; |
| 266 | break; |
| 267 | } |
| 268 | spin_unlock_irqrestore(&session->lock, flags); |
| 269 | return err; |
| 270 | } |
| 271 | EXPORT_SYMBOL_GPL(iscsi_session_chkready); |
| 272 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 273 | static void iscsi_session_release(struct device *dev) |
| 274 | { |
| 275 | struct iscsi_cls_session *session = iscsi_dev_to_session(dev); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 276 | struct Scsi_Host *shost; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 278 | shost = iscsi_session_to_shost(session); |
| 279 | scsi_host_put(shost); |
| 280 | kfree(session); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 281 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 283 | static int iscsi_is_session_dev(const struct device *dev) |
| 284 | { |
| 285 | return dev->release == iscsi_session_release; |
| 286 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
Mike Christie | 8aae18a | 2008-01-31 13:36:48 -0600 | [diff] [blame^] | 288 | /** |
| 289 | * iscsi_scan_finished - helper to report when running scans are done |
| 290 | * @shost: scsi host |
| 291 | * @time: scan run time |
| 292 | * |
| 293 | * This function can be used by drives like qla4xxx to report to the scsi |
| 294 | * layer when the scans it kicked off at module load time are done. |
| 295 | */ |
| 296 | int iscsi_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 297 | { |
| 298 | struct iscsi_host *ihost = shost->shost_data; |
| 299 | /* |
| 300 | * qla4xxx will have kicked off some session unblocks before calling |
| 301 | * scsi_scan_host, so just wait for them to complete. |
| 302 | */ |
| 303 | return !atomic_read(&ihost->nr_scans); |
| 304 | } |
| 305 | EXPORT_SYMBOL_GPL(iscsi_scan_finished); |
| 306 | |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 307 | static int iscsi_user_scan(struct Scsi_Host *shost, uint channel, |
| 308 | uint id, uint lun) |
| 309 | { |
| 310 | struct iscsi_host *ihost = shost->shost_data; |
| 311 | struct iscsi_cls_session *session; |
| 312 | |
| 313 | mutex_lock(&ihost->mutex); |
| 314 | list_for_each_entry(session, &ihost->sessions, host_list) { |
Mike Christie | e6f3b63 | 2006-06-28 12:00:29 -0500 | [diff] [blame] | 315 | if ((channel == SCAN_WILD_CARD || channel == 0) && |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 316 | (id == SCAN_WILD_CARD || id == session->target_id)) |
Mike Christie | e6f3b63 | 2006-06-28 12:00:29 -0500 | [diff] [blame] | 317 | scsi_scan_target(&session->dev, 0, |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 318 | session->target_id, lun, 1); |
| 319 | } |
| 320 | mutex_unlock(&ihost->mutex); |
| 321 | |
| 322 | return 0; |
| 323 | } |
| 324 | |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 325 | static void iscsi_scan_session(struct work_struct *work) |
| 326 | { |
| 327 | struct iscsi_cls_session *session = |
| 328 | container_of(work, struct iscsi_cls_session, scan_work); |
Mike Christie | 8aae18a | 2008-01-31 13:36:48 -0600 | [diff] [blame^] | 329 | struct Scsi_Host *shost = iscsi_session_to_shost(session); |
| 330 | struct iscsi_host *ihost = shost->shost_data; |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 331 | unsigned long flags; |
| 332 | |
| 333 | spin_lock_irqsave(&session->lock, flags); |
| 334 | if (session->state != ISCSI_SESSION_LOGGED_IN) { |
| 335 | spin_unlock_irqrestore(&session->lock, flags); |
Mike Christie | 8aae18a | 2008-01-31 13:36:48 -0600 | [diff] [blame^] | 336 | goto done; |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 337 | } |
| 338 | spin_unlock_irqrestore(&session->lock, flags); |
| 339 | |
| 340 | scsi_scan_target(&session->dev, 0, session->target_id, |
| 341 | SCAN_WILD_CARD, 1); |
Mike Christie | 8aae18a | 2008-01-31 13:36:48 -0600 | [diff] [blame^] | 342 | done: |
| 343 | atomic_dec(&ihost->nr_scans); |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 344 | } |
| 345 | |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 346 | static void session_recovery_timedout(struct work_struct *work) |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 347 | { |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 348 | struct iscsi_cls_session *session = |
| 349 | container_of(work, struct iscsi_cls_session, |
| 350 | recovery_work.work); |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 351 | unsigned long flags; |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 352 | |
Or Gerlitz | be2df72 | 2006-05-02 19:46:43 -0500 | [diff] [blame] | 353 | dev_printk(KERN_INFO, &session->dev, "iscsi: session recovery timed " |
| 354 | "out after %d secs\n", session->recovery_tmo); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 355 | |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 356 | spin_lock_irqsave(&session->lock, flags); |
| 357 | switch (session->state) { |
| 358 | case ISCSI_SESSION_FAILED: |
| 359 | session->state = ISCSI_SESSION_FREE; |
| 360 | break; |
| 361 | case ISCSI_SESSION_LOGGED_IN: |
| 362 | case ISCSI_SESSION_FREE: |
| 363 | /* we raced with the unblock's flush */ |
| 364 | spin_unlock_irqrestore(&session->lock, flags); |
| 365 | return; |
| 366 | } |
| 367 | spin_unlock_irqrestore(&session->lock, flags); |
| 368 | |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 369 | if (session->transport->session_recovery_timedout) |
| 370 | session->transport->session_recovery_timedout(session); |
| 371 | |
| 372 | scsi_target_unblock(&session->dev); |
| 373 | } |
| 374 | |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 375 | void __iscsi_unblock_session(struct iscsi_cls_session *session) |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 376 | { |
| 377 | if (!cancel_delayed_work(&session->recovery_work)) |
Mike Christie | d8bf541 | 2007-12-13 12:43:27 -0600 | [diff] [blame] | 378 | flush_workqueue(iscsi_eh_timer_workq); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 379 | scsi_target_unblock(&session->dev); |
| 380 | } |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 381 | |
| 382 | void iscsi_unblock_session(struct iscsi_cls_session *session) |
| 383 | { |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 384 | struct Scsi_Host *shost = iscsi_session_to_shost(session); |
| 385 | struct iscsi_host *ihost = shost->shost_data; |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 386 | unsigned long flags; |
| 387 | |
| 388 | spin_lock_irqsave(&session->lock, flags); |
| 389 | session->state = ISCSI_SESSION_LOGGED_IN; |
| 390 | spin_unlock_irqrestore(&session->lock, flags); |
| 391 | |
| 392 | __iscsi_unblock_session(session); |
Mike Christie | 8aae18a | 2008-01-31 13:36:48 -0600 | [diff] [blame^] | 393 | /* |
| 394 | * Only do kernel scanning if the driver is properly hooked into |
| 395 | * the async scanning code (drivers like iscsi_tcp do login and |
| 396 | * scanning from userspace). |
| 397 | */ |
| 398 | if (shost->hostt->scan_finished) { |
| 399 | if (queue_work(ihost->scan_workq, &session->scan_work)) |
| 400 | atomic_inc(&ihost->nr_scans); |
| 401 | } |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 402 | } |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 403 | EXPORT_SYMBOL_GPL(iscsi_unblock_session); |
| 404 | |
| 405 | void iscsi_block_session(struct iscsi_cls_session *session) |
| 406 | { |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 407 | unsigned long flags; |
| 408 | |
| 409 | spin_lock_irqsave(&session->lock, flags); |
| 410 | session->state = ISCSI_SESSION_FAILED; |
| 411 | spin_unlock_irqrestore(&session->lock, flags); |
| 412 | |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 413 | scsi_target_block(&session->dev); |
Mike Christie | d8bf541 | 2007-12-13 12:43:27 -0600 | [diff] [blame] | 414 | queue_delayed_work(iscsi_eh_timer_workq, &session->recovery_work, |
| 415 | session->recovery_tmo * HZ); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 416 | } |
| 417 | EXPORT_SYMBOL_GPL(iscsi_block_session); |
| 418 | |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 419 | static void __iscsi_unbind_session(struct work_struct *work) |
| 420 | { |
| 421 | struct iscsi_cls_session *session = |
| 422 | container_of(work, struct iscsi_cls_session, |
| 423 | unbind_work); |
| 424 | struct Scsi_Host *shost = iscsi_session_to_shost(session); |
| 425 | struct iscsi_host *ihost = shost->shost_data; |
| 426 | |
| 427 | /* Prevent new scans and make sure scanning is not in progress */ |
| 428 | mutex_lock(&ihost->mutex); |
| 429 | if (list_empty(&session->host_list)) { |
| 430 | mutex_unlock(&ihost->mutex); |
| 431 | return; |
| 432 | } |
| 433 | list_del_init(&session->host_list); |
| 434 | mutex_unlock(&ihost->mutex); |
| 435 | |
| 436 | scsi_remove_target(&session->dev); |
| 437 | iscsi_session_event(session, ISCSI_KEVENT_UNBIND_SESSION); |
| 438 | } |
| 439 | |
| 440 | static int iscsi_unbind_session(struct iscsi_cls_session *session) |
| 441 | { |
| 442 | struct Scsi_Host *shost = iscsi_session_to_shost(session); |
| 443 | struct iscsi_host *ihost = shost->shost_data; |
| 444 | |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 445 | return queue_work(ihost->scan_workq, &session->unbind_work); |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 446 | } |
| 447 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 448 | struct iscsi_cls_session * |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 449 | iscsi_alloc_session(struct Scsi_Host *shost, |
| 450 | struct iscsi_transport *transport) |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 451 | { |
| 452 | struct iscsi_cls_session *session; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 454 | session = kzalloc(sizeof(*session) + transport->sessiondata_size, |
| 455 | GFP_KERNEL); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 456 | if (!session) |
Mike Christie | f53a88d | 2006-06-28 12:00:27 -0500 | [diff] [blame] | 457 | return NULL; |
| 458 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 459 | session->transport = transport; |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 460 | session->recovery_tmo = 120; |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 461 | session->state = ISCSI_SESSION_FREE; |
David Howells | c402895 | 2006-11-22 14:57:56 +0000 | [diff] [blame] | 462 | INIT_DELAYED_WORK(&session->recovery_work, session_recovery_timedout); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 463 | INIT_LIST_HEAD(&session->host_list); |
| 464 | INIT_LIST_HEAD(&session->sess_list); |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 465 | INIT_WORK(&session->unbind_work, __iscsi_unbind_session); |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 466 | INIT_WORK(&session->scan_work, iscsi_scan_session); |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 467 | spin_lock_init(&session->lock); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 468 | |
Mike Christie | 6a8a0d3 | 2006-06-28 12:00:31 -0500 | [diff] [blame] | 469 | /* this is released in the dev's release function */ |
| 470 | scsi_host_get(shost); |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 471 | session->dev.parent = &shost->shost_gendev; |
| 472 | session->dev.release = iscsi_session_release; |
| 473 | device_initialize(&session->dev); |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 474 | if (transport->sessiondata_size) |
| 475 | session->dd_data = &session[1]; |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 476 | return session; |
| 477 | } |
| 478 | EXPORT_SYMBOL_GPL(iscsi_alloc_session); |
| 479 | |
Mike Christie | 6a8a0d3 | 2006-06-28 12:00:31 -0500 | [diff] [blame] | 480 | int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id) |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 481 | { |
| 482 | struct Scsi_Host *shost = iscsi_session_to_shost(session); |
| 483 | struct iscsi_host *ihost; |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 484 | unsigned long flags; |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 485 | int err; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 486 | |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 487 | ihost = shost->shost_data; |
Mike Christie | 41be144 | 2007-02-28 17:32:18 -0600 | [diff] [blame] | 488 | session->sid = atomic_add_return(1, &iscsi_session_nr); |
Mike Christie | 6a8a0d3 | 2006-06-28 12:00:31 -0500 | [diff] [blame] | 489 | session->target_id = target_id; |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 490 | |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 491 | snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", |
| 492 | session->sid); |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 493 | err = device_add(&session->dev); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 494 | if (err) { |
| 495 | dev_printk(KERN_ERR, &session->dev, "iscsi: could not " |
| 496 | "register session's dev\n"); |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 497 | goto release_host; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 498 | } |
| 499 | transport_register_device(&session->dev); |
| 500 | |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 501 | spin_lock_irqsave(&sesslock, flags); |
| 502 | list_add(&session->sess_list, &sesslist); |
| 503 | spin_unlock_irqrestore(&sesslock, flags); |
| 504 | |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 505 | mutex_lock(&ihost->mutex); |
| 506 | list_add(&session->host_list, &ihost->sessions); |
| 507 | mutex_unlock(&ihost->mutex); |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 508 | |
| 509 | iscsi_session_event(session, ISCSI_KEVENT_CREATE_SESSION); |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 510 | return 0; |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 511 | |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 512 | release_host: |
| 513 | scsi_host_put(shost); |
| 514 | return err; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 515 | } |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 516 | EXPORT_SYMBOL_GPL(iscsi_add_session); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 517 | |
| 518 | /** |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 519 | * iscsi_create_session - create iscsi class session |
| 520 | * @shost: scsi host |
| 521 | * @transport: iscsi transport |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 522 | * @target_id: which target |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 523 | * |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 524 | * This can be called from a LLD or iscsi_transport. |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 525 | */ |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 526 | struct iscsi_cls_session * |
| 527 | iscsi_create_session(struct Scsi_Host *shost, |
Mike Christie | 6a8a0d3 | 2006-06-28 12:00:31 -0500 | [diff] [blame] | 528 | struct iscsi_transport *transport, |
| 529 | unsigned int target_id) |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 530 | { |
| 531 | struct iscsi_cls_session *session; |
| 532 | |
| 533 | session = iscsi_alloc_session(shost, transport); |
| 534 | if (!session) |
| 535 | return NULL; |
| 536 | |
Mike Christie | 6a8a0d3 | 2006-06-28 12:00:31 -0500 | [diff] [blame] | 537 | if (iscsi_add_session(session, target_id)) { |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 538 | iscsi_free_session(session); |
| 539 | return NULL; |
| 540 | } |
| 541 | return session; |
| 542 | } |
| 543 | EXPORT_SYMBOL_GPL(iscsi_create_session); |
| 544 | |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 545 | static void iscsi_conn_release(struct device *dev) |
| 546 | { |
| 547 | struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev); |
| 548 | struct device *parent = conn->dev.parent; |
| 549 | |
| 550 | kfree(conn); |
| 551 | put_device(parent); |
| 552 | } |
| 553 | |
| 554 | static int iscsi_is_conn_dev(const struct device *dev) |
| 555 | { |
| 556 | return dev->release == iscsi_conn_release; |
| 557 | } |
| 558 | |
| 559 | static int iscsi_iter_destroy_conn_fn(struct device *dev, void *data) |
| 560 | { |
| 561 | if (!iscsi_is_conn_dev(dev)) |
| 562 | return 0; |
| 563 | return iscsi_destroy_conn(iscsi_dev_to_conn(dev)); |
| 564 | } |
| 565 | |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 566 | void iscsi_remove_session(struct iscsi_cls_session *session) |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 567 | { |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 568 | struct Scsi_Host *shost = iscsi_session_to_shost(session); |
| 569 | struct iscsi_host *ihost = shost->shost_data; |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 570 | unsigned long flags; |
| 571 | int err; |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 572 | |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 573 | spin_lock_irqsave(&sesslock, flags); |
| 574 | list_del(&session->sess_list); |
| 575 | spin_unlock_irqrestore(&sesslock, flags); |
| 576 | |
| 577 | /* |
| 578 | * If we are blocked let commands flow again. The lld or iscsi |
| 579 | * layer should set up the queuecommand to fail commands. |
| 580 | */ |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 581 | spin_lock_irqsave(&session->lock, flags); |
| 582 | session->state = ISCSI_SESSION_FREE; |
| 583 | spin_unlock_irqrestore(&session->lock, flags); |
| 584 | __iscsi_unblock_session(session); |
Mike Christie | 8aae18a | 2008-01-31 13:36:48 -0600 | [diff] [blame^] | 585 | __iscsi_unbind_session(&session->unbind_work); |
Mike Christie | bd976f6 | 2008-01-31 13:36:46 -0600 | [diff] [blame] | 586 | |
| 587 | /* flush running scans */ |
| 588 | flush_workqueue(ihost->scan_workq); |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 589 | /* |
| 590 | * If the session dropped while removing devices then we need to make |
| 591 | * sure it is not blocked |
| 592 | */ |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 593 | if (!cancel_delayed_work(&session->recovery_work)) |
Mike Christie | d8bf541 | 2007-12-13 12:43:27 -0600 | [diff] [blame] | 594 | flush_workqueue(iscsi_eh_timer_workq); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 595 | |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 596 | /* hw iscsi may not have removed all connections from session */ |
| 597 | err = device_for_each_child(&session->dev, NULL, |
| 598 | iscsi_iter_destroy_conn_fn); |
| 599 | if (err) |
| 600 | dev_printk(KERN_ERR, &session->dev, "iscsi: Could not delete " |
| 601 | "all connections for session. Error %d.\n", err); |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 602 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 603 | transport_unregister_device(&session->dev); |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 604 | device_del(&session->dev); |
| 605 | } |
| 606 | EXPORT_SYMBOL_GPL(iscsi_remove_session); |
| 607 | |
| 608 | void iscsi_free_session(struct iscsi_cls_session *session) |
| 609 | { |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 610 | iscsi_session_event(session, ISCSI_KEVENT_DESTROY_SESSION); |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 611 | put_device(&session->dev); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 612 | } |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 613 | EXPORT_SYMBOL_GPL(iscsi_free_session); |
| 614 | |
| 615 | /** |
| 616 | * iscsi_destroy_session - destroy iscsi session |
| 617 | * @session: iscsi_session |
| 618 | * |
| 619 | * Can be called by a LLD or iscsi_transport. There must not be |
| 620 | * any running connections. |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 621 | */ |
Mike Christie | 8434aa8 | 2006-06-28 12:00:30 -0500 | [diff] [blame] | 622 | int iscsi_destroy_session(struct iscsi_cls_session *session) |
| 623 | { |
| 624 | iscsi_remove_session(session); |
| 625 | iscsi_free_session(session); |
| 626 | return 0; |
| 627 | } |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 628 | EXPORT_SYMBOL_GPL(iscsi_destroy_session); |
| 629 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 630 | /** |
| 631 | * iscsi_create_conn - create iscsi class connection |
| 632 | * @session: iscsi cls session |
| 633 | * @cid: connection id |
| 634 | * |
| 635 | * This can be called from a LLD or iscsi_transport. The connection |
| 636 | * is child of the session so cid must be unique for all connections |
| 637 | * on the session. |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 638 | * |
| 639 | * Since we do not support MCS, cid will normally be zero. In some cases |
| 640 | * for software iscsi we could be trying to preallocate a connection struct |
| 641 | * in which case there could be two connection structs and cid would be |
| 642 | * non-zero. |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 643 | */ |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 644 | struct iscsi_cls_conn * |
| 645 | iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid) |
| 646 | { |
| 647 | struct iscsi_transport *transport = session->transport; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 648 | struct iscsi_cls_conn *conn; |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 649 | unsigned long flags; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 650 | int err; |
| 651 | |
| 652 | conn = kzalloc(sizeof(*conn) + transport->conndata_size, GFP_KERNEL); |
| 653 | if (!conn) |
| 654 | return NULL; |
| 655 | |
| 656 | if (transport->conndata_size) |
| 657 | conn->dd_data = &conn[1]; |
| 658 | |
| 659 | INIT_LIST_HEAD(&conn->conn_list); |
| 660 | conn->transport = transport; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 661 | conn->cid = cid; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 662 | |
| 663 | /* this is released in the dev's release function */ |
| 664 | if (!get_device(&session->dev)) |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 665 | goto free_conn; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 666 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 667 | snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u", |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 668 | session->sid, cid); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 669 | conn->dev.parent = &session->dev; |
| 670 | conn->dev.release = iscsi_conn_release; |
| 671 | err = device_register(&conn->dev); |
| 672 | if (err) { |
| 673 | dev_printk(KERN_ERR, &conn->dev, "iscsi: could not register " |
| 674 | "connection's dev\n"); |
| 675 | goto release_parent_ref; |
| 676 | } |
| 677 | transport_register_device(&conn->dev); |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 678 | |
| 679 | spin_lock_irqsave(&connlock, flags); |
| 680 | list_add(&conn->conn_list, &connlist); |
| 681 | conn->active = 1; |
| 682 | spin_unlock_irqrestore(&connlock, flags); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 683 | return conn; |
| 684 | |
| 685 | release_parent_ref: |
| 686 | put_device(&session->dev); |
| 687 | free_conn: |
| 688 | kfree(conn); |
| 689 | return NULL; |
| 690 | } |
| 691 | |
| 692 | EXPORT_SYMBOL_GPL(iscsi_create_conn); |
| 693 | |
| 694 | /** |
| 695 | * iscsi_destroy_conn - destroy iscsi class connection |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 696 | * @conn: iscsi cls session |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 697 | * |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 698 | * This can be called from a LLD or iscsi_transport. |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 699 | */ |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 700 | int iscsi_destroy_conn(struct iscsi_cls_conn *conn) |
| 701 | { |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 702 | unsigned long flags; |
| 703 | |
| 704 | spin_lock_irqsave(&connlock, flags); |
| 705 | conn->active = 0; |
| 706 | list_del(&conn->conn_list); |
| 707 | spin_unlock_irqrestore(&connlock, flags); |
| 708 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 709 | transport_unregister_device(&conn->dev); |
| 710 | device_unregister(&conn->dev); |
| 711 | return 0; |
| 712 | } |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 713 | EXPORT_SYMBOL_GPL(iscsi_destroy_conn); |
| 714 | |
| 715 | /* |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 716 | * iscsi interface functions |
| 717 | */ |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 718 | static struct iscsi_internal * |
| 719 | iscsi_if_transport_lookup(struct iscsi_transport *tt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | { |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 721 | struct iscsi_internal *priv; |
| 722 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 723 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 724 | spin_lock_irqsave(&iscsi_transport_lock, flags); |
| 725 | list_for_each_entry(priv, &iscsi_transports, list) { |
| 726 | if (tt == priv->iscsi_transport) { |
| 727 | spin_unlock_irqrestore(&iscsi_transport_lock, flags); |
| 728 | return priv; |
| 729 | } |
| 730 | } |
| 731 | spin_unlock_irqrestore(&iscsi_transport_lock, flags); |
| 732 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 733 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 735 | static int |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 736 | iscsi_broadcast_skb(struct sk_buff *skb, gfp_t gfp) |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 737 | { |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 738 | int rc; |
| 739 | |
Mike Christie | 9aaa2b4 | 2006-07-24 15:47:34 -0500 | [diff] [blame] | 740 | rc = netlink_broadcast(nls, skb, 0, 1, gfp); |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 741 | if (rc < 0) { |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 742 | printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc); |
| 743 | return rc; |
| 744 | } |
| 745 | |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 746 | return 0; |
| 747 | } |
| 748 | |
| 749 | static int |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 750 | iscsi_unicast_skb(struct sk_buff *skb, int pid) |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 751 | { |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 752 | int rc; |
| 753 | |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 754 | rc = netlink_unicast(nls, skb, pid, MSG_DONTWAIT); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 755 | if (rc < 0) { |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 756 | printk(KERN_ERR "iscsi: can not unicast skb (%d)\n", rc); |
| 757 | return rc; |
| 758 | } |
| 759 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 760 | return 0; |
| 761 | } |
| 762 | |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 763 | int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr, |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 764 | char *data, uint32_t data_size) |
| 765 | { |
| 766 | struct nlmsghdr *nlh; |
| 767 | struct sk_buff *skb; |
| 768 | struct iscsi_uevent *ev; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 769 | char *pdu; |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 770 | struct iscsi_internal *priv; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 771 | int len = NLMSG_SPACE(sizeof(*ev) + sizeof(struct iscsi_hdr) + |
| 772 | data_size); |
| 773 | |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 774 | priv = iscsi_if_transport_lookup(conn->transport); |
| 775 | if (!priv) |
| 776 | return -EINVAL; |
| 777 | |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 778 | skb = alloc_skb(len, GFP_ATOMIC); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 779 | if (!skb) { |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 780 | iscsi_conn_error(conn, ISCSI_ERR_CONN_FAILED); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 781 | dev_printk(KERN_ERR, &conn->dev, "iscsi: can not deliver " |
| 782 | "control PDU: OOM\n"); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 783 | return -ENOMEM; |
| 784 | } |
| 785 | |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 786 | nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 787 | ev = NLMSG_DATA(nlh); |
| 788 | memset(ev, 0, sizeof(*ev)); |
| 789 | ev->transport_handle = iscsi_handle(conn->transport); |
| 790 | ev->type = ISCSI_KEVENT_RECV_PDU; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 791 | ev->r.recv_req.cid = conn->cid; |
| 792 | ev->r.recv_req.sid = iscsi_conn_get_sid(conn); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 793 | pdu = (char*)ev + sizeof(*ev); |
| 794 | memcpy(pdu, hdr, sizeof(struct iscsi_hdr)); |
| 795 | memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size); |
| 796 | |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 797 | return iscsi_unicast_skb(skb, priv->daemon_pid); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 798 | } |
| 799 | EXPORT_SYMBOL_GPL(iscsi_recv_pdu); |
| 800 | |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 801 | void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error) |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 802 | { |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 803 | struct iscsi_cls_session *session = iscsi_conn_to_session(conn); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 804 | struct nlmsghdr *nlh; |
| 805 | struct sk_buff *skb; |
| 806 | struct iscsi_uevent *ev; |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 807 | struct iscsi_internal *priv; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 808 | int len = NLMSG_SPACE(sizeof(*ev)); |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 809 | unsigned long flags; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 810 | |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 811 | priv = iscsi_if_transport_lookup(conn->transport); |
| 812 | if (!priv) |
| 813 | return; |
| 814 | |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 815 | spin_lock_irqsave(&session->lock, flags); |
| 816 | if (session->state == ISCSI_SESSION_LOGGED_IN) |
| 817 | session->state = ISCSI_SESSION_FAILED; |
| 818 | spin_unlock_irqrestore(&session->lock, flags); |
| 819 | |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 820 | skb = alloc_skb(len, GFP_ATOMIC); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 821 | if (!skb) { |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 822 | dev_printk(KERN_ERR, &conn->dev, "iscsi: gracefully ignored " |
| 823 | "conn error (%d)\n", error); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 824 | return; |
| 825 | } |
| 826 | |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 827 | nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 828 | ev = NLMSG_DATA(nlh); |
| 829 | ev->transport_handle = iscsi_handle(conn->transport); |
| 830 | ev->type = ISCSI_KEVENT_CONN_ERROR; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 831 | ev->r.connerror.error = error; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 832 | ev->r.connerror.cid = conn->cid; |
| 833 | ev->r.connerror.sid = iscsi_conn_get_sid(conn); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 834 | |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 835 | iscsi_broadcast_skb(skb, GFP_ATOMIC); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 836 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 837 | dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n", |
| 838 | error); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 839 | } |
| 840 | EXPORT_SYMBOL_GPL(iscsi_conn_error); |
| 841 | |
| 842 | static int |
| 843 | iscsi_if_send_reply(int pid, int seq, int type, int done, int multi, |
| 844 | void *payload, int size) |
| 845 | { |
| 846 | struct sk_buff *skb; |
| 847 | struct nlmsghdr *nlh; |
| 848 | int len = NLMSG_SPACE(size); |
| 849 | int flags = multi ? NLM_F_MULTI : 0; |
| 850 | int t = done ? NLMSG_DONE : type; |
| 851 | |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 852 | skb = alloc_skb(len, GFP_ATOMIC); |
Mike Christie | 239a7dc | 2007-05-30 12:57:07 -0500 | [diff] [blame] | 853 | if (!skb) { |
| 854 | printk(KERN_ERR "Could not allocate skb to send reply.\n"); |
| 855 | return -ENOMEM; |
| 856 | } |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 857 | |
| 858 | nlh = __nlmsg_put(skb, pid, seq, t, (len - sizeof(*nlh)), 0); |
| 859 | nlh->nlmsg_flags = flags; |
| 860 | memcpy(NLMSG_DATA(nlh), payload, size); |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 861 | return iscsi_unicast_skb(skb, pid); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | static int |
Mike Christie | 5b940ad | 2006-02-01 21:06:56 -0600 | [diff] [blame] | 865 | iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh) |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 866 | { |
| 867 | struct iscsi_uevent *ev = NLMSG_DATA(nlh); |
| 868 | struct iscsi_stats *stats; |
| 869 | struct sk_buff *skbstat; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 870 | struct iscsi_cls_conn *conn; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 871 | struct nlmsghdr *nlhstat; |
| 872 | struct iscsi_uevent *evstat; |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 873 | struct iscsi_internal *priv; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 874 | int len = NLMSG_SPACE(sizeof(*ev) + |
| 875 | sizeof(struct iscsi_stats) + |
| 876 | sizeof(struct iscsi_stats_custom) * |
| 877 | ISCSI_STATS_CUSTOM_MAX); |
| 878 | int err = 0; |
| 879 | |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 880 | priv = iscsi_if_transport_lookup(transport); |
| 881 | if (!priv) |
| 882 | return -EINVAL; |
| 883 | |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 884 | conn = iscsi_conn_lookup(ev->u.get_stats.sid, ev->u.get_stats.cid); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 885 | if (!conn) |
| 886 | return -EEXIST; |
| 887 | |
| 888 | do { |
| 889 | int actual_size; |
| 890 | |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 891 | skbstat = alloc_skb(len, GFP_ATOMIC); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 892 | if (!skbstat) { |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 893 | dev_printk(KERN_ERR, &conn->dev, "iscsi: can not " |
| 894 | "deliver stats: OOM\n"); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 895 | return -ENOMEM; |
| 896 | } |
| 897 | |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 898 | nlhstat = __nlmsg_put(skbstat, priv->daemon_pid, 0, 0, |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 899 | (len - sizeof(*nlhstat)), 0); |
| 900 | evstat = NLMSG_DATA(nlhstat); |
| 901 | memset(evstat, 0, sizeof(*evstat)); |
| 902 | evstat->transport_handle = iscsi_handle(conn->transport); |
| 903 | evstat->type = nlh->nlmsg_type; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 904 | evstat->u.get_stats.cid = |
| 905 | ev->u.get_stats.cid; |
| 906 | evstat->u.get_stats.sid = |
| 907 | ev->u.get_stats.sid; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 908 | stats = (struct iscsi_stats *) |
| 909 | ((char*)evstat + sizeof(*evstat)); |
| 910 | memset(stats, 0, sizeof(*stats)); |
| 911 | |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 912 | transport->get_stats(conn, stats); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 913 | actual_size = NLMSG_SPACE(sizeof(struct iscsi_uevent) + |
| 914 | sizeof(struct iscsi_stats) + |
| 915 | sizeof(struct iscsi_stats_custom) * |
| 916 | stats->custom_length); |
| 917 | actual_size -= sizeof(*nlhstat); |
| 918 | actual_size = NLMSG_LENGTH(actual_size); |
Mike Christie | 5b940ad | 2006-02-01 21:06:56 -0600 | [diff] [blame] | 919 | skb_trim(skbstat, NLMSG_ALIGN(actual_size)); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 920 | nlhstat->nlmsg_len = actual_size; |
| 921 | |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 922 | err = iscsi_unicast_skb(skbstat, priv->daemon_pid); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 923 | } while (err < 0 && err != -ECONNREFUSED); |
| 924 | |
| 925 | return err; |
| 926 | } |
| 927 | |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 928 | /** |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 929 | * iscsi_session_event - send session destr. completion event |
| 930 | * @session: iscsi class session |
| 931 | * @event: type of event |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 932 | */ |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 933 | int iscsi_session_event(struct iscsi_cls_session *session, |
| 934 | enum iscsi_uevent_e event) |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 935 | { |
| 936 | struct iscsi_internal *priv; |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 937 | struct Scsi_Host *shost; |
| 938 | struct iscsi_uevent *ev; |
| 939 | struct sk_buff *skb; |
| 940 | struct nlmsghdr *nlh; |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 941 | int rc, len = NLMSG_SPACE(sizeof(*ev)); |
| 942 | |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 943 | priv = iscsi_if_transport_lookup(session->transport); |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 944 | if (!priv) |
| 945 | return -EINVAL; |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 946 | shost = iscsi_session_to_shost(session); |
| 947 | |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 948 | skb = alloc_skb(len, GFP_KERNEL); |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 949 | if (!skb) { |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 950 | dev_printk(KERN_ERR, &session->dev, "Cannot notify userspace " |
| 951 | "of session event %u\n", event); |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 952 | return -ENOMEM; |
| 953 | } |
| 954 | |
| 955 | nlh = __nlmsg_put(skb, priv->daemon_pid, 0, 0, (len - sizeof(*nlh)), 0); |
| 956 | ev = NLMSG_DATA(nlh); |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 957 | ev->transport_handle = iscsi_handle(session->transport); |
| 958 | |
| 959 | ev->type = event; |
| 960 | switch (event) { |
| 961 | case ISCSI_KEVENT_DESTROY_SESSION: |
| 962 | ev->r.d_session.host_no = shost->host_no; |
| 963 | ev->r.d_session.sid = session->sid; |
| 964 | break; |
| 965 | case ISCSI_KEVENT_CREATE_SESSION: |
| 966 | ev->r.c_session_ret.host_no = shost->host_no; |
| 967 | ev->r.c_session_ret.sid = session->sid; |
| 968 | break; |
| 969 | case ISCSI_KEVENT_UNBIND_SESSION: |
| 970 | ev->r.unbind_session.host_no = shost->host_no; |
| 971 | ev->r.unbind_session.sid = session->sid; |
| 972 | break; |
| 973 | default: |
| 974 | dev_printk(KERN_ERR, &session->dev, "Invalid event %u.\n", |
| 975 | event); |
| 976 | kfree_skb(skb); |
| 977 | return -EINVAL; |
| 978 | } |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 979 | |
| 980 | /* |
| 981 | * this will occur if the daemon is not up, so we just warn |
| 982 | * the user and when the daemon is restarted it will handle it |
| 983 | */ |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 984 | rc = iscsi_broadcast_skb(skb, GFP_KERNEL); |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 985 | if (rc < 0) |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 986 | dev_printk(KERN_ERR, &session->dev, "Cannot notify userspace " |
| 987 | "of session event %u. Check iscsi daemon\n", event); |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 988 | return rc; |
| 989 | } |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 990 | EXPORT_SYMBOL_GPL(iscsi_session_event); |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 991 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 992 | static int |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 993 | iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev) |
| 994 | { |
| 995 | struct iscsi_transport *transport = priv->iscsi_transport; |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 996 | struct iscsi_cls_session *session; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 997 | uint32_t hostno; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 998 | |
Mike Christie | 7996a77 | 2006-04-06 21:13:41 -0500 | [diff] [blame] | 999 | session = transport->create_session(transport, &priv->t, |
Mike Christie | 1548271 | 2007-05-30 12:57:19 -0500 | [diff] [blame] | 1000 | ev->u.c_session.cmds_max, |
| 1001 | ev->u.c_session.queue_depth, |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1002 | ev->u.c_session.initial_cmdsn, |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1003 | &hostno); |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1004 | if (!session) |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1005 | return -ENOMEM; |
| 1006 | |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1007 | ev->r.c_session_ret.host_no = hostno; |
| 1008 | ev->r.c_session_ret.sid = session->sid; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1009 | return 0; |
| 1010 | } |
| 1011 | |
| 1012 | static int |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1013 | iscsi_if_create_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev) |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1014 | { |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1015 | struct iscsi_cls_conn *conn; |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1016 | struct iscsi_cls_session *session; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1017 | |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1018 | session = iscsi_session_lookup(ev->u.c_conn.sid); |
| 1019 | if (!session) { |
| 1020 | printk(KERN_ERR "iscsi: invalid session %d\n", |
| 1021 | ev->u.c_conn.sid); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1022 | return -EINVAL; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1023 | } |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1024 | |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1025 | conn = transport->create_conn(session, ev->u.c_conn.cid); |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1026 | if (!conn) { |
| 1027 | printk(KERN_ERR "iscsi: couldn't create a new " |
| 1028 | "connection for session %d\n", |
| 1029 | session->sid); |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1030 | return -ENOMEM; |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1031 | } |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1032 | |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1033 | ev->r.c_conn_ret.sid = session->sid; |
| 1034 | ev->r.c_conn_ret.cid = conn->cid; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1035 | return 0; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | static int |
| 1039 | iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev) |
| 1040 | { |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1041 | struct iscsi_cls_conn *conn; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1042 | |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1043 | conn = iscsi_conn_lookup(ev->u.d_conn.sid, ev->u.d_conn.cid); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1044 | if (!conn) |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1045 | return -EINVAL; |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1046 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1047 | if (transport->destroy_conn) |
| 1048 | transport->destroy_conn(conn); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1049 | return 0; |
| 1050 | } |
| 1051 | |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1052 | static int |
| 1053 | iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev) |
| 1054 | { |
| 1055 | char *data = (char*)ev + sizeof(*ev); |
| 1056 | struct iscsi_cls_conn *conn; |
| 1057 | struct iscsi_cls_session *session; |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1058 | int err = 0, value = 0; |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1059 | |
| 1060 | session = iscsi_session_lookup(ev->u.set_param.sid); |
| 1061 | conn = iscsi_conn_lookup(ev->u.set_param.sid, ev->u.set_param.cid); |
| 1062 | if (!conn || !session) |
| 1063 | return -EINVAL; |
| 1064 | |
| 1065 | switch (ev->u.set_param.param) { |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1066 | case ISCSI_PARAM_SESS_RECOVERY_TMO: |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1067 | sscanf(data, "%d", &value); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1068 | if (value != 0) |
| 1069 | session->recovery_tmo = value; |
| 1070 | break; |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1071 | default: |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1072 | err = transport->set_param(conn, ev->u.set_param.param, |
| 1073 | data, ev->u.set_param.len); |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1074 | } |
| 1075 | |
| 1076 | return err; |
| 1077 | } |
| 1078 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1079 | static int |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 1080 | iscsi_if_transport_ep(struct iscsi_transport *transport, |
| 1081 | struct iscsi_uevent *ev, int msg_type) |
| 1082 | { |
| 1083 | struct sockaddr *dst_addr; |
| 1084 | int rc = 0; |
| 1085 | |
| 1086 | switch (msg_type) { |
| 1087 | case ISCSI_UEVENT_TRANSPORT_EP_CONNECT: |
| 1088 | if (!transport->ep_connect) |
| 1089 | return -EINVAL; |
| 1090 | |
| 1091 | dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev)); |
| 1092 | rc = transport->ep_connect(dst_addr, |
| 1093 | ev->u.ep_connect.non_blocking, |
| 1094 | &ev->r.ep_connect_ret.handle); |
| 1095 | break; |
| 1096 | case ISCSI_UEVENT_TRANSPORT_EP_POLL: |
| 1097 | if (!transport->ep_poll) |
| 1098 | return -EINVAL; |
| 1099 | |
| 1100 | ev->r.retcode = transport->ep_poll(ev->u.ep_poll.ep_handle, |
| 1101 | ev->u.ep_poll.timeout_ms); |
| 1102 | break; |
| 1103 | case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT: |
| 1104 | if (!transport->ep_disconnect) |
| 1105 | return -EINVAL; |
| 1106 | |
| 1107 | transport->ep_disconnect(ev->u.ep_disconnect.ep_handle); |
| 1108 | break; |
| 1109 | } |
| 1110 | return rc; |
| 1111 | } |
| 1112 | |
| 1113 | static int |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 1114 | iscsi_tgt_dscvr(struct iscsi_transport *transport, |
| 1115 | struct iscsi_uevent *ev) |
| 1116 | { |
Mike Christie | 2174a04 | 2007-05-30 12:57:10 -0500 | [diff] [blame] | 1117 | struct Scsi_Host *shost; |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 1118 | struct sockaddr *dst_addr; |
Mike Christie | 2174a04 | 2007-05-30 12:57:10 -0500 | [diff] [blame] | 1119 | int err; |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 1120 | |
| 1121 | if (!transport->tgt_dscvr) |
| 1122 | return -EINVAL; |
| 1123 | |
Mike Christie | 2174a04 | 2007-05-30 12:57:10 -0500 | [diff] [blame] | 1124 | shost = scsi_host_lookup(ev->u.tgt_dscvr.host_no); |
| 1125 | if (IS_ERR(shost)) { |
| 1126 | printk(KERN_ERR "target discovery could not find host no %u\n", |
| 1127 | ev->u.tgt_dscvr.host_no); |
| 1128 | return -ENODEV; |
| 1129 | } |
| 1130 | |
| 1131 | |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 1132 | dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev)); |
Mike Christie | 2174a04 | 2007-05-30 12:57:10 -0500 | [diff] [blame] | 1133 | err = transport->tgt_dscvr(shost, ev->u.tgt_dscvr.type, |
| 1134 | ev->u.tgt_dscvr.enable, dst_addr); |
| 1135 | scsi_host_put(shost); |
| 1136 | return err; |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | static int |
Mike Christie | 1d9bf13 | 2007-05-30 12:57:11 -0500 | [diff] [blame] | 1140 | iscsi_set_host_param(struct iscsi_transport *transport, |
| 1141 | struct iscsi_uevent *ev) |
| 1142 | { |
| 1143 | char *data = (char*)ev + sizeof(*ev); |
| 1144 | struct Scsi_Host *shost; |
| 1145 | int err; |
| 1146 | |
| 1147 | if (!transport->set_host_param) |
| 1148 | return -ENOSYS; |
| 1149 | |
| 1150 | shost = scsi_host_lookup(ev->u.set_host_param.host_no); |
| 1151 | if (IS_ERR(shost)) { |
| 1152 | printk(KERN_ERR "set_host_param could not find host no %u\n", |
| 1153 | ev->u.set_host_param.host_no); |
| 1154 | return -ENODEV; |
| 1155 | } |
| 1156 | |
| 1157 | err = transport->set_host_param(shost, ev->u.set_host_param.param, |
| 1158 | data, ev->u.set_host_param.len); |
| 1159 | scsi_host_put(shost); |
| 1160 | return err; |
| 1161 | } |
| 1162 | |
| 1163 | static int |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1164 | iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) |
| 1165 | { |
| 1166 | int err = 0; |
| 1167 | struct iscsi_uevent *ev = NLMSG_DATA(nlh); |
| 1168 | struct iscsi_transport *transport = NULL; |
| 1169 | struct iscsi_internal *priv; |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1170 | struct iscsi_cls_session *session; |
| 1171 | struct iscsi_cls_conn *conn; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1172 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1173 | priv = iscsi_if_transport_lookup(iscsi_ptr(ev->transport_handle)); |
| 1174 | if (!priv) |
| 1175 | return -EINVAL; |
| 1176 | transport = priv->iscsi_transport; |
| 1177 | |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1178 | if (!try_module_get(transport->owner)) |
| 1179 | return -EINVAL; |
| 1180 | |
Mike Christie | 790f39a | 2006-05-18 20:31:39 -0500 | [diff] [blame] | 1181 | priv->daemon_pid = NETLINK_CREDS(skb)->pid; |
| 1182 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1183 | switch (nlh->nlmsg_type) { |
| 1184 | case ISCSI_UEVENT_CREATE_SESSION: |
| 1185 | err = iscsi_if_create_session(priv, ev); |
| 1186 | break; |
| 1187 | case ISCSI_UEVENT_DESTROY_SESSION: |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1188 | session = iscsi_session_lookup(ev->u.d_session.sid); |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 1189 | if (session) |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1190 | transport->destroy_session(session); |
Mike Christie | 2697478 | 2007-12-13 12:43:29 -0600 | [diff] [blame] | 1191 | else |
| 1192 | err = -EINVAL; |
| 1193 | break; |
| 1194 | case ISCSI_UEVENT_UNBIND_SESSION: |
| 1195 | session = iscsi_session_lookup(ev->u.d_session.sid); |
| 1196 | if (session) |
| 1197 | iscsi_unbind_session(session); |
| 1198 | else |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1199 | err = -EINVAL; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1200 | break; |
| 1201 | case ISCSI_UEVENT_CREATE_CONN: |
| 1202 | err = iscsi_if_create_conn(transport, ev); |
| 1203 | break; |
| 1204 | case ISCSI_UEVENT_DESTROY_CONN: |
| 1205 | err = iscsi_if_destroy_conn(transport, ev); |
| 1206 | break; |
| 1207 | case ISCSI_UEVENT_BIND_CONN: |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1208 | session = iscsi_session_lookup(ev->u.b_conn.sid); |
| 1209 | conn = iscsi_conn_lookup(ev->u.b_conn.sid, ev->u.b_conn.cid); |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1210 | |
| 1211 | if (session && conn) |
| 1212 | ev->r.retcode = transport->bind_conn(session, conn, |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 1213 | ev->u.b_conn.transport_eph, |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1214 | ev->u.b_conn.is_leading); |
| 1215 | else |
| 1216 | err = -EINVAL; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1217 | break; |
| 1218 | case ISCSI_UEVENT_SET_PARAM: |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1219 | err = iscsi_set_param(transport, ev); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1220 | break; |
| 1221 | case ISCSI_UEVENT_START_CONN: |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1222 | conn = iscsi_conn_lookup(ev->u.start_conn.sid, ev->u.start_conn.cid); |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1223 | if (conn) |
| 1224 | ev->r.retcode = transport->start_conn(conn); |
| 1225 | else |
| 1226 | err = -EINVAL; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1227 | break; |
| 1228 | case ISCSI_UEVENT_STOP_CONN: |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1229 | conn = iscsi_conn_lookup(ev->u.stop_conn.sid, ev->u.stop_conn.cid); |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1230 | if (conn) |
| 1231 | transport->stop_conn(conn, ev->u.stop_conn.flag); |
| 1232 | else |
| 1233 | err = -EINVAL; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1234 | break; |
| 1235 | case ISCSI_UEVENT_SEND_PDU: |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1236 | conn = iscsi_conn_lookup(ev->u.send_pdu.sid, ev->u.send_pdu.cid); |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1237 | if (conn) |
| 1238 | ev->r.retcode = transport->send_pdu(conn, |
| 1239 | (struct iscsi_hdr*)((char*)ev + sizeof(*ev)), |
| 1240 | (char*)ev + sizeof(*ev) + ev->u.send_pdu.hdr_size, |
| 1241 | ev->u.send_pdu.data_size); |
| 1242 | else |
| 1243 | err = -EINVAL; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1244 | break; |
| 1245 | case ISCSI_UEVENT_GET_STATS: |
Mike Christie | 5b940ad | 2006-02-01 21:06:56 -0600 | [diff] [blame] | 1246 | err = iscsi_if_get_stats(transport, nlh); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1247 | break; |
Or Gerlitz | 264faaa | 2006-05-02 19:46:36 -0500 | [diff] [blame] | 1248 | case ISCSI_UEVENT_TRANSPORT_EP_CONNECT: |
| 1249 | case ISCSI_UEVENT_TRANSPORT_EP_POLL: |
| 1250 | case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT: |
| 1251 | err = iscsi_if_transport_ep(transport, ev, nlh->nlmsg_type); |
| 1252 | break; |
Mike Christie | 01cb225 | 2006-06-28 12:00:22 -0500 | [diff] [blame] | 1253 | case ISCSI_UEVENT_TGT_DSCVR: |
| 1254 | err = iscsi_tgt_dscvr(transport, ev); |
| 1255 | break; |
Mike Christie | 1d9bf13 | 2007-05-30 12:57:11 -0500 | [diff] [blame] | 1256 | case ISCSI_UEVENT_SET_HOST_PARAM: |
| 1257 | err = iscsi_set_host_param(transport, ev); |
| 1258 | break; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1259 | default: |
Mike Christie | 1d9bf13 | 2007-05-30 12:57:11 -0500 | [diff] [blame] | 1260 | err = -ENOSYS; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1261 | break; |
| 1262 | } |
| 1263 | |
Mike Christie | 7b7232f | 2006-02-01 21:06:49 -0600 | [diff] [blame] | 1264 | module_put(transport->owner); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1265 | return err; |
| 1266 | } |
| 1267 | |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1268 | /* |
Denis V. Lunev | cd40b7d | 2007-10-10 21:15:29 -0700 | [diff] [blame] | 1269 | * Get message from skb. Each message is processed by iscsi_if_recv_msg. |
| 1270 | * Malformed skbs with wrong lengths or invalid creds are not processed. |
Mike Christie | b5c7a12 | 2006-04-06 21:13:33 -0500 | [diff] [blame] | 1271 | */ |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1272 | static void |
Denis V. Lunev | cd40b7d | 2007-10-10 21:15:29 -0700 | [diff] [blame] | 1273 | iscsi_if_rx(struct sk_buff *skb) |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1274 | { |
Arjan van de Ven | 0b95067 | 2006-01-11 13:16:10 +0100 | [diff] [blame] | 1275 | mutex_lock(&rx_queue_mutex); |
Denis V. Lunev | cd40b7d | 2007-10-10 21:15:29 -0700 | [diff] [blame] | 1276 | while (skb->len >= NLMSG_SPACE(0)) { |
| 1277 | int err; |
| 1278 | uint32_t rlen; |
| 1279 | struct nlmsghdr *nlh; |
| 1280 | struct iscsi_uevent *ev; |
| 1281 | |
| 1282 | nlh = nlmsg_hdr(skb); |
| 1283 | if (nlh->nlmsg_len < sizeof(*nlh) || |
| 1284 | skb->len < nlh->nlmsg_len) { |
| 1285 | break; |
Mike Christie | ee7f8e4 | 2006-02-01 21:07:01 -0600 | [diff] [blame] | 1286 | } |
Mike Christie | ee7f8e4 | 2006-02-01 21:07:01 -0600 | [diff] [blame] | 1287 | |
Denis V. Lunev | cd40b7d | 2007-10-10 21:15:29 -0700 | [diff] [blame] | 1288 | ev = NLMSG_DATA(nlh); |
| 1289 | rlen = NLMSG_ALIGN(nlh->nlmsg_len); |
| 1290 | if (rlen > skb->len) |
| 1291 | rlen = skb->len; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1292 | |
Denis V. Lunev | cd40b7d | 2007-10-10 21:15:29 -0700 | [diff] [blame] | 1293 | err = iscsi_if_recv_msg(skb, nlh); |
| 1294 | if (err) { |
| 1295 | ev->type = ISCSI_KEVENT_IF_ERROR; |
| 1296 | ev->iferror = err; |
| 1297 | } |
| 1298 | do { |
| 1299 | /* |
| 1300 | * special case for GET_STATS: |
| 1301 | * on success - sending reply and stats from |
| 1302 | * inside of if_recv_msg(), |
| 1303 | * on error - fall through. |
| 1304 | */ |
| 1305 | if (ev->type == ISCSI_UEVENT_GET_STATS && !err) |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1306 | break; |
Denis V. Lunev | cd40b7d | 2007-10-10 21:15:29 -0700 | [diff] [blame] | 1307 | err = iscsi_if_send_reply( |
| 1308 | NETLINK_CREDS(skb)->pid, nlh->nlmsg_seq, |
| 1309 | nlh->nlmsg_type, 0, 0, ev, sizeof(*ev)); |
| 1310 | } while (err < 0 && err != -ECONNREFUSED); |
| 1311 | skb_pull(skb, rlen); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1312 | } |
Arjan van de Ven | 0b95067 | 2006-01-11 13:16:10 +0100 | [diff] [blame] | 1313 | mutex_unlock(&rx_queue_mutex); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1314 | } |
| 1315 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1316 | #define iscsi_cdev_to_conn(_cdev) \ |
| 1317 | iscsi_dev_to_conn(_cdev->dev) |
| 1318 | |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1319 | #define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \ |
| 1320 | struct class_device_attribute class_device_attr_##_prefix##_##_name = \ |
| 1321 | __ATTR(_name,_mode,_show,_store) |
| 1322 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1323 | /* |
| 1324 | * iSCSI connection attrs |
| 1325 | */ |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1326 | #define iscsi_conn_attr_show(param) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1327 | static ssize_t \ |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1328 | show_conn_param_##param(struct class_device *cdev, char *buf) \ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1329 | { \ |
| 1330 | struct iscsi_cls_conn *conn = iscsi_cdev_to_conn(cdev); \ |
| 1331 | struct iscsi_transport *t = conn->transport; \ |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1332 | return t->get_conn_param(conn, param, buf); \ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1333 | } |
| 1334 | |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1335 | #define iscsi_conn_attr(field, param) \ |
| 1336 | iscsi_conn_attr_show(param) \ |
| 1337 | static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, show_conn_param_##param, \ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1338 | NULL); |
| 1339 | |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1340 | iscsi_conn_attr(max_recv_dlength, ISCSI_PARAM_MAX_RECV_DLENGTH); |
| 1341 | iscsi_conn_attr(max_xmit_dlength, ISCSI_PARAM_MAX_XMIT_DLENGTH); |
| 1342 | iscsi_conn_attr(header_digest, ISCSI_PARAM_HDRDGST_EN); |
| 1343 | iscsi_conn_attr(data_digest, ISCSI_PARAM_DATADGST_EN); |
| 1344 | iscsi_conn_attr(ifmarker, ISCSI_PARAM_IFMARKER_EN); |
| 1345 | iscsi_conn_attr(ofmarker, ISCSI_PARAM_OFMARKER_EN); |
| 1346 | iscsi_conn_attr(persistent_port, ISCSI_PARAM_PERSISTENT_PORT); |
| 1347 | iscsi_conn_attr(port, ISCSI_PARAM_CONN_PORT); |
| 1348 | iscsi_conn_attr(exp_statsn, ISCSI_PARAM_EXP_STATSN); |
| 1349 | iscsi_conn_attr(persistent_address, ISCSI_PARAM_PERSISTENT_ADDRESS); |
| 1350 | iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS); |
Mike Christie | f6d5180 | 2007-12-13 12:43:30 -0600 | [diff] [blame] | 1351 | iscsi_conn_attr(ping_tmo, ISCSI_PARAM_PING_TMO); |
| 1352 | iscsi_conn_attr(recv_tmo, ISCSI_PARAM_RECV_TMO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1353 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1354 | #define iscsi_cdev_to_session(_cdev) \ |
| 1355 | iscsi_dev_to_session(_cdev->dev) |
| 1356 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1357 | /* |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1358 | * iSCSI session attrs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1359 | */ |
Mike Christie | b2c6416 | 2007-05-30 12:57:16 -0500 | [diff] [blame] | 1360 | #define iscsi_session_attr_show(param, perm) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1361 | static ssize_t \ |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1362 | show_session_param_##param(struct class_device *cdev, char *buf) \ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1363 | { \ |
| 1364 | struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \ |
| 1365 | struct iscsi_transport *t = session->transport; \ |
Mike Christie | b2c6416 | 2007-05-30 12:57:16 -0500 | [diff] [blame] | 1366 | \ |
| 1367 | if (perm && !capable(CAP_SYS_ADMIN)) \ |
| 1368 | return -EACCES; \ |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1369 | return t->get_session_param(session, param, buf); \ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1370 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1371 | |
Mike Christie | b2c6416 | 2007-05-30 12:57:16 -0500 | [diff] [blame] | 1372 | #define iscsi_session_attr(field, param, perm) \ |
| 1373 | iscsi_session_attr_show(param, perm) \ |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1374 | static ISCSI_CLASS_ATTR(sess, field, S_IRUGO, show_session_param_##param, \ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1375 | NULL); |
| 1376 | |
Mike Christie | b2c6416 | 2007-05-30 12:57:16 -0500 | [diff] [blame] | 1377 | iscsi_session_attr(targetname, ISCSI_PARAM_TARGET_NAME, 0); |
| 1378 | iscsi_session_attr(initial_r2t, ISCSI_PARAM_INITIAL_R2T_EN, 0); |
| 1379 | iscsi_session_attr(max_outstanding_r2t, ISCSI_PARAM_MAX_R2T, 0); |
| 1380 | iscsi_session_attr(immediate_data, ISCSI_PARAM_IMM_DATA_EN, 0); |
| 1381 | iscsi_session_attr(first_burst_len, ISCSI_PARAM_FIRST_BURST, 0); |
| 1382 | iscsi_session_attr(max_burst_len, ISCSI_PARAM_MAX_BURST, 0); |
| 1383 | iscsi_session_attr(data_pdu_in_order, ISCSI_PARAM_PDU_INORDER_EN, 0); |
| 1384 | iscsi_session_attr(data_seq_in_order, ISCSI_PARAM_DATASEQ_INORDER_EN, 0); |
| 1385 | iscsi_session_attr(erl, ISCSI_PARAM_ERL, 0); |
| 1386 | iscsi_session_attr(tpgt, ISCSI_PARAM_TPGT, 0); |
| 1387 | iscsi_session_attr(username, ISCSI_PARAM_USERNAME, 1); |
| 1388 | iscsi_session_attr(username_in, ISCSI_PARAM_USERNAME_IN, 1); |
| 1389 | iscsi_session_attr(password, ISCSI_PARAM_PASSWORD, 1); |
| 1390 | iscsi_session_attr(password_in, ISCSI_PARAM_PASSWORD_IN, 1); |
Mike Christie | 4cd49ea | 2007-12-13 12:43:38 -0600 | [diff] [blame] | 1391 | iscsi_session_attr(fast_abort, ISCSI_PARAM_FAST_ABORT, 0); |
| 1392 | iscsi_session_attr(abort_tmo, ISCSI_PARAM_ABORT_TMO, 0); |
| 1393 | iscsi_session_attr(lu_reset_tmo, ISCSI_PARAM_LU_RESET_TMO, 0); |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1394 | |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 1395 | static ssize_t |
| 1396 | show_priv_session_state(struct class_device *cdev, char *buf) |
| 1397 | { |
| 1398 | struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); |
| 1399 | return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); |
| 1400 | } |
| 1401 | static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, |
| 1402 | NULL); |
| 1403 | |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1404 | #define iscsi_priv_session_attr_show(field, format) \ |
| 1405 | static ssize_t \ |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1406 | show_priv_session_##field(struct class_device *cdev, char *buf) \ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1407 | { \ |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1408 | struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev);\ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1409 | return sprintf(buf, format"\n", session->field); \ |
| 1410 | } |
| 1411 | |
| 1412 | #define iscsi_priv_session_attr(field, format) \ |
| 1413 | iscsi_priv_session_attr_show(field, format) \ |
| 1414 | static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO, show_priv_session_##field, \ |
| 1415 | NULL) |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1416 | iscsi_priv_session_attr(recovery_tmo, "%d"); |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1417 | |
Mike Christie | 1819dc8 | 2007-05-30 12:57:08 -0500 | [diff] [blame] | 1418 | /* |
| 1419 | * iSCSI host attrs |
| 1420 | */ |
| 1421 | #define iscsi_host_attr_show(param) \ |
| 1422 | static ssize_t \ |
| 1423 | show_host_param_##param(struct class_device *cdev, char *buf) \ |
| 1424 | { \ |
| 1425 | struct Scsi_Host *shost = transport_class_to_shost(cdev); \ |
| 1426 | struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \ |
| 1427 | return priv->iscsi_transport->get_host_param(shost, param, buf); \ |
| 1428 | } |
| 1429 | |
| 1430 | #define iscsi_host_attr(field, param) \ |
| 1431 | iscsi_host_attr_show(param) \ |
| 1432 | static ISCSI_CLASS_ATTR(host, field, S_IRUGO, show_host_param_##param, \ |
| 1433 | NULL); |
| 1434 | |
Mike Christie | d8196ed | 2007-05-30 12:57:25 -0500 | [diff] [blame] | 1435 | iscsi_host_attr(netdev, ISCSI_HOST_PARAM_NETDEV_NAME); |
Mike Christie | 1819dc8 | 2007-05-30 12:57:08 -0500 | [diff] [blame] | 1436 | iscsi_host_attr(hwaddress, ISCSI_HOST_PARAM_HWADDRESS); |
Mike Christie | d8196ed | 2007-05-30 12:57:25 -0500 | [diff] [blame] | 1437 | iscsi_host_attr(ipaddress, ISCSI_HOST_PARAM_IPADDRESS); |
Mike Christie | 8ad5781 | 2007-05-30 12:57:13 -0500 | [diff] [blame] | 1438 | iscsi_host_attr(initiatorname, ISCSI_HOST_PARAM_INITIATOR_NAME); |
Mike Christie | 1819dc8 | 2007-05-30 12:57:08 -0500 | [diff] [blame] | 1439 | |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1440 | #define SETUP_PRIV_SESSION_RD_ATTR(field) \ |
| 1441 | do { \ |
| 1442 | priv->session_attrs[count] = &class_device_attr_priv_sess_##field; \ |
| 1443 | count++; \ |
| 1444 | } while (0) |
| 1445 | |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1446 | |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1447 | #define SETUP_SESSION_RD_ATTR(field, param_flag) \ |
| 1448 | do { \ |
| 1449 | if (tt->param_mask & param_flag) { \ |
| 1450 | priv->session_attrs[count] = &class_device_attr_sess_##field; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1451 | count++; \ |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1452 | } \ |
| 1453 | } while (0) |
| 1454 | |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1455 | #define SETUP_CONN_RD_ATTR(field, param_flag) \ |
| 1456 | do { \ |
| 1457 | if (tt->param_mask & param_flag) { \ |
| 1458 | priv->conn_attrs[count] = &class_device_attr_conn_##field; \ |
| 1459 | count++; \ |
| 1460 | } \ |
| 1461 | } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1462 | |
Mike Christie | 1819dc8 | 2007-05-30 12:57:08 -0500 | [diff] [blame] | 1463 | #define SETUP_HOST_RD_ATTR(field, param_flag) \ |
| 1464 | do { \ |
| 1465 | if (tt->host_param_mask & param_flag) { \ |
| 1466 | priv->host_attrs[count] = &class_device_attr_host_##field; \ |
| 1467 | count++; \ |
| 1468 | } \ |
| 1469 | } while (0) |
| 1470 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1471 | static int iscsi_session_match(struct attribute_container *cont, |
| 1472 | struct device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | { |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1474 | struct iscsi_cls_session *session; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | struct Scsi_Host *shost; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1476 | struct iscsi_internal *priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1478 | if (!iscsi_is_session_dev(dev)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1479 | return 0; |
| 1480 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1481 | session = iscsi_dev_to_session(dev); |
| 1482 | shost = iscsi_session_to_shost(session); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1483 | if (!shost->transportt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1484 | return 0; |
| 1485 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1486 | priv = to_iscsi_internal(shost->transportt); |
| 1487 | if (priv->session_cont.ac.class != &iscsi_session_class.class) |
| 1488 | return 0; |
| 1489 | |
| 1490 | return &priv->session_cont.ac == cont; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1491 | } |
| 1492 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1493 | static int iscsi_conn_match(struct attribute_container *cont, |
| 1494 | struct device *dev) |
| 1495 | { |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1496 | struct iscsi_cls_session *session; |
| 1497 | struct iscsi_cls_conn *conn; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1498 | struct Scsi_Host *shost; |
| 1499 | struct iscsi_internal *priv; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1500 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1501 | if (!iscsi_is_conn_dev(dev)) |
| 1502 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1503 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1504 | conn = iscsi_dev_to_conn(dev); |
| 1505 | session = iscsi_dev_to_session(conn->dev.parent); |
| 1506 | shost = iscsi_session_to_shost(session); |
| 1507 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1508 | if (!shost->transportt) |
| 1509 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1510 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1511 | priv = to_iscsi_internal(shost->transportt); |
| 1512 | if (priv->conn_cont.ac.class != &iscsi_connection_class.class) |
| 1513 | return 0; |
| 1514 | |
| 1515 | return &priv->conn_cont.ac == cont; |
| 1516 | } |
| 1517 | |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1518 | static int iscsi_host_match(struct attribute_container *cont, |
| 1519 | struct device *dev) |
| 1520 | { |
| 1521 | struct Scsi_Host *shost; |
| 1522 | struct iscsi_internal *priv; |
| 1523 | |
| 1524 | if (!scsi_is_host_device(dev)) |
| 1525 | return 0; |
| 1526 | |
| 1527 | shost = dev_to_shost(dev); |
| 1528 | if (!shost->transportt || |
| 1529 | shost->transportt->host_attrs.ac.class != &iscsi_host_class.class) |
| 1530 | return 0; |
| 1531 | |
| 1532 | priv = to_iscsi_internal(shost->transportt); |
| 1533 | return &priv->t.host_attrs.ac == cont; |
| 1534 | } |
| 1535 | |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1536 | struct scsi_transport_template * |
| 1537 | iscsi_register_transport(struct iscsi_transport *tt) |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1538 | { |
| 1539 | struct iscsi_internal *priv; |
| 1540 | unsigned long flags; |
| 1541 | int count = 0, err; |
| 1542 | |
| 1543 | BUG_ON(!tt); |
| 1544 | |
| 1545 | priv = iscsi_if_transport_lookup(tt); |
| 1546 | if (priv) |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1547 | return NULL; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1548 | |
Jes Sorensen | 24669f75 | 2006-01-16 10:31:18 -0500 | [diff] [blame] | 1549 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1550 | if (!priv) |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1551 | return NULL; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1552 | INIT_LIST_HEAD(&priv->list); |
Mike Christie | 53cb8a1 | 2006-06-28 12:00:32 -0500 | [diff] [blame] | 1553 | priv->daemon_pid = -1; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1554 | priv->iscsi_transport = tt; |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1555 | priv->t.user_scan = iscsi_user_scan; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1556 | |
| 1557 | priv->cdev.class = &iscsi_transport_class; |
| 1558 | snprintf(priv->cdev.class_id, BUS_ID_SIZE, "%s", tt->name); |
| 1559 | err = class_device_register(&priv->cdev); |
| 1560 | if (err) |
| 1561 | goto free_priv; |
| 1562 | |
| 1563 | err = sysfs_create_group(&priv->cdev.kobj, &iscsi_transport_group); |
| 1564 | if (err) |
| 1565 | goto unregister_cdev; |
| 1566 | |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1567 | /* host parameters */ |
| 1568 | priv->t.host_attrs.ac.attrs = &priv->host_attrs[0]; |
| 1569 | priv->t.host_attrs.ac.class = &iscsi_host_class.class; |
| 1570 | priv->t.host_attrs.ac.match = iscsi_host_match; |
| 1571 | priv->t.host_size = sizeof(struct iscsi_host); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1572 | transport_container_register(&priv->t.host_attrs); |
| 1573 | |
Mike Christie | d8196ed | 2007-05-30 12:57:25 -0500 | [diff] [blame] | 1574 | SETUP_HOST_RD_ATTR(netdev, ISCSI_HOST_NETDEV_NAME); |
Mike Christie | 2223696 | 2007-05-30 12:57:24 -0500 | [diff] [blame] | 1575 | SETUP_HOST_RD_ATTR(ipaddress, ISCSI_HOST_IPADDRESS); |
Mike Christie | 1819dc8 | 2007-05-30 12:57:08 -0500 | [diff] [blame] | 1576 | SETUP_HOST_RD_ATTR(hwaddress, ISCSI_HOST_HWADDRESS); |
Mike Christie | 8ad5781 | 2007-05-30 12:57:13 -0500 | [diff] [blame] | 1577 | SETUP_HOST_RD_ATTR(initiatorname, ISCSI_HOST_INITIATOR_NAME); |
Mike Christie | 1819dc8 | 2007-05-30 12:57:08 -0500 | [diff] [blame] | 1578 | BUG_ON(count > ISCSI_HOST_ATTRS); |
| 1579 | priv->host_attrs[count] = NULL; |
| 1580 | count = 0; |
| 1581 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1582 | /* connection parameters */ |
| 1583 | priv->conn_cont.ac.attrs = &priv->conn_attrs[0]; |
| 1584 | priv->conn_cont.ac.class = &iscsi_connection_class.class; |
| 1585 | priv->conn_cont.ac.match = iscsi_conn_match; |
| 1586 | transport_container_register(&priv->conn_cont); |
| 1587 | |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1588 | SETUP_CONN_RD_ATTR(max_recv_dlength, ISCSI_MAX_RECV_DLENGTH); |
| 1589 | SETUP_CONN_RD_ATTR(max_xmit_dlength, ISCSI_MAX_XMIT_DLENGTH); |
| 1590 | SETUP_CONN_RD_ATTR(header_digest, ISCSI_HDRDGST_EN); |
| 1591 | SETUP_CONN_RD_ATTR(data_digest, ISCSI_DATADGST_EN); |
| 1592 | SETUP_CONN_RD_ATTR(ifmarker, ISCSI_IFMARKER_EN); |
| 1593 | SETUP_CONN_RD_ATTR(ofmarker, ISCSI_OFMARKER_EN); |
| 1594 | SETUP_CONN_RD_ATTR(address, ISCSI_CONN_ADDRESS); |
| 1595 | SETUP_CONN_RD_ATTR(port, ISCSI_CONN_PORT); |
Mike Christie | 8d2860b | 2006-05-02 19:46:47 -0500 | [diff] [blame] | 1596 | SETUP_CONN_RD_ATTR(exp_statsn, ISCSI_EXP_STATSN); |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1597 | SETUP_CONN_RD_ATTR(persistent_address, ISCSI_PERSISTENT_ADDRESS); |
| 1598 | SETUP_CONN_RD_ATTR(persistent_port, ISCSI_PERSISTENT_PORT); |
Mike Christie | f6d5180 | 2007-12-13 12:43:30 -0600 | [diff] [blame] | 1599 | SETUP_CONN_RD_ATTR(ping_tmo, ISCSI_PING_TMO); |
| 1600 | SETUP_CONN_RD_ATTR(recv_tmo, ISCSI_RECV_TMO); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1601 | |
| 1602 | BUG_ON(count > ISCSI_CONN_ATTRS); |
| 1603 | priv->conn_attrs[count] = NULL; |
| 1604 | count = 0; |
| 1605 | |
| 1606 | /* session parameters */ |
| 1607 | priv->session_cont.ac.attrs = &priv->session_attrs[0]; |
| 1608 | priv->session_cont.ac.class = &iscsi_session_class.class; |
| 1609 | priv->session_cont.ac.match = iscsi_session_match; |
| 1610 | transport_container_register(&priv->session_cont); |
| 1611 | |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1612 | SETUP_SESSION_RD_ATTR(initial_r2t, ISCSI_INITIAL_R2T_EN); |
| 1613 | SETUP_SESSION_RD_ATTR(max_outstanding_r2t, ISCSI_MAX_R2T); |
| 1614 | SETUP_SESSION_RD_ATTR(immediate_data, ISCSI_IMM_DATA_EN); |
| 1615 | SETUP_SESSION_RD_ATTR(first_burst_len, ISCSI_FIRST_BURST); |
| 1616 | SETUP_SESSION_RD_ATTR(max_burst_len, ISCSI_MAX_BURST); |
| 1617 | SETUP_SESSION_RD_ATTR(data_pdu_in_order, ISCSI_PDU_INORDER_EN); |
| 1618 | SETUP_SESSION_RD_ATTR(data_seq_in_order, ISCSI_DATASEQ_INORDER_EN); |
| 1619 | SETUP_SESSION_RD_ATTR(erl, ISCSI_ERL); |
Mike Christie | a54a52c | 2006-06-28 12:00:23 -0500 | [diff] [blame] | 1620 | SETUP_SESSION_RD_ATTR(targetname, ISCSI_TARGET_NAME); |
| 1621 | SETUP_SESSION_RD_ATTR(tpgt, ISCSI_TPGT); |
Mike Christie | b2c6416 | 2007-05-30 12:57:16 -0500 | [diff] [blame] | 1622 | SETUP_SESSION_RD_ATTR(password, ISCSI_USERNAME); |
| 1623 | SETUP_SESSION_RD_ATTR(password_in, ISCSI_USERNAME_IN); |
| 1624 | SETUP_SESSION_RD_ATTR(username, ISCSI_PASSWORD); |
| 1625 | SETUP_SESSION_RD_ATTR(username_in, ISCSI_PASSWORD_IN); |
Mike Christie | 843c0a8 | 2007-12-13 12:43:20 -0600 | [diff] [blame] | 1626 | SETUP_SESSION_RD_ATTR(fast_abort, ISCSI_FAST_ABORT); |
Mike Christie | 4cd49ea | 2007-12-13 12:43:38 -0600 | [diff] [blame] | 1627 | SETUP_SESSION_RD_ATTR(abort_tmo, ISCSI_ABORT_TMO); |
| 1628 | SETUP_SESSION_RD_ATTR(lu_reset_tmo,ISCSI_LU_RESET_TMO); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1629 | SETUP_PRIV_SESSION_RD_ATTR(recovery_tmo); |
Mike Christie | 6eabafb | 2008-01-31 13:36:43 -0600 | [diff] [blame] | 1630 | SETUP_PRIV_SESSION_RD_ATTR(state); |
Mike Christie | fd7255f | 2006-04-06 21:13:36 -0500 | [diff] [blame] | 1631 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | BUG_ON(count > ISCSI_SESSION_ATTRS); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1633 | priv->session_attrs[count] = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1634 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1635 | spin_lock_irqsave(&iscsi_transport_lock, flags); |
| 1636 | list_add(&priv->list, &iscsi_transports); |
| 1637 | spin_unlock_irqrestore(&iscsi_transport_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1638 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1639 | printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1640 | return &priv->t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1642 | unregister_cdev: |
| 1643 | class_device_unregister(&priv->cdev); |
| 1644 | free_priv: |
| 1645 | kfree(priv); |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1646 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1647 | } |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1648 | EXPORT_SYMBOL_GPL(iscsi_register_transport); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1649 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1650 | int iscsi_unregister_transport(struct iscsi_transport *tt) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1651 | { |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1652 | struct iscsi_internal *priv; |
| 1653 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1654 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1655 | BUG_ON(!tt); |
| 1656 | |
Arjan van de Ven | 0b95067 | 2006-01-11 13:16:10 +0100 | [diff] [blame] | 1657 | mutex_lock(&rx_queue_mutex); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1658 | |
| 1659 | priv = iscsi_if_transport_lookup(tt); |
| 1660 | BUG_ON (!priv); |
| 1661 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1662 | spin_lock_irqsave(&iscsi_transport_lock, flags); |
| 1663 | list_del(&priv->list); |
| 1664 | spin_unlock_irqrestore(&iscsi_transport_lock, flags); |
| 1665 | |
| 1666 | transport_container_unregister(&priv->conn_cont); |
| 1667 | transport_container_unregister(&priv->session_cont); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1668 | transport_container_unregister(&priv->t.host_attrs); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1669 | |
| 1670 | sysfs_remove_group(&priv->cdev.kobj, &iscsi_transport_group); |
| 1671 | class_device_unregister(&priv->cdev); |
Arjan van de Ven | 0b95067 | 2006-01-11 13:16:10 +0100 | [diff] [blame] | 1672 | mutex_unlock(&rx_queue_mutex); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1673 | |
| 1674 | return 0; |
| 1675 | } |
| 1676 | EXPORT_SYMBOL_GPL(iscsi_unregister_transport); |
| 1677 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1678 | static __init int iscsi_transport_init(void) |
| 1679 | { |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1680 | int err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1681 | |
Meelis Roos | 0949260 | 2006-12-17 12:10:26 -0600 | [diff] [blame] | 1682 | printk(KERN_INFO "Loading iSCSI transport class v%s.\n", |
Mike Christie | f4246b3 | 2006-07-24 15:47:54 -0500 | [diff] [blame] | 1683 | ISCSI_TRANSPORT_VERSION); |
| 1684 | |
Mike Christie | 41be144 | 2007-02-28 17:32:18 -0600 | [diff] [blame] | 1685 | atomic_set(&iscsi_session_nr, 0); |
| 1686 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1687 | err = class_register(&iscsi_transport_class); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1688 | if (err) |
| 1689 | return err; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1690 | |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1691 | err = transport_class_register(&iscsi_host_class); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1692 | if (err) |
| 1693 | goto unregister_transport_class; |
| 1694 | |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1695 | err = transport_class_register(&iscsi_connection_class); |
| 1696 | if (err) |
| 1697 | goto unregister_host_class; |
| 1698 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1699 | err = transport_class_register(&iscsi_session_class); |
| 1700 | if (err) |
| 1701 | goto unregister_conn_class; |
| 1702 | |
Eric W. Biederman | b4b5102 | 2007-09-12 13:05:38 +0200 | [diff] [blame] | 1703 | nls = netlink_kernel_create(&init_net, NETLINK_ISCSI, 1, iscsi_if_rx, NULL, |
Mike Christie | 7b8631b | 2006-01-13 18:05:50 -0600 | [diff] [blame] | 1704 | THIS_MODULE); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1705 | if (!nls) { |
| 1706 | err = -ENOBUFS; |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 1707 | goto unregister_session_class; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1708 | } |
| 1709 | |
Mike Christie | d8bf541 | 2007-12-13 12:43:27 -0600 | [diff] [blame] | 1710 | iscsi_eh_timer_workq = create_singlethread_workqueue("iscsi_eh"); |
| 1711 | if (!iscsi_eh_timer_workq) |
| 1712 | goto release_nls; |
| 1713 | |
Mike Christie | 43a145a | 2006-10-16 18:09:38 -0400 | [diff] [blame] | 1714 | return 0; |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1715 | |
Mike Christie | d8bf541 | 2007-12-13 12:43:27 -0600 | [diff] [blame] | 1716 | release_nls: |
Denis V. Lunev | b7c6ba6 | 2008-01-28 14:41:19 -0800 | [diff] [blame] | 1717 | netlink_kernel_release(nls); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1718 | unregister_session_class: |
| 1719 | transport_class_unregister(&iscsi_session_class); |
| 1720 | unregister_conn_class: |
| 1721 | transport_class_unregister(&iscsi_connection_class); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1722 | unregister_host_class: |
| 1723 | transport_class_unregister(&iscsi_host_class); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1724 | unregister_transport_class: |
| 1725 | class_unregister(&iscsi_transport_class); |
| 1726 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1727 | } |
| 1728 | |
| 1729 | static void __exit iscsi_transport_exit(void) |
| 1730 | { |
Mike Christie | d8bf541 | 2007-12-13 12:43:27 -0600 | [diff] [blame] | 1731 | destroy_workqueue(iscsi_eh_timer_workq); |
Denis V. Lunev | b7c6ba6 | 2008-01-28 14:41:19 -0800 | [diff] [blame] | 1732 | netlink_kernel_release(nls); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1733 | transport_class_unregister(&iscsi_connection_class); |
| 1734 | transport_class_unregister(&iscsi_session_class); |
Mike Christie | 30a6c65 | 2006-04-06 21:13:39 -0500 | [diff] [blame] | 1735 | transport_class_unregister(&iscsi_host_class); |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1736 | class_unregister(&iscsi_transport_class); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1737 | } |
| 1738 | |
| 1739 | module_init(iscsi_transport_init); |
| 1740 | module_exit(iscsi_transport_exit); |
| 1741 | |
Alex Aizman | 0896b75 | 2005-08-04 19:33:07 -0700 | [diff] [blame] | 1742 | MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu>, " |
| 1743 | "Dmitry Yusupov <dmitry_yus@yahoo.com>, " |
| 1744 | "Alex Aizman <itn780@yahoo.com>"); |
| 1745 | MODULE_DESCRIPTION("iSCSI Transport Interface"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1746 | MODULE_LICENSE("GPL"); |
Mike Christie | f4246b3 | 2006-07-24 15:47:54 -0500 | [diff] [blame] | 1747 | MODULE_VERSION(ISCSI_TRANSPORT_VERSION); |