1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
38 * Match Entry management routines
41 #define DEBUG_SUBSYSTEM S_LNET
43 #include <lnet/lib-lnet.h>
46 LNetMEAttach(unsigned int portal,
47 lnet_process_id_t match_id,
48 __u64 match_bits, __u64 ignore_bits,
49 lnet_unlink_t unlink, lnet_ins_pos_t pos,
50 lnet_handle_me_t *handle)
54 LASSERT (the_lnet.ln_init);
55 LASSERT (the_lnet.ln_refcount > 0);
57 if ((int)portal >= the_lnet.ln_nportals)
66 me->me_portal = portal;
67 me->me_match_id = match_id;
68 me->me_match_bits = match_bits;
69 me->me_ignore_bits = ignore_bits;
70 me->me_unlink = unlink;
73 lnet_initialise_handle (&me->me_lh, LNET_COOKIE_TYPE_ME);
75 if (pos == LNET_INS_AFTER)
76 list_add_tail(&me->me_list, &(the_lnet.ln_portals[portal].ptl_ml));
78 list_add(&me->me_list, &(the_lnet.ln_portals[portal].ptl_ml));
80 lnet_me2handle(handle, me);
88 LNetMEInsert(lnet_handle_me_t current_meh,
89 lnet_process_id_t match_id,
90 __u64 match_bits, __u64 ignore_bits,
91 lnet_unlink_t unlink, lnet_ins_pos_t pos,
92 lnet_handle_me_t *handle)
94 lnet_me_t *current_me;
97 LASSERT (the_lnet.ln_init);
98 LASSERT (the_lnet.ln_refcount > 0);
100 new_me = lnet_me_alloc();
106 current_me = lnet_handle2me(¤t_meh);
107 if (current_me == NULL) {
108 lnet_me_free (new_me);
114 new_me->me_portal = current_me->me_portal;
115 new_me->me_match_id = match_id;
116 new_me->me_match_bits = match_bits;
117 new_me->me_ignore_bits = ignore_bits;
118 new_me->me_unlink = unlink;
119 new_me->me_md = NULL;
121 lnet_initialise_handle (&new_me->me_lh, LNET_COOKIE_TYPE_ME);
123 if (pos == LNET_INS_AFTER)
124 list_add(&new_me->me_list, ¤t_me->me_list);
126 list_add_tail(&new_me->me_list, ¤t_me->me_list);
128 lnet_me2handle(handle, new_me);
136 LNetMEUnlink(lnet_handle_me_t meh)
142 LASSERT (the_lnet.ln_init);
143 LASSERT (the_lnet.ln_refcount > 0);
147 me = lnet_handle2me(&meh);
156 md->md_refcount == 0) {
157 lnet_build_unlink_event(md, &ev);
158 lnet_enq_event_locked(md->md_eq, &ev);
167 /* call with LNET_LOCK please */
169 lnet_me_unlink(lnet_me_t *me)
171 list_del (&me->me_list);
173 if (me->me_md != NULL) {
174 me->me_md->md_me = NULL;
175 lnet_md_unlink(me->me_md);
178 lnet_invalidate_handle (&me->me_lh);
184 lib_me_dump(lnet_me_t *me)
186 CWARN("Match Entry %p ("LPX64")\n", me,
187 me->me_lh.lh_cookie);
189 CWARN("\tMatch/Ignore\t= %016lx / %016lx\n",
190 me->me_match_bits, me->me_ignore_bits);
192 CWARN("\tMD\t= %p\n", me->md);
193 CWARN("\tprev\t= %p\n",
194 list_entry(me->me_list.prev, lnet_me_t, me_list));
195 CWARN("\tnext\t= %p\n",
196 list_entry(me->me_list.next, lnet_me_t, me_list));