Whamcloud - gitweb
LU-19098 hsm: don't print progname twice with lhsmtool
[fs/lustre-release.git] / lnet / include / lnet / lib-types.h
1 // SPDX-License-Identifier: GPL-2.0
2
3 /* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
4  * Use is subject to license terms.
5  *
6  * Copyright (c) 2012, 2017, Intel Corporation.
7  */
8
9 /* This file is part of Lustre, http://www.lustre.org/
10  *
11  * Types used by the library side routines that do not need to be
12  * exposed to the user application
13  */
14
15 #ifndef __LNET_LIB_TYPES_H__
16 #define __LNET_LIB_TYPES_H__
17
18 #ifndef __KERNEL__
19 # error This include is only for kernel use.
20 #endif
21
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>
28
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>
33
34 int libcfs_strid(struct lnet_processid *id, const char *str);
35
36 int cfs_match_nid_net(struct lnet_nid *nid, u32 net,
37                       struct list_head *net_num_list,
38                       struct list_head *addr);
39
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;
44         u32                     re_lo;
45         u32                     re_hi;
46         u32                     re_stride;
47 };
48
49 struct cfs_expr_list {
50         struct list_head        el_link;
51         struct list_head        el_exprs;
52 };
53
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)
62
63 /* Max payload size */
64 #define LNET_MAX_PAYLOAD        LNET_MTU
65
66 /** limit on the number of fragments in discontiguous MDs */
67 #define LNET_MAX_IOV    256
68
69 /*
70  * This is the maximum health value.
71  * All local and peer NIs created have their health default to this value.
72  */
73 #define LNET_MAX_HEALTH_VALUE 1000
74 #define LNET_MAX_SELECTION_PRIORITY UINT_MAX
75
76 /* forward refs */
77 struct lnet_libmd;
78
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,
91         LNET_MSG_STATUS_END,
92 };
93
94 struct lnet_rsp_tracker {
95         /* chain on the waiting list */
96         struct list_head rspt_on_list;
97         /* cpt to lock */
98         int rspt_cpt;
99         /* nid of next hop */
100         struct lnet_nid rspt_next_hop_nid;
101         /* deadline of the REPLY/ACK */
102         ktime_t rspt_deadline;
103         /* parent MD */
104         struct lnet_handle_md rspt_mdh;
105 };
106
107 struct lnet_msg {
108         struct list_head        msg_activelist;
109         struct list_head        msg_list;       /* Q for credits/MD */
110
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;
116         __u32                   msg_type;
117
118         /*
119          * hold parameters in case message is with held due
120          * to discovery
121          */
122         struct lnet_nid         msg_src_nid_param;
123         struct lnet_nid         msg_rtr_nid_param;
124
125         /*
126          * Deadline for the message after which it will be finalized if it
127          * has not completed.
128          */
129         ktime_t                 msg_deadline;
130
131         /* The message health status. */
132         enum lnet_msg_hstatus   msg_health_status;
133         /* This is a recovery message */
134         bool                    msg_recovery;
135         /* the number of times a transmission has been retried */
136         int                     msg_retry_count;
137         /* flag to indicate that we do not want to resend this message */
138         bool                    msg_no_resend;
139
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;
154
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;
167
168         struct lnet_peer_ni  *msg_txpeer;         /* peer I'm sending to */
169         struct lnet_peer_ni  *msg_rxpeer;         /* peer I received from */
170
171         void                 *msg_private;
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;
176
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;
182
183         struct lnet_event       msg_ev;
184         struct lnet_hdr         msg_hdr;
185 };
186
187 struct lnet_libhandle {
188         struct list_head        lh_hash_chain;
189         __u64                   lh_cookie;
190 };
191
192 #define lh_entry(ptr, type, member) \
193         ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
194
195 struct lnet_me {
196         struct list_head        me_list;
197         int                     me_cpt;
198         struct lnet_processid   me_match_id;
199         unsigned int            me_portal;
200         unsigned int            me_pos;         /* hash offset in mt_hash */
201         __u64                   me_match_bits;
202         __u64                   me_ignore_bits;
203         enum lnet_unlink        me_unlink;
204         struct lnet_libmd      *me_md;
205 };
206
207 struct lnet_libmd {
208         struct list_head         md_list;
209         struct lnet_libhandle    md_lh;
210         struct lnet_me          *md_me;
211         char                    *md_start;
212         unsigned int             md_offset;
213         unsigned int             md_length;
214         unsigned int             md_max_size;
215         int                      md_threshold;
216         int                      md_refcount;
217         unsigned int             md_options;
218         unsigned int             md_flags;
219         unsigned int             md_niov;       /* # frags at end of struct */
220         void                    *md_user_ptr;
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];
225 };
226
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
236  * call.
237  */
238 #define LNET_MD_FLAG_HANDLING    BIT(3)
239 #define LNET_MD_FLAG_GPU         BIT(5) /**< Special mapping needs */
240
241 static inline bool lnet_md_is_gpu(struct lnet_libmd *md)
242 {
243     return (md != NULL) && !!(md->md_flags & LNET_MD_FLAG_GPU);
244 }
245
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 */
251 };
252
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)
258
259 struct netstrfns {
260         u32     nf_type;
261         char    *nf_name;
262         char    *nf_modname;
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,
278                               u32 *max_nid);
279 };
280
281 struct lnet_ni;                                  /* forward ref */
282 struct socket;
283
284 struct lnet_lnd {
285         /* fields initialized by the LND */
286         __u32                   lnd_type;
287
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);
291
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
297          */
298
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
303          * lnet_finalize() */
304         int (*lnd_send)(struct lnet_ni *ni, void *private,
305                         struct lnet_msg *msg);
306
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);
316
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);
325
326         /* notification of peer down */
327         void (*lnd_notify_peer_down)(struct lnet_nid *peer);
328
329         /* accept a new connection */
330         int (*lnd_accept)(struct lnet_ni *ni, struct socket *sock);
331
332         /* get dma_dev priority */
333         unsigned int (*lnd_get_dev_prio)(struct lnet_ni *ni,
334                                          unsigned int dev_idx);
335
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);
339
340         const struct ln_key_list *lnd_keys;
341
342         /* get LND timeout */
343         int (*lnd_get_timeout)(void);
344 };
345
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 */
351 };
352
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
362 };
363
364 enum lnet_ni_state {
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,
371 };
372
373 #define LNET_NI_RECOVERY_PENDING        BIT(0)
374 #define LNET_NI_RECOVERY_FAILED         BIT(1)
375
376 enum lnet_stats_type {
377         LNET_STATS_TYPE_SEND = 0,
378         LNET_STATS_TYPE_RECV,
379         LNET_STATS_TYPE_DROP
380 };
381
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;
388 };
389
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;
394 };
395
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;
403 };
404
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;
410 };
411
412 struct lnet_net {
413         /* chain on the ln_nets */
414         struct list_head        net_list;
415
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 */
420         __u32                   net_id;
421
422         /* round robin selection */
423         __u32                   net_seq;
424
425         /* total number of CPTs in the array */
426         __u32                   net_ncpts;
427
428         /* cumulative CPTs of all NIs in this net */
429         __u32                   *net_cpts;
430
431         /* relative net selection priority */
432         __u32                   net_sel_priority;
433
434         /* network tunables */
435         struct lnet_ioctl_config_lnd_cmn_tunables net_tunables;
436
437         /*
438          * boolean to indicate that the tunables have been set and
439          * shouldn't be reset
440          */
441         bool                    net_tunables_set;
442
443         /* procedural interface */
444         const struct lnet_lnd   *net_lnd;
445
446         /* list of NIs on this net */
447         struct list_head        net_ni_list;
448
449         /* list of NIs being added, but not started yet */
450         struct list_head        net_ni_added;
451
452         /* dying LND instances */
453         struct list_head        net_ni_zombie;
454
455         /* when I was last alive */
456         time64_t                net_last_alive;
457
458         /* protects access to net_last_alive */
459         spinlock_t              net_lock;
460
461         /* list of router nids preferred for this network */
462         struct list_head        net_rtr_pref_nids;
463 };
464
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
468  * the differences.
469  */
470
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
476  *                                      error state.
477  *
478  * @LNET_ERR_ATTR_UNSPEC:               unspecified attribute to catch errors
479  *
480  * @LNET_ERR_ATTR_HDR:                  Name of the error header
481  *                                      (NLA_NUL_STRING)
482  * @LNET_ERR_ATTR_TYPE:                 Which LNet function since error is for
483  *                                      (NLA_STRING)
484  * @LNET_ERR_TYPE_ERRNO:                Error code for failure (NLA_S16)
485  * @LNET_ERR_DESCR:                     Complete error message (NLA_STRING)
486  */
487 enum lnet_err_attrs {
488         LNET_ERR_ATTR_UNSPEC = 0,
489
490         LNET_ERR_ATTR_HDR,
491         LNET_ERR_ATTR_TYPE,
492         LNET_ERR_ATTR_ERRNO,
493         LNET_ERR_ATTR_DESCR,
494         __LNET_ERR_ATTR_MAX_PLUS_ONE,
495 };
496
497 #define LNET_ERR_ATTR_MAX (__LNET_ERR_ATTR_MAX_PLUS_ONE - 1)
498
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.
503  *
504  * @LNET_NET_ATTR_UNSPEC:               unspecified attribute to catch errors
505  *
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)
509  */
510 enum lnet_net_attrs {
511         LNET_NET_ATTR_UNSPEC = 0,
512
513         LNET_NET_ATTR_HDR,
514         LNET_NET_ATTR_TYPE,
515         LNET_NET_ATTR_LOCAL,
516
517         __LNET_NET_ATTR_MAX_PLUS_ONE,
518 };
519
520 #define LNET_NET_ATTR_MAX (__LNET_NET_ATTR_MAX_PLUS_ONE - 1)
521
522 /** enum lnet_net_local_ni_attrs              - LNet local NI netlink properties
523  *                                              attributes that describe local
524  *                                              NI
525  *
526  * @LNET_NET_LOCAL_NI_ATTR_UNSPEC:              unspecified attribute to catch
527  *                                              errors
528  *
529  * @LNET_NET_LOCAL_NI_ATTR_NID:                 NID that represents this NI
530  *                                              (NLA_STRING)
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
534  *                                              (NLA_NESTED)
535  *
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
545  *                                              (NLA_S32)
546  * @LNET_NET_LOCAL_NI_ATTR_CPTS:                CPT core used by this NI
547  *                                              (NLA_STRING)
548  */
549 enum lnet_net_local_ni_attrs {
550         LNET_NET_LOCAL_NI_ATTR_UNSPEC = 0,
551
552         LNET_NET_LOCAL_NI_ATTR_NID,
553         LNET_NET_LOCAL_NI_ATTR_STATUS,
554         LNET_NET_LOCAL_NI_ATTR_INTERFACE,
555
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,
566
567         __LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE,
568 };
569
570 #define LNET_NET_LOCAL_NI_ATTR_MAX (__LNET_NET_LOCAL_NI_ATTR_MAX_PLUS_ONE - 1)
571
572 /** enum lnet_net_local_ni_intf_attrs - LNet NI device netlink properties
573  *                                      attribute that reports the device
574  *                                      in use
575  *
576  * @LNET_NET_LOCAL_NI_INTF_ATTR_UNSPEC: unspecified attribute to catch errors
577  *
578  * @LNET_NET_LOCAL_NI_INTF_ATTR_TYPE:   Physcial device interface (NLA_STRING)
579  */
580 enum lnet_net_local_ni_intf_attrs {
581         LNET_NET_LOCAL_NI_INTF_ATTR_UNSPEC = 0,
582
583         LNET_NET_LOCAL_NI_INTF_ATTR_TYPE,
584
585         __LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE,
586 };
587
588 #define LNET_NET_LOCAL_NI_INTF_ATTR_MAX (__LNET_NET_LOCAL_NI_INTF_ATTR_MAX_PLUS_ONE - 1)
589
590 /** enum lnet_net_local_ni_stats_attrs        - LNet NI netlink properties
591  *                                              attributes that reports the
592  *                                              network traffic stats
593  *
594  * @LNET_NET_LOCAL_NI_STATS_ATTR_UNSPEC:        unspecified attribute to catch
595  *                                              errors
596  *
597  * @LNET_NET_LOCAL_NI_STATS_ATTR_SEND_COUNT:    Number of sent messages
598  *                                              (NLA_U32)
599  * @LNET_NET_LOCAL_NI_STATS_ATTR_RECV_COUNT:    Number of received messages
600  *                                              (NLA_U32)
601  * @LNET_NET_LOCAL_NI_STATS_ATTR_DROP_COUNT:    Number of dropped messages
602  *                                              (NLA_U32)
603  */
604 enum lnet_net_local_ni_stats_attrs {
605         LNET_NET_LOCAL_NI_STATS_ATTR_UNSPEC = 0,
606
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,
611 };
612
613 #define LNET_NET_LOCAL_NI_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_STATS_ATTR_MAX_PLUS_ONE - 1)
614
615 /** enum lnet_net_local_ni_msg_stats_attrs            - LNet NI netlink
616  *                                                      properties attributes
617  *                                                      that reports the message
618  *                                                      type traffic stats
619  *
620  * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_UNSPEC:            unspecified attribute
621  *                                                      to catch errors
622  *
623  * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_PUT_COUNT:         Number of PUT messages
624  *                                                      (NLA_U32)
625  * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_GET_COUNT:         Number of GET messages
626  *                                                      (NLA_U32)
627  * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_REPLY_COUNT:       Number of REPLY messages
628  *                                                      (NLA_U32)
629  * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_ACK_COUNT:         Number of ACK messages
630  *                                                      (NLA_U32)
631  * @LNET_NET_LOCAL_NI_MSG_STATS_ATTR_HELLO_COUNT:       Number of HELLO messages
632  *                                                      (NLA_U32)
633  */
634 enum lnet_net_local_ni_msg_stats_attrs {
635         LNET_NET_LOCAL_NI_MSG_STATS_ATTR_UNSPEC = 0,
636
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,
643 };
644
645 #define LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_MSG_STATS_ATTR_MAX_PLUS_ONE - 1)
646
647 /** enum lnet_net_local_ni_health_stats_attrs         - LNet NI netlink
648  *                                                      properties attributes
649  *                                                      that reports how
650  *                                                      healthly it is.
651  *
652  * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_UNSPEC:         unspecified attribute
653  *                                                      to catch errors
654  *
655  * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_FATAL_ERRORS:   How many fatal errors
656  *                                                      (NLA_S32)
657  * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_LEVEL:          How healthly is NI
658  *                                                      (NLA_S32)
659  * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_INTERRUPTS:     How many interrupts
660  *                                                      happened (NLA_U32)
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
664  *                                                      happened (NLA_U32)
665  * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NO_ROUTE:       How often routing broke
666  *                                                      (NLA_U32)
667  * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_TIMEOUTS:       How often timeouts
668  *                                                      occurred (NLA_U32)
669  * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_ERROR:          The number of errors
670  *                                                      reported (NLA_U32)
671  * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_PING_COUNT:     Number of successful
672  *                                                      ping (NLA_U32)
673  * @LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_NEXT_PING:      Number of next pings
674  *                                                      (NLA_U64)
675  */
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,
679
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,
691 };
692 #define LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX (__LNET_NET_LOCAL_NI_HEALTH_STATS_ATTR_MAX_PLUS_ONE - 1)
693
694 /** enum lnet_net_local_ni_tunables_attrs             - LNet NI tunables
695  *                                                      netlink properties.
696  *                                                      Performance options
697  *                                                      for your NI.
698  *
699  * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_UNSPEC:             unspecified attribute
700  *                                                      to catch errors
701  *
702  * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_TIMEOUT:       Timeout for LNet peer.
703  *                                                      (NLA_S32)
704  * @LNET_NET_LOCAL_NI_TUNABLES_ATTR_PEER_CREDITS:       Credits for LNet peer.
705  *                                                      (NLA_S32)
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
709  *                                                      TX. (NLA_S32)
710  */
711 enum lnet_net_local_ni_tunables_attr {
712         LNET_NET_LOCAL_NI_TUNABLES_ATTR_UNSPEC = 0,
713
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,
719 };
720
721 #define LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX (__LNET_NET_LOCAL_NI_TUNABLES_ATTR_MAX_PLUS_ONE - 1)
722
723 /** enum lnet_route_attrs                     - LNet route netlink
724  *                                              attributes that describe
725  *                                              LNet routes
726  *
727  * @LNET_ROUTE_ATTR_UNSPEC:                     unspecified attribute to
728  *                                              catch errors
729  *
730  * @LNET_ROUTE_ATTR_HDR:                        grouping for LNet route data
731  *                                              (NLA_NUL_STRING)
732  * @LNET_ROUTE_ATTR_NET:                        LNet remote network reached
733  *                                              by the route (NLA_STRING)
734  * @LNET_ROUTE_ATTR_GATEWAY:                    gateway for the route
735  *                                              (NLA_STRING)
736  * @LNET_ROUTE_ATTR_HOP:                        route hop count (NLA_S32)
737  *
738  * @LNET_ROUTE_ATTR_PRIORITY:                   rank of this network path
739  *                                              (NLA_U32)
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)
743  *
744  * @LNET_ROUTE_ATTR_TYPE:                       Report if we support multi-hop
745  *                                              (NLA_STRING)
746  */
747 enum lnet_route_attrs {
748         LNET_ROUTE_ATTR_UNSPEC = 0,
749
750         LNET_ROUTE_ATTR_HDR,
751         LNET_ROUTE_ATTR_NET,
752         LNET_ROUTE_ATTR_GATEWAY,
753         LNET_ROUTE_ATTR_HOP,
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,
759 };
760
761 #define LNET_ROUTE_ATTR_MAX (__LNET_ROUTE_ATTR_MAX_PLUS_ONE - 1)
762
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.
767  *
768  * @LNET_PEER_NI_ATTR_UNSPEC:           unspecified attribute to catch errors
769  *
770  * @LNET_PEER_NI_ATTR_HDR:              grouping for LNet peer data
771  *                                      (NLA_NUL_STRING)
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
776  *                                      (NLA_NESTED)
777  */
778 enum lnet_peer_ni_attrs {
779         LNET_PEER_NI_ATTR_UNSPEC = 0,
780
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,
787 };
788
789 #define LNET_PEER_NI_ATTR_MAX (__LNET_PEER_NI_ATTR_MAX_PLUS_ONE - 1)
790
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
796  *                                              and receiving.
797  *
798  * @LNET_PEER_NI_LIST_ATTR_UNSPEC:              unspecified attribute to catch
799  *                                              errors
800  *
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
803  *                                              (NLA_NESTED)
804  * @LNET_PEER_NI_LIST_ATTR_STATE:               state of remote peer
805  *                                              (NLA_STRING)
806  *
807  * @LNET_PEER_NI_LIST_ATTR_MAX_TX_CREDITS:      Maximum TX credits for remote
808  *                                              peer (NLA_U32)
809  * @LNET_PEER_NI_LIST_ATTR_CUR_TX_CREDITS:      Current TX credits for remote
810  *                                              peer (NLA_U32)
811  * @LNET_PEER_NI_LIST_ATTR_MIN_TX_CREDITS:      Minimum TX credits for remote
812  *                                              peer (NLA_U32)
813  * @LNET_PEER_NI_LIST_ATTR_QUEUE_BUF_COUNT:     Size of TX queue buffer
814  *                                              (NLA_U32)
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
820  *                                              (NLA_U32)
821  * @LNET_PEER_NI_LIST_ATTR_STATS_COUNT:         Remote peer general stats,
822  *                                              reports sent, received, and
823  *                                              dropped packets. (NLA_NESTED)
824  *
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.
836  *                                              (NLA_NESTED)
837  */
838 enum lnet_peer_ni_list_attr {
839         LNET_PEER_NI_LIST_ATTR_UNSPEC = 0,
840
841         LNET_PEER_NI_LIST_ATTR_NID,
842         LNET_PEER_NI_LIST_ATTR_UDSP_INFO,
843         LNET_PEER_NI_LIST_ATTR_STATE,
844
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,
853
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,
858
859         __LNET_PEER_NI_LIST_ATTR_MAX_PLUS_ONE,
860 };
861
862 #define LNET_PEER_NI_LIST_ATTR_MAX (__LNET_PEER_NI_LIST_ATTR_MAX_PLUS_ONE - 1)
863
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.
872  *
873  * @LNET_PEER_NI_LIST_STATS_COUNT_ATTR_UNSPEC:          unspecified attribute to
874  *                                                      catch errors
875  *
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)
882  */
883 enum lnet_peer_ni_list_stats_count {
884         LNET_PEER_NI_LIST_STATS_COUNT_ATTR_UNSPEC = 0,
885
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,
890 };
891
892 #define LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX (__LNET_PEER_NI_LIST_STATS_COUNT_ATTR_MAX_PLUS_ONE - 1)
893
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.
900  *
901  * @LNET_PEER_NI_LIST_STATS_ATTR_UNSPEC:        unspecified attribute to catch
902  *                                              errors
903  *
904  * @LNET_PEER_NI_LIST_STATS_ATTR_PUT:           PUT message count for remote
905  *                                              peer (NLA_U32)
906  * @LNET_PEER_NI_LIST_STATS_ATTR_GET:           GET message count for remote
907  *                                              peer (NLA_U32)
908  * @LNET_PEER_NI_LIST_STATS_ATTR_REPLY:         REPLY message count for remote
909  *                                              peer (NLA_U32)
910  * @LNET_PEER_NI_LIST_STATS_ATTR_ACK:           ACK message count for remote
911  *                                              peer (NLA_U32)
912  * @LNET_PEER_NI_LIST_STATS_ATTR_HEALTH:        HELLO message count for remote
913  *                                              peer (NLA_U32)
914  */
915 enum lnet_peer_ni_list_stats {
916         LNET_PEER_NI_LIST_STATS_ATTR_UNSPEC = 0,
917
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,
924 };
925
926 #define LNET_PEER_NI_LIST_STATS_ATTR_MAX (__LNET_PEER_NI_LIST_STATS_ATTR_MAX_PLUS_ONE - 1)
927
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.
936  *
937  * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_UNSPEC:         unspecified attribute to
938  *                                                      catch errors
939  *
940  * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_VALUE:          Health level of remote
941  *                                                      peer (NLA_S32)
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
945  *                                                      peer (NLA_U32)
946  * @LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_ERROR:          total errors for remote
947  *                                                      peer (NLA_U32)
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
954  *                                                      (NLA_S64)
955  */
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,
959
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,
967
968         __LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX_PLUS_ONE,
969 };
970
971 #define LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX (__LNET_PEER_NI_LIST_HEALTH_STATS_ATTR_MAX_PLUS_ONE - 1)
972
973 /** LNet netlink ping API */
974
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.
979  *
980  * @LNET_PING_ATTR_UNSPEC:                              unspecified attribute to catch errors
981  *
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)
987  */
988 enum lnet_ping_attr {
989         LNET_PING_ATTR_UNSPEC = 0,
990
991         LNET_PING_ATTR_HDR,
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,
997 };
998
999 #define LNET_PING_ATTR_MAX (__LNET_PING_ATTR_MAX_PLUS_ONE - 1)
1000
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.
1004  *
1005  * @LNET_PING_PEER_NI_ATTR_UNSPEC:                      unspecified attribute to catch errrors
1006  *
1007  * @LNET_PING_PEER_NI_ATTR_NID:                         NID address of peer NI. (NLA_STRING)
1008  */
1009 enum lnet_ping_peer_ni_attr {
1010         LNET_PING_PEER_NI_ATTR_UNSPEC = 0,
1011
1012         LNET_PING_PEER_NI_ATTR_NID,
1013         __LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE,
1014 };
1015
1016 #define LNET_PING_PEER_NI_ATTR_MAX (__LNET_PING_PEER_NI_ATTR_MAX_PLUS_ONE - 1)
1017
1018 /** enum lnet_udsp_info_attr                          - LNet UDSP information reported for
1019  *                                                      some subsystem that tracks it.
1020  *
1021  * @LNET_UDSP_INFO_ATTR_UNSPEC:                         unspecified attribute to catch errors
1022  *
1023  * @LNET_UDSP_INFO_ATTR_NET_PRIORITY,                   LNet net priority in selection.
1024  *                                                      (NLA_S32)
1025  * @LNET_UDSP_INFO_ATTR_NID_PRIORITY,                   NID's priority in selection.
1026  *                                                      (NLA_S32)
1027  * @LNET_UDSP_INFO_ATTR_PREF_RTR_NIDS_LIST:             Which gateway's are preferred.
1028  *                                                      (NLA_NESTED)
1029  * @LNET_UDSP_INFO_ATTR_PREF_NIDS_LIST:                 Which NIDs are preferred.
1030  *                                                      (NLA_NESTED)
1031  */
1032 enum lnet_udsp_info_attr {
1033         LNET_UDSP_INFO_ATTR_UNSPEC = 0,
1034
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,
1040 };
1041
1042 #define LNET_UDSP_INFO_ATTR_MAX (__LNET_UDSP_INFO_ATTR_MAX_PLUS_ONE - 1)
1043
1044 /** enum lnet_udsp_info_pref_nids_attr                - LNet UDSP information reported for
1045  *                                                      some subsystem that tracks it.
1046  *
1047  * @LNET_UDSP_INFO_PREF_NIDS_ATTR_UNSPEC:               unspecified attribute to catch errors
1048  *
1049  * @LNET_UDSP_INFO_PREF_NIDS_ATTR_INDEX,                UDSP prority NIDs label
1050  *                                                      (NLA_NUL_STRING)
1051  * @LNET_UDSP_INFO_PREF_NIDS_ATTR_NID,                  UDSP prority NID (NLA_STRING)
1052  */
1053 enum lnet_udsp_info_pref_nids_attr {
1054         LNET_UDSP_INFO_PREF_NIDS_ATTR_UNSPEC = 0,
1055
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,
1059 };
1060
1061 #define LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX (__LNET_UDSP_INFO_PREF_NIDS_ATTR_MAX_PLUS_ONE - 1)
1062
1063 /** enum lnet_cpt_of_nid_attr                   - Attributes to support
1064  *                                                lnetctl cpt-of-nid command
1065  *
1066  * @LNET_CPT_OF_NID_ATTR_UNSPEC                   unspecified attribute to catch
1067  *                                                errors
1068  * @LNET_CPT_OF_NID_ATTR_HDR                      Grouping for cpt-of-nid
1069  *                                                (NLA_NUL_STRING)
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
1073  *                                                (NLA_U32)
1074  */
1075 enum lnet_cpt_of_nid_attr {
1076         LNET_CPT_OF_NID_ATTR_UNSPEC = 0,
1077
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,
1082 };
1083
1084 #define LNET_CPT_OF_NID_ATTR_MAX (__LNET_CPT_OF_NID_ATTR_MAX_PLUS_ONE - 1)
1085
1086 /** enum lnet_peer_dist_attr                  - Attributes to support
1087  *                                              reporting distance for peers
1088  *
1089  * @LNET_PEER_DIST_ATTR_UNSPEC                  unspecified attribute to catch
1090  *                                              errors
1091  * @LNET_PEER_DIST_ATTR_HDR                     Grouping which we just use peer
1092  *                                              (NLA_NUL_STRING)
1093  * @LNET_PEER_DIST_ATTR_NID                     The NID we collect data for
1094  *                                              (NLA_STRING)
1095  * @LNET_PEER_DIST_ATTR_DIST                    The distance for the specified
1096  *                                              NID (NLA_U32)
1097  * @LNET_PEER_DIST_ATTR_ORDER                   The order for the specified NID
1098  *                                              (NLA_U32)
1099  */
1100 enum lnet_peer_dist_attr {
1101         LNET_PEER_DIST_ATTR_UNSPEC = 0,
1102
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,
1108 };
1109
1110 #define LNET_PEER_DIST_ATTR_MAX (__LNET_PEER_DIST_ATTR_MAX_PLUS_ONE - 1)
1111
1112 /** enum lnet_debug_recovery_attr               Attributes to report contents of
1113  *                                              the LNet health recovery queues
1114  *
1115  * @LNET_DBG_RECOV_ATTR_UNSPEC                  Unspecified attribute to catch
1116  *                                              errors
1117  * @LNET_DBG_RECOV_ATTR_HDR                     Grouping for NI recovery queue
1118  *                                              (NLA_NUL_STRING)
1119  * @LNET_DBG_RECOV_ATTR_NID                     A NID in one of the recovery
1120  *                                              queues (NLA_STRING)
1121  */
1122 enum lnet_debug_recovery_attr {
1123         LNET_DBG_RECOV_ATTR_UNSPEC = 0,
1124
1125         LNET_DBG_RECOV_ATTR_HDR,
1126         LNET_DBG_RECOV_ATTR_NID,
1127         __LNET_DBG_RECOV_ATTR_MAX_PLUS_ONE,
1128 };
1129
1130 #define LNET_DBG_RECOV_ATTR_MAX (__LNET_DBG_RECOV_ATTR_MAX_PLUS_ONE - 1)
1131
1132
1133 /** enum lnet_fault_rule_attr           Attributes to report LNet fault
1134  *                                      injection.
1135  *
1136  * @LNET_FAULT_ATTR_UNSPEC              Unspecified attribute to catch errors
1137  * @LNET_FAULT_ATTR_PAD                 Pad attribute for 64b alignment
1138  *
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
1160  */
1161 enum lnet_fault_rule_attr {
1162         LNET_FAULT_ATTR_UNSPEC = 0,
1163         LNET_FAULT_ATTR_PAD = LNET_FAULT_ATTR_UNSPEC,
1164
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,
1184 };
1185
1186 #define LNET_FAULT_ATTR_MAX (__LNET_FAULT_ATTR_MAX_PLUS_ONE - 1)
1187
1188 struct lnet_ni {
1189         /* chain on the lnet_net structure */
1190         struct list_head        ni_netlist;
1191
1192         /* chain on the recovery queue */
1193         struct list_head        ni_recovery;
1194
1195         /* MD handle for recovery ping */
1196         struct lnet_handle_md   ni_ping_mdh;
1197
1198         spinlock_t              ni_lock;
1199
1200         /* number of CPTs */
1201         int                     ni_ncpts;
1202
1203         /* bond NI on some CPTs */
1204         __u32                   *ni_cpts;
1205
1206         /* interface's NID */
1207         struct lnet_nid         ni_nid;
1208
1209         /* instance-specific data */
1210         void                    *ni_data;
1211
1212         /* per ni credits */
1213         atomic_t                ni_tx_credits;
1214
1215         /* percpt TX queues */
1216         struct lnet_tx_queue    **ni_tx_queues;
1217
1218         /* percpt reference count */
1219         int                     **ni_refs;
1220
1221         /* pointer to parent network */
1222         struct lnet_net         *ni_net;
1223
1224         /* my health status */
1225         u32                     *ni_status;
1226
1227         /* NI FSM. Protected by lnet_ni_lock() */
1228         enum lnet_ni_state      ni_state;
1229
1230         /* Recovery state. Protected by lnet_ni_lock() */
1231         __u32                   ni_recovery_state;
1232
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
1237          */
1238         unsigned int            ni_ping_count;
1239
1240         /* per NI LND tunables */
1241         struct lnet_lnd_tunables ni_lnd_tunables;
1242
1243         /* lnd tunables set explicitly */
1244         bool ni_lnd_tunables_set;
1245
1246         /* NI statistics */
1247         struct lnet_element_stats ni_stats;
1248         struct lnet_health_local_stats ni_hstats;
1249
1250         /* physical device CPT */
1251         int                     ni_dev_cpt;
1252
1253         /* sequence number used to round robin over nis within a net */
1254         __u32                   ni_seq;
1255
1256         /*
1257          * health value
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.
1262          */
1263         atomic_t                ni_healthv;
1264
1265         /*
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.
1269          */
1270         atomic_t                ni_fatal_error_on;
1271
1272         /* the relative selection priority of this NI */
1273         __u32                   ni_sel_priority;
1274
1275         /*
1276          * equivalent interface to use
1277          */
1278         char                    *ni_interface;
1279         struct net              *ni_net_ns;     /* original net namespace */
1280 };
1281
1282 #define LNET_PROTO_PING_MATCHBITS       0x8000000000000000LL
1283
1284 /*
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.
1289  */
1290 struct lnet_ping_buffer {
1291         int                     pb_nbytes;      /* sizeof pb_info */
1292         struct kref             pb_refcnt;
1293         bool                    pb_needs_post;
1294         struct lnet_ping_info   pb_info;
1295 };
1296
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)
1301
1302 #define LNET_PING_INFO_TO_BUFFER(PINFO) \
1303         container_of((PINFO), struct lnet_ping_buffer, pb_info)
1304
1305 static inline int
1306 lnet_ping_sts_size(const struct lnet_nid *nid)
1307 {
1308         int size;
1309
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);
1313
1314         if (nid_is_nid4(nid))
1315                 return sizeof(struct lnet_ni_status);
1316
1317         size = offsetof(struct lnet_ni_large_status, ns_nid) +
1318                NID_BYTES(nid);
1319
1320         return round_up(size, 4);
1321 }
1322
1323 static inline struct lnet_ni_large_status *
1324 lnet_ping_sts_next(const struct lnet_ni_large_status *nis)
1325 {
1326         return (void *)nis + lnet_ping_sts_size(&nis->ns_nid);
1327 }
1328
1329 static inline bool
1330 lnet_ping_at_least_two_entries(const struct lnet_ping_info *pi)
1331 {
1332         /* Return true if we have at lease two entries.  There is always a
1333          * least one, a 4-byte lo0 interface.
1334          */
1335         struct lnet_ni_large_status *lns;
1336
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)
1341                 return false;
1342         lns = (void *)&pi->pi_ni[1];
1343         lns = lnet_ping_sts_next(lns);
1344
1345         return ((void *)pi + lnet_ping_info_size(pi) <= (void *)lns);
1346 }
1347
1348 struct lnet_nid_list {
1349         struct list_head nl_list;
1350         struct lnet_nid nl_nid;
1351 };
1352
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 */
1372         int                     lpni_txcredits;
1373         /* low water mark */
1374         int                     lpni_mintxcredits;
1375         /*
1376          * Each peer_ni in a gateway maintains its own credits. This
1377          * allows more traffic to gateways that have multiple interfaces.
1378          */
1379         /* # router credits */
1380         int                     lpni_rtrcredits;
1381         /* low water mark */
1382         int                     lpni_minrtrcredits;
1383         /* bytes queued for sending */
1384         long                    lpni_txqnob;
1385         /* network peer is on */
1386         struct lnet_net         *lpni_net;
1387         /* peer's NID */
1388         struct lnet_nid         lpni_nid;
1389         /* # refs */
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
1399          */
1400         unsigned int            lpni_ping_count;
1401         /* CPT this peer attached on */
1402         int                     lpni_cpt;
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 */
1408         __u32                   lpni_seq;
1409         /* sequence number used to round robin over gateways */
1410         __u32                   lpni_gw_seq;
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 */
1416         union lpni_pref {
1417                 struct lnet_nid nid;
1418                 struct list_head nids;
1419         } lpni_pref;
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
1427          * peer NI
1428          */
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 */
1433         bool                    lpni_notified;
1434 };
1435
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)
1444
1445 struct lnet_peer {
1446         /* chain on pt_peer_list */
1447         struct list_head        lp_peer_list;
1448
1449         /* list of peer nets */
1450         struct list_head        lp_peer_nets;
1451
1452         /* list of messages pending discovery*/
1453         struct list_head        lp_dc_pendq;
1454
1455         /* chain on router list */
1456         struct list_head        lp_rtr_list;
1457
1458         /* primary NID of the peer */
1459         struct lnet_nid         lp_primary_nid;
1460
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;
1465
1466         /* net to perform discovery on */
1467         __u32                   lp_disc_net_id;
1468
1469         /* CPT of peer_table */
1470         int                     lp_cpt;
1471
1472         /* number of NIDs on this peer */
1473         int                     lp_nnis;
1474
1475         /* # refs from lnet_route::lr_gateway */
1476         int                     lp_rtr_refcount;
1477
1478         /*
1479          * peer specific health sensitivity value to decrement peer nis in
1480          * this peer with if set to something other than 0
1481          */
1482         __u32                   lp_health_sensitivity;
1483
1484         /* messages blocking for router credits */
1485         struct list_head        lp_rtrq;
1486
1487         /* routes on this peer */
1488         struct list_head        lp_routes;
1489
1490         /* reference count */
1491         atomic_t                lp_refcount;
1492
1493         /* lock protecting peer state flags and lpni_rtrq */
1494         spinlock_t              lp_lock;
1495
1496         /* peer state flags */
1497         unsigned                lp_state;
1498
1499         /* buffer for data pushed by peer */
1500         struct lnet_ping_buffer *lp_data;
1501
1502         /* MD handle for ping in progress */
1503         struct lnet_handle_md   lp_ping_mdh;
1504
1505         /* MD handle for push in progress */
1506         struct lnet_handle_md   lp_push_mdh;
1507
1508         /* number of bytes for sizing pb_info in push data */
1509         int                     lp_data_bytes;
1510
1511         /* NI config sequence number of peer */
1512         __u32                   lp_peer_seqno;
1513
1514         /* Local NI config sequence number acked by peer */
1515         __u32                   lp_node_seqno;
1516
1517         /* Local NI config sequence number sent to peer */
1518         __u32                   lp_node_seqno_sent;
1519
1520         /* Ping error encountered during discovery. */
1521         int                     lp_ping_error;
1522
1523         /* Push error encountered during discovery. */
1524         int                     lp_push_error;
1525
1526         /* Error encountered during discovery. */
1527         int                     lp_dc_error;
1528
1529         /* time it was put on the ln_dc_working queue */
1530         time64_t                lp_last_queued;
1531
1532         /* link on discovery-related lists */
1533         struct list_head        lp_dc_list;
1534
1535         /* tasks waiting on discovery of this peer */
1536         wait_queue_head_t       lp_dc_waitq;
1537
1538         /* cached peer aliveness */
1539         bool                    lp_alive;
1540
1541         /* sequence number used to round robin traffic to this peer's
1542          * nets/NIs
1543          */
1544         __u32                   lp_send_seq;
1545
1546         /* timestamp of primary nid lock */
1547         __u64                   lp_prim_lock_ts;
1548
1549         /* merge and assign this NID as primary when discovery completes */
1550         struct lnet_nid         lp_merge_primary_nid;
1551 };
1552
1553 /*
1554  * The status flags in lp_state. Their semantics have chosen so that
1555  * lp_state can be zero-initialized.
1556  *
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.
1559  *
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.
1562  *
1563  * A peer is marked ROUTER if it indicates so in the feature bit.
1564  */
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 */
1568
1569 /*
1570  * A peer is marked CONFIGURED if it was configured by DLC.
1571  *
1572  * In addition, a peer is marked DISCOVERED if it has fully passed
1573  * through Peer Discovery.
1574  *
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.
1578  *
1579  * A peer that was created as the result of inbound traffic will not
1580  * be marked at all.
1581  */
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 */
1585 /*
1586  * A peer is marked DISCOVERING when discovery is in progress.
1587  * The other flags below correspond to stages of discovery.
1588  */
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 */
1596 /*
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.
1601  */
1602 #define LNET_PEER_FORCE_PING            BIT(13) /* Forced Ping */
1603 #define LNET_PEER_FORCE_PUSH            BIT(14) /* Forced Push */
1604
1605 /* force delete even if router */
1606 #define LNET_PEER_RTR_NI_FORCE_DEL      BIT(15)
1607
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)
1612
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.
1622  */
1623 #define LNET_PEER_BAD_CONFIG            BIT(21)
1624
1625 struct lnet_peer_net {
1626         /* chain on lp_peer_nets */
1627         struct list_head        lpn_peer_nets;
1628
1629         /* list of peer_nis on this network */
1630         struct list_head        lpn_peer_nis;
1631
1632         /* pointer to the peer I'm part of */
1633         struct lnet_peer        *lpn_peer;
1634
1635         /* Net ID */
1636         __u32                   lpn_net_id;
1637
1638         /* peer net health */
1639         int                     lpn_healthv;
1640
1641         /* time of next router ping on this net */
1642         time64_t                lpn_next_ping;
1643
1644         /* selection sequence number */
1645         __u32                   lpn_seq;
1646
1647         /* relative peer net selection priority */
1648         __u32                   lpn_sel_priority;
1649
1650         /* reference count */
1651         atomic_t                lpn_refcount;
1652 };
1653
1654 /* peer hash size */
1655 #define LNET_PEER_HASH_BITS     9
1656 #define LNET_PEER_HASH_SIZE     (1 << LNET_PEER_HASH_BITS)
1657
1658 /*
1659  * peer hash table - one per CPT
1660  *
1661  * protected by lnet_net_lock/EX for update
1662  *    pt_version
1663  *    pt_hash[...]
1664  *    pt_peer_list
1665  *    pt_peers
1666  * protected by pt_zombie_lock:
1667  *    pt_zombie_list
1668  *    pt_zombies
1669  *
1670  * pt_zombie lock nests inside lnet_net_lock
1671  */
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 */
1680 };
1681
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
1684  */
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)
1688
1689 struct lnet_route {
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 */
1701 };
1702
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)
1706
1707 struct lnet_remotenet {
1708         /* chain on ln_remote_nets_hash */
1709         struct list_head        lrn_list;
1710         /* routes to me */
1711         struct list_head        lrn_routes;
1712         /* my net number */
1713         __u32                   lrn_net;
1714 };
1715
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
1722
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 */
1729         int                     rbp_npages;
1730         /* requested number of buffers */
1731         int                     rbp_req_nbuffers;
1732         /* # buffers actually allocated */
1733         int                     rbp_nbuffers;
1734         /* # free buffers / blocked messages */
1735         int                     rbp_credits;
1736         /* low water mark */
1737         int                     rbp_mincredits;
1738 };
1739
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 */
1744 };
1745
1746 #define LNET_PEER_HASHSIZE   503                /* prime! */
1747
1748 enum lnet_match_flags {
1749         /* Didn't match anything */
1750         LNET_MATCHMD_NONE       = BIT(0),
1751         /* Matched OK */
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),
1757         /* match or drop */
1758         LNET_MATCHMD_FINISH     = (LNET_MATCHMD_OK | LNET_MATCHMD_DROP),
1759 };
1760
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 */
1765
1766 /* parameter for matching operations (GET, PUT) */
1767 struct lnet_match_info {
1768         __u64                   mi_mbits;
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;
1775 };
1776
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)
1790
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 */
1802 };
1803
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
1813
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 */
1828         int                     ptl_mt_nmaps;
1829         /* array of active entries' cpu-partition-id */
1830         int                     ptl_mt_maps[];
1831 };
1832
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)
1836
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 */
1843 };
1844
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;
1859 };
1860
1861 /* This UDSP structures need to match the user space liblnetconfig structures
1862  * in order for the marshall and unmarshall functions to be common.
1863  */
1864
1865 /* Net is described as a
1866  *  1. net type
1867  *  2. num range
1868  */
1869 struct lnet_ud_net_descr {
1870         __u32 udn_net_type;
1871         struct list_head udn_net_num_range;
1872 };
1873
1874 /* each NID range is defined as
1875  *  1. net descriptor
1876  *  2. address range descriptor
1877  */
1878 struct lnet_ud_nid_descr {
1879         struct lnet_ud_net_descr ud_net_id;
1880         struct list_head ud_addr_range;
1881         __u32 ud_mem_size;
1882 };
1883
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
1888  *
1889  * An action union defines the action to take when the rule
1890  * is matched
1891  */
1892 struct lnet_udsp {
1893         struct list_head udsp_on_list;
1894         __u32 udsp_idx;
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;
1899         union {
1900                 __u32 udsp_priority;
1901         } udsp_action;
1902 };
1903
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 */
1908
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 */
1913
1914 /* LNet states */
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 */
1918
1919 struct lnet {
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;
1925
1926         /* protect LNet resources (ME/MD/EQ) */
1927         struct cfs_percpt_lock          *ln_res_lock;
1928         /* # portals */
1929         int                             ln_nportals;
1930         /* the vector of portals */
1931         struct lnet_portal              **ln_portals;
1932         /* percpt MD container */
1933         struct lnet_res_container       **ln_md_containers;
1934
1935         /* Event Queue container */
1936         struct lnet_res_container       ln_eq_container;
1937         spinlock_t                      ln_eq_wait_lock;
1938
1939         unsigned int                    ln_remote_nets_hbits;
1940
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;
1953         /* LND instances */
1954         struct list_head                ln_nets;
1955         /* Sequence number used to round robin sends across all nets */
1956         __u32                           ln_net_seq;
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;
1965
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;
1976
1977         /*
1978          * Ping target / Push source
1979          *
1980          * The ping target and push source share a single buffer. The
1981          * ln_ping_target is protected against concurrent updates by
1982          * ln_api_mutex.
1983          */
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;
1988
1989         /*
1990          * Push Target
1991          *
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.
1996          */
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;
2002
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 */
2014         int                             ln_dc_state;
2015
2016         /* monitor thread startup/shutdown state */
2017         int                             ln_mt_state;
2018         /* serialise startup/shutdown */
2019         struct semaphore                ln_mt_signal;
2020
2021         struct mutex                    ln_api_mutex;
2022         struct mutex                    ln_lnd_mutex;
2023         /* Have I called LNetNIInit myself? */
2024         int                             ln_niinit_self;
2025         /* LNetNIInit/LNetNIFini counter */
2026         int                             ln_refcount;
2027         /* SHUTDOWN/RUNNING/STOPPING */
2028         int                             ln_state;
2029
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];
2036
2037         /* test protocol compatibility flags */
2038         unsigned long                   ln_testprotocompat;
2039
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
2043          * need no change
2044          */
2045         bool                            ln_nis_from_mod_params;
2046
2047         /* Switch to test large NIDs */
2048         bool                            ln_nis_use_large_nids;
2049
2050         /*
2051          * completion for the monitor thread. The monitor thread takes care of
2052          * checking routes, timedout messages and resending messages.
2053          */
2054         struct completion               ln_mt_wait_complete;
2055
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;
2062         /*
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.
2068          */
2069         struct list_head                **ln_mt_rstq;
2070         /*
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.
2075          */
2076         struct list_head                **ln_mt_zombie_rstqs;
2077         /* recovery handler */
2078         lnet_handler_t                  ln_mt_handler;
2079
2080         /*
2081          * Completed when the discovery and monitor threads can enter their
2082          * work loops
2083          */
2084         struct completion               ln_started;
2085         /* UDSP list */
2086         struct list_head                ln_udsp_list;
2087
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;
2092
2093         /* for LNDs to signal that ping buffer needs updating */
2094         atomic_t                        ln_update_ping_buf;
2095
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;
2099
2100         atomic_t                        ln_pb_update_ready;
2101 };
2102
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 },
2110 };
2111
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[]);
2115
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.
2119  */
2120 static inline int lnet_nl_send_error(struct sk_buff *msg, int portid, int seq,
2121                                      int error)
2122 {
2123 #ifndef HAVE_NL_DUMP_WITH_EXT_ACK
2124         struct nlmsghdr *nlh;
2125
2126         if (!error)
2127                 return 0;
2128
2129         nlh = nlmsg_put(msg, portid, seq, NLMSG_ERROR, sizeof(error), 0);
2130         if (!nlh)
2131                 return -ENOMEM;
2132 #ifdef HAVE_NL_PARSE_WITH_EXT_ACK
2133         netlink_ack(msg, nlh, error, NULL);
2134 #else
2135         netlink_ack(msg, nlh, error);
2136 #endif
2137         return nlmsg_len(nlh);
2138 #else
2139         return error;
2140 #endif
2141 }
2142
2143 #endif