aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/iscsi_tcp.c5
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c106
-rw-r--r--include/scsi/iscsi_if.h37
-rw-r--r--include/scsi/scsi_transport_iscsi.h7
4 files changed, 105 insertions, 50 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 2068b66822b7..6ecb4baa37e2 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -3254,7 +3254,7 @@ static struct iscsi_transport iscsi_tcp_transport;
3254 3254
3255static struct iscsi_cls_session * 3255static struct iscsi_cls_session *
3256iscsi_session_create(struct scsi_transport_template *scsit, 3256iscsi_session_create(struct scsi_transport_template *scsit,
3257 uint32_t initial_cmdsn, uint32_t *sid) 3257 uint32_t initial_cmdsn, uint32_t *hostno)
3258{ 3258{
3259 struct Scsi_Host *shost; 3259 struct Scsi_Host *shost;
3260 struct iscsi_session *session; 3260 struct iscsi_session *session;
@@ -3274,7 +3274,8 @@ iscsi_session_create(struct scsi_transport_template *scsit,
3274 session->exp_cmdsn = initial_cmdsn + 1; 3274 session->exp_cmdsn = initial_cmdsn + 1;
3275 session->max_cmdsn = initial_cmdsn + 1; 3275 session->max_cmdsn = initial_cmdsn + 1;
3276 session->max_r2t = 1; 3276 session->max_r2t = 1;
3277 *sid = shost->host_no; 3277
3278 *hostno = shost->host_no;
3278 3279
3279 /* initialize SCSI PDU commands pool */ 3280 /* initialize SCSI PDU commands pool */
3280 if (iscsi_pool_init(&session->cmdpool, session->cmds_max, 3281 if (iscsi_pool_init(&session->cmdpool, session->cmds_max,
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 2730d507e585..10ff0f0210ba 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -56,6 +56,8 @@ struct iscsi_internal {
56 struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1]; 56 struct class_device_attribute *session_attrs[ISCSI_SESSION_ATTRS + 1];
57}; 57};
58 58
59static int iscsi_session_nr; /* sysfs session id for next new session */
60
59/* 61/*
60 * list of registered transports and lock that must 62 * list of registered transports and lock that must
61 * be held while accessing list. The iscsi_transport_lock must 63 * be held while accessing list. The iscsi_transport_lock must
@@ -165,14 +167,23 @@ static DEFINE_SPINLOCK(sesslock);
165static LIST_HEAD(connlist); 167static LIST_HEAD(connlist);
166static DEFINE_SPINLOCK(connlock); 168static DEFINE_SPINLOCK(connlock);
167 169
168static struct iscsi_cls_session *iscsi_session_lookup(uint64_t handle) 170static uint32_t iscsi_conn_get_sid(struct iscsi_cls_conn *conn)
171{
172 struct iscsi_cls_session *sess = iscsi_dev_to_session(conn->dev.parent);
173 return sess->sid;
174}
175
176/*
177 * Returns the matching session to a given sid
178 */
179static struct iscsi_cls_session *iscsi_session_lookup(uint32_t sid)
169{ 180{
170 unsigned long flags; 181 unsigned long flags;
171 struct iscsi_cls_session *sess; 182 struct iscsi_cls_session *sess;
172 183
173 spin_lock_irqsave(&sesslock, flags); 184 spin_lock_irqsave(&sesslock, flags);
174 list_for_each_entry(sess, &sesslist, sess_list) { 185 list_for_each_entry(sess, &sesslist, sess_list) {
175 if (sess == iscsi_ptr(handle)) { 186 if (sess->sid == sid) {
176 spin_unlock_irqrestore(&sesslock, flags); 187 spin_unlock_irqrestore(&sesslock, flags);
177 return sess; 188 return sess;
178 } 189 }
@@ -181,14 +192,17 @@ static struct iscsi_cls_session *iscsi_session_lookup(uint64_t handle)
181 return NULL; 192 return NULL;
182} 193}
183 194
184static struct iscsi_cls_conn *iscsi_conn_lookup(uint64_t handle) 195/*
196 * Returns the matching connection to a given sid / cid tuple
197 */
198static struct iscsi_cls_conn *iscsi_conn_lookup(uint32_t sid, uint32_t cid)
185{ 199{
186 unsigned long flags; 200 unsigned long flags;
187 struct iscsi_cls_conn *conn; 201 struct iscsi_cls_conn *conn;
188 202
189 spin_lock_irqsave(&connlock, flags); 203 spin_lock_irqsave(&connlock, flags);
190 list_for_each_entry(conn, &connlist, conn_list) { 204 list_for_each_entry(conn, &connlist, conn_list) {
191 if (conn == iscsi_ptr(handle)) { 205 if ((conn->cid == cid) && (iscsi_conn_get_sid(conn) == sid)) {
192 spin_unlock_irqrestore(&connlock, flags); 206 spin_unlock_irqrestore(&connlock, flags);
193 return conn; 207 return conn;
194 } 208 }
@@ -223,7 +237,7 @@ static int iscsi_is_session_dev(const struct device *dev)
223 * @shost: scsi host 237 * @shost: scsi host
224 * @transport: iscsi transport 238 * @transport: iscsi transport
225 * 239 *
226 * This can be called from a LLD or iscsi_transport 240 * This can be called from a LLD or iscsi_transport.
227 **/ 241 **/
228struct iscsi_cls_session * 242struct iscsi_cls_session *
229iscsi_create_session(struct Scsi_Host *shost, struct iscsi_transport *transport) 243iscsi_create_session(struct Scsi_Host *shost, struct iscsi_transport *transport)
@@ -234,14 +248,20 @@ iscsi_create_session(struct Scsi_Host *shost, struct iscsi_transport *transport)
234 if (!try_module_get(transport->owner)) 248 if (!try_module_get(transport->owner))
235 return NULL; 249 return NULL;
236 250
237 session = kzalloc(sizeof(*session), GFP_KERNEL); 251 session = kzalloc(sizeof(*session) + transport->sessiondata_size,
252 GFP_KERNEL);
238 if (!session) 253 if (!session)
239 goto module_put; 254 goto module_put;
240 session->transport = transport; 255 session->transport = transport;
241 256
257 if (transport->sessiondata_size)
258 session->dd_data = &session[1];
259
242 /* this is released in the dev's release function */ 260 /* this is released in the dev's release function */
243 scsi_host_get(shost); 261 scsi_host_get(shost);
244 snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u", shost->host_no); 262 session->sid = iscsi_session_nr++;
263 snprintf(session->dev.bus_id, BUS_ID_SIZE, "session%u",
264 session->sid);
245 session->dev.parent = &shost->shost_gendev; 265 session->dev.parent = &shost->shost_gendev;
246 session->dev.release = iscsi_session_release; 266 session->dev.release = iscsi_session_release;
247 err = device_register(&session->dev); 267 err = device_register(&session->dev);
@@ -301,12 +321,16 @@ static int iscsi_is_conn_dev(const struct device *dev)
301 * This can be called from a LLD or iscsi_transport. The connection 321 * This can be called from a LLD or iscsi_transport. The connection
302 * is child of the session so cid must be unique for all connections 322 * is child of the session so cid must be unique for all connections
303 * on the session. 323 * on the session.
324 *
325 * Since we do not support MCS, cid will normally be zero. In some cases
326 * for software iscsi we could be trying to preallocate a connection struct
327 * in which case there could be two connection structs and cid would be
328 * non-zero.
304 **/ 329 **/
305struct iscsi_cls_conn * 330struct iscsi_cls_conn *
306iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid) 331iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid)
307{ 332{
308 struct iscsi_transport *transport = session->transport; 333 struct iscsi_transport *transport = session->transport;
309 struct Scsi_Host *shost = iscsi_session_to_shost(session);
310 struct iscsi_cls_conn *conn; 334 struct iscsi_cls_conn *conn;
311 int err; 335 int err;
312 336
@@ -319,12 +343,14 @@ iscsi_create_conn(struct iscsi_cls_session *session, uint32_t cid)
319 343
320 INIT_LIST_HEAD(&conn->conn_list); 344 INIT_LIST_HEAD(&conn->conn_list);
321 conn->transport = transport; 345 conn->transport = transport;
346 conn->cid = cid;
322 347
323 /* this is released in the dev's release function */ 348 /* this is released in the dev's release function */
324 if (!get_device(&session->dev)) 349 if (!get_device(&session->dev))
325 goto free_conn; 350 goto free_conn;
351
326 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u", 352 snprintf(conn->dev.bus_id, BUS_ID_SIZE, "connection%d:%u",
327 shost->host_no, cid); 353 session->sid, cid);
328 conn->dev.parent = &session->dev; 354 conn->dev.parent = &session->dev;
329 conn->dev.release = iscsi_conn_release; 355 conn->dev.release = iscsi_conn_release;
330 err = device_register(&conn->dev); 356 err = device_register(&conn->dev);
@@ -607,7 +633,8 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
607 ev->type = ISCSI_KEVENT_RECV_PDU; 633 ev->type = ISCSI_KEVENT_RECV_PDU;
608 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat) 634 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat)
609 ev->iferror = -ENOMEM; 635 ev->iferror = -ENOMEM;
610 ev->r.recv_req.conn_handle = iscsi_handle(conn); 636 ev->r.recv_req.cid = conn->cid;
637 ev->r.recv_req.sid = iscsi_conn_get_sid(conn);
611 pdu = (char*)ev + sizeof(*ev); 638 pdu = (char*)ev + sizeof(*ev);
612 memcpy(pdu, hdr, sizeof(struct iscsi_hdr)); 639 memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
613 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size); 640 memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);
@@ -639,7 +666,8 @@ void iscsi_conn_error(struct iscsi_cls_conn *conn, enum iscsi_err error)
639 if (atomic_read(&conn->z_error->allocated) >= conn->z_error->hiwat) 666 if (atomic_read(&conn->z_error->allocated) >= conn->z_error->hiwat)
640 ev->iferror = -ENOMEM; 667 ev->iferror = -ENOMEM;
641 ev->r.connerror.error = error; 668 ev->r.connerror.error = error;
642 ev->r.connerror.conn_handle = iscsi_handle(conn); 669 ev->r.connerror.cid = conn->cid;
670 ev->r.connerror.sid = iscsi_conn_get_sid(conn);
643 671
644 iscsi_unicast_skb(conn->z_error, skb); 672 iscsi_unicast_skb(conn->z_error, skb);
645 673
@@ -689,7 +717,7 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
689 ISCSI_STATS_CUSTOM_MAX); 717 ISCSI_STATS_CUSTOM_MAX);
690 int err = 0; 718 int err = 0;
691 719
692 conn = iscsi_conn_lookup(ev->u.get_stats.conn_handle); 720 conn = iscsi_conn_lookup(ev->u.get_stats.sid, ev->u.get_stats.cid);
693 if (!conn) 721 if (!conn)
694 return -EEXIST; 722 return -EEXIST;
695 723
@@ -713,8 +741,10 @@ iscsi_if_get_stats(struct iscsi_transport *transport, struct nlmsghdr *nlh)
713 evstat->type = nlh->nlmsg_type; 741 evstat->type = nlh->nlmsg_type;
714 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat) 742 if (atomic_read(&conn->z_pdu->allocated) >= conn->z_pdu->hiwat)
715 evstat->iferror = -ENOMEM; 743 evstat->iferror = -ENOMEM;
716 evstat->u.get_stats.conn_handle = 744 evstat->u.get_stats.cid =
717 ev->u.get_stats.conn_handle; 745 ev->u.get_stats.cid;
746 evstat->u.get_stats.sid =
747 ev->u.get_stats.sid;
718 stats = (struct iscsi_stats *) 748 stats = (struct iscsi_stats *)
719 ((char*)evstat + sizeof(*evstat)); 749 ((char*)evstat + sizeof(*evstat));
720 memset(stats, 0, sizeof(*stats)); 750 memset(stats, 0, sizeof(*stats));
@@ -740,16 +770,16 @@ iscsi_if_create_session(struct iscsi_internal *priv, struct iscsi_uevent *ev)
740{ 770{
741 struct iscsi_transport *transport = priv->iscsi_transport; 771 struct iscsi_transport *transport = priv->iscsi_transport;
742 struct iscsi_cls_session *session; 772 struct iscsi_cls_session *session;
743 uint32_t sid; 773 uint32_t hostno;
744 774
745 session = transport->create_session(&priv->t, 775 session = transport->create_session(&priv->t,
746 ev->u.c_session.initial_cmdsn, 776 ev->u.c_session.initial_cmdsn,
747 &sid); 777 &hostno);
748 if (!session) 778 if (!session)
749 return -ENOMEM; 779 return -ENOMEM;
750 780
751 ev->r.c_session_ret.session_handle = iscsi_handle(session); 781 ev->r.c_session_ret.host_no = hostno;
752 ev->r.c_session_ret.sid = sid; 782 ev->r.c_session_ret.sid = session->sid;
753 return 0; 783 return 0;
754} 784}
755 785
@@ -760,13 +790,20 @@ iscsi_if_create_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev)
760 struct iscsi_cls_session *session; 790 struct iscsi_cls_session *session;
761 unsigned long flags; 791 unsigned long flags;
762 792
763 session = iscsi_session_lookup(ev->u.c_conn.session_handle); 793 session = iscsi_session_lookup(ev->u.c_conn.sid);
764 if (!session) 794 if (!session) {
795 printk(KERN_ERR "iscsi: invalid session %d\n",
796 ev->u.c_conn.sid);
765 return -EINVAL; 797 return -EINVAL;
798 }
766 799
767 conn = transport->create_conn(session, ev->u.c_conn.cid); 800 conn = transport->create_conn(session, ev->u.c_conn.cid);
768 if (!conn) 801 if (!conn) {
802 printk(KERN_ERR "iscsi: couldn't create a new "
803 "connection for session %d\n",
804 session->sid);
769 return -ENOMEM; 805 return -ENOMEM;
806 }
770 807
771 conn->z_pdu = mempool_zone_init(Z_MAX_PDU, 808 conn->z_pdu = mempool_zone_init(Z_MAX_PDU,
772 NLMSG_SPACE(sizeof(struct iscsi_uevent) + 809 NLMSG_SPACE(sizeof(struct iscsi_uevent) +
@@ -788,7 +825,8 @@ iscsi_if_create_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev)
788 goto free_pdu_pool; 825 goto free_pdu_pool;
789 } 826 }
790 827
791 ev->r.handle = iscsi_handle(conn); 828 ev->r.c_conn_ret.sid = session->sid;
829 ev->r.c_conn_ret.cid = conn->cid;
792 830
793 spin_lock_irqsave(&connlock, flags); 831 spin_lock_irqsave(&connlock, flags);
794 list_add(&conn->conn_list, &connlist); 832 list_add(&conn->conn_list, &connlist);
@@ -812,7 +850,7 @@ iscsi_if_destroy_conn(struct iscsi_transport *transport, struct iscsi_uevent *ev
812 struct iscsi_cls_conn *conn; 850 struct iscsi_cls_conn *conn;
813 struct mempool_zone *z_error, *z_pdu; 851 struct mempool_zone *z_error, *z_pdu;
814 852
815 conn = iscsi_conn_lookup(ev->u.d_conn.conn_handle); 853 conn = iscsi_conn_lookup(ev->u.d_conn.sid, ev->u.d_conn.cid);
816 if (!conn) 854 if (!conn)
817 return -EINVAL; 855 return -EINVAL;
818 spin_lock_irqsave(&connlock, flags); 856 spin_lock_irqsave(&connlock, flags);
@@ -855,7 +893,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
855 err = iscsi_if_create_session(priv, ev); 893 err = iscsi_if_create_session(priv, ev);
856 break; 894 break;
857 case ISCSI_UEVENT_DESTROY_SESSION: 895 case ISCSI_UEVENT_DESTROY_SESSION:
858 session = iscsi_session_lookup(ev->u.d_session.session_handle); 896 session = iscsi_session_lookup(ev->u.d_session.sid);
859 if (session) 897 if (session)
860 transport->destroy_session(session); 898 transport->destroy_session(session);
861 else 899 else
@@ -868,8 +906,8 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
868 err = iscsi_if_destroy_conn(transport, ev); 906 err = iscsi_if_destroy_conn(transport, ev);
869 break; 907 break;
870 case ISCSI_UEVENT_BIND_CONN: 908 case ISCSI_UEVENT_BIND_CONN:
871 session = iscsi_session_lookup(ev->u.b_conn.session_handle); 909 session = iscsi_session_lookup(ev->u.b_conn.sid);
872 conn = iscsi_conn_lookup(ev->u.b_conn.conn_handle); 910 conn = iscsi_conn_lookup(ev->u.b_conn.sid, ev->u.b_conn.cid);
873 911
874 if (session && conn) 912 if (session && conn)
875 ev->r.retcode = transport->bind_conn(session, conn, 913 ev->r.retcode = transport->bind_conn(session, conn,
@@ -879,7 +917,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
879 err = -EINVAL; 917 err = -EINVAL;
880 break; 918 break;
881 case ISCSI_UEVENT_SET_PARAM: 919 case ISCSI_UEVENT_SET_PARAM:
882 conn = iscsi_conn_lookup(ev->u.set_param.conn_handle); 920 conn = iscsi_conn_lookup(ev->u.set_param.sid, ev->u.set_param.cid);
883 if (conn) 921 if (conn)
884 ev->r.retcode = transport->set_param(conn, 922 ev->r.retcode = transport->set_param(conn,
885 ev->u.set_param.param, ev->u.set_param.value); 923 ev->u.set_param.param, ev->u.set_param.value);
@@ -887,7 +925,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
887 err = -EINVAL; 925 err = -EINVAL;
888 break; 926 break;
889 case ISCSI_UEVENT_START_CONN: 927 case ISCSI_UEVENT_START_CONN:
890 conn = iscsi_conn_lookup(ev->u.start_conn.conn_handle); 928 conn = iscsi_conn_lookup(ev->u.start_conn.sid, ev->u.start_conn.cid);
891 if (conn) 929 if (conn)
892 ev->r.retcode = transport->start_conn(conn); 930 ev->r.retcode = transport->start_conn(conn);
893 else 931 else
@@ -895,14 +933,14 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
895 933
896 break; 934 break;
897 case ISCSI_UEVENT_STOP_CONN: 935 case ISCSI_UEVENT_STOP_CONN:
898 conn = iscsi_conn_lookup(ev->u.stop_conn.conn_handle); 936 conn = iscsi_conn_lookup(ev->u.stop_conn.sid, ev->u.stop_conn.cid);
899 if (conn) 937 if (conn)
900 transport->stop_conn(conn, ev->u.stop_conn.flag); 938 transport->stop_conn(conn, ev->u.stop_conn.flag);
901 else 939 else
902 err = -EINVAL; 940 err = -EINVAL;
903 break; 941 break;
904 case ISCSI_UEVENT_SEND_PDU: 942 case ISCSI_UEVENT_SEND_PDU:
905 conn = iscsi_conn_lookup(ev->u.send_pdu.conn_handle); 943 conn = iscsi_conn_lookup(ev->u.send_pdu.sid, ev->u.send_pdu.cid);
906 if (conn) 944 if (conn)
907 ev->r.retcode = transport->send_pdu(conn, 945 ev->r.retcode = transport->send_pdu(conn,
908 (struct iscsi_hdr*)((char*)ev + sizeof(*ev)), 946 (struct iscsi_hdr*)((char*)ev + sizeof(*ev)),
@@ -923,9 +961,11 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
923 return err; 961 return err;
924} 962}
925 963
926/* Get message from skb (based on rtnetlink_rcv_skb). Each message is 964/*
927 * processed by iscsi_if_recv_msg. Malformed skbs with wrong length are 965 * Get message from skb (based on rtnetlink_rcv_skb). Each message is
928 * or invalid creds discarded silently. */ 966 * processed by iscsi_if_recv_msg. Malformed skbs with wrong lengths or
967 * invalid creds are discarded silently.
968 */
929static void 969static void
930iscsi_if_rx(struct sock *sk, int len) 970iscsi_if_rx(struct sock *sk, int len)
931{ 971{
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index e5618b90996e..933a91b1474e 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -60,59 +60,68 @@ struct iscsi_uevent {
60 uint32_t initial_cmdsn; 60 uint32_t initial_cmdsn;
61 } c_session; 61 } c_session;
62 struct msg_destroy_session { 62 struct msg_destroy_session {
63 uint64_t session_handle;
64 uint32_t sid; 63 uint32_t sid;
65 } d_session; 64 } d_session;
66 struct msg_create_conn { 65 struct msg_create_conn {
67 uint64_t session_handle;
68 uint32_t cid;
69 uint32_t sid; 66 uint32_t sid;
67 uint32_t cid;
70 } c_conn; 68 } c_conn;
71 struct msg_bind_conn { 69 struct msg_bind_conn {
72 uint64_t session_handle; 70 uint32_t sid;
73 uint64_t conn_handle; 71 uint32_t cid;
74 uint32_t transport_fd; 72 uint32_t transport_fd;
75 uint32_t is_leading; 73 uint32_t is_leading;
76 } b_conn; 74 } b_conn;
77 struct msg_destroy_conn { 75 struct msg_destroy_conn {
78 uint64_t conn_handle; 76 uint32_t sid;
79 uint32_t cid; 77 uint32_t cid;
80 } d_conn; 78 } d_conn;
81 struct msg_send_pdu { 79 struct msg_send_pdu {
80 uint32_t sid;
81 uint32_t cid;
82 uint32_t hdr_size; 82 uint32_t hdr_size;
83 uint32_t data_size; 83 uint32_t data_size;
84 uint64_t conn_handle;
85 } send_pdu; 84 } send_pdu;
86 struct msg_set_param { 85 struct msg_set_param {
87 uint64_t conn_handle; 86 uint32_t sid;
87 uint32_t cid;
88 uint32_t param; /* enum iscsi_param */ 88 uint32_t param; /* enum iscsi_param */
89 uint32_t value; 89 uint32_t value;
90 } set_param; 90 } set_param;
91 struct msg_start_conn { 91 struct msg_start_conn {
92 uint64_t conn_handle; 92 uint32_t sid;
93 uint32_t cid;
93 } start_conn; 94 } start_conn;
94 struct msg_stop_conn { 95 struct msg_stop_conn {
96 uint32_t sid;
97 uint32_t cid;
95 uint64_t conn_handle; 98 uint64_t conn_handle;
96 uint32_t flag; 99 uint32_t flag;
97 } stop_conn; 100 } stop_conn;
98 struct msg_get_stats { 101 struct msg_get_stats {
99 uint64_t conn_handle; 102 uint32_t sid;
103 uint32_t cid;
100 } get_stats; 104 } get_stats;
101 } u; 105 } u;
102 union { 106 union {
103 /* messages k -> u */ 107 /* messages k -> u */
104 uint64_t handle;
105 int retcode; 108 int retcode;
106 struct msg_create_session_ret { 109 struct msg_create_session_ret {
107 uint64_t session_handle;
108 uint32_t sid; 110 uint32_t sid;
111 uint32_t host_no;
109 } c_session_ret; 112 } c_session_ret;
113 struct msg_create_conn_ret {
114 uint32_t sid;
115 uint32_t cid;
116 } c_conn_ret;
110 struct msg_recv_req { 117 struct msg_recv_req {
118 uint32_t sid;
119 uint32_t cid;
111 uint64_t recv_handle; 120 uint64_t recv_handle;
112 uint64_t conn_handle;
113 } recv_req; 121 } recv_req;
114 struct msg_conn_error { 122 struct msg_conn_error {
115 uint64_t conn_handle; 123 uint32_t sid;
124 uint32_t cid;
116 uint32_t error; /* enum iscsi_err */ 125 uint32_t error; /* enum iscsi_err */
117 } connerror; 126 } connerror;
118 } r; 127 } r;
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index b41cf077e54b..631463cd4892 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -60,11 +60,13 @@ struct iscsi_transport {
60 int ihostdata_size; 60 int ihostdata_size;
61 /* LLD connection data size */ 61 /* LLD connection data size */
62 int conndata_size; 62 int conndata_size;
63 /* LLD session data size */
64 int sessiondata_size;
63 int max_lun; 65 int max_lun;
64 unsigned int max_conn; 66 unsigned int max_conn;
65 unsigned int max_cmd_len; 67 unsigned int max_cmd_len;
66 struct iscsi_cls_session *(*create_session) 68 struct iscsi_cls_session *(*create_session)
67 (struct scsi_transport_template *t, uint32_t sn, uint32_t *sid); 69 (struct scsi_transport_template *t, uint32_t sn, uint32_t *hn);
68 void (*destroy_session) (struct iscsi_cls_session *session); 70 void (*destroy_session) (struct iscsi_cls_session *session);
69 struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess, 71 struct iscsi_cls_conn *(*create_conn) (struct iscsi_cls_session *sess,
70 uint32_t cid); 72 uint32_t cid);
@@ -104,6 +106,7 @@ struct iscsi_cls_conn {
104 struct list_head conn_list; /* item in connlist */ 106 struct list_head conn_list; /* item in connlist */
105 void *dd_data; /* LLD private data */ 107 void *dd_data; /* LLD private data */
106 struct iscsi_transport *transport; 108 struct iscsi_transport *transport;
109 uint32_t cid; /* connection id */
107 int active; /* must be accessed with the connlock */ 110 int active; /* must be accessed with the connlock */
108 struct device dev; /* sysfs transport/container device */ 111 struct device dev; /* sysfs transport/container device */
109 struct mempool_zone *z_error; 112 struct mempool_zone *z_error;
@@ -117,6 +120,8 @@ struct iscsi_cls_conn {
117struct iscsi_cls_session { 120struct iscsi_cls_session {
118 struct list_head sess_list; /* item in session_list */ 121 struct list_head sess_list; /* item in session_list */
119 struct iscsi_transport *transport; 122 struct iscsi_transport *transport;
123 int sid; /* session id */
124 void *dd_data; /* LLD private data */
120 struct device dev; /* sysfs transport/container device */ 125 struct device dev; /* sysfs transport/container device */
121}; 126};
122 127