aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOr Gerlitz <ogerlitz@voltaire.com>2006-05-02 20:46:36 -0400
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-05-10 11:11:38 -0400
commit264faaaa12544e7914928ad57ccba21907cad56b (patch)
treeeb8a6993e43f3802b203b371b81fcfb89fc4f754
parent169e1a2a8a789fa84254695ec6a56fc410bb19a9 (diff)
[SCSI] iscsi: add transport end point callbacks
add transport end point callbacks so iscsi drivers that cannot connect from userspace, like iscsi tcp, using sockets do not have to implement their own socket infrastructure. Signed-off-by: Or Gerlitz <ogerlitz@voltaire.com> Signed-off-by: Mike Christie <michaelc@cs.wisc.edu> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
-rw-r--r--drivers/scsi/iscsi_tcp.c4
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c41
-rw-r--r--include/scsi/iscsi_if.h19
-rw-r--r--include/scsi/scsi_transport_iscsi.h6
4 files changed, 65 insertions, 5 deletions
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index fe00a3f6d204..ac507daacfeb 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -1975,7 +1975,7 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_conn *cls_conn)
1975 1975
1976static int 1976static int
1977iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session, 1977iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session,
1978 struct iscsi_cls_conn *cls_conn, uint32_t transport_fd, 1978 struct iscsi_cls_conn *cls_conn, uint64_t transport_eph,
1979 int is_leading) 1979 int is_leading)
1980{ 1980{
1981 struct iscsi_conn *conn = cls_conn->dd_data; 1981 struct iscsi_conn *conn = cls_conn->dd_data;
@@ -1985,7 +1985,7 @@ iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session,
1985 int err; 1985 int err;
1986 1986
1987 /* lookup for existing socket */ 1987 /* lookup for existing socket */
1988 sock = sockfd_lookup(transport_fd, &err); 1988 sock = sockfd_lookup((int)transport_eph, &err);
1989 if (!sock) { 1989 if (!sock) {
1990 printk(KERN_ERR "iscsi_tcp: sockfd_lookup failed %d\n", err); 1990 printk(KERN_ERR "iscsi_tcp: sockfd_lookup failed %d\n", err);
1991 return -EEXIST; 1991 return -EEXIST;
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index bc9071d2d212..7b7a194822da 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -929,6 +929,40 @@ iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev)
929} 929}
930 930
931static int 931static int
932iscsi_if_transport_ep(struct iscsi_transport *transport,
933 struct iscsi_uevent *ev, int msg_type)
934{
935 struct sockaddr *dst_addr;
936 int rc = 0;
937
938 switch (msg_type) {
939 case ISCSI_UEVENT_TRANSPORT_EP_CONNECT:
940 if (!transport->ep_connect)
941 return -EINVAL;
942
943 dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev));
944 rc = transport->ep_connect(dst_addr,
945 ev->u.ep_connect.non_blocking,
946 &ev->r.ep_connect_ret.handle);
947 break;
948 case ISCSI_UEVENT_TRANSPORT_EP_POLL:
949 if (!transport->ep_poll)
950 return -EINVAL;
951
952 ev->r.retcode = transport->ep_poll(ev->u.ep_poll.ep_handle,
953 ev->u.ep_poll.timeout_ms);
954 break;
955 case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:
956 if (!transport->ep_disconnect)
957 return -EINVAL;
958
959 transport->ep_disconnect(ev->u.ep_disconnect.ep_handle);
960 break;
961 }
962 return rc;
963}
964
965static int
932iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) 966iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
933{ 967{
934 int err = 0; 968 int err = 0;
@@ -974,7 +1008,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
974 1008
975 if (session && conn) 1009 if (session && conn)
976 ev->r.retcode = transport->bind_conn(session, conn, 1010 ev->r.retcode = transport->bind_conn(session, conn,
977 ev->u.b_conn.transport_fd, 1011 ev->u.b_conn.transport_eph,
978 ev->u.b_conn.is_leading); 1012 ev->u.b_conn.is_leading);
979 else 1013 else
980 err = -EINVAL; 1014 err = -EINVAL;
@@ -1009,6 +1043,11 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
1009 case ISCSI_UEVENT_GET_STATS: 1043 case ISCSI_UEVENT_GET_STATS:
1010 err = iscsi_if_get_stats(transport, nlh); 1044 err = iscsi_if_get_stats(transport, nlh);
1011 break; 1045 break;
1046 case ISCSI_UEVENT_TRANSPORT_EP_CONNECT:
1047 case ISCSI_UEVENT_TRANSPORT_EP_POLL:
1048 case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:
1049 err = iscsi_if_transport_ep(transport, ev, nlh->nlmsg_type);
1050 break;
1012 default: 1051 default:
1013 err = -EINVAL; 1052 err = -EINVAL;
1014 break; 1053 break;
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 47524c726ee8..feff74e544b7 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -43,6 +43,10 @@ enum iscsi_uevent_e {
43 ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10, 43 ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10,
44 ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11, 44 ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11,
45 45
46 ISCSI_UEVENT_TRANSPORT_EP_CONNECT = UEVENT_BASE + 12,
47 ISCSI_UEVENT_TRANSPORT_EP_POLL = UEVENT_BASE + 13,
48 ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14,
49
46 /* up events */ 50 /* up events */
47 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1, 51 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
48 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2, 52 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
@@ -69,7 +73,7 @@ struct iscsi_uevent {
69 struct msg_bind_conn { 73 struct msg_bind_conn {
70 uint32_t sid; 74 uint32_t sid;
71 uint32_t cid; 75 uint32_t cid;
72 uint32_t transport_fd; 76 uint64_t transport_eph;
73 uint32_t is_leading; 77 uint32_t is_leading;
74 } b_conn; 78 } b_conn;
75 struct msg_destroy_conn { 79 struct msg_destroy_conn {
@@ -102,6 +106,16 @@ struct iscsi_uevent {
102 uint32_t sid; 106 uint32_t sid;
103 uint32_t cid; 107 uint32_t cid;
104 } get_stats; 108 } get_stats;
109 struct msg_transport_connect {
110 uint32_t non_blocking;
111 } ep_connect;
112 struct msg_transport_poll {
113 uint64_t ep_handle;
114 uint32_t timeout_ms;
115 } ep_poll;
116 struct msg_transport_disconnect {
117 uint64_t ep_handle;
118 } ep_disconnect;
105 } u; 119 } u;
106 union { 120 union {
107 /* messages k -> u */ 121 /* messages k -> u */
@@ -124,6 +138,9 @@ struct iscsi_uevent {
124 uint32_t cid; 138 uint32_t cid;
125 uint32_t error; /* enum iscsi_err */ 139 uint32_t error; /* enum iscsi_err */
126 } connerror; 140 } connerror;
141 struct msg_transport_connect_ret {
142 uint64_t handle;
143 } ep_connect_ret;
127 } r; 144 } r;
128} __attribute__ ((aligned (sizeof(uint64_t)))); 145} __attribute__ ((aligned (sizeof(uint64_t))));
129 146
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index b332d6e839fe..c9e9475c6dff 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -88,7 +88,7 @@ struct iscsi_transport {
88 uint32_t cid); 88 uint32_t cid);
89 int (*bind_conn) (struct iscsi_cls_session *session, 89 int (*bind_conn) (struct iscsi_cls_session *session,
90 struct iscsi_cls_conn *cls_conn, 90 struct iscsi_cls_conn *cls_conn,
91 uint32_t transport_fd, int is_leading); 91 uint64_t transport_eph, int is_leading);
92 int (*start_conn) (struct iscsi_cls_conn *conn); 92 int (*start_conn) (struct iscsi_cls_conn *conn);
93 void (*stop_conn) (struct iscsi_cls_conn *conn, int flag); 93 void (*stop_conn) (struct iscsi_cls_conn *conn, int flag);
94 void (*destroy_conn) (struct iscsi_cls_conn *conn); 94 void (*destroy_conn) (struct iscsi_cls_conn *conn);
@@ -119,6 +119,10 @@ struct iscsi_transport {
119 int (*xmit_mgmt_task) (struct iscsi_conn *conn, 119 int (*xmit_mgmt_task) (struct iscsi_conn *conn,
120 struct iscsi_mgmt_task *mtask); 120 struct iscsi_mgmt_task *mtask);
121 void (*session_recovery_timedout) (struct iscsi_cls_session *session); 121 void (*session_recovery_timedout) (struct iscsi_cls_session *session);
122 int (*ep_connect) (struct sockaddr *dst_addr, int non_blocking,
123 uint64_t *ep_handle);
124 int (*ep_poll) (uint64_t ep_handle, int timeout_ms);
125 void (*ep_disconnect) (uint64_t ep_handle);
122}; 126};
123 127
124/* 128/*