1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
6 * This file is part of Portals
7 * http://sourceforge.net/projects/sandiaportals/
9 * Portals is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * Portals is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Portals; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define DEBUG_SUBSYSTEM S_LNET
25 #include <lnet/lib-lnet.h>
27 #if defined(__KERNEL__) && defined(LNET_ROUTER)
29 static char *forwarding = "";
30 CFS_MODULE_PARM(forwarding, "s", charp, 0444,
31 "Explicitly enable/disable forwarding between networks");
33 static int tiny_router_buffers = 1024;
34 CFS_MODULE_PARM(tiny_router_buffers, "i", int, 0444,
35 "# of 0 payload messages to buffer in the router");
36 static int small_router_buffers = 8192;
37 CFS_MODULE_PARM(small_router_buffers, "i", int, 0444,
38 "# of small (1 page) messages to buffer in the router");
39 static int large_router_buffers = 512;
40 CFS_MODULE_PARM(large_router_buffers, "i", int, 0444,
41 "# of large messages to buffer in the router");
43 static int auto_down = 1;
44 CFS_MODULE_PARM(auto_down, "i", int, 0444,
45 "Automatically mark peers down on comms error");
47 static int check_routers_before_use = 0;
48 CFS_MODULE_PARM(check_routers_before_use, "i", int, 0444,
49 "Assume routers are down and ping them before use");
51 static int dead_router_check_interval = 0;
52 CFS_MODULE_PARM(dead_router_check_interval, "i", int, 0444,
53 "Seconds between dead router health checks (<= 0 to disable)");
55 static int live_router_check_interval = 0;
56 CFS_MODULE_PARM(live_router_check_interval, "i", int, 0444,
57 "Seconds between live router health checks (<= 0 to disable)");
59 static int router_ping_timeout = 50;
60 CFS_MODULE_PARM(router_ping_timeout, "i", int, 0444,
61 "Seconds to wait for the reply to a router health query");
64 lnet_peers_start_down(void)
66 return check_routers_before_use;
70 lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive, time_t when)
72 if (when < lp->lp_timestamp) { /* out of date information */
73 CDEBUG(D_NET, "Out of date\n");
77 lp->lp_timestamp = when; /* update timestamp */
78 lp->lp_ping_deadline = 0; /* disable ping timeout */
80 if (lp->lp_alive_count != 0 && /* got old news */
81 (!lp->lp_alive) == (!alive)) { /* new date for old news */
82 CDEBUG(D_NET, "Old news\n");
86 /* Flag that notification is outstanding */
89 lp->lp_alive = !(!alive); /* 1 bit! */
91 lp->lp_notifylnd |= notifylnd;
93 CDEBUG(D_NET, "set %s %d\n", libcfs_nid2str(lp->lp_nid), alive);
97 lnet_do_notify (lnet_peer_t *lp)
99 lnet_ni_t *ni = lp->lp_ni;
105 /* Notify only in 1 thread at any time to ensure ordered notification.
106 * NB individual events can be missed; the only guarantee is that you
107 * always get the most recent news */
109 if (lp->lp_notifying) {
114 lp->lp_notifying = 1;
116 while (lp->lp_notify) {
117 alive = lp->lp_alive;
118 notifylnd = lp->lp_notifylnd;
120 lp->lp_notifylnd = 0;
123 if (notifylnd && ni->ni_lnd->lnd_notify != NULL) {
126 /* A new notification could happen now; I'll handle it
127 * when control returns to me */
129 (ni->ni_lnd->lnd_notify)(ni, lp->lp_nid, alive);
135 lp->lp_notifying = 0;
141 lnet_notify (lnet_ni_t *ni, lnet_nid_t nid, int alive, time_t when)
143 lnet_peer_t *lp = NULL;
144 time_t now = cfs_time_current_sec();
146 LASSERT (!in_interrupt ());
148 CDEBUG (D_NET, "%s notifying %s: %s\n",
149 (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid),
151 alive ? "up" : "down");
154 LNET_NIDNET(ni->ni_nid) != LNET_NIDNET(nid)) {
155 CWARN ("Ignoring notification of %s %s by %s (different net)\n",
156 libcfs_nid2str(nid), alive ? "birth" : "death",
157 libcfs_nid2str(ni->ni_nid));
161 /* can't do predictions... */
163 CWARN ("Ignoring prediction from %s of %s %s "
164 "%ld seconds in the future\n",
165 (ni == NULL) ? "userspace" : libcfs_nid2str(ni->ni_nid),
166 libcfs_nid2str(nid), alive ? "up" : "down",
171 if (ni != NULL && !alive && /* LND telling me she's down */
172 !auto_down) { /* auto-down disabled */
173 CDEBUG(D_NET, "Auto-down disabled\n");
179 lp = lnet_find_peer_locked(nid);
183 CDEBUG(D_NET, "%s not found\n", libcfs_nid2str(nid));
187 lnet_notify_locked(lp, ni == NULL, alive, when);
195 lnet_peer_decref_locked(lp);
200 EXPORT_SYMBOL(lnet_notify);
205 lnet_notify (lnet_ni_t *ni, lnet_nid_t nid, int alive, time_t when)
211 lnet_notify_locked (lnet_peer_t *lp, int notifylnd, int alive, time_t when)
219 lnet_rtr_addref_locked(lnet_peer_t *lp)
221 LASSERT (lp->lp_refcount > 0);
222 LASSERT (lp->lp_rtr_refcount >= 0);
224 lp->lp_rtr_refcount++;
225 if (lp->lp_rtr_refcount == 1) {
226 struct list_head *pos;
228 /* a simple insertion sort */
229 list_for_each_prev(pos, &the_lnet.ln_routers) {
230 lnet_peer_t *rtr = list_entry(pos, lnet_peer_t,
233 if (rtr->lp_nid < lp->lp_nid)
237 list_add(&lp->lp_rtr_list, pos);
238 /* addref for the_lnet.ln_routers */
239 lnet_peer_addref_locked(lp);
240 the_lnet.ln_routers_version++;
245 lnet_rtr_decref_locked(lnet_peer_t *lp)
247 LASSERT (lp->lp_refcount > 0);
248 LASSERT (lp->lp_rtr_refcount > 0);
250 lp->lp_rtr_refcount--;
251 if (lp->lp_rtr_refcount == 0) {
252 list_del(&lp->lp_rtr_list);
253 /* decref for the_lnet.ln_routers */
254 lnet_peer_decref_locked(lp);
255 the_lnet.ln_routers_version++;
260 lnet_find_net_locked (__u32 net)
262 lnet_remotenet_t *rnet;
263 struct list_head *tmp;
265 LASSERT (!the_lnet.ln_shutdown);
267 list_for_each (tmp, &the_lnet.ln_remote_nets) {
268 rnet = list_entry(tmp, lnet_remotenet_t, lrn_list);
270 if (rnet->lrn_net == net)
277 lnet_add_route (__u32 net, unsigned int hops, lnet_nid_t gateway)
279 struct list_head zombies;
281 lnet_remotenet_t *rnet;
282 lnet_remotenet_t *rnet2;
284 lnet_route_t *route2;
289 CDEBUG(D_NET, "Add route: net %s hops %u gw %s\n",
290 libcfs_net2str(net), hops, libcfs_nid2str(gateway));
292 if (gateway == LNET_NID_ANY ||
293 LNET_NETTYP(LNET_NIDNET(gateway)) == LOLND ||
294 net == LNET_NIDNET(LNET_NID_ANY) ||
295 LNET_NETTYP(net) == LOLND ||
296 LNET_NIDNET(gateway) == net ||
297 hops < 1 || hops > 255)
300 if (lnet_islocalnet(net)) /* it's a local network */
301 return 0; /* ignore the route entry */
303 /* Assume net, route, all new */
304 LIBCFS_ALLOC(route, sizeof(*route));
305 LIBCFS_ALLOC(rnet, sizeof(*rnet));
306 if (route == NULL || rnet == NULL) {
307 CERROR("Out of memory creating route %s %d %s\n",
308 libcfs_net2str(net), hops, libcfs_nid2str(gateway));
310 LIBCFS_FREE(route, sizeof(*route));
312 LIBCFS_FREE(rnet, sizeof(*rnet));
316 CFS_INIT_LIST_HEAD(&rnet->lrn_routes);
318 rnet->lrn_hops = hops;
322 rc = lnet_nid2peer_locked(&route->lr_gateway, gateway);
326 LIBCFS_FREE(route, sizeof(*route));
327 LIBCFS_FREE(rnet, sizeof(*rnet));
329 if (rc == -EHOSTUNREACH) /* gateway is not on a local net */
330 return 0; /* ignore the route entry */
332 CERROR("Error %d creating route %s %d %s\n", rc,
333 libcfs_net2str(net), hops, libcfs_nid2str(gateway));
337 LASSERT (!the_lnet.ln_shutdown);
338 CFS_INIT_LIST_HEAD(&zombies);
340 rnet2 = lnet_find_net_locked(net);
343 list_add_tail(&rnet->lrn_list, &the_lnet.ln_remote_nets);
347 if (hops > rnet2->lrn_hops) {
348 /* New route is longer; ignore it */
350 } else if (hops < rnet2->lrn_hops) {
351 /* new route supercedes all currently known routes to this
353 list_add(&zombies, &rnet2->lrn_routes);
354 list_del_init(&rnet2->lrn_routes);
358 /* New route has the same hopcount as existing routes; search
359 * for a duplicate route (it's a NOOP if it is) */
360 list_for_each (e, &rnet2->lrn_routes) {
361 route2 = list_entry(e, lnet_route_t, lr_list);
363 if (route2->lr_gateway == route->lr_gateway) {
368 /* our loopups must be true */
369 LASSERT (route2->lr_gateway->lp_nid != gateway);
374 ni = route->lr_gateway->lp_ni;
375 lnet_ni_addref_locked(ni);
378 list_add_tail(&route->lr_list, &rnet2->lrn_routes);
379 the_lnet.ln_remote_nets_version++;
381 lnet_rtr_addref_locked(route->lr_gateway);
385 /* XXX Assume alive */
386 if (ni->ni_lnd->lnd_notify != NULL)
387 (ni->ni_lnd->lnd_notify)(ni, gateway, 1);
391 lnet_peer_decref_locked(route->lr_gateway);
393 LIBCFS_FREE(route, sizeof(*route));
397 LIBCFS_FREE(rnet, sizeof(*rnet));
399 while (!list_empty(&zombies)) {
400 route = list_entry(zombies.next, lnet_route_t, lr_list);
401 list_del(&route->lr_list);
404 lnet_rtr_decref_locked(route->lr_gateway);
405 lnet_peer_decref_locked(route->lr_gateway);
407 LIBCFS_FREE(route, sizeof(*route));
414 lnet_check_routes (void)
416 lnet_remotenet_t *rnet;
418 lnet_route_t *route2;
419 struct list_head *e1;
420 struct list_head *e2;
424 list_for_each (e1, &the_lnet.ln_remote_nets) {
425 rnet = list_entry(e1, lnet_remotenet_t, lrn_list);
428 list_for_each (e2, &rnet->lrn_routes) {
429 route = list_entry(e2, lnet_route_t, lr_list);
433 else if (route->lr_gateway->lp_ni !=
434 route2->lr_gateway->lp_ni) {
437 CERROR("Routes to %s via %s and %s not supported\n",
438 libcfs_net2str(rnet->lrn_net),
439 libcfs_nid2str(route->lr_gateway->lp_nid),
440 libcfs_nid2str(route2->lr_gateway->lp_nid));
451 lnet_del_route (__u32 net, lnet_nid_t gw_nid)
453 lnet_remotenet_t *rnet;
455 struct list_head *e1;
456 struct list_head *e2;
459 CDEBUG(D_NET, "Del route: net %s : gw %s\n",
460 libcfs_net2str(net), libcfs_nid2str(gw_nid));
462 /* NB Caller may specify either all routes via the given gateway
463 * or a specific route entry actual NIDs) */
468 list_for_each (e1, &the_lnet.ln_remote_nets) {
469 rnet = list_entry(e1, lnet_remotenet_t, lrn_list);
471 if (!(net == LNET_NIDNET(LNET_NID_ANY) ||
472 net == rnet->lrn_net))
475 list_for_each (e2, &rnet->lrn_routes) {
476 route = list_entry(e2, lnet_route_t, lr_list);
478 if (!(gw_nid == LNET_NID_ANY ||
479 gw_nid == route->lr_gateway->lp_nid))
482 list_del(&route->lr_list);
483 the_lnet.ln_remote_nets_version++;
485 if (list_empty(&rnet->lrn_routes))
486 list_del(&rnet->lrn_list);
490 lnet_rtr_decref_locked(route->lr_gateway);
491 lnet_peer_decref_locked(route->lr_gateway);
494 LIBCFS_FREE(route, sizeof (*route));
497 LIBCFS_FREE(rnet, sizeof(*rnet));
509 lnet_destroy_routes (void)
511 lnet_del_route(LNET_NIDNET(LNET_NID_ANY), LNET_NID_ANY);
515 lnet_get_route (int idx, __u32 *net, __u32 *hops,
516 lnet_nid_t *gateway, __u32 *alive)
518 struct list_head *e1;
519 struct list_head *e2;
520 lnet_remotenet_t *rnet;
525 list_for_each (e1, &the_lnet.ln_remote_nets) {
526 rnet = list_entry(e1, lnet_remotenet_t, lrn_list);
528 list_for_each (e2, &rnet->lrn_routes) {
529 route = list_entry(e2, lnet_route_t, lr_list);
532 *net = rnet->lrn_net;
533 *hops = rnet->lrn_hops;
534 *gateway = route->lr_gateway->lp_nid;
535 *alive = route->lr_gateway->lp_alive;
546 #if defined(__KERNEL__) && defined(LNET_ROUTER)
548 lnet_router_checker_event (lnet_event_t *event)
550 /* CAVEAT EMPTOR: I'm called with LNET_LOCKed and I'm not allowed to
551 * drop it (that's how come I see _every_ event, even ones that would
556 if (event->unlinked) {
557 /* The router checker thread has unlinked the rc_md
559 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_UNLINKING);
560 the_lnet.ln_rc_state = LNET_RC_STATE_UNLINKED;
561 mutex_up(&the_lnet.ln_rc_signal);
565 LASSERT (event->type == LNET_EVENT_SEND ||
566 event->type == LNET_EVENT_REPLY);
568 nid = (event->type == LNET_EVENT_SEND) ?
569 event->target.nid : event->initiator.nid;
571 lp = lnet_find_peer_locked(nid);
573 /* router may have been removed */
574 CDEBUG(D_NET, "Router %s not found\n", libcfs_nid2str(nid));
578 if (event->type == LNET_EVENT_SEND) /* re-enable another ping */
579 lp->lp_ping_notsent = 0;
581 if (lnet_isrouter(lp) && /* ignore if no longer a router */
582 (event->status != 0 ||
583 event->type == LNET_EVENT_REPLY)) {
585 /* A successful REPLY means the router is up. If _any_ comms
586 * to the router fail I assume it's down (this will happen if
587 * we ping alive routers to try to detect router death before
588 * apps get burned). */
590 lnet_notify_locked(lp, 1, (event->status == 0),
591 cfs_time_current_sec());
593 /* The router checker will wake up very shortly and do the
594 * actual notification.
595 * XXX If 'lp' stops being a router before then, it will still
596 * have the notification pending!!! */
599 /* This decref will NOT drop LNET_LOCK (it had to have 1 ref when it
600 * was in the peer table and I've not dropped the lock, so no-one else
601 * can have reduced the refcount) */
602 LASSERT(lp->lp_refcount > 1);
604 lnet_peer_decref_locked(lp);
608 lnet_router_checker(void *arg)
610 static lnet_ping_info_t pinginfo;
613 lnet_handle_md_t mdh;
616 struct list_head *entry;
618 lnet_process_id_t rtr_id;
621 cfs_daemonize("router_checker");
624 rtr_id.pid = LUSTRE_SRV_LNET_PID;
626 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
628 /* initialize md content */
629 md.start = &pinginfo;
630 md.length = sizeof(pinginfo);
631 md.threshold = LNET_MD_THRESH_INF;
633 md.options = LNET_MD_TRUNCATE,
635 md.eq_handle = the_lnet.ln_rc_eqh;
637 rc = LNetMDBind(md, LNET_UNLINK, &mdh);
640 CERROR("Can't bind MD: %d\n", rc);
641 the_lnet.ln_rc_state = rc;
642 mutex_up(&the_lnet.ln_rc_signal);
648 the_lnet.ln_rc_state = LNET_RC_STATE_RUNNING;
649 mutex_up(&the_lnet.ln_rc_signal); /* let my parent go */
651 while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) {
656 version = the_lnet.ln_routers_version;
658 list_for_each (entry, &the_lnet.ln_routers) {
659 rtr = list_entry(entry, lnet_peer_t, lp_rtr_list);
661 lnet_peer_addref_locked(rtr);
663 now = cfs_time_current_sec();
665 if (rtr->lp_ping_deadline != 0 && /* ping timed out? */
666 now > rtr->lp_ping_deadline)
667 lnet_notify_locked(rtr, 1, 0, now);
671 /* Run any outstanding notificiations */
675 secs = live_router_check_interval;
677 secs = dead_router_check_interval;
683 !rtr->lp_ping_notsent &&
684 now > rtr->lp_ping_timestamp + secs) {
685 CDEBUG(D_NET, "Check: %s\n",
686 libcfs_nid2str(rtr->lp_nid));
689 rtr_id.nid = rtr->lp_nid;
690 rtr->lp_ping_notsent = 1;
691 rtr->lp_ping_timestamp = now;
693 if (rtr->lp_ping_deadline == 0)
694 rtr->lp_ping_deadline =
695 now + router_ping_timeout;
699 LNetGet(LNET_NID_ANY, mdh, rtr_id,
700 LNET_RESERVED_PORTAL,
701 LNET_PROTO_PING_MATCHBITS, 0);
705 lnet_peer_decref_locked(rtr);
707 if (version != the_lnet.ln_routers_version) {
708 /* the routers list has changed */
715 /* Call cfs_pause() here always adds 1 to load average
716 * because kernel counts # active tasks as nr_running
717 * + nr_uninterruptible. */
718 cfs_schedule_timeout(CFS_TASK_INTERRUPTIBLE,
719 cfs_time_seconds(1));
722 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_STOPTHREAD);
723 the_lnet.ln_rc_state = LNET_RC_STATE_UNLINKING;
725 rc = LNetMDUnlink(mdh);
728 /* The unlink event callback will signal final completion */
734 lnet_wait_known_routerstate(void)
737 struct list_head *entry;
744 list_for_each (entry, &the_lnet.ln_routers) {
745 rtr = list_entry(entry, lnet_peer_t, lp_rtr_list);
747 if (rtr->lp_alive_count == 0) {
758 cfs_pause(cfs_time_seconds(1));
763 lnet_router_checker_stop(void)
767 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING ||
768 the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
770 if (the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN)
773 the_lnet.ln_rc_state = LNET_RC_STATE_STOPTHREAD;
774 /* block until event callback signals exit */
775 mutex_down(&the_lnet.ln_rc_signal);
777 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_UNLINKED);
779 rc = LNetEQFree(the_lnet.ln_rc_eqh);
782 the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
786 lnet_router_checker_start(void)
790 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
792 if (check_routers_before_use &&
793 dead_router_check_interval <= 0) {
794 LCONSOLE_ERROR_MSG(0x10a, "'dead_router_check_interval' must be"
795 " set if 'check_routers_before_use' is set"
800 if (live_router_check_interval <= 0 &&
801 dead_router_check_interval <= 0)
804 init_mutex_locked(&the_lnet.ln_rc_signal);
806 /* EQ size doesn't matter; the callback is guaranteed to get every
808 rc = LNetEQAlloc(1, lnet_router_checker_event,
809 &the_lnet.ln_rc_eqh);
811 CERROR("Can't allocate EQ: %d\n", rc);
815 rc = (int)cfs_kernel_thread(lnet_router_checker, NULL, 0);
817 CERROR("Can't start router checker thread: %d\n", rc);
821 mutex_down(&the_lnet.ln_rc_signal); /* wait for checker to startup */
823 rc = the_lnet.ln_rc_state;
825 the_lnet.ln_rc_state = LNET_RC_STATE_SHUTDOWN;
829 LASSERT (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
831 if (check_routers_before_use) {
832 /* Note that a helpful side-effect of pinging all known routers
833 * at startup is that it makes them drop stale connections they
834 * may have to a previous instance of me. */
835 lnet_wait_known_routerstate();
841 rc = LNetEQFree(the_lnet.ln_rc_eqh);
847 lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages)
849 int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]);
851 while (--npages >= 0)
852 cfs_free_page(rb->rb_kiov[npages].kiov_page);
858 lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp)
860 int npages = rbp->rbp_npages;
861 int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]);
866 LIBCFS_ALLOC(rb, sz);
872 for (i = 0; i < npages; i++) {
873 page = cfs_alloc_page(CFS_ALLOC_ZERO | CFS_ALLOC_STD);
876 cfs_free_page(rb->rb_kiov[i].kiov_page);
882 rb->rb_kiov[i].kiov_len = CFS_PAGE_SIZE;
883 rb->rb_kiov[i].kiov_offset = 0;
884 rb->rb_kiov[i].kiov_page = page;
891 lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp)
893 int npages = rbp->rbp_npages;
897 LASSERT (list_empty(&rbp->rbp_msgs));
898 LASSERT (rbp->rbp_credits == rbp->rbp_nbuffers);
900 while (!list_empty(&rbp->rbp_bufs)) {
901 LASSERT (rbp->rbp_credits > 0);
903 rb = list_entry(rbp->rbp_bufs.next,
904 lnet_rtrbuf_t, rb_list);
905 list_del(&rb->rb_list);
906 lnet_destroy_rtrbuf(rb, npages);
910 LASSERT (rbp->rbp_nbuffers == nbuffers);
911 LASSERT (rbp->rbp_credits == nbuffers);
913 rbp->rbp_nbuffers = rbp->rbp_credits = 0;
917 lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs)
922 if (rbp->rbp_nbuffers != 0) {
923 LASSERT (rbp->rbp_nbuffers == nbufs);
927 for (i = 0; i < nbufs; i++) {
928 rb = lnet_new_rtrbuf(rbp);
931 CERROR("Failed to allocate %d router bufs of %d pages\n",
932 nbufs, rbp->rbp_npages);
938 rbp->rbp_mincredits++;
939 list_add(&rb->rb_list, &rbp->rbp_bufs);
941 /* No allocation "under fire" */
942 /* Otherwise we'd need code to schedule blocked msgs etc */
943 LASSERT (!the_lnet.ln_routing);
946 LASSERT (rbp->rbp_credits == nbufs);
951 lnet_rtrpool_init(lnet_rtrbufpool_t *rbp, int npages)
953 CFS_INIT_LIST_HEAD(&rbp->rbp_msgs);
954 CFS_INIT_LIST_HEAD(&rbp->rbp_bufs);
956 rbp->rbp_npages = npages;
957 rbp->rbp_credits = 0;
958 rbp->rbp_mincredits = 0;
962 lnet_free_rtrpools(void)
964 lnet_rtrpool_free_bufs(&the_lnet.ln_rtrpools[0]);
965 lnet_rtrpool_free_bufs(&the_lnet.ln_rtrpools[1]);
966 lnet_rtrpool_free_bufs(&the_lnet.ln_rtrpools[2]);
970 lnet_init_rtrpools(void)
973 int large_pages = (LNET_MTU + CFS_PAGE_SIZE - 1) >> CFS_PAGE_SHIFT;
975 lnet_rtrpool_init(&the_lnet.ln_rtrpools[0], 0);
976 lnet_rtrpool_init(&the_lnet.ln_rtrpools[1], small_pages);
977 lnet_rtrpool_init(&the_lnet.ln_rtrpools[2], large_pages);
982 lnet_alloc_rtrpools(int im_a_router)
986 if (!strcmp(forwarding, "")) {
987 /* not set either way */
990 } else if (!strcmp(forwarding, "disabled")) {
991 /* explicitly disabled */
993 } else if (!strcmp(forwarding, "enabled")) {
994 /* explicitly enabled */
996 LCONSOLE_ERROR_MSG(0x10b, "'forwarding' not set to either "
997 "'enabled' or 'disabled'\n");
1001 if (tiny_router_buffers <= 0) {
1002 LCONSOLE_ERROR_MSG(0x10c, "tiny_router_buffers=%d invalid when "
1003 "routing enabled\n", tiny_router_buffers);
1008 rc = lnet_rtrpool_alloc_bufs(&the_lnet.ln_rtrpools[0],
1009 tiny_router_buffers);
1013 if (small_router_buffers <= 0) {
1014 LCONSOLE_ERROR_MSG(0x10d, "small_router_buffers=%d invalid when"
1015 " routing enabled\n", small_router_buffers);
1020 rc = lnet_rtrpool_alloc_bufs(&the_lnet.ln_rtrpools[1],
1021 small_router_buffers);
1025 if (large_router_buffers <= 0) {
1026 LCONSOLE_ERROR_MSG(0x10e, "large_router_buffers=%d invalid when"
1027 " routing enabled\n", large_router_buffers);
1032 rc = lnet_rtrpool_alloc_bufs(&the_lnet.ln_rtrpools[2],
1033 large_router_buffers);
1038 the_lnet.ln_routing = 1;
1044 lnet_free_rtrpools();
1051 lnet_peers_start_down(void)
1057 lnet_router_checker_stop(void)
1063 lnet_router_checker_start(void)
1069 lnet_free_rtrpools (void)
1074 lnet_init_rtrpools (void)
1079 lnet_alloc_rtrpools (int im_a_arouter)