Whamcloud - gitweb
LU-10391 lnet: separate lnet_hdr in msg from that in lnd. 03/43603/12
authorMr NeilBrown <neilb@suse.de>
Fri, 7 Jan 2022 00:09:49 +0000 (19:09 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 26 Jan 2022 05:12:45 +0000 (05:12 +0000)
The lnet_hdr stored in an lnet_msg has fields which are sometimes in
le byte order and sometimes in host byte order.

The various lnds need all these fields to be in le byte order for
transmission or reception over the network.

To support larger (IPv6) NIDs, we will need the lnet_hdr in lnet_msg
to store these NIDs, but the lnd will need both 4byte-addr and 16-byte
lnds depending on protocol negotiation.

This patch separates out the two to make the conversion easier to
follow.

'struct lnet_hdr' is now used within common lnet code, and is not
stored in network buffers.

lnd_send will convert from 'struct lnet_hdr' to whatever is required
in the network buffer.  When lnet_parse() is called, the network
buffer will be converted to a 'struct lnet_hdr' first, and that will
be passed to lnet_parse().

The common fields of 'struct lnet_hdr' are always in host byte order.
The command specific fields (now in 'union lnet_cmd_hdr') have not
been changed and are sometimes host-byte-order and sometimes
l3-byte-order.

The new 'struct lnet_hdr_nid4' is used in network buffers.  It is
opaque - there are no subfields to access.  Very few places in the lnd
code want to access fields anyway.

New functions lnet_hdr_to_nid4() and lnet_hdr_from_nid4() can
convert between the lnet_hdr_nid4 to the internal lnet_hdr.

'struct _lnet_hdr_nid4' is provided to access fields inside 'struct
lnet_hdr_nid4' when that is really needed.  It is used by the to/from
functions and a couple of other places.

Test-Parameters: trivial
Test-Parameters: serverversion=2.12 serverdistro=el7.9 testlist=runtests
Test-Parameters: clientversion=2.12 testlist=runtests
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I55277a49538543376cf0404f749d3357a2950a7c
Reviewed-on: https://review.whamcloud.com/43603
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
15 files changed:
lnet/include/lnet/lib-lnet.h
lnet/include/lnet/socklnd.h
lnet/include/uapi/linux/lnet/lnet-idl.h
lnet/klnds/gnilnd/gnilnd.h
lnet/klnds/gnilnd/gnilnd_cb.c
lnet/klnds/o2iblnd/o2iblnd-idl.h
lnet/klnds/o2iblnd/o2iblnd_cb.c
lnet/klnds/socklnd/socklnd.h
lnet/klnds/socklnd/socklnd_cb.c
lnet/klnds/socklnd/socklnd_proto.c
lnet/lnet/api-ni.c
lnet/lnet/lib-move.c
lnet/lnet/lib-msg.c
lnet/lnet/net_fault.c
lnet/utils/wirecheck.c

index 730c614..4b2f270 100644 (file)
@@ -517,6 +517,36 @@ lnet_net2rnethash(__u32 net)
                ((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;
 
index 519ccbf..be2f502 100644 (file)
@@ -65,7 +65,7 @@ struct ksock_msg {
                /* 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
index 10a9cb4..457e6d6 100644 (file)
@@ -141,7 +141,32 @@ struct lnet_hello {
        __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;
@@ -149,13 +174,14 @@ struct lnet_hdr {
        __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
index f7359a4..4ad528b 100644 (file)
@@ -411,13 +411,13 @@ typedef struct {
 } __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 {
@@ -428,10 +428,10 @@ 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 {
index ad314de..7fa5dcb 100644 (file)
@@ -2107,9 +2107,10 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 
                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);
@@ -2143,9 +2144,10 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 
                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);
@@ -2170,7 +2172,7 @@ kgnilnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
                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);
 
@@ -4021,6 +4023,7 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
        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.
@@ -4281,14 +4284,14 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
        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:
@@ -4393,8 +4396,8 @@ kgnilnd_check_fma_rx(kgn_conn_t *conn)
                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;
 
index 5749348..35df50b 100644 (file)
@@ -49,7 +49,7 @@ struct kib_connparams {
 } __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;
 
@@ -65,7 +65,7 @@ struct kib_rdma_desc {
 } __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;
 
@@ -76,7 +76,7 @@ struct kib_putack_msg {
 } __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;
index 2a84e06..f1cea6d 100644 (file)
@@ -325,13 +325,14 @@ static void
 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);
 
@@ -389,21 +390,21 @@ kiblnd_handle_rx(struct kib_rx *rx)
                         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",
@@ -459,13 +460,13 @@ kiblnd_handle_rx(struct kib_rx *rx)
                                          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;
@@ -1697,7 +1698,7 @@ kiblnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
 
                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);
 
@@ -1732,7 +1733,7 @@ kiblnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
                        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));
@@ -1749,7 +1750,7 @@ kiblnd_send(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg)
                <= 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,
@@ -1861,16 +1862,16 @@ kiblnd_recv(struct lnet_ni *ni, void *private, struct lnet_msg *lntmsg,
        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,
index 7bd050a..ec0cafe 100644 (file)
@@ -339,8 +339,9 @@ struct ksock_conn {
                                                 * 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 */
index 7f61ea9..7d5d48a 100644 (file)
@@ -1087,19 +1087,21 @@ ksocknal_new_packet(struct ksock_conn *conn, int nob_to_skip)
                        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;
@@ -1141,8 +1143,9 @@ ksocknal_process_receive(struct ksock_conn *conn,
                         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);
@@ -1235,13 +1238,14 @@ ksocknal_process_receive(struct ksock_conn *conn,
                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;
@@ -1262,21 +1266,23 @@ ksocknal_process_receive(struct ksock_conn *conn,
                /* 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) {
@@ -1313,7 +1319,7 @@ ksocknal_process_receive(struct ksock_conn *conn,
                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(
index 954f9c0..5ee5f9f 100644 (file)
@@ -288,7 +288,7 @@ ksocknal_match_tx(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk)
                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 */
@@ -324,7 +324,8 @@ ksocknal_match_tx_v3(struct ksock_conn *conn, struct ksock_tx *tx, int nonblk)
        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) {
@@ -455,27 +456,28 @@ static int
 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 */
@@ -565,18 +567,19 @@ ksocknal_recv_hello_v1(struct ksock_conn *conn, struct ksock_hello_msg *hello,
                       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",
@@ -710,10 +713,12 @@ ksocknal_pack_msg_v1(struct ksock_tx *tx)
        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;
 }
 
@@ -728,9 +733,10 @@ ksocknal_pack_msg_v2(struct ksock_tx *tx)
        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;
index b130c11..204227b 100644 (file)
@@ -776,64 +776,64 @@ static void lnet_assert_wire_constants(void)
                                   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);
index af2467d..d20145a 100644 (file)
@@ -722,13 +722,13 @@ lnet_prep_send(struct lnet_msg *msg, int type, struct lnet_process_id target,
                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
@@ -900,7 +900,7 @@ lnet_post_send_locked(struct lnet_msg *msg, int do_send)
                        !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)
@@ -1097,7 +1097,8 @@ lnet_return_tx_credits_locked(struct lnet_msg *msg)
                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++;
@@ -1813,10 +1814,10 @@ lnet_handle_lo_send(struct lnet_send_data *sd)
        /* 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;
@@ -1918,7 +1919,7 @@ lnet_handle_send(struct lnet_send_data *sd)
         */
        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;
@@ -1935,14 +1936,14 @@ lnet_handle_send(struct lnet_send_data *sd)
                 */
                /* 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);
        }
 
        /*
@@ -4522,11 +4523,11 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
 
        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);
@@ -4676,15 +4677,6 @@ lnet_parse(struct lnet_ni *ni, struct lnet_hdr *hdr, lnet_nid_t from_nid4,
                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);
index 290b78f..6373d6f 100644 (file)
@@ -68,8 +68,8 @@ lnet_build_msg_event(struct lnet_msg *msg, enum lnet_event_kind ev_type)
 
        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;
index efe69d9..a4fdf97 100644 (file)
@@ -429,9 +429,9 @@ lnet_drop_rule_match(struct lnet_hdr *hdr,
                     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;
@@ -605,9 +605,9 @@ bool
 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 */
index 91eb999..2a23e74 100644 (file)
@@ -109,47 +109,47 @@ check_lnet_magicversion (void)
 }
 
 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
@@ -277,7 +277,7 @@ main (int argc, char **argv)
 
        check_lnet_handle_wire();
        check_lnet_magicversion();
-       check_lnet_hdr();
+       check_lnet_hdr_nid4();
        check_lnet_ni_status();
        check_lnet_ping_info();