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 int libcfs_strid(struct lnet_processid *id, const char *str);
58 int cfs_match_nid_net(struct lnet_nid *nid, u32 net,
59 struct list_head *net_num_list,
60 struct list_head *addr);
62 /* Max payload size */
63 #define LNET_MAX_PAYLOAD LNET_MTU
65 /** limit on the number of fragments in discontiguous MDs */
66 #define LNET_MAX_IOV 256
69 * This is the maximum health value.
70 * All local and peer NIs created have their health default to this value.
72 #define LNET_MAX_HEALTH_VALUE 1000
73 #define LNET_MAX_SELECTION_PRIORITY UINT_MAX
78 enum lnet_msg_hstatus {
79 LNET_MSG_STATUS_OK = 0,
80 LNET_MSG_STATUS_LOCAL_INTERRUPT,
81 LNET_MSG_STATUS_LOCAL_DROPPED,
82 LNET_MSG_STATUS_LOCAL_ABORTED,
83 LNET_MSG_STATUS_LOCAL_NO_ROUTE,
84 LNET_MSG_STATUS_LOCAL_ERROR,
85 LNET_MSG_STATUS_LOCAL_TIMEOUT,
86 LNET_MSG_STATUS_REMOTE_ERROR,
87 LNET_MSG_STATUS_REMOTE_DROPPED,
88 LNET_MSG_STATUS_REMOTE_TIMEOUT,
89 LNET_MSG_STATUS_NETWORK_TIMEOUT,
93 struct lnet_rsp_tracker {
94 /* chain on the waiting list */
95 struct list_head rspt_on_list;
99 struct lnet_nid rspt_next_hop_nid;
100 /* deadline of the REPLY/ACK */
101 ktime_t rspt_deadline;
103 struct lnet_handle_md rspt_mdh;
107 struct list_head msg_activelist;
108 struct list_head msg_list; /* Q for credits/MD */
110 struct lnet_processid msg_target;
111 /* Primary NID of the source. */
112 struct lnet_nid msg_initiator;
113 /* where is it from, it's only for building event */
114 struct lnet_nid msg_from;
118 * hold parameters in case message is with held due
121 struct lnet_nid msg_src_nid_param;
122 struct lnet_nid msg_rtr_nid_param;
125 * Deadline for the message after which it will be finalized if it
128 ktime_t msg_deadline;
130 /* The message health status. */
131 enum lnet_msg_hstatus msg_health_status;
132 /* This is a recovery message */
134 /* the number of times a transmission has been retried */
136 /* flag to indicate that we do not want to resend this message */
139 /* committed for sending */
140 unsigned int msg_tx_committed:1;
141 /* CPT # this message committed for sending */
142 unsigned int msg_tx_cpt:15;
143 /* committed for receiving */
144 unsigned int msg_rx_committed:1;
145 /* CPT # this message committed for receiving */
146 unsigned int msg_rx_cpt:15;
147 /* queued for tx credit */
148 unsigned int msg_tx_delayed:1;
149 /* queued for RX buffer */
150 unsigned int msg_rx_delayed:1;
151 /* ready for pending on RX delay list */
152 unsigned int msg_rx_ready_delay:1;
154 unsigned int msg_vmflush:1; /* VM trying to free memory */
155 unsigned int msg_target_is_router:1; /* sending to a router */
156 unsigned int msg_routing:1; /* being forwarded */
157 unsigned int msg_ack:1; /* ack on finalize (PUT) */
158 unsigned int msg_sending:1; /* outgoing message */
159 unsigned int msg_receiving:1; /* being received */
160 unsigned int msg_txcredit:1; /* taken an NI send credit */
161 unsigned int msg_peertxcredit:1; /* taken a peer send credit */
162 unsigned int msg_rtrcredit:1; /* taken a globel router credit */
163 unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */
164 unsigned int msg_onactivelist:1; /* on the activelist */
165 unsigned int msg_rdma_get:1;
167 struct lnet_peer_ni *msg_txpeer; /* peer I'm sending to */
168 struct lnet_peer_ni *msg_rxpeer; /* peer I received from */
171 struct lnet_libmd *msg_md;
172 /* the NI the message was sent or received over */
173 struct lnet_ni *msg_txni;
174 struct lnet_ni *msg_rxni;
176 unsigned int msg_len;
177 unsigned int msg_wanted;
178 unsigned int msg_offset;
179 unsigned int msg_niov;
180 struct bio_vec *msg_kiov;
182 struct lnet_event msg_ev;
183 struct lnet_hdr msg_hdr;
186 struct lnet_libhandle {
187 struct list_head lh_hash_chain;
191 #define lh_entry(ptr, type, member) \
192 ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
195 struct list_head me_list;
197 struct lnet_processid me_match_id;
198 unsigned int me_portal;
199 unsigned int me_pos; /* hash offset in mt_hash */
201 __u64 me_ignore_bits;
202 enum lnet_unlink me_unlink;
203 struct lnet_libmd *me_md;
207 struct list_head md_list;
208 struct lnet_libhandle md_lh;
209 struct lnet_me *md_me;
211 unsigned int md_offset;
212 unsigned int md_length;
213 unsigned int md_max_size;
216 unsigned int md_options;
217 unsigned int md_flags;
218 unsigned int md_niov; /* # frags at end of struct */
220 struct lnet_rsp_tracker *md_rspt_ptr;
221 lnet_handler_t md_handler;
222 struct lnet_handle_md md_bulk_handle;
223 struct bio_vec md_kiov[LNET_MAX_IOV];
226 #define LNET_MD_FLAG_ZOMBIE BIT(0)
227 #define LNET_MD_FLAG_AUTO_UNLINK BIT(1)
228 #define LNET_MD_FLAG_ABORTED BIT(2)
229 /* LNET_MD_FLAG_HANDLING is set when a non-unlink event handler
230 * is being called for an event relating to the md.
231 * It ensures only one such handler runs at a time.
232 * The final "unlink" event is only called once the
233 * md_refcount has reached zero, and this flag has been cleared,
234 * ensuring that it doesn't race with any other event handler
237 #define LNET_MD_FLAG_HANDLING BIT(3)
238 #define LNET_MD_FLAG_DISCARD BIT(4)
239 #define LNET_MD_FLAG_GPU BIT(5) /**< Special mapping needs */
241 static inline bool lnet_md_is_gpu(struct lnet_libmd *md)
243 return (md != NULL) && !!(md->md_flags & LNET_MD_FLAG_GPU);
246 struct lnet_test_peer {
247 /* info about peers we are trying to fail */
248 struct list_head tp_list; /* ln_test_peers */
249 struct lnet_nid tp_nid; /* matching nid */
250 unsigned int tp_threshold; /* # failures to simulate */
253 #define LNET_COOKIE_TYPE_MD 1
254 #define LNET_COOKIE_TYPE_ME 2
255 #define LNET_COOKIE_TYPE_EQ 3
256 #define LNET_COOKIE_TYPE_BITS 2
257 #define LNET_COOKIE_MASK ((1ULL << LNET_COOKIE_TYPE_BITS) - 1ULL)
263 void (*nf_addr2str)(u32 addr, char *str, size_t size);
264 void (*nf_addr2str_size)(const __be32 *addr, size_t asize,
265 char *str, size_t size);
266 int (*nf_str2addr)(const char *str, int nob, u32 *addr);
267 int (*nf_str2addr_size)(const char *str, int nob,
268 __be32 *addr, size_t *asize);
269 int (*nf_parse_addrlist)(char *str, int len,
270 struct list_head *list);
271 int (*nf_print_addrlist)(char *buffer, int count,
272 struct list_head *list);
273 int (*nf_match_addr)(u32 addr, struct list_head *list);
274 int (*nf_min_max)(struct list_head *nidlist, u32 *min_nid,
278 struct lnet_ni; /* forward ref */
282 /* fields initialized by the LND */
285 int (*lnd_startup)(struct lnet_ni *ni);
286 void (*lnd_shutdown)(struct lnet_ni *ni);
287 int (*lnd_ctl)(struct lnet_ni *ni, unsigned int cmd, void *arg);
289 /* In data movement APIs below, payload buffers are described as a set
290 * of 'niov' fragments which are in pages.
291 * The LND may NOT overwrite these fragment descriptors.
292 * An 'offset' and may specify a byte offset within the set of
293 * fragments to start from
296 /* Start sending a preformatted message. 'private' is NULL for PUT and
297 * GET messages; otherwise this is a response to an incoming message
298 * and 'private' is the 'private' passed to lnet_parse(). Return
299 * non-zero for immediate failure, otherwise complete later with
301 int (*lnd_send)(struct lnet_ni *ni, void *private,
302 struct lnet_msg *msg);
304 /* Start receiving 'mlen' bytes of payload data, skipping the following
305 * 'rlen' - 'mlen' bytes. 'private' is the 'private' passed to
306 * lnet_parse(). Return non-zero for immedaite failure, otherwise
307 * complete later with lnet_finalize(). This also gives back a receive
308 * credit if the LND does flow control. */
309 int (*lnd_recv)(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
310 int delayed, unsigned int niov,
311 struct bio_vec *kiov,
312 unsigned int offset, unsigned int mlen, unsigned int rlen);
314 /* lnet_parse() has had to delay processing of this message
315 * (e.g. waiting for a forwarding buffer or send credits). Give the
316 * LND a chance to free urgently needed resources. If called, return 0
317 * for success and do NOT give back a receive credit; that has to wait
318 * until lnd_recv() gets called. On failure return < 0 and
319 * release resources; lnd_recv() will not be called. */
320 int (*lnd_eager_recv)(struct lnet_ni *ni, void *private,
321 struct lnet_msg *msg, void **new_privatep);
323 /* notification of peer down */
324 void (*lnd_notify_peer_down)(struct lnet_nid *peer);
326 /* accept a new connection */
327 int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock);
329 /* get dma_dev priority */
330 unsigned int (*lnd_get_dev_prio)(struct lnet_ni *ni,
331 unsigned int dev_idx);
333 /* Handle LND specific Netlink handling */
334 int (*lnd_nl_get)(int cmd, struct sk_buff *msg, int type, void *data);
335 int (*lnd_nl_set)(int cmd, struct nlattr *attr, int type, void *data);
337 const struct ln_key_list *lnd_keys;
340 struct lnet_tx_queue {
341 int tq_credits; /* # tx credits free */
342 int tq_credits_min; /* lowest it's been */
343 int tq_credits_max; /* total # tx credits */
344 struct list_head tq_delayed; /* delayed TXs */
347 enum lnet_net_state {
348 /* set when net block is allocated */
349 LNET_NET_STATE_INIT = 0,
350 /* set when NIs in net are started successfully */
351 LNET_NET_STATE_ACTIVE,
352 /* set if all NIs in net are in FAILED state */
353 LNET_NET_STATE_INACTIVE,
354 /* set when shutting down a NET */
355 LNET_NET_STATE_DELETING
359 /* initial state when NI is created */
360 LNET_NI_STATE_INIT = 0,
361 /* set when NI is brought up */
362 LNET_NI_STATE_ACTIVE,
363 /* set when NI is being shutdown */
364 LNET_NI_STATE_DELETING,
367 #define LNET_NI_RECOVERY_PENDING BIT(0)
368 #define LNET_NI_RECOVERY_FAILED BIT(1)
370 enum lnet_stats_type {
371 LNET_STATS_TYPE_SEND = 0,
372 LNET_STATS_TYPE_RECV,
376 struct lnet_comm_count {
377 atomic_t co_get_count;
378 atomic_t co_put_count;
379 atomic_t co_reply_count;
380 atomic_t co_ack_count;
381 atomic_t co_hello_count;
384 struct lnet_element_stats {
385 struct lnet_comm_count el_send_stats;
386 struct lnet_comm_count el_recv_stats;
387 struct lnet_comm_count el_drop_stats;
390 struct lnet_health_local_stats {
391 atomic_t hlt_local_interrupt;
392 atomic_t hlt_local_dropped;
393 atomic_t hlt_local_aborted;
394 atomic_t hlt_local_no_route;
395 atomic_t hlt_local_timeout;
396 atomic_t hlt_local_error;
399 struct lnet_health_remote_stats {
400 atomic_t hlt_remote_dropped;
401 atomic_t hlt_remote_timeout;
402 atomic_t hlt_remote_error;
403 atomic_t hlt_network_timeout;
407 /* chain on the ln_nets */
408 struct list_head net_list;
410 /* net ID, which is composed of
411 * (net_type << 16) | net_num.
412 * net_type can be one of the enumerated types defined in
413 * lnet/include/lnet/nidstr.h */
416 /* round robin selection */
419 /* total number of CPTs in the array */
422 /* cumulative CPTs of all NIs in this net */
425 /* relative net selection priority */
426 __u32 net_sel_priority;
428 /* network tunables */
429 struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
432 * boolean to indicate that the tunables have been set and
435 bool net_tunables_set;
437 /* procedural interface */
438 const struct lnet_lnd *net_lnd;
440 /* list of NIs on this net */
441 struct list_head net_ni_list;
443 /* list of NIs being added, but not started yet */
444 struct list_head net_ni_added;
446 /* dying LND instances */
447 struct list_head net_ni_zombie;
449 /* when I was last alive */
450 time64_t net_last_alive;
452 /* protects access to net_last_alive */
455 /* list of router nids preferred for this network */
456 struct list_head net_rtr_pref_nids;
459 /* Normally Netlink atttributes are defined in UAPI headers but Lustre is
460 * different in that the ABI is in a constant state of change unlike other
461 * Netlink interfaces. LNet sends a special header to help user land handle
465 /** enum lnet_err_atrrs - LNet error netlink properties
466 * For LNet request of multiple items
467 * sometimes those items exist and
468 * others don't. In the case the item
469 * item doesn't exist we return the
472 * @LNET_ERR_ATTR_UNSPEC: unspecified attribute to catch errors
474 * @LNET_ERR_ATTR_HDR: Name of the error header
476 * @LNET_ERR_ATTR_TYPE: Which LNet function since error is for
478 * @LNET_ERR_TYPE_ERRNO: Error code for failure (NLA_S16)
479 * @LNET_ERR_DESCR: Complete error message (NLA_STRING)
481 enum lnet_err_attrs {
482 LNET_ERR_ATTR_UNSPEC = 0,
488 __LNET_ERR_ATTR_MAX_PLUS_ONE,
491 #define LNET_ERR_ATTR_MAX (__LNET_ERR_ATTR_MAX_PLUS_ONE - 1)
493 /** enum lnet_net_attrs - LNet NI netlink properties
494 * attributes that describe LNet 'NI'
495 * These values are used to piece together
496 * messages for sending and receiving.
498 * @LNET_NET_ATTR_UNSPEC: unspecified attribute to catch errors
500 * @LNET_NET_ATTR_HDR: grouping for LNet net data (NLA_NUL_STRING)
501 * @LNET_NET_ATTR_TYPE: LNet net this NI belongs to (NLA_STRING)
502 * @LNET_NET_ATTR_LOCAL: Local NI information (NLA_NESTED)
504 enum lnet_net_attrs {
505 LNET_NET_ATTR_UNSPEC = 0,
511 __LNET_NET_ATTR_MAX_PLUS_ONE,
514 #define LNET_NET_ATTR_MAX (__LNET_NET_ATTR_MAX_PLUS_ONE - 1)
516 /** enum lnet_net_local_ni_attrs - LNet local NI netlink properties
517 * attributes that describe local
520 * @LNET_NET_LOCAL_NI_ATTR_UNSPEC: unspecified attribute to catch
523 * @LNET_NET_LOCAL_NI_ATTR_NID: NID that represents this NI
525 * @LNET_NET_LOCAL_NI_ATTR_STATUS: State of this NI (NLA_STRING)
526 * @LNET_NET_LOCAL_NI_ATTR_INTERFACE: Defines physical devices. used
527 * to be many devices but no longer
530 * @LNET_NET_LOCAL_NI_ATTR_STATS: NI general msg stats (NLA_NESTED)
531 * @LNET_NET_LOCAL_NI_ATTR_UDSP_INFO: NI UDSP state (NLA_NESTED)
532 * @LNET_NET_LOCAL_NI_ATTR_SEND_STATS: NI send stats (NLA_NESTED)
533 * @LNET_NET_LOCAL_NI_ATTR_RECV_STATS: NI recieved stats (NLA_NESTED)
534 * @LNET_NET_LOCAL_NI_ATTR_DROPPED_STATS: NI dropped stats (NLA_NESTED)
535 * @LNET_NET_LOCAL_NI_ATTR_HEALTH_STATS: NI health stats (NLA_NESTED)
536 * @LNET_NET_LOCAL_NI_ATTR_TUNABLES: NI tunables (NLA_NESTED)
537 * @LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES: NI LND tunables (NLA_NESTED)
538 * @LNET_NET_LOCAL_NI_ATTR_DEV_CPT: NI CPT interface bound to
540 * @LNET_NET_LOCAL_NI_ATTR_CPTS: CPT core used by this NI
543 enum lnet_net_local_ni_attrs {
544 LNET_NET_LOCAL_NI_ATTR_UNSPEC = 0,
546 LNET_NET_LOCAL_NI_ATTR_NID,
547 LNET_NET_LOCAL_NI_ATTR_STATUS,
548 LNET_NET_LOCAL_NI_ATTR_INTERFACE,
550 LNET_NET_LOCAL_NI_ATTR_STATS,
551 LNET_NET_LOCAL_NI_ATTR_UDSP_INFO,
552 LNET_NET_LOCAL_NI_ATTR_SEND_STATS,
553 LNET_NET_LOCAL_NI_ATTR_RECV_STATS,
554 LNET_NET_LOCAL_NI_ATTR_DROPPED_STATS,
555 LNET_NET_LOCAL_NI_ATTR_HEALTH_STATS,
556 LNET_NET_LOCAL_NI_ATTR_TUNABLES,
557 LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES,
558 LNET_NET_LOCAL_NI_DEV_CPT,
559 LNET_NET_LOCAL_NI_CPTS,
561 __LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE,
564 #define LNET_NET_LOCAL_NI_ATTR_MAX (__LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE - 1)
566 /** enum lnet_net_local_ni_intf_attrs - LNet NI device netlink properties
567 * attribute that reports the device
570 * @LNET_NET_LOCAL_NI_INTF_ATTR_UNSPEC: unspecified attribute to catch errors
572 * @LNET_NET_LOCAL_NI_INTF_ATTR_TYPE: Physcial device interface (NLA_STRING)
574 enum lnet_net_local_ni_intf_attrs {
575 LNET_NET_LOCAL_NI_INTF_ATTR_UNSPEC = 0,
577 LNET_NET_LOCAL_NI_INTF_ATTR_TYPE,
579 __LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE,
582 #define LNET_NET_LOCAL_NI_INTF_ATTR_MAX (__LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE - 1)
584 /** enum lnet_net_local_ni_stats_attrs - LNet NI netlink properties
585 * attributes that reports the
586 * network traffic stats
588 * @LNET_NET_LOCAL_NI_STATS_ATTR_UNSPEC: unspecified attribute to catch
591 * @LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT: Number of sent messages
593 * @LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT: Number of recieved messages
595 * @LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT: Number of dropped messages
598 enum lnet_net_local_ni_stats_attrs {
599 LNET_NET_LOCAL_NI_STATS_ATTR_UNSPEC = 0,
601 LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT,
602 LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT,
603 LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT,
604 __LNET_NET_LOCAL_NI_STATS_ATTR_MAX_PLUS_ONE,
607 #define LNET_NET_LOCAL_NI_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_STATS_ATTR_MAX_PLUS_ONE - 1)
609 /** enum lnet_net_local_ni_msg_stats_attrs - LNet NI netlink
610 * properties attributes
611 * that reports the message
614 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_UNSPEC: unspecified attribute
617 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT: Number of PUT messages
619 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT: Number of GET messages
621 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT: Number of REPLY messages
623 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT: Number of ACK messages
625 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT: Number of HELLO messages
628 enum lnet_net_local_ni_msg_stats_attrs {
629 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_UNSPEC = 0,
631 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT,
632 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT,
633 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT,
634 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT,
635 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT,
636 __LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX_PLUS_ONE,
639 #define LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX_PLUS_ONE - 1)
641 /** enum lnet_net_local_ni_health_stats_attrs - LNet NI netlink
642 * properties attributes
646 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC: unspecified attribute
649 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS: How many fatal errors
651 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL: How healthly is NI
653 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS: How many interrupts
655 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_DROPPED: How much traffic has
656 * been dropped (NLA_U32)
657 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ABORTED: How many aborts
659 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE: How often routing broke
661 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS: How often timeouts
663 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR: The number of errors
665 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT: Number of successful
667 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING: Number of next pings
670 enum lnet_net_local_ni_health_stats_attrs {
671 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC = 0,
672 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PAD = LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC,
674 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS,
675 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL,
676 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS,
677 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_DROPPED,
678 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ABORTED,
679 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE,
680 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS,
681 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR,
682 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT,
683 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING,
684 __LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX_PLUS_ONE,
686 #define LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX_PLUS_ONE - 1)
688 /** enum lnet_net_local_ni_tunables_attrs - LNet NI tunables
689 * netlink properties.
690 * Performance options
693 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_UNSPEC: unspecified attribute
696 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT: Timeout for LNet peer.
698 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS: Credits for LNet peer.
700 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_BUFFER_CREDITS: Buffer credits for
701 * LNet peer. (NLA_S32)
702 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_CREDITS: Credits for LNet peer
705 enum lnet_net_local_ni_tunables_attr {
706 LNET_NET_LOCAL_NI_TUNABLES_ATTR_UNSPEC = 0,
708 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT,
709 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS,
710 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_BUFFER_CREDITS,
711 LNET_NET_LOCAL_NI_TUNABLES_ATTR_CREDITS,
712 __LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX_PLUS_ONE,
715 #define LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX (__LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX_PLUS_ONE - 1)
717 /** enum lnet_route_attrs - LNet route netlink
718 * attributes that describe
721 * @LNET_ROUTE_ATTR_UNSPEC: unspecified attribute to
724 * @LNET_ROUTE_ATTR_HDR: grouping for LNet route data
726 * @LNET_ROUTE_ATTR_NET: LNet remote network reached
727 * by the route (NLA_STRING)
728 * @LNET_ROUTE_ATTR_GATEWAY: gateway for the route
730 * @LNET_ROUTE_ATTR_HOP: route hop count (NLA_S32)
732 * @LNET_ROUTE_ATTR_PRIORITY: rank of this network path
734 * @LNET_ROUTE_ATTR_HEALTH_SENSITIVITY: rate of health value change
735 * for the route (NLA_U32)
736 * @LNET_ROUTE_ATTR_STATE: state of route (NLA_STRING)
738 * @LNET_ROUTE_ATTR_TYPE: Report if we support multi-hop
741 enum lnet_route_attrs {
742 LNET_ROUTE_ATTR_UNSPEC = 0,
746 LNET_ROUTE_ATTR_GATEWAY,
748 LNET_ROUTE_ATTR_PRIORITY,
749 LNET_ROUTE_ATTR_HEALTH_SENSITIVITY,
750 LNET_ROUTE_ATTR_STATE,
751 LNET_ROUTE_ATTR_TYPE,
752 __LNET_ROUTE_ATTR_MAX_PLUS_ONE,
755 #define LNET_ROUTE_ATTR_MAX (__LNET_ROUTE_ATTR_MAX_PLUS_ONE - 1)
757 /** enum lnet_peer_ni_attrs - LNet peer NI netlink properties
758 * attributes that describe LNet peer 'NI'.
759 * These values are used to piece together
760 * messages for sending and receiving.
762 * @LNET_PEER_NI_ATTR_UNSPEC: unspecified attribute to catch errors
764 * @LNET_PEER_NI_ATTR_HDR: grouping for LNet peer data
766 * @LNET_PEER_NI_ATTR_PRIMARY_NID: primary NID of this peer (NLA_STRING)
767 * @LNET_PEER_NI_ATTR_MULTIRAIL: Do we support MultiRail ? (NLA_FLAG)
768 * @LNET_PEER_NI_ATTR_STATE: Bitfields of the peer state (NLA_U32)
769 * @LNET_PEER_NI_ATTR_PEER_NI_LIST: List of remote peers we can reach
772 enum lnet_peer_ni_attrs {
773 LNET_PEER_NI_ATTR_UNSPEC = 0,
775 LNET_PEER_NI_ATTR_HDR,
776 LNET_PEER_NI_ATTR_PRIMARY_NID,
777 LNET_PEER_NI_ATTR_MULTIRAIL,
778 LNET_PEER_NI_ATTR_STATE,
779 LNET_PEER_NI_ATTR_PEER_NI_LIST,
780 __LNET_PEER_NI_ATTR_MAX_PLUS_ONE,
783 #define LNET_PEER_NI_ATTR_MAX (__LNET_PEER_NI_ATTR_MAX_PLUS_ONE - 1)
785 /** enum lnet_peer_ni_list_attrs - LNet remote peer netlink
786 * properties attributes that
787 * describe remote LNet peer 'NI'.
788 * These values are used to piece
789 * together messages for sending
792 * @LNET_PEER_NI_LIST_ATTR_UNSPEC: unspecified attribute to catch
795 * @LNET_PEER_NI_LIST_ATTR_NID: remote peer's NID (NLA_STRING)
796 * @LNET_PEER_NI_LIST_ATTR_UDSP_INFO: remote peer's UDSP info
798 * @LNET_PEER_NI_LIST_ATTR_STATE: state of remote peer
801 * @LNET_PEER_NI_LIST_ATTR_MAX_TX_CREDITS: Maximum TX credits for remote
803 * @LNET_PEER_NI_LIST_ATTR_CUR_TX_CREDITS: Current TX credits for remote
805 * @LNET_PEER_NI_LIST_ATTR_MIN_TX_CREDITS: Minimum TX credits for remote
807 * @LNET_PEER_NI_LIST_ATTR_QUEUE_BUF_COUNT: Size of TX queue buffer
809 * @LNET_PEER_NI_LIST_ATTR_CUR_RTR_CREDITS: Current router credits for
810 * remote peer (NLA_U32)
811 * @LNET_PEER_NI_LIST_ATTR_MIN_RTR_CREDITS: Minimum router credits for
812 * remote peer (NLA_U32)
813 * @LNET_PEER_NI_LIST_ATTR_REFCOUNT: Remote peer reference count
815 * @LNET_PEER_NI_LIST_ATTR_STATS_COUNT: Remote peer general stats,
816 * reports sent, recieved, and
817 * dropped packets. (NLA_NESTED)
819 * @LNET_PEER_NI_LIST_ATTR_SENT_STATS: Remote peer sent stats,
820 * reports gets, puts, acks, and
821 * hello packets. (NLA_NESTED)
822 * @LNET_PEER_NI_LIST_ATTR_RECV_STATS: Remote peer recieved stats,
823 * reports gets, puts, acks, and
824 * hello packets. (NLA_NESTED)
825 * @LNET_PEER_NI_LIST_ATTR_DROP_STATS: Remote peer dropped stats,
826 * reports gets, puts, acks, and
827 * hello packets. (NLA_NESTED)
828 * @LNET_PEER_NI_LIST_ATTR_HEALTH_STATS: Report the stats about the
829 * health of the remote peer.
832 enum lnet_peer_ni_list_attr {
833 LNET_PEER_NI_LIST_ATTR_UNSPEC = 0,
835 LNET_PEER_NI_LIST_ATTR_NID,
836 LNET_PEER_NI_LIST_ATTR_UDSP_INFO,
837 LNET_PEER_NI_LIST_ATTR_STATE,
839 LNET_PEER_NI_LIST_ATTR_MAX_TX_CREDITS,
840 LNET_PEER_NI_LIST_ATTR_CUR_TX_CREDITS,
841 LNET_PEER_NI_LIST_ATTR_MIN_TX_CREDITS,
842 LNET_PEER_NI_LIST_ATTR_QUEUE_BUF_COUNT,
843 LNET_PEER_NI_LIST_ATTR_CUR_RTR_CREDITS,
844 LNET_PEER_NI_LIST_ATTR_MIN_RTR_CREDITS,
845 LNET_PEER_NI_LIST_ATTR_REFCOUNT,
846 LNET_PEER_NI_LIST_ATTR_STATS_COUNT,
848 LNET_PEER_NI_LIST_ATTR_SENT_STATS,
849 LNET_PEER_NI_LIST_ATTR_RECV_STATS,
850 LNET_PEER_NI_LIST_ATTR_DROP_STATS,
851 LNET_PEER_NI_LIST_ATTR_HEALTH_STATS,
853 __LNET_PEER_NI_LIST_ATTR_MAX_PLUS_ONE,
856 #define LNET_PEER_NI_LIST_ATTR_MAX (__LNET_PEER_NI_LIST_ATTR_MAX_PLUS_ONE - 1)
858 /** enum lnet_peer_ni_list_stats_count - LNet remote peer traffic
859 * stats netlink properties
860 * attributes that provide
861 * traffic stats on the
862 * remote LNet peer 'NI'.
863 * These values are used to
864 * piece together messages
865 * for sending and receiving.
867 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_UNSPEC: unspecified attribute to
870 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_SEND_COUNT: Number of sent packets for
871 * remote peer (NLA_U32)
872 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_RECV_COUNT: Numebr of recieved packets
873 * for remote peer (NLA_U32)
874 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_DROP_COUNT: Number of dropped packets
875 * for remote peer (NLA_U32)
877 enum lnet_peer_ni_list_stats_count {
878 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_UNSPEC = 0,
880 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_SEND_COUNT,
881 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_RECV_COUNT,
882 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_DROP_COUNT,
883 __LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX_PLUS_ONE,
886 #define LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX (__LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX_PLUS_ONE - 1)
888 /** enum lnet_peer_ni_list_stats - LNet remote peer stats netlink
889 * properties attributes that
890 * provide stats on the remote
891 * LNet peer 'NI'. These values are
892 * used to piece together messages
893 * for sending and receiving.
895 * @LNET_PEER_NI_LIST_STATS_ATTR_UNSPEC: unspecified attribute to catch
898 * @LNET_PEER_NI_LIST_STATS_ATTR_PUT: PUT message count for remote
900 * @LNET_PEER_NI_LIST_STATS_ATTR_GET: GET message count for remote
902 * @LNET_PEER_NI_LIST_STATS_ATTR_REPLY: REPLY message count for remote
904 * @LNET_PEER_NI_LIST_STATS_ATTR_ACK: ACK message count for remote
906 * @LNET_PEER_NI_LIST_STATS_ATTR_HEALTH: HELLO message count for remote
909 enum lnet_peer_ni_list_stats {
910 LNET_PEER_NI_LIST_STATS_ATTR_UNSPEC = 0,
912 LNET_PEER_NI_LIST_STATS_ATTR_PUT,
913 LNET_PEER_NI_LIST_STATS_ATTR_GET,
914 LNET_PEER_NI_LIST_STATS_ATTR_REPLY,
915 LNET_PEER_NI_LIST_STATS_ATTR_ACK,
916 LNET_PEER_NI_LIST_STATS_ATTR_HELLO,
917 __LNET_PEER_NI_LIST_STATS_ATTR_MAX_PLUS_ONE,
920 #define LNET_PEER_NI_LIST_STATS_ATTR_MAX (__LNET_PEER_NI_LIST_STATS_ATTR_MAX_PLUS_ONE - 1)
922 /** enum lnet_peer_ni_list_health_stats - LNet remote peer health
923 * stats netlink properties
924 * attributes that provide
925 * stats on the health of a
926 * remote LNet peer 'NI'.
927 * These values are used to
928 * piece together messages
929 * for sending and receiving.
931 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_UNSPEC: unspecified attribute to
934 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_VALUE: Health level of remote
936 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_DROP: drop message state for
937 * remote peer (NLA_U32)
938 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_TIMEOUT: timeout set for remote
940 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_ERROR: total errors for remote
942 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NETWORK_TIMEOUT: network timeout for
943 * remote peer (NLA_U32)
944 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_PING_COUNT: number of pings for
945 * remote peer (NLA_U32)
946 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NEXT_PING: timestamp for next ping
947 * sent by remote peer
950 enum lnet_peer_ni_list_health_stats {
951 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_UNSPEC = 0,
952 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_PAD = LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_UNSPEC,
954 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_VALUE,
955 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_DROPPED,
956 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_TIMEOUT,
957 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_ERROR,
958 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NETWORK_TIMEOUT,
959 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_PING_COUNT,
960 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NEXT_PING,
962 __LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX_PLUS_ONE,
965 #define LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX (__LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX_PLUS_ONE - 1)
967 /** LNet netlink ping API */
969 /** enum lnet_ping_attr - LNet ping netlink properties
970 * attributes to describe ping format
971 * These values are used to piece together
972 * messages for sending and receiving.
974 * @LNET_PING_ATTR_UNSPEC: unspecified attribute to catch errors
976 * @LNET_PING_ATTR_HDR: grouping for LNet ping data (NLA_NUL_STRING)
977 * @LNET_PING_ATTR_PRIMARY_NID: Source NID for ping request (NLA_STRING)
978 * @LNET_PING_ATTR_ERRNO: error code if we fail to ping (NLA_S16)
979 * @LNET_PING_ATTR_MULTIRAIL: Report if MR is supported (NLA_FLAG)
980 * @LNET_PING_ATTR_PEER_NI_LIST: List of peer NI's (NLA_NESTED)
982 enum lnet_ping_attr {
983 LNET_PING_ATTR_UNSPEC = 0,
986 LNET_PING_ATTR_PRIMARY_NID,
987 LNET_PING_ATTR_ERRNO,
988 LNET_PING_ATTR_MULTIRAIL,
989 LNET_PING_ATTR_PEER_NI_LIST,
990 __LNET_PING_ATTR_MAX_PLUS_ONE,
993 #define LNET_PING_ATTR_MAX (__LNET_PING_ATTR_MAX_PLUS_ONE - 1)
995 /** enum lnet_ping_peer_ni_attr - LNet peer ni information reported by
996 * ping command. A list of these are
997 * returned with a ping request.
999 * @LNET_PING_PEER_NI_ATTR_UNSPEC: unspecified attribute to catch errrors
1001 * @LNET_PING_PEER_NI_ATTR_NID: NID address of peer NI. (NLA_STRING)
1003 enum lnet_ping_peer_ni_attr {
1004 LNET_PING_PEER_NI_ATTR_UNSPEC = 0,
1006 LNET_PING_PEER_NI_ATTR_NID,
1007 __LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE,
1010 #define LNET_PING_PEER_NI_ATTR_MAX (__LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE - 1)
1012 /** enum lnet_udsp_info_attr - LNet UDSP information reported for
1013 * some subsystem that tracks it.
1015 * @LNET_UDSP_INFO_ATTR_UNSPEC: unspecified attribute to catch errors
1017 * @LNET_UDSP_INFO_ATTR_NET_PRIORITY, LNet net priority in selection.
1019 * @LNET_UDSP_INFO_ATTR_NID_PRIORITY, NID's priority in selection.
1021 * @LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST: Which gateway's are preferred.
1023 * @LNET_UDSP_INFO_ATTR_PREF_NIDS_LIST: Which NIDs are preferred.
1026 enum lnet_udsp_info_attr {
1027 LNET_UDSP_INFO_ATTR_UNSPEC = 0,
1029 LNET_UDSP_INFO_ATTR_NET_PRIORITY,
1030 LNET_UDSP_INFO_ATTR_NID_PRIORITY,
1031 LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST,
1032 LNET_UDSP_INFO_ATTR_PREF_NIDS_LIST,
1033 __LNET_UDSP_INFO_ATTR_MAX_PLUS_ONE,
1036 #define LNET_UDSP_INFO_ATTR_MAX (__LNET_UDSP_INFO_ATTR_MAX_PLUS_ONE - 1)
1038 /** enum lnet_udsp_info_pref_nids_attr - LNet UDSP information reported for
1039 * some subsystem that tracks it.
1041 * @LNET_UDSP_INFO_PREF_NIDS_ATTR_UNSPEC: unspecified attribute to catch errors
1043 * @LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX, UDSP prority NIDs label
1045 * @LNET_UDSP_INFO_PREF_NIDS_ATTR_NID, UDSP prority NID (NLA_STRING)
1047 enum lnet_udsp_info_pref_nids_attr {
1048 LNET_UDSP_INFO_PREF_NIDS_ATTR_UNSPEC = 0,
1050 LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX,
1051 LNET_UDSP_INFO_PREF_NIDS_ATTR_NID,
1052 __LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX_PLUS_ONE,
1055 #define LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX (__LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX_PLUS_ONE - 1)
1057 /** enum lnet_cpt_of_nid_attr - Attributes to support
1058 * lnetctl cpt-of-nid command
1060 * @LNET_CPT_OF_NID_ATTR_UNSPEC unspecified attribute to catch
1062 * @LNET_CPT_OF_NID_ATTR_HDR Grouping for cpt-of-nid
1064 * @LNET_CPT_OF_NID_ATTR_NID The NID whose CPT we want to
1065 * calculate (NLA_STRING)
1066 * LNET_CPT_OF_NID_ATTR_CPT The CPT for the specified NID
1069 enum lnet_cpt_of_nid_attr {
1070 LNET_CPT_OF_NID_ATTR_UNSPEC = 0,
1072 LNET_CPT_OF_NID_ATTR_HDR,
1073 LNET_CPT_OF_NID_ATTR_NID,
1074 LNET_CPT_OF_NID_ATTR_CPT,
1075 __LNET_CPT_OF_NID_ATTR_MAX_PLUS_ONE,
1078 #define LNET_CPT_OF_NID_ATTR_MAX (__LNET_CPT_OF_NID_ATTR_MAX_PLUS_ONE - 1)
1080 /** enum lnet_peer_dist_attr - Attributes to support
1081 * reporting distance for peers
1083 * @LNET_PEER_DIST_ATTR_UNSPEC unspecified attribute to catch
1085 * @LNET_PEER_DIST_ATTR_HDR Grouping which we just use peer
1087 * @LNET_PEER_DIST_ATTR_NID The NID we collect data for
1089 * @LNET_PEER_DIST_ATTR_DIST The distance for the specified
1091 * @LNET_PEER_DIST_ATTR_ORDER The order for the specified NID
1094 enum lnet_peer_dist_attr {
1095 LNET_PEER_DIST_ATTR_UNSPEC = 0,
1097 LNET_PEER_DIST_ATTR_HDR,
1098 LNET_PEER_DIST_ATTR_NID,
1099 LNET_PEER_DIST_ATTR_DIST,
1100 LNET_PEER_DIST_ATTR_ORDER,
1101 __LNET_PEER_DIST_ATTR_MAX_PLUS_ONE,
1104 #define LNET_PEER_DIST_ATTR_MAX (__LNET_PEER_DIST_ATTR_MAX_PLUS_ONE - 1)
1107 /* chain on the lnet_net structure */
1108 struct list_head ni_netlist;
1110 /* chain on the recovery queue */
1111 struct list_head ni_recovery;
1113 /* MD handle for recovery ping */
1114 struct lnet_handle_md ni_ping_mdh;
1118 /* number of CPTs */
1121 /* bond NI on some CPTs */
1124 /* interface's NID */
1125 struct lnet_nid ni_nid;
1127 /* instance-specific data */
1130 /* per ni credits */
1131 atomic_t ni_tx_credits;
1133 /* percpt TX queues */
1134 struct lnet_tx_queue **ni_tx_queues;
1136 /* percpt reference count */
1139 /* pointer to parent network */
1140 struct lnet_net *ni_net;
1142 /* my health status */
1145 /* NI FSM. Protected by lnet_ni_lock() */
1146 enum lnet_ni_state ni_state;
1148 /* Recovery state. Protected by lnet_ni_lock() */
1149 __u32 ni_recovery_state;
1151 /* When to send the next recovery ping */
1152 time64_t ni_next_ping;
1153 /* How many pings sent during current recovery period did not receive
1154 * a reply. NB: reset whenever _any_ message arrives on this NI
1156 unsigned int ni_ping_count;
1158 /* per NI LND tunables */
1159 struct lnet_lnd_tunables ni_lnd_tunables;
1161 /* lnd tunables set explicitly */
1162 bool ni_lnd_tunables_set;
1165 struct lnet_element_stats ni_stats;
1166 struct lnet_health_local_stats ni_hstats;
1168 /* physical device CPT */
1171 /* sequence number used to round robin over nis within a net */
1176 * initialized to LNET_MAX_HEALTH_VALUE
1177 * Value is decremented every time we fail to send a message over
1178 * this NI because of a NI specific failure.
1179 * Value is incremented if we successfully send a message.
1181 atomic_t ni_healthv;
1184 * Set to 1 by the LND when it receives an event telling it the device
1185 * has gone into a fatal state. Set to 0 when the LND receives an
1186 * even telling it the device is back online.
1188 atomic_t ni_fatal_error_on;
1190 /* the relative selection priority of this NI */
1191 __u32 ni_sel_priority;
1194 * equivalent interface to use
1197 struct net *ni_net_ns; /* original net namespace */
1200 #define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL
1203 * Descriptor of a ping info buffer: keep a separate indicator of the
1204 * size and a reference count. The type is used both as a source and
1205 * sink of data, so we need to keep some information outside of the
1206 * area that may be overwritten by network data.
1208 struct lnet_ping_buffer {
1209 int pb_nbytes; /* sizeof pb_info */
1212 struct lnet_ping_info pb_info;
1215 #define LNET_PING_BUFFER_SIZE(bytes) \
1216 (offsetof(struct lnet_ping_buffer, pb_info) + bytes)
1217 #define LNET_PING_BUFFER_LONI(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_nid)
1218 #define LNET_PING_BUFFER_SEQNO(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_status)
1220 #define LNET_PING_INFO_TO_BUFFER(PINFO) \
1221 container_of((PINFO), struct lnet_ping_buffer, pb_info)
1224 lnet_ping_sts_size(const struct lnet_nid *nid)
1228 /* for deciding the size of the ping buffer */
1229 if (unlikely(LNET_NID_IS_ANY(nid)))
1230 return sizeof(struct lnet_ni_large_status);
1232 if (nid_is_nid4(nid))
1233 return sizeof(struct lnet_ni_status);
1235 size = offsetof(struct lnet_ni_large_status, ns_nid) +
1238 return round_up(size, 4);
1241 static inline struct lnet_ni_large_status *
1242 lnet_ping_sts_next(const struct lnet_ni_large_status *nis)
1244 return (void *)nis + lnet_ping_sts_size(&nis->ns_nid);
1248 lnet_ping_at_least_two_entries(const struct lnet_ping_info *pi)
1250 /* Return true if we have at lease two entries. There is always a
1251 * least one, a 4-byte lo0 interface.
1253 struct lnet_ni_large_status *lns;
1255 if ((pi->pi_features & LNET_PING_FEAT_LARGE_ADDR) == 0)
1256 return pi->pi_nnis <= 2;
1257 /* There is at least 1 large-address entry */
1258 if (pi->pi_nnis != 1)
1260 lns = (void *)&pi->pi_ni[1];
1261 lns = lnet_ping_sts_next(lns);
1263 return ((void *)pi + lnet_ping_info_size(pi) <= (void *)lns);
1266 struct lnet_nid_list {
1267 struct list_head nl_list;
1268 struct lnet_nid nl_nid;
1271 struct lnet_peer_ni {
1272 /* chain on lpn_peer_nis */
1273 struct list_head lpni_peer_nis;
1274 /* chain on remote peer list */
1275 struct list_head lpni_on_remote_peer_ni_list;
1276 /* chain on recovery queue */
1277 struct list_head lpni_recovery;
1278 /* chain on peer hash */
1279 struct list_head lpni_hashlist;
1280 /* messages blocking for tx credits */
1281 struct list_head lpni_txq;
1282 /* pointer to peer net I'm part of */
1283 struct lnet_peer_net *lpni_peer_net;
1284 /* statistics kept on each peer NI */
1285 struct lnet_element_stats lpni_stats;
1286 struct lnet_health_remote_stats lpni_hstats;
1287 /* spin lock protecting credits and lpni_txq */
1288 spinlock_t lpni_lock;
1289 /* # tx credits available */
1291 /* low water mark */
1292 int lpni_mintxcredits;
1294 * Each peer_ni in a gateway maintains its own credits. This
1295 * allows more traffic to gateways that have multiple interfaces.
1297 /* # router credits */
1298 int lpni_rtrcredits;
1299 /* low water mark */
1300 int lpni_minrtrcredits;
1301 /* bytes queued for sending */
1303 /* network peer is on */
1304 struct lnet_net *lpni_net;
1306 struct lnet_nid lpni_nid;
1308 struct kref lpni_kref;
1309 /* health value for the peer */
1310 atomic_t lpni_healthv;
1311 /* recovery ping mdh */
1312 struct lnet_handle_md lpni_recovery_ping_mdh;
1313 /* When to send the next recovery ping */
1314 time64_t lpni_next_ping;
1315 /* How many pings sent during current recovery period did not receive
1316 * a reply. NB: reset whenever _any_ message arrives from this peer NI
1318 unsigned int lpni_ping_count;
1319 /* CPT this peer attached on */
1321 /* state flags -- protected by lpni_lock */
1322 unsigned lpni_state;
1323 /* status of the peer NI as reported by the peer */
1324 __u32 lpni_ns_status;
1325 /* sequence number used to round robin over peer nis within a net */
1327 /* sequence number used to round robin over gateways */
1329 /* returned RC ping features. Protected with lpni_lock */
1330 unsigned int lpni_ping_feats;
1331 /* time last message was received from the peer */
1332 time64_t lpni_last_alive;
1333 /* preferred local nids: if only one, use lpni_pref.nid */
1335 struct lnet_nid nid;
1336 struct list_head nids;
1338 /* list of router nids preferred for this peer NI */
1339 struct list_head lpni_rtr_pref_nids;
1340 /* The relative selection priority of this peer NI */
1341 __u32 lpni_sel_priority;
1342 /* number of preferred NIDs in lnpi_pref_nids */
1343 __u32 lpni_pref_nnids;
1346 /* Preferred path added due to traffic on non-MR peer_ni */
1347 #define LNET_PEER_NI_NON_MR_PREF BIT(0)
1348 /* peer is being recovered. */
1349 #define LNET_PEER_NI_RECOVERY_PENDING BIT(1)
1350 /* recovery ping failed */
1351 #define LNET_PEER_NI_RECOVERY_FAILED BIT(2)
1352 /* peer is being deleted */
1353 #define LNET_PEER_NI_DELETING BIT(3)
1356 /* chain on pt_peer_list */
1357 struct list_head lp_peer_list;
1359 /* list of peer nets */
1360 struct list_head lp_peer_nets;
1362 /* list of messages pending discovery*/
1363 struct list_head lp_dc_pendq;
1365 /* chain on router list */
1366 struct list_head lp_rtr_list;
1368 /* primary NID of the peer */
1369 struct lnet_nid lp_primary_nid;
1371 /* source NID to use during discovery */
1372 struct lnet_nid lp_disc_src_nid;
1373 /* destination NID to use during discovery */
1374 struct lnet_nid lp_disc_dst_nid;
1376 /* net to perform discovery on */
1377 __u32 lp_disc_net_id;
1379 /* CPT of peer_table */
1382 /* number of NIDs on this peer */
1385 /* # refs from lnet_route::lr_gateway */
1386 int lp_rtr_refcount;
1389 * peer specific health sensitivity value to decrement peer nis in
1390 * this peer with if set to something other than 0
1392 __u32 lp_health_sensitivity;
1394 /* messages blocking for router credits */
1395 struct list_head lp_rtrq;
1397 /* routes on this peer */
1398 struct list_head lp_routes;
1400 /* reference count */
1401 atomic_t lp_refcount;
1403 /* lock protecting peer state flags and lpni_rtrq */
1406 /* peer state flags */
1409 /* buffer for data pushed by peer */
1410 struct lnet_ping_buffer *lp_data;
1412 /* MD handle for ping in progress */
1413 struct lnet_handle_md lp_ping_mdh;
1415 /* MD handle for push in progress */
1416 struct lnet_handle_md lp_push_mdh;
1418 /* number of bytes for sizing pb_info in push data */
1421 /* NI config sequence number of peer */
1422 __u32 lp_peer_seqno;
1424 /* Local NI config sequence number acked by peer */
1425 __u32 lp_node_seqno;
1427 /* Local NI config sequence number sent to peer */
1428 __u32 lp_node_seqno_sent;
1430 /* Ping error encountered during discovery. */
1433 /* Push error encountered during discovery. */
1436 /* Error encountered during discovery. */
1439 /* time it was put on the ln_dc_working queue */
1440 time64_t lp_last_queued;
1442 /* link on discovery-related lists */
1443 struct list_head lp_dc_list;
1445 /* tasks waiting on discovery of this peer */
1446 wait_queue_head_t lp_dc_waitq;
1448 /* cached peer aliveness */
1451 /* sequence number used to round robin traffic to this peer's
1456 /* timestamp of primary nid lock */
1457 __u64 lp_prim_lock_ts;
1461 * The status flags in lp_state. Their semantics have chosen so that
1462 * lp_state can be zero-initialized.
1464 * A peer is marked MULTI_RAIL in two cases: it was configured using DLC
1465 * as multi-rail aware, or the LNET_PING_FEAT_MULTI_RAIL bit was set.
1467 * A peer is marked NO_DISCOVERY if the LNET_PING_FEAT_DISCOVERY bit was
1468 * NOT set when the peer was pinged by discovery.
1470 * A peer is marked ROUTER if it indicates so in the feature bit.
1472 #define LNET_PEER_MULTI_RAIL BIT(0) /* Multi-rail aware */
1473 #define LNET_PEER_NO_DISCOVERY BIT(1) /* Peer disabled discovery */
1474 #define LNET_PEER_ROUTER_ENABLED BIT(2) /* router feature enabled */
1477 * A peer is marked CONFIGURED if it was configured by DLC.
1479 * In addition, a peer is marked DISCOVERED if it has fully passed
1480 * through Peer Discovery.
1482 * When Peer Discovery is disabled, the discovery thread will mark
1483 * peers REDISCOVER to indicate that they should be re-examined if
1484 * discovery is (re)enabled on the node.
1486 * A peer that was created as the result of inbound traffic will not
1489 #define LNET_PEER_CONFIGURED BIT(3) /* Configured via DLC */
1490 #define LNET_PEER_DISCOVERED BIT(4) /* Peer was discovered */
1491 #define LNET_PEER_REDISCOVER BIT(5) /* Discovery was disabled */
1493 * A peer is marked DISCOVERING when discovery is in progress.
1494 * The other flags below correspond to stages of discovery.
1496 #define LNET_PEER_DISCOVERING BIT(6) /* Discovering */
1497 #define LNET_PEER_DATA_PRESENT BIT(7) /* Remote peer data present */
1498 #define LNET_PEER_NIDS_UPTODATE BIT(8) /* Remote peer info uptodate */
1499 #define LNET_PEER_PING_SENT BIT(9) /* Waiting for REPLY to Ping */
1500 #define LNET_PEER_PUSH_SENT BIT(10) /* Waiting for ACK of Push */
1501 #define LNET_PEER_PING_FAILED BIT(11) /* Ping send failure */
1502 #define LNET_PEER_PUSH_FAILED BIT(12) /* Push send failure */
1504 * A ping can be forced as a way to fix up state, or as a manual
1505 * intervention by an admin.
1506 * A push can be forced in circumstances that would normally not
1507 * allow for one to happen.
1509 #define LNET_PEER_FORCE_PING BIT(13) /* Forced Ping */
1510 #define LNET_PEER_FORCE_PUSH BIT(14) /* Forced Push */
1512 /* force delete even if router */
1513 #define LNET_PEER_RTR_NI_FORCE_DEL BIT(15)
1515 /* gw undergoing alive discovery */
1516 #define LNET_PEER_RTR_DISCOVERY BIT(16)
1517 /* gw has undergone discovery (does not indicate success or failure) */
1518 #define LNET_PEER_RTR_DISCOVERED BIT(17)
1520 /* peer is marked for deletion */
1521 #define LNET_PEER_MARK_DELETION BIT(18)
1522 /* lnet_peer_del()/lnet_peer_del_locked() has been called on the peer */
1523 #define LNET_PEER_MARK_DELETED BIT(19)
1524 /* lock primary NID to what's requested by ULP */
1525 #define LNET_PEER_LOCK_PRIMARY BIT(20)
1526 /* this is for informational purposes only. It is set if a peer gets
1527 * configured from Lustre with a primary NID which belongs to another peer
1528 * which is also configured by Lustre as the primary NID.
1530 #define LNET_PEER_BAD_CONFIG BIT(21)
1532 struct lnet_peer_net {
1533 /* chain on lp_peer_nets */
1534 struct list_head lpn_peer_nets;
1536 /* list of peer_nis on this network */
1537 struct list_head lpn_peer_nis;
1539 /* pointer to the peer I'm part of */
1540 struct lnet_peer *lpn_peer;
1545 /* peer net health */
1548 /* time of next router ping on this net */
1549 time64_t lpn_next_ping;
1551 /* selection sequence number */
1554 /* relative peer net selection priority */
1555 __u32 lpn_sel_priority;
1557 /* reference count */
1558 atomic_t lpn_refcount;
1561 /* peer hash size */
1562 #define LNET_PEER_HASH_BITS 9
1563 #define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS)
1566 * peer hash table - one per CPT
1568 * protected by lnet_net_lock/EX for update
1573 * protected by pt_zombie_lock:
1577 * pt_zombie lock nests inside lnet_net_lock
1579 struct lnet_peer_table {
1580 int pt_version; /* /proc validity stamp */
1581 struct list_head *pt_hash; /* NID->peer hash */
1582 struct list_head pt_peer_list; /* peers */
1583 int pt_peers; /* # peers */
1584 struct list_head pt_zombie_list; /* zombie peer_ni */
1585 int pt_zombies; /* # zombie peers_ni */
1586 spinlock_t pt_zombie_lock; /* protect list and count */
1589 /* peer aliveness is enabled only on routers for peers in a network where the
1590 * struct lnet_ni::ni_peertimeout has been set to a positive value
1592 #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing != 0 && \
1593 ((lp)->lpni_net) && \
1594 (lp)->lpni_net->net_tunables.lct_peer_timeout > 0)
1597 struct list_head lr_list; /* chain on net */
1598 struct list_head lr_gwlist; /* chain on gateway */
1599 struct lnet_peer *lr_gateway; /* router node */
1600 struct lnet_nid lr_nid; /* NID used to add route */
1601 __u32 lr_net; /* remote network number */
1602 __u32 lr_lnet; /* local network number */
1603 int lr_seq; /* sequence for round-robin */
1604 __u32 lr_hops; /* how far I am */
1605 unsigned int lr_priority; /* route priority */
1606 atomic_t lr_alive; /* cached route aliveness */
1607 bool lr_single_hop; /* this route is single-hop */
1610 #define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)
1611 #define LNET_REMOTE_NETS_HASH_MAX (1U << 16)
1612 #define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits)
1614 struct lnet_remotenet {
1615 /* chain on ln_remote_nets_hash */
1616 struct list_head lrn_list;
1618 struct list_head lrn_routes;
1623 /** lnet message has credit and can be submitted to lnd for send/receive */
1624 #define LNET_CREDIT_OK 0
1625 /** lnet message is waiting for credit */
1626 #define LNET_CREDIT_WAIT 1
1627 /** lnet message is waiting for discovery */
1628 #define LNET_DC_WAIT 2
1630 struct lnet_rtrbufpool {
1631 /* my free buffer pool */
1632 struct list_head rbp_bufs;
1633 /* messages blocking for a buffer */
1634 struct list_head rbp_msgs;
1635 /* # pages in each buffer */
1637 /* requested number of buffers */
1638 int rbp_req_nbuffers;
1639 /* # buffers actually allocated */
1641 /* # free buffers / blocked messages */
1643 /* low water mark */
1647 struct lnet_rtrbuf {
1648 struct list_head rb_list; /* chain on rbp_bufs */
1649 struct lnet_rtrbufpool *rb_pool; /* owning pool */
1650 struct bio_vec rb_kiov[0]; /* the buffer space */
1653 #define LNET_PEER_HASHSIZE 503 /* prime! */
1655 enum lnet_match_flags {
1656 /* Didn't match anything */
1657 LNET_MATCHMD_NONE = BIT(0),
1659 LNET_MATCHMD_OK = BIT(1),
1660 /* Must be discarded */
1661 LNET_MATCHMD_DROP = BIT(2),
1662 /* match and buffer is exhausted */
1663 LNET_MATCHMD_EXHAUSTED = BIT(3),
1665 LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
1668 /* Options for struct lnet_portal::ptl_options */
1669 #define LNET_PTL_LAZY BIT(0)
1670 #define LNET_PTL_MATCH_UNIQUE BIT(1) /* unique match, for RDMA */
1671 #define LNET_PTL_MATCH_WILDCARD BIT(2) /* wildcard match, request portal */
1673 /* parameter for matching operations (GET, PUT) */
1674 struct lnet_match_info {
1676 struct lnet_processid mi_id;
1677 unsigned int mi_cpt;
1678 unsigned int mi_opc;
1679 unsigned int mi_portal;
1680 unsigned int mi_rlength;
1681 unsigned int mi_roffset;
1684 /* ME hash of RDMA portal */
1685 #define LNET_MT_HASH_BITS 8
1686 #define LNET_MT_HASH_SIZE (1 << LNET_MT_HASH_BITS)
1687 #define LNET_MT_HASH_MASK (LNET_MT_HASH_SIZE - 1)
1688 /* we allocate (LNET_MT_HASH_SIZE + 1) entries for lnet_match_table::mt_hash,
1689 * the last entry is reserved for MEs with ignore-bits */
1690 #define LNET_MT_HASH_IGNORE LNET_MT_HASH_SIZE
1691 /* __u64 has 2^6 bits, so need 2^(LNET_MT_HASH_BITS - LNET_MT_BITS_U64) which
1692 * is 4 __u64s as bit-map, and add an extra __u64 (only use one bit) for the
1693 * ME-list with ignore-bits, which is mtable::mt_hash[LNET_MT_HASH_IGNORE] */
1694 #define LNET_MT_BITS_U64 6 /* 2^6 bits */
1695 #define LNET_MT_EXHAUSTED_BITS (LNET_MT_HASH_BITS - LNET_MT_BITS_U64)
1696 #define LNET_MT_EXHAUSTED_BMAP ((1 << LNET_MT_EXHAUSTED_BITS) + 1)
1698 /* portal match table */
1699 struct lnet_match_table {
1700 /* reserved for upcoming patches, CPU partition ID */
1701 unsigned int mt_cpt;
1702 unsigned int mt_portal; /* portal index */
1703 /* match table is set as "enabled" if there's non-exhausted MD
1704 * attached on mt_mhash, it's only valid for wildcard portal */
1705 unsigned int mt_enabled;
1706 /* bitmap to flag whether MEs on mt_hash are exhausted or not */
1707 __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
1708 struct list_head *mt_mhash; /* matching hash */
1711 /* these are only useful for wildcard portal */
1712 /* Turn off message rotor for wildcard portals */
1713 #define LNET_PTL_ROTOR_OFF 0
1714 /* round-robin dispatch all PUT messages for wildcard portals */
1715 #define LNET_PTL_ROTOR_ON 1
1716 /* round-robin dispatch routed PUT message for wildcard portals */
1717 #define LNET_PTL_ROTOR_RR_RT 2
1718 /* dispatch routed PUT message by hashing source NID for wildcard portals */
1719 #define LNET_PTL_ROTOR_HASH_RT 3
1721 struct lnet_portal {
1722 spinlock_t ptl_lock;
1723 unsigned int ptl_index; /* portal ID, reserved */
1724 /* flags on this portal: lazy, unique... */
1725 unsigned int ptl_options;
1726 /* list of messages which are stealing buffer */
1727 struct list_head ptl_msg_stealing;
1728 /* messages blocking for MD */
1729 struct list_head ptl_msg_delayed;
1730 /* Match table for each CPT */
1731 struct lnet_match_table **ptl_mtables;
1732 /* spread rotor of incoming "PUT" */
1733 unsigned int ptl_rotor;
1734 /* # active entries for this portal */
1736 /* array of active entries' cpu-partition-id */
1740 #define LNET_LH_HASH_BITS 12
1741 #define LNET_LH_HASH_SIZE (1ULL << LNET_LH_HASH_BITS)
1742 #define LNET_LH_HASH_MASK (LNET_LH_HASH_SIZE - 1)
1744 /* resource container (ME, MD, EQ) */
1745 struct lnet_res_container {
1746 unsigned int rec_type; /* container type */
1747 __u64 rec_lh_cookie; /* cookie generator */
1748 struct list_head rec_active; /* active resource list */
1749 struct list_head *rec_lh_hash; /* handle hash */
1752 /* message container */
1753 struct lnet_msg_container {
1754 int msc_init; /* initialized or not */
1755 /* max # threads finalizing */
1756 int msc_nfinalizers;
1757 /* msgs waiting to complete finalizing */
1758 struct list_head msc_finalizing;
1759 /* msgs waiting to be resent */
1760 struct list_head msc_resending;
1761 struct list_head msc_active; /* active message list */
1762 /* threads doing finalization */
1763 void **msc_finalizers;
1764 /* threads doing resends */
1765 void **msc_resenders;
1768 /* This UDSP structures need to match the user space liblnetconfig structures
1769 * in order for the marshall and unmarshall functions to be common.
1772 /* Net is described as a
1776 struct lnet_ud_net_descr {
1778 struct list_head udn_net_num_range;
1781 /* each NID range is defined as
1783 * 2. address range descriptor
1785 struct lnet_ud_nid_descr {
1786 struct lnet_ud_net_descr ud_net_id;
1787 struct list_head ud_addr_range;
1791 /* a UDSP rule can have up to three user defined NID descriptors
1792 * - src: defines the local NID range for the rule
1793 * - dst: defines the peer NID range for the rule
1794 * - rte: defines the router NID range for the rule
1796 * An action union defines the action to take when the rule
1800 struct list_head udsp_on_list;
1802 struct lnet_ud_nid_descr udsp_src;
1803 struct lnet_ud_nid_descr udsp_dst;
1804 struct lnet_ud_nid_descr udsp_rte;
1805 enum lnet_udsp_action_type udsp_action_type;
1807 __u32 udsp_priority;
1811 /* Peer Discovery states */
1812 #define LNET_DC_STATE_SHUTDOWN 0 /* not started */
1813 #define LNET_DC_STATE_RUNNING 1 /* started up OK */
1814 #define LNET_DC_STATE_STOPPING 2 /* telling thread to stop */
1816 /* Router Checker states */
1817 #define LNET_MT_STATE_SHUTDOWN 0 /* not started */
1818 #define LNET_MT_STATE_RUNNING 1 /* started up OK */
1819 #define LNET_MT_STATE_STOPPING 2 /* telling thread to stop */
1822 #define LNET_STATE_SHUTDOWN 0 /* not started */
1823 #define LNET_STATE_RUNNING 1 /* started up OK */
1824 #define LNET_STATE_STOPPING 2 /* telling thread to stop */
1827 /* CPU partition table of LNet */
1828 struct cfs_cpt_table *ln_cpt_table;
1829 /* number of CPTs in ln_cpt_table */
1830 unsigned int ln_cpt_number;
1831 unsigned int ln_cpt_bits;
1833 /* protect LNet resources (ME/MD/EQ) */
1834 struct cfs_percpt_lock *ln_res_lock;
1837 /* the vector of portals */
1838 struct lnet_portal **ln_portals;
1839 /* percpt MD container */
1840 struct lnet_res_container **ln_md_containers;
1842 /* Event Queue container */
1843 struct lnet_res_container ln_eq_container;
1844 spinlock_t ln_eq_wait_lock;
1846 unsigned int ln_remote_nets_hbits;
1848 /* protect NI, peer table, credits, routers, rtrbuf... */
1849 struct cfs_percpt_lock *ln_net_lock;
1850 /* percpt message containers for active/finalizing/freed message */
1851 struct lnet_msg_container **ln_msg_containers;
1852 struct lnet_counters **ln_counters;
1853 struct lnet_peer_table **ln_peer_tables;
1854 /* list of peer nis not on a local network */
1855 struct list_head ln_remote_peer_ni_list;
1856 /* failure simulation */
1857 struct list_head ln_test_peers;
1858 struct list_head ln_drop_rules;
1859 struct list_head ln_delay_rules;
1861 struct list_head ln_nets;
1862 /* Sequence number used to round robin sends across all nets */
1864 /* the loopback NI */
1865 struct lnet_ni *ln_loni;
1866 /* network zombie list */
1867 struct list_head ln_net_zombie;
1868 /* resend messages list */
1869 struct list_head ln_msg_resend;
1870 /* spin lock to protect the msg resend list */
1871 spinlock_t ln_msg_resend_lock;
1873 /* remote networks with routes to them */
1874 struct list_head *ln_remote_nets_hash;
1875 /* validity stamp */
1876 __u64 ln_remote_nets_version;
1877 /* list of all known routers */
1878 struct list_head ln_routers;
1879 /* validity stamp */
1880 __u64 ln_routers_version;
1881 /* percpt router buffer pools */
1882 struct lnet_rtrbufpool **ln_rtrpools;
1885 * Ping target / Push source
1887 * The ping target and push source share a single buffer. The
1888 * ln_ping_target is protected against concurrent updates by
1891 struct lnet_handle_md ln_ping_target_md;
1892 lnet_handler_t ln_ping_target_handler;
1893 struct lnet_ping_buffer *ln_ping_target;
1894 atomic_t ln_ping_target_seqno;
1899 * ln_push_nnis contains the desired size of the push target.
1900 * The lnet_net_lock is used to handle update races. The old
1901 * buffer may linger a while after it has been unlinked, in
1902 * which case the event handler cleans up.
1904 lnet_handler_t ln_push_target_handler;
1905 struct lnet_handle_md ln_push_target_md;
1906 struct lnet_ping_buffer *ln_push_target;
1907 /* bytes needed for pb_info to receive push */
1908 int ln_push_target_nbytes;
1910 /* discovery event queue handle */
1911 lnet_handler_t ln_dc_handler;
1912 /* discovery requests */
1913 struct list_head ln_dc_request;
1914 /* discovery working list */
1915 struct list_head ln_dc_working;
1916 /* discovery expired list */
1917 struct list_head ln_dc_expired;
1918 /* discovery thread wait queue */
1919 wait_queue_head_t ln_dc_waitq;
1920 /* discovery startup/shutdown state */
1923 /* monitor thread startup/shutdown state */
1925 /* serialise startup/shutdown */
1926 struct semaphore ln_mt_signal;
1928 struct mutex ln_api_mutex;
1929 struct mutex ln_lnd_mutex;
1930 /* Have I called LNetNIInit myself? */
1932 /* LNetNIInit/LNetNIFini counter */
1934 /* SHUTDOWN/RUNNING/STOPPING */
1937 int ln_routing; /* am I a router? */
1938 lnet_pid_t ln_pid; /* requested pid */
1939 /* uniquely identifies this ni in this epoch */
1940 __u64 ln_interface_cookie;
1941 /* registered LNDs */
1942 const struct lnet_lnd *ln_lnds[NUM_LNDS];
1944 /* test protocol compatibility flags */
1945 unsigned long ln_testprotocompat;
1947 /* 0 - load the NIs from the mod params
1948 * 1 - do not load the NIs from the mod params
1949 * Reverse logic to ensure that other calls to LNetNIInit
1952 bool ln_nis_from_mod_params;
1955 * completion for the monitor thread. The monitor thread takes care of
1956 * checking routes, timedout messages and resending messages.
1958 struct completion ln_mt_wait_complete;
1960 /* per-cpt resend queues */
1961 struct list_head **ln_mt_resendqs;
1962 /* local NIs to recover */
1963 struct list_head ln_mt_localNIRecovq;
1964 /* local NIs to recover */
1965 struct list_head ln_mt_peerNIRecovq;
1967 * An array of queues for GET/PUT waiting for REPLY/ACK respectively.
1968 * There are CPT number of queues. Since response trackers will be
1969 * added on the fast path we can't afford to grab the exclusive
1970 * net lock to protect these queues. The CPT will be calculated
1971 * based on the mdh cookie.
1973 struct list_head **ln_mt_rstq;
1975 * A response tracker becomes a zombie when the associated MD is queued
1976 * for unlink before the response tracker is detached from the MD. An
1977 * entry on a zombie list can be freed when either the remaining
1978 * operations on the MD complete or when LNet has shut down.
1980 struct list_head **ln_mt_zombie_rstqs;
1981 /* recovery handler */
1982 lnet_handler_t ln_mt_handler;
1985 * Completed when the discovery and monitor threads can enter their
1988 struct completion ln_started;
1990 struct list_head ln_udsp_list;
1992 /* Number of messages that have exceeded their message deadline */
1993 atomic_t ln_late_msg_count;
1994 /* Total amount of time past their deadline for all late ^ messages */
1995 atomic64_t ln_late_msg_nsecs;
1997 /* for LNDs to signal that ping buffer needs updating */
1998 atomic_t ln_update_ping_buf;
2000 /* workqueue for serving lnd ping buffer update requests */
2001 struct workqueue_struct *ln_pb_update_wq;
2002 struct work_struct ln_pb_update_work;
2004 atomic_t ln_pb_update_ready;
2007 struct genl_filter_list {
2008 struct list_head lp_list;
2013 static const struct nla_policy scalar_attr_policy[LN_SCALAR_MAX + 1] = {
2014 [LN_SCALAR_ATTR_LIST] = { .type = NLA_NESTED },
2015 [LN_SCALAR_ATTR_LIST_SIZE] = { .type = NLA_U16 },
2016 [LN_SCALAR_ATTR_INDEX] = { .type = NLA_U16 },
2017 [LN_SCALAR_ATTR_NLA_TYPE] = { .type = NLA_U16 },
2018 [LN_SCALAR_ATTR_VALUE] = { .type = NLA_STRING },
2019 [LN_SCALAR_ATTR_KEY_FORMAT] = { .type = NLA_U16 },
2022 int lnet_genl_send_scalar_list(struct sk_buff *msg, u32 portid, u32 seq,
2023 const struct genl_family *family, int flags,
2024 u8 cmd, const struct ln_key_list *data[]);
2026 /* Special workaround for pre-4.19 kernels to send error messages
2027 * from dumpit routines. Newer kernels will send message with
2028 * NL_SET_ERR_MSG information by default if NETLINK_EXT_ACK is set.
2030 static inline int lnet_nl_send_error(struct sk_buff *msg, int portid, int seq,
2033 #ifndef HAVE_NL_DUMP_WITH_EXT_ACK
2034 struct nlmsghdr *nlh;
2039 nlh = nlmsg_put(msg, portid, seq, NLMSG_ERROR, sizeof(error), 0);
2042 #ifdef HAVE_NL_PARSE_WITH_EXT_ACK
2043 netlink_ack(msg, nlh, error, NULL);
2045 netlink_ack(msg, nlh, error);
2047 return nlmsg_len(nlh);