Commit 8ea43b5a authored by James Simmons's avatar James Simmons Committed by Greg Kroah-Hartman
Browse files

staging: lustre: socklnd: change UAPI typedefs to proper structure



The upstream kernel requires proper structures so
convert all the UAPI typedefs in socklnd.h.

Signed-off-by: default avatarJames Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6142
Reviewed-on: https://review.whamcloud.com/18506


Reviewed-by: default avatarDmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: default avatarDoug Oucharek <doug.s.oucharek@intel.com>
Reviewed-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ccbadf70
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@

#define SOCKLND_CONN_ACK	SOCKLND_CONN_BULK_IN

typedef struct {
struct ksock_hello_msg {
	__u32		kshm_magic;	/* magic number of socklnd message */
	__u32		kshm_version;	/* version of socklnd message */
	lnet_nid_t      kshm_src_nid;	/* sender's nid */
@@ -57,9 +57,9 @@ typedef struct {
	__u32		kshm_ctype;	/* connection type */
	__u32		kshm_nips;	/* # IP addrs */
	__u32		kshm_ips[0];	/* IP addrs */
} WIRE_ATTR ksock_hello_msg_t;
} WIRE_ATTR;

typedef struct {
struct ksock_lnet_msg {
	struct lnet_hdr	ksnm_hdr;	/* lnet hdr */

	/*
@@ -68,17 +68,17 @@ typedef struct {
	 * structure definitions. lnet payload will be stored just after
	 * the body of structure ksock_lnet_msg_t
	 */
} WIRE_ATTR ksock_lnet_msg_t;
} WIRE_ATTR;

typedef struct {
struct ksock_msg {
	__u32	ksm_type;		/* type of socklnd message */
	__u32	ksm_csum;		/* checksum if != 0 */
	__u64	ksm_zc_cookies[2];	/* Zero-Copy request/ACK cookie */
	union {
		ksock_lnet_msg_t lnetmsg;/* lnet message, it's empty if
		struct ksock_lnet_msg lnetmsg; /* lnet message, it's empty if
					  * it's NOOP */
	} WIRE_ATTR ksm_u;
} WIRE_ATTR ksock_msg_t;
} WIRE_ATTR;

#define KSOCK_MSG_NOOP	0xC0	/* ksm_u empty */
#define KSOCK_MSG_LNET	0xC1	/* lnet msg */
+4 −4
Original line number Diff line number Diff line
@@ -1038,7 +1038,7 @@ ksocknal_create_conn(lnet_ni_t *ni, struct ksock_route *route,
	struct ksock_peer *peer = NULL;
	struct ksock_peer *peer2;
	struct ksock_sched *sched;
	ksock_hello_msg_t *hello;
	struct ksock_hello_msg *hello;
	int cpt;
	struct ksock_tx *tx;
	struct ksock_tx *txtmp;
@@ -1077,7 +1077,7 @@ ksocknal_create_conn(lnet_ni_t *ni, struct ksock_route *route,
	conn->ksnc_tx_carrier = NULL;
	atomic_set(&conn->ksnc_tx_nob, 0);

	LIBCFS_ALLOC(hello, offsetof(ksock_hello_msg_t,
	LIBCFS_ALLOC(hello, offsetof(struct ksock_hello_msg,
				     kshm_ips[LNET_MAX_INTERFACES]));
	if (!hello) {
		rc = -ENOMEM;
@@ -1341,7 +1341,7 @@ ksocknal_create_conn(lnet_ni_t *ni, struct ksock_route *route,
		rc = ksocknal_send_hello(ni, conn, peerid.nid, hello);
	}

	LIBCFS_FREE(hello, offsetof(ksock_hello_msg_t,
	LIBCFS_FREE(hello, offsetof(struct ksock_hello_msg,
				    kshm_ips[LNET_MAX_INTERFACES]));

	/*
@@ -1423,7 +1423,7 @@ ksocknal_create_conn(lnet_ni_t *ni, struct ksock_route *route,

failed_1:
	if (hello)
		LIBCFS_FREE(hello, offsetof(ksock_hello_msg_t,
		LIBCFS_FREE(hello, offsetof(struct ksock_hello_msg,
					    kshm_ips[LNET_MAX_INTERFACES]));

	LIBCFS_FREE(conn, sizeof(*conn));
+7 −7
Original line number Diff line number Diff line
@@ -287,7 +287,7 @@ struct ksock_tx { /* transmit packet */
	lnet_msg_t        *tx_lnetmsg;     /* lnet message for lnet_finalize()
					    */
	unsigned long     tx_deadline;     /* when (in jiffies) tx times out */
	ksock_msg_t       tx_msg;          /* socklnd message buffer */
	struct ksock_msg       tx_msg;          /* socklnd message buffer */
	int               tx_desc_size;    /* size of this descriptor */
	union {
		struct {
@@ -369,7 +369,7 @@ struct ksock_conn {
					       */
	void               *ksnc_cookie;      /* rx lnet_finalize passthru arg
					       */
	ksock_msg_t        ksnc_msg;          /* incoming message buffer:
	struct ksock_msg        ksnc_msg;          /* incoming message buffer:
					       * V2.x message takes the
					       * whole struct
					       * V1.x message is a bare
@@ -474,16 +474,16 @@ struct ksock_proto {
	int        pro_version;

	/* handshake function */
	int        (*pro_send_hello)(struct ksock_conn *, ksock_hello_msg_t *);
	int        (*pro_send_hello)(struct ksock_conn *, struct ksock_hello_msg *);

	/* handshake function */
	int        (*pro_recv_hello)(struct ksock_conn *, ksock_hello_msg_t *, int);
	int        (*pro_recv_hello)(struct ksock_conn *, struct ksock_hello_msg *, int);

	/* message pack */
	void       (*pro_pack)(struct ksock_tx *);

	/* message unpack */
	void       (*pro_unpack)(ksock_msg_t *);
	void       (*pro_unpack)(struct ksock_msg *);

	/* queue tx on the connection */
	struct ksock_tx *(*pro_queue_tx_msg)(struct ksock_conn *, struct ksock_tx *);
@@ -691,9 +691,9 @@ int ksocknal_scheduler(void *arg);
int ksocknal_connd(void *arg);
int ksocknal_reaper(void *arg);
int ksocknal_send_hello(lnet_ni_t *ni, struct ksock_conn *conn,
			lnet_nid_t peer_nid, ksock_hello_msg_t *hello);
			lnet_nid_t peer_nid, struct ksock_hello_msg *hello);
int ksocknal_recv_hello(lnet_ni_t *ni, struct ksock_conn *conn,
			ksock_hello_msg_t *hello, lnet_process_id_t *id,
			struct ksock_hello_msg *hello, lnet_process_id_t *id,
			__u64 *incarnation);
void ksocknal_read_callback(struct ksock_conn *conn);
void ksocknal_write_callback(struct ksock_conn *conn);
+11 −11
Original line number Diff line number Diff line
@@ -695,7 +695,7 @@ void
ksocknal_queue_tx_locked(struct ksock_tx *tx, struct ksock_conn *conn)
{
	struct ksock_sched *sched = conn->ksnc_scheduler;
	ksock_msg_t *msg = &tx->tx_msg;
	struct ksock_msg *msg = &tx->tx_msg;
	struct ksock_tx *ztx = NULL;
	int bufnob = 0;

@@ -1072,9 +1072,9 @@ ksocknal_new_packet(struct ksock_conn *conn, int nob_to_skip)
			conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space;
			conn->ksnc_rx_iov[0].iov_base = &conn->ksnc_msg;

			conn->ksnc_rx_nob_wanted = offsetof(ksock_msg_t, ksm_u);
			conn->ksnc_rx_nob_left = offsetof(ksock_msg_t, ksm_u);
			conn->ksnc_rx_iov[0].iov_len  = offsetof(ksock_msg_t, ksm_u);
			conn->ksnc_rx_nob_wanted = offsetof(struct ksock_msg, ksm_u);
			conn->ksnc_rx_nob_left = offsetof(struct ksock_msg, ksm_u);
			conn->ksnc_rx_iov[0].iov_len = offsetof(struct ksock_msg, ksm_u);
			break;

		case KSOCK_PROTO_V1:
@@ -1232,12 +1232,12 @@ ksocknal_process_receive(struct ksock_conn *conn)
		}

		conn->ksnc_rx_state = SOCKNAL_RX_LNET_HEADER;
		conn->ksnc_rx_nob_wanted = sizeof(ksock_lnet_msg_t);
		conn->ksnc_rx_nob_left = sizeof(ksock_lnet_msg_t);
		conn->ksnc_rx_nob_wanted = sizeof(struct ksock_lnet_msg);
		conn->ksnc_rx_nob_left = sizeof(struct ksock_lnet_msg);

		conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space;
		conn->ksnc_rx_iov[0].iov_base = &conn->ksnc_msg.ksm_u.lnetmsg;
		conn->ksnc_rx_iov[0].iov_len  = sizeof(ksock_lnet_msg_t);
		conn->ksnc_rx_iov[0].iov_len = sizeof(struct ksock_lnet_msg);

		conn->ksnc_rx_niov = 1;
		conn->ksnc_rx_kiov = NULL;
@@ -1633,7 +1633,7 @@ void ksocknal_write_callback(struct ksock_conn *conn)
}

static struct ksock_proto *
ksocknal_parse_proto_version(ksock_hello_msg_t *hello)
ksocknal_parse_proto_version(struct ksock_hello_msg *hello)
{
	__u32 version = 0;

@@ -1664,7 +1664,7 @@ ksocknal_parse_proto_version(ksock_hello_msg_t *hello)
		struct lnet_magicversion *hmv = (struct lnet_magicversion *)hello;

		BUILD_BUG_ON(sizeof(struct lnet_magicversion) !=
			 offsetof(ksock_hello_msg_t, kshm_src_nid));
			     offsetof(struct ksock_hello_msg, kshm_src_nid));

		if (hmv->version_major == cpu_to_le16(KSOCK_PROTO_V1_MAJOR) &&
		    hmv->version_minor == cpu_to_le16(KSOCK_PROTO_V1_MINOR))
@@ -1676,7 +1676,7 @@ ksocknal_parse_proto_version(ksock_hello_msg_t *hello)

int
ksocknal_send_hello(lnet_ni_t *ni, struct ksock_conn *conn,
		    lnet_nid_t peer_nid, ksock_hello_msg_t *hello)
		    lnet_nid_t peer_nid, struct ksock_hello_msg *hello)
{
	/* CAVEAT EMPTOR: this byte flips 'ipaddrs' */
	struct ksock_net *net = (struct ksock_net *)ni->ni_data;
@@ -1714,7 +1714,7 @@ ksocknal_invert_type(int type)

int
ksocknal_recv_hello(lnet_ni_t *ni, struct ksock_conn *conn,
		    ksock_hello_msg_t *hello, lnet_process_id_t *peerid,
		    struct ksock_hello_msg *hello, lnet_process_id_t *peerid,
		    __u64 *incarnation)
{
	/* Return < 0	fatal error
+19 −19
Original line number Diff line number Diff line
@@ -287,11 +287,11 @@ ksocknal_match_tx(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk)

	if (!tx || !tx->tx_lnetmsg) {
		/* noop packet */
		nob = offsetof(ksock_msg_t, ksm_u);
		nob = offsetof(struct ksock_msg, ksm_u);
	} else {
		nob = tx->tx_lnetmsg->msg_len +
		      ((conn->ksnc_proto == &ksocknal_protocol_v1x) ?
		       sizeof(struct lnet_hdr) : sizeof(ksock_msg_t));
		       sizeof(struct lnet_hdr) : sizeof(struct ksock_msg));
	}

	/* default checking for typed connection */
@@ -325,9 +325,9 @@ ksocknal_match_tx_v3(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk)
	int nob;

	if (!tx || !tx->tx_lnetmsg)
		nob = offsetof(ksock_msg_t, ksm_u);
		nob = offsetof(struct ksock_msg, ksm_u);
	else
		nob = tx->tx_lnetmsg->msg_len + sizeof(ksock_msg_t);
		nob = tx->tx_lnetmsg->msg_len + sizeof(struct ksock_msg);

	switch (conn->ksnc_type) {
	default:
@@ -456,7 +456,7 @@ ksocknal_handle_zcack(struct ksock_conn *conn, __u64 cookie1, __u64 cookie2)
}

static int
ksocknal_send_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello)
ksocknal_send_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello)
{
	struct socket *sock = conn->ksnc_sock;
	struct lnet_hdr *hdr;
@@ -531,7 +531,7 @@ ksocknal_send_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello)
}

static int
ksocknal_send_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello)
ksocknal_send_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello)
{
	struct socket *sock = conn->ksnc_sock;
	int rc;
@@ -549,7 +549,7 @@ ksocknal_send_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello)
		LNET_UNLOCK();
	}

	rc = lnet_sock_write(sock, hello, offsetof(ksock_hello_msg_t, kshm_ips),
	rc = lnet_sock_write(sock, hello, offsetof(struct ksock_hello_msg, kshm_ips),
			     lnet_acceptor_timeout());
	if (rc) {
		CNETERR("Error %d sending HELLO hdr to %pI4h/%d\n",
@@ -573,7 +573,7 @@ ksocknal_send_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello)
}

static int
ksocknal_recv_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello,
ksocknal_recv_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello,
		       int timeout)
{
	struct socket *sock = conn->ksnc_sock;
@@ -649,7 +649,7 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, ksock_hello_msg_t *hello,
}

static int
ksocknal_recv_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello,
ksocknal_recv_hello_v2(struct ksock_conn *conn, struct ksock_hello_msg *hello,
		       int timeout)
{
	struct socket *sock = conn->ksnc_sock;
@@ -662,8 +662,8 @@ ksocknal_recv_hello_v2(struct ksock_conn *conn, ksock_hello_msg_t *hello,
		conn->ksnc_flip = 1;

	rc = lnet_sock_read(sock, &hello->kshm_src_nid,
			    offsetof(ksock_hello_msg_t, kshm_ips) -
				     offsetof(ksock_hello_msg_t, kshm_src_nid),
			    offsetof(struct ksock_hello_msg, kshm_ips) -
				     offsetof(struct ksock_hello_msg, kshm_src_nid),
			    timeout);
	if (rc) {
		CERROR("Error %d reading HELLO from %pI4h\n",
@@ -738,15 +738,15 @@ ksocknal_pack_msg_v2(struct ksock_tx *tx)
		LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);

		tx->tx_msg.ksm_u.lnetmsg.ksnm_hdr = tx->tx_lnetmsg->msg_hdr;
		tx->tx_iov[0].iov_len = sizeof(ksock_msg_t);
		tx->tx_nob = sizeof(ksock_msg_t) + tx->tx_lnetmsg->msg_len;
		tx->tx_resid = sizeof(ksock_msg_t) + tx->tx_lnetmsg->msg_len;
		tx->tx_iov[0].iov_len = sizeof(struct ksock_msg);
		tx->tx_nob = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len;
		tx->tx_resid = sizeof(struct ksock_msg) + tx->tx_lnetmsg->msg_len;
	} else {
		LASSERT(tx->tx_msg.ksm_type == KSOCK_MSG_NOOP);

		tx->tx_iov[0].iov_len = offsetof(ksock_msg_t, ksm_u.lnetmsg.ksnm_hdr);
		tx->tx_nob = offsetof(ksock_msg_t,  ksm_u.lnetmsg.ksnm_hdr);
		tx->tx_resid = offsetof(ksock_msg_t,  ksm_u.lnetmsg.ksnm_hdr);
		tx->tx_iov[0].iov_len = offsetof(struct ksock_msg, ksm_u.lnetmsg.ksnm_hdr);
		tx->tx_nob = offsetof(struct ksock_msg,  ksm_u.lnetmsg.ksnm_hdr);
		tx->tx_resid = offsetof(struct ksock_msg,  ksm_u.lnetmsg.ksnm_hdr);
	}
	/*
	 * Don't checksum before start sending, because packet can be
@@ -755,7 +755,7 @@ ksocknal_pack_msg_v2(struct ksock_tx *tx)
}

static void
ksocknal_unpack_msg_v1(ksock_msg_t *msg)
ksocknal_unpack_msg_v1(struct ksock_msg *msg)
{
	msg->ksm_csum = 0;
	msg->ksm_type = KSOCK_MSG_LNET;
@@ -764,7 +764,7 @@ ksocknal_unpack_msg_v1(ksock_msg_t *msg)
}

static void
ksocknal_unpack_msg_v2(ksock_msg_t *msg)
ksocknal_unpack_msg_v2(struct ksock_msg *msg)
{
	return;  /* Do nothing */
}