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 /* Structure to represent \<range_expr\> token of the syntax. */
41 struct cfs_range_expr {
42 /* Link to cfs_expr_list::el_exprs. */
43 struct list_head re_link;
49 struct cfs_expr_list {
50 struct list_head el_link;
51 struct list_head el_exprs;
54 int cfs_expr_list_match(u32 value, struct cfs_expr_list *expr_list);
55 int cfs_expr_list_values(struct cfs_expr_list *expr_list,
56 int max, u32 **values);
57 void cfs_expr_list_free(struct cfs_expr_list *expr_list);
58 int cfs_expr_list_parse(char *str, int len, unsigned int min, unsigned int max,
59 struct cfs_expr_list **elpp);
60 void cfs_expr_list_free_list(struct list_head *list);
61 #define cfs_expr_list_values_free(values, num) CFS_FREE_PTR_ARRAY(values, num)
63 /* Max payload size */
64 #define LNET_MAX_PAYLOAD LNET_MTU
66 /** limit on the number of fragments in discontiguous MDs */
67 #define LNET_MAX_IOV 256
70 * This is the maximum health value.
71 * All local and peer NIs created have their health default to this value.
73 #define LNET_MAX_HEALTH_VALUE 1000
74 #define LNET_MAX_SELECTION_PRIORITY UINT_MAX
79 enum lnet_msg_hstatus {
80 LNET_MSG_STATUS_OK = 0,
81 LNET_MSG_STATUS_LOCAL_INTERRUPT,
82 LNET_MSG_STATUS_LOCAL_DROPPED,
83 LNET_MSG_STATUS_LOCAL_ABORTED,
84 LNET_MSG_STATUS_LOCAL_NO_ROUTE,
85 LNET_MSG_STATUS_LOCAL_ERROR,
86 LNET_MSG_STATUS_LOCAL_TIMEOUT,
87 LNET_MSG_STATUS_REMOTE_ERROR,
88 LNET_MSG_STATUS_REMOTE_DROPPED,
89 LNET_MSG_STATUS_REMOTE_TIMEOUT,
90 LNET_MSG_STATUS_NETWORK_TIMEOUT,
94 struct lnet_rsp_tracker {
95 /* chain on the waiting list */
96 struct list_head rspt_on_list;
100 struct lnet_nid rspt_next_hop_nid;
101 /* deadline of the REPLY/ACK */
102 ktime_t rspt_deadline;
104 struct lnet_handle_md rspt_mdh;
108 struct list_head msg_activelist;
109 struct list_head msg_list; /* Q for credits/MD */
111 struct lnet_processid msg_target;
112 /* Primary NID of the source. */
113 struct lnet_nid msg_initiator;
114 /* where is it from, it's only for building event */
115 struct lnet_nid msg_from;
119 * hold parameters in case message is with held due
122 struct lnet_nid msg_src_nid_param;
123 struct lnet_nid msg_rtr_nid_param;
126 * Deadline for the message after which it will be finalized if it
129 ktime_t msg_deadline;
131 /* The message health status. */
132 enum lnet_msg_hstatus msg_health_status;
133 /* This is a recovery message */
135 /* the number of times a transmission has been retried */
137 /* flag to indicate that we do not want to resend this message */
140 /* committed for sending */
141 unsigned int msg_tx_committed:1;
142 /* CPT # this message committed for sending */
143 unsigned int msg_tx_cpt:15;
144 /* committed for receiving */
145 unsigned int msg_rx_committed:1;
146 /* CPT # this message committed for receiving */
147 unsigned int msg_rx_cpt:15;
148 /* queued for tx credit */
149 unsigned int msg_tx_delayed:1;
150 /* queued for RX buffer */
151 unsigned int msg_rx_delayed:1;
152 /* ready for pending on RX delay list */
153 unsigned int msg_rx_ready_delay:1;
155 unsigned int msg_vmflush:1; /* VM trying to free memory */
156 unsigned int msg_target_is_router:1; /* sending to a router */
157 unsigned int msg_routing:1; /* being forwarded */
158 unsigned int msg_ack:1; /* ack on finalize (PUT) */
159 unsigned int msg_sending:1; /* outgoing message */
160 unsigned int msg_receiving:1; /* being received */
161 unsigned int msg_txcredit:1; /* taken an NI send credit */
162 unsigned int msg_peertxcredit:1; /* taken a peer send credit */
163 unsigned int msg_rtrcredit:1; /* taken a globel router credit */
164 unsigned int msg_peerrtrcredit:1; /* taken a peer router credit */
165 unsigned int msg_onactivelist:1; /* on the activelist */
166 unsigned int msg_rdma_get:1;
168 struct lnet_peer_ni *msg_txpeer; /* peer I'm sending to */
169 struct lnet_peer_ni *msg_rxpeer; /* peer I received from */
172 struct lnet_libmd *msg_md;
173 /* the NI the message was sent or received over */
174 struct lnet_ni *msg_txni;
175 struct lnet_ni *msg_rxni;
177 unsigned int msg_len;
178 unsigned int msg_wanted;
179 unsigned int msg_offset;
180 unsigned int msg_niov;
181 struct bio_vec *msg_kiov;
183 struct lnet_event msg_ev;
184 struct lnet_hdr msg_hdr;
187 struct lnet_libhandle {
188 struct list_head lh_hash_chain;
192 #define lh_entry(ptr, type, member) \
193 ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
196 struct list_head me_list;
198 struct lnet_processid me_match_id;
199 unsigned int me_portal;
200 unsigned int me_pos; /* hash offset in mt_hash */
202 __u64 me_ignore_bits;
203 enum lnet_unlink me_unlink;
204 struct lnet_libmd *me_md;
208 struct list_head md_list;
209 struct lnet_libhandle md_lh;
210 struct lnet_me *md_me;
212 unsigned int md_offset;
213 unsigned int md_length;
214 unsigned int md_max_size;
217 unsigned int md_options;
218 unsigned int md_flags;
219 unsigned int md_niov; /* # frags at end of struct */
221 struct lnet_rsp_tracker *md_rspt_ptr;
222 lnet_handler_t md_handler;
223 struct lnet_handle_md md_bulk_handle;
224 struct bio_vec md_kiov[LNET_MAX_IOV];
227 #define LNET_MD_FLAG_ZOMBIE BIT(0)
228 #define LNET_MD_FLAG_AUTO_UNLINK BIT(1)
229 #define LNET_MD_FLAG_ABORTED BIT(2)
230 /* LNET_MD_FLAG_HANDLING is set when a non-unlink event handler
231 * is being called for an event relating to the md.
232 * It ensures only one such handler runs at a time.
233 * The final "unlink" event is only called once the
234 * md_refcount has reached zero, and this flag has been cleared,
235 * ensuring that it doesn't race with any other event handler
238 #define LNET_MD_FLAG_HANDLING BIT(3)
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_match_netmask)(const __be32 *addr, size_t asize,
275 const __be32 *netmask,
276 const __be32 *netaddr);
277 int (*nf_min_max)(struct list_head *nidlist, u32 *min_nid,
281 struct lnet_ni; /* forward ref */
285 /* fields initialized by the LND */
288 int (*lnd_startup)(struct lnet_ni *ni);
289 void (*lnd_shutdown)(struct lnet_ni *ni);
290 int (*lnd_ctl)(struct lnet_ni *ni, unsigned int cmd, void *arg);
292 /* In data movement APIs below, payload buffers are described as a set
293 * of 'niov' fragments which are in pages.
294 * The LND may NOT overwrite these fragment descriptors.
295 * An 'offset' and may specify a byte offset within the set of
296 * fragments to start from
299 /* Start sending a preformatted message. 'private' is NULL for PUT and
300 * GET messages; otherwise this is a response to an incoming message
301 * and 'private' is the 'private' passed to lnet_parse(). Return
302 * non-zero for immediate failure, otherwise complete later with
304 int (*lnd_send)(struct lnet_ni *ni, void *private,
305 struct lnet_msg *msg);
307 /* Start receiving 'mlen' bytes of payload data, skipping the following
308 * 'rlen' - 'mlen' bytes. 'private' is the 'private' passed to
309 * lnet_parse(). Return non-zero for immedaite failure, otherwise
310 * complete later with lnet_finalize(). This also gives back a receive
311 * credit if the LND does flow control. */
312 int (*lnd_recv)(struct lnet_ni *ni, void *private, struct lnet_msg *msg,
313 int delayed, unsigned int niov,
314 struct bio_vec *kiov,
315 unsigned int offset, unsigned int mlen, unsigned int rlen);
317 /* lnet_parse() has had to delay processing of this message
318 * (e.g. waiting for a forwarding buffer or send credits). Give the
319 * LND a chance to free urgently needed resources. If called, return 0
320 * for success and do NOT give back a receive credit; that has to wait
321 * until lnd_recv() gets called. On failure return < 0 and
322 * release resources; lnd_recv() will not be called. */
323 int (*lnd_eager_recv)(struct lnet_ni *ni, void *private,
324 struct lnet_msg *msg, void **new_privatep);
326 /* notification of peer down */
327 void (*lnd_notify_peer_down)(struct lnet_nid *peer);
329 /* accept a new connection */
330 int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock);
332 /* get dma_dev priority */
333 unsigned int (*lnd_get_dev_prio)(struct lnet_ni *ni,
334 unsigned int dev_idx);
336 /* Handle LND specific Netlink handling */
337 int (*lnd_nl_get)(int cmd, struct sk_buff *msg, int type, void *data);
338 int (*lnd_nl_set)(int cmd, struct nlattr *attr, int type, void *data);
340 const struct ln_key_list *lnd_keys;
342 /* get LND timeout */
343 int (*lnd_get_timeout)(void);
346 struct lnet_tx_queue {
347 int tq_credits; /* # tx credits free */
348 int tq_credits_min; /* lowest it's been */
349 int tq_credits_max; /* total # tx credits */
350 struct list_head tq_delayed; /* delayed TXs */
353 enum lnet_net_state {
354 /* set when net block is allocated */
355 LNET_NET_STATE_INIT = 0,
356 /* set when NIs in net are started successfully */
357 LNET_NET_STATE_ACTIVE,
358 /* set if all NIs in net are in FAILED state */
359 LNET_NET_STATE_INACTIVE,
360 /* set when shutting down a NET */
361 LNET_NET_STATE_DELETING
365 /* initial state when NI is created */
366 LNET_NI_STATE_INIT = 0,
367 /* set when NI is brought up */
368 LNET_NI_STATE_ACTIVE,
369 /* set when NI is being shutdown */
370 LNET_NI_STATE_DELETING,
373 #define LNET_NI_RECOVERY_PENDING BIT(0)
374 #define LNET_NI_RECOVERY_FAILED BIT(1)
376 enum lnet_stats_type {
377 LNET_STATS_TYPE_SEND = 0,
378 LNET_STATS_TYPE_RECV,
382 struct lnet_comm_count {
383 atomic_t co_get_count;
384 atomic_t co_put_count;
385 atomic_t co_reply_count;
386 atomic_t co_ack_count;
387 atomic_t co_hello_count;
390 struct lnet_element_stats {
391 struct lnet_comm_count el_send_stats;
392 struct lnet_comm_count el_recv_stats;
393 struct lnet_comm_count el_drop_stats;
396 struct lnet_health_local_stats {
397 atomic_t hlt_local_interrupt;
398 atomic_t hlt_local_dropped;
399 atomic_t hlt_local_aborted;
400 atomic_t hlt_local_no_route;
401 atomic_t hlt_local_timeout;
402 atomic_t hlt_local_error;
405 struct lnet_health_remote_stats {
406 atomic_t hlt_remote_dropped;
407 atomic_t hlt_remote_timeout;
408 atomic_t hlt_remote_error;
409 atomic_t hlt_network_timeout;
413 /* chain on the ln_nets */
414 struct list_head net_list;
416 /* net ID, which is composed of
417 * (net_type << 16) | net_num.
418 * net_type can be one of the enumerated types defined in
419 * lnet/include/lnet/nidstr.h */
422 /* round robin selection */
425 /* total number of CPTs in the array */
428 /* cumulative CPTs of all NIs in this net */
431 /* relative net selection priority */
432 __u32 net_sel_priority;
434 /* network tunables */
435 struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
438 * boolean to indicate that the tunables have been set and
441 bool net_tunables_set;
443 /* procedural interface */
444 const struct lnet_lnd *net_lnd;
446 /* list of NIs on this net */
447 struct list_head net_ni_list;
449 /* list of NIs being added, but not started yet */
450 struct list_head net_ni_added;
452 /* dying LND instances */
453 struct list_head net_ni_zombie;
455 /* when I was last alive */
456 time64_t net_last_alive;
458 /* protects access to net_last_alive */
461 /* list of router nids preferred for this network */
462 struct list_head net_rtr_pref_nids;
465 /* Normally Netlink atttributes are defined in UAPI headers but Lustre is
466 * different in that the ABI is in a constant state of change unlike other
467 * Netlink interfaces. LNet sends a special header to help user land handle
471 /** enum lnet_err_atrrs - LNet error netlink properties
472 * For LNet request of multiple items
473 * sometimes those items exist and
474 * others don't. In the case the item
475 * item doesn't exist we return the
478 * @LNET_ERR_ATTR_UNSPEC: unspecified attribute to catch errors
480 * @LNET_ERR_ATTR_HDR: Name of the error header
482 * @LNET_ERR_ATTR_TYPE: Which LNet function since error is for
484 * @LNET_ERR_TYPE_ERRNO: Error code for failure (NLA_S16)
485 * @LNET_ERR_DESCR: Complete error message (NLA_STRING)
487 enum lnet_err_attrs {
488 LNET_ERR_ATTR_UNSPEC = 0,
494 __LNET_ERR_ATTR_MAX_PLUS_ONE,
497 #define LNET_ERR_ATTR_MAX (__LNET_ERR_ATTR_MAX_PLUS_ONE - 1)
499 /** enum lnet_net_attrs - LNet NI netlink properties
500 * attributes that describe LNet 'NI'
501 * These values are used to piece together
502 * messages for sending and receiving.
504 * @LNET_NET_ATTR_UNSPEC: unspecified attribute to catch errors
506 * @LNET_NET_ATTR_HDR: grouping for LNet net data (NLA_NUL_STRING)
507 * @LNET_NET_ATTR_TYPE: LNet net this NI belongs to (NLA_STRING)
508 * @LNET_NET_ATTR_LOCAL: Local NI information (NLA_NESTED)
510 enum lnet_net_attrs {
511 LNET_NET_ATTR_UNSPEC = 0,
517 __LNET_NET_ATTR_MAX_PLUS_ONE,
520 #define LNET_NET_ATTR_MAX (__LNET_NET_ATTR_MAX_PLUS_ONE - 1)
522 /** enum lnet_net_local_ni_attrs - LNet local NI netlink properties
523 * attributes that describe local
526 * @LNET_NET_LOCAL_NI_ATTR_UNSPEC: unspecified attribute to catch
529 * @LNET_NET_LOCAL_NI_ATTR_NID: NID that represents this NI
531 * @LNET_NET_LOCAL_NI_ATTR_STATUS: State of this NI (NLA_STRING)
532 * @LNET_NET_LOCAL_NI_ATTR_INTERFACE: Defines physical devices. used
533 * to be many devices but no longer
536 * @LNET_NET_LOCAL_NI_ATTR_STATS: NI general msg stats (NLA_NESTED)
537 * @LNET_NET_LOCAL_NI_ATTR_UDSP_INFO: NI UDSP state (NLA_NESTED)
538 * @LNET_NET_LOCAL_NI_ATTR_SEND_STATS: NI send stats (NLA_NESTED)
539 * @LNET_NET_LOCAL_NI_ATTR_RECV_STATS: NI received stats (NLA_NESTED)
540 * @LNET_NET_LOCAL_NI_ATTR_DROPPED_STATS: NI dropped stats (NLA_NESTED)
541 * @LNET_NET_LOCAL_NI_ATTR_HEALTH_STATS: NI health stats (NLA_NESTED)
542 * @LNET_NET_LOCAL_NI_ATTR_TUNABLES: NI tunables (NLA_NESTED)
543 * @LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES: NI LND tunables (NLA_NESTED)
544 * @LNET_NET_LOCAL_NI_ATTR_DEV_CPT: NI CPT interface bound to
546 * @LNET_NET_LOCAL_NI_ATTR_CPTS: CPT core used by this NI
549 enum lnet_net_local_ni_attrs {
550 LNET_NET_LOCAL_NI_ATTR_UNSPEC = 0,
552 LNET_NET_LOCAL_NI_ATTR_NID,
553 LNET_NET_LOCAL_NI_ATTR_STATUS,
554 LNET_NET_LOCAL_NI_ATTR_INTERFACE,
556 LNET_NET_LOCAL_NI_ATTR_STATS,
557 LNET_NET_LOCAL_NI_ATTR_UDSP_INFO,
558 LNET_NET_LOCAL_NI_ATTR_SEND_STATS,
559 LNET_NET_LOCAL_NI_ATTR_RECV_STATS,
560 LNET_NET_LOCAL_NI_ATTR_DROPPED_STATS,
561 LNET_NET_LOCAL_NI_ATTR_HEALTH_STATS,
562 LNET_NET_LOCAL_NI_ATTR_TUNABLES,
563 LNET_NET_LOCAL_NI_ATTR_LND_TUNABLES,
564 LNET_NET_LOCAL_NI_DEV_CPT,
565 LNET_NET_LOCAL_NI_CPTS,
567 __LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE,
570 #define LNET_NET_LOCAL_NI_ATTR_MAX (__LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE - 1)
572 /** enum lnet_net_local_ni_intf_attrs - LNet NI device netlink properties
573 * attribute that reports the device
576 * @LNET_NET_LOCAL_NI_INTF_ATTR_UNSPEC: unspecified attribute to catch errors
578 * @LNET_NET_LOCAL_NI_INTF_ATTR_TYPE: Physcial device interface (NLA_STRING)
580 enum lnet_net_local_ni_intf_attrs {
581 LNET_NET_LOCAL_NI_INTF_ATTR_UNSPEC = 0,
583 LNET_NET_LOCAL_NI_INTF_ATTR_TYPE,
585 __LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE,
588 #define LNET_NET_LOCAL_NI_INTF_ATTR_MAX (__LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE - 1)
590 /** enum lnet_net_local_ni_stats_attrs - LNet NI netlink properties
591 * attributes that reports the
592 * network traffic stats
594 * @LNET_NET_LOCAL_NI_STATS_ATTR_UNSPEC: unspecified attribute to catch
597 * @LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT: Number of sent messages
599 * @LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT: Number of received messages
601 * @LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT: Number of dropped messages
604 enum lnet_net_local_ni_stats_attrs {
605 LNET_NET_LOCAL_NI_STATS_ATTR_UNSPEC = 0,
607 LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT,
608 LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT,
609 LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT,
610 __LNET_NET_LOCAL_NI_STATS_ATTR_MAX_PLUS_ONE,
613 #define LNET_NET_LOCAL_NI_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_STATS_ATTR_MAX_PLUS_ONE - 1)
615 /** enum lnet_net_local_ni_msg_stats_attrs - LNet NI netlink
616 * properties attributes
617 * that reports the message
620 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_UNSPEC: unspecified attribute
623 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT: Number of PUT messages
625 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT: Number of GET messages
627 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT: Number of REPLY messages
629 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT: Number of ACK messages
631 * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT: Number of HELLO messages
634 enum lnet_net_local_ni_msg_stats_attrs {
635 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_UNSPEC = 0,
637 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT,
638 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT,
639 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT,
640 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT,
641 LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT,
642 __LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX_PLUS_ONE,
645 #define LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX_PLUS_ONE - 1)
647 /** enum lnet_net_local_ni_health_stats_attrs - LNet NI netlink
648 * properties attributes
652 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC: unspecified attribute
655 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS: How many fatal errors
657 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL: How healthly is NI
659 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS: How many interrupts
661 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_DROPPED: How much traffic has
662 * been dropped (NLA_U32)
663 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ABORTED: How many aborts
665 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE: How often routing broke
667 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS: How often timeouts
669 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR: The number of errors
671 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT: Number of successful
673 * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING: Number of next pings
676 enum lnet_net_local_ni_health_stats_attrs {
677 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC = 0,
678 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PAD = LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC,
680 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS,
681 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL,
682 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS,
683 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_DROPPED,
684 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ABORTED,
685 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE,
686 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS,
687 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR,
688 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT,
689 LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING,
690 __LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX_PLUS_ONE,
692 #define LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX_PLUS_ONE - 1)
694 /** enum lnet_net_local_ni_tunables_attrs - LNet NI tunables
695 * netlink properties.
696 * Performance options
699 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_UNSPEC: unspecified attribute
702 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT: Timeout for LNet peer.
704 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS: Credits for LNet peer.
706 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_BUFFER_CREDITS: Buffer credits for
707 * LNet peer. (NLA_S32)
708 * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_CREDITS: Credits for LNet peer
711 enum lnet_net_local_ni_tunables_attr {
712 LNET_NET_LOCAL_NI_TUNABLES_ATTR_UNSPEC = 0,
714 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT,
715 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS,
716 LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_BUFFER_CREDITS,
717 LNET_NET_LOCAL_NI_TUNABLES_ATTR_CREDITS,
718 __LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX_PLUS_ONE,
721 #define LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX (__LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX_PLUS_ONE - 1)
723 /** enum lnet_route_attrs - LNet route netlink
724 * attributes that describe
727 * @LNET_ROUTE_ATTR_UNSPEC: unspecified attribute to
730 * @LNET_ROUTE_ATTR_HDR: grouping for LNet route data
732 * @LNET_ROUTE_ATTR_NET: LNet remote network reached
733 * by the route (NLA_STRING)
734 * @LNET_ROUTE_ATTR_GATEWAY: gateway for the route
736 * @LNET_ROUTE_ATTR_HOP: route hop count (NLA_S32)
738 * @LNET_ROUTE_ATTR_PRIORITY: rank of this network path
740 * @LNET_ROUTE_ATTR_HEALTH_SENSITIVITY: rate of health value change
741 * for the route (NLA_U32)
742 * @LNET_ROUTE_ATTR_STATE: state of route (NLA_STRING)
744 * @LNET_ROUTE_ATTR_TYPE: Report if we support multi-hop
747 enum lnet_route_attrs {
748 LNET_ROUTE_ATTR_UNSPEC = 0,
752 LNET_ROUTE_ATTR_GATEWAY,
754 LNET_ROUTE_ATTR_PRIORITY,
755 LNET_ROUTE_ATTR_HEALTH_SENSITIVITY,
756 LNET_ROUTE_ATTR_STATE,
757 LNET_ROUTE_ATTR_TYPE,
758 __LNET_ROUTE_ATTR_MAX_PLUS_ONE,
761 #define LNET_ROUTE_ATTR_MAX (__LNET_ROUTE_ATTR_MAX_PLUS_ONE - 1)
763 /** enum lnet_peer_ni_attrs - LNet peer NI netlink properties
764 * attributes that describe LNet peer 'NI'.
765 * These values are used to piece together
766 * messages for sending and receiving.
768 * @LNET_PEER_NI_ATTR_UNSPEC: unspecified attribute to catch errors
770 * @LNET_PEER_NI_ATTR_HDR: grouping for LNet peer data
772 * @LNET_PEER_NI_ATTR_PRIMARY_NID: primary NID of this peer (NLA_STRING)
773 * @LNET_PEER_NI_ATTR_MULTIRAIL: Do we support MultiRail ? (NLA_FLAG)
774 * @LNET_PEER_NI_ATTR_STATE: Bitfields of the peer state (NLA_U32)
775 * @LNET_PEER_NI_ATTR_PEER_NI_LIST: List of remote peers we can reach
778 enum lnet_peer_ni_attrs {
779 LNET_PEER_NI_ATTR_UNSPEC = 0,
781 LNET_PEER_NI_ATTR_HDR,
782 LNET_PEER_NI_ATTR_PRIMARY_NID,
783 LNET_PEER_NI_ATTR_MULTIRAIL,
784 LNET_PEER_NI_ATTR_STATE,
785 LNET_PEER_NI_ATTR_PEER_NI_LIST,
786 __LNET_PEER_NI_ATTR_MAX_PLUS_ONE,
789 #define LNET_PEER_NI_ATTR_MAX (__LNET_PEER_NI_ATTR_MAX_PLUS_ONE - 1)
791 /** enum lnet_peer_ni_list_attrs - LNet remote peer netlink
792 * properties attributes that
793 * describe remote LNet peer 'NI'.
794 * These values are used to piece
795 * together messages for sending
798 * @LNET_PEER_NI_LIST_ATTR_UNSPEC: unspecified attribute to catch
801 * @LNET_PEER_NI_LIST_ATTR_NID: remote peer's NID (NLA_STRING)
802 * @LNET_PEER_NI_LIST_ATTR_UDSP_INFO: remote peer's UDSP info
804 * @LNET_PEER_NI_LIST_ATTR_STATE: state of remote peer
807 * @LNET_PEER_NI_LIST_ATTR_MAX_TX_CREDITS: Maximum TX credits for remote
809 * @LNET_PEER_NI_LIST_ATTR_CUR_TX_CREDITS: Current TX credits for remote
811 * @LNET_PEER_NI_LIST_ATTR_MIN_TX_CREDITS: Minimum TX credits for remote
813 * @LNET_PEER_NI_LIST_ATTR_QUEUE_BUF_COUNT: Size of TX queue buffer
815 * @LNET_PEER_NI_LIST_ATTR_CUR_RTR_CREDITS: Current router credits for
816 * remote peer (NLA_U32)
817 * @LNET_PEER_NI_LIST_ATTR_MIN_RTR_CREDITS: Minimum router credits for
818 * remote peer (NLA_U32)
819 * @LNET_PEER_NI_LIST_ATTR_REFCOUNT: Remote peer reference count
821 * @LNET_PEER_NI_LIST_ATTR_STATS_COUNT: Remote peer general stats,
822 * reports sent, received, and
823 * dropped packets. (NLA_NESTED)
825 * @LNET_PEER_NI_LIST_ATTR_SENT_STATS: Remote peer sent stats,
826 * reports gets, puts, acks, and
827 * hello packets. (NLA_NESTED)
828 * @LNET_PEER_NI_LIST_ATTR_RECV_STATS: Remote peer received stats,
829 * reports gets, puts, acks, and
830 * hello packets. (NLA_NESTED)
831 * @LNET_PEER_NI_LIST_ATTR_DROP_STATS: Remote peer dropped stats,
832 * reports gets, puts, acks, and
833 * hello packets. (NLA_NESTED)
834 * @LNET_PEER_NI_LIST_ATTR_HEALTH_STATS: Report the stats about the
835 * health of the remote peer.
838 enum lnet_peer_ni_list_attr {
839 LNET_PEER_NI_LIST_ATTR_UNSPEC = 0,
841 LNET_PEER_NI_LIST_ATTR_NID,
842 LNET_PEER_NI_LIST_ATTR_UDSP_INFO,
843 LNET_PEER_NI_LIST_ATTR_STATE,
845 LNET_PEER_NI_LIST_ATTR_MAX_TX_CREDITS,
846 LNET_PEER_NI_LIST_ATTR_CUR_TX_CREDITS,
847 LNET_PEER_NI_LIST_ATTR_MIN_TX_CREDITS,
848 LNET_PEER_NI_LIST_ATTR_QUEUE_BUF_COUNT,
849 LNET_PEER_NI_LIST_ATTR_CUR_RTR_CREDITS,
850 LNET_PEER_NI_LIST_ATTR_MIN_RTR_CREDITS,
851 LNET_PEER_NI_LIST_ATTR_REFCOUNT,
852 LNET_PEER_NI_LIST_ATTR_STATS_COUNT,
854 LNET_PEER_NI_LIST_ATTR_SENT_STATS,
855 LNET_PEER_NI_LIST_ATTR_RECV_STATS,
856 LNET_PEER_NI_LIST_ATTR_DROP_STATS,
857 LNET_PEER_NI_LIST_ATTR_HEALTH_STATS,
859 __LNET_PEER_NI_LIST_ATTR_MAX_PLUS_ONE,
862 #define LNET_PEER_NI_LIST_ATTR_MAX (__LNET_PEER_NI_LIST_ATTR_MAX_PLUS_ONE - 1)
864 /** enum lnet_peer_ni_list_stats_count - LNet remote peer traffic
865 * stats netlink properties
866 * attributes that provide
867 * traffic stats on the
868 * remote LNet peer 'NI'.
869 * These values are used to
870 * piece together messages
871 * for sending and receiving.
873 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_UNSPEC: unspecified attribute to
876 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_SEND_COUNT: Number of sent packets for
877 * remote peer (NLA_U32)
878 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_RECV_COUNT: Number of received packets
879 * for remote peer (NLA_U32)
880 * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_DROP_COUNT: Number of dropped packets
881 * for remote peer (NLA_U32)
883 enum lnet_peer_ni_list_stats_count {
884 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_UNSPEC = 0,
886 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_SEND_COUNT,
887 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_RECV_COUNT,
888 LNET_PEER_NI_LIST_STATS_COUNT_ATTR_DROP_COUNT,
889 __LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX_PLUS_ONE,
892 #define LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX (__LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX_PLUS_ONE - 1)
894 /** enum lnet_peer_ni_list_stats - LNet remote peer stats netlink
895 * properties attributes that
896 * provide stats on the remote
897 * LNet peer 'NI'. These values are
898 * used to piece together messages
899 * for sending and receiving.
901 * @LNET_PEER_NI_LIST_STATS_ATTR_UNSPEC: unspecified attribute to catch
904 * @LNET_PEER_NI_LIST_STATS_ATTR_PUT: PUT message count for remote
906 * @LNET_PEER_NI_LIST_STATS_ATTR_GET: GET message count for remote
908 * @LNET_PEER_NI_LIST_STATS_ATTR_REPLY: REPLY message count for remote
910 * @LNET_PEER_NI_LIST_STATS_ATTR_ACK: ACK message count for remote
912 * @LNET_PEER_NI_LIST_STATS_ATTR_HEALTH: HELLO message count for remote
915 enum lnet_peer_ni_list_stats {
916 LNET_PEER_NI_LIST_STATS_ATTR_UNSPEC = 0,
918 LNET_PEER_NI_LIST_STATS_ATTR_PUT,
919 LNET_PEER_NI_LIST_STATS_ATTR_GET,
920 LNET_PEER_NI_LIST_STATS_ATTR_REPLY,
921 LNET_PEER_NI_LIST_STATS_ATTR_ACK,
922 LNET_PEER_NI_LIST_STATS_ATTR_HELLO,
923 __LNET_PEER_NI_LIST_STATS_ATTR_MAX_PLUS_ONE,
926 #define LNET_PEER_NI_LIST_STATS_ATTR_MAX (__LNET_PEER_NI_LIST_STATS_ATTR_MAX_PLUS_ONE - 1)
928 /** enum lnet_peer_ni_list_health_stats - LNet remote peer health
929 * stats netlink properties
930 * attributes that provide
931 * stats on the health of a
932 * remote LNet peer 'NI'.
933 * These values are used to
934 * piece together messages
935 * for sending and receiving.
937 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_UNSPEC: unspecified attribute to
940 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_VALUE: Health level of remote
942 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_DROP: drop message state for
943 * remote peer (NLA_U32)
944 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_TIMEOUT: timeout set for remote
946 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_ERROR: total errors for remote
948 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NETWORK_TIMEOUT: network timeout for
949 * remote peer (NLA_U32)
950 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_PING_COUNT: number of pings for
951 * remote peer (NLA_U32)
952 * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NEXT_PING: timestamp for next ping
953 * sent by remote peer
956 enum lnet_peer_ni_list_health_stats {
957 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_UNSPEC = 0,
958 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_PAD = LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_UNSPEC,
960 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_VALUE,
961 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_DROPPED,
962 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_TIMEOUT,
963 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_ERROR,
964 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NETWORK_TIMEOUT,
965 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_PING_COUNT,
966 LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_NEXT_PING,
968 __LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX_PLUS_ONE,
971 #define LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX (__LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX_PLUS_ONE - 1)
973 /** LNet netlink ping API */
975 /** enum lnet_ping_attr - LNet ping netlink properties
976 * attributes to describe ping format
977 * These values are used to piece together
978 * messages for sending and receiving.
980 * @LNET_PING_ATTR_UNSPEC: unspecified attribute to catch errors
982 * @LNET_PING_ATTR_HDR: grouping for LNet ping data (NLA_NUL_STRING)
983 * @LNET_PING_ATTR_PRIMARY_NID: Source NID for ping request (NLA_STRING)
984 * @LNET_PING_ATTR_ERRNO: error code if we fail to ping (NLA_S16)
985 * @LNET_PING_ATTR_MULTIRAIL: Report if MR is supported (NLA_FLAG)
986 * @LNET_PING_ATTR_PEER_NI_LIST: List of peer NI's (NLA_NESTED)
988 enum lnet_ping_attr {
989 LNET_PING_ATTR_UNSPEC = 0,
992 LNET_PING_ATTR_PRIMARY_NID,
993 LNET_PING_ATTR_ERRNO,
994 LNET_PING_ATTR_MULTIRAIL,
995 LNET_PING_ATTR_PEER_NI_LIST,
996 __LNET_PING_ATTR_MAX_PLUS_ONE,
999 #define LNET_PING_ATTR_MAX (__LNET_PING_ATTR_MAX_PLUS_ONE - 1)
1001 /** enum lnet_ping_peer_ni_attr - LNet peer ni information reported by
1002 * ping command. A list of these are
1003 * returned with a ping request.
1005 * @LNET_PING_PEER_NI_ATTR_UNSPEC: unspecified attribute to catch errrors
1007 * @LNET_PING_PEER_NI_ATTR_NID: NID address of peer NI. (NLA_STRING)
1009 enum lnet_ping_peer_ni_attr {
1010 LNET_PING_PEER_NI_ATTR_UNSPEC = 0,
1012 LNET_PING_PEER_NI_ATTR_NID,
1013 __LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE,
1016 #define LNET_PING_PEER_NI_ATTR_MAX (__LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE - 1)
1018 /** enum lnet_udsp_info_attr - LNet UDSP information reported for
1019 * some subsystem that tracks it.
1021 * @LNET_UDSP_INFO_ATTR_UNSPEC: unspecified attribute to catch errors
1023 * @LNET_UDSP_INFO_ATTR_NET_PRIORITY, LNet net priority in selection.
1025 * @LNET_UDSP_INFO_ATTR_NID_PRIORITY, NID's priority in selection.
1027 * @LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST: Which gateway's are preferred.
1029 * @LNET_UDSP_INFO_ATTR_PREF_NIDS_LIST: Which NIDs are preferred.
1032 enum lnet_udsp_info_attr {
1033 LNET_UDSP_INFO_ATTR_UNSPEC = 0,
1035 LNET_UDSP_INFO_ATTR_NET_PRIORITY,
1036 LNET_UDSP_INFO_ATTR_NID_PRIORITY,
1037 LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST,
1038 LNET_UDSP_INFO_ATTR_PREF_NIDS_LIST,
1039 __LNET_UDSP_INFO_ATTR_MAX_PLUS_ONE,
1042 #define LNET_UDSP_INFO_ATTR_MAX (__LNET_UDSP_INFO_ATTR_MAX_PLUS_ONE - 1)
1044 /** enum lnet_udsp_info_pref_nids_attr - LNet UDSP information reported for
1045 * some subsystem that tracks it.
1047 * @LNET_UDSP_INFO_PREF_NIDS_ATTR_UNSPEC: unspecified attribute to catch errors
1049 * @LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX, UDSP prority NIDs label
1051 * @LNET_UDSP_INFO_PREF_NIDS_ATTR_NID, UDSP prority NID (NLA_STRING)
1053 enum lnet_udsp_info_pref_nids_attr {
1054 LNET_UDSP_INFO_PREF_NIDS_ATTR_UNSPEC = 0,
1056 LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX,
1057 LNET_UDSP_INFO_PREF_NIDS_ATTR_NID,
1058 __LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX_PLUS_ONE,
1061 #define LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX (__LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX_PLUS_ONE - 1)
1063 /** enum lnet_cpt_of_nid_attr - Attributes to support
1064 * lnetctl cpt-of-nid command
1066 * @LNET_CPT_OF_NID_ATTR_UNSPEC unspecified attribute to catch
1068 * @LNET_CPT_OF_NID_ATTR_HDR Grouping for cpt-of-nid
1070 * @LNET_CPT_OF_NID_ATTR_NID The NID whose CPT we want to
1071 * calculate (NLA_STRING)
1072 * LNET_CPT_OF_NID_ATTR_CPT The CPT for the specified NID
1075 enum lnet_cpt_of_nid_attr {
1076 LNET_CPT_OF_NID_ATTR_UNSPEC = 0,
1078 LNET_CPT_OF_NID_ATTR_HDR,
1079 LNET_CPT_OF_NID_ATTR_NID,
1080 LNET_CPT_OF_NID_ATTR_CPT,
1081 __LNET_CPT_OF_NID_ATTR_MAX_PLUS_ONE,
1084 #define LNET_CPT_OF_NID_ATTR_MAX (__LNET_CPT_OF_NID_ATTR_MAX_PLUS_ONE - 1)
1086 /** enum lnet_peer_dist_attr - Attributes to support
1087 * reporting distance for peers
1089 * @LNET_PEER_DIST_ATTR_UNSPEC unspecified attribute to catch
1091 * @LNET_PEER_DIST_ATTR_HDR Grouping which we just use peer
1093 * @LNET_PEER_DIST_ATTR_NID The NID we collect data for
1095 * @LNET_PEER_DIST_ATTR_DIST The distance for the specified
1097 * @LNET_PEER_DIST_ATTR_ORDER The order for the specified NID
1100 enum lnet_peer_dist_attr {
1101 LNET_PEER_DIST_ATTR_UNSPEC = 0,
1103 LNET_PEER_DIST_ATTR_HDR,
1104 LNET_PEER_DIST_ATTR_NID,
1105 LNET_PEER_DIST_ATTR_DIST,
1106 LNET_PEER_DIST_ATTR_ORDER,
1107 __LNET_PEER_DIST_ATTR_MAX_PLUS_ONE,
1110 #define LNET_PEER_DIST_ATTR_MAX (__LNET_PEER_DIST_ATTR_MAX_PLUS_ONE - 1)
1112 /** enum lnet_debug_recovery_attr Attributes to report contents of
1113 * the LNet health recovery queues
1115 * @LNET_DBG_RECOV_ATTR_UNSPEC Unspecified attribute to catch
1117 * @LNET_DBG_RECOV_ATTR_HDR Grouping for NI recovery queue
1119 * @LNET_DBG_RECOV_ATTR_NID A NID in one of the recovery
1120 * queues (NLA_STRING)
1122 enum lnet_debug_recovery_attr {
1123 LNET_DBG_RECOV_ATTR_UNSPEC = 0,
1125 LNET_DBG_RECOV_ATTR_HDR,
1126 LNET_DBG_RECOV_ATTR_NID,
1127 __LNET_DBG_RECOV_ATTR_MAX_PLUS_ONE,
1130 #define LNET_DBG_RECOV_ATTR_MAX (__LNET_DBG_RECOV_ATTR_MAX_PLUS_ONE - 1)
1133 /** enum lnet_fault_rule_attr Attributes to report LNet fault
1136 * @LNET_FAULT_ATTR_UNSPEC Unspecified attribute to catch errors
1137 * @LNET_FAULT_ATTR_PAD Pad attribute for 64b alignment
1139 * @LNET_FAULT_ATTR_HDR Grouping for "fault"
1140 * @LNET_FAULT_ATTR_FA_TYPE The type of fault injection rule. i.e.
1141 * either a "drop" rule or a "delay" rule.
1142 * @LNET_FAULT_ATTR_FA_SRC For a description of this field, and
1143 * the ones below, refer to
1144 * struct lnet_fault_attr
1145 * @LNET_FAULT_ATTR_FA_DST
1146 * @LNET_FAULT_ATTR_FA_PTL_MASK
1147 * @LNET_FAULT_ATTR_FA_MSG_MASK
1148 * @LNET_FAULT_ATTR_DA_RATE
1149 * @LNET_FAULT_ATTR_DA_INTERVAL
1150 * @LNET_FAULT_ATTR_DS_DROPPED
1151 * @LNET_FAULT_ATTR_LA_RATE
1152 * @LNET_FAULT_ATTR_LA_INTERVAL
1153 * @LNET_FAULT_ATTR_LA_LATENCY
1154 * @LNET_FAULT_ATTR_LS_DELAYED
1155 * @LNET_FAULT_ATTR_FS_COUNT
1156 * @LNET_FAULT_ATTR_FS_PUT
1157 * @LNET_FAULT_ATTR_FS_ACK
1158 * @LNET_FAULT_ATTR_FS_GET
1159 * @LNET_FAULT_ATTR_FS_REPLY
1161 enum lnet_fault_rule_attr {
1162 LNET_FAULT_ATTR_UNSPEC = 0,
1163 LNET_FAULT_ATTR_PAD = LNET_FAULT_ATTR_UNSPEC,
1165 LNET_FAULT_ATTR_HDR,
1166 LNET_FAULT_ATTR_FA_TYPE,
1167 LNET_FAULT_ATTR_FA_SRC,
1168 LNET_FAULT_ATTR_FA_DST,
1169 LNET_FAULT_ATTR_FA_PTL_MASK,
1170 LNET_FAULT_ATTR_FA_MSG_MASK,
1171 LNET_FAULT_ATTR_DA_RATE,
1172 LNET_FAULT_ATTR_DA_INTERVAL,
1173 LNET_FAULT_ATTR_DS_DROPPED,
1174 LNET_FAULT_ATTR_LA_RATE,
1175 LNET_FAULT_ATTR_LA_INTERVAL,
1176 LNET_FAULT_ATTR_LA_LATENCY,
1177 LNET_FAULT_ATTR_LS_DELAYED,
1178 LNET_FAULT_ATTR_FS_COUNT,
1179 LNET_FAULT_ATTR_FS_PUT,
1180 LNET_FAULT_ATTR_FS_ACK,
1181 LNET_FAULT_ATTR_FS_GET,
1182 LNET_FAULT_ATTR_FS_REPLY,
1183 __LNET_FAULT_ATTR_MAX_PLUS_ONE,
1186 #define LNET_FAULT_ATTR_MAX (__LNET_FAULT_ATTR_MAX_PLUS_ONE - 1)
1189 /* chain on the lnet_net structure */
1190 struct list_head ni_netlist;
1192 /* chain on the recovery queue */
1193 struct list_head ni_recovery;
1195 /* MD handle for recovery ping */
1196 struct lnet_handle_md ni_ping_mdh;
1200 /* number of CPTs */
1203 /* bond NI on some CPTs */
1206 /* interface's NID */
1207 struct lnet_nid ni_nid;
1209 /* instance-specific data */
1212 /* per ni credits */
1213 atomic_t ni_tx_credits;
1215 /* percpt TX queues */
1216 struct lnet_tx_queue **ni_tx_queues;
1218 /* percpt reference count */
1221 /* pointer to parent network */
1222 struct lnet_net *ni_net;
1224 /* my health status */
1227 /* NI FSM. Protected by lnet_ni_lock() */
1228 enum lnet_ni_state ni_state;
1230 /* Recovery state. Protected by lnet_ni_lock() */
1231 __u32 ni_recovery_state;
1233 /* When to send the next recovery ping */
1234 time64_t ni_next_ping;
1235 /* How many pings sent during current recovery period did not receive
1236 * a reply. NB: reset whenever _any_ message arrives on this NI
1238 unsigned int ni_ping_count;
1240 /* per NI LND tunables */
1241 struct lnet_lnd_tunables ni_lnd_tunables;
1243 /* lnd tunables set explicitly */
1244 bool ni_lnd_tunables_set;
1247 struct lnet_element_stats ni_stats;
1248 struct lnet_health_local_stats ni_hstats;
1250 /* physical device CPT */
1253 /* sequence number used to round robin over nis within a net */
1258 * initialized to LNET_MAX_HEALTH_VALUE
1259 * Value is decremented every time we fail to send a message over
1260 * this NI because of a NI specific failure.
1261 * Value is incremented if we successfully send a message.
1263 atomic_t ni_healthv;
1266 * Set to 1 by the LND when it receives an event telling it the device
1267 * has gone into a fatal state. Set to 0 when the LND receives an
1268 * even telling it the device is back online.
1270 atomic_t ni_fatal_error_on;
1272 /* the relative selection priority of this NI */
1273 __u32 ni_sel_priority;
1276 * equivalent interface to use
1279 struct net *ni_net_ns; /* original net namespace */
1282 #define LNET_PROTO_PING_MATCHBITS 0x8000000000000000LL
1285 * Descriptor of a ping info buffer: keep a separate indicator of the
1286 * size and a reference count. The type is used both as a source and
1287 * sink of data, so we need to keep some information outside of the
1288 * area that may be overwritten by network data.
1290 struct lnet_ping_buffer {
1291 int pb_nbytes; /* sizeof pb_info */
1292 struct kref pb_refcnt;
1294 struct lnet_ping_info pb_info;
1297 #define LNET_PING_BUFFER_SIZE(bytes) \
1298 (offsetof(struct lnet_ping_buffer, pb_info) + bytes)
1299 #define LNET_PING_BUFFER_LONI(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_nid)
1300 #define LNET_PING_BUFFER_SEQNO(PBUF) ((PBUF)->pb_info.pi_ni[0].ns_status)
1302 #define LNET_PING_INFO_TO_BUFFER(PINFO) \
1303 container_of((PINFO), struct lnet_ping_buffer, pb_info)
1306 lnet_ping_sts_size(const struct lnet_nid *nid)
1310 /* for deciding the size of the ping buffer */
1311 if (unlikely(LNET_NID_IS_ANY(nid)))
1312 return sizeof(struct lnet_ni_large_status);
1314 if (nid_is_nid4(nid))
1315 return sizeof(struct lnet_ni_status);
1317 size = offsetof(struct lnet_ni_large_status, ns_nid) +
1320 return round_up(size, 4);
1323 static inline struct lnet_ni_large_status *
1324 lnet_ping_sts_next(const struct lnet_ni_large_status *nis)
1326 return (void *)nis + lnet_ping_sts_size(&nis->ns_nid);
1330 lnet_ping_at_least_two_entries(const struct lnet_ping_info *pi)
1332 /* Return true if we have at lease two entries. There is always a
1333 * least one, a 4-byte lo0 interface.
1335 struct lnet_ni_large_status *lns;
1337 if ((pi->pi_features & LNET_PING_FEAT_LARGE_ADDR) == 0)
1338 return pi->pi_nnis <= 2;
1339 /* There is at least 1 large-address entry */
1340 if (pi->pi_nnis != 1)
1342 lns = (void *)&pi->pi_ni[1];
1343 lns = lnet_ping_sts_next(lns);
1345 return ((void *)pi + lnet_ping_info_size(pi) <= (void *)lns);
1348 struct lnet_nid_list {
1349 struct list_head nl_list;
1350 struct lnet_nid nl_nid;
1353 struct lnet_peer_ni {
1354 /* chain on lpn_peer_nis */
1355 struct list_head lpni_peer_nis;
1356 /* chain on remote peer list */
1357 struct list_head lpni_on_remote_peer_ni_list;
1358 /* chain on recovery queue */
1359 struct list_head lpni_recovery;
1360 /* chain on peer hash */
1361 struct list_head lpni_hashlist;
1362 /* messages blocking for tx credits */
1363 struct list_head lpni_txq;
1364 /* pointer to peer net I'm part of */
1365 struct lnet_peer_net *lpni_peer_net;
1366 /* statistics kept on each peer NI */
1367 struct lnet_element_stats lpni_stats;
1368 struct lnet_health_remote_stats lpni_hstats;
1369 /* spin lock protecting credits and lpni_txq */
1370 spinlock_t lpni_lock;
1371 /* # tx credits available */
1373 /* low water mark */
1374 int lpni_mintxcredits;
1376 * Each peer_ni in a gateway maintains its own credits. This
1377 * allows more traffic to gateways that have multiple interfaces.
1379 /* # router credits */
1380 int lpni_rtrcredits;
1381 /* low water mark */
1382 int lpni_minrtrcredits;
1383 /* bytes queued for sending */
1385 /* network peer is on */
1386 struct lnet_net *lpni_net;
1388 struct lnet_nid lpni_nid;
1390 struct kref lpni_kref;
1391 /* health value for the peer */
1392 atomic_t lpni_healthv;
1393 /* recovery ping mdh */
1394 struct lnet_handle_md lpni_recovery_ping_mdh;
1395 /* When to send the next recovery ping */
1396 time64_t lpni_next_ping;
1397 /* How many pings sent during current recovery period did not receive
1398 * a reply. NB: reset whenever _any_ message arrives from this peer NI
1400 unsigned int lpni_ping_count;
1401 /* CPT this peer attached on */
1403 /* state flags -- protected by lpni_lock */
1404 unsigned lpni_state;
1405 /* status of the peer NI as reported by the peer */
1406 __u32 lpni_ns_status;
1407 /* sequence number used to round robin over peer nis within a net */
1409 /* sequence number used to round robin over gateways */
1411 /* returned RC ping features. Protected with lpni_lock */
1412 unsigned int lpni_ping_feats;
1413 /* time last message was received from the peer */
1414 time64_t lpni_last_alive;
1415 /* preferred local nids: if only one, use lpni_pref.nid */
1417 struct lnet_nid nid;
1418 struct list_head nids;
1420 /* list of router nids preferred for this peer NI */
1421 struct list_head lpni_rtr_pref_nids;
1422 /* The relative selection priority of this peer NI */
1423 __u32 lpni_sel_priority;
1424 /* number of preferred NIDs in lnpi_pref_nids */
1425 __u32 lpni_pref_nnids;
1426 /* Whether some thread is processing an lnet_notify() event for this
1429 bool lpni_notifying;
1430 /* Timestamp of the last lnet_notify() event for this peer NI */
1431 time64_t lpni_timestamp;
1432 /* Whether we've received an lnet_notify() event for this peer NI */
1436 /* Preferred path added due to traffic on non-MR peer_ni */
1437 #define LNET_PEER_NI_NON_MR_PREF BIT(0)
1438 /* peer is being recovered. */
1439 #define LNET_PEER_NI_RECOVERY_PENDING BIT(1)
1440 /* recovery ping failed */
1441 #define LNET_PEER_NI_RECOVERY_FAILED BIT(2)
1442 /* peer is being deleted */
1443 #define LNET_PEER_NI_DELETING BIT(3)
1446 /* chain on pt_peer_list */
1447 struct list_head lp_peer_list;
1449 /* list of peer nets */
1450 struct list_head lp_peer_nets;
1452 /* list of messages pending discovery*/
1453 struct list_head lp_dc_pendq;
1455 /* chain on router list */
1456 struct list_head lp_rtr_list;
1458 /* primary NID of the peer */
1459 struct lnet_nid lp_primary_nid;
1461 /* source NID to use during discovery */
1462 struct lnet_nid lp_disc_src_nid;
1463 /* destination NID to use during discovery */
1464 struct lnet_nid lp_disc_dst_nid;
1466 /* net to perform discovery on */
1467 __u32 lp_disc_net_id;
1469 /* CPT of peer_table */
1472 /* number of NIDs on this peer */
1475 /* # refs from lnet_route::lr_gateway */
1476 int lp_rtr_refcount;
1479 * peer specific health sensitivity value to decrement peer nis in
1480 * this peer with if set to something other than 0
1482 __u32 lp_health_sensitivity;
1484 /* messages blocking for router credits */
1485 struct list_head lp_rtrq;
1487 /* routes on this peer */
1488 struct list_head lp_routes;
1490 /* reference count */
1491 atomic_t lp_refcount;
1493 /* lock protecting peer state flags and lpni_rtrq */
1496 /* peer state flags */
1499 /* buffer for data pushed by peer */
1500 struct lnet_ping_buffer *lp_data;
1502 /* MD handle for ping in progress */
1503 struct lnet_handle_md lp_ping_mdh;
1505 /* MD handle for push in progress */
1506 struct lnet_handle_md lp_push_mdh;
1508 /* number of bytes for sizing pb_info in push data */
1511 /* NI config sequence number of peer */
1512 __u32 lp_peer_seqno;
1514 /* Local NI config sequence number acked by peer */
1515 __u32 lp_node_seqno;
1517 /* Local NI config sequence number sent to peer */
1518 __u32 lp_node_seqno_sent;
1520 /* Ping error encountered during discovery. */
1523 /* Push error encountered during discovery. */
1526 /* Error encountered during discovery. */
1529 /* time it was put on the ln_dc_working queue */
1530 time64_t lp_last_queued;
1532 /* link on discovery-related lists */
1533 struct list_head lp_dc_list;
1535 /* tasks waiting on discovery of this peer */
1536 wait_queue_head_t lp_dc_waitq;
1538 /* cached peer aliveness */
1541 /* sequence number used to round robin traffic to this peer's
1546 /* timestamp of primary nid lock */
1547 __u64 lp_prim_lock_ts;
1549 /* merge and assign this NID as primary when discovery completes */
1550 struct lnet_nid lp_merge_primary_nid;
1554 * The status flags in lp_state. Their semantics have chosen so that
1555 * lp_state can be zero-initialized.
1557 * A peer is marked MULTI_RAIL in two cases: it was configured using DLC
1558 * as multi-rail aware, or the LNET_PING_FEAT_MULTI_RAIL bit was set.
1560 * A peer is marked NO_DISCOVERY if the LNET_PING_FEAT_DISCOVERY bit was
1561 * NOT set when the peer was pinged by discovery.
1563 * A peer is marked ROUTER if it indicates so in the feature bit.
1565 #define LNET_PEER_MULTI_RAIL BIT(0) /* Multi-rail aware */
1566 #define LNET_PEER_NO_DISCOVERY BIT(1) /* Peer disabled discovery */
1567 #define LNET_PEER_ROUTER_ENABLED BIT(2) /* router feature enabled */
1570 * A peer is marked CONFIGURED if it was configured by DLC.
1572 * In addition, a peer is marked DISCOVERED if it has fully passed
1573 * through Peer Discovery.
1575 * When Peer Discovery is disabled, the discovery thread will mark
1576 * peers REDISCOVER to indicate that they should be re-examined if
1577 * discovery is (re)enabled on the node.
1579 * A peer that was created as the result of inbound traffic will not
1582 #define LNET_PEER_CONFIGURED BIT(3) /* Configured via DLC */
1583 #define LNET_PEER_DISCOVERED BIT(4) /* Peer was discovered */
1584 #define LNET_PEER_REDISCOVER BIT(5) /* Discovery was disabled */
1586 * A peer is marked DISCOVERING when discovery is in progress.
1587 * The other flags below correspond to stages of discovery.
1589 #define LNET_PEER_DISCOVERING BIT(6) /* Discovering */
1590 #define LNET_PEER_DATA_PRESENT BIT(7) /* Remote peer data present */
1591 #define LNET_PEER_NIDS_UPTODATE BIT(8) /* Remote peer info uptodate */
1592 #define LNET_PEER_PING_SENT BIT(9) /* Waiting for REPLY to Ping */
1593 #define LNET_PEER_PUSH_SENT BIT(10) /* Waiting for ACK of Push */
1594 #define LNET_PEER_PING_FAILED BIT(11) /* Ping send failure */
1595 #define LNET_PEER_PUSH_FAILED BIT(12) /* Push send failure */
1597 * A ping can be forced as a way to fix up state, or as a manual
1598 * intervention by an admin.
1599 * A push can be forced in circumstances that would normally not
1600 * allow for one to happen.
1602 #define LNET_PEER_FORCE_PING BIT(13) /* Forced Ping */
1603 #define LNET_PEER_FORCE_PUSH BIT(14) /* Forced Push */
1605 /* force delete even if router */
1606 #define LNET_PEER_RTR_NI_FORCE_DEL BIT(15)
1608 /* gw undergoing alive discovery */
1609 #define LNET_PEER_RTR_DISCOVERY BIT(16)
1610 /* gw has undergone discovery (does not indicate success or failure) */
1611 #define LNET_PEER_RTR_DISCOVERED BIT(17)
1613 /* peer is marked for deletion */
1614 #define LNET_PEER_MARK_DELETION BIT(18)
1615 /* lnet_peer_del()/lnet_peer_del_locked() has been called on the peer */
1616 #define LNET_PEER_MARK_DELETED BIT(19)
1617 /* lock primary NID to what's requested by ULP */
1618 #define LNET_PEER_LOCK_PRIMARY BIT(20)
1619 /* this is for informational purposes only. It is set if a peer gets
1620 * configured from Lustre with a primary NID which belongs to another peer
1621 * which is also configured by Lustre as the primary NID.
1623 #define LNET_PEER_BAD_CONFIG BIT(21)
1625 struct lnet_peer_net {
1626 /* chain on lp_peer_nets */
1627 struct list_head lpn_peer_nets;
1629 /* list of peer_nis on this network */
1630 struct list_head lpn_peer_nis;
1632 /* pointer to the peer I'm part of */
1633 struct lnet_peer *lpn_peer;
1638 /* peer net health */
1641 /* time of next router ping on this net */
1642 time64_t lpn_next_ping;
1644 /* selection sequence number */
1647 /* relative peer net selection priority */
1648 __u32 lpn_sel_priority;
1650 /* reference count */
1651 atomic_t lpn_refcount;
1654 /* peer hash size */
1655 #define LNET_PEER_HASH_BITS 9
1656 #define LNET_PEER_HASH_SIZE (1 << LNET_PEER_HASH_BITS)
1659 * peer hash table - one per CPT
1661 * protected by lnet_net_lock/EX for update
1666 * protected by pt_zombie_lock:
1670 * pt_zombie lock nests inside lnet_net_lock
1672 struct lnet_peer_table {
1673 int pt_version; /* /proc validity stamp */
1674 struct list_head *pt_hash; /* NID->peer hash */
1675 struct list_head pt_peer_list; /* peers */
1676 int pt_peers; /* # peers */
1677 struct list_head pt_zombie_list; /* zombie peer_ni */
1678 int pt_zombies; /* # zombie peers_ni */
1679 spinlock_t pt_zombie_lock; /* protect list and count */
1682 /* peer aliveness is enabled only on routers for peers in a network where the
1683 * struct lnet_ni::ni_peertimeout has been set to a positive value
1685 #define lnet_peer_aliveness_enabled(lp) (the_lnet.ln_routing != 0 && \
1686 ((lp)->lpni_net) && \
1687 (lp)->lpni_net->net_tunables.lct_peer_timeout > 0)
1690 struct list_head lr_list; /* chain on net */
1691 struct list_head lr_gwlist; /* chain on gateway */
1692 struct lnet_peer *lr_gateway; /* router node */
1693 struct lnet_nid lr_nid; /* NID used to add route */
1694 __u32 lr_net; /* remote network number */
1695 __u32 lr_lnet; /* local network number */
1696 int lr_seq; /* sequence for round-robin */
1697 __u32 lr_hops; /* how far I am */
1698 unsigned int lr_priority; /* route priority */
1699 atomic_t lr_alive; /* cached route aliveness */
1700 bool lr_single_hop; /* this route is single-hop */
1703 #define LNET_REMOTE_NETS_HASH_DEFAULT (1U << 7)
1704 #define LNET_REMOTE_NETS_HASH_MAX (1U << 16)
1705 #define LNET_REMOTE_NETS_HASH_SIZE (1 << the_lnet.ln_remote_nets_hbits)
1707 struct lnet_remotenet {
1708 /* chain on ln_remote_nets_hash */
1709 struct list_head lrn_list;
1711 struct list_head lrn_routes;
1716 /** lnet message has credit and can be submitted to lnd for send/receive */
1717 #define LNET_CREDIT_OK 0
1718 /** lnet message is waiting for credit */
1719 #define LNET_CREDIT_WAIT 1
1720 /** lnet message is waiting for discovery */
1721 #define LNET_DC_WAIT 2
1723 struct lnet_rtrbufpool {
1724 /* my free buffer pool */
1725 struct list_head rbp_bufs;
1726 /* messages blocking for a buffer */
1727 struct list_head rbp_msgs;
1728 /* # pages in each buffer */
1730 /* requested number of buffers */
1731 int rbp_req_nbuffers;
1732 /* # buffers actually allocated */
1734 /* # free buffers / blocked messages */
1736 /* low water mark */
1740 struct lnet_rtrbuf {
1741 struct list_head rb_list; /* chain on rbp_bufs */
1742 struct lnet_rtrbufpool *rb_pool; /* owning pool */
1743 struct bio_vec rb_kiov[]; /* the buffer space */
1746 #define LNET_PEER_HASHSIZE 503 /* prime! */
1748 enum lnet_match_flags {
1749 /* Didn't match anything */
1750 LNET_MATCHMD_NONE = BIT(0),
1752 LNET_MATCHMD_OK = BIT(1),
1753 /* Must be discarded */
1754 LNET_MATCHMD_DROP = BIT(2),
1755 /* match and buffer is exhausted */
1756 LNET_MATCHMD_EXHAUSTED = BIT(3),
1758 LNET_MATCHMD_FINISH = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
1761 /* Options for struct lnet_portal::ptl_options */
1762 #define LNET_PTL_LAZY BIT(0)
1763 #define LNET_PTL_MATCH_UNIQUE BIT(1) /* unique match, for RDMA */
1764 #define LNET_PTL_MATCH_WILDCARD BIT(2) /* wildcard match, request portal */
1766 /* parameter for matching operations (GET, PUT) */
1767 struct lnet_match_info {
1769 struct lnet_processid mi_id;
1770 unsigned int mi_cpt;
1771 unsigned int mi_opc;
1772 unsigned int mi_portal;
1773 unsigned int mi_rlength;
1774 unsigned int mi_roffset;
1777 /* ME hash of RDMA portal */
1778 #define LNET_MT_HASH_BITS 8
1779 #define LNET_MT_HASH_SIZE (1 << LNET_MT_HASH_BITS)
1780 #define LNET_MT_HASH_MASK (LNET_MT_HASH_SIZE - 1)
1781 /* we allocate (LNET_MT_HASH_SIZE + 1) entries for lnet_match_table::mt_hash,
1782 * the last entry is reserved for MEs with ignore-bits */
1783 #define LNET_MT_HASH_IGNORE LNET_MT_HASH_SIZE
1784 /* __u64 has 2^6 bits, so need 2^(LNET_MT_HASH_BITS - LNET_MT_BITS_U64) which
1785 * is 4 __u64s as bit-map, and add an extra __u64 (only use one bit) for the
1786 * ME-list with ignore-bits, which is mtable::mt_hash[LNET_MT_HASH_IGNORE] */
1787 #define LNET_MT_BITS_U64 6 /* 2^6 bits */
1788 #define LNET_MT_EXHAUSTED_BITS (LNET_MT_HASH_BITS - LNET_MT_BITS_U64)
1789 #define LNET_MT_EXHAUSTED_BMAP ((1 << LNET_MT_EXHAUSTED_BITS) + 1)
1791 /* portal match table */
1792 struct lnet_match_table {
1793 /* reserved for upcoming patches, CPU partition ID */
1794 unsigned int mt_cpt;
1795 unsigned int mt_portal; /* portal index */
1796 /* match table is set as "enabled" if there's non-exhausted MD
1797 * attached on mt_mhash, it's only valid for wildcard portal */
1798 unsigned int mt_enabled;
1799 /* bitmap to flag whether MEs on mt_hash are exhausted or not */
1800 __u64 mt_exhausted[LNET_MT_EXHAUSTED_BMAP];
1801 struct list_head *mt_mhash; /* matching hash */
1804 /* these are only useful for wildcard portal */
1805 /* Turn off message rotor for wildcard portals */
1806 #define LNET_PTL_ROTOR_OFF 0
1807 /* round-robin dispatch all PUT messages for wildcard portals */
1808 #define LNET_PTL_ROTOR_ON 1
1809 /* round-robin dispatch routed PUT message for wildcard portals */
1810 #define LNET_PTL_ROTOR_RR_RT 2
1811 /* dispatch routed PUT message by hashing source NID for wildcard portals */
1812 #define LNET_PTL_ROTOR_HASH_RT 3
1814 struct lnet_portal {
1815 spinlock_t ptl_lock;
1816 unsigned int ptl_index; /* portal ID, reserved */
1817 /* flags on this portal: lazy, unique... */
1818 unsigned int ptl_options;
1819 /* list of messages which are stealing buffer */
1820 struct list_head ptl_msg_stealing;
1821 /* messages blocking for MD */
1822 struct list_head ptl_msg_delayed;
1823 /* Match table for each CPT */
1824 struct lnet_match_table **ptl_mtables;
1825 /* spread rotor of incoming "PUT" */
1826 unsigned int ptl_rotor;
1827 /* # active entries for this portal */
1829 /* array of active entries' cpu-partition-id */
1833 #define LNET_LH_HASH_BITS 12
1834 #define LNET_LH_HASH_SIZE (1ULL << LNET_LH_HASH_BITS)
1835 #define LNET_LH_HASH_MASK (LNET_LH_HASH_SIZE - 1)
1837 /* resource container (ME, MD, EQ) */
1838 struct lnet_res_container {
1839 unsigned int rec_type; /* container type */
1840 __u64 rec_lh_cookie; /* cookie generator */
1841 struct list_head rec_active; /* active resource list */
1842 struct list_head *rec_lh_hash; /* handle hash */
1845 /* message container */
1846 struct lnet_msg_container {
1847 int msc_init; /* initialized or not */
1848 /* max # threads finalizing */
1849 int msc_nfinalizers;
1850 /* msgs waiting to complete finalizing */
1851 struct list_head msc_finalizing;
1852 /* msgs waiting to be resent */
1853 struct list_head msc_resending;
1854 struct list_head msc_active; /* active message list */
1855 /* threads doing finalization */
1856 void **msc_finalizers;
1857 /* threads doing resends */
1858 void **msc_resenders;
1861 /* This UDSP structures need to match the user space liblnetconfig structures
1862 * in order for the marshall and unmarshall functions to be common.
1865 /* Net is described as a
1869 struct lnet_ud_net_descr {
1871 struct list_head udn_net_num_range;
1874 /* each NID range is defined as
1876 * 2. address range descriptor
1878 struct lnet_ud_nid_descr {
1879 struct lnet_ud_net_descr ud_net_id;
1880 struct list_head ud_addr_range;
1884 /* a UDSP rule can have up to three user defined NID descriptors
1885 * - src: defines the local NID range for the rule
1886 * - dst: defines the peer NID range for the rule
1887 * - rte: defines the router NID range for the rule
1889 * An action union defines the action to take when the rule
1893 struct list_head udsp_on_list;
1895 struct lnet_ud_nid_descr udsp_src;
1896 struct lnet_ud_nid_descr udsp_dst;
1897 struct lnet_ud_nid_descr udsp_rte;
1898 enum lnet_udsp_action_type udsp_action_type;
1900 __u32 udsp_priority;
1904 /* Peer Discovery states */
1905 #define LNET_DC_STATE_SHUTDOWN 0 /* not started */
1906 #define LNET_DC_STATE_RUNNING 1 /* started up OK */
1907 #define LNET_DC_STATE_STOPPING 2 /* telling thread to stop */
1909 /* Router Checker states */
1910 #define LNET_MT_STATE_SHUTDOWN 0 /* not started */
1911 #define LNET_MT_STATE_RUNNING 1 /* started up OK */
1912 #define LNET_MT_STATE_STOPPING 2 /* telling thread to stop */
1915 #define LNET_STATE_SHUTDOWN 0 /* not started */
1916 #define LNET_STATE_RUNNING 1 /* started up OK */
1917 #define LNET_STATE_STOPPING 2 /* telling thread to stop */
1920 /* CPU partition table of LNet */
1921 struct cfs_cpt_table *ln_cpt_table;
1922 /* number of CPTs in ln_cpt_table */
1923 unsigned int ln_cpt_number;
1924 unsigned int ln_cpt_bits;
1926 /* protect LNet resources (ME/MD/EQ) */
1927 struct cfs_percpt_lock *ln_res_lock;
1930 /* the vector of portals */
1931 struct lnet_portal **ln_portals;
1932 /* percpt MD container */
1933 struct lnet_res_container **ln_md_containers;
1935 /* Event Queue container */
1936 struct lnet_res_container ln_eq_container;
1937 spinlock_t ln_eq_wait_lock;
1939 unsigned int ln_remote_nets_hbits;
1941 /* protect NI, peer table, credits, routers, rtrbuf... */
1942 struct cfs_percpt_lock *ln_net_lock;
1943 /* percpt message containers for active/finalizing/freed message */
1944 struct lnet_msg_container **ln_msg_containers;
1945 struct lnet_counters **ln_counters;
1946 struct lnet_peer_table **ln_peer_tables;
1947 /* list of peer nis not on a local network */
1948 struct list_head ln_remote_peer_ni_list;
1949 /* failure simulation */
1950 struct list_head ln_test_peers;
1951 struct list_head ln_drop_rules;
1952 struct list_head ln_delay_rules;
1954 struct list_head ln_nets;
1955 /* Sequence number used to round robin sends across all nets */
1957 /* the loopback NI */
1958 struct lnet_ni *ln_loni;
1959 /* network zombie list */
1960 struct list_head ln_net_zombie;
1961 /* resend messages list */
1962 struct list_head ln_msg_resend;
1963 /* spin lock to protect the msg resend list */
1964 spinlock_t ln_msg_resend_lock;
1966 /* remote networks with routes to them */
1967 struct list_head *ln_remote_nets_hash;
1968 /* validity stamp */
1969 __u64 ln_remote_nets_version;
1970 /* list of all known routers */
1971 struct list_head ln_routers;
1972 /* validity stamp */
1973 __u64 ln_routers_version;
1974 /* percpt router buffer pools */
1975 struct lnet_rtrbufpool **ln_rtrpools;
1978 * Ping target / Push source
1980 * The ping target and push source share a single buffer. The
1981 * ln_ping_target is protected against concurrent updates by
1984 struct lnet_handle_md ln_ping_target_md;
1985 lnet_handler_t ln_ping_target_handler;
1986 struct lnet_ping_buffer *ln_ping_target;
1987 atomic_t ln_ping_target_seqno;
1992 * ln_push_nnis contains the desired size of the push target.
1993 * The lnet_net_lock is used to handle update races. The old
1994 * buffer may linger a while after it has been unlinked, in
1995 * which case the event handler cleans up.
1997 lnet_handler_t ln_push_target_handler;
1998 struct lnet_handle_md ln_push_target_md;
1999 struct lnet_ping_buffer *ln_push_target;
2000 /* bytes needed for pb_info to receive push */
2001 int ln_push_target_nbytes;
2003 /* discovery event queue handle */
2004 lnet_handler_t ln_dc_handler;
2005 /* discovery requests */
2006 struct list_head ln_dc_request;
2007 /* discovery working list */
2008 struct list_head ln_dc_working;
2009 /* discovery expired list */
2010 struct list_head ln_dc_expired;
2011 /* discovery thread wait queue */
2012 wait_queue_head_t ln_dc_waitq;
2013 /* discovery startup/shutdown state */
2016 /* monitor thread startup/shutdown state */
2018 /* serialise startup/shutdown */
2019 struct semaphore ln_mt_signal;
2021 struct mutex ln_api_mutex;
2022 struct mutex ln_lnd_mutex;
2023 /* Have I called LNetNIInit myself? */
2025 /* LNetNIInit/LNetNIFini counter */
2027 /* SHUTDOWN/RUNNING/STOPPING */
2030 int ln_routing; /* am I a router? */
2031 lnet_pid_t ln_pid; /* requested pid */
2032 /* uniquely identifies this ni in this epoch */
2033 __u64 ln_interface_cookie;
2034 /* registered LNDs */
2035 const struct lnet_lnd *ln_lnds[NUM_LNDS];
2037 /* test protocol compatibility flags */
2038 unsigned long ln_testprotocompat;
2040 /* 0 - load the NIs from the mod params
2041 * 1 - do not load the NIs from the mod params
2042 * Reverse logic to ensure that other calls to LNetNIInit
2045 bool ln_nis_from_mod_params;
2047 /* Switch to test large NIDs */
2048 bool ln_nis_use_large_nids;
2051 * completion for the monitor thread. The monitor thread takes care of
2052 * checking routes, timedout messages and resending messages.
2054 struct completion ln_mt_wait_complete;
2056 /* per-cpt resend queues */
2057 struct list_head **ln_mt_resendqs;
2058 /* local NIs to recover */
2059 struct list_head ln_mt_localNIRecovq;
2060 /* local NIs to recover */
2061 struct list_head ln_mt_peerNIRecovq;
2063 * An array of queues for GET/PUT waiting for REPLY/ACK respectively.
2064 * There are CPT number of queues. Since response trackers will be
2065 * added on the fast path we can't afford to grab the exclusive
2066 * net lock to protect these queues. The CPT will be calculated
2067 * based on the mdh cookie.
2069 struct list_head **ln_mt_rstq;
2071 * A response tracker becomes a zombie when the associated MD is queued
2072 * for unlink before the response tracker is detached from the MD. An
2073 * entry on a zombie list can be freed when either the remaining
2074 * operations on the MD complete or when LNet has shut down.
2076 struct list_head **ln_mt_zombie_rstqs;
2077 /* recovery handler */
2078 lnet_handler_t ln_mt_handler;
2081 * Completed when the discovery and monitor threads can enter their
2084 struct completion ln_started;
2086 struct list_head ln_udsp_list;
2088 /* Number of messages that have exceeded their message deadline */
2089 atomic_t ln_late_msg_count;
2090 /* Total amount of time past their deadline for all late ^ messages */
2091 atomic64_t ln_late_msg_nsecs;
2093 /* for LNDs to signal that ping buffer needs updating */
2094 atomic_t ln_update_ping_buf;
2096 /* workqueue for serving lnd ping buffer update requests */
2097 struct workqueue_struct *ln_pb_update_wq;
2098 struct work_struct ln_pb_update_work;
2100 atomic_t ln_pb_update_ready;
2103 static const struct nla_policy scalar_attr_policy[LN_SCALAR_MAX + 1] = {
2104 [LN_SCALAR_ATTR_LIST] = { .type = NLA_NESTED },
2105 [LN_SCALAR_ATTR_LIST_SIZE] = { .type = NLA_U16 },
2106 [LN_SCALAR_ATTR_INDEX] = { .type = NLA_U16 },
2107 [LN_SCALAR_ATTR_NLA_TYPE] = { .type = NLA_U16 },
2108 [LN_SCALAR_ATTR_VALUE] = { .type = NLA_STRING },
2109 [LN_SCALAR_ATTR_KEY_FORMAT] = { .type = NLA_U16 },
2112 int lnet_genl_send_scalar_list(struct sk_buff *msg, u32 portid, u32 seq,
2113 const struct genl_family *family, int flags,
2114 u8 cmd, const struct ln_key_list *data[]);
2116 /* Special workaround for pre-4.19 kernels to send error messages
2117 * from dumpit routines. Newer kernels will send message with
2118 * NL_SET_ERR_MSG information by default if NETLINK_EXT_ACK is set.
2120 static inline int lnet_nl_send_error(struct sk_buff *msg, int portid, int seq,
2123 #ifndef HAVE_NL_DUMP_WITH_EXT_ACK
2124 struct nlmsghdr *nlh;
2129 nlh = nlmsg_put(msg, portid, seq, NLMSG_ERROR, sizeof(error), 0);
2132 #ifdef HAVE_NL_PARSE_WITH_EXT_ACK
2133 netlink_ack(msg, nlh, error, NULL);
2135 netlink_ack(msg, nlh, error);
2137 return nlmsg_len(nlh);