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)
59 * This is the maximum health value.
60 * All local and peer NIs created have their health default to this value.
62 #define LNET_MAX_HEALTH_VALUE 1000
68 struct list_head msg_activelist;
69 struct list_head msg_list; /* Q for credits/MD */
71 struct lnet_process_id msg_target;
72 /* Primary NID of the source. */
73 lnet_nid_t msg_initiator;
74 /* where is it from, it's only for building event */
79 * hold parameters in case message is with held due
82 lnet_nid_t msg_src_nid_param;
83 lnet_nid_t msg_rtr_nid_param;
85 /* committed for sending */
86 unsigned int msg_tx_committed:1;
87 /* CPT # this message committed for sending */
88 unsigned int msg_tx_cpt:15;
89 /* committed for receiving */
90 unsigned int msg_rx_committed:1;
91 /* CPT # this message committed for receiving */
92 unsigned int msg_rx_cpt:15;
93 /* queued for tx credit */
94 unsigned int msg_tx_delayed:1;
95 /* queued for RX buffer */
96 unsigned int msg_rx_delayed:1;
97 /* ready for pending on RX delay list */
98 unsigned int msg_rx_ready_delay:1;
100 unsigned int msg_vmflush:1; /* VM trying to free memory */
101 unsigned int msg_target_is_router:1; /* sending to a router */
102 unsigned int msg_routing:1; /* being forwarded */
103 unsigned int msg_ack:1; /* ack on finalize (PUT) */
104 unsigned int msg_sending:1; /* outgoing message */
105 unsigned int msg_receiving:1; /* being received */
106 unsigned int msg_txcredit:1; /* taken an NI send credit */
107 unsigned int msg_peertxcredit:1; /* taken a peer send credit */
108 unsigned int msg_rtrcredit:1; /* taken a globel router credit */
109 unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */
110 unsigned int msg_onactivelist:1; /* on the activelist */
111 unsigned int msg_rdma_get:1;
113 struct lnet_peer_ni *msg_txpeer; /* peer I'm sending to */
114 struct lnet_peer_ni *msg_rxpeer; /* peer I received from */
117 struct lnet_libmd *msg_md;
118 /* the NI the message was sent or received over */
119 struct lnet_ni *msg_txni;
120 struct lnet_ni *msg_rxni;
122 unsigned int msg_len;
123 unsigned int msg_wanted;
124 unsigned int msg_offset;
125 unsigned int msg_niov;
126 struct kvec *msg_iov;
127 lnet_kiov_t *msg_kiov;
129 struct lnet_event msg_ev;
130 struct lnet_hdr msg_hdr;
133 struct lnet_libhandle {
134 struct list_head lh_hash_chain;
138 #define lh_entry(ptr, type, member) \
139 ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
142 struct list_head eq_list;
143 struct lnet_libhandle eq_lh;
144 unsigned long eq_enq_seq;
145 unsigned long eq_deq_seq;
146 unsigned int eq_size;
147 lnet_eq_handler_t eq_callback;
148 struct lnet_event *eq_events;
149 int **eq_refs; /* percpt refcount for EQ */
153 struct list_head me_list;
154 struct lnet_libhandle me_lh;
155 struct lnet_process_id me_match_id;
156 unsigned int me_portal;
157 unsigned int me_pos; /* hash offset in mt_hash */
159 __u64 me_ignore_bits;
160 enum lnet_unlink me_unlink;
161 struct lnet_libmd *me_md;
165 struct list_head md_list;
166 struct lnet_libhandle md_lh;
167 struct lnet_me *md_me;
169 unsigned int md_offset;
170 unsigned int md_length;
171 unsigned int md_max_size;
174 unsigned int md_options;
175 unsigned int md_flags;
176 unsigned int md_niov; /* # frags at end of struct */
178 struct lnet_eq *md_eq;
179 struct lnet_handle_md md_bulk_handle;
181 struct kvec iov[LNET_MAX_IOV];
182 lnet_kiov_t kiov[LNET_MAX_IOV];
186 #define LNET_MD_FLAG_ZOMBIE (1 << 0)
187 #define LNET_MD_FLAG_AUTO_UNLINK (1 << 1)
188 #define LNET_MD_FLAG_ABORTED (1 << 2)
190 struct lnet_test_peer {
191 /* info about peers we are trying to fail */
192 struct list_head tp_list; /* ln_test_peers */
193 lnet_nid_t tp_nid; /* matching nid */
194 unsigned int tp_threshold; /* # failures to simulate */
197 #define LNET_COOKIE_TYPE_MD 1
198 #define LNET_COOKIE_TYPE_ME 2
199 #define LNET_COOKIE_TYPE_EQ 3
200 #define LNET_COOKIE_TYPE_BITS 2
201 #define LNET_COOKIE_MASK ((1ULL << LNET_COOKIE_TYPE_BITS) - 1ULL)
203 struct lnet_ni; /* forward ref */
207 /* fields managed by portals */
208 struct list_head lnd_list; /* stash in the LND table */
209 int lnd_refcount; /* # active instances */
211 /* fields initialized by the LND */
214 int (*lnd_startup)(struct lnet_ni *ni);
215 void (*lnd_shutdown)(struct lnet_ni *ni);
216 int (*lnd_ctl)(struct lnet_ni *ni, unsigned int cmd, void *arg);
218 /* In data movement APIs below, payload buffers are described as a set
219 * of 'niov' fragments which are...
221 * in virtual memory (struct kvec *iov != NULL)
223 * in pages (kernel only: plt_kiov_t *kiov != NULL).
224 * The LND may NOT overwrite these fragment descriptors.
225 * An 'offset' and may specify a byte offset within the set of
226 * fragments to start from
229 /* Start sending a preformatted message. 'private' is NULL for PUT and
230 * GET messages; otherwise this is a response to an incoming message
231 * and 'private' is the 'private' passed to lnet_parse(). Return
232 * non-zero for immediate failure, otherwise complete later with
234 int (*lnd_send)(struct lnet_ni *ni, void *private,
235 struct lnet_msg *msg);
237 /* Start receiving 'mlen' bytes of payload data, skipping the following
238 * 'rlen' - 'mlen' bytes. 'private' is the 'private' passed to
239 * lnet_parse(). Return non-zero for immedaite failure, otherwise
240 * complete later with lnet_finalize(). This also gives back a receive
241 * credit if the LND does flow control. */
242 int (*lnd_recv)(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
243 int delayed, unsigned int niov,
244 struct kvec *iov, lnet_kiov_t *kiov,
245 unsigned int offset, unsigned int mlen, unsigned int rlen);
247 /* lnet_parse() has had to delay processing of this message
248 * (e.g. waiting for a forwarding buffer or send credits). Give the
249 * LND a chance to free urgently needed resources. If called, return 0
250 * for success and do NOT give back a receive credit; that has to wait
251 * until lnd_recv() gets called. On failure return < 0 and
252 * release resources; lnd_recv() will not be called. */
253 int (*lnd_eager_recv)(struct lnet_ni *ni, void *private,
254 struct lnet_msg *msg, void **new_privatep);
256 /* notification of peer health */
257 void (*lnd_notify)(struct lnet_ni *ni, lnet_nid_t peer, int alive);
259 /* query of peer aliveness */
260 void (*lnd_query)(struct lnet_ni *ni, lnet_nid_t peer, time64_t *when);
262 /* accept a new connection */
263 int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock);
266 struct lnet_tx_queue {
267 int tq_credits; /* # tx credits free */
268 int tq_credits_min; /* lowest it's been */
269 int tq_credits_max; /* total # tx credits */
270 struct list_head tq_delayed; /* delayed TXs */
273 enum lnet_net_state {
274 /* set when net block is allocated */
275 LNET_NET_STATE_INIT = 0,
276 /* set when NIs in net are started successfully */
277 LNET_NET_STATE_ACTIVE,
278 /* set if all NIs in net are in FAILED state */
279 LNET_NET_STATE_INACTIVE,
280 /* set when shutting down a NET */
281 LNET_NET_STATE_DELETING
285 /* set when NI block is allocated */
286 LNET_NI_STATE_INIT = 0,
287 /* set when NI is started successfully */
288 LNET_NI_STATE_ACTIVE,
289 /* set when LND notifies NI failed */
290 LNET_NI_STATE_FAILED,
291 /* set when LND notifies NI degraded */
292 LNET_NI_STATE_DEGRADED,
293 /* set when shuttding down NI */
294 LNET_NI_STATE_DELETING
297 enum lnet_stats_type {
298 LNET_STATS_TYPE_SEND = 0,
299 LNET_STATS_TYPE_RECV,
303 struct lnet_comm_count {
304 atomic_t co_get_count;
305 atomic_t co_put_count;
306 atomic_t co_reply_count;
307 atomic_t co_ack_count;
308 atomic_t co_hello_count;
311 struct lnet_element_stats {
312 struct lnet_comm_count el_send_stats;
313 struct lnet_comm_count el_recv_stats;
314 struct lnet_comm_count el_drop_stats;
318 /* chain on the ln_nets */
319 struct list_head net_list;
321 /* net ID, which is composed of
322 * (net_type << 16) | net_num.
323 * net_type can be one of the enumerated types defined in
324 * lnet/include/lnet/nidstr.h */
327 /* priority of the network */
330 /* total number of CPTs in the array */
333 /* cumulative CPTs of all NIs in this net */
336 /* network tunables */
337 struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
340 * boolean to indicate that the tunables have been set and
343 bool net_tunables_set;
345 /* procedural interface */
346 struct lnet_lnd *net_lnd;
348 /* list of NIs on this net */
349 struct list_head net_ni_list;
351 /* list of NIs being added, but not started yet */
352 struct list_head net_ni_added;
354 /* dying LND instances */
355 struct list_head net_ni_zombie;
358 enum lnet_net_state net_state;
362 /* chain on the lnet_net structure */
363 struct list_head ni_netlist;
365 /* chain on net_ni_cpt */
366 struct list_head ni_cptlist;
373 /* bond NI on some CPTs */
376 /* interface's NID */
379 /* instance-specific data */
383 atomic_t ni_tx_credits;
385 /* percpt TX queues */
386 struct lnet_tx_queue **ni_tx_queues;
388 /* percpt reference count */
391 /* when I was last alive */
392 time64_t ni_last_alive;
394 /* pointer to parent network */
395 struct lnet_net *ni_net;
397 /* my health status */
398 struct lnet_ni_status *ni_status;
401 enum lnet_ni_state ni_state;
403 /* per NI LND tunables */
404 struct lnet_lnd_tunables ni_lnd_tunables;
406 /* lnd tunables set explicitly */
407 bool ni_lnd_tunables_set;
410 struct lnet_element_stats ni_stats;
412 /* physical device CPT */
415 /* sequence number used to round robin over nis within a net */
420 * initialized to LNET_MAX_HEALTH_VALUE
421 * Value is decremented every time we fail to send a message over
422 * this NI because of a NI specific failure.
423 * Value is incremented if we successfully send a message.
428 * equivalent interfaces to use
429 * This is an array because socklnd bonding can still be configured
431 char *ni_interfaces[LNET_INTERFACES_NUM];
432 struct net *ni_net_ns; /* original net namespace */
435 #define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL
438 * Descriptor of a ping info buffer: keep a separate indicator of the
439 * size and a reference count. The type is used both as a source and
440 * sink of data, so we need to keep some information outside of the
441 * area that may be overwritten by network data.
443 struct lnet_ping_buffer {
446 struct lnet_ping_info pb_info;
449 #define LNET_PING_BUFFER_SIZE(NNIDS) \
450 offsetof(struct lnet_ping_buffer, pb_info.pi_ni[NNIDS])
451 #define LNET_PING_BUFFER_LONI(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_nid)
452 #define LNET_PING_BUFFER_SEQNO(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_status)
454 #define LNET_PING_INFO_TO_BUFFER(PINFO) \
455 container_of((PINFO), struct lnet_ping_buffer, pb_info)
457 /* router checker data, per router */
458 struct lnet_rc_data {
459 /* chain on the_lnet.ln_zombie_rcd or ln_deathrow_rcd */
460 struct list_head rcd_list;
461 struct lnet_handle_md rcd_mdh; /* ping buffer MD */
462 struct lnet_peer_ni *rcd_gateway; /* reference to gateway */
463 struct lnet_ping_buffer *rcd_pingbuffer;/* ping buffer */
464 int rcd_nnis; /* desired size of buffer */
467 struct lnet_peer_ni {
468 /* chain on lpn_peer_nis */
469 struct list_head lpni_peer_nis;
470 /* chain on remote peer list */
471 struct list_head lpni_on_remote_peer_ni_list;
472 /* chain on peer hash */
473 struct list_head lpni_hashlist;
474 /* messages blocking for tx credits */
475 struct list_head lpni_txq;
476 /* messages blocking for router credits */
477 struct list_head lpni_rtrq;
478 /* chain on router list */
479 struct list_head lpni_rtr_list;
480 /* pointer to peer net I'm part of */
481 struct lnet_peer_net *lpni_peer_net;
482 /* statistics kept on each peer NI */
483 struct lnet_element_stats lpni_stats;
484 /* spin lock protecting credits and lpni_txq / lpni_rtrq */
485 spinlock_t lpni_lock;
486 /* # tx credits available */
489 int lpni_mintxcredits;
490 /* # router credits */
493 int lpni_minrtrcredits;
494 /* bytes queued for sending */
498 /* notification outstanding? */
500 /* outstanding notification for LND? */
502 /* some thread is handling notification */
504 /* SEND event outstanding from ping */
505 bool lpni_ping_notsent;
506 /* # times router went dead<->alive. Protected with lpni_lock */
507 int lpni_alive_count;
508 /* time of last aliveness news */
509 time64_t lpni_timestamp;
510 /* time of last ping attempt */
511 time64_t lpni_ping_timestamp;
512 /* != 0 if ping reply expected */
513 time64_t lpni_ping_deadline;
514 /* when I was last alive */
515 time64_t lpni_last_alive;
516 /* when lpni_ni was queried last time */
517 time64_t lpni_last_query;
518 /* network peer is on */
519 struct lnet_net *lpni_net;
523 atomic_t lpni_refcount;
524 /* CPT this peer attached on */
526 /* state flags -- protected by lpni_lock */
528 /* # refs from lnet_route_t::lr_gateway */
529 int lpni_rtr_refcount;
530 /* sequence number used to round robin over peer nis within a net */
532 /* sequence number used to round robin over gateways */
536 /* returned RC ping features. Protected with lpni_lock */
537 unsigned int lpni_ping_feats;
538 /* routes on this peer */
539 struct list_head lpni_routes;
540 /* preferred local nids: if only one, use lpni_pref.nid */
545 /* number of preferred NIDs in lnpi_pref_nids */
546 __u32 lpni_pref_nnids;
547 /* router checker state */
548 struct lnet_rc_data *lpni_rcd;
551 /* Preferred path added due to traffic on non-MR peer_ni */
552 #define LNET_PEER_NI_NON_MR_PREF (1 << 0)
555 /* chain on pt_peer_list */
556 struct list_head lp_peer_list;
558 /* list of peer nets */
559 struct list_head lp_peer_nets;
561 /* list of messages pending discovery*/
562 struct list_head lp_dc_pendq;
564 /* primary NID of the peer */
565 lnet_nid_t lp_primary_nid;
567 /* CPT of peer_table */
570 /* number of NIDs on this peer */
573 /* reference count */
574 atomic_t lp_refcount;
576 /* lock protecting peer state flags */
579 /* peer state flags */
582 /* buffer for data pushed by peer */
583 struct lnet_ping_buffer *lp_data;
585 /* MD handle for ping in progress */
586 struct lnet_handle_md lp_ping_mdh;
588 /* MD handle for push in progress */
589 struct lnet_handle_md lp_push_mdh;
591 /* number of NIDs for sizing push data */
594 /* NI config sequence number of peer */
597 /* Local NI config sequence number acked by peer */
600 /* Local NI config sequence number sent to peer */
601 __u32 lp_node_seqno_sent;
603 /* Ping error encountered during discovery. */
606 /* Push error encountered during discovery. */
609 /* Error encountered during discovery. */
612 /* time it was put on the ln_dc_working queue */
613 time64_t lp_last_queued;
615 /* link on discovery-related lists */
616 struct list_head lp_dc_list;
618 /* tasks waiting on discovery of this peer */
619 wait_queue_head_t lp_dc_waitq;
623 * The status flags in lp_state. Their semantics have chosen so that
624 * lp_state can be zero-initialized.
626 * A peer is marked MULTI_RAIL in two cases: it was configured using DLC
627 * as multi-rail aware, or the LNET_PING_FEAT_MULTI_RAIL bit was set.
629 * A peer is marked NO_DISCOVERY if the LNET_PING_FEAT_DISCOVERY bit was
630 * NOT set when the peer was pinged by discovery.
632 #define LNET_PEER_MULTI_RAIL (1 << 0) /* Multi-rail aware */
633 #define LNET_PEER_NO_DISCOVERY (1 << 1) /* Peer disabled discovery */
635 * A peer is marked CONFIGURED if it was configured by DLC.
637 * In addition, a peer is marked DISCOVERED if it has fully passed
638 * through Peer Discovery.
640 * When Peer Discovery is disabled, the discovery thread will mark
641 * peers REDISCOVER to indicate that they should be re-examined if
642 * discovery is (re)enabled on the node.
644 * A peer that was created as the result of inbound traffic will not
647 #define LNET_PEER_CONFIGURED (1 << 2) /* Configured via DLC */
648 #define LNET_PEER_DISCOVERED (1 << 3) /* Peer was discovered */
649 #define LNET_PEER_REDISCOVER (1 << 4) /* Discovery was disabled */
651 * A peer is marked DISCOVERING when discovery is in progress.
652 * The other flags below correspond to stages of discovery.
654 #define LNET_PEER_DISCOVERING (1 << 5) /* Discovering */
655 #define LNET_PEER_DATA_PRESENT (1 << 6) /* Remote peer data present */
656 #define LNET_PEER_NIDS_UPTODATE (1 << 7) /* Remote peer info uptodate */
657 #define LNET_PEER_PING_SENT (1 << 8) /* Waiting for REPLY to Ping */
658 #define LNET_PEER_PUSH_SENT (1 << 9) /* Waiting for ACK of Push */
659 #define LNET_PEER_PING_FAILED (1 << 10) /* Ping send failure */
660 #define LNET_PEER_PUSH_FAILED (1 << 11) /* Push send failure */
662 * A ping can be forced as a way to fix up state, or as a manual
663 * intervention by an admin.
664 * A push can be forced in circumstances that would normally not
665 * allow for one to happen.
667 #define LNET_PEER_FORCE_PING (1 << 12) /* Forced Ping */
668 #define LNET_PEER_FORCE_PUSH (1 << 13) /* Forced Push */
670 struct lnet_peer_net {
671 /* chain on lp_peer_nets */
672 struct list_head lpn_peer_nets;
674 /* list of peer_nis on this network */
675 struct list_head lpn_peer_nis;
677 /* pointer to the peer I'm part of */
678 struct lnet_peer *lpn_peer;
683 /* reference count */
684 atomic_t lpn_refcount;
688 #define LNET_PEER_HASH_BITS 9
689 #define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS)
692 * peer hash table - one per CPT
694 * protected by lnet_net_lock/EX for update
700 * protected by pt_zombie_lock:
704 * pt_zombie lock nests inside lnet_net_lock
706 struct lnet_peer_table {
707 int pt_version; /* /proc validity stamp */
708 int pt_number; /* # peers_ni extant */
709 struct list_head *pt_hash; /* NID->peer hash */
710 struct list_head pt_peer_list; /* peers */
711 int pt_peers; /* # peers */
712 struct list_head pt_zombie_list; /* zombie peer_ni */
713 int pt_zombies; /* # zombie peers_ni */
714 spinlock_t pt_zombie_lock; /* protect list and count */
717 /* peer aliveness is enabled only on routers for peers in a network where the
718 * struct lnet_ni::ni_peertimeout has been set to a positive value
720 #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing != 0 && \
721 ((lp)->lpni_net) && \
722 (lp)->lpni_net->net_tunables.lct_peer_timeout > 0)
725 struct list_head lr_list; /* chain on net */
726 struct list_head lr_gwlist; /* chain on gateway */
727 struct lnet_peer_ni *lr_gateway; /* router node */
728 __u32 lr_net; /* remote network number */
729 int lr_seq; /* sequence for round-robin */
730 unsigned int lr_downis; /* number of down NIs */
731 __u32 lr_hops; /* how far I am */
732 unsigned int lr_priority; /* route priority */
735 #define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)
736 #define LNET_REMOTE_NETS_HASH_MAX (1U << 16)
737 #define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits)
739 struct lnet_remotenet {
740 /* chain on ln_remote_nets_hash */
741 struct list_head lrn_list;
743 struct list_head lrn_routes;
748 /** lnet message has credit and can be submitted to lnd for send/receive */
749 #define LNET_CREDIT_OK 0
750 /** lnet message is waiting for credit */
751 #define LNET_CREDIT_WAIT 1
752 /** lnet message is waiting for discovery */
753 #define LNET_DC_WAIT 2
755 struct lnet_rtrbufpool {
756 /* my free buffer pool */
757 struct list_head rbp_bufs;
758 /* messages blocking for a buffer */
759 struct list_head rbp_msgs;
760 /* # pages in each buffer */
762 /* requested number of buffers */
763 int rbp_req_nbuffers;
764 /* # buffers actually allocated */
766 /* # free buffers / blocked messages */
773 struct list_head rb_list; /* chain on rbp_bufs */
774 struct lnet_rtrbufpool *rb_pool; /* owning pool */
775 lnet_kiov_t rb_kiov[0]; /* the buffer space */
778 #define LNET_PEER_HASHSIZE 503 /* prime! */
780 enum lnet_match_flags {
781 /* Didn't match anything */
782 LNET_MATCHMD_NONE = (1 << 0),
784 LNET_MATCHMD_OK = (1 << 1),
785 /* Must be discarded */
786 LNET_MATCHMD_DROP = (1 << 2),
787 /* match and buffer is exhausted */
788 LNET_MATCHMD_EXHAUSTED = (1 << 3),
790 LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
793 /* Options for struct lnet_portal::ptl_options */
794 #define LNET_PTL_LAZY (1 << 0)
795 #define LNET_PTL_MATCH_UNIQUE (1 << 1) /* unique match, for RDMA */
796 #define LNET_PTL_MATCH_WILDCARD (1 << 2) /* wildcard match, request portal */
798 /* parameter for matching operations (GET, PUT) */
799 struct lnet_match_info {
801 struct lnet_process_id mi_id;
804 unsigned int mi_portal;
805 unsigned int mi_rlength;
806 unsigned int mi_roffset;
809 /* ME hash of RDMA portal */
810 #define LNET_MT_HASH_BITS 8
811 #define LNET_MT_HASH_SIZE (1 << LNET_MT_HASH_BITS)
812 #define LNET_MT_HASH_MASK (LNET_MT_HASH_SIZE - 1)
813 /* we allocate (LNET_MT_HASH_SIZE + 1) entries for lnet_match_table::mt_hash,
814 * the last entry is reserved for MEs with ignore-bits */
815 #define LNET_MT_HASH_IGNORE LNET_MT_HASH_SIZE
816 /* __u64 has 2^6 bits, so need 2^(LNET_MT_HASH_BITS - LNET_MT_BITS_U64) which
817 * is 4 __u64s as bit-map, and add an extra __u64 (only use one bit) for the
818 * ME-list with ignore-bits, which is mtable::mt_hash[LNET_MT_HASH_IGNORE] */
819 #define LNET_MT_BITS_U64 6 /* 2^6 bits */
820 #define LNET_MT_EXHAUSTED_BITS (LNET_MT_HASH_BITS - LNET_MT_BITS_U64)
821 #define LNET_MT_EXHAUSTED_BMAP ((1 << LNET_MT_EXHAUSTED_BITS) + 1)
823 /* portal match table */
824 struct lnet_match_table {
825 /* reserved for upcoming patches, CPU partition ID */
827 unsigned int mt_portal; /* portal index */
828 /* match table is set as "enabled" if there's non-exhausted MD
829 * attached on mt_mhash, it's only valid for wildcard portal */
830 unsigned int mt_enabled;
831 /* bitmap to flag whether MEs on mt_hash are exhausted or not */
832 __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
833 struct list_head *mt_mhash; /* matching hash */
836 /* these are only useful for wildcard portal */
837 /* Turn off message rotor for wildcard portals */
838 #define LNET_PTL_ROTOR_OFF 0
839 /* round-robin dispatch all PUT messages for wildcard portals */
840 #define LNET_PTL_ROTOR_ON 1
841 /* round-robin dispatch routed PUT message for wildcard portals */
842 #define LNET_PTL_ROTOR_RR_RT 2
843 /* dispatch routed PUT message by hashing source NID for wildcard portals */
844 #define LNET_PTL_ROTOR_HASH_RT 3
848 unsigned int ptl_index; /* portal ID, reserved */
849 /* flags on this portal: lazy, unique... */
850 unsigned int ptl_options;
851 /* list of messages which are stealing buffer */
852 struct list_head ptl_msg_stealing;
853 /* messages blocking for MD */
854 struct list_head ptl_msg_delayed;
855 /* Match table for each CPT */
856 struct lnet_match_table **ptl_mtables;
857 /* spread rotor of incoming "PUT" */
858 unsigned int ptl_rotor;
859 /* # active entries for this portal */
861 /* array of active entries' cpu-partition-id */
865 #define LNET_LH_HASH_BITS 12
866 #define LNET_LH_HASH_SIZE (1ULL << LNET_LH_HASH_BITS)
867 #define LNET_LH_HASH_MASK (LNET_LH_HASH_SIZE - 1)
869 /* resource container (ME, MD, EQ) */
870 struct lnet_res_container {
871 unsigned int rec_type; /* container type */
872 __u64 rec_lh_cookie; /* cookie generator */
873 struct list_head rec_active; /* active resource list */
874 struct list_head *rec_lh_hash; /* handle hash */
877 /* message container */
878 struct lnet_msg_container {
879 int msc_init; /* initialized or not */
880 /* max # threads finalizing */
882 /* msgs waiting to complete finalizing */
883 struct list_head msc_finalizing;
884 struct list_head msc_active; /* active message list */
885 /* threads doing finalization */
886 void **msc_finalizers;
889 /* Peer Discovery states */
890 #define LNET_DC_STATE_SHUTDOWN 0 /* not started */
891 #define LNET_DC_STATE_RUNNING 1 /* started up OK */
892 #define LNET_DC_STATE_STOPPING 2 /* telling thread to stop */
894 /* Router Checker states */
895 #define LNET_RC_STATE_SHUTDOWN 0 /* not started */
896 #define LNET_RC_STATE_RUNNING 1 /* started up OK */
897 #define LNET_RC_STATE_STOPPING 2 /* telling thread to stop */
900 #define LNET_STATE_SHUTDOWN 0 /* not started */
901 #define LNET_STATE_RUNNING 1 /* started up OK */
902 #define LNET_STATE_STOPPING 2 /* telling thread to stop */
905 /* CPU partition table of LNet */
906 struct cfs_cpt_table *ln_cpt_table;
907 /* number of CPTs in ln_cpt_table */
908 unsigned int ln_cpt_number;
909 unsigned int ln_cpt_bits;
911 /* protect LNet resources (ME/MD/EQ) */
912 struct cfs_percpt_lock *ln_res_lock;
915 /* the vector of portals */
916 struct lnet_portal **ln_portals;
917 /* percpt ME containers */
918 struct lnet_res_container **ln_me_containers;
919 /* percpt MD container */
920 struct lnet_res_container **ln_md_containers;
922 /* Event Queue container */
923 struct lnet_res_container ln_eq_container;
924 wait_queue_head_t ln_eq_waitq;
925 spinlock_t ln_eq_wait_lock;
927 unsigned int ln_remote_nets_hbits;
929 /* protect NI, peer table, credits, routers, rtrbuf... */
930 struct cfs_percpt_lock *ln_net_lock;
931 /* percpt message containers for active/finalizing/freed message */
932 struct lnet_msg_container **ln_msg_containers;
933 struct lnet_counters **ln_counters;
934 struct lnet_peer_table **ln_peer_tables;
935 /* list of peer nis not on a local network */
936 struct list_head ln_remote_peer_ni_list;
937 /* failure simulation */
938 struct list_head ln_test_peers;
939 struct list_head ln_drop_rules;
940 struct list_head ln_delay_rules;
942 struct list_head ln_nets;
943 /* the loopback NI */
944 struct lnet_ni *ln_loni;
945 /* network zombie list */
946 struct list_head ln_net_zombie;
947 /* resend messages list */
948 struct list_head ln_msg_resend;
949 /* spin lock to protect the msg resend list */
950 spinlock_t ln_msg_resend_lock;
952 /* remote networks with routes to them */
953 struct list_head *ln_remote_nets_hash;
955 __u64 ln_remote_nets_version;
956 /* list of all known routers */
957 struct list_head ln_routers;
959 __u64 ln_routers_version;
960 /* percpt router buffer pools */
961 struct lnet_rtrbufpool **ln_rtrpools;
964 * Ping target / Push source
966 * The ping target and push source share a single buffer. The
967 * ln_ping_target is protected against concurrent updates by
970 struct lnet_handle_md ln_ping_target_md;
971 struct lnet_handle_eq ln_ping_target_eq;
972 struct lnet_ping_buffer *ln_ping_target;
973 atomic_t ln_ping_target_seqno;
978 * ln_push_nnis contains the desired size of the push target.
979 * The lnet_net_lock is used to handle update races. The old
980 * buffer may linger a while after it has been unlinked, in
981 * which case the event handler cleans up.
983 struct lnet_handle_eq ln_push_target_eq;
984 struct lnet_handle_md ln_push_target_md;
985 struct lnet_ping_buffer *ln_push_target;
986 int ln_push_target_nnis;
988 /* discovery event queue handle */
989 struct lnet_handle_eq ln_dc_eqh;
990 /* discovery requests */
991 struct list_head ln_dc_request;
992 /* discovery working list */
993 struct list_head ln_dc_working;
994 /* discovery expired list */
995 struct list_head ln_dc_expired;
996 /* discovery thread wait queue */
997 wait_queue_head_t ln_dc_waitq;
998 /* discovery startup/shutdown state */
1001 /* router checker startup/shutdown state */
1003 /* router checker's event queue */
1004 struct lnet_handle_eq ln_rc_eqh;
1005 /* rcd still pending on net */
1006 struct list_head ln_rcd_deathrow;
1007 /* rcd ready for free */
1008 struct list_head ln_rcd_zombie;
1009 /* serialise startup/shutdown */
1010 struct semaphore ln_rc_signal;
1012 struct mutex ln_api_mutex;
1013 struct mutex ln_lnd_mutex;
1014 /* Have I called LNetNIInit myself? */
1016 /* LNetNIInit/LNetNIFini counter */
1018 /* SHUTDOWN/RUNNING/STOPPING */
1021 int ln_routing; /* am I a router? */
1022 lnet_pid_t ln_pid; /* requested pid */
1023 /* uniquely identifies this ni in this epoch */
1024 __u64 ln_interface_cookie;
1025 /* registered LNDs */
1026 struct list_head ln_lnds;
1028 /* test protocol compatibility flags */
1029 int ln_testprotocompat;
1031 /* 0 - load the NIs from the mod params
1032 * 1 - do not load the NIs from the mod params
1033 * Reverse logic to ensure that other calls to LNetNIInit
1036 bool ln_nis_from_mod_params;
1038 /* waitq for router checker. As long as there are no routes in
1039 * the list, the router checker will sleep on this queue. when
1040 * routes are added the thread will wake up */
1041 wait_queue_head_t ln_rc_waitq;