4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2016, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lnet/include/lnet/lib-types.h
34 * Types used by the library side routines that do not need to be
35 * exposed to the user application
38 #ifndef __LNET_LIB_TYPES_H__
39 #define __LNET_LIB_TYPES_H__
42 # error This include is only for kernel use.
45 #include <linux/kthread.h>
46 #include <linux/uio.h>
47 #include <linux/types.h>
49 #include <lnet/lnetctl.h>
51 /* Max payload size */
52 #ifndef CONFIG_LNET_MAX_PAYLOAD
53 # error "CONFIG_LNET_MAX_PAYLOAD must be defined in config.h"
56 #define LNET_MAX_PAYLOAD CONFIG_LNET_MAX_PAYLOAD
57 #if (LNET_MAX_PAYLOAD < LNET_MTU)
58 # error "LNET_MAX_PAYLOAD too small - error in configure --with-max-payload-mb"
59 #elif (LNET_MAX_PAYLOAD > (PAGE_SIZE * LNET_MAX_IOV))
60 # error "LNET_MAX_PAYLOAD too large - error in configure --with-max-payload-mb"
66 typedef struct lnet_msg {
67 struct list_head msg_activelist;
68 struct list_head msg_list; /* Q for credits/MD */
70 struct lnet_process_id msg_target;
71 /* Primary NID of the source. */
72 lnet_nid_t msg_initiator;
73 /* where is it from, it's only for building event */
77 /* committed for sending */
78 unsigned int msg_tx_committed:1;
79 /* CPT # this message committed for sending */
80 unsigned int msg_tx_cpt:15;
81 /* committed for receiving */
82 unsigned int msg_rx_committed:1;
83 /* CPT # this message committed for receiving */
84 unsigned int msg_rx_cpt:15;
85 /* queued for tx credit */
86 unsigned int msg_tx_delayed:1;
87 /* queued for RX buffer */
88 unsigned int msg_rx_delayed:1;
89 /* ready for pending on RX delay list */
90 unsigned int msg_rx_ready_delay:1;
92 unsigned int msg_vmflush:1; /* VM trying to free memory */
93 unsigned int msg_target_is_router:1; /* sending to a router */
94 unsigned int msg_routing:1; /* being forwarded */
95 unsigned int msg_ack:1; /* ack on finalize (PUT) */
96 unsigned int msg_sending:1; /* outgoing message */
97 unsigned int msg_receiving:1; /* being received */
98 unsigned int msg_txcredit:1; /* taken an NI send credit */
99 unsigned int msg_peertxcredit:1; /* taken a peer send credit */
100 unsigned int msg_rtrcredit:1; /* taken a globel router credit */
101 unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */
102 unsigned int msg_onactivelist:1; /* on the activelist */
103 unsigned int msg_rdma_get:1;
105 struct lnet_peer_ni *msg_txpeer; /* peer I'm sending to */
106 struct lnet_peer_ni *msg_rxpeer; /* peer I received from */
109 struct lnet_libmd *msg_md;
110 /* the NI the message was sent or received over */
111 struct lnet_ni *msg_txni;
112 struct lnet_ni *msg_rxni;
114 unsigned int msg_len;
115 unsigned int msg_wanted;
116 unsigned int msg_offset;
117 unsigned int msg_niov;
118 struct kvec *msg_iov;
119 lnet_kiov_t *msg_kiov;
121 struct lnet_event msg_ev;
122 struct lnet_hdr msg_hdr;
125 typedef struct lnet_libhandle {
126 struct list_head lh_hash_chain;
130 #define lh_entry(ptr, type, member) \
131 ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
133 typedef struct lnet_eq {
134 struct list_head eq_list;
135 struct lnet_libhandle eq_lh;
136 unsigned long eq_enq_seq;
137 unsigned long eq_deq_seq;
138 unsigned int eq_size;
139 lnet_eq_handler_t eq_callback;
140 struct lnet_event *eq_events;
141 int **eq_refs; /* percpt refcount for EQ */
144 typedef struct lnet_me {
145 struct list_head me_list;
146 struct lnet_libhandle me_lh;
147 struct lnet_process_id me_match_id;
148 unsigned int me_portal;
149 unsigned int me_pos; /* hash offset in mt_hash */
151 __u64 me_ignore_bits;
152 enum lnet_unlink me_unlink;
153 struct lnet_libmd *me_md;
156 typedef struct lnet_libmd {
157 struct list_head md_list;
158 struct lnet_libhandle md_lh;
159 struct lnet_me *md_me;
161 unsigned int md_offset;
162 unsigned int md_length;
163 unsigned int md_max_size;
166 unsigned int md_options;
167 unsigned int md_flags;
168 unsigned int md_niov; /* # frags at end of struct */
170 struct lnet_eq *md_eq;
171 struct lnet_handle_md md_bulk_handle;
173 struct kvec iov[LNET_MAX_IOV];
174 lnet_kiov_t kiov[LNET_MAX_IOV];
178 #define LNET_MD_FLAG_ZOMBIE (1 << 0)
179 #define LNET_MD_FLAG_AUTO_UNLINK (1 << 1)
180 #define LNET_MD_FLAG_ABORTED (1 << 2)
182 typedef struct lnet_test_peer {
183 /* info about peers we are trying to fail */
184 struct list_head tp_list; /* ln_test_peers */
185 lnet_nid_t tp_nid; /* matching nid */
186 unsigned int tp_threshold; /* # failures to simulate */
189 #define LNET_COOKIE_TYPE_MD 1
190 #define LNET_COOKIE_TYPE_ME 2
191 #define LNET_COOKIE_TYPE_EQ 3
192 #define LNET_COOKIE_TYPE_BITS 2
193 #define LNET_COOKIE_MASK ((1ULL << LNET_COOKIE_TYPE_BITS) - 1ULL)
195 struct lnet_ni; /* forward ref */
198 typedef struct lnet_lnd {
199 /* fields managed by portals */
200 struct list_head lnd_list; /* stash in the LND table */
201 int lnd_refcount; /* # active instances */
203 /* fields initialized by the LND */
206 int (*lnd_startup)(struct lnet_ni *ni);
207 void (*lnd_shutdown)(struct lnet_ni *ni);
208 int (*lnd_ctl)(struct lnet_ni *ni, unsigned int cmd, void *arg);
210 /* In data movement APIs below, payload buffers are described as a set
211 * of 'niov' fragments which are...
213 * in virtual memory (struct kvec *iov != NULL)
215 * in pages (kernel only: plt_kiov_t *kiov != NULL).
216 * The LND may NOT overwrite these fragment descriptors.
217 * An 'offset' and may specify a byte offset within the set of
218 * fragments to start from
221 /* Start sending a preformatted message. 'private' is NULL for PUT and
222 * GET messages; otherwise this is a response to an incoming message
223 * and 'private' is the 'private' passed to lnet_parse(). Return
224 * non-zero for immediate failure, otherwise complete later with
226 int (*lnd_send)(struct lnet_ni *ni, void *private,
227 struct lnet_msg *msg);
229 /* Start receiving 'mlen' bytes of payload data, skipping the following
230 * 'rlen' - 'mlen' bytes. 'private' is the 'private' passed to
231 * lnet_parse(). Return non-zero for immedaite failure, otherwise
232 * complete later with lnet_finalize(). This also gives back a receive
233 * credit if the LND does flow control. */
234 int (*lnd_recv)(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
235 int delayed, unsigned int niov,
236 struct kvec *iov, lnet_kiov_t *kiov,
237 unsigned int offset, unsigned int mlen, unsigned int rlen);
239 /* lnet_parse() has had to delay processing of this message
240 * (e.g. waiting for a forwarding buffer or send credits). Give the
241 * LND a chance to free urgently needed resources. If called, return 0
242 * for success and do NOT give back a receive credit; that has to wait
243 * until lnd_recv() gets called. On failure return < 0 and
244 * release resources; lnd_recv() will not be called. */
245 int (*lnd_eager_recv)(struct lnet_ni *ni, void *private,
246 struct lnet_msg *msg, void **new_privatep);
248 /* notification of peer health */
249 void (*lnd_notify)(struct lnet_ni *ni, lnet_nid_t peer, int alive);
251 /* query of peer aliveness */
252 void (*lnd_query)(struct lnet_ni *ni, lnet_nid_t peer, cfs_time_t *when);
254 /* accept a new connection */
255 int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock);
258 typedef struct lnet_ni_status {
262 } WIRE_ATTR lnet_ni_status_t;
264 struct lnet_tx_queue {
265 int tq_credits; /* # tx credits free */
266 int tq_credits_min; /* lowest it's been */
267 int tq_credits_max; /* total # tx credits */
268 struct list_head tq_delayed; /* delayed TXs */
271 enum lnet_net_state {
272 /* set when net block is allocated */
273 LNET_NET_STATE_INIT = 0,
274 /* set when NIs in net are started successfully */
275 LNET_NET_STATE_ACTIVE,
276 /* set if all NIs in net are in FAILED state */
277 LNET_NET_STATE_INACTIVE,
278 /* set when shutting down a NET */
279 LNET_NET_STATE_DELETING
283 /* set when NI block is allocated */
284 LNET_NI_STATE_INIT = 0,
285 /* set when NI is started successfully */
286 LNET_NI_STATE_ACTIVE,
287 /* set when LND notifies NI failed */
288 LNET_NI_STATE_FAILED,
289 /* set when LND notifies NI degraded */
290 LNET_NI_STATE_DEGRADED,
291 /* set when shuttding down NI */
292 LNET_NI_STATE_DELETING
295 struct lnet_element_stats {
302 /* chain on the ln_nets */
303 struct list_head net_list;
305 /* net ID, which is composed of
306 * (net_type << 16) | net_num.
307 * net_type can be one of the enumerated types defined in
308 * lnet/include/lnet/nidstr.h */
311 /* priority of the network */
314 /* total number of CPTs in the array */
317 /* cumulative CPTs of all NIs in this net */
320 /* network tunables */
321 struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
324 * boolean to indicate that the tunables have been set and
327 bool net_tunables_set;
329 /* procedural interface */
330 struct lnet_lnd *net_lnd;
332 /* list of NIs on this net */
333 struct list_head net_ni_list;
335 /* list of NIs being added, but not started yet */
336 struct list_head net_ni_added;
338 /* dying LND instances */
339 struct list_head net_ni_zombie;
342 enum lnet_net_state net_state;
345 typedef struct lnet_ni {
346 /* chain on the lnet_net structure */
347 struct list_head ni_netlist;
349 /* chain on net_ni_cpt */
350 struct list_head ni_cptlist;
357 /* bond NI on some CPTs */
360 /* interface's NID */
363 /* instance-specific data */
367 atomic_t ni_tx_credits;
369 /* percpt TX queues */
370 struct lnet_tx_queue **ni_tx_queues;
372 /* percpt reference count */
375 /* when I was last alive */
378 /* pointer to parent network */
379 struct lnet_net *ni_net;
381 /* my health status */
382 struct lnet_ni_status *ni_status;
385 enum lnet_ni_state ni_state;
387 /* per NI LND tunables */
388 struct lnet_lnd_tunables ni_lnd_tunables;
390 /* lnd tunables set explicitly */
391 bool ni_lnd_tunables_set;
394 struct lnet_element_stats ni_stats;
396 /* physical device CPT */
399 /* sequence number used to round robin over nis within a net */
403 * equivalent interfaces to use
404 * This is an array because socklnd bonding can still be configured
406 char *ni_interfaces[LNET_NUM_INTERFACES];
407 struct net *ni_net_ns; /* original net namespace */
410 #define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL
412 /* NB: value of these features equal to LNET_PROTO_PING_VERSION_x
413 * of old LNet, so there shouldn't be any compatibility issue */
414 #define LNET_PING_FEAT_INVAL (0) /* no feature */
415 #define LNET_PING_FEAT_BASE (1 << 0) /* just a ping */
416 #define LNET_PING_FEAT_NI_STATUS (1 << 1) /* return NI status */
417 #define LNET_PING_FEAT_RTE_DISABLED (1 << 2) /* Routing enabled */
419 #define LNET_PING_FEAT_MASK (LNET_PING_FEAT_BASE | \
420 LNET_PING_FEAT_NI_STATUS)
422 typedef struct lnet_ping_info {
427 struct lnet_ni_status pi_ni[0];
428 } WIRE_ATTR lnet_ping_info_t;
430 /* router checker data, per router */
431 #define LNET_MAX_RTR_NIS 16
432 #define LNET_PINGINFO_SIZE offsetof(struct lnet_ping_info, pi_ni[LNET_MAX_RTR_NIS])
433 typedef struct lnet_rc_data {
434 /* chain on the_lnet.ln_zombie_rcd or ln_deathrow_rcd */
435 struct list_head rcd_list;
436 struct lnet_handle_md rcd_mdh; /* ping buffer MD */
437 struct lnet_peer_ni *rcd_gateway; /* reference to gateway */
438 struct lnet_ping_info *rcd_pinginfo; /* ping buffer */
441 struct lnet_peer_ni {
442 /* chain on peer_net */
443 struct list_head lpni_on_peer_net_list;
444 /* chain on remote peer list */
445 struct list_head lpni_on_remote_peer_ni_list;
446 /* chain on peer hash */
447 struct list_head lpni_hashlist;
448 /* messages blocking for tx credits */
449 struct list_head lpni_txq;
450 /* messages blocking for router credits */
451 struct list_head lpni_rtrq;
452 /* chain on router list */
453 struct list_head lpni_rtr_list;
454 /* pointer to peer net I'm part of */
455 struct lnet_peer_net *lpni_peer_net;
456 /* statistics kept on each peer NI */
457 struct lnet_element_stats lpni_stats;
458 /* spin lock protecting credits and lpni_txq / lpni_rtrq */
459 spinlock_t lpni_lock;
460 /* # tx credits available */
463 int lpni_mintxcredits;
464 /* # router credits */
467 int lpni_minrtrcredits;
468 /* bytes queued for sending */
472 /* notification outstanding? */
474 /* outstanding notification for LND? */
476 /* some thread is handling notification */
478 /* SEND event outstanding from ping */
479 bool lpni_ping_notsent;
480 /* # times router went dead<->alive. Protected with lpni_lock */
481 int lpni_alive_count;
482 /* time of last aliveness news */
483 cfs_time_t lpni_timestamp;
484 /* time of last ping attempt */
485 cfs_time_t lpni_ping_timestamp;
486 /* != 0 if ping reply expected */
487 cfs_time_t lpni_ping_deadline;
488 /* when I was last alive */
489 cfs_time_t lpni_last_alive;
490 /* when lpni_ni was queried last time */
491 cfs_time_t lpni_last_query;
492 /* network peer is on */
493 struct lnet_net *lpni_net;
497 atomic_t lpni_refcount;
498 /* CPT this peer attached on */
500 /* # refs from lnet_route_t::lr_gateway */
501 int lpni_rtr_refcount;
502 /* sequence number used to round robin over peer nis within a net */
504 /* sequence number used to round robin over gateways */
508 /* returned RC ping features. Protected with lpni_lock */
509 unsigned int lpni_ping_feats;
510 /* routes on this peer */
511 struct list_head lpni_routes;
512 /* array of preferred local nids */
513 lnet_nid_t *lpni_pref_nids;
514 /* number of preferred NIDs in lnpi_pref_nids */
515 __u32 lpni_pref_nnids;
516 /* router checker state */
517 struct lnet_rc_data *lpni_rcd;
521 /* chain on global peer list */
522 struct list_head lp_on_lnet_peer_list;
524 /* list of peer nets */
525 struct list_head lp_peer_nets;
527 /* primary NID of the peer */
528 lnet_nid_t lp_primary_nid;
530 /* peer is Multi-Rail enabled peer */
534 struct lnet_peer_net {
535 /* chain on peer block */
536 struct list_head lpn_on_peer_list;
538 /* list of peer_nis on this network */
539 struct list_head lpn_peer_nis;
541 /* pointer to the peer I'm part of */
542 struct lnet_peer *lpn_peer;
549 #define LNET_PEER_HASH_BITS 9
550 #define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS)
552 /* peer hash table */
553 struct lnet_peer_table {
554 int pt_version; /* /proc validity stamp */
555 atomic_t pt_number; /* # peers extant */
556 struct list_head *pt_hash; /* NID->peer hash */
557 struct list_head pt_zombie_list; /* zombie peers */
558 int pt_zombies; /* # zombie peers */
559 spinlock_t pt_zombie_lock; /* protect list and count */
562 /* peer aliveness is enabled only on routers for peers in a network where the
563 * struct lnet_ni::ni_peertimeout has been set to a positive value
565 #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing != 0 && \
566 ((lp)->lpni_net) && \
567 (lp)->lpni_net->net_tunables.lct_peer_timeout > 0)
569 typedef struct lnet_route {
570 struct list_head lr_list; /* chain on net */
571 struct list_head lr_gwlist; /* chain on gateway */
572 struct lnet_peer_ni *lr_gateway; /* router node */
573 __u32 lr_net; /* remote network number */
574 int lr_seq; /* sequence for round-robin */
575 unsigned int lr_downis; /* number of down NIs */
576 __u32 lr_hops; /* how far I am */
577 unsigned int lr_priority; /* route priority */
580 #define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)
581 #define LNET_REMOTE_NETS_HASH_MAX (1U << 16)
582 #define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits)
584 typedef struct lnet_remotenet {
585 /* chain on ln_remote_nets_hash */
586 struct list_head lrn_list;
588 struct list_head lrn_routes;
593 /** lnet message has credit and can be submitted to lnd for send/receive */
594 #define LNET_CREDIT_OK 0
595 /** lnet message is waiting for credit */
596 #define LNET_CREDIT_WAIT 1
598 typedef struct lnet_rtrbufpool {
599 /* my free buffer pool */
600 struct list_head rbp_bufs;
601 /* messages blocking for a buffer */
602 struct list_head rbp_msgs;
603 /* # pages in each buffer */
605 /* requested number of buffers */
606 int rbp_req_nbuffers;
607 /* # buffers actually allocated */
609 /* # free buffers / blocked messages */
615 typedef struct lnet_rtrbuf {
616 struct list_head rb_list; /* chain on rbp_bufs */
617 struct lnet_rtrbufpool *rb_pool; /* owning pool */
618 lnet_kiov_t rb_kiov[0]; /* the buffer space */
621 #define LNET_PEER_HASHSIZE 503 /* prime! */
623 enum lnet_match_flags {
624 /* Didn't match anything */
625 LNET_MATCHMD_NONE = (1 << 0),
627 LNET_MATCHMD_OK = (1 << 1),
628 /* Must be discarded */
629 LNET_MATCHMD_DROP = (1 << 2),
630 /* match and buffer is exhausted */
631 LNET_MATCHMD_EXHAUSTED = (1 << 3),
633 LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
636 /* Options for struct lnet_portal::ptl_options */
637 #define LNET_PTL_LAZY (1 << 0)
638 #define LNET_PTL_MATCH_UNIQUE (1 << 1) /* unique match, for RDMA */
639 #define LNET_PTL_MATCH_WILDCARD (1 << 2) /* wildcard match, request portal */
641 /* parameter for matching operations (GET, PUT) */
642 struct lnet_match_info {
644 struct lnet_process_id mi_id;
647 unsigned int mi_portal;
648 unsigned int mi_rlength;
649 unsigned int mi_roffset;
652 /* ME hash of RDMA portal */
653 #define LNET_MT_HASH_BITS 8
654 #define LNET_MT_HASH_SIZE (1 << LNET_MT_HASH_BITS)
655 #define LNET_MT_HASH_MASK (LNET_MT_HASH_SIZE - 1)
656 /* we allocate (LNET_MT_HASH_SIZE + 1) entries for lnet_match_table::mt_hash,
657 * the last entry is reserved for MEs with ignore-bits */
658 #define LNET_MT_HASH_IGNORE LNET_MT_HASH_SIZE
659 /* __u64 has 2^6 bits, so need 2^(LNET_MT_HASH_BITS - LNET_MT_BITS_U64) which
660 * is 4 __u64s as bit-map, and add an extra __u64 (only use one bit) for the
661 * ME-list with ignore-bits, which is mtable::mt_hash[LNET_MT_HASH_IGNORE] */
662 #define LNET_MT_BITS_U64 6 /* 2^6 bits */
663 #define LNET_MT_EXHAUSTED_BITS (LNET_MT_HASH_BITS - LNET_MT_BITS_U64)
664 #define LNET_MT_EXHAUSTED_BMAP ((1 << LNET_MT_EXHAUSTED_BITS) + 1)
666 /* portal match table */
667 struct lnet_match_table {
668 /* reserved for upcoming patches, CPU partition ID */
670 unsigned int mt_portal; /* portal index */
671 /* match table is set as "enabled" if there's non-exhausted MD
672 * attached on mt_mhash, it's only valid for wildcard portal */
673 unsigned int mt_enabled;
674 /* bitmap to flag whether MEs on mt_hash are exhausted or not */
675 __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
676 struct list_head *mt_mhash; /* matching hash */
679 /* these are only useful for wildcard portal */
680 /* Turn off message rotor for wildcard portals */
681 #define LNET_PTL_ROTOR_OFF 0
682 /* round-robin dispatch all PUT messages for wildcard portals */
683 #define LNET_PTL_ROTOR_ON 1
684 /* round-robin dispatch routed PUT message for wildcard portals */
685 #define LNET_PTL_ROTOR_RR_RT 2
686 /* dispatch routed PUT message by hashing source NID for wildcard portals */
687 #define LNET_PTL_ROTOR_HASH_RT 3
689 typedef struct lnet_portal {
691 unsigned int ptl_index; /* portal ID, reserved */
692 /* flags on this portal: lazy, unique... */
693 unsigned int ptl_options;
694 /* list of messages which are stealing buffer */
695 struct list_head ptl_msg_stealing;
696 /* messages blocking for MD */
697 struct list_head ptl_msg_delayed;
698 /* Match table for each CPT */
699 struct lnet_match_table **ptl_mtables;
700 /* spread rotor of incoming "PUT" */
701 unsigned int ptl_rotor;
702 /* # active entries for this portal */
704 /* array of active entries' cpu-partition-id */
708 #define LNET_LH_HASH_BITS 12
709 #define LNET_LH_HASH_SIZE (1ULL << LNET_LH_HASH_BITS)
710 #define LNET_LH_HASH_MASK (LNET_LH_HASH_SIZE - 1)
712 /* resource container (ME, MD, EQ) */
713 struct lnet_res_container {
714 unsigned int rec_type; /* container type */
715 __u64 rec_lh_cookie; /* cookie generator */
716 struct list_head rec_active; /* active resource list */
717 struct list_head *rec_lh_hash; /* handle hash */
720 /* message container */
721 struct lnet_msg_container {
722 int msc_init; /* initialized or not */
723 /* max # threads finalizing */
725 /* msgs waiting to complete finalizing */
726 struct list_head msc_finalizing;
727 struct list_head msc_active; /* active message list */
728 /* threads doing finalization */
729 void **msc_finalizers;
732 /* Router Checker states */
733 #define LNET_RC_STATE_SHUTDOWN 0 /* not started */
734 #define LNET_RC_STATE_RUNNING 1 /* started up OK */
735 #define LNET_RC_STATE_STOPPING 2 /* telling thread to stop */
738 #define LNET_STATE_SHUTDOWN 0 /* not started */
739 #define LNET_STATE_RUNNING 1 /* started up OK */
740 #define LNET_STATE_STOPPING 2 /* telling thread to stop */
742 typedef struct lnet {
743 /* CPU partition table of LNet */
744 struct cfs_cpt_table *ln_cpt_table;
745 /* number of CPTs in ln_cpt_table */
746 unsigned int ln_cpt_number;
747 unsigned int ln_cpt_bits;
749 /* protect LNet resources (ME/MD/EQ) */
750 struct cfs_percpt_lock *ln_res_lock;
753 /* the vector of portals */
754 struct lnet_portal **ln_portals;
755 /* percpt ME containers */
756 struct lnet_res_container **ln_me_containers;
757 /* percpt MD container */
758 struct lnet_res_container **ln_md_containers;
760 /* Event Queue container */
761 struct lnet_res_container ln_eq_container;
762 wait_queue_head_t ln_eq_waitq;
763 spinlock_t ln_eq_wait_lock;
765 unsigned int ln_remote_nets_hbits;
767 /* protect NI, peer table, credits, routers, rtrbuf... */
768 struct cfs_percpt_lock *ln_net_lock;
769 /* percpt message containers for active/finalizing/freed message */
770 struct lnet_msg_container **ln_msg_containers;
771 struct lnet_counters **ln_counters;
772 struct lnet_peer_table **ln_peer_tables;
773 /* list of configured or discovered peers */
774 struct list_head ln_peers;
775 /* list of peer nis not on a local network */
776 struct list_head ln_remote_peer_ni_list;
777 /* failure simulation */
778 struct list_head ln_test_peers;
779 struct list_head ln_drop_rules;
780 struct list_head ln_delay_rules;
782 struct list_head ln_nets;
783 /* the loopback NI */
784 struct lnet_ni *ln_loni;
785 /* network zombie list */
786 struct list_head ln_net_zombie;
788 /* remote networks with routes to them */
789 struct list_head *ln_remote_nets_hash;
791 __u64 ln_remote_nets_version;
792 /* list of all known routers */
793 struct list_head ln_routers;
795 __u64 ln_routers_version;
796 /* percpt router buffer pools */
797 struct lnet_rtrbufpool **ln_rtrpools;
799 struct lnet_handle_md ln_ping_target_md;
800 struct lnet_handle_eq ln_ping_target_eq;
801 struct lnet_ping_info *ln_ping_info;
803 /* router checker startup/shutdown state */
805 /* router checker's event queue */
806 struct lnet_handle_eq ln_rc_eqh;
807 /* rcd still pending on net */
808 struct list_head ln_rcd_deathrow;
809 /* rcd ready for free */
810 struct list_head ln_rcd_zombie;
811 /* serialise startup/shutdown */
812 struct semaphore ln_rc_signal;
814 struct mutex ln_api_mutex;
815 struct mutex ln_lnd_mutex;
816 /* Have I called LNetNIInit myself? */
818 /* LNetNIInit/LNetNIFini counter */
820 /* SHUTDOWN/RUNNING/STOPPING */
823 int ln_routing; /* am I a router? */
824 lnet_pid_t ln_pid; /* requested pid */
825 /* uniquely identifies this ni in this epoch */
826 __u64 ln_interface_cookie;
827 /* registered LNDs */
828 struct list_head ln_lnds;
830 /* test protocol compatibility flags */
831 int ln_testprotocompat;
833 /* 0 - load the NIs from the mod params
834 * 1 - do not load the NIs from the mod params
835 * Reverse logic to ensure that other calls to LNetNIInit
838 bool ln_nis_from_mod_params;
840 /* waitq for router checker. As long as there are no routes in
841 * the list, the router checker will sleep on this queue. when
842 * routes are added the thread will wake up */
843 wait_queue_head_t ln_rc_waitq;