Add icl_conn_connect() ICL method, required for iSER.

Obtained from:	Mellanox Technologies (earlier version)
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Edward Tomasz Napierala 2016-05-17 11:10:44 +00:00
parent 2a339d9e3d
commit f41492b00f
8 changed files with 53 additions and 27 deletions

View File

@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <sys/mutex.h>
#include <sys/queue.h>
#include <sys/sbuf.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/uio.h>

View File

@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/module.h>
#include <sys/queue.h>
#include <sys/sbuf.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/sx.h>

View File

@ -138,12 +138,6 @@ int icl_unregister(const char *offload);
struct sockaddr;
struct icl_listen;
/*
* Initiator part.
*/
int icl_conn_connect(struct icl_conn *ic, bool rdma,
int domain, int socktype, int protocol,
struct sockaddr *from_sa, struct sockaddr *to_sa);
/*
* Target part.
*/
@ -156,9 +150,11 @@ int icl_listen_add(struct icl_listen *il, bool rdma,
int icl_listen_remove(struct icl_listen *il, struct sockaddr *sa);
/*
* This one is not a public API; only to be used by icl_proxy.c.
* Those two are not a public API; only to be used between icl_soft.c and icl_proxy.c.
*/
int icl_conn_handoff_sock(struct icl_conn *ic, struct socket *so);
int icl_soft_handoff_sock(struct icl_conn *ic, struct socket *so);
int icl_soft_proxy_connect(struct icl_conn *ic, int domain,
int socktype, int protocol, struct sockaddr *from_sa,
struct sockaddr *to_sa);
#endif /* ICL_KERNEL_PROXY */
#endif /* !ICL_H */

View File

@ -29,6 +29,7 @@
# $FreeBSD$
#
#include <sys/socket.h>
#include <dev/iscsi/icl.h>
INTERFACE icl_conn;
@ -106,3 +107,15 @@ METHOD void transfer_done {
struct icl_conn *_ic;
void *_prv;
};
#
# The function below is only used with ICL_KERNEL_PROXY.
#
METHOD int connect {
struct icl_conn *_ic;
int _domain;
int _socktype;
int _protocol;
struct sockaddr *_from_sa;
struct sockaddr *_to_sa;
};

View File

@ -105,8 +105,8 @@ struct icl_listen {
static MALLOC_DEFINE(M_ICL_PROXY, "ICL_PROXY", "iSCSI common layer proxy");
static int
icl_conn_connect_tcp(struct icl_conn *ic, int domain, int socktype,
int
icl_soft_proxy_connect(struct icl_conn *ic, int domain, int socktype,
int protocol, struct sockaddr *from_sa, struct sockaddr *to_sa)
{
struct socket *so;
@ -153,26 +153,13 @@ icl_conn_connect_tcp(struct icl_conn *ic, int domain, int socktype,
return (error);
}
error = icl_conn_handoff_sock(ic, so);
error = icl_soft_handoff_sock(ic, so);
if (error != 0)
soclose(so);
return (error);
}
int
icl_conn_connect(struct icl_conn *ic, bool rdma, int domain, int socktype,
int protocol, struct sockaddr *from_sa, struct sockaddr *to_sa)
{
if (rdma) {
ICL_DEBUG("RDMA not supported");
return (EOPNOTSUPP);
}
return (icl_conn_connect_tcp(ic, domain, socktype, protocol, from_sa, to_sa));
}
struct icl_listen *
icl_listen_new(void (*accept_cb)(struct socket *, struct sockaddr *, int))
{

View File

@ -101,6 +101,9 @@ static icl_conn_task_setup_t icl_soft_conn_task_setup;
static icl_conn_task_done_t icl_soft_conn_task_done;
static icl_conn_transfer_setup_t icl_soft_conn_transfer_setup;
static icl_conn_transfer_done_t icl_soft_conn_transfer_done;
#ifdef ICL_KERNEL_PROXY
static icl_conn_connect_t icl_soft_conn_connect;
#endif
static kobj_method_t icl_soft_methods[] = {
KOBJMETHOD(icl_conn_new_pdu, icl_soft_conn_new_pdu),
@ -117,6 +120,9 @@ static kobj_method_t icl_soft_methods[] = {
KOBJMETHOD(icl_conn_task_done, icl_soft_conn_task_done),
KOBJMETHOD(icl_conn_transfer_setup, icl_soft_conn_transfer_setup),
KOBJMETHOD(icl_conn_transfer_done, icl_soft_conn_transfer_done),
#ifdef ICL_KERNEL_PROXY
KOBJMETHOD(icl_conn_connect, icl_soft_conn_connect),
#endif
{ 0, 0 }
};
@ -1460,7 +1466,16 @@ icl_soft_limits(size_t *limitp)
#ifdef ICL_KERNEL_PROXY
int
icl_conn_handoff_sock(struct icl_conn *ic, struct socket *so)
icl_soft_conn_connect(struct icl_conn *ic, int domain, int socktype,
int protocol, struct sockaddr *from_sa, struct sockaddr *to_sa)
{
return (icl_soft_proxy_connect(ic, domain, socktype, protocol,
from_sa, to_sa));
}
int
icl_soft_handoff_sock(struct icl_conn *ic, struct socket *so)
{
int error;

View File

@ -135,4 +135,16 @@ icl_conn_transfer_done(struct icl_conn *ic, void *prv)
ICL_CONN_TRANSFER_DONE(ic, prv);
}
/*
* The function below is only used with ICL_KERNEL_PROXY.
*/
static inline int
icl_conn_connect(struct icl_conn *ic, int domain, int socktype,
int protocol, struct sockaddr *from_sa, struct sockaddr *to_sa)
{
return (ICL_CONN_CONNECT(ic, domain, socktype, protocol,
from_sa, to_sa));
}
#endif /* !ICL_WRAPPERS_H */

View File

@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/module.h>
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/sx.h>
@ -1559,7 +1560,7 @@ iscsi_ioctl_daemon_connect(struct iscsi_softc *sc,
is->is_timeout = 0;
ISCSI_SESSION_UNLOCK(is);
error = icl_conn_connect(is->is_conn, idc->idc_iser, idc->idc_domain,
error = icl_conn_connect(is->is_conn, idc->idc_domain,
idc->idc_socktype, idc->idc_protocol, from_sa, to_sa);
free(from_sa, M_SONAME);
free(to_sa, M_SONAME);