((1U << the_lnet.ln_remote_nets_hbits) - 1)];
}
+static inline void lnet_hdr_from_nid4(struct lnet_hdr *hdr,
+ const struct lnet_hdr_nid4 *vhdr)
+{
+ const struct _lnet_hdr_nid4 *hdr_nid4 = (void *)vhdr;
+
+ hdr->dest_nid = le64_to_cpu(hdr_nid4->dest_nid);
+ hdr->src_nid = le64_to_cpu(hdr_nid4->src_nid);
+ hdr->dest_pid = le32_to_cpu(hdr_nid4->dest_pid);
+ hdr->src_pid = le32_to_cpu(hdr_nid4->src_pid);
+ hdr->type = le32_to_cpu(hdr_nid4->type);
+ hdr->payload_length = le32_to_cpu(hdr_nid4->payload_length);
+
+ hdr->msg = hdr_nid4->msg;
+}
+
+static inline void lnet_hdr_to_nid4(const struct lnet_hdr *hdr,
+ struct lnet_hdr_nid4 *vhdr)
+{
+ struct _lnet_hdr_nid4 *hdr_nid4 = (void *)vhdr;
+
+ hdr_nid4->dest_nid = cpu_to_le64(hdr->dest_nid);
+ hdr_nid4->src_nid = cpu_to_le64(hdr->src_nid);
+ hdr_nid4->dest_pid = cpu_to_le32(hdr->dest_pid);
+ hdr_nid4->src_pid = cpu_to_le32(hdr->src_pid);
+ hdr_nid4->type = cpu_to_le32(hdr->type);
+ hdr_nid4->payload_length = cpu_to_le32(hdr->payload_length);
+
+ hdr_nid4->msg = hdr->msg;
+}
+
extern const struct lnet_lnd the_lolnd;
extern int avoid_asym_router_failure;
/* case ksm_kh.ksh_type == KSOCK_MSG_NOOP */
/* - nothing */
/* case ksm_kh.ksh_type == KSOCK_MSG_LNET */
- struct lnet_hdr lnetmsg;
+ struct lnet_hdr_nid4 lnetmsg_nid4;
} __packed ksm_u;
} __packed;
#define ksm_type ksm_kh.ksh_type
__u32 type;
} __attribute__((packed));
+union lnet_cmd_hdr {
+ struct lnet_ack ack;
+ struct lnet_put put;
+ struct lnet_get get;
+ struct lnet_reply reply;
+ struct lnet_hello hello;
+} __attribute__((packed));
+
+/* This is used for message headers that lnet code is manipulating.
+ * All fields before the union are in host-byte-order.
+ */
struct lnet_hdr {
+ lnet_nid_t dest_nid;
+ lnet_nid_t src_nid;
+ lnet_pid_t dest_pid;
+ lnet_pid_t src_pid;
+ __u32 type; /* enum lnet_msg_type */
+ __u32 payload_length; /* payload data to follow */
+ /*<------__u64 aligned------->*/
+ union lnet_cmd_hdr msg;
+} __attribute__((packed));
+
+/* This is used to support conversion between an lnet_hdr and
+ * the content of a network message.
+ */
+struct _lnet_hdr_nid4 {
lnet_nid_t dest_nid;
lnet_nid_t src_nid;
lnet_pid_t dest_pid;
__u32 type; /* enum lnet_msg_type */
__u32 payload_length; /* payload data to follow */
/*<------__u64 aligned------->*/
- union {
- struct lnet_ack ack;
- struct lnet_put put;
- struct lnet_get get;
- struct lnet_reply reply;
- struct lnet_hello hello;
- } msg;
+ union lnet_cmd_hdr msg;
+} __attribute__((packed));
+
+/* This is stored in a network message buffer. Content cannot be accessed
+ * without converting to an lnet_hdr.
+ */
+struct lnet_hdr_nid4 {
+ char _bytes[sizeof(struct _lnet_hdr_nid4)];
} __attribute__((packed));
/* A HELLO message contains a magic number and protocol version
} __packed kgn_rdma_desc_t;
typedef struct {
- struct lnet_hdr gnim_hdr; /* LNet header */
+ struct lnet_hdr_nid4 gnim_hdr; /* LNet header */
/* LNet payload is in FMA "Message Data" */
} __packed kgn_immediate_msg_t;
typedef struct {
- struct lnet_hdr gnprm_hdr; /* LNet header */
- __u64 gnprm_cookie; /* opaque completion cookie */
+ struct lnet_hdr_nid4 gnprm_hdr; /* LNet header */
+ __u64 gnprm_cookie; /* opaque completion cookie */
} __packed kgn_putreq_msg_t;
typedef struct {
} __packed kgn_putack_msg_t;
typedef struct {
- struct lnet_hdr gngm_hdr; /* LNet header */
- __u64 gngm_cookie; /* opaque completion cookie */
- __u16 gngm_payload_cksum; /* checksum for put msg */
- kgn_rdma_desc_t gngm_desc; /* sender's sink buffer */
+ struct lnet_hdr_nid4 gngm_hdr; /* LNet header */
+ __u64 gngm_cookie; /* opaque completion cookie */
+ __u16 gngm_payload_cksum; /* checksum for put msg */
+ kgn_rdma_desc_t gngm_desc; /* sender's sink buffer */
} __packed kgn_get_msg_t;
typedef struct {
tx->tx_lntmsg[0] = lntmsg;
if ((reverse_rdma_flag & GNILND_REVERSE_GET) == 0)
- tx->tx_msg.gnm_u.get.gngm_hdr = *hdr;
+ lnet_hdr_to_nid4(hdr, &tx->tx_msg.gnm_u.get.gngm_hdr);
else
- tx->tx_msg.gnm_u.putreq.gnprm_hdr = *hdr;
+ lnet_hdr_to_nid4(hdr,
+ &tx->tx_msg.gnm_u.putreq.gnprm_hdr);
/* rest of tx_msg is setup just before it is sent */
kgnilnd_launch_tx(tx, net, target);
tx->tx_lntmsg[0] = lntmsg;
if ((reverse_rdma_flag & GNILND_REVERSE_PUT) == 0)
- tx->tx_msg.gnm_u.putreq.gnprm_hdr = *hdr;
+ lnet_hdr_to_nid4(hdr,
+ &tx->tx_msg.gnm_u.putreq.gnprm_hdr);
else
- tx->tx_msg.gnm_u.get.gngm_hdr = *hdr;
+ lnet_hdr_to_nid4(hdr, &tx->tx_msg.gnm_u.get.gngm_hdr);
/* rest of tx_msg is setup just before it is sent */
kgnilnd_launch_tx(tx, net, target);
goto out;
}
- tx->tx_msg.gnm_u.immediate.gnim_hdr = *hdr;
+ lnet_hdr_to_nid4(hdr, &tx->tx_msg.gnm_u.immediate.gnim_hdr);
tx->tx_lntmsg[0] = lntmsg;
kgnilnd_launch_tx(tx, net, target);
int repost = 1, saw_complete;
unsigned long timestamp, newest_last_rx, timeout;
int last_seq;
+ struct lnet_hdr hdr;
ENTRY;
/* Short circuit if the ep_handle is null.
case GNILND_MSG_IMMEDIATE:
/* only get SMSG payload for IMMEDIATE */
atomic64_add(msg->gnm_payload_len, &conn->gnc_device->gnd_short_rxbytes);
- rc = lnet_parse(net->gnn_ni, &msg->gnm_u.immediate.gnim_hdr,
- msg->gnm_srcnid, rx, 0);
+ lnet_hdr_from_nid4(&hdr, &msg->gnm_u.immediate.gnim_hdr);
+ rc = lnet_parse(net->gnn_ni, &hdr, msg->gnm_srcnid, rx, 0);
repost = rc < 0;
break;
case GNILND_MSG_GET_REQ_REV:
case GNILND_MSG_PUT_REQ:
- rc = lnet_parse(net->gnn_ni, &msg->gnm_u.putreq.gnprm_hdr,
- msg->gnm_srcnid, rx, 1);
+ lnet_hdr_from_nid4(&hdr, &msg->gnm_u.putreq.gnprm_hdr);
+ rc = lnet_parse(net->gnn_ni, &hdr, msg->gnm_srcnid, rx, 1);
repost = rc < 0;
break;
case GNILND_MSG_GET_NAK_REV:
break;
case GNILND_MSG_PUT_REQ_REV:
case GNILND_MSG_GET_REQ:
- rc = lnet_parse(net->gnn_ni, &msg->gnm_u.get.gngm_hdr,
- msg->gnm_srcnid, rx, 1);
+ lnet_hdr_from_nid4(&hdr, &msg->gnm_u.get.gngm_hdr);
+ rc = lnet_parse(net->gnn_ni, &hdr, msg->gnm_srcnid, rx, 1);
repost = rc < 0;
break;
} __packed;
struct kib_immediate_msg {
- struct lnet_hdr ibim_hdr; /* portals header */
+ struct lnet_hdr_nid4 ibim_hdr; /* portals header */
char ibim_payload[0];/* piggy-backed payload */
} __packed;
} __packed;
struct kib_putreq_msg {
- struct lnet_hdr ibprm_hdr; /* portals header */
+ struct lnet_hdr_nid4 ibprm_hdr; /* portals header */
u64 ibprm_cookie; /* opaque completion cookie */
} __packed;
} __packed;
struct kib_get_msg {
- struct lnet_hdr ibgm_hdr; /* portals header */
+ struct lnet_hdr_nid4 ibgm_hdr; /* portals header */
u64 ibgm_cookie; /* opaque completion cookie */
struct kib_rdma_desc ibgm_rd; /* rdma descriptor */
} __packed;
kiblnd_handle_rx(struct kib_rx *rx)
{
struct kib_msg *msg = rx->rx_msg;
- struct kib_conn *conn = rx->rx_conn;
+ struct kib_conn *conn = rx->rx_conn;
struct lnet_ni *ni = conn->ibc_peer->ibp_ni;
- int credits = msg->ibm_credits;
+ int credits = msg->ibm_credits;
struct kib_tx *tx;
- int rc = 0;
- int rc2;
- int post_credit;
+ int rc = 0;
+ int rc2;
+ int post_credit;
+ struct lnet_hdr hdr;
LASSERT (conn->ibc_state >= IBLND_CONN_ESTABLISHED);
post_credit = IBLND_POSTRX_PEER_CREDIT;
break;
- case IBLND_MSG_IMMEDIATE:
- post_credit = IBLND_POSTRX_DONT_POST;
- rc = lnet_parse(ni, &msg->ibm_u.immediate.ibim_hdr,
- msg->ibm_srcnid, rx, 0);
- if (rc < 0) /* repost on error */
- post_credit = IBLND_POSTRX_PEER_CREDIT;
- break;
+ case IBLND_MSG_IMMEDIATE:
+ post_credit = IBLND_POSTRX_DONT_POST;
+ lnet_hdr_from_nid4(&hdr, &msg->ibm_u.immediate.ibim_hdr);
+ rc = lnet_parse(ni, &hdr, msg->ibm_srcnid, rx, 0);
+ if (rc < 0) /* repost on error */
+ post_credit = IBLND_POSTRX_PEER_CREDIT;
+ break;
- case IBLND_MSG_PUT_REQ:
- post_credit = IBLND_POSTRX_DONT_POST;
- rc = lnet_parse(ni, &msg->ibm_u.putreq.ibprm_hdr,
- msg->ibm_srcnid, rx, 1);
- if (rc < 0) /* repost on error */
- post_credit = IBLND_POSTRX_PEER_CREDIT;
- break;
+ case IBLND_MSG_PUT_REQ:
+ post_credit = IBLND_POSTRX_DONT_POST;
+ lnet_hdr_from_nid4(&hdr, &msg->ibm_u.putreq.ibprm_hdr);
+ rc = lnet_parse(ni, &hdr, msg->ibm_srcnid, rx, 1);
+ if (rc < 0) /* repost on error */
+ post_credit = IBLND_POSTRX_PEER_CREDIT;
+ break;
case IBLND_MSG_PUT_NAK:
CWARN ("PUT_NACK from %s\n",
msg->ibm_u.completion.ibcm_cookie);
break;
- case IBLND_MSG_GET_REQ:
- post_credit = IBLND_POSTRX_DONT_POST;
- rc = lnet_parse(ni, &msg->ibm_u.get.ibgm_hdr,
- msg->ibm_srcnid, rx, 1);
- if (rc < 0) /* repost on error */
- post_credit = IBLND_POSTRX_PEER_CREDIT;
- break;
+ case IBLND_MSG_GET_REQ:
+ post_credit = IBLND_POSTRX_DONT_POST;
+ lnet_hdr_from_nid4(&hdr, &msg->ibm_u.get.ibgm_hdr);
+ rc = lnet_parse(ni, &hdr, msg->ibm_srcnid, rx, 1);
+ if (rc < 0) /* repost on error */
+ post_credit = IBLND_POSTRX_PEER_CREDIT;
+ break;
case IBLND_MSG_GET_DONE:
post_credit = IBLND_POSTRX_RSRVD_CREDIT;
nob = offsetof(struct kib_get_msg, ibgm_rd.rd_frags[rd->rd_nfrags]);
ibmsg->ibm_u.get.ibgm_cookie = tx->tx_cookie;
- ibmsg->ibm_u.get.ibgm_hdr = *hdr;
+ lnet_hdr_to_nid4(hdr, &ibmsg->ibm_u.get.ibgm_hdr);
kiblnd_init_tx_msg(ni, tx, IBLND_MSG_GET_REQ, nob);
return -EIO;
}
- ibmsg->ibm_u.putreq.ibprm_hdr = *hdr;
+ lnet_hdr_to_nid4(hdr, &ibmsg->ibm_u.putreq.ibprm_hdr);
ibmsg->ibm_u.putreq.ibprm_cookie = tx->tx_cookie;
kiblnd_init_tx_msg(ni, tx, IBLND_MSG_PUT_REQ,
sizeof(struct kib_putreq_msg));
<= IBLND_MSG_SIZE);
ibmsg = tx->tx_msg;
- ibmsg->ibm_u.immediate.ibim_hdr = *hdr;
+ lnet_hdr_to_nid4(hdr, &ibmsg->ibm_u.immediate.ibim_hdr);
lnet_copy_kiov2flat(IBLND_MSG_SIZE, ibmsg,
offsetof(struct kib_msg,
switch (rxmsg->ibm_type) {
default:
LBUG();
-
- case IBLND_MSG_IMMEDIATE:
+ /* fallthrough */
+ case IBLND_MSG_IMMEDIATE:
nob = offsetof(struct kib_msg, ibm_u.immediate.ibim_payload[rlen]);
- if (nob > rx->rx_nob) {
- CERROR ("Immediate message from %s too big: %d(%d)\n",
- libcfs_nid2str(rxmsg->ibm_u.immediate.ibim_hdr.src_nid),
- nob, rx->rx_nob);
- rc = -EPROTO;
- break;
- }
+ if (nob > rx->rx_nob) {
+ CERROR("Immediate message from %s too big: %d(%d)\n",
+ libcfs_nid2str(lntmsg->msg_hdr.src_nid),
+ nob, rx->rx_nob);
+ rc = -EPROTO;
+ break;
+ }
lnet_copy_flat2kiov(niov, kiov, offset,
IBLND_MSG_SIZE, rxmsg,
* V2.x message takes the
* whole struct
* V1.x message is a bare
- * struct lnet_hdr, it's stored
- * in ksnc_msg.ksm_u.lnetmsg
+ * struct lnet_hdr_nid4, it's
+ * stored in
+ * ksnc_msg.ksm_u.lnetmsg
*/
/* -- WRITER -- */
/* where I enq waiting for output space */
break;
case KSOCK_PROTO_V1:
- /* Receiving bare struct lnet_hdr */
+ /* Receiving bare struct lnet_hdr_nid4 */
conn->ksnc_rx_state = SOCKNAL_RX_LNET_HEADER;
- conn->ksnc_rx_nob_wanted = sizeof(struct lnet_hdr);
- conn->ksnc_rx_nob_left = sizeof(struct lnet_hdr);
+ conn->ksnc_rx_nob_wanted = sizeof(struct lnet_hdr_nid4);
+ conn->ksnc_rx_nob_left = sizeof(struct lnet_hdr_nid4);
conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space;
- conn->ksnc_rx_iov[0].iov_base = (char *)&conn->ksnc_msg.ksm_u.lnetmsg;
- conn->ksnc_rx_iov[0].iov_len = sizeof(struct lnet_hdr);
- break;
+ conn->ksnc_rx_iov[0].iov_base =
+ (void *)&conn->ksnc_msg.ksm_u.lnetmsg_nid4;
+ conn->ksnc_rx_iov[0].iov_len =
+ sizeof(struct lnet_hdr_nid4);
+ break;
- default:
- LBUG ();
- }
+ default:
+ LBUG();
+ }
conn->ksnc_rx_niov = 1;
conn->ksnc_rx_kiov = NULL;
struct page **rx_scratch_pgs,
struct kvec *scratch_iov)
{
- struct lnet_hdr *lhdr;
+ struct _lnet_hdr_nid4 *lhdr;
struct lnet_processid *id;
+ struct lnet_hdr hdr;
int rc;
LASSERT(refcount_read(&conn->ksnc_conn_refcount) > 0);
case KSOCK_MSG_LNET:
conn->ksnc_rx_state = SOCKNAL_RX_LNET_HEADER;
- conn->ksnc_rx_nob_wanted = sizeof(struct lnet_hdr);
- conn->ksnc_rx_nob_left = sizeof(struct lnet_hdr);
+ conn->ksnc_rx_nob_wanted = sizeof(struct lnet_hdr_nid4);
+ conn->ksnc_rx_nob_left = sizeof(struct lnet_hdr_nid4);
conn->ksnc_rx_iov = conn->ksnc_rx_iov_space.iov;
conn->ksnc_rx_iov[0].iov_base =
- (void *)&conn->ksnc_msg.ksm_u.lnetmsg;
- conn->ksnc_rx_iov[0].iov_len = sizeof(struct lnet_hdr);
+ (void *)&conn->ksnc_msg.ksm_u.lnetmsg_nid4;
+ conn->ksnc_rx_iov[0].iov_len =
+ sizeof(struct lnet_hdr_nid4);
conn->ksnc_rx_niov = 1;
conn->ksnc_rx_kiov = NULL;
/* unpack message header */
conn->ksnc_proto->pro_unpack(&conn->ksnc_msg);
+ lnet_hdr_from_nid4(&hdr, &conn->ksnc_msg.ksm_u.lnetmsg_nid4);
+
if ((conn->ksnc_peer->ksnp_id.pid & LNET_PID_USERFLAG) != 0) {
/* Userspace peer_ni */
- lhdr = &conn->ksnc_msg.ksm_u.lnetmsg;
id = &conn->ksnc_peer->ksnp_id;
/* Substitute process ID assigned at connection time */
- lhdr->src_pid = cpu_to_le32(id->pid);
- lhdr->src_nid = cpu_to_le64(lnet_nid_to_nid4(&id->nid));
+ hdr.src_pid = id->pid;
+ hdr.src_nid = lnet_nid_to_nid4(&id->nid);
}
conn->ksnc_rx_state = SOCKNAL_RX_PARSE;
ksocknal_conn_addref(conn); /* ++ref while parsing */
+
rc = lnet_parse(conn->ksnc_peer->ksnp_ni,
- &conn->ksnc_msg.ksm_u.lnetmsg,
+ &hdr,
lnet_nid_to_nid4(&conn->ksnc_peer->ksnp_id.nid),
conn, 0);
if (rc < 0) {
if (rc == 0 && conn->ksnc_msg.ksm_zc_cookies[0] != 0) {
LASSERT(conn->ksnc_proto != &ksocknal_protocol_v1x);
- lhdr = &conn->ksnc_msg.ksm_u.lnetmsg;
+ lhdr = (void *)&conn->ksnc_msg.ksm_u.lnetmsg_nid4;
id = &conn->ksnc_peer->ksnp_id;
rc = conn->ksnc_proto->pro_handle_zcreq(
nob = tx->tx_lnetmsg->msg_len +
((conn->ksnc_proto == &ksocknal_protocol_v1x) ?
0 : sizeof(struct ksock_msg_hdr)) +
- sizeof(struct lnet_hdr);
+ sizeof(struct lnet_hdr_nid4);
}
/* default checking for typed connection */
if (tx == NULL || tx->tx_lnetmsg == NULL)
nob = sizeof(struct ksock_msg_hdr);
else
- nob = sizeof(struct ksock_msg_hdr) + sizeof(struct lnet_hdr) +
+ nob = sizeof(struct ksock_msg_hdr) +
+ sizeof(struct lnet_hdr_nid4) +
tx->tx_lnetmsg->msg_len;
switch (conn->ksnc_type) {
ksocknal_send_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello)
{
struct socket *sock = conn->ksnc_sock;
- struct lnet_hdr *hdr;
+ struct _lnet_hdr_nid4 *hdr;
struct lnet_magicversion *hmv;
int rc;
int i;
BUILD_BUG_ON(sizeof(struct lnet_magicversion) !=
- offsetof(struct lnet_hdr, src_nid));
+ offsetof(struct _lnet_hdr_nid4, src_nid));
LIBCFS_ALLOC(hdr, sizeof(*hdr));
if (hdr == NULL) {
- CERROR("Can't allocate struct lnet_hdr\n");
+ CERROR("Can't allocate struct lnet_hdr_nid4\n");
return -ENOMEM;
}
hmv = (struct lnet_magicversion *)&hdr->dest_nid;
- /* Re-organize V2.x message header to V1.x (struct lnet_hdr)
- * header and send out */
- hmv->magic = cpu_to_le32 (LNET_PROTO_TCP_MAGIC);
- hmv->version_major = cpu_to_le16 (KSOCK_PROTO_V1_MAJOR);
- hmv->version_minor = cpu_to_le16 (KSOCK_PROTO_V1_MINOR);
+ /* Re-organize V2.x message header to V1.x (struct lnet_hdr_nid4)
+ * header and send out
+ */
+ hmv->magic = cpu_to_le32 (LNET_PROTO_TCP_MAGIC);
+ hmv->version_major = cpu_to_le16 (KSOCK_PROTO_V1_MAJOR);
+ hmv->version_minor = cpu_to_le16 (KSOCK_PROTO_V1_MINOR);
if (the_lnet.ln_testprotocompat) {
/* single-shot proto check */
int timeout)
{
struct socket *sock = conn->ksnc_sock;
- struct lnet_hdr *hdr;
+ struct _lnet_hdr_nid4 *hdr;
int rc;
int i;
LIBCFS_ALLOC(hdr, sizeof(*hdr));
if (hdr == NULL) {
- CERROR("Can't allocate struct lnet_hdr\n");
+ CERROR("Can't allocate struct lnet_hdr_nid4\n");
return -ENOMEM;
}
rc = lnet_sock_read(sock, &hdr->src_nid,
- sizeof(*hdr) - offsetof(struct lnet_hdr, src_nid),
+ sizeof(*hdr) - offsetof(struct _lnet_hdr_nid4,
+ src_nid),
timeout);
if (rc != 0) {
CERROR("Error %d reading rest of HELLO hdr from %pIS\n",
LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
LASSERT(tx->tx_lnetmsg != NULL);
- tx->tx_hdr.iov_base = (void *)&tx->tx_lnetmsg->msg_hdr;
- tx->tx_hdr.iov_len = sizeof(struct lnet_hdr);
+ lnet_hdr_to_nid4(&tx->tx_lnetmsg->msg_hdr,
+ &tx->tx_msg.ksm_u.lnetmsg_nid4);
+ tx->tx_hdr.iov_base = (void *)&tx->tx_msg.ksm_u.lnetmsg_nid4;
+ tx->tx_hdr.iov_len = sizeof(struct lnet_hdr_nid4);
- tx->tx_nob = tx->tx_lnetmsg->msg_len + sizeof(struct lnet_hdr);
+ tx->tx_nob = tx->tx_lnetmsg->msg_len + sizeof(struct lnet_hdr_nid4);
tx->tx_resid = tx->tx_nob;
}
case KSOCK_MSG_LNET:
LASSERT(tx->tx_lnetmsg != NULL);
hdr_size = (sizeof(struct ksock_msg_hdr) +
- sizeof(struct lnet_hdr));
+ sizeof(struct lnet_hdr_nid4));
- tx->tx_msg.ksm_u.lnetmsg = tx->tx_lnetmsg->msg_hdr;
+ lnet_hdr_to_nid4(&tx->tx_lnetmsg->msg_hdr,
+ &tx->tx_msg.ksm_u.lnetmsg_nid4);
tx->tx_hdr.iov_len = hdr_size;
tx->tx_resid = tx->tx_nob = hdr_size + tx->tx_lnetmsg->msg_len;
break;
version_minor) != 6);
BUILD_BUG_ON((int)sizeof(((struct lnet_magicversion *)0)->version_minor) != 2);
- /* Checks for struct struct lnet_hdr */
- BUILD_BUG_ON((int)sizeof(struct lnet_hdr) != 72);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, dest_nid) != 0);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->dest_nid) != 8);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, src_nid) != 8);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->src_nid) != 8);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, dest_pid) != 16);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->dest_pid) != 4);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, src_pid) != 20);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->src_pid) != 4);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, type) != 24);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->type) != 4);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, payload_length) != 28);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->payload_length) != 4);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg) != 32);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg) != 40);
+ /* Checks for struct _lnet_hdr_nid4 */
+ BUILD_BUG_ON((int)sizeof(struct _lnet_hdr_nid4) != 72);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, dest_nid) != 0);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->dest_nid) != 8);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, src_nid) != 8);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->src_nid) != 8);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, dest_pid) != 16);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->dest_pid) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, src_pid) != 20);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->src_pid) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, type) != 24);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->type) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, payload_length) != 28);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->payload_length) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg) != 32);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg) != 40);
/* Ack */
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.dst_wmd) != 32);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.dst_wmd) != 16);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.match_bits) != 48);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.match_bits) != 8);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.ack.mlength) != 56);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.ack.mlength) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.ack.dst_wmd) != 32);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.ack.dst_wmd) != 16);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.ack.match_bits) != 48);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.ack.match_bits) != 8);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.ack.mlength) != 56);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.ack.mlength) != 4);
/* Put */
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.ack_wmd) != 32);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.ack_wmd) != 16);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.match_bits) != 48);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.match_bits) != 8);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.hdr_data) != 56);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.hdr_data) != 8);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.ptl_index) != 64);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.ptl_index) != 4);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.put.offset) != 68);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.put.offset) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.put.ack_wmd) != 32);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.put.ack_wmd) != 16);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.put.match_bits) != 48);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.put.match_bits) != 8);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.put.hdr_data) != 56);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.put.hdr_data) != 8);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.put.ptl_index) != 64);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.put.ptl_index) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.put.offset) != 68);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.put.offset) != 4);
/* Get */
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.return_wmd) != 32);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.return_wmd) != 16);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.match_bits) != 48);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.match_bits) != 8);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.ptl_index) != 56);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.ptl_index) != 4);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.src_offset) != 60);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.src_offset) != 4);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.get.sink_length) != 64);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.get.sink_length) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.get.return_wmd) != 32);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.get.return_wmd) != 16);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.get.match_bits) != 48);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.get.match_bits) != 8);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.get.ptl_index) != 56);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.get.ptl_index) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.get.src_offset) != 60);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.get.src_offset) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.get.sink_length) != 64);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.get.sink_length) != 4);
/* Reply */
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.reply.dst_wmd) != 32);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.reply.dst_wmd) != 16);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.reply.dst_wmd) != 32);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.reply.dst_wmd) != 16);
/* Hello */
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.hello.incarnation) != 32);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.hello.incarnation) != 8);
- BUILD_BUG_ON((int)offsetof(struct lnet_hdr, msg.hello.type) != 40);
- BUILD_BUG_ON((int)sizeof(((struct lnet_hdr *)0)->msg.hello.type) != 4);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.hello.incarnation) != 32);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.hello.incarnation) != 8);
+ BUILD_BUG_ON((int)offsetof(struct _lnet_hdr_nid4, msg.hello.type) != 40);
+ BUILD_BUG_ON((int)sizeof(((struct _lnet_hdr_nid4 *)0)->msg.hello.type) != 4);
/* Checks for struct lnet_ni_status and related constants */
BUILD_BUG_ON(LNET_NI_STATUS_INVALID != 0x00000000);
lnet_setpayloadbuffer(msg);
memset (&msg->msg_hdr, 0, sizeof (msg->msg_hdr));
- msg->msg_hdr.type = cpu_to_le32(type);
+ msg->msg_hdr.type = type;
/* dest_nid will be overwritten by lnet_select_pathway() */
- msg->msg_hdr.dest_nid = cpu_to_le64(target.nid);
- msg->msg_hdr.dest_pid = cpu_to_le32(target.pid);
+ msg->msg_hdr.dest_nid = target.nid;
+ msg->msg_hdr.dest_pid = target.pid;
/* src_nid will be set later */
- msg->msg_hdr.src_pid = cpu_to_le32(the_lnet.ln_pid);
- msg->msg_hdr.payload_length = cpu_to_le32(len);
+ msg->msg_hdr.src_pid = the_lnet.ln_pid;
+ msg->msg_hdr.payload_length = len;
}
void
!list_empty(&lp->lpni_txq));
msg->msg_peertxcredit = 1;
- lp->lpni_txqnob += msg->msg_len + sizeof(struct lnet_hdr);
+ lp->lpni_txqnob += msg->msg_len + sizeof(struct lnet_hdr_nid4);
lp->lpni_txcredits--;
if (lp->lpni_txcredits < lp->lpni_mintxcredits)
LASSERT((txpeer->lpni_txcredits < 0) ==
!list_empty(&txpeer->lpni_txq));
- txpeer->lpni_txqnob -= msg->msg_len + sizeof(struct lnet_hdr);
+ txpeer->lpni_txqnob -= msg->msg_len +
+ sizeof(struct lnet_hdr_nid4);
LASSERT(txpeer->lpni_txqnob >= 0);
txpeer->lpni_txcredits++;
/* No send credit hassles with LOLND */
lnet_ni_addref_locked(the_lnet.ln_loni, cpt);
msg->msg_hdr.dest_nid =
- cpu_to_le64(lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid));
+ lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid);
if (!msg->msg_routing)
msg->msg_hdr.src_nid =
- cpu_to_le64(lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid));
+ lnet_nid_to_nid4(&the_lnet.ln_loni->ni_nid);
msg->msg_target.nid = the_lnet.ln_loni->ni_nid;
lnet_msg_commit(msg, cpt);
msg->msg_txni = the_lnet.ln_loni;
*/
if (!msg->msg_routing)
msg->msg_hdr.src_nid =
- cpu_to_le64(lnet_nid_to_nid4(&msg->msg_txni->ni_nid));
+ lnet_nid_to_nid4(&msg->msg_txni->ni_nid);
if (routing) {
msg->msg_target_is_router = 1;
*/
/* FIXME handle large-addr nid */
msg->msg_hdr.dest_nid =
- cpu_to_le64(lnet_nid_to_nid4(&final_dst_lpni->lpni_nid));
+ lnet_nid_to_nid4(&final_dst_lpni->lpni_nid);
} else {
/*
* if we're not routing set the dest_nid to the best peer
* ni NID that we picked earlier in the algorithm.
*/
msg->msg_hdr.dest_nid =
- cpu_to_le64(lnet_nid_to_nid4(&msg->msg_txpeer->lpni_nid));
+ lnet_nid_to_nid4(&msg->msg_txpeer->lpni_nid);
}
/*
lnet_nid4_to_nid(from_nid4, &from_nid);
- type = le32_to_cpu(hdr->type);
- src_nid = le64_to_cpu(hdr->src_nid);
- dest_nid = le64_to_cpu(hdr->dest_nid);
- dest_pid = le32_to_cpu(hdr->dest_pid);
- payload_length = le32_to_cpu(hdr->payload_length);
+ type = hdr->type;
+ src_nid = hdr->src_nid;
+ dest_nid = hdr->dest_nid;
+ dest_pid = hdr->dest_pid;
+ payload_length = hdr->payload_length;
/* FIXME handle large-addr nids */
for_me = (lnet_nid_to_nid4(&ni->ni_nid) == dest_nid);
msg->msg_target.pid = dest_pid;
lnet_nid4_to_nid(dest_nid, &msg->msg_target.nid);
msg->msg_routing = 1;
-
- } else {
- /* convert common msg->hdr fields to host byteorder */
- msg->msg_hdr.type = type;
- msg->msg_hdr.src_nid = src_nid;
- msg->msg_hdr.src_pid = le32_to_cpu(msg->msg_hdr.src_pid);
- msg->msg_hdr.dest_nid = dest_nid;
- msg->msg_hdr.dest_pid = dest_pid;
- msg->msg_hdr.payload_length = payload_length;
}
lnet_net_lock(cpt);
if (ev_type == LNET_EVENT_SEND) {
/* event for active message */
- lnet_nid4_to_nid(le64_to_cpu(hdr->dest_nid), &ev->target.nid);
- ev->target.pid = le32_to_cpu(hdr->dest_pid);
+ lnet_nid4_to_nid(hdr->dest_nid, &ev->target.nid);
+ ev->target.pid = hdr->dest_pid;
ev->initiator.nid = LNET_ANY_NID;
ev->initiator.pid = the_lnet.ln_pid;
ev->source.nid = LNET_ANY_NID;
lnet_nid_t local_nid,
enum lnet_msg_hstatus *hstatus)
{
- lnet_nid_t src = le64_to_cpu(hdr->src_nid);
- lnet_nid_t dst = le64_to_cpu(hdr->dest_nid);
- unsigned int typ = le32_to_cpu(hdr->type);
+ lnet_nid_t src = hdr->src_nid;
+ lnet_nid_t dst = hdr->dest_nid;
+ unsigned int typ = hdr->type;
struct lnet_drop_rule *rule;
unsigned int ptl = -1;
bool drop = false;
lnet_delay_rule_match_locked(struct lnet_hdr *hdr, struct lnet_msg *msg)
{
struct lnet_delay_rule *rule;
- lnet_nid_t src = le64_to_cpu(hdr->src_nid);
- lnet_nid_t dst = le64_to_cpu(hdr->dest_nid);
- unsigned int typ = le32_to_cpu(hdr->type);
+ lnet_nid_t src = hdr->src_nid;
+ lnet_nid_t dst = hdr->dest_nid;
+ unsigned int typ = hdr->type;
unsigned int ptl = -1;
/* NB: called with hold of lnet_net_lock */
}
void
-check_lnet_hdr (void)
+check_lnet_hdr_nid4(void)
{
- CHECK_STRUCT(struct lnet_hdr);
- CHECK_MEMBER(struct lnet_hdr, dest_nid);
- CHECK_MEMBER(struct lnet_hdr, src_nid);
- CHECK_MEMBER(struct lnet_hdr, dest_pid);
- CHECK_MEMBER(struct lnet_hdr, src_pid);
- CHECK_MEMBER(struct lnet_hdr, type);
- CHECK_MEMBER(struct lnet_hdr, payload_length);
- CHECK_MEMBER(struct lnet_hdr, msg);
+ CHECK_STRUCT(struct _lnet_hdr_nid4);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, dest_nid);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, src_nid);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, dest_pid);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, src_pid);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, type);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, payload_length);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg);
BLANK_LINE ();
COMMENT ("Ack");
- CHECK_MEMBER(struct lnet_hdr, msg.ack.dst_wmd);
- CHECK_MEMBER(struct lnet_hdr, msg.ack.match_bits);
- CHECK_MEMBER(struct lnet_hdr, msg.ack.mlength);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.ack.dst_wmd);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.ack.match_bits);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.ack.mlength);
BLANK_LINE ();
COMMENT ("Put");
- CHECK_MEMBER(struct lnet_hdr, msg.put.ack_wmd);
- CHECK_MEMBER(struct lnet_hdr, msg.put.match_bits);
- CHECK_MEMBER(struct lnet_hdr, msg.put.hdr_data);
- CHECK_MEMBER(struct lnet_hdr, msg.put.ptl_index);
- CHECK_MEMBER(struct lnet_hdr, msg.put.offset);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.put.ack_wmd);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.put.match_bits);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.put.hdr_data);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.put.ptl_index);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.put.offset);
BLANK_LINE ();
COMMENT ("Get");
- CHECK_MEMBER(struct lnet_hdr, msg.get.return_wmd);
- CHECK_MEMBER(struct lnet_hdr, msg.get.match_bits);
- CHECK_MEMBER(struct lnet_hdr, msg.get.ptl_index);
- CHECK_MEMBER(struct lnet_hdr, msg.get.src_offset);
- CHECK_MEMBER(struct lnet_hdr, msg.get.sink_length);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.get.return_wmd);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.get.match_bits);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.get.ptl_index);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.get.src_offset);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.get.sink_length);
BLANK_LINE ();
COMMENT ("Reply");
- CHECK_MEMBER(struct lnet_hdr, msg.reply.dst_wmd);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.reply.dst_wmd);
BLANK_LINE ();
COMMENT ("Hello");
- CHECK_MEMBER(struct lnet_hdr, msg.hello.incarnation);
- CHECK_MEMBER(struct lnet_hdr, msg.hello.type);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.hello.incarnation);
+ CHECK_MEMBER(struct _lnet_hdr_nid4, msg.hello.type);
}
void
check_lnet_handle_wire();
check_lnet_magicversion();
- check_lnet_hdr();
+ check_lnet_hdr_nid4();
check_lnet_ni_status();
check_lnet_ping_info();