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, 2017, 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/semaphore.h>
48 #include <linux/types.h>
50 #include <uapi/linux/lnet/lnet-dlc.h>
51 #include <uapi/linux/lnet/lnetctl.h>
53 /* Max payload size */
54 #define LNET_MAX_PAYLOAD LNET_MTU
56 #define LNET_MAX_IOV (LNET_MAX_PAYLOAD >> PAGE_SHIFT)
62 struct list_head msg_activelist;
63 struct list_head msg_list; /* Q for credits/MD */
65 struct lnet_process_id msg_target;
66 /* Primary NID of the source. */
67 lnet_nid_t msg_initiator;
68 /* where is it from, it's only for building event */
73 * hold parameters in case message is with held due
76 lnet_nid_t msg_src_nid_param;
77 lnet_nid_t msg_rtr_nid_param;
79 /* committed for sending */
80 unsigned int msg_tx_committed:1;
81 /* CPT # this message committed for sending */
82 unsigned int msg_tx_cpt:15;
83 /* committed for receiving */
84 unsigned int msg_rx_committed:1;
85 /* CPT # this message committed for receiving */
86 unsigned int msg_rx_cpt:15;
87 /* queued for tx credit */
88 unsigned int msg_tx_delayed:1;
89 /* queued for RX buffer */
90 unsigned int msg_rx_delayed:1;
91 /* ready for pending on RX delay list */
92 unsigned int msg_rx_ready_delay:1;
94 unsigned int msg_vmflush:1; /* VM trying to free memory */
95 unsigned int msg_target_is_router:1; /* sending to a router */
96 unsigned int msg_routing:1; /* being forwarded */
97 unsigned int msg_ack:1; /* ack on finalize (PUT) */
98 unsigned int msg_sending:1; /* outgoing message */
99 unsigned int msg_receiving:1; /* being received */
100 unsigned int msg_txcredit:1; /* taken an NI send credit */
101 unsigned int msg_peertxcredit:1; /* taken a peer send credit */
102 unsigned int msg_rtrcredit:1; /* taken a globel router credit */
103 unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */
104 unsigned int msg_onactivelist:1; /* on the activelist */
105 unsigned int msg_rdma_get:1;
107 struct lnet_peer_ni *msg_txpeer; /* peer I'm sending to */
108 struct lnet_peer_ni *msg_rxpeer; /* peer I received from */
111 struct lnet_libmd *msg_md;
112 /* the NI the message was sent or received over */
113 struct lnet_ni *msg_txni;
114 struct lnet_ni *msg_rxni;
116 unsigned int msg_len;
117 unsigned int msg_wanted;
118 unsigned int msg_offset;
119 unsigned int msg_niov;
120 struct kvec *msg_iov;
121 lnet_kiov_t *msg_kiov;
123 struct lnet_event msg_ev;
124 struct lnet_hdr msg_hdr;
127 struct lnet_libhandle {
128 struct list_head lh_hash_chain;
132 #define lh_entry(ptr, type, member) \
133 ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
136 struct list_head eq_list;
137 struct lnet_libhandle eq_lh;
138 unsigned long eq_enq_seq;
139 unsigned long eq_deq_seq;
140 unsigned int eq_size;
141 lnet_eq_handler_t eq_callback;
142 struct lnet_event *eq_events;
143 int **eq_refs; /* percpt refcount for EQ */
147 struct list_head me_list;
148 struct lnet_libhandle me_lh;
149 struct lnet_process_id me_match_id;
150 unsigned int me_portal;
151 unsigned int me_pos; /* hash offset in mt_hash */
153 __u64 me_ignore_bits;
154 enum lnet_unlink me_unlink;
155 struct lnet_libmd *me_md;
159 struct list_head md_list;
160 struct lnet_libhandle md_lh;
161 struct lnet_me *md_me;
163 unsigned int md_offset;
164 unsigned int md_length;
165 unsigned int md_max_size;
168 unsigned int md_options;
169 unsigned int md_flags;
170 unsigned int md_niov; /* # frags at end of struct */
172 struct lnet_eq *md_eq;
173 struct lnet_handle_md md_bulk_handle;
175 struct kvec iov[LNET_MAX_IOV];
176 lnet_kiov_t kiov[LNET_MAX_IOV];
180 #define LNET_MD_FLAG_ZOMBIE (1 << 0)
181 #define LNET_MD_FLAG_AUTO_UNLINK (1 << 1)
182 #define LNET_MD_FLAG_ABORTED (1 << 2)
184 struct lnet_test_peer {
185 /* info about peers we are trying to fail */
186 struct list_head tp_list; /* ln_test_peers */
187 lnet_nid_t tp_nid; /* matching nid */
188 unsigned int tp_threshold; /* # failures to simulate */
191 #define LNET_COOKIE_TYPE_MD 1
192 #define LNET_COOKIE_TYPE_ME 2
193 #define LNET_COOKIE_TYPE_EQ 3
194 #define LNET_COOKIE_TYPE_BITS 2
195 #define LNET_COOKIE_MASK ((1ULL << LNET_COOKIE_TYPE_BITS) - 1ULL)
197 struct lnet_ni; /* forward ref */
201 /* fields managed by portals */
202 struct list_head lnd_list; /* stash in the LND table */
203 int lnd_refcount; /* # active instances */
205 /* fields initialized by the LND */
208 int (*lnd_startup)(struct lnet_ni *ni);
209 void (*lnd_shutdown)(struct lnet_ni *ni);
210 int (*lnd_ctl)(struct lnet_ni *ni, unsigned int cmd, void *arg);
212 /* In data movement APIs below, payload buffers are described as a set
213 * of 'niov' fragments which are...
215 * in virtual memory (struct kvec *iov != NULL)
217 * in pages (kernel only: plt_kiov_t *kiov != NULL).
218 * The LND may NOT overwrite these fragment descriptors.
219 * An 'offset' and may specify a byte offset within the set of
220 * fragments to start from
223 /* Start sending a preformatted message. 'private' is NULL for PUT and
224 * GET messages; otherwise this is a response to an incoming message
225 * and 'private' is the 'private' passed to lnet_parse(). Return
226 * non-zero for immediate failure, otherwise complete later with
228 int (*lnd_send)(struct lnet_ni *ni, void *private,
229 struct lnet_msg *msg);
231 /* Start receiving 'mlen' bytes of payload data, skipping the following
232 * 'rlen' - 'mlen' bytes. 'private' is the 'private' passed to
233 * lnet_parse(). Return non-zero for immedaite failure, otherwise
234 * complete later with lnet_finalize(). This also gives back a receive
235 * credit if the LND does flow control. */
236 int (*lnd_recv)(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
237 int delayed, unsigned int niov,
238 struct kvec *iov, lnet_kiov_t *kiov,
239 unsigned int offset, unsigned int mlen, unsigned int rlen);
241 /* lnet_parse() has had to delay processing of this message
242 * (e.g. waiting for a forwarding buffer or send credits). Give the
243 * LND a chance to free urgently needed resources. If called, return 0
244 * for success and do NOT give back a receive credit; that has to wait
245 * until lnd_recv() gets called. On failure return < 0 and
246 * release resources; lnd_recv() will not be called. */
247 int (*lnd_eager_recv)(struct lnet_ni *ni, void *private,
248 struct lnet_msg *msg, void **new_privatep);
250 /* notification of peer health */
251 void (*lnd_notify)(struct lnet_ni *ni, lnet_nid_t peer, int alive);
253 /* query of peer aliveness */
254 void (*lnd_query)(struct lnet_ni *ni, lnet_nid_t peer, time64_t *when);
256 /* accept a new connection */
257 int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock);
260 struct lnet_tx_queue {
261 int tq_credits; /* # tx credits free */
262 int tq_credits_min; /* lowest it's been */
263 int tq_credits_max; /* total # tx credits */
264 struct list_head tq_delayed; /* delayed TXs */
267 enum lnet_net_state {
268 /* set when net block is allocated */
269 LNET_NET_STATE_INIT = 0,
270 /* set when NIs in net are started successfully */
271 LNET_NET_STATE_ACTIVE,
272 /* set if all NIs in net are in FAILED state */
273 LNET_NET_STATE_INACTIVE,
274 /* set when shutting down a NET */
275 LNET_NET_STATE_DELETING
279 /* set when NI block is allocated */
280 LNET_NI_STATE_INIT = 0,
281 /* set when NI is started successfully */
282 LNET_NI_STATE_ACTIVE,
283 /* set when LND notifies NI failed */
284 LNET_NI_STATE_FAILED,
285 /* set when LND notifies NI degraded */
286 LNET_NI_STATE_DEGRADED,
287 /* set when shuttding down NI */
288 LNET_NI_STATE_DELETING
291 enum lnet_stats_type {
292 LNET_STATS_TYPE_SEND = 0,
293 LNET_STATS_TYPE_RECV,
297 struct lnet_comm_count {
298 atomic_t co_get_count;
299 atomic_t co_put_count;
300 atomic_t co_reply_count;
301 atomic_t co_ack_count;
302 atomic_t co_hello_count;
305 struct lnet_element_stats {
306 struct lnet_comm_count el_send_stats;
307 struct lnet_comm_count el_recv_stats;
308 struct lnet_comm_count el_drop_stats;
312 /* chain on the ln_nets */
313 struct list_head net_list;
315 /* net ID, which is composed of
316 * (net_type << 16) | net_num.
317 * net_type can be one of the enumerated types defined in
318 * lnet/include/lnet/nidstr.h */
321 /* priority of the network */
324 /* total number of CPTs in the array */
327 /* cumulative CPTs of all NIs in this net */
330 /* network tunables */
331 struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
334 * boolean to indicate that the tunables have been set and
337 bool net_tunables_set;
339 /* procedural interface */
340 struct lnet_lnd *net_lnd;
342 /* list of NIs on this net */
343 struct list_head net_ni_list;
345 /* list of NIs being added, but not started yet */
346 struct list_head net_ni_added;
348 /* dying LND instances */
349 struct list_head net_ni_zombie;
352 enum lnet_net_state net_state;
356 /* chain on the lnet_net structure */
357 struct list_head ni_netlist;
359 /* chain on net_ni_cpt */
360 struct list_head ni_cptlist;
367 /* bond NI on some CPTs */
370 /* interface's NID */
373 /* instance-specific data */
377 atomic_t ni_tx_credits;
379 /* percpt TX queues */
380 struct lnet_tx_queue **ni_tx_queues;
382 /* percpt reference count */
385 /* when I was last alive */
386 time64_t ni_last_alive;
388 /* pointer to parent network */
389 struct lnet_net *ni_net;
391 /* my health status */
392 struct lnet_ni_status *ni_status;
395 enum lnet_ni_state ni_state;
397 /* per NI LND tunables */
398 struct lnet_lnd_tunables ni_lnd_tunables;
400 /* lnd tunables set explicitly */
401 bool ni_lnd_tunables_set;
404 struct lnet_element_stats ni_stats;
406 /* physical device CPT */
409 /* sequence number used to round robin over nis within a net */
413 * equivalent interfaces to use
414 * This is an array because socklnd bonding can still be configured
416 char *ni_interfaces[LNET_INTERFACES_NUM];
417 struct net *ni_net_ns; /* original net namespace */
420 #define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL
423 * Descriptor of a ping info buffer: keep a separate indicator of the
424 * size and a reference count. The type is used both as a source and
425 * sink of data, so we need to keep some information outside of the
426 * area that may be overwritten by network data.
428 struct lnet_ping_buffer {
431 struct lnet_ping_info pb_info;
434 #define LNET_PING_BUFFER_SIZE(NNIDS) \
435 offsetof(struct lnet_ping_buffer, pb_info.pi_ni[NNIDS])
436 #define LNET_PING_BUFFER_LONI(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_nid)
437 #define LNET_PING_BUFFER_SEQNO(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_status)
439 #define LNET_PING_INFO_TO_BUFFER(PINFO) \
440 container_of((PINFO), struct lnet_ping_buffer, pb_info)
442 /* router checker data, per router */
443 struct lnet_rc_data {
444 /* chain on the_lnet.ln_zombie_rcd or ln_deathrow_rcd */
445 struct list_head rcd_list;
446 struct lnet_handle_md rcd_mdh; /* ping buffer MD */
447 struct lnet_peer_ni *rcd_gateway; /* reference to gateway */
448 struct lnet_ping_buffer *rcd_pingbuffer;/* ping buffer */
449 int rcd_nnis; /* desired size of buffer */
452 struct lnet_peer_ni {
453 /* chain on lpn_peer_nis */
454 struct list_head lpni_peer_nis;
455 /* chain on remote peer list */
456 struct list_head lpni_on_remote_peer_ni_list;
457 /* chain on peer hash */
458 struct list_head lpni_hashlist;
459 /* messages blocking for tx credits */
460 struct list_head lpni_txq;
461 /* messages blocking for router credits */
462 struct list_head lpni_rtrq;
463 /* chain on router list */
464 struct list_head lpni_rtr_list;
465 /* pointer to peer net I'm part of */
466 struct lnet_peer_net *lpni_peer_net;
467 /* statistics kept on each peer NI */
468 struct lnet_element_stats lpni_stats;
469 /* spin lock protecting credits and lpni_txq / lpni_rtrq */
470 spinlock_t lpni_lock;
471 /* # tx credits available */
474 int lpni_mintxcredits;
475 /* # router credits */
478 int lpni_minrtrcredits;
479 /* bytes queued for sending */
483 /* notification outstanding? */
485 /* outstanding notification for LND? */
487 /* some thread is handling notification */
489 /* SEND event outstanding from ping */
490 bool lpni_ping_notsent;
491 /* # times router went dead<->alive. Protected with lpni_lock */
492 int lpni_alive_count;
493 /* time of last aliveness news */
494 time64_t lpni_timestamp;
495 /* time of last ping attempt */
496 time64_t lpni_ping_timestamp;
497 /* != 0 if ping reply expected */
498 time64_t lpni_ping_deadline;
499 /* when I was last alive */
500 time64_t lpni_last_alive;
501 /* when lpni_ni was queried last time */
502 time64_t lpni_last_query;
503 /* network peer is on */
504 struct lnet_net *lpni_net;
508 atomic_t lpni_refcount;
509 /* CPT this peer attached on */
511 /* state flags -- protected by lpni_lock */
513 /* # refs from lnet_route_t::lr_gateway */
514 int lpni_rtr_refcount;
515 /* sequence number used to round robin over peer nis within a net */
517 /* sequence number used to round robin over gateways */
521 /* returned RC ping features. Protected with lpni_lock */
522 unsigned int lpni_ping_feats;
523 /* routes on this peer */
524 struct list_head lpni_routes;
525 /* preferred local nids: if only one, use lpni_pref.nid */
530 /* number of preferred NIDs in lnpi_pref_nids */
531 __u32 lpni_pref_nnids;
532 /* router checker state */
533 struct lnet_rc_data *lpni_rcd;
536 /* Preferred path added due to traffic on non-MR peer_ni */
537 #define LNET_PEER_NI_NON_MR_PREF (1 << 0)
540 /* chain on pt_peer_list */
541 struct list_head lp_peer_list;
543 /* list of peer nets */
544 struct list_head lp_peer_nets;
546 /* list of messages pending discovery*/
547 struct list_head lp_dc_pendq;
549 /* primary NID of the peer */
550 lnet_nid_t lp_primary_nid;
552 /* CPT of peer_table */
555 /* number of NIDs on this peer */
558 /* reference count */
559 atomic_t lp_refcount;
561 /* lock protecting peer state flags */
564 /* peer state flags */
567 /* buffer for data pushed by peer */
568 struct lnet_ping_buffer *lp_data;
570 /* MD handle for ping in progress */
571 struct lnet_handle_md lp_ping_mdh;
573 /* MD handle for push in progress */
574 struct lnet_handle_md lp_push_mdh;
576 /* number of NIDs for sizing push data */
579 /* NI config sequence number of peer */
582 /* Local NI config sequence number acked by peer */
585 /* Local NI config sequence number sent to peer */
586 __u32 lp_node_seqno_sent;
588 /* Ping error encountered during discovery. */
591 /* Push error encountered during discovery. */
594 /* Error encountered during discovery. */
597 /* time it was put on the ln_dc_working queue */
598 time64_t lp_last_queued;
600 /* link on discovery-related lists */
601 struct list_head lp_dc_list;
603 /* tasks waiting on discovery of this peer */
604 wait_queue_head_t lp_dc_waitq;
608 * The status flags in lp_state. Their semantics have chosen so that
609 * lp_state can be zero-initialized.
611 * A peer is marked MULTI_RAIL in two cases: it was configured using DLC
612 * as multi-rail aware, or the LNET_PING_FEAT_MULTI_RAIL bit was set.
614 * A peer is marked NO_DISCOVERY if the LNET_PING_FEAT_DISCOVERY bit was
615 * NOT set when the peer was pinged by discovery.
617 #define LNET_PEER_MULTI_RAIL (1 << 0) /* Multi-rail aware */
618 #define LNET_PEER_NO_DISCOVERY (1 << 1) /* Peer disabled discovery */
620 * A peer is marked CONFIGURED if it was configured by DLC.
622 * In addition, a peer is marked DISCOVERED if it has fully passed
623 * through Peer Discovery.
625 * When Peer Discovery is disabled, the discovery thread will mark
626 * peers REDISCOVER to indicate that they should be re-examined if
627 * discovery is (re)enabled on the node.
629 * A peer that was created as the result of inbound traffic will not
632 #define LNET_PEER_CONFIGURED (1 << 2) /* Configured via DLC */
633 #define LNET_PEER_DISCOVERED (1 << 3) /* Peer was discovered */
634 #define LNET_PEER_REDISCOVER (1 << 4) /* Discovery was disabled */
636 * A peer is marked DISCOVERING when discovery is in progress.
637 * The other flags below correspond to stages of discovery.
639 #define LNET_PEER_DISCOVERING (1 << 5) /* Discovering */
640 #define LNET_PEER_DATA_PRESENT (1 << 6) /* Remote peer data present */
641 #define LNET_PEER_NIDS_UPTODATE (1 << 7) /* Remote peer info uptodate */
642 #define LNET_PEER_PING_SENT (1 << 8) /* Waiting for REPLY to Ping */
643 #define LNET_PEER_PUSH_SENT (1 << 9) /* Waiting for ACK of Push */
644 #define LNET_PEER_PING_FAILED (1 << 10) /* Ping send failure */
645 #define LNET_PEER_PUSH_FAILED (1 << 11) /* Push send failure */
647 * A ping can be forced as a way to fix up state, or as a manual
648 * intervention by an admin.
649 * A push can be forced in circumstances that would normally not
650 * allow for one to happen.
652 #define LNET_PEER_FORCE_PING (1 << 12) /* Forced Ping */
653 #define LNET_PEER_FORCE_PUSH (1 << 13) /* Forced Push */
655 struct lnet_peer_net {
656 /* chain on lp_peer_nets */
657 struct list_head lpn_peer_nets;
659 /* list of peer_nis on this network */
660 struct list_head lpn_peer_nis;
662 /* pointer to the peer I'm part of */
663 struct lnet_peer *lpn_peer;
668 /* reference count */
669 atomic_t lpn_refcount;
673 #define LNET_PEER_HASH_BITS 9
674 #define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS)
677 * peer hash table - one per CPT
679 * protected by lnet_net_lock/EX for update
685 * protected by pt_zombie_lock:
689 * pt_zombie lock nests inside lnet_net_lock
691 struct lnet_peer_table {
692 int pt_version; /* /proc validity stamp */
693 int pt_number; /* # peers_ni extant */
694 struct list_head *pt_hash; /* NID->peer hash */
695 struct list_head pt_peer_list; /* peers */
696 int pt_peers; /* # peers */
697 struct list_head pt_zombie_list; /* zombie peer_ni */
698 int pt_zombies; /* # zombie peers_ni */
699 spinlock_t pt_zombie_lock; /* protect list and count */
702 /* peer aliveness is enabled only on routers for peers in a network where the
703 * struct lnet_ni::ni_peertimeout has been set to a positive value
705 #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing != 0 && \
706 ((lp)->lpni_net) && \
707 (lp)->lpni_net->net_tunables.lct_peer_timeout > 0)
710 struct list_head lr_list; /* chain on net */
711 struct list_head lr_gwlist; /* chain on gateway */
712 struct lnet_peer_ni *lr_gateway; /* router node */
713 __u32 lr_net; /* remote network number */
714 int lr_seq; /* sequence for round-robin */
715 unsigned int lr_downis; /* number of down NIs */
716 __u32 lr_hops; /* how far I am */
717 unsigned int lr_priority; /* route priority */
720 #define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)
721 #define LNET_REMOTE_NETS_HASH_MAX (1U << 16)
722 #define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits)
724 struct lnet_remotenet {
725 /* chain on ln_remote_nets_hash */
726 struct list_head lrn_list;
728 struct list_head lrn_routes;
733 /** lnet message has credit and can be submitted to lnd for send/receive */
734 #define LNET_CREDIT_OK 0
735 /** lnet message is waiting for credit */
736 #define LNET_CREDIT_WAIT 1
737 /** lnet message is waiting for discovery */
738 #define LNET_DC_WAIT 2
740 struct lnet_rtrbufpool {
741 /* my free buffer pool */
742 struct list_head rbp_bufs;
743 /* messages blocking for a buffer */
744 struct list_head rbp_msgs;
745 /* # pages in each buffer */
747 /* requested number of buffers */
748 int rbp_req_nbuffers;
749 /* # buffers actually allocated */
751 /* # free buffers / blocked messages */
758 struct list_head rb_list; /* chain on rbp_bufs */
759 struct lnet_rtrbufpool *rb_pool; /* owning pool */
760 lnet_kiov_t rb_kiov[0]; /* the buffer space */
763 #define LNET_PEER_HASHSIZE 503 /* prime! */
765 enum lnet_match_flags {
766 /* Didn't match anything */
767 LNET_MATCHMD_NONE = (1 << 0),
769 LNET_MATCHMD_OK = (1 << 1),
770 /* Must be discarded */
771 LNET_MATCHMD_DROP = (1 << 2),
772 /* match and buffer is exhausted */
773 LNET_MATCHMD_EXHAUSTED = (1 << 3),
775 LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
778 /* Options for struct lnet_portal::ptl_options */
779 #define LNET_PTL_LAZY (1 << 0)
780 #define LNET_PTL_MATCH_UNIQUE (1 << 1) /* unique match, for RDMA */
781 #define LNET_PTL_MATCH_WILDCARD (1 << 2) /* wildcard match, request portal */
783 /* parameter for matching operations (GET, PUT) */
784 struct lnet_match_info {
786 struct lnet_process_id mi_id;
789 unsigned int mi_portal;
790 unsigned int mi_rlength;
791 unsigned int mi_roffset;
794 /* ME hash of RDMA portal */
795 #define LNET_MT_HASH_BITS 8
796 #define LNET_MT_HASH_SIZE (1 << LNET_MT_HASH_BITS)
797 #define LNET_MT_HASH_MASK (LNET_MT_HASH_SIZE - 1)
798 /* we allocate (LNET_MT_HASH_SIZE + 1) entries for lnet_match_table::mt_hash,
799 * the last entry is reserved for MEs with ignore-bits */
800 #define LNET_MT_HASH_IGNORE LNET_MT_HASH_SIZE
801 /* __u64 has 2^6 bits, so need 2^(LNET_MT_HASH_BITS - LNET_MT_BITS_U64) which
802 * is 4 __u64s as bit-map, and add an extra __u64 (only use one bit) for the
803 * ME-list with ignore-bits, which is mtable::mt_hash[LNET_MT_HASH_IGNORE] */
804 #define LNET_MT_BITS_U64 6 /* 2^6 bits */
805 #define LNET_MT_EXHAUSTED_BITS (LNET_MT_HASH_BITS - LNET_MT_BITS_U64)
806 #define LNET_MT_EXHAUSTED_BMAP ((1 << LNET_MT_EXHAUSTED_BITS) + 1)
808 /* portal match table */
809 struct lnet_match_table {
810 /* reserved for upcoming patches, CPU partition ID */
812 unsigned int mt_portal; /* portal index */
813 /* match table is set as "enabled" if there's non-exhausted MD
814 * attached on mt_mhash, it's only valid for wildcard portal */
815 unsigned int mt_enabled;
816 /* bitmap to flag whether MEs on mt_hash are exhausted or not */
817 __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
818 struct list_head *mt_mhash; /* matching hash */
821 /* these are only useful for wildcard portal */
822 /* Turn off message rotor for wildcard portals */
823 #define LNET_PTL_ROTOR_OFF 0
824 /* round-robin dispatch all PUT messages for wildcard portals */
825 #define LNET_PTL_ROTOR_ON 1
826 /* round-robin dispatch routed PUT message for wildcard portals */
827 #define LNET_PTL_ROTOR_RR_RT 2
828 /* dispatch routed PUT message by hashing source NID for wildcard portals */
829 #define LNET_PTL_ROTOR_HASH_RT 3
833 unsigned int ptl_index; /* portal ID, reserved */
834 /* flags on this portal: lazy, unique... */
835 unsigned int ptl_options;
836 /* list of messages which are stealing buffer */
837 struct list_head ptl_msg_stealing;
838 /* messages blocking for MD */
839 struct list_head ptl_msg_delayed;
840 /* Match table for each CPT */
841 struct lnet_match_table **ptl_mtables;
842 /* spread rotor of incoming "PUT" */
843 unsigned int ptl_rotor;
844 /* # active entries for this portal */
846 /* array of active entries' cpu-partition-id */
850 #define LNET_LH_HASH_BITS 12
851 #define LNET_LH_HASH_SIZE (1ULL << LNET_LH_HASH_BITS)
852 #define LNET_LH_HASH_MASK (LNET_LH_HASH_SIZE - 1)
854 /* resource container (ME, MD, EQ) */
855 struct lnet_res_container {
856 unsigned int rec_type; /* container type */
857 __u64 rec_lh_cookie; /* cookie generator */
858 struct list_head rec_active; /* active resource list */
859 struct list_head *rec_lh_hash; /* handle hash */
862 /* message container */
863 struct lnet_msg_container {
864 int msc_init; /* initialized or not */
865 /* max # threads finalizing */
867 /* msgs waiting to complete finalizing */
868 struct list_head msc_finalizing;
869 struct list_head msc_active; /* active message list */
870 /* threads doing finalization */
871 void **msc_finalizers;
874 /* Peer Discovery states */
875 #define LNET_DC_STATE_SHUTDOWN 0 /* not started */
876 #define LNET_DC_STATE_RUNNING 1 /* started up OK */
877 #define LNET_DC_STATE_STOPPING 2 /* telling thread to stop */
879 /* Router Checker states */
880 #define LNET_RC_STATE_SHUTDOWN 0 /* not started */
881 #define LNET_RC_STATE_RUNNING 1 /* started up OK */
882 #define LNET_RC_STATE_STOPPING 2 /* telling thread to stop */
885 #define LNET_STATE_SHUTDOWN 0 /* not started */
886 #define LNET_STATE_RUNNING 1 /* started up OK */
887 #define LNET_STATE_STOPPING 2 /* telling thread to stop */
890 /* CPU partition table of LNet */
891 struct cfs_cpt_table *ln_cpt_table;
892 /* number of CPTs in ln_cpt_table */
893 unsigned int ln_cpt_number;
894 unsigned int ln_cpt_bits;
896 /* protect LNet resources (ME/MD/EQ) */
897 struct cfs_percpt_lock *ln_res_lock;
900 /* the vector of portals */
901 struct lnet_portal **ln_portals;
902 /* percpt ME containers */
903 struct lnet_res_container **ln_me_containers;
904 /* percpt MD container */
905 struct lnet_res_container **ln_md_containers;
907 /* Event Queue container */
908 struct lnet_res_container ln_eq_container;
909 wait_queue_head_t ln_eq_waitq;
910 spinlock_t ln_eq_wait_lock;
912 unsigned int ln_remote_nets_hbits;
914 /* protect NI, peer table, credits, routers, rtrbuf... */
915 struct cfs_percpt_lock *ln_net_lock;
916 /* percpt message containers for active/finalizing/freed message */
917 struct lnet_msg_container **ln_msg_containers;
918 struct lnet_counters **ln_counters;
919 struct lnet_peer_table **ln_peer_tables;
920 /* list of peer nis not on a local network */
921 struct list_head ln_remote_peer_ni_list;
922 /* failure simulation */
923 struct list_head ln_test_peers;
924 struct list_head ln_drop_rules;
925 struct list_head ln_delay_rules;
927 struct list_head ln_nets;
928 /* the loopback NI */
929 struct lnet_ni *ln_loni;
930 /* network zombie list */
931 struct list_head ln_net_zombie;
932 /* resend messages list */
933 struct list_head ln_msg_resend;
934 /* spin lock to protect the msg resend list */
935 spinlock_t ln_msg_resend_lock;
937 /* remote networks with routes to them */
938 struct list_head *ln_remote_nets_hash;
940 __u64 ln_remote_nets_version;
941 /* list of all known routers */
942 struct list_head ln_routers;
944 __u64 ln_routers_version;
945 /* percpt router buffer pools */
946 struct lnet_rtrbufpool **ln_rtrpools;
949 * Ping target / Push source
951 * The ping target and push source share a single buffer. The
952 * ln_ping_target is protected against concurrent updates by
955 struct lnet_handle_md ln_ping_target_md;
956 struct lnet_handle_eq ln_ping_target_eq;
957 struct lnet_ping_buffer *ln_ping_target;
958 atomic_t ln_ping_target_seqno;
963 * ln_push_nnis contains the desired size of the push target.
964 * The lnet_net_lock is used to handle update races. The old
965 * buffer may linger a while after it has been unlinked, in
966 * which case the event handler cleans up.
968 struct lnet_handle_eq ln_push_target_eq;
969 struct lnet_handle_md ln_push_target_md;
970 struct lnet_ping_buffer *ln_push_target;
971 int ln_push_target_nnis;
973 /* discovery event queue handle */
974 struct lnet_handle_eq ln_dc_eqh;
975 /* discovery requests */
976 struct list_head ln_dc_request;
977 /* discovery working list */
978 struct list_head ln_dc_working;
979 /* discovery expired list */
980 struct list_head ln_dc_expired;
981 /* discovery thread wait queue */
982 wait_queue_head_t ln_dc_waitq;
983 /* discovery startup/shutdown state */
986 /* router checker startup/shutdown state */
988 /* router checker's event queue */
989 struct lnet_handle_eq ln_rc_eqh;
990 /* rcd still pending on net */
991 struct list_head ln_rcd_deathrow;
992 /* rcd ready for free */
993 struct list_head ln_rcd_zombie;
994 /* serialise startup/shutdown */
995 struct semaphore ln_rc_signal;
997 struct mutex ln_api_mutex;
998 struct mutex ln_lnd_mutex;
999 /* Have I called LNetNIInit myself? */
1001 /* LNetNIInit/LNetNIFini counter */
1003 /* SHUTDOWN/RUNNING/STOPPING */
1006 int ln_routing; /* am I a router? */
1007 lnet_pid_t ln_pid; /* requested pid */
1008 /* uniquely identifies this ni in this epoch */
1009 __u64 ln_interface_cookie;
1010 /* registered LNDs */
1011 struct list_head ln_lnds;
1013 /* test protocol compatibility flags */
1014 int ln_testprotocompat;
1016 /* 0 - load the NIs from the mod params
1017 * 1 - do not load the NIs from the mod params
1018 * Reverse logic to ensure that other calls to LNetNIInit
1021 bool ln_nis_from_mod_params;
1023 /* waitq for router checker. As long as there are no routes in
1024 * the list, the router checker will sleep on this queue. when
1025 * routes are added the thread will wake up */
1026 wait_queue_head_t ln_rc_waitq;