23 #include <linux/module.h>
25 #include <linux/slab.h>
29 #include <scsi/scsi.h>
38 #define ISCSI_TRANSPORT_VERSION "2.0-870"
40 static int dbg_session;
44 "Turn on debugging for sessions in scsi_transport_iscsi "
45 "module. Set to 1 to turn on, and zero to turn off. Default "
52 "Turn on debugging for connections in scsi_transport_iscsi "
53 "module. Set to 1 to turn on, and zero to turn off. Default "
56 #define ISCSI_DBG_TRANS_SESSION(_session, dbg_fmt, arg...) \
59 iscsi_cls_session_printk(KERN_INFO, _session, \
64 #define ISCSI_DBG_TRANS_CONN(_conn, dbg_fmt, arg...) \
67 iscsi_cls_conn_printk(KERN_INFO, _conn, \
94 #define to_iscsi_internal(tmpl) \
95 container_of(tmpl, struct iscsi_internal, t)
97 #define dev_to_iscsi_internal(_dev) \
98 container_of(_dev, struct iscsi_internal, dev)
100 static void iscsi_transport_release(
struct device *
dev)
110 static struct class iscsi_transport_class = {
111 .name =
"iscsi_transport",
112 .dev_release = iscsi_transport_release,
124 #define show_transport_attr(name, format) \
126 show_transport_##name(struct device *dev, \
127 struct device_attribute *attr,char *buf) \
129 struct iscsi_internal *priv = dev_to_iscsi_internal(dev); \
130 return sprintf(buf, format"\n", priv->iscsi_transport->name); \
132 static DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL);
136 static struct attribute *iscsi_transport_attrs[] = {
137 &dev_attr_handle.attr,
143 .attrs = iscsi_transport_attrs,
149 #define iscsi_dev_to_endpoint(_dev) \
150 container_of(_dev, struct iscsi_endpoint, dev)
152 #define ISCSI_ATTR(_prefix,_name,_mode,_show,_store) \
153 struct device_attribute dev_attr_##_prefix##_##_name = \
154 __ATTR(_name,_mode,_show,_store)
156 static void iscsi_endpoint_release(
struct device *dev)
162 static struct class iscsi_endpoint_class = {
163 .name =
"iscsi_endpoint",
164 .dev_release = iscsi_endpoint_release,
171 return sprintf(buf,
"%llu\n", (
unsigned long long) ep->
id);
175 static struct attribute *iscsi_endpoint_attrs[] = {
176 &dev_attr_ep_handle.attr,
181 .attrs = iscsi_endpoint_attrs,
184 #define ISCSI_MAX_EPID -1
186 static int iscsi_match_epid(
struct device *dev,
void *
data)
191 return *epid == ep->
id;
208 if (
id == ISCSI_MAX_EPID) {
214 ep = kzalloc(
sizeof(*ep) + dd_size,
GFP_KERNEL);
219 ep->
dev.class = &iscsi_endpoint_class;
274 static void iscsi_iface_release(
struct device *dev)
284 static struct class iscsi_iface_class = {
285 .name =
"iscsi_iface",
286 .dev_release = iscsi_iface_release,
289 #define ISCSI_IFACE_ATTR(_prefix, _name, _mode, _show, _store) \
290 struct device_attribute dev_attr_##_prefix##_##_name = \
291 __ATTR(_name, _mode, _show, _store)
294 #define iscsi_iface_attr_show(type, name, param_type, param) \
296 show_##type##_##name(struct device *dev, struct device_attribute *attr, \
299 struct iscsi_iface *iface = iscsi_dev_to_iface(dev); \
300 struct iscsi_transport *t = iface->transport; \
301 return t->get_iface_param(iface, param_type, param, buf); \
304 #define iscsi_iface_net_attr(type, name, param) \
305 iscsi_iface_attr_show(type, name, ISCSI_NET_PARAM, param) \
306 static ISCSI_IFACE_ATTR(type, name, S_IRUGO, show_##type##_##name, NULL);
339 if (attr == &dev_attr_iface_enabled.attr)
341 else if (attr == &dev_attr_iface_vlan_id.attr)
343 else if (attr == &dev_attr_iface_vlan_priority.attr)
345 else if (attr == &dev_attr_iface_vlan_enabled.attr)
347 else if (attr == &dev_attr_iface_mtu.attr)
349 else if (attr == &dev_attr_iface_port.attr)
352 if (attr == &dev_attr_ipv4_iface_ipaddress.attr)
354 else if (attr == &dev_attr_ipv4_iface_gateway.attr)
356 else if (attr == &dev_attr_ipv4_iface_subnet.attr)
358 else if (attr == &dev_attr_ipv4_iface_bootproto.attr)
363 if (attr == &dev_attr_ipv6_iface_ipaddress.attr)
365 else if (attr == &dev_attr_ipv6_iface_link_local_addr.attr)
367 else if (attr == &dev_attr_ipv6_iface_router_addr.attr)
369 else if (attr == &dev_attr_ipv6_iface_ipaddr_autocfg.attr)
371 else if (attr == &dev_attr_ipv6_iface_link_local_autocfg.attr)
383 static struct attribute *iscsi_iface_attrs[] = {
384 &dev_attr_iface_enabled.attr,
385 &dev_attr_iface_vlan_id.attr,
386 &dev_attr_iface_vlan_priority.attr,
387 &dev_attr_iface_vlan_enabled.attr,
388 &dev_attr_ipv4_iface_ipaddress.attr,
389 &dev_attr_ipv4_iface_gateway.attr,
390 &dev_attr_ipv4_iface_subnet.attr,
391 &dev_attr_ipv4_iface_bootproto.attr,
392 &dev_attr_ipv6_iface_ipaddress.attr,
393 &dev_attr_ipv6_iface_link_local_addr.attr,
394 &dev_attr_ipv6_iface_router_addr.attr,
395 &dev_attr_ipv6_iface_ipaddr_autocfg.attr,
396 &dev_attr_ipv6_iface_link_local_autocfg.attr,
397 &dev_attr_iface_mtu.attr,
398 &dev_attr_iface_port.attr,
403 .attrs = iscsi_iface_attrs,
404 .is_visible = iscsi_iface_attr_is_visible,
414 iface = kzalloc(
sizeof(*iface) + dd_size,
GFP_KERNEL);
421 iface->
dev.release = iscsi_iface_release;
422 iface->
dev.class = &iscsi_iface_class;
469 static int iscsi_bsg_host_dispatch(
struct bsg_job *job)
488 if ((shost->
hostt->vendor_id == 0L) ||
490 shost->
hostt->vendor_id)) {
528 struct device *dev = &shost->shost_gendev;
546 "initialize - no request queue\n");
558 struct Scsi_Host *shost = dev_to_shost(dev);
561 memset(ihost, 0,
sizeof(*ihost));
565 iscsi_bsg_host_add(shost, ihost);
574 struct Scsi_Host *shost = dev_to_shost(dev);
602 static struct sock *nls;
626 if (sess->
sid == sid) {
627 spin_unlock_irqrestore(&sesslock, flags);
631 spin_unlock_irqrestore(&sesslock, flags);
645 if ((conn->
cid == cid) && (iscsi_conn_get_sid(conn) == sid)) {
646 spin_unlock_irqrestore(&connlock, flags);
650 spin_unlock_irqrestore(&connlock, flags);
661 } iscsi_session_state_names[] = {
667 static const char *iscsi_session_state_name(
int state)
672 for (i = 0; i <
ARRAY_SIZE(iscsi_session_state_names); i++) {
673 if (iscsi_session_state_names[i].
value == state) {
674 name = iscsi_session_state_names[
i].name;
687 switch (session->
state) {
701 spin_unlock_irqrestore(&session->
lock, flags);
714 spin_unlock_irqrestore(&session->
lock, flags);
719 static void iscsi_session_release(
struct device *dev)
732 return dev->
release == iscsi_session_release;
736 static int iscsi_iter_session_fn(
struct device *dev,
void *
data)
750 iscsi_iter_session_fn);
779 static int iscsi_user_scan_session(
struct device *dev,
void *data)
801 spin_unlock_irqrestore(&session->
lock, flags);
805 spin_unlock_irqrestore(&session->
lock, flags);
811 scan_data->
id ==
id))
832 iscsi_user_scan_session);
847 iscsi_user_scan_session(&session->
dev, &scan_data);
873 spin_unlock_irqrestore(&session->
lock, flags);
877 spin_unlock_irqrestore(&session->
lock, flags);
890 "session recovery timed out after %d secs\n",
894 switch (session->
state) {
901 spin_unlock_irqrestore(&session->
lock, flags);
904 spin_unlock_irqrestore(&session->
lock, flags);
906 if (session->
transport->session_recovery_timedout)
907 session->
transport->session_recovery_timedout(session);
914 static void __iscsi_unblock_session(
struct work_struct *work)
931 spin_unlock_irqrestore(&session->
lock, flags);
939 if (shost->
hostt->scan_finished) {
963 static void __iscsi_block_session(
struct work_struct *work)
973 spin_unlock_irqrestore(&session->
lock, flags);
988 static void __iscsi_unbind_session(
struct work_struct *work)
1004 spin_unlock_irqrestore(&session->
lock, flags);
1011 spin_unlock_irqrestore(&session->
lock, flags);
1028 session = kzalloc(
sizeof(*session) + dd_size,
1047 session->
dev.parent = &shost->shost_gendev;
1048 session->
dev.release = iscsi_session_release;
1051 session->
dd_data = &session[1];
1062 unsigned long flags;
1074 "Failure in Target ID Allocation\n");
1086 "could not register session's dev\n");
1089 transport_register_device(&session->
dev);
1092 list_add(&session->
sess_list, &sesslist);
1093 spin_unlock_irqrestore(&sesslock, flags);
1118 int dd_size,
unsigned int target_id)
1134 static void iscsi_conn_release(
struct device *dev)
1144 static int iscsi_is_conn_dev(
const struct device *dev)
1146 return dev->
release == iscsi_conn_release;
1149 static int iscsi_iter_destroy_conn_fn(
struct device *dev,
void *data)
1151 if (!iscsi_is_conn_dev(dev))
1159 unsigned long flags;
1166 spin_unlock_irqrestore(&sesslock, flags);
1181 spin_unlock_irqrestore(&session->
lock, flags);
1190 iscsi_iter_destroy_conn_fn);
1193 "Could not delete all connections "
1194 "for session. Error %d.\n", err);
1196 transport_unregister_device(&session->
dev);
1247 unsigned long flags;
1250 conn = kzalloc(
sizeof(*conn) + dd_size,
GFP_KERNEL);
1266 conn->
dev.parent = &session->
dev;
1267 conn->
dev.release = iscsi_conn_release;
1271 "register connection's dev\n");
1272 goto release_parent_ref;
1274 transport_register_device(&conn->
dev);
1278 spin_unlock_irqrestore(&connlock, flags);
1300 unsigned long flags;
1304 spin_unlock_irqrestore(&connlock, flags);
1306 transport_unregister_device(&conn->
dev);
1320 unsigned long flags;
1325 spin_unlock_irqrestore(&iscsi_transport_lock, flags);
1329 spin_unlock_irqrestore(&iscsi_transport_lock, flags);
1336 return nlmsg_multicast(nls, skb, 0, group, gfp);
1350 priv = iscsi_if_transport_lookup(conn->
transport);
1358 "control PDU: OOM\n");
1362 nlh =
__nlmsg_put(skb, 0, 0, 0, (len -
sizeof(*nlh)), 0);
1364 memset(ev, 0,
sizeof(*ev));
1368 ev->
r.
recv_req.sid = iscsi_conn_get_sid(conn);
1369 pdu = (
char*)ev +
sizeof(*ev);
1392 nlh =
__nlmsg_put(skb, 0, 0, 0, (len -
sizeof(*nlh)), 0);
1394 memset(ev, 0,
sizeof(*ev));
1406 memcpy((
char *)ev +
sizeof(*ev), data, data_size);
1420 priv = iscsi_if_transport_lookup(conn->
transport);
1427 "conn error (%d)\n", error);
1431 nlh =
__nlmsg_put(skb, 0, 0, 0, (len -
sizeof(*nlh)), 0);
1437 ev->
r.
connerror.sid = iscsi_conn_get_sid(conn);
1455 priv = iscsi_if_transport_lookup(conn->
transport);
1462 "conn login (%d)\n", state);
1466 nlh =
__nlmsg_put(skb, 0, 0, 0, (len -
sizeof(*nlh)), 0);
1496 nlh =
__nlmsg_put(skb, 0, 0, 0, (len -
sizeof(*nlh)), 0);
1505 memcpy((
char *)ev +
sizeof(*ev), data, data_size);
1526 nlh =
__nlmsg_put(skb, 0, 0, 0, (len -
sizeof(*nlh)), 0);
1534 memcpy((
char *)ev +
sizeof(*ev), data, data_size);
1556 nlh =
__nlmsg_put(skb, 0, 0, t, (len -
sizeof(*nlh)), 0);
1559 return iscsi_multicast_skb(skb, group,
GFP_ATOMIC);
1578 priv = iscsi_if_transport_lookup(transport);
1592 "deliver stats: OOM\n");
1597 (len -
sizeof(*nlhstat)), 0);
1599 memset(evstat, 0,
sizeof(*evstat));
1607 ((
char*)evstat +
sizeof(*evstat));
1608 memset(stats, 0,
sizeof(*stats));
1615 actual_size -=
sizeof(*nlhstat);
1642 priv = iscsi_if_transport_lookup(session->
transport);
1650 "Cannot notify userspace of session "
1651 "event %u\n", event);
1655 nlh =
__nlmsg_put(skb, 0, 0, 0, (len -
sizeof(*nlh)), 0);
1687 "Cannot notify userspace of session "
1688 "event %u. Check iscsi daemon\n",
1717 "Completed creating transport session\n");
1727 session = iscsi_session_lookup(ev->
u.
c_conn.sid);
1737 "couldn't create a new connection.");
1767 char *data = (
char*)ev +
sizeof(*ev);
1770 int err = 0,
value = 0;
1772 session = iscsi_session_lookup(ev->
u.
set_param.sid);
1774 if (!conn || !session)
1813 dst_addr = (
struct sockaddr *)((
char*)ev +
sizeof(*ev));
1814 ep = transport->
ep_connect(shost, dst_addr, non_blocking);
1860 rc = iscsi_if_ep_connect(transport, ev, msg_type);
1874 rc = iscsi_if_ep_disconnect(transport,
1900 dst_addr = (
struct sockaddr *)((
char*)ev +
sizeof(*ev));
1911 char *data = (
char*)ev +
sizeof(*ev);
1948 params = (
struct iscsi_path *)((
char *)ev +
sizeof(*ev));
1949 err = transport->
set_path(shost, params);
1959 char *data = (
char *)ev +
sizeof(*ev);
1995 dst_addr = (
struct sockaddr *)((
char *)ev +
sizeof(*ev));
2022 priv = iscsi_if_transport_lookup(transport);
2026 chap_buf_size = (ev->
u.
get_chap.num_entries *
sizeof(*chap_rec));
2047 (len -
sizeof(*nlhchap)), 0);
2049 memset(evchap, 0,
sizeof(*evchap));
2055 buf = (
char *) ((
char *)evchap +
sizeof(*evchap));
2056 memset(buf, 0, chap_buf_size);
2061 actual_size =
NLMSG_SPACE(
sizeof(*ev) + chap_buf_size);
2116 if (!try_module_get(transport->
owner))
2121 err = iscsi_if_create_session(priv, ep, ev,
2134 err = iscsi_if_create_session(priv, ep, ev,
2141 session = iscsi_session_lookup(ev->
u.
d_session.sid);
2148 session = iscsi_session_lookup(ev->
u.
d_session.sid);
2156 err = iscsi_if_create_conn(transport, ev);
2159 err = iscsi_if_destroy_conn(transport, ev);
2162 session = iscsi_session_lookup(ev->
u.
b_conn.sid);
2165 if (conn && conn->
ep)
2166 iscsi_if_ep_disconnect(transport, conn->
ep->id);
2168 if (!session || !conn) {
2188 "Could not set ep conn "
2212 (
struct iscsi_hdr*)((
char*)ev +
sizeof(*ev)),
2213 (
char*)ev +
sizeof(*ev) + ev->
u.
send_pdu.hdr_size,
2219 err = iscsi_if_get_stats(transport, nlh);
2225 err = iscsi_if_transport_ep(transport, ev, nlh->
nlmsg_type);
2231 err = iscsi_set_host_param(transport, ev);
2234 err = iscsi_set_path(transport, ev);
2237 err = iscsi_set_iface_params(transport, ev,
2238 nlmsg_attrlen(nlh,
sizeof(*ev)));
2241 err = iscsi_send_ping(transport, ev);
2244 err = iscsi_get_chap(transport, nlh);
2247 err = iscsi_delete_chap(transport, ev);
2254 module_put(transport->
owner);
2263 iscsi_if_rx(
struct sk_buff *skb)
2273 nlh = nlmsg_hdr(skb);
2281 if (rlen > skb->
len)
2284 err = iscsi_if_recv_msg(skb, nlh, &group);
2300 err = iscsi_if_send_reply(group, nlh->
nlmsg_seq,
2308 #define ISCSI_CLASS_ATTR(_prefix,_name,_mode,_show,_store) \
2309 struct device_attribute dev_attr_##_prefix##_##_name = \
2310 __ATTR(_name,_mode,_show,_store)
2315 #define iscsi_conn_attr_show(param) \
2317 show_conn_param_##param(struct device *dev, \
2318 struct device_attribute *attr, char *buf) \
2320 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); \
2321 struct iscsi_transport *t = conn->transport; \
2322 return t->get_conn_param(conn, param, buf); \
2325 #define iscsi_conn_attr(field, param) \
2326 iscsi_conn_attr_show(param) \
2327 static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, show_conn_param_##param, \
2342 #define iscsi_conn_ep_attr_show(param) \
2343 static ssize_t show_conn_ep_param_##param(struct device *dev, \
2344 struct device_attribute *attr,\
2347 struct iscsi_cls_conn *conn = iscsi_dev_to_conn(dev->parent); \
2348 struct iscsi_transport *t = conn->transport; \
2349 struct iscsi_endpoint *ep; \
2356 mutex_lock(&conn->ep_mutex); \
2358 if (!ep && t->ep_connect) { \
2359 mutex_unlock(&conn->ep_mutex); \
2364 rc = t->get_ep_param(ep, param, buf); \
2366 rc = t->get_conn_param(conn, param, buf); \
2367 mutex_unlock(&conn->ep_mutex); \
2371 #define iscsi_conn_ep_attr(field, param) \
2372 iscsi_conn_ep_attr_show(param) \
2373 static ISCSI_CLASS_ATTR(conn, field, S_IRUGO, \
2374 show_conn_ep_param_##param, NULL);
2379 static struct attribute *iscsi_conn_attrs[] = {
2380 &dev_attr_conn_max_recv_dlength.attr,
2381 &dev_attr_conn_max_xmit_dlength.attr,
2382 &dev_attr_conn_header_digest.attr,
2383 &dev_attr_conn_data_digest.attr,
2384 &dev_attr_conn_ifmarker.attr,
2385 &dev_attr_conn_ofmarker.attr,
2386 &dev_attr_conn_address.attr,
2387 &dev_attr_conn_port.attr,
2388 &dev_attr_conn_exp_statsn.attr,
2389 &dev_attr_conn_persistent_address.attr,
2390 &dev_attr_conn_persistent_port.attr,
2391 &dev_attr_conn_ping_tmo.attr,
2392 &dev_attr_conn_recv_tmo.attr,
2404 if (attr == &dev_attr_conn_max_recv_dlength.attr)
2406 else if (attr == &dev_attr_conn_max_xmit_dlength.attr)
2408 else if (attr == &dev_attr_conn_header_digest.attr)
2410 else if (attr == &dev_attr_conn_data_digest.attr)
2412 else if (attr == &dev_attr_conn_ifmarker.attr)
2414 else if (attr == &dev_attr_conn_ofmarker.attr)
2416 else if (attr == &dev_attr_conn_address.attr)
2418 else if (attr == &dev_attr_conn_port.attr)
2420 else if (attr == &dev_attr_conn_exp_statsn.attr)
2422 else if (attr == &dev_attr_conn_persistent_address.attr)
2424 else if (attr == &dev_attr_conn_persistent_port.attr)
2426 else if (attr == &dev_attr_conn_ping_tmo.attr)
2428 else if (attr == &dev_attr_conn_recv_tmo.attr)
2439 .attrs = iscsi_conn_attrs,
2440 .is_visible = iscsi_conn_attr_is_visible,
2446 #define iscsi_session_attr_show(param, perm) \
2448 show_session_param_##param(struct device *dev, \
2449 struct device_attribute *attr, char *buf) \
2451 struct iscsi_cls_session *session = \
2452 iscsi_dev_to_session(dev->parent); \
2453 struct iscsi_transport *t = session->transport; \
2455 if (perm && !capable(CAP_SYS_ADMIN)) \
2457 return t->get_session_param(session, param, buf); \
2460 #define iscsi_session_attr(field, param, perm) \
2461 iscsi_session_attr_show(param, perm) \
2462 static ISCSI_CLASS_ATTR(sess, field, S_IRUGO, show_session_param_##param, \
2493 return sprintf(buf,
"%s\n", iscsi_session_state_name(session->
state));
2507 #define iscsi_priv_session_attr_show(field, format) \
2509 show_priv_session_##field(struct device *dev, \
2510 struct device_attribute *attr, char *buf) \
2512 struct iscsi_cls_session *session = \
2513 iscsi_dev_to_session(dev->parent); \
2514 if (session->field == -1) \
2515 return sprintf(buf, "off\n"); \
2516 return sprintf(buf, format"\n", session->field); \
2519 #define iscsi_priv_session_attr_store(field) \
2521 store_priv_session_##field(struct device *dev, \
2522 struct device_attribute *attr, \
2523 const char *buf, size_t count) \
2527 struct iscsi_cls_session *session = \
2528 iscsi_dev_to_session(dev->parent); \
2529 if ((session->state == ISCSI_SESSION_FREE) || \
2530 (session->state == ISCSI_SESSION_FAILED)) \
2532 if (strncmp(buf, "off", 3) == 0) \
2533 session->field = -1; \
2535 val = simple_strtoul(buf, &cp, 0); \
2536 if (*cp != '\0' && *cp != '\n') \
2538 session->field = val; \
2543 #define iscsi_priv_session_rw_attr(field, format) \
2544 iscsi_priv_session_attr_show(field, format) \
2545 iscsi_priv_session_attr_store(field) \
2546 static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO | S_IWUSR, \
2547 show_priv_session_##field, \
2548 store_priv_session_##field)
2551 static struct attribute *iscsi_session_attrs[] = {
2552 &dev_attr_sess_initial_r2t.attr,
2553 &dev_attr_sess_max_outstanding_r2t.attr,
2554 &dev_attr_sess_immediate_data.attr,
2555 &dev_attr_sess_first_burst_len.attr,
2556 &dev_attr_sess_max_burst_len.attr,
2557 &dev_attr_sess_data_pdu_in_order.attr,
2558 &dev_attr_sess_data_seq_in_order.attr,
2559 &dev_attr_sess_erl.attr,
2560 &dev_attr_sess_targetname.attr,
2561 &dev_attr_sess_tpgt.attr,
2562 &dev_attr_sess_password.attr,
2563 &dev_attr_sess_password_in.attr,
2564 &dev_attr_sess_username.attr,
2565 &dev_attr_sess_username_in.attr,
2566 &dev_attr_sess_fast_abort.attr,
2567 &dev_attr_sess_abort_tmo.attr,
2568 &dev_attr_sess_lu_reset_tmo.attr,
2569 &dev_attr_sess_tgt_reset_tmo.attr,
2570 &dev_attr_sess_ifacename.attr,
2571 &dev_attr_sess_initiatorname.attr,
2572 &dev_attr_sess_targetalias.attr,
2573 &dev_attr_priv_sess_recovery_tmo.attr,
2574 &dev_attr_priv_sess_state.attr,
2575 &dev_attr_priv_sess_creator.attr,
2576 &dev_attr_sess_chap_out_idx.attr,
2577 &dev_attr_sess_chap_in_idx.attr,
2581 static umode_t iscsi_session_attr_is_visible(
struct kobject *kobj,
2589 if (attr == &dev_attr_sess_initial_r2t.attr)
2591 else if (attr == &dev_attr_sess_max_outstanding_r2t.attr)
2593 else if (attr == &dev_attr_sess_immediate_data.attr)
2595 else if (attr == &dev_attr_sess_first_burst_len.attr)
2597 else if (attr == &dev_attr_sess_max_burst_len.attr)
2599 else if (attr == &dev_attr_sess_data_pdu_in_order.attr)
2601 else if (attr == &dev_attr_sess_data_seq_in_order.attr)
2603 else if (attr == &dev_attr_sess_erl.attr)
2605 else if (attr == &dev_attr_sess_targetname.attr)
2607 else if (attr == &dev_attr_sess_tpgt.attr)
2609 else if (attr == &dev_attr_sess_chap_in_idx.attr)
2611 else if (attr == &dev_attr_sess_chap_out_idx.attr)
2613 else if (attr == &dev_attr_sess_password.attr)
2615 else if (attr == &dev_attr_sess_password_in.attr)
2617 else if (attr == &dev_attr_sess_username.attr)
2619 else if (attr == &dev_attr_sess_username_in.attr)
2621 else if (attr == &dev_attr_sess_fast_abort.attr)
2623 else if (attr == &dev_attr_sess_abort_tmo.attr)
2625 else if (attr == &dev_attr_sess_lu_reset_tmo.attr)
2627 else if (attr == &dev_attr_sess_tgt_reset_tmo.attr)
2629 else if (attr == &dev_attr_sess_ifacename.attr)
2631 else if (attr == &dev_attr_sess_initiatorname.attr)
2633 else if (attr == &dev_attr_sess_targetalias.attr)
2635 else if (attr == &dev_attr_priv_sess_recovery_tmo.attr)
2637 else if (attr == &dev_attr_priv_sess_state.attr)
2639 else if (attr == &dev_attr_priv_sess_creator.attr)
2650 .attrs = iscsi_session_attrs,
2651 .is_visible = iscsi_session_attr_is_visible,
2657 #define iscsi_host_attr_show(param) \
2659 show_host_param_##param(struct device *dev, \
2660 struct device_attribute *attr, char *buf) \
2662 struct Scsi_Host *shost = transport_class_to_shost(dev); \
2663 struct iscsi_internal *priv = to_iscsi_internal(shost->transportt); \
2664 return priv->iscsi_transport->get_host_param(shost, param, buf); \
2667 #define iscsi_host_attr(field, param) \
2668 iscsi_host_attr_show(param) \
2669 static ISCSI_CLASS_ATTR(host, field, S_IRUGO, show_host_param_##param, \
2679 static struct attribute *iscsi_host_attrs[] = {
2680 &dev_attr_host_netdev.attr,
2681 &dev_attr_host_hwaddress.attr,
2682 &dev_attr_host_ipaddress.attr,
2683 &dev_attr_host_initiatorname.attr,
2684 &dev_attr_host_port_state.attr,
2685 &dev_attr_host_port_speed.attr,
2697 if (attr == &dev_attr_host_netdev.attr)
2699 else if (attr == &dev_attr_host_hwaddress.attr)
2701 else if (attr == &dev_attr_host_ipaddress.attr)
2703 else if (attr == &dev_attr_host_initiatorname.attr)
2705 else if (attr == &dev_attr_host_port_state.attr)
2707 else if (attr == &dev_attr_host_port_speed.attr)
2718 .attrs = iscsi_host_attrs,
2719 .is_visible = iscsi_host_attr_is_visible,
2723 static const struct {
2726 } iscsi_port_speed_names[] = {
2737 char *
speed =
"Unknown!";
2741 for (i = 0; i <
ARRAY_SIZE(iscsi_port_speed_names); i++) {
2742 if (iscsi_port_speed_names[i].
value & port_speed) {
2743 speed = iscsi_port_speed_names[
i].name;
2752 static const struct {
2755 } iscsi_port_state_names[] = {
2763 char *state =
"Unknown!";
2767 for (i = 0; i <
ARRAY_SIZE(iscsi_port_state_names); i++) {
2768 if (iscsi_port_state_names[i].
value & port_state) {
2769 state = iscsi_port_state_names[
i].name;
2793 if (priv->
session_cont.ac.class != &iscsi_session_class.class)
2807 if (!iscsi_is_conn_dev(dev))
2818 if (priv->
conn_cont.ac.class != &iscsi_connection_class.class)
2833 shost = dev_to_shost(dev);
2835 shost->
transportt->host_attrs.ac.class != &iscsi_host_class.class)
2839 return &priv->
t.host_attrs.ac ==
cont;
2846 unsigned long flags;
2851 priv = iscsi_if_transport_lookup(tt);
2858 INIT_LIST_HEAD(&priv->
list);
2860 priv->
t.user_scan = iscsi_user_scan;
2861 priv->
t.create_work_queue = 1;
2863 priv->
dev.class = &iscsi_transport_class;
2871 goto unregister_dev;
2874 priv->
t.host_attrs.ac.class = &iscsi_host_class.class;
2875 priv->
t.host_attrs.ac.match = iscsi_host_match;
2876 priv->
t.host_attrs.ac.grp = &iscsi_host_group;
2878 transport_container_register(&priv->
t.host_attrs);
2881 priv->
conn_cont.ac.class = &iscsi_connection_class.class;
2882 priv->
conn_cont.ac.match = iscsi_conn_match;
2883 priv->
conn_cont.ac.grp = &iscsi_conn_group;
2884 transport_container_register(&priv->
conn_cont);
2887 priv->
session_cont.ac.class = &iscsi_session_class.class;
2893 list_add(&priv->
list, &iscsi_transports);
2894 spin_unlock_irqrestore(&iscsi_transport_lock, flags);
2911 unsigned long flags;
2917 priv = iscsi_if_transport_lookup(tt);
2922 spin_unlock_irqrestore(&iscsi_transport_lock, flags);
2924 transport_container_unregister(&priv->
conn_cont);
2926 transport_container_unregister(&priv->
t.host_attrs);
2936 static __init int iscsi_transport_init(
void)
2941 .input = iscsi_if_rx,
2954 goto unregister_transport_class;
2958 goto unregister_endpoint_class;
2962 goto unregister_iface_class;
2966 goto unregister_host_class;
2970 goto unregister_conn_class;
2975 goto unregister_session_class;
2979 if (!iscsi_eh_timer_workq)
2986 unregister_session_class:
2988 unregister_conn_class:
2990 unregister_host_class:
2992 unregister_iface_class:
2994 unregister_endpoint_class:
2996 unregister_transport_class:
3001 static void __exit iscsi_transport_exit(
void)