1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 * Data movement routines
7 * Copyright (c) 2001-2003 Cluster File Systems, Inc.
9 * This file is part of Lustre, http://www.lustre.org
11 * Lustre is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * Lustre is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Lustre; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #define DEBUG_SUBSYSTEM S_PORTALS
30 # include <libcfs/kp30.h>
32 #include <portals/p30.h>
33 #include <portals/lib-p30.h>
36 static void lib_commit_md (lib_nal_t *nal, lib_md_t *md, lib_msg_t *msg);
37 static ptl_err_t do_lib_parse(lib_nal_t *nal, ptl_hdr_t *hdr,
38 void *private, int loopback);
41 lib_match_md(lib_nal_t *nal, int index, int op_mask,
42 ptl_nid_t src_nid, ptl_pid_t src_pid,
43 ptl_size_t rlength, ptl_size_t roffset,
44 ptl_match_bits_t match_bits, lib_msg_t *msg,
45 ptl_size_t *mlength_out, ptl_size_t *offset_out)
47 lib_ni_t *ni = &nal->libnal_ni;
48 struct list_head *match_list = &ni->ni_portals.tbl[index];
49 struct list_head *tmp;
56 CDEBUG (D_NET, "Request from "LPU64".%d of length %d into portal %d "
57 "MB="LPX64"\n", src_nid, src_pid, rlength, index, match_bits);
59 if (index < 0 || index >= ni->ni_portals.size) {
60 CERROR("Invalid portal %d not in [0-%d]\n",
61 index, ni->ni_portals.size);
65 list_for_each (tmp, match_list) {
66 me = list_entry(tmp, lib_me_t, me_list);
69 /* ME attached but MD not attached yet */
73 LASSERT (me == md->me);
75 /* mismatched MD op */
76 if ((md->options & op_mask) == 0)
80 if (lib_md_exhausted(md))
83 /* mismatched ME nid/pid? */
84 if (me->match_id.nid != PTL_NID_ANY &&
85 me->match_id.nid != src_nid)
88 CDEBUG(D_NET, "match_id.pid [%x], src_pid [%x]\n",
89 me->match_id.pid, src_pid);
91 if (me->match_id.pid != PTL_PID_ANY &&
92 me->match_id.pid != src_pid)
95 /* mismatched ME matchbits? */
96 if (((me->match_bits ^ match_bits) & ~me->ignore_bits) != 0)
99 /* Hurrah! This _is_ a match; check it out... */
101 if ((md->options & PTL_MD_MANAGE_REMOTE) == 0)
106 if ((md->options & PTL_MD_MAX_SIZE) != 0) {
107 mlength = md->max_size;
108 LASSERT (md->offset + mlength <= md->length);
110 mlength = md->length - offset;
113 if (rlength <= mlength) { /* fits in allowed space */
115 } else if ((md->options & PTL_MD_TRUNCATE) == 0) {
116 /* this packet _really_ is too big */
117 CERROR("Matching packet %d too big: %d left, "
118 "%d allowed\n", rlength, md->length - offset,
123 /* Commit to this ME/MD */
124 CDEBUG(D_NET, "Incoming %s index %x from "LPU64"/%u of "
125 "length %d/%d into md "LPX64" [%d] + %d\n",
126 (op_mask == PTL_MD_OP_PUT) ? "put" : "get",
127 index, src_nid, src_pid, mlength, rlength,
128 md->md_lh.lh_cookie, md->md_niov, offset);
130 lib_commit_md(nal, md, msg);
131 md->offset = offset + mlength;
133 /* NB Caller sets ev.type and ev.hdr_data */
134 msg->ev.initiator.nid = src_nid;
135 msg->ev.initiator.pid = src_pid;
136 msg->ev.pt_index = index;
137 msg->ev.match_bits = match_bits;
138 msg->ev.rlength = rlength;
139 msg->ev.mlength = mlength;
140 msg->ev.offset = offset;
142 lib_md_deconstruct(nal, md, &msg->ev.md);
143 ptl_md2handle(&msg->ev.md_handle, nal, md);
145 *offset_out = offset;
146 *mlength_out = mlength;
148 /* Auto-unlink NOW, so the ME gets unlinked if required.
149 * We bumped md->pending above so the MD just gets flagged
150 * for unlink when it is finalized. */
151 if ((md->md_flags & PTL_MD_FLAG_AUTO_UNLINK) != 0 &&
152 lib_md_exhausted(md))
153 lib_md_unlink(nal, md);
159 CERROR (LPU64": Dropping %s from "LPU64".%d portal %d match "LPX64
160 " offset %d length %d: no match\n",
161 ni->ni_pid.nid, (op_mask == PTL_MD_OP_GET) ? "GET" : "PUT",
162 src_nid, src_pid, index, match_bits, roffset, rlength);
166 int lib_api_fail_nid (nal_t *apinal, ptl_nid_t nid, unsigned int threshold)
168 lib_nal_t *nal = apinal->nal_data;
171 struct list_head *el;
172 struct list_head *next;
173 struct list_head cull;
175 if (threshold != 0) {
176 /* Adding a new entry */
177 PORTAL_ALLOC(tp, sizeof(*tp));
182 tp->tp_threshold = threshold;
184 LIB_LOCK(nal, flags);
185 list_add_tail (&tp->tp_list, &nal->libnal_ni.ni_test_peers);
186 LIB_UNLOCK(nal, flags);
190 /* removing entries */
191 CFS_INIT_LIST_HEAD (&cull);
193 LIB_LOCK(nal, flags);
195 list_for_each_safe (el, next, &nal->libnal_ni.ni_test_peers) {
196 tp = list_entry (el, lib_test_peer_t, tp_list);
198 if (tp->tp_threshold == 0 || /* needs culling anyway */
199 nid == PTL_NID_ANY || /* removing all entries */
200 tp->tp_nid == nid) /* matched this one */
202 list_del (&tp->tp_list);
203 list_add (&tp->tp_list, &cull);
207 LIB_UNLOCK(nal, flags);
209 while (!list_empty (&cull)) {
210 tp = list_entry (cull.next, lib_test_peer_t, tp_list);
212 list_del (&tp->tp_list);
213 PORTAL_FREE(tp, sizeof (*tp));
219 lib_api_loopback (nal_t *apinal, int set, int *enabled)
221 lib_nal_t *nal = apinal->nal_data;
224 nal->libnal_ni.ni_loopback = *enabled;
226 *enabled = nal->libnal_ni.ni_loopback;
232 fail_peer (lib_nal_t *nal, ptl_nid_t nid, int outgoing)
235 struct list_head *el;
236 struct list_head *next;
238 struct list_head cull;
241 CFS_INIT_LIST_HEAD (&cull);
243 LIB_LOCK (nal, flags);
245 list_for_each_safe (el, next, &nal->libnal_ni.ni_test_peers) {
246 tp = list_entry (el, lib_test_peer_t, tp_list);
248 if (tp->tp_threshold == 0) {
251 /* only cull zombies on outgoing tests,
252 * since we may be at interrupt priority on
253 * incoming messages. */
254 list_del (&tp->tp_list);
255 list_add (&tp->tp_list, &cull);
260 if (tp->tp_nid == PTL_NID_ANY || /* fail every peer */
261 nid == tp->tp_nid) { /* fail this peer */
264 if (tp->tp_threshold != PTL_MD_THRESH_INF) {
267 tp->tp_threshold == 0) {
269 list_del (&tp->tp_list);
270 list_add (&tp->tp_list, &cull);
277 LIB_UNLOCK (nal, flags);
279 while (!list_empty (&cull)) {
280 tp = list_entry (cull.next, lib_test_peer_t, tp_list);
281 list_del (&tp->tp_list);
283 PORTAL_FREE(tp, sizeof (*tp));
290 lib_iov_nob (int niov, struct iovec *iov)
295 nob += (iov++)->iov_len;
301 lib_copy_iov2buf (char *dest, int niov, struct iovec *iov,
302 ptl_size_t offset, ptl_size_t len)
309 /* skip complete frags before 'offset' */
311 while (offset >= iov->iov_len) {
312 offset -= iov->iov_len;
320 nob = MIN (iov->iov_len - offset, len);
321 memcpy (dest, iov->iov_base + offset, nob);
332 lib_copy_buf2iov (int niov, struct iovec *iov, ptl_size_t offset,
333 char *src, ptl_size_t len)
340 /* skip complete frags before 'offset' */
342 while (offset >= iov->iov_len) {
343 offset -= iov->iov_len;
351 nob = MIN (iov->iov_len - offset, len);
352 memcpy (iov->iov_base + offset, src, nob);
363 lib_extract_iov (int dst_niov, struct iovec *dst,
364 int src_niov, struct iovec *src,
365 ptl_size_t offset, ptl_size_t len)
367 /* Initialise 'dst' to the subset of 'src' starting at 'offset',
368 * for exactly 'len' bytes, and return the number of entries.
369 * NB not destructive to 'src' */
373 if (len == 0) /* no data => */
374 return (0); /* no frags */
376 LASSERT (src_niov > 0);
377 while (offset >= src->iov_len) { /* skip initial frags */
378 offset -= src->iov_len;
381 LASSERT (src_niov > 0);
386 LASSERT (src_niov > 0);
387 LASSERT (niov <= dst_niov);
389 frag_len = src->iov_len - offset;
390 dst->iov_base = ((char *)src->iov_base) + offset;
392 if (len <= frag_len) {
397 dst->iov_len = frag_len;
410 lib_kiov_nob (int niov, ptl_kiov_t *kiov)
417 lib_copy_kiov2buf (char *dest, int niov, ptl_kiov_t *kiov,
418 ptl_size_t offset, ptl_size_t len)
424 lib_copy_buf2kiov (int niov, ptl_kiov_t *kiov, ptl_size_t offset,
425 char *src, ptl_size_t len)
431 lib_extract_kiov (int dst_niov, ptl_kiov_t *dst,
432 int src_niov, ptl_kiov_t *src,
433 ptl_size_t offset, ptl_size_t len)
439 lib_lo_rxkiov(lib_nal_t *nal, void *private, lib_msg_t *libmsg,
440 unsigned int niov, ptl_kiov_t *kiov,
441 size_t offset, size_t mlen, size_t rlen)
447 lib_lo_txkiov (lib_nal_t *nal, void *private, lib_msg_t *libmsg,
448 ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid,
449 unsigned int payload_niov, ptl_kiov_t *payload_kiov,
450 size_t payload_offset, size_t payload_nob)
455 #else /* __KERNEL__ */
458 lib_kiov_nob (int niov, ptl_kiov_t *kiov)
463 nob += (kiov++)->kiov_len;
469 lib_copy_kiov2buf (char *dest, int niov, ptl_kiov_t *kiov,
470 ptl_size_t offset, ptl_size_t len)
478 LASSERT (!in_interrupt ());
481 while (offset > kiov->kiov_len) {
482 offset -= kiov->kiov_len;
490 nob = MIN (kiov->kiov_len - offset, len);
492 addr = ((char *)cfs_kmap(kiov->kiov_page)) + kiov->kiov_offset +
494 memcpy (dest, addr, nob);
495 cfs_kunmap (kiov->kiov_page);
506 lib_copy_buf2kiov (int niov, ptl_kiov_t *kiov, ptl_size_t offset,
507 char *src, ptl_size_t len)
515 LASSERT (!in_interrupt ());
518 while (offset >= kiov->kiov_len) {
519 offset -= kiov->kiov_len;
527 nob = MIN (kiov->kiov_len - offset, len);
529 addr = ((char *)cfs_kmap(kiov->kiov_page)) + kiov->kiov_offset +
531 memcpy (addr, src, nob);
532 cfs_kunmap (kiov->kiov_page);
543 lib_extract_kiov (int dst_niov, ptl_kiov_t *dst,
544 int src_niov, ptl_kiov_t *src,
545 ptl_size_t offset, ptl_size_t len)
547 /* Initialise 'dst' to the subset of 'src' starting at 'offset',
548 * for exactly 'len' bytes, and return the number of entries.
549 * NB not destructive to 'src' */
553 if (len == 0) /* no data => */
554 return (0); /* no frags */
556 LASSERT (src_niov > 0);
557 while (offset >= src->kiov_len) { /* skip initial frags */
558 offset -= src->kiov_len;
561 LASSERT (src_niov > 0);
566 LASSERT (src_niov > 0);
567 LASSERT (niov <= dst_niov);
569 frag_len = src->kiov_len - offset;
570 dst->kiov_page = src->kiov_page;
571 dst->kiov_offset = src->kiov_offset + offset;
573 if (len <= frag_len) {
575 LASSERT (dst->kiov_offset + dst->kiov_len <= PAGE_SIZE);
579 dst->kiov_len = frag_len;
580 LASSERT (dst->kiov_offset + dst->kiov_len <= PAGE_SIZE);
592 lib_lo_rxkiov(lib_nal_t *nal,
601 void *srcaddr = NULL;
602 void *dstaddr = NULL;
603 unsigned long srcfrag = 0;
604 unsigned long dstfrag = 0;
605 unsigned long fraglen;
606 lo_desc_t *lod = (lo_desc_t *)private;
608 /* I only handle unmapped->unmapped matches */
609 LASSERT(lod->lod_type == LOD_KIOV);
614 while (offset >= kiov->kiov_len) {
615 offset -= kiov->kiov_len;
621 while (lod->lod_offset >= lod->lod_iov.kiov->kiov_len) {
622 lod->lod_offset -= lod->lod_iov.kiov->kiov_len;
625 LASSERT(lod->lod_niov > 0);
630 * I kmap 2 pages at once == slight risk of deadlock */
632 if (dstaddr == NULL) {
634 ((unsigned long)cfs_kmap(kiov->kiov_page) +
635 kiov->kiov_offset + offset);
636 dstfrag = kiov->kiov_len - offset;
639 LASSERT(lod->lod_niov > 0);
640 if (srcaddr == NULL) {
642 ((unsigned long)cfs_kmap(lod->lod_iov.kiov->kiov_page)+
643 lod->lod_iov.kiov->kiov_offset + lod->lod_offset);
644 srcfrag = lod->lod_iov.kiov->kiov_len - lod->lod_offset;
647 fraglen = MIN(srcfrag, dstfrag);
651 memcpy(dstaddr, srcaddr, fraglen);
653 if (fraglen < dstfrag) {
655 dstaddr = (void *)((unsigned long)dstaddr + fraglen);
657 cfs_kunmap(kiov->kiov_page);
664 if (fraglen < srcfrag) {
666 srcaddr = (void *)((unsigned long)srcaddr + fraglen);
668 cfs_kunmap(lod->lod_iov.kiov->kiov_page);
679 cfs_kunmap(kiov->kiov_page);
682 cfs_kunmap(lod->lod_iov.kiov->kiov_page);
684 lib_finalize(nal, private, libmsg, PTL_OK);
689 lib_lo_txkiov (lib_nal_t *nal,
696 unsigned int payload_niov,
697 ptl_kiov_t *payload_kiov,
698 size_t payload_offset,
702 .lod_type = LOD_KIOV,
703 .lod_niov = payload_niov,
704 .lod_offset = payload_offset,
705 .lod_nob = payload_nob,
706 .lod_iov = { .kiov = payload_kiov } };
709 rc = do_lib_parse(nal, hdr, &lod, 1);
711 lib_finalize(nal, private, libmsg, PTL_OK);
718 lib_lo_rxiov(lib_nal_t *nal,
727 lo_desc_t *lod = (lo_desc_t *)private;
729 /* I only handle mapped->mapped matches */
730 LASSERT(lod->lod_type == LOD_IOV);
733 while (offset >= iov->iov_len) {
734 offset -= iov->iov_len;
740 while (lod->lod_offset >= lod->lod_iov.iov->iov_len) {
741 lod->lod_offset -= lod->lod_iov.iov->iov_len;
744 LASSERT(lod->lod_niov > 0);
748 int fraglen = MIN(iov->iov_len - offset,
749 lod->lod_iov.iov->iov_len - lod->lod_offset);
752 LASSERT(lod->lod_niov > 0);
757 memcpy((void *)((unsigned long)iov->iov_base + offset),
758 (void *)((unsigned long)lod->lod_iov.iov->iov_base +
762 if (offset + fraglen < iov->iov_len) {
770 if (lod->lod_offset + fraglen < lod->lod_iov.iov->iov_len ) {
771 lod->lod_offset += fraglen;
781 lib_finalize(nal, private, libmsg, PTL_OK);
786 lib_lo_txiov (lib_nal_t *nal,
793 unsigned int payload_niov,
794 struct iovec *payload_iov,
795 size_t payload_offset,
800 .lod_niov = payload_niov,
801 .lod_offset = payload_offset,
802 .lod_nob = payload_nob,
803 .lod_iov = { .iov = payload_iov } };
806 rc = do_lib_parse(nal, hdr, &lod, 1);
808 lib_finalize(nal, private, libmsg, PTL_OK);
814 lib_lo_recv (lib_nal_t *nal, void *private, lib_msg_t *msg, lib_md_t *md,
815 ptl_size_t offset, ptl_size_t mlen, ptl_size_t rlen)
818 lib_finalize(nal, private, msg, PTL_OK);
822 if ((md->options & PTL_MD_KIOV) == 0)
823 return lib_lo_rxiov(nal, private, msg,
824 md->md_niov, md->md_iov.iov,
827 return lib_lo_rxkiov(nal, private, msg,
828 md->md_niov, md->md_iov.kiov,
833 lib_recv (lib_nal_t *nal, void *private, lib_msg_t *msg, lib_md_t *md,
834 ptl_size_t offset, ptl_size_t mlen, ptl_size_t rlen)
837 return (nal->libnal_recv(nal, private, msg,
839 offset, mlen, rlen));
841 if ((md->options & PTL_MD_KIOV) == 0)
842 return (nal->libnal_recv(nal, private, msg,
843 md->md_niov, md->md_iov.iov,
844 offset, mlen, rlen));
846 return (nal->libnal_recv_pages(nal, private, msg,
847 md->md_niov, md->md_iov.kiov,
848 offset, mlen, rlen));
852 lib_send (lib_nal_t *nal, void *private, lib_msg_t *msg,
853 ptl_hdr_t *hdr, int type, ptl_nid_t nid, ptl_pid_t pid,
854 lib_md_t *md, ptl_size_t offset, ptl_size_t len)
856 int loopback = (nal->libnal_ni.ni_loopback &&
857 (nid == nal->libnal_ni.ni_pid.nid));
861 return lib_lo_txiov(nal, private, msg,
866 return nal->libnal_send(nal, private, msg,
872 if ((md->options & PTL_MD_KIOV) == 0) {
874 return lib_lo_txiov(nal, private, msg,
876 md->md_niov, md->md_iov.iov,
879 return nal->libnal_send(nal, private, msg,
881 md->md_niov, md->md_iov.iov,
886 return lib_lo_txkiov(nal, private, msg,
888 md->md_niov, md->md_iov.kiov,
891 return nal->libnal_send_pages(nal, private, msg,
893 md->md_niov, md->md_iov.kiov,
898 lib_commit_md (lib_nal_t *nal, lib_md_t *md, lib_msg_t *msg)
900 /* ALWAYS called holding the LIB_LOCK */
901 lib_counters_t *counters = &nal->libnal_ni.ni_counters;
903 /* Here, we commit the MD to a network OP by marking it busy and
904 * decrementing its threshold. Come what may, the network "owns"
905 * the MD until a call to lib_finalize() signals completion. */
909 if (md->threshold != PTL_MD_THRESH_INF) {
910 LASSERT (md->threshold > 0);
914 counters->msgs_alloc++;
915 if (counters->msgs_alloc > counters->msgs_max)
916 counters->msgs_max = counters->msgs_alloc;
918 list_add (&msg->msg_list, &nal->libnal_ni.ni_active_msgs);
922 lib_drop_message (lib_nal_t *nal, void *private, ptl_hdr_t *hdr, int loopback)
926 /* CAVEAT EMPTOR: this only drops messages that we've not committed
927 * to receive (init_msg() not called) and therefore can't cause an
930 LIB_LOCK(nal, flags);
931 nal->libnal_ni.ni_counters.drop_count++;
932 nal->libnal_ni.ni_counters.drop_length += hdr->payload_length;
933 LIB_UNLOCK(nal, flags);
935 /* NULL msg => if NAL calls lib_finalize it will be a noop */
937 (void) lib_recv(nal, private, NULL, NULL, 0, 0,
938 hdr->payload_length);
942 * Incoming messages have a ptl_msg_t object associated with them
943 * by the library. This object encapsulates the state of the
944 * message and allows the NAL to do non-blocking receives or sends
949 parse_put(lib_nal_t *nal, ptl_hdr_t *hdr, void *private,
950 lib_msg_t *msg, int loopback)
952 lib_ni_t *ni = &nal->libnal_ni;
953 ptl_size_t mlength = 0;
954 ptl_size_t offset = 0;
959 /* Convert put fields to host byte order */
960 hdr->msg.put.match_bits = le64_to_cpu(hdr->msg.put.match_bits);
961 hdr->msg.put.ptl_index = le32_to_cpu(hdr->msg.put.ptl_index);
962 hdr->msg.put.offset = le32_to_cpu(hdr->msg.put.offset);
964 LIB_LOCK(nal, flags);
966 md = lib_match_md(nal, hdr->msg.put.ptl_index, PTL_MD_OP_PUT,
967 hdr->src_nid, hdr->src_pid,
968 hdr->payload_length, hdr->msg.put.offset,
969 hdr->msg.put.match_bits, msg,
972 LIB_UNLOCK(nal, flags);
976 msg->ev.type = PTL_EVENT_PUT_END;
977 msg->ev.hdr_data = hdr->msg.put.hdr_data;
979 if (!ptl_is_wire_handle_none(&hdr->msg.put.ack_wmd) &&
980 !(md->options & PTL_MD_ACK_DISABLE)) {
981 msg->ack_wmd = hdr->msg.put.ack_wmd;
984 ni->ni_counters.recv_count++;
985 ni->ni_counters.recv_length += mlength;
987 LIB_UNLOCK(nal, flags);
990 rc = lib_lo_recv(nal, private, msg, md, offset, mlength,
991 hdr->payload_length);
993 rc = lib_recv(nal, private, msg, md, offset, mlength,
994 hdr->payload_length);
997 CERROR(LPU64": error on receiving PUT from "LPU64": %d\n",
998 ni->ni_pid.nid, hdr->src_nid, rc);
1004 parse_get(lib_nal_t *nal, ptl_hdr_t *hdr, void *private,
1005 lib_msg_t *msg, int loopback)
1007 lib_ni_t *ni = &nal->libnal_ni;
1008 ptl_size_t mlength = 0;
1009 ptl_size_t offset = 0;
1012 unsigned long flags;
1015 /* Convert get fields to host byte order */
1016 hdr->msg.get.match_bits = le64_to_cpu(hdr->msg.get.match_bits);
1017 hdr->msg.get.ptl_index = le32_to_cpu(hdr->msg.get.ptl_index);
1018 hdr->msg.get.sink_length = le32_to_cpu(hdr->msg.get.sink_length);
1019 hdr->msg.get.src_offset = le32_to_cpu(hdr->msg.get.src_offset);
1021 LIB_LOCK(nal, flags);
1023 md = lib_match_md(nal, hdr->msg.get.ptl_index, PTL_MD_OP_GET,
1024 hdr->src_nid, hdr->src_pid,
1025 hdr->msg.get.sink_length, hdr->msg.get.src_offset,
1026 hdr->msg.get.match_bits, msg,
1029 LIB_UNLOCK(nal, flags);
1033 msg->ev.type = PTL_EVENT_GET_END;
1034 msg->ev.hdr_data = 0;
1036 ni->ni_counters.send_count++;
1037 ni->ni_counters.send_length += mlength;
1039 LIB_UNLOCK(nal, flags);
1041 memset (&reply, 0, sizeof (reply));
1042 reply.type = cpu_to_le32(PTL_MSG_REPLY);
1043 reply.dest_nid = cpu_to_le64(hdr->src_nid);
1044 reply.dest_pid = cpu_to_le32(hdr->src_pid);
1045 reply.src_nid = cpu_to_le64(ni->ni_pid.nid);
1046 reply.src_pid = cpu_to_le32(ni->ni_pid.pid);
1047 reply.payload_length = cpu_to_le32(mlength);
1049 reply.msg.reply.dst_wmd = hdr->msg.get.return_wmd;
1051 /* NB call lib_send() _BEFORE_ lib_recv() completes the incoming
1052 * message. Some NALs _require_ this to implement optimized GET */
1054 rc = lib_send (nal, private, msg, &reply, PTL_MSG_REPLY,
1055 hdr->src_nid, hdr->src_pid, md, offset, mlength);
1057 CERROR(LPU64": Unable to send REPLY for GET from "LPU64": %d\n",
1058 ni->ni_pid.nid, hdr->src_nid, rc);
1060 /* Discard any junk after the hdr */
1062 (void) lib_recv(nal, private, NULL, NULL, 0, 0,
1063 hdr->payload_length);
1069 parse_reply(lib_nal_t *nal, ptl_hdr_t *hdr, void *private,
1070 lib_msg_t *msg, int loopback)
1072 lib_ni_t *ni = &nal->libnal_ni;
1076 unsigned long flags;
1079 LIB_LOCK(nal, flags);
1081 /* NB handles only looked up by creator (no flips) */
1082 md = ptl_wire_handle2md(&hdr->msg.reply.dst_wmd, nal);
1083 if (md == NULL || md->threshold == 0) {
1084 CERROR (LPU64": Dropping REPLY from "LPU64" for %s MD "LPX64"."LPX64"\n",
1085 ni->ni_pid.nid, hdr->src_nid,
1086 md == NULL ? "invalid" : "inactive",
1087 hdr->msg.reply.dst_wmd.wh_interface_cookie,
1088 hdr->msg.reply.dst_wmd.wh_object_cookie);
1090 LIB_UNLOCK(nal, flags);
1094 LASSERT (md->offset == 0);
1096 length = rlength = hdr->payload_length;
1098 if (length > md->length) {
1099 if ((md->options & PTL_MD_TRUNCATE) == 0) {
1100 CERROR (LPU64": Dropping REPLY from "LPU64
1101 " length %d for MD "LPX64" would overflow (%d)\n",
1102 ni->ni_pid.nid, hdr->src_nid, length,
1103 hdr->msg.reply.dst_wmd.wh_object_cookie,
1105 LIB_UNLOCK(nal, flags);
1108 length = md->length;
1111 CDEBUG(D_NET, "Reply from "LPU64" of length %d/%d into md "LPX64"\n",
1112 hdr->src_nid, length, rlength,
1113 hdr->msg.reply.dst_wmd.wh_object_cookie);
1115 lib_commit_md(nal, md, msg);
1117 msg->ev.type = PTL_EVENT_REPLY_END;
1118 msg->ev.initiator.nid = hdr->src_nid;
1119 msg->ev.initiator.pid = hdr->src_pid;
1120 msg->ev.rlength = rlength;
1121 msg->ev.mlength = length;
1124 lib_md_deconstruct(nal, md, &msg->ev.md);
1125 ptl_md2handle(&msg->ev.md_handle, nal, md);
1127 ni->ni_counters.recv_count++;
1128 ni->ni_counters.recv_length += length;
1130 LIB_UNLOCK(nal, flags);
1133 rc = lib_lo_recv(nal, private, msg, md, 0, length, rlength);
1135 rc = lib_recv(nal, private, msg, md, 0, length, rlength);
1138 CERROR(LPU64": error on receiving REPLY from "LPU64": %d\n",
1139 ni->ni_pid.nid, hdr->src_nid, rc);
1145 parse_ack(lib_nal_t *nal, ptl_hdr_t *hdr, void *private,
1146 lib_msg_t *msg, int loopback)
1148 lib_ni_t *ni = &nal->libnal_ni;
1150 unsigned long flags;
1152 /* Convert ack fields to host byte order */
1153 hdr->msg.ack.match_bits = le64_to_cpu(hdr->msg.ack.match_bits);
1154 hdr->msg.ack.mlength = le32_to_cpu(hdr->msg.ack.mlength);
1156 LIB_LOCK(nal, flags);
1158 /* NB handles only looked up by creator (no flips) */
1159 md = ptl_wire_handle2md(&hdr->msg.ack.dst_wmd, nal);
1160 if (md == NULL || md->threshold == 0) {
1161 CDEBUG(D_INFO, LPU64": Dropping ACK from "LPU64" to %s MD "
1162 LPX64"."LPX64"\n", ni->ni_pid.nid, hdr->src_nid,
1163 (md == NULL) ? "invalid" : "inactive",
1164 hdr->msg.ack.dst_wmd.wh_interface_cookie,
1165 hdr->msg.ack.dst_wmd.wh_object_cookie);
1167 LIB_UNLOCK(nal, flags);
1171 CDEBUG(D_NET, LPU64": ACK from "LPU64" into md "LPX64"\n",
1172 ni->ni_pid.nid, hdr->src_nid,
1173 hdr->msg.ack.dst_wmd.wh_object_cookie);
1175 lib_commit_md(nal, md, msg);
1177 msg->ev.type = PTL_EVENT_ACK;
1178 msg->ev.initiator.nid = hdr->src_nid;
1179 msg->ev.initiator.pid = hdr->src_pid;
1180 msg->ev.mlength = hdr->msg.ack.mlength;
1181 msg->ev.match_bits = hdr->msg.ack.match_bits;
1183 lib_md_deconstruct(nal, md, &msg->ev.md);
1184 ptl_md2handle(&msg->ev.md_handle, nal, md);
1186 ni->ni_counters.recv_count++;
1188 LIB_UNLOCK(nal, flags);
1190 /* We have received and matched up the ack OK, create the
1191 * completion event now... */
1192 lib_finalize(nal, private, msg, PTL_OK);
1194 /* ...and now discard any junk after the hdr */
1196 (void) lib_recv(nal, private, NULL, NULL, 0, 0,
1197 hdr->payload_length);
1203 hdr_type_string (ptl_hdr_t *hdr)
1205 switch (hdr->type) {
1217 return ("<UNKNOWN>");
1221 void print_hdr(lib_nal_t *nal, ptl_hdr_t * hdr)
1223 char *type_str = hdr_type_string (hdr);
1225 CWARN("P3 Header at %p of type %s\n", hdr, type_str);
1226 CWARN(" From nid/pid "LPX64"/%u", hdr->src_nid, hdr->src_pid);
1227 CWARN(" To nid/pid "LPX64"/%u\n", hdr->dest_nid, hdr->dest_pid);
1229 switch (hdr->type) {
1234 CWARN(" Ptl index %d, ack md "LPX64"."LPX64", "
1235 "match bits "LPX64"\n",
1236 hdr->msg.put.ptl_index,
1237 hdr->msg.put.ack_wmd.wh_interface_cookie,
1238 hdr->msg.put.ack_wmd.wh_object_cookie,
1239 hdr->msg.put.match_bits);
1240 CWARN(" Length %d, offset %d, hdr data "LPX64"\n",
1241 hdr->payload_length, hdr->msg.put.offset,
1242 hdr->msg.put.hdr_data);
1246 CWARN(" Ptl index %d, return md "LPX64"."LPX64", "
1247 "match bits "LPX64"\n", hdr->msg.get.ptl_index,
1248 hdr->msg.get.return_wmd.wh_interface_cookie,
1249 hdr->msg.get.return_wmd.wh_object_cookie,
1250 hdr->msg.get.match_bits);
1251 CWARN(" Length %d, src offset %d\n",
1252 hdr->msg.get.sink_length,
1253 hdr->msg.get.src_offset);
1257 CWARN(" dst md "LPX64"."LPX64", "
1258 "manipulated length %d\n",
1259 hdr->msg.ack.dst_wmd.wh_interface_cookie,
1260 hdr->msg.ack.dst_wmd.wh_object_cookie,
1261 hdr->msg.ack.mlength);
1265 CWARN(" dst md "LPX64"."LPX64", "
1267 hdr->msg.reply.dst_wmd.wh_interface_cookie,
1268 hdr->msg.reply.dst_wmd.wh_object_cookie,
1269 hdr->payload_length);
1272 } /* end of print_hdr() */
1276 lib_parse(lib_nal_t *nal, ptl_hdr_t *hdr, void *private)
1278 return do_lib_parse(nal, hdr, private, 0);
1282 do_lib_parse(lib_nal_t *nal, ptl_hdr_t *hdr, void *private, int loopback)
1284 unsigned long flags;
1288 /* NB we return PTL_OK if we manage to parse the header and believe
1289 * it looks OK. Anything that goes wrong with receiving the
1290 * message after that point is the responsibility of the NAL */
1292 /* convert common fields to host byte order */
1293 hdr->type = le32_to_cpu(hdr->type);
1294 hdr->src_nid = le64_to_cpu(hdr->src_nid);
1295 hdr->src_pid = le32_to_cpu(hdr->src_pid);
1296 hdr->dest_pid = le32_to_cpu(hdr->dest_pid);
1297 hdr->payload_length = le32_to_cpu(hdr->payload_length);
1299 switch (hdr->type) {
1300 case PTL_MSG_HELLO: {
1301 /* dest_nid is really ptl_magicversion_t */
1302 ptl_magicversion_t *mv = (ptl_magicversion_t *)&hdr->dest_nid;
1304 mv->magic = le32_to_cpu(mv->magic);
1305 mv->version_major = le16_to_cpu(mv->version_major);
1306 mv->version_minor = le16_to_cpu(mv->version_minor);
1308 if (mv->magic == PORTALS_PROTO_MAGIC &&
1309 mv->version_major == PORTALS_PROTO_VERSION_MAJOR &&
1310 mv->version_minor == PORTALS_PROTO_VERSION_MINOR) {
1311 CWARN (LPU64": Dropping unexpected HELLO message: "
1312 "magic %d, version %d.%d from "LPD64"\n",
1313 nal->libnal_ni.ni_pid.nid, mv->magic,
1314 mv->version_major, mv->version_minor,
1317 /* it's good but we don't want it */
1318 lib_drop_message(nal, private, hdr, loopback);
1322 /* we got garbage */
1323 CERROR (LPU64": Bad HELLO message: "
1324 "magic %d, version %d.%d from "LPD64"\n",
1325 nal->libnal_ni.ni_pid.nid, mv->magic,
1326 mv->version_major, mv->version_minor,
1335 hdr->dest_nid = le64_to_cpu(hdr->dest_nid);
1336 if (hdr->dest_nid != nal->libnal_ni.ni_pid.nid) {
1337 CERROR(LPU64": BAD dest NID in %s message from"
1338 LPU64" to "LPU64" (not me)\n",
1339 nal->libnal_ni.ni_pid.nid, hdr_type_string (hdr),
1340 hdr->src_nid, hdr->dest_nid);
1346 CERROR(LPU64": Bad message type 0x%x from "LPU64"\n",
1347 nal->libnal_ni.ni_pid.nid, hdr->type, hdr->src_nid);
1351 /* We've decided we're not receiving garbage since we can parse the
1352 * header. We will return PTL_OK come what may... */
1354 if (!list_empty (&nal->libnal_ni.ni_test_peers) && /* normally we don't */
1355 fail_peer (nal, hdr->src_nid, 0)) /* shall we now? */
1357 CERROR(LPU64": Dropping incoming %s from "LPU64
1358 ": simulated failure\n",
1359 nal->libnal_ni.ni_pid.nid, hdr_type_string (hdr),
1361 lib_drop_message(nal, private, hdr, loopback);
1365 msg = lib_msg_alloc(nal);
1367 CERROR(LPU64": Dropping incoming %s from "LPU64
1368 ": can't allocate a lib_msg_t\n",
1369 nal->libnal_ni.ni_pid.nid, hdr_type_string (hdr),
1371 lib_drop_message(nal, private, hdr, loopback);
1375 switch (hdr->type) {
1377 rc = parse_ack(nal, hdr, private, msg, loopback);
1380 rc = parse_put(nal, hdr, private, msg, loopback);
1383 rc = parse_get(nal, hdr, private, msg, loopback);
1386 rc = parse_reply(nal, hdr, private, msg, loopback);
1390 rc = PTL_FAIL; /* no compiler warning please */
1395 if (msg->md != NULL) {
1397 lib_finalize(nal, private, msg, rc);
1399 LIB_LOCK(nal, flags);
1400 lib_msg_free(nal, msg); /* expects LIB_LOCK held */
1401 LIB_UNLOCK(nal, flags);
1403 lib_drop_message(nal, private, hdr, loopback);
1408 /* That's "OK I can parse it", not "OK I like it" :) */
1412 lib_api_put(nal_t *apinal, ptl_handle_md_t *mdh,
1413 ptl_ack_req_t ack, ptl_process_id_t *id,
1414 ptl_pt_index_t portal, ptl_ac_index_t ac,
1415 ptl_match_bits_t match_bits,
1416 ptl_size_t offset, ptl_hdr_data_t hdr_data)
1418 lib_nal_t *nal = apinal->nal_data;
1419 lib_ni_t *ni = &nal->libnal_ni;
1423 unsigned long flags;
1426 if (!list_empty (&ni->ni_test_peers) && /* normally we don't */
1427 fail_peer (nal, id->nid, 1)) /* shall we now? */
1429 CERROR("Dropping PUT to "LPU64": simulated failure\n",
1431 return PTL_PROCESS_INVALID;
1434 msg = lib_msg_alloc(nal);
1436 CERROR(LPU64": Dropping PUT to "LPU64": ENOMEM on lib_msg_t\n",
1437 ni->ni_pid.nid, id->nid);
1438 return PTL_NO_SPACE;
1441 LIB_LOCK(nal, flags);
1443 md = ptl_handle2md(mdh, nal);
1444 if (md == NULL || md->threshold == 0) {
1445 lib_msg_free(nal, msg);
1446 LIB_UNLOCK(nal, flags);
1448 return PTL_MD_INVALID;
1451 CDEBUG(D_NET, "PtlPut -> "LPX64"\n", id->nid);
1453 memset (&hdr, 0, sizeof (hdr));
1454 hdr.type = cpu_to_le32(PTL_MSG_PUT);
1455 hdr.dest_nid = cpu_to_le64(id->nid);
1456 hdr.dest_pid = cpu_to_le32(id->pid);
1457 hdr.src_nid = cpu_to_le64(ni->ni_pid.nid);
1458 hdr.src_pid = cpu_to_le32(ni->ni_pid.pid);
1459 hdr.payload_length = cpu_to_le32(md->length);
1461 /* NB handles only looked up by creator (no flips) */
1462 if (ack == PTL_ACK_REQ) {
1463 hdr.msg.put.ack_wmd.wh_interface_cookie = ni->ni_interface_cookie;
1464 hdr.msg.put.ack_wmd.wh_object_cookie = md->md_lh.lh_cookie;
1466 hdr.msg.put.ack_wmd = PTL_WIRE_HANDLE_NONE;
1469 hdr.msg.put.match_bits = cpu_to_le64(match_bits);
1470 hdr.msg.put.ptl_index = cpu_to_le32(portal);
1471 hdr.msg.put.offset = cpu_to_le32(offset);
1472 hdr.msg.put.hdr_data = hdr_data;
1474 lib_commit_md(nal, md, msg);
1476 msg->ev.type = PTL_EVENT_SEND_END;
1477 msg->ev.initiator.nid = ni->ni_pid.nid;
1478 msg->ev.initiator.pid = ni->ni_pid.pid;
1479 msg->ev.pt_index = portal;
1480 msg->ev.match_bits = match_bits;
1481 msg->ev.rlength = md->length;
1482 msg->ev.mlength = md->length;
1483 msg->ev.offset = offset;
1484 msg->ev.hdr_data = hdr_data;
1486 lib_md_deconstruct(nal, md, &msg->ev.md);
1487 ptl_md2handle(&msg->ev.md_handle, nal, md);
1489 ni->ni_counters.send_count++;
1490 ni->ni_counters.send_length += md->length;
1492 LIB_UNLOCK(nal, flags);
1494 rc = lib_send (nal, NULL, msg, &hdr, PTL_MSG_PUT,
1495 id->nid, id->pid, md, 0, md->length);
1497 CERROR("Error sending PUT to "LPX64": %d\n",
1499 lib_finalize (nal, NULL, msg, rc);
1502 /* completion will be signalled by an event */
1507 lib_create_reply_msg (lib_nal_t *nal, ptl_nid_t peer_nid, lib_msg_t *getmsg)
1509 /* The NAL can DMA direct to the GET md (i.e. no REPLY msg). This
1510 * returns a msg for the NAL to pass to lib_finalize() when the sink
1511 * data has been received.
1513 * CAVEAT EMPTOR: 'getmsg' is the original GET, which is freed when
1514 * lib_finalize() is called on it, so the NAL must call this first */
1516 lib_ni_t *ni = &nal->libnal_ni;
1517 lib_msg_t *msg = lib_msg_alloc(nal);
1518 lib_md_t *getmd = getmsg->md;
1519 unsigned long flags;
1521 LIB_LOCK(nal, flags);
1523 LASSERT (getmd->pending > 0);
1526 CERROR ("Dropping REPLY from "LPU64": can't allocate msg\n",
1531 if (getmd->threshold == 0) {
1532 CERROR ("Dropping REPLY from "LPU64" for inactive MD %p\n",
1537 LASSERT (getmd->offset == 0);
1539 CDEBUG(D_NET, "Reply from "LPU64" md %p\n", peer_nid, getmd);
1541 lib_commit_md (nal, getmd, msg);
1543 msg->ev.type = PTL_EVENT_REPLY_END;
1544 msg->ev.initiator.nid = peer_nid;
1545 msg->ev.initiator.pid = 0; /* XXX FIXME!!! */
1546 msg->ev.rlength = msg->ev.mlength = getmd->length;
1549 lib_md_deconstruct(nal, getmd, &msg->ev.md);
1550 ptl_md2handle(&msg->ev.md_handle, nal, getmd);
1552 ni->ni_counters.recv_count++;
1553 ni->ni_counters.recv_length += getmd->length;
1555 LIB_UNLOCK(nal, flags);
1560 lib_msg_free(nal, msg);
1562 nal->libnal_ni.ni_counters.drop_count++;
1563 nal->libnal_ni.ni_counters.drop_length += getmd->length;
1565 LIB_UNLOCK (nal, flags);
1571 lib_api_get(nal_t *apinal, ptl_handle_md_t *mdh, ptl_process_id_t *id,
1572 ptl_pt_index_t portal, ptl_ac_index_t ac,
1573 ptl_match_bits_t match_bits, ptl_size_t offset)
1575 lib_nal_t *nal = apinal->nal_data;
1576 lib_ni_t *ni = &nal->libnal_ni;
1580 unsigned long flags;
1583 if (!list_empty (&ni->ni_test_peers) && /* normally we don't */
1584 fail_peer (nal, id->nid, 1)) /* shall we now? */
1586 CERROR("Dropping PUT to "LPX64": simulated failure\n",
1588 return PTL_PROCESS_INVALID;
1591 msg = lib_msg_alloc(nal);
1593 CERROR("Dropping GET to "LPU64": ENOMEM on lib_msg_t\n",
1595 return PTL_NO_SPACE;
1598 LIB_LOCK(nal, flags);
1600 md = ptl_handle2md(mdh, nal);
1601 if (md == NULL || !md->threshold) {
1602 lib_msg_free(nal, msg);
1603 LIB_UNLOCK(nal, flags);
1605 return PTL_MD_INVALID;
1608 CDEBUG(D_NET, "PtlGet -> %Lu: %lu\n", (unsigned long long)id->nid,
1609 (unsigned long)id->pid);
1611 memset (&hdr, 0, sizeof (hdr));
1612 hdr.type = cpu_to_le32(PTL_MSG_GET);
1613 hdr.dest_nid = cpu_to_le64(id->nid);
1614 hdr.dest_pid = cpu_to_le32(id->pid);
1615 hdr.src_nid = cpu_to_le64(ni->ni_pid.nid);
1616 hdr.src_pid = cpu_to_le32(ni->ni_pid.pid);
1617 hdr.payload_length = 0;
1619 /* NB handles only looked up by creator (no flips) */
1620 hdr.msg.get.return_wmd.wh_interface_cookie = ni->ni_interface_cookie;
1621 hdr.msg.get.return_wmd.wh_object_cookie = md->md_lh.lh_cookie;
1623 hdr.msg.get.match_bits = cpu_to_le64(match_bits);
1624 hdr.msg.get.ptl_index = cpu_to_le32(portal);
1625 hdr.msg.get.src_offset = cpu_to_le32(offset);
1626 hdr.msg.get.sink_length = cpu_to_le32(md->length);
1628 lib_commit_md(nal, md, msg);
1630 msg->ev.type = PTL_EVENT_SEND_END;
1631 msg->ev.initiator = ni->ni_pid;
1632 msg->ev.pt_index = portal;
1633 msg->ev.match_bits = match_bits;
1634 msg->ev.rlength = md->length;
1635 msg->ev.mlength = md->length;
1636 msg->ev.offset = offset;
1637 msg->ev.hdr_data = 0;
1639 lib_md_deconstruct(nal, md, &msg->ev.md);
1640 ptl_md2handle(&msg->ev.md_handle, nal, md);
1642 ni->ni_counters.send_count++;
1644 LIB_UNLOCK(nal, flags);
1646 rc = lib_send (nal, NULL, msg, &hdr, PTL_MSG_GET,
1647 id->nid, id->pid, NULL, 0, 0);
1649 CERROR(LPU64": error sending GET to "LPU64": %d\n",
1650 ni->ni_pid.nid, id->nid, rc);
1651 lib_finalize (nal, NULL, msg, rc);
1654 /* completion will be signalled by an event */
1658 void lib_assert_wire_constants (void)
1660 /* Wire protocol assertions generated by 'wirecheck'
1661 * running on Linux mdevi 2.4.21-p4smp-55chaos #1 SMP Tue Jun 8 14:38:44 PDT 2004 i686 i686 i
1662 * with gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-34) */
1666 LASSERT (PORTALS_PROTO_MAGIC == 0xeebc0ded);
1667 LASSERT (PORTALS_PROTO_VERSION_MAJOR == 1);
1668 LASSERT (PORTALS_PROTO_VERSION_MINOR == 0);
1669 LASSERT (PTL_MSG_ACK == 0);
1670 LASSERT (PTL_MSG_PUT == 1);
1671 LASSERT (PTL_MSG_GET == 2);
1672 LASSERT (PTL_MSG_REPLY == 3);
1673 LASSERT (PTL_MSG_HELLO == 4);
1675 /* Checks for struct ptl_handle_wire_t */
1676 LASSERT ((int)sizeof(ptl_handle_wire_t) == 16);
1677 LASSERT ((int)offsetof(ptl_handle_wire_t, wh_interface_cookie) == 0);
1678 LASSERT ((int)sizeof(((ptl_handle_wire_t *)0)->wh_interface_cookie) == 8);
1679 LASSERT ((int)offsetof(ptl_handle_wire_t, wh_object_cookie) == 8);
1680 LASSERT ((int)sizeof(((ptl_handle_wire_t *)0)->wh_object_cookie) == 8);
1682 /* Checks for struct ptl_magicversion_t */
1683 LASSERT ((int)sizeof(ptl_magicversion_t) == 8);
1684 LASSERT ((int)offsetof(ptl_magicversion_t, magic) == 0);
1685 LASSERT ((int)sizeof(((ptl_magicversion_t *)0)->magic) == 4);
1686 LASSERT ((int)offsetof(ptl_magicversion_t, version_major) == 4);
1687 LASSERT ((int)sizeof(((ptl_magicversion_t *)0)->version_major) == 2);
1688 LASSERT ((int)offsetof(ptl_magicversion_t, version_minor) == 6);
1689 LASSERT ((int)sizeof(((ptl_magicversion_t *)0)->version_minor) == 2);
1691 /* Checks for struct ptl_hdr_t */
1692 LASSERT ((int)sizeof(ptl_hdr_t) == 72);
1693 LASSERT ((int)offsetof(ptl_hdr_t, dest_nid) == 0);
1694 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->dest_nid) == 8);
1695 LASSERT ((int)offsetof(ptl_hdr_t, src_nid) == 8);
1696 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->src_nid) == 8);
1697 LASSERT ((int)offsetof(ptl_hdr_t, dest_pid) == 16);
1698 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->dest_pid) == 4);
1699 LASSERT ((int)offsetof(ptl_hdr_t, src_pid) == 20);
1700 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->src_pid) == 4);
1701 LASSERT ((int)offsetof(ptl_hdr_t, type) == 24);
1702 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->type) == 4);
1703 LASSERT ((int)offsetof(ptl_hdr_t, payload_length) == 28);
1704 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->payload_length) == 4);
1705 LASSERT ((int)offsetof(ptl_hdr_t, msg) == 32);
1706 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg) == 40);
1709 LASSERT ((int)offsetof(ptl_hdr_t, msg.ack.dst_wmd) == 32);
1710 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.ack.dst_wmd) == 16);
1711 LASSERT ((int)offsetof(ptl_hdr_t, msg.ack.match_bits) == 48);
1712 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.ack.match_bits) == 8);
1713 LASSERT ((int)offsetof(ptl_hdr_t, msg.ack.mlength) == 56);
1714 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.ack.mlength) == 4);
1717 LASSERT ((int)offsetof(ptl_hdr_t, msg.put.ack_wmd) == 32);
1718 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.ack_wmd) == 16);
1719 LASSERT ((int)offsetof(ptl_hdr_t, msg.put.match_bits) == 48);
1720 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.match_bits) == 8);
1721 LASSERT ((int)offsetof(ptl_hdr_t, msg.put.hdr_data) == 56);
1722 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.hdr_data) == 8);
1723 LASSERT ((int)offsetof(ptl_hdr_t, msg.put.ptl_index) == 64);
1724 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.ptl_index) == 4);
1725 LASSERT ((int)offsetof(ptl_hdr_t, msg.put.offset) == 68);
1726 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.put.offset) == 4);
1729 LASSERT ((int)offsetof(ptl_hdr_t, msg.get.return_wmd) == 32);
1730 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.return_wmd) == 16);
1731 LASSERT ((int)offsetof(ptl_hdr_t, msg.get.match_bits) == 48);
1732 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.match_bits) == 8);
1733 LASSERT ((int)offsetof(ptl_hdr_t, msg.get.ptl_index) == 56);
1734 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.ptl_index) == 4);
1735 LASSERT ((int)offsetof(ptl_hdr_t, msg.get.src_offset) == 60);
1736 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.src_offset) == 4);
1737 LASSERT ((int)offsetof(ptl_hdr_t, msg.get.sink_length) == 64);
1738 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.get.sink_length) == 4);
1741 LASSERT ((int)offsetof(ptl_hdr_t, msg.reply.dst_wmd) == 32);
1742 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.reply.dst_wmd) == 16);
1745 LASSERT ((int)offsetof(ptl_hdr_t, msg.hello.incarnation) == 32);
1746 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.hello.incarnation) == 8);
1747 LASSERT ((int)offsetof(ptl_hdr_t, msg.hello.type) == 40);
1748 LASSERT ((int)sizeof(((ptl_hdr_t *)0)->msg.hello.type) == 4);