1 // SPDX-License-Identifier: GPL-2.0
3 /* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
4 * Use is subject to license terms.
6 * Copyright (c) 2012, 2017, Intel Corporation.
9 /* This file is part of Lustre, http://www.lustre.org/
11 * Types used by the library side routines that do not need to be
12 * exposed to the user application
15 #ifndef __LNET_LIB_TYPES_H__
16 #define __LNET_LIB_TYPES_H__
19 # error This include is only for kernel use.
22 #include <linux/kthread.h>
23 #include <linux/uio.h>
24 #include <linux/semaphore.h>
25 #include <linux/types.h>
26 #include <linux/kref.h>
27 #include <net/genetlink.h>
29 #include <uapi/linux/lnet/lnet-nl.h>
30 #include <uapi/linux/lnet/lnet-dlc.h>
31 #include <uapi/linux/lnet/lnetctl.h>
32 #include <uapi/linux/lnet/nidstr.h>
34 int libcfs_strid(struct lnet_processid *id, const char *str);
36 int cfs_match_nid_net(struct lnet_nid *nid, u32 net,
37 struct list_head *net_num_list,
38 struct list_head *addr);
40 /* Max payload size */
41 #define LNET_MAX_PAYLOAD LNET_MTU
43 /** limit on the number of fragments in discontiguous MDs */
44 #define LNET_MAX_IOV 256
47 * This is the maximum health value.
48 * All local and peer NIs created have their health default to this value.
50 #define LNET_MAX_HEALTH_VALUE 1000
51 #define LNET_MAX_SELECTION_PRIORITY UINT_MAX
56 enum lnet_msg_hstatus {
57 LNET_MSG_STATUS_OK = 0,
58 LNET_MSG_STATUS_LOCAL_INTERRUPT,
59 LNET_MSG_STATUS_LOCAL_DROPPED,
60 LNET_MSG_STATUS_LOCAL_ABORTED,
61 LNET_MSG_STATUS_LOCAL_NO_ROUTE,
62 LNET_MSG_STATUS_LOCAL_ERROR,
63 LNET_MSG_STATUS_LOCAL_TIMEOUT,
64 LNET_MSG_STATUS_REMOTE_ERROR,
65 LNET_MSG_STATUS_REMOTE_DROPPED,
66 LNET_MSG_STATUS_REMOTE_TIMEOUT,
67 LNET_MSG_STATUS_NETWORK_TIMEOUT,
71 struct lnet_rsp_tracker {
72 /* chain on the waiting list */
73 struct list_head rspt_on_list;
77 struct lnet_nid rspt_next_hop_nid;
78 /* deadline of the REPLY/ACK */
79 ktime_t rspt_deadline;
81 struct lnet_handle_md rspt_mdh;
85 struct list_head msg_activelist;
86 struct list_head msg_list; /* Q for credits/MD */
88 struct lnet_processid msg_target;
89 /* Primary NID of the source. */
90 struct lnet_nid msg_initiator;
91 /* where is it from, it's only for building event */
92 struct lnet_nid msg_from;
96 * hold parameters in case message is with held due
99 struct lnet_nid msg_src_nid_param;
100 struct lnet_nid msg_rtr_nid_param;
103 * Deadline for the message after which it will be finalized if it
106 ktime_t msg_deadline;
108 /* The message health status. */
109 enum lnet_msg_hstatus msg_health_status;
110 /* This is a recovery message */
112 /* the number of times a transmission has been retried */
114 /* flag to indicate that we do not want to resend this message */
117 /* committed for sending */
118 unsigned int msg_tx_committed:1;
119 /* CPT # this message committed for sending */
120 unsigned int msg_tx_cpt:15;
121 /* committed for receiving */
122 unsigned int msg_rx_committed:1;
123 /* CPT # this message committed for receiving */
124 unsigned int msg_rx_cpt:15;
125 /* queued for tx credit */
126 unsigned int msg_tx_delayed:1;
127 /* queued for RX buffer */
128 unsigned int msg_rx_delayed:1;
129 /* ready for pending on RX delay list */
130 unsigned int msg_rx_ready_delay:1;
132 unsigned int msg_vmflush:1; /* VM trying to free memory */
133 unsigned int msg_target_is_router:1; /* sending to a router */
134 unsigned int msg_routing:1; /* being forwarded */
135 unsigned int msg_ack:1; /* ack on finalize (PUT) */
136 unsigned int msg_sending:1; /* outgoing message */
137 unsigned int msg_receiving:1; /* being received */
138 unsigned int msg_txcredit:1; /* taken an NI send credit */
139 unsigned int msg_peertxcredit:1; /* taken a peer send credit */
140 unsigned int msg_rtrcredit:1; /* taken a globel router credit */
141 unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */
142 unsigned int msg_onactivelist:1; /* on the activelist */
143 unsigned int msg_rdma_get:1;
145 struct lnet_peer_ni *msg_txpeer; /* peer I'm sending to */
146 struct lnet_peer_ni *msg_rxpeer; /* peer I received from */
149 struct lnet_libmd *msg_md;
150 /* the NI the message was sent or received over */
151 struct lnet_ni *msg_txni;
152 struct lnet_ni *msg_rxni;
154 unsigned int msg_len;
155 unsigned int msg_wanted;
156 unsigned int msg_offset;
157 unsigned int msg_niov;
158 struct bio_vec *msg_kiov;
160 struct lnet_event msg_ev;
161 struct lnet_hdr msg_hdr;
164 struct lnet_libhandle {
165 struct list_head lh_hash_chain;
169 #define lh_entry(ptr, type, member) \
170 ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
173 struct list_head me_list;
175 struct lnet_processid me_match_id;
176 unsigned int me_portal;
177 unsigned int me_pos; /* hash offset in mt_hash */
179 __u64 me_ignore_bits;
180 enum lnet_unlink me_unlink;
181 struct lnet_libmd *me_md;
185 struct list_head md_list;
186 struct lnet_libhandle md_lh;
187 struct lnet_me *md_me;
189 unsigned int md_offset;
190 unsigned int md_length;
191 unsigned int md_max_size;
194 unsigned int md_options;
195 unsigned int md_flags;
196 unsigned int md_niov; /* # frags at end of struct */
198 struct lnet_rsp_tracker *md_rspt_ptr;
199 lnet_handler_t md_handler;
200 struct lnet_handle_md md_bulk_handle;
201 struct bio_vec md_kiov[LNET_MAX_IOV];
204 #define LNET_MD_FLAG_ZOMBIE BIT(0)
205 #define LNET_MD_FLAG_AUTO_UNLINK BIT(1)
206 #define LNET_MD_FLAG_ABORTED BIT(2)
207 /* LNET_MD_FLAG_HANDLING is set when a non-unlink event handler
208 * is being called for an event relating to the md.
209 * It ensures only one such handler runs at a time.
210 * The final "unlink" event is only called once the
211 * md_refcount has reached zero, and this flag has been cleared,
212 * ensuring that it doesn't race with any other event handler
215 #define LNET_MD_FLAG_HANDLING BIT(3)
216 #define LNET_MD_FLAG_DISCARD BIT(4)
217 #define LNET_MD_FLAG_GPU BIT(5) /**< Special mapping needs */
219 static inline bool lnet_md_is_gpu(struct lnet_libmd *md)
221 return (md != NULL) && !!(md->md_flags & LNET_MD_FLAG_GPU);
224 struct lnet_test_peer {
225 /* info about peers we are trying to fail */
226 struct list_head tp_list; /* ln_test_peers */
227 struct lnet_nid tp_nid; /* matching nid */
228 unsigned int tp_threshold; /* # failures to simulate */
231 #define LNET_COOKIE_TYPE_MD 1
232 #define LNET_COOKIE_TYPE_ME 2
233 #define LNET_COOKIE_TYPE_EQ 3
234 #define LNET_COOKIE_TYPE_BITS 2
235 #define LNET_COOKIE_MASK ((1ULL << LNET_COOKIE_TYPE_BITS) - 1ULL)
241 void (*nf_addr2str)(u32 addr, char *str, size_t size);
242 void (*nf_addr2str_size)(const __be32 *addr, size_t asize,
243 char *str, size_t size);
244 int (*nf_str2addr)(const char *str, int nob, u32 *addr);
245 int (*nf_str2addr_size)(const char *str, int nob,
246 __be32 *addr, size_t *asize);
247 int (*nf_parse_addrlist)(char *str, int len,
248 struct list_head *list);
249 int (*nf_print_addrlist)(char *buffer, int count,
250 struct list_head *list);
251 int (*nf_match_addr)(u32 addr, struct list_head *list);
252 int (*nf_min_max)(struct list_head *nidlist, u32 *min_nid,
256 struct lnet_ni; /* forward ref */
260 /* fields initialized by the LND */
263 int (*lnd_startup)(struct lnet_ni *ni);
264 void (*lnd_shutdown)(struct lnet_ni *ni);
265 int (*lnd_ctl)(struct lnet_ni *ni, unsigned int cmd, void *arg);
267 /* In data movement APIs below, payload buffers are described as a set
268 * of 'niov' fragments which are in pages.
269 * The LND may NOT overwrite these fragment descriptors.
270 * An 'offset' and may specify a byte offset within the set of
271 * fragments to start from
274 /* Start sending a preformatted message. 'private' is NULL for PUT and
275 * GET messages; otherwise this is a response to an incoming message
276 * and 'private' is the 'private' passed to lnet_parse(). Return
277 * non-zero for immediate failure, otherwise complete later with
279 int (*lnd_send)(struct lnet_ni *ni, void *private,
280 struct lnet_msg *msg);
282 /* Start receiving 'mlen' bytes of payload data, skipping the following
283 * 'rlen' - 'mlen' bytes. 'private' is the 'private' passed to
284 * lnet_parse(). Return non-zero for immedaite failure, otherwise
285 * complete later with lnet_finalize(). This also gives back a receive
286 * credit if the LND does flow control. */
287 int (*lnd_recv)(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
288 int delayed, unsigned int niov,
289 struct bio_vec *kiov,
290 unsigned int offset, unsigned int mlen, unsigned int rlen);
292 /* lnet_parse() has had to delay processing of this message
293 * (e.g. waiting for a forwarding buffer or send credits). Give the
294 * LND a chance to free urgently needed resources. If called, return 0
295 * for success and do NOT give back a receive credit; that has to wait
296 * until lnd_recv() gets called. On failure return < 0 and
297 * release resources; lnd_recv() will not be called. */
298 int (*lnd_eager_recv)(struct lnet_ni *ni, void *private,
299 struct lnet_msg *msg, void **new_privatep);
301 /* notification of peer down */
302 void (*lnd_notify_peer_down)(struct lnet_nid *peer);
304 /* accept a new connection */
305 int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock);
307 /* get dma_dev priority */
308 unsigned int (*lnd_get_dev_prio)(struct lnet_ni *ni,
309 unsigned int dev_idx);
311 /* Handle LND specific Netlink handling */
312 int (*lnd_nl_get)(int cmd, struct sk_buff *msg, int type, void *data);
313 int (*lnd_nl_set)(int cmd, struct nlattr *attr, int type, void *data);
315 const struct ln_key_list *lnd_keys;
318 struct lnet_tx_queue {
319 int tq_credits; /* # tx credits free */
320 int tq_credits_min; /* lowest it's been */
321 int tq_credits_max; /* total # tx credits */
322 struct list_head tq_delayed; /* delayed TXs */
325 enum lnet_net_state {
326 /* set when net block is allocated */
327 LNET_NET_STATE_INIT = 0,
328 /* set when NIs in net are started successfully */
329 LNET_NET_STATE_ACTIVE,
330 /* set if all NIs in net are in FAILED state */
331 LNET_NET_STATE_INACTIVE,
332 /* set when shutting down a NET */
333 LNET_NET_STATE_DELETING
337 /* initial state when NI is created */
338 LNET_NI_STATE_INIT = 0,
339 /* set when NI is brought up */
340 LNET_NI_STATE_ACTIVE,
341 /* set when NI is being shutdown */
342 LNET_NI_STATE_DELETING,
345 #define LNET_NI_RECOVERY_PENDING BIT(0)
346 #define LNET_NI_RECOVERY_FAILED BIT(1)
348 enum lnet_stats_type {
349 LNET_STATS_TYPE_SEND = 0,
350 LNET_STATS_TYPE_RECV,
354 struct lnet_comm_count {
355 atomic_t co_get_count;
356 atomic_t co_put_count;
357 atomic_t co_reply_count;
358 atomic_t co_ack_count;
359 atomic_t co_hello_count;
362 struct lnet_element_stats {
363 struct lnet_comm_count el_send_stats;
364 struct lnet_comm_count el_recv_stats;
365 struct lnet_comm_count el_drop_stats;
368 struct lnet_health_local_stats {
369 atomic_t hlt_local_interrupt;
370 atomic_t hlt_local_dropped;
371 atomic_t hlt_local_aborted;
372 atomic_t hlt_local_no_route;
373 atomic_t hlt_local_timeout;
374 atomic_t hlt_local_error;
377 struct lnet_health_remote_stats {
378 atomic_t hlt_remote_dropped;
379 atomic_t hlt_remote_timeout;
380 atomic_t hlt_remote_error;
381 atomic_t hlt_network_timeout;
385 /* chain on the ln_nets */
386 struct list_head net_list;
388 /* net ID, which is composed of
389 * (net_type << 16) | net_num.
390 * net_type can be one of the enumerated types defined in
391 * lnet/include/lnet/nidstr.h */
394 /* round robin selection */
397 /* total number of CPTs in the array */
400 /* cumulative CPTs of all NIs in this net */
403 /* relative net selection priority */
404 __u32 net_sel_priority;
406 /* network tunables */
407 struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
410 * boolean to indicate that the tunables have been set and
413 bool net_tunables_set;
415 /* procedural interface */
416 const struct lnet_lnd *net_lnd;
418 /* list of NIs on this net */
419 struct list_head net_ni_list;
421 /* list of NIs being added, but not started yet */
422 struct list_head net_ni_added;
424 /* dying LND instances */
425 struct list_head net_ni_zombie;
427 /* when I was last alive */
428 time64_t net_last_alive;
430 /* protects access to net_last_alive */
433 /* list of router nids preferred for this network */
434 struct list_head net_rtr_pref_nids;
437 /* Normally Netlink atttributes are defined in UAPI headers but Lustre is
438 * different in that the ABI is in a constant state of change unlike other
439 * Netlink interfaces. LNet sends a special header to help user land handle
443 /** enum lnet_err_atrrs - LNet error netlink properties
444 * For LNet request of multiple items
445 * sometimes those items exist and
446 * others don't. In the case the item
447 * item doesn't exist we return the
450 * @LNET_ERR_ATTR_UNSPEC: unspecified attribute to catch errors
452 * @LNET_ERR_ATTR_HDR: Name of the error header
454 * @LNET_ERR_ATTR_TYPE: Which LNet function since error is for
456 * @LNET_ERR_TYPE_ERRNO: Error code for failure (NLA_S16)
457 * @LNET_ERR_DESCR: Complete error message (NLA_STRING)
459 enum lnet_err_attrs {
460 LNET_ERR_ATTR_UNSPEC = 0,
466 __LNET_ERR_ATTR_MAX_PLUS_ONE,
469 #define LNET_ERR_ATTR_MAX (__LNET_ERR_ATTR_MAX_PLUS_ONE - 1)
471 /** enum lnet_net_attrs - LNet NI netlink properties
472 * attributes that describe LNet 'NI'
473 * These values are used to piece together
474 * messages for sending and receiving.
476 * @LNET_NET_ATTR_UNSPEC: unspecified attribute to catch errors
478 * @LNET_NET_ATTR_HDR: grouping for LNet net data (NLA_NUL_STRING)
479 * @LNET_NET_ATTR_TYPE: LNet net this NI belongs to (NLA_STRING)
480 * @LNET_NET_ATTR_LOCAL: Local NI information (NLA_NESTED)
482 enum lnet_net_attrs {
483 LNET_NET_ATTR_UNSPEC = 0,
489 __LNET_NET_ATTR_MAX_PLUS_ONE,
492 #define LNET_NET_ATTR_MAX (__LNET_NET_ATTR_MAX_PLUS_ONE - 1)
494 /** enum lnet_net_local_ni_attrs - LNet local NI netlink properties
495 * attributes that describe local
498 * @LNET_NET_LOCAL_NI_ATTR_UNSPEC: unspecified attribute to catch
501 * @LNET_NET_LOCAL_NI_ATTR_NID: NID that represents this NI
503 * @LNET_NET_LOCAL_NI_ATTR_STATUS: State of this NI (NLA_STRING)
504 * @LNET_NET_LOCAL_NI_ATTR_INTERFACE: Defines physical devices. used
505 * to be many devices but no longer
508 * @LNET_NET_LOCAL_NI_ATTR_STATS: NI general msg stats (NLA_NESTED)
509 * @LNET_NET_LOCAL_NI_ATTR_UDSP_INFO: NI UDSP state (NLA_NESTED)
510 * @LNET_NET_LOCAL_NI_ATTR_SEND_STATS: NI send stats (NLA_NESTED)
511 * @LNET_NET_LOCAL_NI_ATTR_RECV_STATS: NI recieved stats (NLA_NESTED)
512 * @LNET_NET_LOCAL_NI_ATTR_DROPPED_STATS: NI dropped stats (NLA_NESTED)
513 * @LNET_NET_LOCAL_NI_ATTR_HEALTH_STATS: NI health stats (NLA_NESTED)
514 * @LNET_NET_LOCAL_NI_ATTR_TUNABLES: NI tunables (NLA_NESTED)
515 * @LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES: NI LND tunables (NLA_NESTED)
516 * @LNET_NET_LOCAL_NI_ATTR_DEV_CPT: NI CPT interface bound to
518 * @LNET_NET_LOCAL_NI_ATTR_CPTS: CPT core used by this NI
521 enum lnet_net_local_ni_attrs {
522 LNET_NET_LOCAL_NI_ATTR_UNSPEC = 0,
524 LNET_NET_LOCAL_NI_ATTR_NID,
525 LNET_NET_LOCAL_NI_ATTR_STATUS,
526 LNET_NET_LOCAL_NI_ATTR_INTERFACE,
528 LNET_NET_LOCAL_NI_ATTR_STATS,
529 LNET_NET_LOCAL_NI_ATTR_UDSP_INFO,
530 LNET_NET_LOCAL_NI_ATTR_SEND_STATS,
531 LNET_NET_LOCAL_NI_ATTR_RECV_STATS,
532 LNET_NET_LOCAL_NI_ATTR_DROPPED_STATS,
533 LNET_NET_LOCAL_NI_ATTR_HEALTH_STATS,
534 LNET_NET_LOCAL_NI_ATTR_TUNABLES,
535 LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES,
536 LNET_NET_LOCAL_NI_DEV_CPT,
537 LNET_NET_LOCAL_NI_CPTS,
539 __LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE,
542 #define LNET_NET_LOCAL_NI_ATTR_MAX (__LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE - 1)
544 /** enum lnet_net_local_ni_intf_attrs - LNet NI device netlink properties
545 * attribute that reports the device
548 * @LNET_NET_LOCAL_NI_INTF_ATTR_UNSPEC: unspecified attribute to catch errors
550 * @LNET_NET_LOCAL_NI_INTF_ATTR_TYPE: Physcial device interface (NLA_STRING)
552 enum lnet_net_local_ni_intf_attrs {
553 LNET_NET_LOCAL_NI_INTF_ATTR_UNSPEC = 0,
555 LNET_NET_LOCAL_NI_INTF_ATTR_TYPE,
557 __LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE,
560 #define LNET_NET_LOCAL_NI_INTF_ATTR_MAX (__LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE - 1)
562 /** enum lnet_net_local_ni_stats_attrs - LNet NI netlink properties
563 * attributes that reports the
564 * network traffic stats
566 * @LNET_NET_LOCAL_NI_STATS_ATTR_UNSPEC: unspecified attribute to catch
569 * @LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT: Number of sent messages
571 * @LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT: Number of recieved messages
573 * @LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT: Number of dropped messages
576 enum lnet_net_local_ni_stats_attrs {
577 LNET_NET_LOCAL_NI_STATS_ATTR_UNSPEC = 0,
579 LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT,
580 LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT,
581 LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT,
582 __LNET_NET_LOCAL_NI_STATS_ATTR_MAX_PLUS_ONE,
585 #define LNET_NET_LOCAL_NI_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_STATS_ATTR_MAX_PLUS_ONE - 1)
587 /** enum lnet_net_local_ni_msg_stats_attrs - LNet NI netlink
588 * properties attributes
589 * that reports the message
592 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_UNSPEC: unspecified attribute
595 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT: Number of PUT messages
597 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT: Number of GET messages
599 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT: Number of REPLY messages
601 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT: Number of ACK messages
603 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT: Number of HELLO messages
606 enum lnet_net_local_ni_msg_stats_attrs {
607 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_UNSPEC = 0,
609 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT,
610 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT,
611 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT,
612 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT,
613 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT,
614 __LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX_PLUS_ONE,
617 #define LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX_PLUS_ONE - 1)
619 /** enum lnet_net_local_ni_health_stats_attrs - LNet NI netlink
620 * properties attributes
624 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC: unspecified attribute
627 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS: How many fatal errors
629 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL: How healthly is NI
631 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS: How many interrupts
633 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_DROPPED: How much traffic has
634 * been dropped (NLA_U32)
635 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ABORTED: How many aborts
637 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE: How often routing broke
639 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS: How often timeouts
641 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR: The number of errors
643 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT: Number of successful
645 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING: Number of next pings
648 enum lnet_net_local_ni_health_stats_attrs {
649 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC = 0,
650 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PAD = LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC,
652 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS,
653 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL,
654 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS,
655 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_DROPPED,
656 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ABORTED,
657 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE,
658 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS,
659 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR,
660 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT,
661 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING,
662 __LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX_PLUS_ONE,
664 #define LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX_PLUS_ONE - 1)
666 /** enum lnet_net_local_ni_tunables_attrs - LNet NI tunables
667 * netlink properties.
668 * Performance options
671 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_UNSPEC: unspecified attribute
674 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT: Timeout for LNet peer.
676 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS: Credits for LNet peer.
678 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_BUFFER_CREDITS: Buffer credits for
679 * LNet peer. (NLA_S32)
680 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_CREDITS: Credits for LNet peer
683 enum lnet_net_local_ni_tunables_attr {
684 LNET_NET_LOCAL_NI_TUNABLES_ATTR_UNSPEC = 0,
686 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT,
687 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS,
688 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_BUFFER_CREDITS,
689 LNET_NET_LOCAL_NI_TUNABLES_ATTR_CREDITS,
690 __LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX_PLUS_ONE,
693 #define LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX (__LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX_PLUS_ONE - 1)
695 /** enum lnet_route_attrs - LNet route netlink
696 * attributes that describe
699 * @LNET_ROUTE_ATTR_UNSPEC: unspecified attribute to
702 * @LNET_ROUTE_ATTR_HDR: grouping for LNet route data
704 * @LNET_ROUTE_ATTR_NET: LNet remote network reached
705 * by the route (NLA_STRING)
706 * @LNET_ROUTE_ATTR_GATEWAY: gateway for the route
708 * @LNET_ROUTE_ATTR_HOP: route hop count (NLA_S32)
710 * @LNET_ROUTE_ATTR_PRIORITY: rank of this network path
712 * @LNET_ROUTE_ATTR_HEALTH_SENSITIVITY: rate of health value change
713 * for the route (NLA_U32)
714 * @LNET_ROUTE_ATTR_STATE: state of route (NLA_STRING)
716 * @LNET_ROUTE_ATTR_TYPE: Report if we support multi-hop
719 enum lnet_route_attrs {
720 LNET_ROUTE_ATTR_UNSPEC = 0,
724 LNET_ROUTE_ATTR_GATEWAY,
726 LNET_ROUTE_ATTR_PRIORITY,
727 LNET_ROUTE_ATTR_HEALTH_SENSITIVITY,
728 LNET_ROUTE_ATTR_STATE,
729 LNET_ROUTE_ATTR_TYPE,
730 __LNET_ROUTE_ATTR_MAX_PLUS_ONE,
733 #define LNET_ROUTE_ATTR_MAX (__LNET_ROUTE_ATTR_MAX_PLUS_ONE - 1)
735 /** enum lnet_peer_ni_attrs - LNet peer NI netlink properties
736 * attributes that describe LNet peer 'NI'.
737 * These values are used to piece together
738 * messages for sending and receiving.
740 * @LNET_PEER_NI_ATTR_UNSPEC: unspecified attribute to catch errors
742 * @LNET_PEER_NI_ATTR_HDR: grouping for LNet peer data
744 * @LNET_PEER_NI_ATTR_PRIMARY_NID: primary NID of this peer (NLA_STRING)
745 * @LNET_PEER_NI_ATTR_MULTIRAIL: Do we support MultiRail ? (NLA_FLAG)
746 * @LNET_PEER_NI_ATTR_STATE: Bitfields of the peer state (NLA_U32)
747 * @LNET_PEER_NI_ATTR_PEER_NI_LIST: List of remote peers we can reach
750 enum lnet_peer_ni_attrs {
751 LNET_PEER_NI_ATTR_UNSPEC = 0,
753 LNET_PEER_NI_ATTR_HDR,
754 LNET_PEER_NI_ATTR_PRIMARY_NID,
755 LNET_PEER_NI_ATTR_MULTIRAIL,
756 LNET_PEER_NI_ATTR_STATE,
757 LNET_PEER_NI_ATTR_PEER_NI_LIST,
758 __LNET_PEER_NI_ATTR_MAX_PLUS_ONE,
761 #define LNET_PEER_NI_ATTR_MAX (__LNET_PEER_NI_ATTR_MAX_PLUS_ONE - 1)
763 /** enum lnet_peer_ni_list_attrs - LNet remote peer netlink
764 * properties attributes that
765 * describe remote LNet peer 'NI'.
766 * These values are used to piece
767 * together messages for sending
770 * @LNET_PEER_NI_LIST_ATTR_UNSPEC: unspecified attribute to catch
773 * @LNET_PEER_NI_LIST_ATTR_NID: remote peer's NID (NLA_STRING)
774 * @LNET_PEER_NI_LIST_ATTR_UDSP_INFO: remote peer's UDSP info
776 * @LNET_PEER_NI_LIST_ATTR_STATE: state of remote peer
779 * @LNET_PEER_NI_LIST_ATTR_MAX_TX_CREDITS: Maximum TX credits for remote
781 * @LNET_PEER_NI_LIST_ATTR_CUR_TX_CREDITS: Current TX credits for remote
783 * @LNET_PEER_NI_LIST_ATTR_MIN_TX_CREDITS: Minimum TX credits for remote
785 * @LNET_PEER_NI_LIST_ATTR_QUEUE_BUF_COUNT: Size of TX queue buffer
787 * @LNET_PEER_NI_LIST_ATTR_CUR_RTR_CREDITS: Current router credits for
788 * remote peer (NLA_U32)
789 * @LNET_PEER_NI_LIST_ATTR_MIN_RTR_CREDITS: Minimum router credits for
790 * remote peer (NLA_U32)
791 * @LNET_PEER_NI_LIST_ATTR_REFCOUNT: Remote peer reference count
793 * @LNET_PEER_NI_LIST_ATTR_STATS_COUNT: Remote peer general stats,
794 * reports sent, recieved, and
795 * dropped packets. (NLA_NESTED)
797 * @LNET_PEER_NI_LIST_ATTR_SENT_STATS: Remote peer sent stats,
798 * reports gets, puts, acks, and
799 * hello packets. (NLA_NESTED)
800 * @LNET_PEER_NI_LIST_ATTR_RECV_STATS: Remote peer recieved stats,
801 * reports gets, puts, acks, and
802 * hello packets. (NLA_NESTED)
803 * @LNET_PEER_NI_LIST_ATTR_DROP_STATS: Remote peer dropped stats,
804 * reports gets, puts, acks, and
805 * hello packets. (NLA_NESTED)
806 * @LNET_PEER_NI_LIST_ATTR_HEALTH_STATS: Report the stats about the
807 * health of the remote peer.
810 enum lnet_peer_ni_list_attr {
811 LNET_PEER_NI_LIST_ATTR_UNSPEC = 0,
813 LNET_PEER_NI_LIST_ATTR_NID,
814 LNET_PEER_NI_LIST_ATTR_UDSP_INFO,
815 LNET_PEER_NI_LIST_ATTR_STATE,
817 LNET_PEER_NI_LIST_ATTR_MAX_TX_CREDITS,
818 LNET_PEER_NI_LIST_ATTR_CUR_TX_CREDITS,
819 LNET_PEER_NI_LIST_ATTR_MIN_TX_CREDITS,
820 LNET_PEER_NI_LIST_ATTR_QUEUE_BUF_COUNT,
821 LNET_PEER_NI_LIST_ATTR_CUR_RTR_CREDITS,
822 LNET_PEER_NI_LIST_ATTR_MIN_RTR_CREDITS,
823 LNET_PEER_NI_LIST_ATTR_REFCOUNT,
824 LNET_PEER_NI_LIST_ATTR_STATS_COUNT,
826 LNET_PEER_NI_LIST_ATTR_SENT_STATS,
827 LNET_PEER_NI_LIST_ATTR_RECV_STATS,
828 LNET_PEER_NI_LIST_ATTR_DROP_STATS,
829 LNET_PEER_NI_LIST_ATTR_HEALTH_STATS,
831 __LNET_PEER_NI_LIST_ATTR_MAX_PLUS_ONE,
834 #define LNET_PEER_NI_LIST_ATTR_MAX (__LNET_PEER_NI_LIST_ATTR_MAX_PLUS_ONE - 1)
836 /** enum lnet_peer_ni_list_stats_count - LNet remote peer traffic
837 * stats netlink properties
838 * attributes that provide
839 * traffic stats on the
840 * remote LNet peer 'NI'.
841 * These values are used to
842 * piece together messages
843 * for sending and receiving.
845 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_UNSPEC: unspecified attribute to
848 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_SEND_COUNT: Number of sent packets for
849 * remote peer (NLA_U32)
850 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_RECV_COUNT: Numebr of recieved packets
851 * for remote peer (NLA_U32)
852 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_DROP_COUNT: Number of dropped packets
853 * for remote peer (NLA_U32)
855 enum lnet_peer_ni_list_stats_count {
856 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_UNSPEC = 0,
858 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_SEND_COUNT,
859 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_RECV_COUNT,
860 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_DROP_COUNT,
861 __LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX_PLUS_ONE,
864 #define LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX (__LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX_PLUS_ONE - 1)
866 /** enum lnet_peer_ni_list_stats - LNet remote peer stats netlink
867 * properties attributes that
868 * provide stats on the remote
869 * LNet peer 'NI'. These values are
870 * used to piece together messages
871 * for sending and receiving.
873 * @LNET_PEER_NI_LIST_STATS_ATTR_UNSPEC: unspecified attribute to catch
876 * @LNET_PEER_NI_LIST_STATS_ATTR_PUT: PUT message count for remote
878 * @LNET_PEER_NI_LIST_STATS_ATTR_GET: GET message count for remote
880 * @LNET_PEER_NI_LIST_STATS_ATTR_REPLY: REPLY message count for remote
882 * @LNET_PEER_NI_LIST_STATS_ATTR_ACK: ACK message count for remote
884 * @LNET_PEER_NI_LIST_STATS_ATTR_HEALTH: HELLO message count for remote
887 enum lnet_peer_ni_list_stats {
888 LNET_PEER_NI_LIST_STATS_ATTR_UNSPEC = 0,
890 LNET_PEER_NI_LIST_STATS_ATTR_PUT,
891 LNET_PEER_NI_LIST_STATS_ATTR_GET,
892 LNET_PEER_NI_LIST_STATS_ATTR_REPLY,
893 LNET_PEER_NI_LIST_STATS_ATTR_ACK,
894 LNET_PEER_NI_LIST_STATS_ATTR_HELLO,
895 __LNET_PEER_NI_LIST_STATS_ATTR_MAX_PLUS_ONE,
898 #define LNET_PEER_NI_LIST_STATS_ATTR_MAX (__LNET_PEER_NI_LIST_STATS_ATTR_MAX_PLUS_ONE - 1)
900 /** enum lnet_peer_ni_list_health_stats - LNet remote peer health
901 * stats netlink properties
902 * attributes that provide
903 * stats on the health of a
904 * remote LNet peer 'NI'.
905 * These values are used to
906 * piece together messages
907 * for sending and receiving.
909 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_UNSPEC: unspecified attribute to
912 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_VALUE: Health level of remote
914 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_DROP: drop message state for
915 * remote peer (NLA_U32)
916 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_TIMEOUT: timeout set for remote
918 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_ERROR: total errors for remote
920 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NETWORK_TIMEOUT: network timeout for
921 * remote peer (NLA_U32)
922 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_PING_COUNT: number of pings for
923 * remote peer (NLA_U32)
924 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NEXT_PING: timestamp for next ping
925 * sent by remote peer
928 enum lnet_peer_ni_list_health_stats {
929 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_UNSPEC = 0,
930 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_PAD = LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_UNSPEC,
932 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_VALUE,
933 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_DROPPED,
934 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_TIMEOUT,
935 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_ERROR,
936 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NETWORK_TIMEOUT,
937 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_PING_COUNT,
938 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NEXT_PING,
940 __LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX_PLUS_ONE,
943 #define LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX (__LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX_PLUS_ONE - 1)
945 /** LNet netlink ping API */
947 /** enum lnet_ping_attr - LNet ping netlink properties
948 * attributes to describe ping format
949 * These values are used to piece together
950 * messages for sending and receiving.
952 * @LNET_PING_ATTR_UNSPEC: unspecified attribute to catch errors
954 * @LNET_PING_ATTR_HDR: grouping for LNet ping data (NLA_NUL_STRING)
955 * @LNET_PING_ATTR_PRIMARY_NID: Source NID for ping request (NLA_STRING)
956 * @LNET_PING_ATTR_ERRNO: error code if we fail to ping (NLA_S16)
957 * @LNET_PING_ATTR_MULTIRAIL: Report if MR is supported (NLA_FLAG)
958 * @LNET_PING_ATTR_PEER_NI_LIST: List of peer NI's (NLA_NESTED)
960 enum lnet_ping_attr {
961 LNET_PING_ATTR_UNSPEC = 0,
964 LNET_PING_ATTR_PRIMARY_NID,
965 LNET_PING_ATTR_ERRNO,
966 LNET_PING_ATTR_MULTIRAIL,
967 LNET_PING_ATTR_PEER_NI_LIST,
968 __LNET_PING_ATTR_MAX_PLUS_ONE,
971 #define LNET_PING_ATTR_MAX (__LNET_PING_ATTR_MAX_PLUS_ONE - 1)
973 /** enum lnet_ping_peer_ni_attr - LNet peer ni information reported by
974 * ping command. A list of these are
975 * returned with a ping request.
977 * @LNET_PING_PEER_NI_ATTR_UNSPEC: unspecified attribute to catch errrors
979 * @LNET_PING_PEER_NI_ATTR_NID: NID address of peer NI. (NLA_STRING)
981 enum lnet_ping_peer_ni_attr {
982 LNET_PING_PEER_NI_ATTR_UNSPEC = 0,
984 LNET_PING_PEER_NI_ATTR_NID,
985 __LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE,
988 #define LNET_PING_PEER_NI_ATTR_MAX (__LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE - 1)
990 /** enum lnet_udsp_info_attr - LNet UDSP information reported for
991 * some subsystem that tracks it.
993 * @LNET_UDSP_INFO_ATTR_UNSPEC: unspecified attribute to catch errors
995 * @LNET_UDSP_INFO_ATTR_NET_PRIORITY, LNet net priority in selection.
997 * @LNET_UDSP_INFO_ATTR_NID_PRIORITY, NID's priority in selection.
999 * @LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST: Which gateway's are preferred.
1001 * @LNET_UDSP_INFO_ATTR_PREF_NIDS_LIST: Which NIDs are preferred.
1004 enum lnet_udsp_info_attr {
1005 LNET_UDSP_INFO_ATTR_UNSPEC = 0,
1007 LNET_UDSP_INFO_ATTR_NET_PRIORITY,
1008 LNET_UDSP_INFO_ATTR_NID_PRIORITY,
1009 LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST,
1010 LNET_UDSP_INFO_ATTR_PREF_NIDS_LIST,
1011 __LNET_UDSP_INFO_ATTR_MAX_PLUS_ONE,
1014 #define LNET_UDSP_INFO_ATTR_MAX (__LNET_UDSP_INFO_ATTR_MAX_PLUS_ONE - 1)
1016 /** enum lnet_udsp_info_pref_nids_attr - LNet UDSP information reported for
1017 * some subsystem that tracks it.
1019 * @LNET_UDSP_INFO_PREF_NIDS_ATTR_UNSPEC: unspecified attribute to catch errors
1021 * @LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX, UDSP prority NIDs label
1023 * @LNET_UDSP_INFO_PREF_NIDS_ATTR_NID, UDSP prority NID (NLA_STRING)
1025 enum lnet_udsp_info_pref_nids_attr {
1026 LNET_UDSP_INFO_PREF_NIDS_ATTR_UNSPEC = 0,
1028 LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX,
1029 LNET_UDSP_INFO_PREF_NIDS_ATTR_NID,
1030 __LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX_PLUS_ONE,
1033 #define LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX (__LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX_PLUS_ONE - 1)
1035 /** enum lnet_cpt_of_nid_attr - Attributes to support
1036 * lnetctl cpt-of-nid command
1038 * @LNET_CPT_OF_NID_ATTR_UNSPEC unspecified attribute to catch
1040 * @LNET_CPT_OF_NID_ATTR_HDR Grouping for cpt-of-nid
1042 * @LNET_CPT_OF_NID_ATTR_NID The NID whose CPT we want to
1043 * calculate (NLA_STRING)
1044 * LNET_CPT_OF_NID_ATTR_CPT The CPT for the specified NID
1047 enum lnet_cpt_of_nid_attr {
1048 LNET_CPT_OF_NID_ATTR_UNSPEC = 0,
1050 LNET_CPT_OF_NID_ATTR_HDR,
1051 LNET_CPT_OF_NID_ATTR_NID,
1052 LNET_CPT_OF_NID_ATTR_CPT,
1053 __LNET_CPT_OF_NID_ATTR_MAX_PLUS_ONE,
1056 #define LNET_CPT_OF_NID_ATTR_MAX (__LNET_CPT_OF_NID_ATTR_MAX_PLUS_ONE - 1)
1058 /** enum lnet_peer_dist_attr - Attributes to support
1059 * reporting distance for peers
1061 * @LNET_PEER_DIST_ATTR_UNSPEC unspecified attribute to catch
1063 * @LNET_PEER_DIST_ATTR_HDR Grouping which we just use peer
1065 * @LNET_PEER_DIST_ATTR_NID The NID we collect data for
1067 * @LNET_PEER_DIST_ATTR_DIST The distance for the specified
1069 * @LNET_PEER_DIST_ATTR_ORDER The order for the specified NID
1072 enum lnet_peer_dist_attr {
1073 LNET_PEER_DIST_ATTR_UNSPEC = 0,
1075 LNET_PEER_DIST_ATTR_HDR,
1076 LNET_PEER_DIST_ATTR_NID,
1077 LNET_PEER_DIST_ATTR_DIST,
1078 LNET_PEER_DIST_ATTR_ORDER,
1079 __LNET_PEER_DIST_ATTR_MAX_PLUS_ONE,
1082 #define LNET_PEER_DIST_ATTR_MAX (__LNET_PEER_DIST_ATTR_MAX_PLUS_ONE - 1)
1085 /* chain on the lnet_net structure */
1086 struct list_head ni_netlist;
1088 /* chain on the recovery queue */
1089 struct list_head ni_recovery;
1091 /* MD handle for recovery ping */
1092 struct lnet_handle_md ni_ping_mdh;
1096 /* number of CPTs */
1099 /* bond NI on some CPTs */
1102 /* interface's NID */
1103 struct lnet_nid ni_nid;
1105 /* instance-specific data */
1108 /* per ni credits */
1109 atomic_t ni_tx_credits;
1111 /* percpt TX queues */
1112 struct lnet_tx_queue **ni_tx_queues;
1114 /* percpt reference count */
1117 /* pointer to parent network */
1118 struct lnet_net *ni_net;
1120 /* my health status */
1123 /* NI FSM. Protected by lnet_ni_lock() */
1124 enum lnet_ni_state ni_state;
1126 /* Recovery state. Protected by lnet_ni_lock() */
1127 __u32 ni_recovery_state;
1129 /* When to send the next recovery ping */
1130 time64_t ni_next_ping;
1131 /* How many pings sent during current recovery period did not receive
1132 * a reply. NB: reset whenever _any_ message arrives on this NI
1134 unsigned int ni_ping_count;
1136 /* per NI LND tunables */
1137 struct lnet_lnd_tunables ni_lnd_tunables;
1139 /* lnd tunables set explicitly */
1140 bool ni_lnd_tunables_set;
1143 struct lnet_element_stats ni_stats;
1144 struct lnet_health_local_stats ni_hstats;
1146 /* physical device CPT */
1149 /* sequence number used to round robin over nis within a net */
1154 * initialized to LNET_MAX_HEALTH_VALUE
1155 * Value is decremented every time we fail to send a message over
1156 * this NI because of a NI specific failure.
1157 * Value is incremented if we successfully send a message.
1159 atomic_t ni_healthv;
1162 * Set to 1 by the LND when it receives an event telling it the device
1163 * has gone into a fatal state. Set to 0 when the LND receives an
1164 * even telling it the device is back online.
1166 atomic_t ni_fatal_error_on;
1168 /* the relative selection priority of this NI */
1169 __u32 ni_sel_priority;
1172 * equivalent interface to use
1175 struct net *ni_net_ns; /* original net namespace */
1178 #define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL
1181 * Descriptor of a ping info buffer: keep a separate indicator of the
1182 * size and a reference count. The type is used both as a source and
1183 * sink of data, so we need to keep some information outside of the
1184 * area that may be overwritten by network data.
1186 struct lnet_ping_buffer {
1187 int pb_nbytes; /* sizeof pb_info */
1190 struct lnet_ping_info pb_info;
1193 #define LNET_PING_BUFFER_SIZE(bytes) \
1194 (offsetof(struct lnet_ping_buffer, pb_info) + bytes)
1195 #define LNET_PING_BUFFER_LONI(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_nid)
1196 #define LNET_PING_BUFFER_SEQNO(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_status)
1198 #define LNET_PING_INFO_TO_BUFFER(PINFO) \
1199 container_of((PINFO), struct lnet_ping_buffer, pb_info)
1202 lnet_ping_sts_size(const struct lnet_nid *nid)
1206 /* for deciding the size of the ping buffer */
1207 if (unlikely(LNET_NID_IS_ANY(nid)))
1208 return sizeof(struct lnet_ni_large_status);
1210 if (nid_is_nid4(nid))
1211 return sizeof(struct lnet_ni_status);
1213 size = offsetof(struct lnet_ni_large_status, ns_nid) +
1216 return round_up(size, 4);
1219 static inline struct lnet_ni_large_status *
1220 lnet_ping_sts_next(const struct lnet_ni_large_status *nis)
1222 return (void *)nis + lnet_ping_sts_size(&nis->ns_nid);
1226 lnet_ping_at_least_two_entries(const struct lnet_ping_info *pi)
1228 /* Return true if we have at lease two entries. There is always a
1229 * least one, a 4-byte lo0 interface.
1231 struct lnet_ni_large_status *lns;
1233 if ((pi->pi_features & LNET_PING_FEAT_LARGE_ADDR) == 0)
1234 return pi->pi_nnis <= 2;
1235 /* There is at least 1 large-address entry */
1236 if (pi->pi_nnis != 1)
1238 lns = (void *)&pi->pi_ni[1];
1239 lns = lnet_ping_sts_next(lns);
1241 return ((void *)pi + lnet_ping_info_size(pi) <= (void *)lns);
1244 struct lnet_nid_list {
1245 struct list_head nl_list;
1246 struct lnet_nid nl_nid;
1249 struct lnet_peer_ni {
1250 /* chain on lpn_peer_nis */
1251 struct list_head lpni_peer_nis;
1252 /* chain on remote peer list */
1253 struct list_head lpni_on_remote_peer_ni_list;
1254 /* chain on recovery queue */
1255 struct list_head lpni_recovery;
1256 /* chain on peer hash */
1257 struct list_head lpni_hashlist;
1258 /* messages blocking for tx credits */
1259 struct list_head lpni_txq;
1260 /* pointer to peer net I'm part of */
1261 struct lnet_peer_net *lpni_peer_net;
1262 /* statistics kept on each peer NI */
1263 struct lnet_element_stats lpni_stats;
1264 struct lnet_health_remote_stats lpni_hstats;
1265 /* spin lock protecting credits and lpni_txq */
1266 spinlock_t lpni_lock;
1267 /* # tx credits available */
1269 /* low water mark */
1270 int lpni_mintxcredits;
1272 * Each peer_ni in a gateway maintains its own credits. This
1273 * allows more traffic to gateways that have multiple interfaces.
1275 /* # router credits */
1276 int lpni_rtrcredits;
1277 /* low water mark */
1278 int lpni_minrtrcredits;
1279 /* bytes queued for sending */
1281 /* network peer is on */
1282 struct lnet_net *lpni_net;
1284 struct lnet_nid lpni_nid;
1286 struct kref lpni_kref;
1287 /* health value for the peer */
1288 atomic_t lpni_healthv;
1289 /* recovery ping mdh */
1290 struct lnet_handle_md lpni_recovery_ping_mdh;
1291 /* When to send the next recovery ping */
1292 time64_t lpni_next_ping;
1293 /* How many pings sent during current recovery period did not receive
1294 * a reply. NB: reset whenever _any_ message arrives from this peer NI
1296 unsigned int lpni_ping_count;
1297 /* CPT this peer attached on */
1299 /* state flags -- protected by lpni_lock */
1300 unsigned lpni_state;
1301 /* status of the peer NI as reported by the peer */
1302 __u32 lpni_ns_status;
1303 /* sequence number used to round robin over peer nis within a net */
1305 /* sequence number used to round robin over gateways */
1307 /* returned RC ping features. Protected with lpni_lock */
1308 unsigned int lpni_ping_feats;
1309 /* time last message was received from the peer */
1310 time64_t lpni_last_alive;
1311 /* preferred local nids: if only one, use lpni_pref.nid */
1313 struct lnet_nid nid;
1314 struct list_head nids;
1316 /* list of router nids preferred for this peer NI */
1317 struct list_head lpni_rtr_pref_nids;
1318 /* The relative selection priority of this peer NI */
1319 __u32 lpni_sel_priority;
1320 /* number of preferred NIDs in lnpi_pref_nids */
1321 __u32 lpni_pref_nnids;
1324 /* Preferred path added due to traffic on non-MR peer_ni */
1325 #define LNET_PEER_NI_NON_MR_PREF BIT(0)
1326 /* peer is being recovered. */
1327 #define LNET_PEER_NI_RECOVERY_PENDING BIT(1)
1328 /* recovery ping failed */
1329 #define LNET_PEER_NI_RECOVERY_FAILED BIT(2)
1330 /* peer is being deleted */
1331 #define LNET_PEER_NI_DELETING BIT(3)
1334 /* chain on pt_peer_list */
1335 struct list_head lp_peer_list;
1337 /* list of peer nets */
1338 struct list_head lp_peer_nets;
1340 /* list of messages pending discovery*/
1341 struct list_head lp_dc_pendq;
1343 /* chain on router list */
1344 struct list_head lp_rtr_list;
1346 /* primary NID of the peer */
1347 struct lnet_nid lp_primary_nid;
1349 /* source NID to use during discovery */
1350 struct lnet_nid lp_disc_src_nid;
1351 /* destination NID to use during discovery */
1352 struct lnet_nid lp_disc_dst_nid;
1354 /* net to perform discovery on */
1355 __u32 lp_disc_net_id;
1357 /* CPT of peer_table */
1360 /* number of NIDs on this peer */
1363 /* # refs from lnet_route::lr_gateway */
1364 int lp_rtr_refcount;
1367 * peer specific health sensitivity value to decrement peer nis in
1368 * this peer with if set to something other than 0
1370 __u32 lp_health_sensitivity;
1372 /* messages blocking for router credits */
1373 struct list_head lp_rtrq;
1375 /* routes on this peer */
1376 struct list_head lp_routes;
1378 /* reference count */
1379 atomic_t lp_refcount;
1381 /* lock protecting peer state flags and lpni_rtrq */
1384 /* peer state flags */
1387 /* buffer for data pushed by peer */
1388 struct lnet_ping_buffer *lp_data;
1390 /* MD handle for ping in progress */
1391 struct lnet_handle_md lp_ping_mdh;
1393 /* MD handle for push in progress */
1394 struct lnet_handle_md lp_push_mdh;
1396 /* number of bytes for sizing pb_info in push data */
1399 /* NI config sequence number of peer */
1400 __u32 lp_peer_seqno;
1402 /* Local NI config sequence number acked by peer */
1403 __u32 lp_node_seqno;
1405 /* Local NI config sequence number sent to peer */
1406 __u32 lp_node_seqno_sent;
1408 /* Ping error encountered during discovery. */
1411 /* Push error encountered during discovery. */
1414 /* Error encountered during discovery. */
1417 /* time it was put on the ln_dc_working queue */
1418 time64_t lp_last_queued;
1420 /* link on discovery-related lists */
1421 struct list_head lp_dc_list;
1423 /* tasks waiting on discovery of this peer */
1424 wait_queue_head_t lp_dc_waitq;
1426 /* cached peer aliveness */
1429 /* sequence number used to round robin traffic to this peer's
1434 /* timestamp of primary nid lock */
1435 __u64 lp_prim_lock_ts;
1439 * The status flags in lp_state. Their semantics have chosen so that
1440 * lp_state can be zero-initialized.
1442 * A peer is marked MULTI_RAIL in two cases: it was configured using DLC
1443 * as multi-rail aware, or the LNET_PING_FEAT_MULTI_RAIL bit was set.
1445 * A peer is marked NO_DISCOVERY if the LNET_PING_FEAT_DISCOVERY bit was
1446 * NOT set when the peer was pinged by discovery.
1448 * A peer is marked ROUTER if it indicates so in the feature bit.
1450 #define LNET_PEER_MULTI_RAIL BIT(0) /* Multi-rail aware */
1451 #define LNET_PEER_NO_DISCOVERY BIT(1) /* Peer disabled discovery */
1452 #define LNET_PEER_ROUTER_ENABLED BIT(2) /* router feature enabled */
1455 * A peer is marked CONFIGURED if it was configured by DLC.
1457 * In addition, a peer is marked DISCOVERED if it has fully passed
1458 * through Peer Discovery.
1460 * When Peer Discovery is disabled, the discovery thread will mark
1461 * peers REDISCOVER to indicate that they should be re-examined if
1462 * discovery is (re)enabled on the node.
1464 * A peer that was created as the result of inbound traffic will not
1467 #define LNET_PEER_CONFIGURED BIT(3) /* Configured via DLC */
1468 #define LNET_PEER_DISCOVERED BIT(4) /* Peer was discovered */
1469 #define LNET_PEER_REDISCOVER BIT(5) /* Discovery was disabled */
1471 * A peer is marked DISCOVERING when discovery is in progress.
1472 * The other flags below correspond to stages of discovery.
1474 #define LNET_PEER_DISCOVERING BIT(6) /* Discovering */
1475 #define LNET_PEER_DATA_PRESENT BIT(7) /* Remote peer data present */
1476 #define LNET_PEER_NIDS_UPTODATE BIT(8) /* Remote peer info uptodate */
1477 #define LNET_PEER_PING_SENT BIT(9) /* Waiting for REPLY to Ping */
1478 #define LNET_PEER_PUSH_SENT BIT(10) /* Waiting for ACK of Push */
1479 #define LNET_PEER_PING_FAILED BIT(11) /* Ping send failure */
1480 #define LNET_PEER_PUSH_FAILED BIT(12) /* Push send failure */
1482 * A ping can be forced as a way to fix up state, or as a manual
1483 * intervention by an admin.
1484 * A push can be forced in circumstances that would normally not
1485 * allow for one to happen.
1487 #define LNET_PEER_FORCE_PING BIT(13) /* Forced Ping */
1488 #define LNET_PEER_FORCE_PUSH BIT(14) /* Forced Push */
1490 /* force delete even if router */
1491 #define LNET_PEER_RTR_NI_FORCE_DEL BIT(15)
1493 /* gw undergoing alive discovery */
1494 #define LNET_PEER_RTR_DISCOVERY BIT(16)
1495 /* gw has undergone discovery (does not indicate success or failure) */
1496 #define LNET_PEER_RTR_DISCOVERED BIT(17)
1498 /* peer is marked for deletion */
1499 #define LNET_PEER_MARK_DELETION BIT(18)
1500 /* lnet_peer_del()/lnet_peer_del_locked() has been called on the peer */
1501 #define LNET_PEER_MARK_DELETED BIT(19)
1502 /* lock primary NID to what's requested by ULP */
1503 #define LNET_PEER_LOCK_PRIMARY BIT(20)
1504 /* this is for informational purposes only. It is set if a peer gets
1505 * configured from Lustre with a primary NID which belongs to another peer
1506 * which is also configured by Lustre as the primary NID.
1508 #define LNET_PEER_BAD_CONFIG BIT(21)
1510 struct lnet_peer_net {
1511 /* chain on lp_peer_nets */
1512 struct list_head lpn_peer_nets;
1514 /* list of peer_nis on this network */
1515 struct list_head lpn_peer_nis;
1517 /* pointer to the peer I'm part of */
1518 struct lnet_peer *lpn_peer;
1523 /* peer net health */
1526 /* time of next router ping on this net */
1527 time64_t lpn_next_ping;
1529 /* selection sequence number */
1532 /* relative peer net selection priority */
1533 __u32 lpn_sel_priority;
1535 /* reference count */
1536 atomic_t lpn_refcount;
1539 /* peer hash size */
1540 #define LNET_PEER_HASH_BITS 9
1541 #define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS)
1544 * peer hash table - one per CPT
1546 * protected by lnet_net_lock/EX for update
1551 * protected by pt_zombie_lock:
1555 * pt_zombie lock nests inside lnet_net_lock
1557 struct lnet_peer_table {
1558 int pt_version; /* /proc validity stamp */
1559 struct list_head *pt_hash; /* NID->peer hash */
1560 struct list_head pt_peer_list; /* peers */
1561 int pt_peers; /* # peers */
1562 struct list_head pt_zombie_list; /* zombie peer_ni */
1563 int pt_zombies; /* # zombie peers_ni */
1564 spinlock_t pt_zombie_lock; /* protect list and count */
1567 /* peer aliveness is enabled only on routers for peers in a network where the
1568 * struct lnet_ni::ni_peertimeout has been set to a positive value
1570 #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing != 0 && \
1571 ((lp)->lpni_net) && \
1572 (lp)->lpni_net->net_tunables.lct_peer_timeout > 0)
1575 struct list_head lr_list; /* chain on net */
1576 struct list_head lr_gwlist; /* chain on gateway */
1577 struct lnet_peer *lr_gateway; /* router node */
1578 struct lnet_nid lr_nid; /* NID used to add route */
1579 __u32 lr_net; /* remote network number */
1580 __u32 lr_lnet; /* local network number */
1581 int lr_seq; /* sequence for round-robin */
1582 __u32 lr_hops; /* how far I am */
1583 unsigned int lr_priority; /* route priority */
1584 atomic_t lr_alive; /* cached route aliveness */
1585 bool lr_single_hop; /* this route is single-hop */
1588 #define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)
1589 #define LNET_REMOTE_NETS_HASH_MAX (1U << 16)
1590 #define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits)
1592 struct lnet_remotenet {
1593 /* chain on ln_remote_nets_hash */
1594 struct list_head lrn_list;
1596 struct list_head lrn_routes;
1601 /** lnet message has credit and can be submitted to lnd for send/receive */
1602 #define LNET_CREDIT_OK 0
1603 /** lnet message is waiting for credit */
1604 #define LNET_CREDIT_WAIT 1
1605 /** lnet message is waiting for discovery */
1606 #define LNET_DC_WAIT 2
1608 struct lnet_rtrbufpool {
1609 /* my free buffer pool */
1610 struct list_head rbp_bufs;
1611 /* messages blocking for a buffer */
1612 struct list_head rbp_msgs;
1613 /* # pages in each buffer */
1615 /* requested number of buffers */
1616 int rbp_req_nbuffers;
1617 /* # buffers actually allocated */
1619 /* # free buffers / blocked messages */
1621 /* low water mark */
1625 struct lnet_rtrbuf {
1626 struct list_head rb_list; /* chain on rbp_bufs */
1627 struct lnet_rtrbufpool *rb_pool; /* owning pool */
1628 struct bio_vec rb_kiov[0]; /* the buffer space */
1631 #define LNET_PEER_HASHSIZE 503 /* prime! */
1633 enum lnet_match_flags {
1634 /* Didn't match anything */
1635 LNET_MATCHMD_NONE = BIT(0),
1637 LNET_MATCHMD_OK = BIT(1),
1638 /* Must be discarded */
1639 LNET_MATCHMD_DROP = BIT(2),
1640 /* match and buffer is exhausted */
1641 LNET_MATCHMD_EXHAUSTED = BIT(3),
1643 LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
1646 /* Options for struct lnet_portal::ptl_options */
1647 #define LNET_PTL_LAZY BIT(0)
1648 #define LNET_PTL_MATCH_UNIQUE BIT(1) /* unique match, for RDMA */
1649 #define LNET_PTL_MATCH_WILDCARD BIT(2) /* wildcard match, request portal */
1651 /* parameter for matching operations (GET, PUT) */
1652 struct lnet_match_info {
1654 struct lnet_processid mi_id;
1655 unsigned int mi_cpt;
1656 unsigned int mi_opc;
1657 unsigned int mi_portal;
1658 unsigned int mi_rlength;
1659 unsigned int mi_roffset;
1662 /* ME hash of RDMA portal */
1663 #define LNET_MT_HASH_BITS 8
1664 #define LNET_MT_HASH_SIZE (1 << LNET_MT_HASH_BITS)
1665 #define LNET_MT_HASH_MASK (LNET_MT_HASH_SIZE - 1)
1666 /* we allocate (LNET_MT_HASH_SIZE + 1) entries for lnet_match_table::mt_hash,
1667 * the last entry is reserved for MEs with ignore-bits */
1668 #define LNET_MT_HASH_IGNORE LNET_MT_HASH_SIZE
1669 /* __u64 has 2^6 bits, so need 2^(LNET_MT_HASH_BITS - LNET_MT_BITS_U64) which
1670 * is 4 __u64s as bit-map, and add an extra __u64 (only use one bit) for the
1671 * ME-list with ignore-bits, which is mtable::mt_hash[LNET_MT_HASH_IGNORE] */
1672 #define LNET_MT_BITS_U64 6 /* 2^6 bits */
1673 #define LNET_MT_EXHAUSTED_BITS (LNET_MT_HASH_BITS - LNET_MT_BITS_U64)
1674 #define LNET_MT_EXHAUSTED_BMAP ((1 << LNET_MT_EXHAUSTED_BITS) + 1)
1676 /* portal match table */
1677 struct lnet_match_table {
1678 /* reserved for upcoming patches, CPU partition ID */
1679 unsigned int mt_cpt;
1680 unsigned int mt_portal; /* portal index */
1681 /* match table is set as "enabled" if there's non-exhausted MD
1682 * attached on mt_mhash, it's only valid for wildcard portal */
1683 unsigned int mt_enabled;
1684 /* bitmap to flag whether MEs on mt_hash are exhausted or not */
1685 __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
1686 struct list_head *mt_mhash; /* matching hash */
1689 /* these are only useful for wildcard portal */
1690 /* Turn off message rotor for wildcard portals */
1691 #define LNET_PTL_ROTOR_OFF 0
1692 /* round-robin dispatch all PUT messages for wildcard portals */
1693 #define LNET_PTL_ROTOR_ON 1
1694 /* round-robin dispatch routed PUT message for wildcard portals */
1695 #define LNET_PTL_ROTOR_RR_RT 2
1696 /* dispatch routed PUT message by hashing source NID for wildcard portals */
1697 #define LNET_PTL_ROTOR_HASH_RT 3
1699 struct lnet_portal {
1700 spinlock_t ptl_lock;
1701 unsigned int ptl_index; /* portal ID, reserved */
1702 /* flags on this portal: lazy, unique... */
1703 unsigned int ptl_options;
1704 /* list of messages which are stealing buffer */
1705 struct list_head ptl_msg_stealing;
1706 /* messages blocking for MD */
1707 struct list_head ptl_msg_delayed;
1708 /* Match table for each CPT */
1709 struct lnet_match_table **ptl_mtables;
1710 /* spread rotor of incoming "PUT" */
1711 unsigned int ptl_rotor;
1712 /* # active entries for this portal */
1714 /* array of active entries' cpu-partition-id */
1718 #define LNET_LH_HASH_BITS 12
1719 #define LNET_LH_HASH_SIZE (1ULL << LNET_LH_HASH_BITS)
1720 #define LNET_LH_HASH_MASK (LNET_LH_HASH_SIZE - 1)
1722 /* resource container (ME, MD, EQ) */
1723 struct lnet_res_container {
1724 unsigned int rec_type; /* container type */
1725 __u64 rec_lh_cookie; /* cookie generator */
1726 struct list_head rec_active; /* active resource list */
1727 struct list_head *rec_lh_hash; /* handle hash */
1730 /* message container */
1731 struct lnet_msg_container {
1732 int msc_init; /* initialized or not */
1733 /* max # threads finalizing */
1734 int msc_nfinalizers;
1735 /* msgs waiting to complete finalizing */
1736 struct list_head msc_finalizing;
1737 /* msgs waiting to be resent */
1738 struct list_head msc_resending;
1739 struct list_head msc_active; /* active message list */
1740 /* threads doing finalization */
1741 void **msc_finalizers;
1742 /* threads doing resends */
1743 void **msc_resenders;
1746 /* This UDSP structures need to match the user space liblnetconfig structures
1747 * in order for the marshall and unmarshall functions to be common.
1750 /* Net is described as a
1754 struct lnet_ud_net_descr {
1756 struct list_head udn_net_num_range;
1759 /* each NID range is defined as
1761 * 2. address range descriptor
1763 struct lnet_ud_nid_descr {
1764 struct lnet_ud_net_descr ud_net_id;
1765 struct list_head ud_addr_range;
1769 /* a UDSP rule can have up to three user defined NID descriptors
1770 * - src: defines the local NID range for the rule
1771 * - dst: defines the peer NID range for the rule
1772 * - rte: defines the router NID range for the rule
1774 * An action union defines the action to take when the rule
1778 struct list_head udsp_on_list;
1780 struct lnet_ud_nid_descr udsp_src;
1781 struct lnet_ud_nid_descr udsp_dst;
1782 struct lnet_ud_nid_descr udsp_rte;
1783 enum lnet_udsp_action_type udsp_action_type;
1785 __u32 udsp_priority;
1789 /* Peer Discovery states */
1790 #define LNET_DC_STATE_SHUTDOWN 0 /* not started */
1791 #define LNET_DC_STATE_RUNNING 1 /* started up OK */
1792 #define LNET_DC_STATE_STOPPING 2 /* telling thread to stop */
1794 /* Router Checker states */
1795 #define LNET_MT_STATE_SHUTDOWN 0 /* not started */
1796 #define LNET_MT_STATE_RUNNING 1 /* started up OK */
1797 #define LNET_MT_STATE_STOPPING 2 /* telling thread to stop */
1800 #define LNET_STATE_SHUTDOWN 0 /* not started */
1801 #define LNET_STATE_RUNNING 1 /* started up OK */
1802 #define LNET_STATE_STOPPING 2 /* telling thread to stop */
1805 /* CPU partition table of LNet */
1806 struct cfs_cpt_table *ln_cpt_table;
1807 /* number of CPTs in ln_cpt_table */
1808 unsigned int ln_cpt_number;
1809 unsigned int ln_cpt_bits;
1811 /* protect LNet resources (ME/MD/EQ) */
1812 struct cfs_percpt_lock *ln_res_lock;
1815 /* the vector of portals */
1816 struct lnet_portal **ln_portals;
1817 /* percpt MD container */
1818 struct lnet_res_container **ln_md_containers;
1820 /* Event Queue container */
1821 struct lnet_res_container ln_eq_container;
1822 spinlock_t ln_eq_wait_lock;
1824 unsigned int ln_remote_nets_hbits;
1826 /* protect NI, peer table, credits, routers, rtrbuf... */
1827 struct cfs_percpt_lock *ln_net_lock;
1828 /* percpt message containers for active/finalizing/freed message */
1829 struct lnet_msg_container **ln_msg_containers;
1830 struct lnet_counters **ln_counters;
1831 struct lnet_peer_table **ln_peer_tables;
1832 /* list of peer nis not on a local network */
1833 struct list_head ln_remote_peer_ni_list;
1834 /* failure simulation */
1835 struct list_head ln_test_peers;
1836 struct list_head ln_drop_rules;
1837 struct list_head ln_delay_rules;
1839 struct list_head ln_nets;
1840 /* Sequence number used to round robin sends across all nets */
1842 /* the loopback NI */
1843 struct lnet_ni *ln_loni;
1844 /* network zombie list */
1845 struct list_head ln_net_zombie;
1846 /* resend messages list */
1847 struct list_head ln_msg_resend;
1848 /* spin lock to protect the msg resend list */
1849 spinlock_t ln_msg_resend_lock;
1851 /* remote networks with routes to them */
1852 struct list_head *ln_remote_nets_hash;
1853 /* validity stamp */
1854 __u64 ln_remote_nets_version;
1855 /* list of all known routers */
1856 struct list_head ln_routers;
1857 /* validity stamp */
1858 __u64 ln_routers_version;
1859 /* percpt router buffer pools */
1860 struct lnet_rtrbufpool **ln_rtrpools;
1863 * Ping target / Push source
1865 * The ping target and push source share a single buffer. The
1866 * ln_ping_target is protected against concurrent updates by
1869 struct lnet_handle_md ln_ping_target_md;
1870 lnet_handler_t ln_ping_target_handler;
1871 struct lnet_ping_buffer *ln_ping_target;
1872 atomic_t ln_ping_target_seqno;
1877 * ln_push_nnis contains the desired size of the push target.
1878 * The lnet_net_lock is used to handle update races. The old
1879 * buffer may linger a while after it has been unlinked, in
1880 * which case the event handler cleans up.
1882 lnet_handler_t ln_push_target_handler;
1883 struct lnet_handle_md ln_push_target_md;
1884 struct lnet_ping_buffer *ln_push_target;
1885 /* bytes needed for pb_info to receive push */
1886 int ln_push_target_nbytes;
1888 /* discovery event queue handle */
1889 lnet_handler_t ln_dc_handler;
1890 /* discovery requests */
1891 struct list_head ln_dc_request;
1892 /* discovery working list */
1893 struct list_head ln_dc_working;
1894 /* discovery expired list */
1895 struct list_head ln_dc_expired;
1896 /* discovery thread wait queue */
1897 wait_queue_head_t ln_dc_waitq;
1898 /* discovery startup/shutdown state */
1901 /* monitor thread startup/shutdown state */
1903 /* serialise startup/shutdown */
1904 struct semaphore ln_mt_signal;
1906 struct mutex ln_api_mutex;
1907 struct mutex ln_lnd_mutex;
1908 /* Have I called LNetNIInit myself? */
1910 /* LNetNIInit/LNetNIFini counter */
1912 /* SHUTDOWN/RUNNING/STOPPING */
1915 int ln_routing; /* am I a router? */
1916 lnet_pid_t ln_pid; /* requested pid */
1917 /* uniquely identifies this ni in this epoch */
1918 __u64 ln_interface_cookie;
1919 /* registered LNDs */
1920 const struct lnet_lnd *ln_lnds[NUM_LNDS];
1922 /* test protocol compatibility flags */
1923 unsigned long ln_testprotocompat;
1925 /* 0 - load the NIs from the mod params
1926 * 1 - do not load the NIs from the mod params
1927 * Reverse logic to ensure that other calls to LNetNIInit
1930 bool ln_nis_from_mod_params;
1932 /* Switch to test large NIDs */
1933 bool ln_nis_use_large_nids;
1936 * completion for the monitor thread. The monitor thread takes care of
1937 * checking routes, timedout messages and resending messages.
1939 struct completion ln_mt_wait_complete;
1941 /* per-cpt resend queues */
1942 struct list_head **ln_mt_resendqs;
1943 /* local NIs to recover */
1944 struct list_head ln_mt_localNIRecovq;
1945 /* local NIs to recover */
1946 struct list_head ln_mt_peerNIRecovq;
1948 * An array of queues for GET/PUT waiting for REPLY/ACK respectively.
1949 * There are CPT number of queues. Since response trackers will be
1950 * added on the fast path we can't afford to grab the exclusive
1951 * net lock to protect these queues. The CPT will be calculated
1952 * based on the mdh cookie.
1954 struct list_head **ln_mt_rstq;
1956 * A response tracker becomes a zombie when the associated MD is queued
1957 * for unlink before the response tracker is detached from the MD. An
1958 * entry on a zombie list can be freed when either the remaining
1959 * operations on the MD complete or when LNet has shut down.
1961 struct list_head **ln_mt_zombie_rstqs;
1962 /* recovery handler */
1963 lnet_handler_t ln_mt_handler;
1966 * Completed when the discovery and monitor threads can enter their
1969 struct completion ln_started;
1971 struct list_head ln_udsp_list;
1973 /* Number of messages that have exceeded their message deadline */
1974 atomic_t ln_late_msg_count;
1975 /* Total amount of time past their deadline for all late ^ messages */
1976 atomic64_t ln_late_msg_nsecs;
1978 /* for LNDs to signal that ping buffer needs updating */
1979 atomic_t ln_update_ping_buf;
1981 /* workqueue for serving lnd ping buffer update requests */
1982 struct workqueue_struct *ln_pb_update_wq;
1983 struct work_struct ln_pb_update_work;
1985 atomic_t ln_pb_update_ready;
1988 struct genl_filter_list {
1989 struct list_head lp_list;
1994 static const struct nla_policy scalar_attr_policy[LN_SCALAR_MAX + 1] = {
1995 [LN_SCALAR_ATTR_LIST] = { .type = NLA_NESTED },
1996 [LN_SCALAR_ATTR_LIST_SIZE] = { .type = NLA_U16 },
1997 [LN_SCALAR_ATTR_INDEX] = { .type = NLA_U16 },
1998 [LN_SCALAR_ATTR_NLA_TYPE] = { .type = NLA_U16 },
1999 [LN_SCALAR_ATTR_VALUE] = { .type = NLA_STRING },
2000 [LN_SCALAR_ATTR_KEY_FORMAT] = { .type = NLA_U16 },
2003 int lnet_genl_send_scalar_list(struct sk_buff *msg, u32 portid, u32 seq,
2004 const struct genl_family *family, int flags,
2005 u8 cmd, const struct ln_key_list *data[]);
2007 /* Special workaround for pre-4.19 kernels to send error messages
2008 * from dumpit routines. Newer kernels will send message with
2009 * NL_SET_ERR_MSG information by default if NETLINK_EXT_ACK is set.
2011 static inline int lnet_nl_send_error(struct sk_buff *msg, int portid, int seq,
2014 #ifndef HAVE_NL_DUMP_WITH_EXT_ACK
2015 struct nlmsghdr *nlh;
2020 nlh = nlmsg_put(msg, portid, seq, NLMSG_ERROR, sizeof(error), 0);
2023 #ifdef HAVE_NL_PARSE_WITH_EXT_ACK
2024 netlink_ack(msg, nlh, error, NULL);
2026 netlink_ack(msg, nlh, error);
2028 return nlmsg_len(nlh);