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/
31 * lnet/include/lnet/lib-types.h
33 * Types used by the library side routines that do not need to be
34 * exposed to the user application
37 #ifndef __LNET_LIB_TYPES_H__
38 #define __LNET_LIB_TYPES_H__
41 # error This include is only for kernel use.
44 #include <linux/kthread.h>
45 #include <linux/uio.h>
46 #include <linux/semaphore.h>
47 #include <linux/types.h>
48 #include <linux/kref.h>
49 #include <net/genetlink.h>
51 #include <uapi/linux/lnet/lnet-nl.h>
52 #include <uapi/linux/lnet/lnet-dlc.h>
53 #include <uapi/linux/lnet/lnetctl.h>
54 #include <uapi/linux/lnet/nidstr.h>
56 char *libcfs_nidstr_r(const struct lnet_nid *nid,
57 char *buf, size_t buf_size);
59 static inline char *libcfs_nidstr(const struct lnet_nid *nid)
61 return libcfs_nidstr_r(nid, libcfs_next_nidstring(),
65 int libcfs_strnid(struct lnet_nid *nid, const char *str);
66 char *libcfs_idstr(struct lnet_processid *id);
67 int libcfs_strid(struct lnet_processid *id, const char *str);
69 int cfs_match_nid_net(struct lnet_nid *nid, u32 net,
70 struct list_head *net_num_list,
71 struct list_head *addr);
73 /* Max payload size */
74 #define LNET_MAX_PAYLOAD LNET_MTU
76 /** limit on the number of fragments in discontiguous MDs */
77 #define LNET_MAX_IOV 256
80 * This is the maximum health value.
81 * All local and peer NIs created have their health default to this value.
83 #define LNET_MAX_HEALTH_VALUE 1000
84 #define LNET_MAX_SELECTION_PRIORITY UINT_MAX
89 enum lnet_msg_hstatus {
90 LNET_MSG_STATUS_OK = 0,
91 LNET_MSG_STATUS_LOCAL_INTERRUPT,
92 LNET_MSG_STATUS_LOCAL_DROPPED,
93 LNET_MSG_STATUS_LOCAL_ABORTED,
94 LNET_MSG_STATUS_LOCAL_NO_ROUTE,
95 LNET_MSG_STATUS_LOCAL_ERROR,
96 LNET_MSG_STATUS_LOCAL_TIMEOUT,
97 LNET_MSG_STATUS_REMOTE_ERROR,
98 LNET_MSG_STATUS_REMOTE_DROPPED,
99 LNET_MSG_STATUS_REMOTE_TIMEOUT,
100 LNET_MSG_STATUS_NETWORK_TIMEOUT,
104 struct lnet_rsp_tracker {
105 /* chain on the waiting list */
106 struct list_head rspt_on_list;
109 /* nid of next hop */
110 struct lnet_nid rspt_next_hop_nid;
111 /* deadline of the REPLY/ACK */
112 ktime_t rspt_deadline;
114 struct lnet_handle_md rspt_mdh;
118 struct list_head msg_activelist;
119 struct list_head msg_list; /* Q for credits/MD */
121 struct lnet_processid msg_target;
122 /* Primary NID of the source. */
123 struct lnet_nid msg_initiator;
124 /* where is it from, it's only for building event */
125 struct lnet_nid msg_from;
129 * hold parameters in case message is with held due
132 struct lnet_nid msg_src_nid_param;
133 struct lnet_nid msg_rtr_nid_param;
136 * Deadline for the message after which it will be finalized if it
139 ktime_t msg_deadline;
141 /* The message health status. */
142 enum lnet_msg_hstatus msg_health_status;
143 /* This is a recovery message */
145 /* the number of times a transmission has been retried */
147 /* flag to indicate that we do not want to resend this message */
150 /* committed for sending */
151 unsigned int msg_tx_committed:1;
152 /* CPT # this message committed for sending */
153 unsigned int msg_tx_cpt:15;
154 /* committed for receiving */
155 unsigned int msg_rx_committed:1;
156 /* CPT # this message committed for receiving */
157 unsigned int msg_rx_cpt:15;
158 /* queued for tx credit */
159 unsigned int msg_tx_delayed:1;
160 /* queued for RX buffer */
161 unsigned int msg_rx_delayed:1;
162 /* ready for pending on RX delay list */
163 unsigned int msg_rx_ready_delay:1;
165 unsigned int msg_vmflush:1; /* VM trying to free memory */
166 unsigned int msg_target_is_router:1; /* sending to a router */
167 unsigned int msg_routing:1; /* being forwarded */
168 unsigned int msg_ack:1; /* ack on finalize (PUT) */
169 unsigned int msg_sending:1; /* outgoing message */
170 unsigned int msg_receiving:1; /* being received */
171 unsigned int msg_txcredit:1; /* taken an NI send credit */
172 unsigned int msg_peertxcredit:1; /* taken a peer send credit */
173 unsigned int msg_rtrcredit:1; /* taken a globel router credit */
174 unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */
175 unsigned int msg_onactivelist:1; /* on the activelist */
176 unsigned int msg_rdma_get:1;
178 struct lnet_peer_ni *msg_txpeer; /* peer I'm sending to */
179 struct lnet_peer_ni *msg_rxpeer; /* peer I received from */
182 struct lnet_libmd *msg_md;
183 /* the NI the message was sent or received over */
184 struct lnet_ni *msg_txni;
185 struct lnet_ni *msg_rxni;
187 unsigned int msg_len;
188 unsigned int msg_wanted;
189 unsigned int msg_offset;
190 unsigned int msg_niov;
191 struct bio_vec *msg_kiov;
193 struct lnet_event msg_ev;
194 struct lnet_hdr msg_hdr;
197 struct lnet_libhandle {
198 struct list_head lh_hash_chain;
202 #define lh_entry(ptr, type, member) \
203 ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
206 struct list_head me_list;
208 struct lnet_processid me_match_id;
209 unsigned int me_portal;
210 unsigned int me_pos; /* hash offset in mt_hash */
212 __u64 me_ignore_bits;
213 enum lnet_unlink me_unlink;
214 struct lnet_libmd *me_md;
218 struct list_head md_list;
219 struct lnet_libhandle md_lh;
220 struct lnet_me *md_me;
222 unsigned int md_offset;
223 unsigned int md_length;
224 unsigned int md_max_size;
227 unsigned int md_options;
228 unsigned int md_flags;
229 unsigned int md_niov; /* # frags at end of struct */
231 struct lnet_rsp_tracker *md_rspt_ptr;
232 lnet_handler_t md_handler;
233 struct lnet_handle_md md_bulk_handle;
234 struct bio_vec md_kiov[LNET_MAX_IOV];
237 #define LNET_MD_FLAG_ZOMBIE BIT(0)
238 #define LNET_MD_FLAG_AUTO_UNLINK BIT(1)
239 #define LNET_MD_FLAG_ABORTED BIT(2)
240 /* LNET_MD_FLAG_HANDLING is set when a non-unlink event handler
241 * is being called for an event relating to the md.
242 * It ensures only one such handler runs at a time.
243 * The final "unlink" event is only called once the
244 * md_refcount has reached zero, and this flag has been cleared,
245 * ensuring that it doesn't race with any other event handler
248 #define LNET_MD_FLAG_HANDLING BIT(3)
249 #define LNET_MD_FLAG_DISCARD BIT(4)
250 #define LNET_MD_FLAG_GPU BIT(5) /**< Special mapping needs */
252 struct lnet_test_peer {
253 /* info about peers we are trying to fail */
254 struct list_head tp_list; /* ln_test_peers */
255 struct lnet_nid tp_nid; /* matching nid */
256 unsigned int tp_threshold; /* # failures to simulate */
259 #define LNET_COOKIE_TYPE_MD 1
260 #define LNET_COOKIE_TYPE_ME 2
261 #define LNET_COOKIE_TYPE_EQ 3
262 #define LNET_COOKIE_TYPE_BITS 2
263 #define LNET_COOKIE_MASK ((1ULL << LNET_COOKIE_TYPE_BITS) - 1ULL)
269 void (*nf_addr2str)(u32 addr, char *str, size_t size);
270 void (*nf_addr2str_size)(const __be32 *addr, size_t asize,
271 char *str, size_t size);
272 int (*nf_str2addr)(const char *str, int nob, u32 *addr);
273 int (*nf_str2addr_size)(const char *str, int nob,
274 __be32 *addr, size_t *asize);
275 int (*nf_parse_addrlist)(char *str, int len,
276 struct list_head *list);
277 int (*nf_print_addrlist)(char *buffer, int count,
278 struct list_head *list);
279 int (*nf_match_addr)(u32 addr, struct list_head *list);
280 int (*nf_min_max)(struct list_head *nidlist, u32 *min_nid,
284 struct lnet_ni; /* forward ref */
288 /* fields initialized by the LND */
291 int (*lnd_startup)(struct lnet_ni *ni);
292 void (*lnd_shutdown)(struct lnet_ni *ni);
293 int (*lnd_ctl)(struct lnet_ni *ni, unsigned int cmd, void *arg);
295 /* In data movement APIs below, payload buffers are described as a set
296 * of 'niov' fragments which are in pages.
297 * The LND may NOT overwrite these fragment descriptors.
298 * An 'offset' and may specify a byte offset within the set of
299 * fragments to start from
302 /* Start sending a preformatted message. 'private' is NULL for PUT and
303 * GET messages; otherwise this is a response to an incoming message
304 * and 'private' is the 'private' passed to lnet_parse(). Return
305 * non-zero for immediate failure, otherwise complete later with
307 int (*lnd_send)(struct lnet_ni *ni, void *private,
308 struct lnet_msg *msg);
310 /* Start receiving 'mlen' bytes of payload data, skipping the following
311 * 'rlen' - 'mlen' bytes. 'private' is the 'private' passed to
312 * lnet_parse(). Return non-zero for immedaite failure, otherwise
313 * complete later with lnet_finalize(). This also gives back a receive
314 * credit if the LND does flow control. */
315 int (*lnd_recv)(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
316 int delayed, unsigned int niov,
317 struct bio_vec *kiov,
318 unsigned int offset, unsigned int mlen, unsigned int rlen);
320 /* lnet_parse() has had to delay processing of this message
321 * (e.g. waiting for a forwarding buffer or send credits). Give the
322 * LND a chance to free urgently needed resources. If called, return 0
323 * for success and do NOT give back a receive credit; that has to wait
324 * until lnd_recv() gets called. On failure return < 0 and
325 * release resources; lnd_recv() will not be called. */
326 int (*lnd_eager_recv)(struct lnet_ni *ni, void *private,
327 struct lnet_msg *msg, void **new_privatep);
329 /* notification of peer down */
330 void (*lnd_notify_peer_down)(struct lnet_nid *peer);
332 /* accept a new connection */
333 int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock);
335 /* get dma_dev priority */
336 unsigned int (*lnd_get_dev_prio)(struct lnet_ni *ni,
337 unsigned int dev_idx);
339 /* Handle LND specific Netlink handling */
340 int (*lnd_nl_set)(int cmd, struct nlattr *attr, int type, void *data);
342 const struct ln_key_list *lnd_keys;
345 struct lnet_tx_queue {
346 int tq_credits; /* # tx credits free */
347 int tq_credits_min; /* lowest it's been */
348 int tq_credits_max; /* total # tx credits */
349 struct list_head tq_delayed; /* delayed TXs */
352 enum lnet_net_state {
353 /* set when net block is allocated */
354 LNET_NET_STATE_INIT = 0,
355 /* set when NIs in net are started successfully */
356 LNET_NET_STATE_ACTIVE,
357 /* set if all NIs in net are in FAILED state */
358 LNET_NET_STATE_INACTIVE,
359 /* set when shutting down a NET */
360 LNET_NET_STATE_DELETING
364 /* initial state when NI is created */
365 LNET_NI_STATE_INIT = 0,
366 /* set when NI is brought up */
367 LNET_NI_STATE_ACTIVE,
368 /* set when NI is being shutdown */
369 LNET_NI_STATE_DELETING,
372 #define LNET_NI_RECOVERY_PENDING BIT(0)
373 #define LNET_NI_RECOVERY_FAILED BIT(1)
375 enum lnet_stats_type {
376 LNET_STATS_TYPE_SEND = 0,
377 LNET_STATS_TYPE_RECV,
381 struct lnet_comm_count {
382 atomic_t co_get_count;
383 atomic_t co_put_count;
384 atomic_t co_reply_count;
385 atomic_t co_ack_count;
386 atomic_t co_hello_count;
389 struct lnet_element_stats {
390 struct lnet_comm_count el_send_stats;
391 struct lnet_comm_count el_recv_stats;
392 struct lnet_comm_count el_drop_stats;
395 struct lnet_health_local_stats {
396 atomic_t hlt_local_interrupt;
397 atomic_t hlt_local_dropped;
398 atomic_t hlt_local_aborted;
399 atomic_t hlt_local_no_route;
400 atomic_t hlt_local_timeout;
401 atomic_t hlt_local_error;
404 struct lnet_health_remote_stats {
405 atomic_t hlt_remote_dropped;
406 atomic_t hlt_remote_timeout;
407 atomic_t hlt_remote_error;
408 atomic_t hlt_network_timeout;
412 /* chain on the ln_nets */
413 struct list_head net_list;
415 /* net ID, which is composed of
416 * (net_type << 16) | net_num.
417 * net_type can be one of the enumerated types defined in
418 * lnet/include/lnet/nidstr.h */
421 /* round robin selection */
424 /* total number of CPTs in the array */
427 /* cumulative CPTs of all NIs in this net */
430 /* relative net selection priority */
431 __u32 net_sel_priority;
433 /* network tunables */
434 struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
437 * boolean to indicate that the tunables have been set and
440 bool net_tunables_set;
442 /* procedural interface */
443 const struct lnet_lnd *net_lnd;
445 /* list of NIs on this net */
446 struct list_head net_ni_list;
448 /* list of NIs being added, but not started yet */
449 struct list_head net_ni_added;
451 /* dying LND instances */
452 struct list_head net_ni_zombie;
454 /* when I was last alive */
455 time64_t net_last_alive;
457 /* protects access to net_last_alive */
460 /* list of router nids preferred for this network */
461 struct list_head net_rtr_pref_nids;
464 /* Normally Netlink atttributes are defined in UAPI headers but Lustre is
465 * different in that the ABI is in a constant state of change unlike other
466 * Netlink interfaces. LNet sends a special header to help user land handle
470 /** enum lnet_net_attrs - LNet NI netlink properties
471 * attributes that describe LNet 'NI'
472 * These values are used to piece together
473 * messages for sending and receiving.
475 * @LNET_NET_ATTR_UNSPEC: unspecified attribute to catch errors
477 * @LNET_NET_ATTR_HDR: grouping for LNet net data (NLA_NESTED)
478 * @LNET_NET_ATTR_TYPE: LNet net this NI belongs to (NLA_STRING)
479 * @LNET_NET_ATTR_LOCAL: Local NI information (NLA_NESTED)
481 enum lnet_net_attrs {
482 LNET_NET_ATTR_UNSPEC = 0,
488 __LNET_NET_ATTR_MAX_PLUS_ONE,
491 #define LNET_NET_ATTR_MAX (__LNET_NET_ATTR_MAX_PLUS_ONE - 1)
493 /** enum lnet_net_local_ni_attrs - LNet local NI netlink properties
494 * attributes that describe local NI
496 * @LNET_NET_LOCAL_NI_ATTR_UNSPEC: unspecified attribute to catch errors
498 * @LNET_NET_LOCAL_NI_ATTR_NID: NID that represents this NI (NLA_STRING)
499 * @LNET_NET_LOCAL_NI_ATTR_STATUS: State of this NI (NLA_STRING)
500 * @LNET_NET_LOCAL_NI_ATTR_INTERFACE: Defines physical devices (NLA_NESTED)
501 * Used to be many devices but no longer.
503 enum lnet_net_local_ni_attrs {
504 LNET_NET_LOCAL_NI_ATTR_UNSPEC = 0,
506 LNET_NET_LOCAL_NI_ATTR_NID,
507 LNET_NET_LOCAL_NI_ATTR_STATUS,
508 LNET_NET_LOCAL_NI_ATTR_INTERFACE,
510 __LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE,
513 #define LNET_NET_LOCAL_NI_ATTR_MAX (__LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE - 1)
515 /** enum lnet_net_local_ni_intf_attrs - LNet NI device netlink properties
516 * attribute that reports the device
519 * @LNET_NET_LOCAL_NI_INTF_ATTR_UNSPEC: unspecified attribute to catch errors
521 * @LNET_NET_LOCAL_NI_INTF_ATTR_TYPE: Physcial device interface (NLA_STRING)
523 enum lnet_net_local_ni_intf_attrs {
524 LNET_NET_LOCAL_NI_INTF_ATTR_UNSPEC = 0,
526 LNET_NET_LOCAL_NI_INTF_ATTR_TYPE,
528 __LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE,
531 #define LNET_NET_LOCAL_NI_INTF_ATTR_MAX (__LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE - 1)
533 /** enum lnet_net_local_ni_tunables_attrs - LNet NI tunables
534 * netlink properties.
535 * Performance options
538 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_UNSPEC: unspecified attribute
541 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT: Timeout for LNet peer.
543 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS: Credits for LNet peer.
545 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_BUFFER_CREDITS: Buffer credits for
546 * LNet peer. (NLA_S32)
547 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_CREDITS: Credits for LNet peer
550 enum lnet_net_local_ni_tunables_attr {
551 LNET_NET_LOCAL_NI_TUNABLES_ATTR_UNSPEC = 0,
553 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT,
554 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS,
555 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_BUFFER_CREDITS,
556 LNET_NET_LOCAL_NI_TUNABLES_ATTR_CREDITS,
557 __LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX_PLUS_ONE,
560 #define LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX (__LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX_PLUS_ONE - 1)
562 /** LNet netlink ping API */
564 /** enum lnet_ping_atts - LNet ping netlink properties
565 * attributes to describe ping format
566 * These values are used to piece together
567 * messages for sending and receiving.
569 * @LNET_PING_ATTR_UNSPEC: unspecified attribute to catch errors
571 * @LNET_PING_ATTR_HDR: grouping for LNet ping data (NLA_NUL_STRING)
572 * @LNET_PING_ATTR_PRIMARY_NID: Source NID for ping request (NLA_STRING)
573 * @LNET_PING_ATTR_ERRNO: error code if we fail to ping (NLA_S16)
574 * @LNET_PING_ATTR_MULTIRAIL: Report if MR is supported (NLA_FLAG)
575 * @LNET_PING_ATTR_PEER_NI_LIST: List of peer NI's (NLA_NESTED)
577 enum lnet_ping_attr {
578 LNET_PING_ATTR_UNSPEC = 0,
581 LNET_PING_ATTR_PRIMARY_NID,
582 LNET_PING_ATTR_ERRNO,
583 LNET_PING_ATTR_MULTIRAIL,
584 LNET_PING_ATTR_PEER_NI_LIST,
585 __LNET_PING_ATTR_MAX_PLUS_ONE,
588 #define LNET_PING_ATTR_MAX (__LNET_PING_ATTR_MAX_PLUS_ONE - 1)
590 /** enium lnet_ping_peer_ni_attr - LNet peer ni information reported by
591 * ping command. A list of these are
592 * returned with a ping request.
594 * @LNET_PING_PEER_NI_ATTR_UNSPEC: unspecified attribute to catch errrors
596 * @LNET_PING_PEER_NI_ATTR_NID: NID address of peer NI. (NLA_STRING)
598 enum lnet_ping_peer_ni_attr {
599 LNET_PING_PEER_NI_ATTR_UNSPEC = 0,
601 LNET_PING_PEER_NI_ATTR_NID,
602 __LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE,
605 #define LNET_PING_PEER_NI_ATTR_MAX (__LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE - 1)
608 /* chain on the lnet_net structure */
609 struct list_head ni_netlist;
611 /* chain on the recovery queue */
612 struct list_head ni_recovery;
614 /* MD handle for recovery ping */
615 struct lnet_handle_md ni_ping_mdh;
622 /* bond NI on some CPTs */
625 /* interface's NID */
626 struct lnet_nid ni_nid;
628 /* instance-specific data */
632 atomic_t ni_tx_credits;
634 /* percpt TX queues */
635 struct lnet_tx_queue **ni_tx_queues;
637 /* percpt reference count */
640 /* pointer to parent network */
641 struct lnet_net *ni_net;
643 /* my health status */
646 /* NI FSM. Protected by lnet_ni_lock() */
647 enum lnet_ni_state ni_state;
649 /* Recovery state. Protected by lnet_ni_lock() */
650 __u32 ni_recovery_state;
652 /* When to send the next recovery ping */
653 time64_t ni_next_ping;
654 /* How many pings sent during current recovery period did not receive
655 * a reply. NB: reset whenever _any_ message arrives on this NI
657 unsigned int ni_ping_count;
659 /* per NI LND tunables */
660 struct lnet_lnd_tunables ni_lnd_tunables;
662 /* lnd tunables set explicitly */
663 bool ni_lnd_tunables_set;
666 struct lnet_element_stats ni_stats;
667 struct lnet_health_local_stats ni_hstats;
669 /* physical device CPT */
672 /* sequence number used to round robin over nis within a net */
677 * initialized to LNET_MAX_HEALTH_VALUE
678 * Value is decremented every time we fail to send a message over
679 * this NI because of a NI specific failure.
680 * Value is incremented if we successfully send a message.
685 * Set to 1 by the LND when it receives an event telling it the device
686 * has gone into a fatal state. Set to 0 when the LND receives an
687 * even telling it the device is back online.
689 atomic_t ni_fatal_error_on;
691 /* the relative selection priority of this NI */
692 __u32 ni_sel_priority;
695 * equivalent interface to use
698 struct net *ni_net_ns; /* original net namespace */
701 #define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL
704 * Descriptor of a ping info buffer: keep a separate indicator of the
705 * size and a reference count. The type is used both as a source and
706 * sink of data, so we need to keep some information outside of the
707 * area that may be overwritten by network data.
709 struct lnet_ping_buffer {
710 int pb_nbytes; /* sizeof pb_info */
713 struct lnet_ping_info pb_info;
716 #define LNET_PING_BUFFER_SIZE(bytes) \
717 (offsetof(struct lnet_ping_buffer, pb_info) + bytes)
718 #define LNET_PING_BUFFER_LONI(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_nid)
719 #define LNET_PING_BUFFER_SEQNO(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_status)
721 #define LNET_PING_INFO_TO_BUFFER(PINFO) \
722 container_of((PINFO), struct lnet_ping_buffer, pb_info)
725 lnet_ping_sts_size(const struct lnet_nid *nid)
729 if (nid_is_nid4(nid))
730 return sizeof(struct lnet_ni_status);
732 size = offsetof(struct lnet_ni_large_status, ns_nid) +
735 return round_up(size, 4);
738 static inline struct lnet_ni_large_status *
739 lnet_ping_sts_next(const struct lnet_ni_large_status *nis)
741 return (void *)nis + lnet_ping_sts_size(&nis->ns_nid);
745 lnet_ping_at_least_two_entries(const struct lnet_ping_info *pi)
747 /* Return true if we have at lease two entries. There is always a
748 * least one, a 4-byte lo0 interface.
750 struct lnet_ni_large_status *lns;
752 if ((pi->pi_features & LNET_PING_FEAT_LARGE_ADDR) == 0)
753 return pi->pi_nnis <= 2;
754 /* There is at least 1 large-address entry */
755 if (pi->pi_nnis != 1)
757 lns = (void *)&pi->pi_ni[1];
758 lns = lnet_ping_sts_next(lns);
760 return ((void *)pi + lnet_ping_info_size(pi) <= (void *)lns);
763 struct lnet_nid_list {
764 struct list_head nl_list;
765 struct lnet_nid nl_nid;
768 struct lnet_peer_ni {
769 /* chain on lpn_peer_nis */
770 struct list_head lpni_peer_nis;
771 /* chain on remote peer list */
772 struct list_head lpni_on_remote_peer_ni_list;
773 /* chain on recovery queue */
774 struct list_head lpni_recovery;
775 /* chain on peer hash */
776 struct list_head lpni_hashlist;
777 /* messages blocking for tx credits */
778 struct list_head lpni_txq;
779 /* pointer to peer net I'm part of */
780 struct lnet_peer_net *lpni_peer_net;
781 /* statistics kept on each peer NI */
782 struct lnet_element_stats lpni_stats;
783 struct lnet_health_remote_stats lpni_hstats;
784 /* spin lock protecting credits and lpni_txq */
785 spinlock_t lpni_lock;
786 /* # tx credits available */
789 int lpni_mintxcredits;
791 * Each peer_ni in a gateway maintains its own credits. This
792 * allows more traffic to gateways that have multiple interfaces.
794 /* # router credits */
797 int lpni_minrtrcredits;
798 /* bytes queued for sending */
800 /* network peer is on */
801 struct lnet_net *lpni_net;
803 struct lnet_nid lpni_nid;
805 struct kref lpni_kref;
806 /* health value for the peer */
807 atomic_t lpni_healthv;
808 /* recovery ping mdh */
809 struct lnet_handle_md lpni_recovery_ping_mdh;
810 /* When to send the next recovery ping */
811 time64_t lpni_next_ping;
812 /* How many pings sent during current recovery period did not receive
813 * a reply. NB: reset whenever _any_ message arrives from this peer NI
815 unsigned int lpni_ping_count;
816 /* CPT this peer attached on */
818 /* state flags -- protected by lpni_lock */
820 /* status of the peer NI as reported by the peer */
821 __u32 lpni_ns_status;
822 /* sequence number used to round robin over peer nis within a net */
824 /* sequence number used to round robin over gateways */
826 /* returned RC ping features. Protected with lpni_lock */
827 unsigned int lpni_ping_feats;
828 /* time last message was received from the peer */
829 time64_t lpni_last_alive;
830 /* preferred local nids: if only one, use lpni_pref.nid */
833 struct list_head nids;
835 /* list of router nids preferred for this peer NI */
836 struct list_head lpni_rtr_pref_nids;
837 /* The relative selection priority of this peer NI */
838 __u32 lpni_sel_priority;
839 /* number of preferred NIDs in lnpi_pref_nids */
840 __u32 lpni_pref_nnids;
843 /* Preferred path added due to traffic on non-MR peer_ni */
844 #define LNET_PEER_NI_NON_MR_PREF BIT(0)
845 /* peer is being recovered. */
846 #define LNET_PEER_NI_RECOVERY_PENDING BIT(1)
847 /* recovery ping failed */
848 #define LNET_PEER_NI_RECOVERY_FAILED BIT(2)
849 /* peer is being deleted */
850 #define LNET_PEER_NI_DELETING BIT(3)
853 /* chain on pt_peer_list */
854 struct list_head lp_peer_list;
856 /* list of peer nets */
857 struct list_head lp_peer_nets;
859 /* list of messages pending discovery*/
860 struct list_head lp_dc_pendq;
862 /* chain on router list */
863 struct list_head lp_rtr_list;
865 /* primary NID of the peer */
866 struct lnet_nid lp_primary_nid;
868 /* source NID to use during discovery */
869 struct lnet_nid lp_disc_src_nid;
870 /* destination NID to use during discovery */
871 struct lnet_nid lp_disc_dst_nid;
873 /* net to perform discovery on */
874 __u32 lp_disc_net_id;
876 /* CPT of peer_table */
879 /* number of NIDs on this peer */
882 /* # refs from lnet_route::lr_gateway */
886 * peer specific health sensitivity value to decrement peer nis in
887 * this peer with if set to something other than 0
889 __u32 lp_health_sensitivity;
891 /* messages blocking for router credits */
892 struct list_head lp_rtrq;
894 /* routes on this peer */
895 struct list_head lp_routes;
897 /* reference count */
898 atomic_t lp_refcount;
900 /* lock protecting peer state flags and lpni_rtrq */
903 /* peer state flags */
906 /* buffer for data pushed by peer */
907 struct lnet_ping_buffer *lp_data;
909 /* MD handle for ping in progress */
910 struct lnet_handle_md lp_ping_mdh;
912 /* MD handle for push in progress */
913 struct lnet_handle_md lp_push_mdh;
915 /* number of bytes for sizing pb_info in push data */
918 /* NI config sequence number of peer */
921 /* Local NI config sequence number acked by peer */
924 /* Local NI config sequence number sent to peer */
925 __u32 lp_node_seqno_sent;
927 /* Ping error encountered during discovery. */
930 /* Push error encountered during discovery. */
933 /* Error encountered during discovery. */
936 /* time it was put on the ln_dc_working queue */
937 time64_t lp_last_queued;
939 /* link on discovery-related lists */
940 struct list_head lp_dc_list;
942 /* tasks waiting on discovery of this peer */
943 wait_queue_head_t lp_dc_waitq;
945 /* cached peer aliveness */
948 /* sequence number used to round robin traffic to this peer's
955 * The status flags in lp_state. Their semantics have chosen so that
956 * lp_state can be zero-initialized.
958 * A peer is marked MULTI_RAIL in two cases: it was configured using DLC
959 * as multi-rail aware, or the LNET_PING_FEAT_MULTI_RAIL bit was set.
961 * A peer is marked NO_DISCOVERY if the LNET_PING_FEAT_DISCOVERY bit was
962 * NOT set when the peer was pinged by discovery.
964 * A peer is marked ROUTER if it indicates so in the feature bit.
966 #define LNET_PEER_MULTI_RAIL BIT(0) /* Multi-rail aware */
967 #define LNET_PEER_NO_DISCOVERY BIT(1) /* Peer disabled discovery */
968 #define LNET_PEER_ROUTER_ENABLED BIT(2) /* router feature enabled */
971 * A peer is marked CONFIGURED if it was configured by DLC.
973 * In addition, a peer is marked DISCOVERED if it has fully passed
974 * through Peer Discovery.
976 * When Peer Discovery is disabled, the discovery thread will mark
977 * peers REDISCOVER to indicate that they should be re-examined if
978 * discovery is (re)enabled on the node.
980 * A peer that was created as the result of inbound traffic will not
983 #define LNET_PEER_CONFIGURED BIT(3) /* Configured via DLC */
984 #define LNET_PEER_DISCOVERED BIT(4) /* Peer was discovered */
985 #define LNET_PEER_REDISCOVER BIT(5) /* Discovery was disabled */
987 * A peer is marked DISCOVERING when discovery is in progress.
988 * The other flags below correspond to stages of discovery.
990 #define LNET_PEER_DISCOVERING BIT(6) /* Discovering */
991 #define LNET_PEER_DATA_PRESENT BIT(7) /* Remote peer data present */
992 #define LNET_PEER_NIDS_UPTODATE BIT(8) /* Remote peer info uptodate */
993 #define LNET_PEER_PING_SENT BIT(9) /* Waiting for REPLY to Ping */
994 #define LNET_PEER_PUSH_SENT BIT(10) /* Waiting for ACK of Push */
995 #define LNET_PEER_PING_FAILED BIT(11) /* Ping send failure */
996 #define LNET_PEER_PUSH_FAILED BIT(12) /* Push send failure */
998 * A ping can be forced as a way to fix up state, or as a manual
999 * intervention by an admin.
1000 * A push can be forced in circumstances that would normally not
1001 * allow for one to happen.
1003 #define LNET_PEER_FORCE_PING BIT(13) /* Forced Ping */
1004 #define LNET_PEER_FORCE_PUSH BIT(14) /* Forced Push */
1006 /* force delete even if router */
1007 #define LNET_PEER_RTR_NI_FORCE_DEL BIT(15)
1009 /* gw undergoing alive discovery */
1010 #define LNET_PEER_RTR_DISCOVERY BIT(16)
1011 /* gw has undergone discovery (does not indicate success or failure) */
1012 #define LNET_PEER_RTR_DISCOVERED BIT(17)
1014 /* peer is marked for deletion */
1015 #define LNET_PEER_MARK_DELETION BIT(18)
1016 /* lnet_peer_del()/lnet_peer_del_locked() has been called on the peer */
1017 #define LNET_PEER_MARK_DELETED BIT(19)
1018 /* lock primary NID to what's requested by ULP */
1019 #define LNET_PEER_LOCK_PRIMARY BIT(20)
1020 /* this is for informational purposes only. It is set if a peer gets
1021 * configured from Lustre with a primary NID which belongs to another peer
1022 * which is also configured by Lustre as the primary NID.
1024 #define LNET_PEER_BAD_CONFIG BIT(21)
1026 struct lnet_peer_net {
1027 /* chain on lp_peer_nets */
1028 struct list_head lpn_peer_nets;
1030 /* list of peer_nis on this network */
1031 struct list_head lpn_peer_nis;
1033 /* pointer to the peer I'm part of */
1034 struct lnet_peer *lpn_peer;
1039 /* peer net health */
1042 /* time of next router ping on this net */
1043 time64_t lpn_next_ping;
1045 /* selection sequence number */
1048 /* relative peer net selection priority */
1049 __u32 lpn_sel_priority;
1051 /* reference count */
1052 atomic_t lpn_refcount;
1055 /* peer hash size */
1056 #define LNET_PEER_HASH_BITS 9
1057 #define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS)
1060 * peer hash table - one per CPT
1062 * protected by lnet_net_lock/EX for update
1067 * protected by pt_zombie_lock:
1071 * pt_zombie lock nests inside lnet_net_lock
1073 struct lnet_peer_table {
1074 int pt_version; /* /proc validity stamp */
1075 struct list_head *pt_hash; /* NID->peer hash */
1076 struct list_head pt_peer_list; /* peers */
1077 int pt_peers; /* # peers */
1078 struct list_head pt_zombie_list; /* zombie peer_ni */
1079 int pt_zombies; /* # zombie peers_ni */
1080 spinlock_t pt_zombie_lock; /* protect list and count */
1083 /* peer aliveness is enabled only on routers for peers in a network where the
1084 * struct lnet_ni::ni_peertimeout has been set to a positive value
1086 #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing != 0 && \
1087 ((lp)->lpni_net) && \
1088 (lp)->lpni_net->net_tunables.lct_peer_timeout > 0)
1091 struct list_head lr_list; /* chain on net */
1092 struct list_head lr_gwlist; /* chain on gateway */
1093 struct lnet_peer *lr_gateway; /* router node */
1094 struct lnet_nid lr_nid; /* NID used to add route */
1095 __u32 lr_net; /* remote network number */
1096 __u32 lr_lnet; /* local network number */
1097 int lr_seq; /* sequence for round-robin */
1098 __u32 lr_hops; /* how far I am */
1099 unsigned int lr_priority; /* route priority */
1100 atomic_t lr_alive; /* cached route aliveness */
1101 bool lr_single_hop; /* this route is single-hop */
1104 #define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)
1105 #define LNET_REMOTE_NETS_HASH_MAX (1U << 16)
1106 #define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits)
1108 struct lnet_remotenet {
1109 /* chain on ln_remote_nets_hash */
1110 struct list_head lrn_list;
1112 struct list_head lrn_routes;
1117 /** lnet message has credit and can be submitted to lnd for send/receive */
1118 #define LNET_CREDIT_OK 0
1119 /** lnet message is waiting for credit */
1120 #define LNET_CREDIT_WAIT 1
1121 /** lnet message is waiting for discovery */
1122 #define LNET_DC_WAIT 2
1124 struct lnet_rtrbufpool {
1125 /* my free buffer pool */
1126 struct list_head rbp_bufs;
1127 /* messages blocking for a buffer */
1128 struct list_head rbp_msgs;
1129 /* # pages in each buffer */
1131 /* requested number of buffers */
1132 int rbp_req_nbuffers;
1133 /* # buffers actually allocated */
1135 /* # free buffers / blocked messages */
1137 /* low water mark */
1141 struct lnet_rtrbuf {
1142 struct list_head rb_list; /* chain on rbp_bufs */
1143 struct lnet_rtrbufpool *rb_pool; /* owning pool */
1144 struct bio_vec rb_kiov[0]; /* the buffer space */
1147 #define LNET_PEER_HASHSIZE 503 /* prime! */
1149 enum lnet_match_flags {
1150 /* Didn't match anything */
1151 LNET_MATCHMD_NONE = BIT(0),
1153 LNET_MATCHMD_OK = BIT(1),
1154 /* Must be discarded */
1155 LNET_MATCHMD_DROP = BIT(2),
1156 /* match and buffer is exhausted */
1157 LNET_MATCHMD_EXHAUSTED = BIT(3),
1159 LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
1162 /* Options for struct lnet_portal::ptl_options */
1163 #define LNET_PTL_LAZY BIT(0)
1164 #define LNET_PTL_MATCH_UNIQUE BIT(1) /* unique match, for RDMA */
1165 #define LNET_PTL_MATCH_WILDCARD BIT(2) /* wildcard match, request portal */
1167 /* parameter for matching operations (GET, PUT) */
1168 struct lnet_match_info {
1170 struct lnet_processid mi_id;
1171 unsigned int mi_cpt;
1172 unsigned int mi_opc;
1173 unsigned int mi_portal;
1174 unsigned int mi_rlength;
1175 unsigned int mi_roffset;
1178 /* ME hash of RDMA portal */
1179 #define LNET_MT_HASH_BITS 8
1180 #define LNET_MT_HASH_SIZE (1 << LNET_MT_HASH_BITS)
1181 #define LNET_MT_HASH_MASK (LNET_MT_HASH_SIZE - 1)
1182 /* we allocate (LNET_MT_HASH_SIZE + 1) entries for lnet_match_table::mt_hash,
1183 * the last entry is reserved for MEs with ignore-bits */
1184 #define LNET_MT_HASH_IGNORE LNET_MT_HASH_SIZE
1185 /* __u64 has 2^6 bits, so need 2^(LNET_MT_HASH_BITS - LNET_MT_BITS_U64) which
1186 * is 4 __u64s as bit-map, and add an extra __u64 (only use one bit) for the
1187 * ME-list with ignore-bits, which is mtable::mt_hash[LNET_MT_HASH_IGNORE] */
1188 #define LNET_MT_BITS_U64 6 /* 2^6 bits */
1189 #define LNET_MT_EXHAUSTED_BITS (LNET_MT_HASH_BITS - LNET_MT_BITS_U64)
1190 #define LNET_MT_EXHAUSTED_BMAP ((1 << LNET_MT_EXHAUSTED_BITS) + 1)
1192 /* portal match table */
1193 struct lnet_match_table {
1194 /* reserved for upcoming patches, CPU partition ID */
1195 unsigned int mt_cpt;
1196 unsigned int mt_portal; /* portal index */
1197 /* match table is set as "enabled" if there's non-exhausted MD
1198 * attached on mt_mhash, it's only valid for wildcard portal */
1199 unsigned int mt_enabled;
1200 /* bitmap to flag whether MEs on mt_hash are exhausted or not */
1201 __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
1202 struct list_head *mt_mhash; /* matching hash */
1205 /* these are only useful for wildcard portal */
1206 /* Turn off message rotor for wildcard portals */
1207 #define LNET_PTL_ROTOR_OFF 0
1208 /* round-robin dispatch all PUT messages for wildcard portals */
1209 #define LNET_PTL_ROTOR_ON 1
1210 /* round-robin dispatch routed PUT message for wildcard portals */
1211 #define LNET_PTL_ROTOR_RR_RT 2
1212 /* dispatch routed PUT message by hashing source NID for wildcard portals */
1213 #define LNET_PTL_ROTOR_HASH_RT 3
1215 struct lnet_portal {
1216 spinlock_t ptl_lock;
1217 unsigned int ptl_index; /* portal ID, reserved */
1218 /* flags on this portal: lazy, unique... */
1219 unsigned int ptl_options;
1220 /* list of messages which are stealing buffer */
1221 struct list_head ptl_msg_stealing;
1222 /* messages blocking for MD */
1223 struct list_head ptl_msg_delayed;
1224 /* Match table for each CPT */
1225 struct lnet_match_table **ptl_mtables;
1226 /* spread rotor of incoming "PUT" */
1227 unsigned int ptl_rotor;
1228 /* # active entries for this portal */
1230 /* array of active entries' cpu-partition-id */
1234 #define LNET_LH_HASH_BITS 12
1235 #define LNET_LH_HASH_SIZE (1ULL << LNET_LH_HASH_BITS)
1236 #define LNET_LH_HASH_MASK (LNET_LH_HASH_SIZE - 1)
1238 /* resource container (ME, MD, EQ) */
1239 struct lnet_res_container {
1240 unsigned int rec_type; /* container type */
1241 __u64 rec_lh_cookie; /* cookie generator */
1242 struct list_head rec_active; /* active resource list */
1243 struct list_head *rec_lh_hash; /* handle hash */
1246 /* message container */
1247 struct lnet_msg_container {
1248 int msc_init; /* initialized or not */
1249 /* max # threads finalizing */
1250 int msc_nfinalizers;
1251 /* msgs waiting to complete finalizing */
1252 struct list_head msc_finalizing;
1253 /* msgs waiting to be resent */
1254 struct list_head msc_resending;
1255 struct list_head msc_active; /* active message list */
1256 /* threads doing finalization */
1257 void **msc_finalizers;
1258 /* threads doing resends */
1259 void **msc_resenders;
1262 /* This UDSP structures need to match the user space liblnetconfig structures
1263 * in order for the marshall and unmarshall functions to be common.
1266 /* Net is described as a
1270 struct lnet_ud_net_descr {
1272 struct list_head udn_net_num_range;
1275 /* each NID range is defined as
1277 * 2. address range descriptor
1279 struct lnet_ud_nid_descr {
1280 struct lnet_ud_net_descr ud_net_id;
1281 struct list_head ud_addr_range;
1285 /* a UDSP rule can have up to three user defined NID descriptors
1286 * - src: defines the local NID range for the rule
1287 * - dst: defines the peer NID range for the rule
1288 * - rte: defines the router NID range for the rule
1290 * An action union defines the action to take when the rule
1294 struct list_head udsp_on_list;
1296 struct lnet_ud_nid_descr udsp_src;
1297 struct lnet_ud_nid_descr udsp_dst;
1298 struct lnet_ud_nid_descr udsp_rte;
1299 enum lnet_udsp_action_type udsp_action_type;
1301 __u32 udsp_priority;
1305 /* Peer Discovery states */
1306 #define LNET_DC_STATE_SHUTDOWN 0 /* not started */
1307 #define LNET_DC_STATE_RUNNING 1 /* started up OK */
1308 #define LNET_DC_STATE_STOPPING 2 /* telling thread to stop */
1310 /* Router Checker states */
1311 #define LNET_MT_STATE_SHUTDOWN 0 /* not started */
1312 #define LNET_MT_STATE_RUNNING 1 /* started up OK */
1313 #define LNET_MT_STATE_STOPPING 2 /* telling thread to stop */
1316 #define LNET_STATE_SHUTDOWN 0 /* not started */
1317 #define LNET_STATE_RUNNING 1 /* started up OK */
1318 #define LNET_STATE_STOPPING 2 /* telling thread to stop */
1321 /* CPU partition table of LNet */
1322 struct cfs_cpt_table *ln_cpt_table;
1323 /* number of CPTs in ln_cpt_table */
1324 unsigned int ln_cpt_number;
1325 unsigned int ln_cpt_bits;
1327 /* protect LNet resources (ME/MD/EQ) */
1328 struct cfs_percpt_lock *ln_res_lock;
1331 /* the vector of portals */
1332 struct lnet_portal **ln_portals;
1333 /* percpt MD container */
1334 struct lnet_res_container **ln_md_containers;
1336 /* Event Queue container */
1337 struct lnet_res_container ln_eq_container;
1338 spinlock_t ln_eq_wait_lock;
1340 unsigned int ln_remote_nets_hbits;
1342 /* protect NI, peer table, credits, routers, rtrbuf... */
1343 struct cfs_percpt_lock *ln_net_lock;
1344 /* percpt message containers for active/finalizing/freed message */
1345 struct lnet_msg_container **ln_msg_containers;
1346 struct lnet_counters **ln_counters;
1347 struct lnet_peer_table **ln_peer_tables;
1348 /* list of peer nis not on a local network */
1349 struct list_head ln_remote_peer_ni_list;
1350 /* failure simulation */
1351 struct list_head ln_test_peers;
1352 struct list_head ln_drop_rules;
1353 struct list_head ln_delay_rules;
1355 struct list_head ln_nets;
1356 /* Sequence number used to round robin sends across all nets */
1358 /* the loopback NI */
1359 struct lnet_ni *ln_loni;
1360 /* network zombie list */
1361 struct list_head ln_net_zombie;
1362 /* resend messages list */
1363 struct list_head ln_msg_resend;
1364 /* spin lock to protect the msg resend list */
1365 spinlock_t ln_msg_resend_lock;
1367 /* remote networks with routes to them */
1368 struct list_head *ln_remote_nets_hash;
1369 /* validity stamp */
1370 __u64 ln_remote_nets_version;
1371 /* list of all known routers */
1372 struct list_head ln_routers;
1373 /* validity stamp */
1374 __u64 ln_routers_version;
1375 /* percpt router buffer pools */
1376 struct lnet_rtrbufpool **ln_rtrpools;
1379 * Ping target / Push source
1381 * The ping target and push source share a single buffer. The
1382 * ln_ping_target is protected against concurrent updates by
1385 struct lnet_handle_md ln_ping_target_md;
1386 lnet_handler_t ln_ping_target_handler;
1387 struct lnet_ping_buffer *ln_ping_target;
1388 atomic_t ln_ping_target_seqno;
1393 * ln_push_nnis contains the desired size of the push target.
1394 * The lnet_net_lock is used to handle update races. The old
1395 * buffer may linger a while after it has been unlinked, in
1396 * which case the event handler cleans up.
1398 lnet_handler_t ln_push_target_handler;
1399 struct lnet_handle_md ln_push_target_md;
1400 struct lnet_ping_buffer *ln_push_target;
1401 /* bytes needed for pb_info to receive push */
1402 int ln_push_target_nbytes;
1404 /* discovery event queue handle */
1405 lnet_handler_t ln_dc_handler;
1406 /* discovery requests */
1407 struct list_head ln_dc_request;
1408 /* discovery working list */
1409 struct list_head ln_dc_working;
1410 /* discovery expired list */
1411 struct list_head ln_dc_expired;
1412 /* discovery thread wait queue */
1413 wait_queue_head_t ln_dc_waitq;
1414 /* discovery startup/shutdown state */
1417 /* monitor thread startup/shutdown state */
1419 /* serialise startup/shutdown */
1420 struct semaphore ln_mt_signal;
1422 struct mutex ln_api_mutex;
1423 struct mutex ln_lnd_mutex;
1424 /* Have I called LNetNIInit myself? */
1426 /* LNetNIInit/LNetNIFini counter */
1428 /* SHUTDOWN/RUNNING/STOPPING */
1431 int ln_routing; /* am I a router? */
1432 lnet_pid_t ln_pid; /* requested pid */
1433 /* uniquely identifies this ni in this epoch */
1434 __u64 ln_interface_cookie;
1435 /* registered LNDs */
1436 const struct lnet_lnd *ln_lnds[NUM_LNDS];
1438 /* test protocol compatibility flags */
1439 unsigned long ln_testprotocompat;
1441 /* 0 - load the NIs from the mod params
1442 * 1 - do not load the NIs from the mod params
1443 * Reverse logic to ensure that other calls to LNetNIInit
1446 bool ln_nis_from_mod_params;
1449 * completion for the monitor thread. The monitor thread takes care of
1450 * checking routes, timedout messages and resending messages.
1452 struct completion ln_mt_wait_complete;
1454 /* per-cpt resend queues */
1455 struct list_head **ln_mt_resendqs;
1456 /* local NIs to recover */
1457 struct list_head ln_mt_localNIRecovq;
1458 /* local NIs to recover */
1459 struct list_head ln_mt_peerNIRecovq;
1461 * An array of queues for GET/PUT waiting for REPLY/ACK respectively.
1462 * There are CPT number of queues. Since response trackers will be
1463 * added on the fast path we can't afford to grab the exclusive
1464 * net lock to protect these queues. The CPT will be calculated
1465 * based on the mdh cookie.
1467 struct list_head **ln_mt_rstq;
1469 * A response tracker becomes a zombie when the associated MD is queued
1470 * for unlink before the response tracker is detached from the MD. An
1471 * entry on a zombie list can be freed when either the remaining
1472 * operations on the MD complete or when LNet has shut down.
1474 struct list_head **ln_mt_zombie_rstqs;
1475 /* recovery handler */
1476 lnet_handler_t ln_mt_handler;
1479 * Completed when the discovery and monitor threads can enter their
1482 struct completion ln_started;
1484 struct list_head ln_udsp_list;
1487 struct genl_filter_list {
1488 struct list_head lp_list;
1493 static const struct nla_policy scalar_attr_policy[LN_SCALAR_MAX + 1] = {
1494 [LN_SCALAR_ATTR_LIST] = { .type = NLA_NESTED },
1495 [LN_SCALAR_ATTR_LIST_SIZE] = { .type = NLA_U16 },
1496 [LN_SCALAR_ATTR_INDEX] = { .type = NLA_U16 },
1497 [LN_SCALAR_ATTR_NLA_TYPE] = { .type = NLA_U16 },
1498 [LN_SCALAR_ATTR_VALUE] = { .type = NLA_STRING },
1499 [LN_SCALAR_ATTR_KEY_FORMAT] = { .type = NLA_U16 },
1502 int lnet_genl_send_scalar_list(struct sk_buff *msg, u32 portid, u32 seq,
1503 const struct genl_family *family, int flags,
1504 u8 cmd, const struct ln_key_list *data[]);
1506 /* Special workaround for pre-4.19 kernels to send error messages
1507 * from dumpit routines. Newer kernels will send message with
1508 * NL_SET_ERR_MSG information by default if NETLINK_EXT_ACK is set.
1510 static inline int lnet_nl_send_error(struct sk_buff *msg, int portid, int seq,
1513 #ifndef HAVE_NL_DUMP_WITH_EXT_ACK
1514 struct nlmsghdr *nlh;
1519 nlh = nlmsg_put(msg, portid, seq, NLMSG_ERROR, sizeof(error), 0);
1522 #ifdef HAVE_NL_PARSE_WITH_EXT_ACK
1523 netlink_ack(msg, nlh, error, NULL);
1525 netlink_ack(msg, nlh, error);
1527 return nlmsg_len(nlh);