Whamcloud - gitweb
LU-17888 osd-ldiskfs: osd_scrub_refresh_mapping deadlock
[fs/lustre-release.git] / lnet / include / uapi / linux / lnet / nidstr.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) 2015, 2017, Intel Corporation.
7  */
8
9 /* This file is part of Lustre, http://www.lustre.org/ */
10
11 #ifndef _LNET_NIDSTRINGS_H
12 #define _LNET_NIDSTRINGS_H
13
14 #include <linux/types.h>
15 #include <linux/lnet/lnet-types.h>
16
17 /**
18  *  Lustre Network Driver types.
19  */
20 enum {
21         /* Only add to these values (i.e. don't ever change or redefine them):
22          * network addresses depend on them...
23          *
24          * It is important to keep these definitions and the nidstring handlers
25          * in libcfs_netstrfns[] around for several releases after the actual
26          * LND support has been removed, so that it is still possible to use
27          * LNet routers between peers that may still be using the old LND type.
28          *
29          * The "removed" version is when the LND code was deleted.
30          * The nidstring handling was removed several releases later.
31          */
32         /* QSWLND       = 1,  removed v2_7_50_0-34-g8be9e41369        */
33         SOCKLND         = 2,  /* TCP Sockets                          */
34         /* GMLND        = 3,  removed v2_0_0-rc1a-16-gc660aac3        */
35         /* PTLLND       = 4,  removed v2_7_50_0-34-g8be9e41369        */
36         O2IBLND         = 5,  /* OpenFabrics Alliance OFED v2         */
37         /* CIBLND       = 6,  removed v2_0_0-rc1a-175-gd2b8a0e        */
38         /* OPENIBLND    = 7,  removed v2_0_0-rc1a-175-gd2b8a0e        */
39         /* IIBLND       = 8,  removed v2_0_0-rc1a-175-gd2b8a0e        */
40         LOLND           = 9,  /* LNet internal loopback/memcpy        */
41         /* RALND        = 10, removed v2_7_50_0-34-g8be9e41369        */
42         /* VIBLND       = 11, removed v2_0_0-rc1a-175-gd2b8a0e        */
43         /* MXLND        = 12, removed v2_7_50_0-34-g8be9e41369        */
44         GNILND          = 13, /* Cray/HPE Gemini Network Interface    */
45         GNIIPLND        = 14, /* Cray/HPE Gemini IP Network Interface */
46         PTL4LND         = 15, /* ATOS/Bull Portals 4 for BXI          */
47         KFILND          = 16, /* HPE Kernel Fabric Interface          */
48         TOFULND         = 17, /* Fujitsu Torus Fusion                 */
49         EFALND          = 18, /* Amazon Elastic Fabric Adapter        */
50         /* Please email adilger@whamcloud.com and lustre-devel@lists.lustre.org
51          * to reserve new LND numbers before they are used anywhere.  This only
52          * takes a few minutes, and will save everyone a lot of grief later.
53          */
54         NUM_LNDS
55 };
56
57 struct list_head;
58
59 #define LNET_NIDSTR_COUNT 1024  /* # of nidstrings */
60 #define LNET_NIDSTR_SIZE  64    /* size of each one (see below for usage) */
61
62 /* support decl needed by both kernel and user space */
63 char *libcfs_next_nidstring(void);
64 int libcfs_isknown_lnd(__u32 lnd);
65 char *libcfs_lnd2modname(__u32 lnd);
66 char *libcfs_lnd2str_r(__u32 lnd, char *buf, __kernel_size_t buf_size);
67 static inline char *libcfs_lnd2str(__u32 lnd)
68 {
69         return libcfs_lnd2str_r(lnd, libcfs_next_nidstring(),
70                                 LNET_NIDSTR_SIZE);
71 }
72 int libcfs_str2lnd(const char *str);
73 char *libcfs_net2str_r(__u32 net, char *buf, __kernel_size_t buf_size);
74 static inline char *libcfs_net2str(__u32 net)
75 {
76         return libcfs_net2str_r(net, libcfs_next_nidstring(),
77                                 LNET_NIDSTR_SIZE);
78 }
79 char *libcfs_nid2str_r(lnet_nid_t nid, char *buf, __kernel_size_t buf_size);
80 static inline char *libcfs_nid2str(lnet_nid_t nid)
81 {
82         return libcfs_nid2str_r(nid, libcfs_next_nidstring(),
83                                 LNET_NIDSTR_SIZE);
84 }
85
86 char *libcfs_nidstr_r(const struct lnet_nid *nid,
87                       char *buf, __kernel_size_t buf_size);
88
89 static inline char *libcfs_nidstr(const struct lnet_nid *nid)
90 {
91         return libcfs_nidstr_r(nid, libcfs_next_nidstring(),
92                                LNET_NIDSTR_SIZE);
93 }
94
95 int libcfs_strnid(struct lnet_nid *nid, const char *str);
96 #ifdef __KERNEL__
97 char *libcfs_idstr(struct lnet_processid *id);
98 #endif
99 __u32 libcfs_str2net(const char *str);
100 lnet_nid_t libcfs_str2nid(const char *str);
101 int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
102 int libcfs_num_parse(char *str, int len, struct list_head *list);
103 char *libcfs_id2str(struct lnet_process_id id);
104 void cfs_free_nidlist(struct list_head *list);
105 #ifdef __KERNEL__
106 int cfs_parse_nidlist(char *str, struct list_head *list);
107 #else
108 int cfs_parse_nidlist(char *str, int len, struct list_head *list);
109 #endif
110 int cfs_print_nidlist(char *buffer, int count, struct list_head *list);
111 int cfs_match_nid(struct lnet_nid *nid, struct list_head *list);
112 int cfs_match_net(__u32 net_id, __u32 net_type,
113                   struct list_head *net_num_list);
114
115 int cfs_ip_addr_parse(char *str, int len, struct list_head *list);
116 int cfs_ip_addr_match(__u32 addr, struct list_head *list);
117 int cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid,
118                                char *max_nid, __kernel_size_t nidstr_length);
119 void cfs_expr_list_free_list(struct list_head *list);
120
121 #endif /* _LNET_NIDSTRINGS_H */