Commit 264faaaa authored by Or Gerlitz's avatar Or Gerlitz Committed by James Bottomley

[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: default avatarOr Gerlitz <ogerlitz@voltaire.com>
Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 169e1a2a
...@@ -1975,7 +1975,7 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_conn *cls_conn) ...@@ -1975,7 +1975,7 @@ iscsi_tcp_conn_destroy(struct iscsi_cls_conn *cls_conn)
static int static int
iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session, iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session,
struct iscsi_cls_conn *cls_conn, uint32_t transport_fd, struct iscsi_cls_conn *cls_conn, uint64_t transport_eph,
int is_leading) int is_leading)
{ {
struct iscsi_conn *conn = cls_conn->dd_data; struct iscsi_conn *conn = cls_conn->dd_data;
...@@ -1985,7 +1985,7 @@ iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session, ...@@ -1985,7 +1985,7 @@ iscsi_tcp_conn_bind(struct iscsi_cls_session *cls_session,
int err; int err;
/* lookup for existing socket */ /* lookup for existing socket */
sock = sockfd_lookup(transport_fd, &err); sock = sockfd_lookup((int)transport_eph, &err);
if (!sock) { if (!sock) {
printk(KERN_ERR "iscsi_tcp: sockfd_lookup failed %d\n", err); printk(KERN_ERR "iscsi_tcp: sockfd_lookup failed %d\n", err);
return -EEXIST; return -EEXIST;
......
...@@ -928,6 +928,40 @@ iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev) ...@@ -928,6 +928,40 @@ iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev)
return err; return err;
} }
static int
iscsi_if_transport_ep(struct iscsi_transport *transport,
struct iscsi_uevent *ev, int msg_type)
{
struct sockaddr *dst_addr;
int rc = 0;
switch (msg_type) {
case ISCSI_UEVENT_TRANSPORT_EP_CONNECT:
if (!transport->ep_connect)
return -EINVAL;
dst_addr = (struct sockaddr *)((char*)ev + sizeof(*ev));
rc = transport->ep_connect(dst_addr,
ev->u.ep_connect.non_blocking,
&ev->r.ep_connect_ret.handle);
break;
case ISCSI_UEVENT_TRANSPORT_EP_POLL:
if (!transport->ep_poll)
return -EINVAL;
ev->r.retcode = transport->ep_poll(ev->u.ep_poll.ep_handle,
ev->u.ep_poll.timeout_ms);
break;
case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:
if (!transport->ep_disconnect)
return -EINVAL;
transport->ep_disconnect(ev->u.ep_disconnect.ep_handle);
break;
}
return rc;
}
static int static int
iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
{ {
...@@ -974,7 +1008,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -974,7 +1008,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
if (session && conn) if (session && conn)
ev->r.retcode = transport->bind_conn(session, conn, ev->r.retcode = transport->bind_conn(session, conn,
ev->u.b_conn.transport_fd, ev->u.b_conn.transport_eph,
ev->u.b_conn.is_leading); ev->u.b_conn.is_leading);
else else
err = -EINVAL; err = -EINVAL;
...@@ -1009,6 +1043,11 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -1009,6 +1043,11 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
case ISCSI_UEVENT_GET_STATS: case ISCSI_UEVENT_GET_STATS:
err = iscsi_if_get_stats(transport, nlh); err = iscsi_if_get_stats(transport, nlh);
break; break;
case ISCSI_UEVENT_TRANSPORT_EP_CONNECT:
case ISCSI_UEVENT_TRANSPORT_EP_POLL:
case ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT:
err = iscsi_if_transport_ep(transport, ev, nlh->nlmsg_type);
break;
default: default:
err = -EINVAL; err = -EINVAL;
break; break;
......
...@@ -43,6 +43,10 @@ enum iscsi_uevent_e { ...@@ -43,6 +43,10 @@ enum iscsi_uevent_e {
ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10, ISCSI_UEVENT_GET_STATS = UEVENT_BASE + 10,
ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11, ISCSI_UEVENT_GET_PARAM = UEVENT_BASE + 11,
ISCSI_UEVENT_TRANSPORT_EP_CONNECT = UEVENT_BASE + 12,
ISCSI_UEVENT_TRANSPORT_EP_POLL = UEVENT_BASE + 13,
ISCSI_UEVENT_TRANSPORT_EP_DISCONNECT = UEVENT_BASE + 14,
/* up events */ /* up events */
ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1, ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2, ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
...@@ -69,7 +73,7 @@ struct iscsi_uevent { ...@@ -69,7 +73,7 @@ struct iscsi_uevent {
struct msg_bind_conn { struct msg_bind_conn {
uint32_t sid; uint32_t sid;
uint32_t cid; uint32_t cid;
uint32_t transport_fd; uint64_t transport_eph;
uint32_t is_leading; uint32_t is_leading;
} b_conn; } b_conn;
struct msg_destroy_conn { struct msg_destroy_conn {
...@@ -102,6 +106,16 @@ struct iscsi_uevent { ...@@ -102,6 +106,16 @@ struct iscsi_uevent {
uint32_t sid; uint32_t sid;
uint32_t cid; uint32_t cid;
} get_stats; } get_stats;
struct msg_transport_connect {
uint32_t non_blocking;
} ep_connect;
struct msg_transport_poll {
uint64_t ep_handle;
uint32_t timeout_ms;
} ep_poll;
struct msg_transport_disconnect {
uint64_t ep_handle;
} ep_disconnect;
} u; } u;
union { union {
/* messages k -> u */ /* messages k -> u */
...@@ -124,6 +138,9 @@ struct iscsi_uevent { ...@@ -124,6 +138,9 @@ struct iscsi_uevent {
uint32_t cid; uint32_t cid;
uint32_t error; /* enum iscsi_err */ uint32_t error; /* enum iscsi_err */
} connerror; } connerror;
struct msg_transport_connect_ret {
uint64_t handle;
} ep_connect_ret;
} r; } r;
} __attribute__ ((aligned (sizeof(uint64_t)))); } __attribute__ ((aligned (sizeof(uint64_t))));
......
...@@ -88,7 +88,7 @@ struct iscsi_transport { ...@@ -88,7 +88,7 @@ struct iscsi_transport {
uint32_t cid); uint32_t cid);
int (*bind_conn) (struct iscsi_cls_session *session, int (*bind_conn) (struct iscsi_cls_session *session,
struct iscsi_cls_conn *cls_conn, struct iscsi_cls_conn *cls_conn,
uint32_t transport_fd, int is_leading); uint64_t transport_eph, int is_leading);
int (*start_conn) (struct iscsi_cls_conn *conn); int (*start_conn) (struct iscsi_cls_conn *conn);
void (*stop_conn) (struct iscsi_cls_conn *conn, int flag); void (*stop_conn) (struct iscsi_cls_conn *conn, int flag);
void (*destroy_conn) (struct iscsi_cls_conn *conn); void (*destroy_conn) (struct iscsi_cls_conn *conn);
...@@ -119,6 +119,10 @@ struct iscsi_transport { ...@@ -119,6 +119,10 @@ struct iscsi_transport {
int (*xmit_mgmt_task) (struct iscsi_conn *conn, int (*xmit_mgmt_task) (struct iscsi_conn *conn,
struct iscsi_mgmt_task *mtask); struct iscsi_mgmt_task *mtask);
void (*session_recovery_timedout) (struct iscsi_cls_session *session); void (*session_recovery_timedout) (struct iscsi_cls_session *session);
int (*ep_connect) (struct sockaddr *dst_addr, int non_blocking,
uint64_t *ep_handle);
int (*ep_poll) (uint64_t ep_handle, int timeout_ms);
void (*ep_disconnect) (uint64_t ep_handle);
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment