Whamcloud - gitweb
LU-8912 nodemap: fix contiguous range support
[fs/lustre-release.git] / lnet / include / uapi / linux / lnet / nidstr.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2015, 2017, Intel Corporation.
27  */
28 #ifndef _LNET_NIDSTRINGS_H
29 #define _LNET_NIDSTRINGS_H
30
31 /*
32  * This is due to us being out of kernel and the way the OpenSFS branch
33  * handles CFLAGS.
34  */
35 #ifdef __KERNEL__
36 # include <uapi/linux/lnet/lnet-types.h>
37 #else
38 # include <linux/lnet/lnet-types.h>
39 #endif
40
41 /**
42  *  Lustre Network Driver types.
43  */
44 enum {
45         /* Only add to these values (i.e. don't ever change or redefine them):
46          * network addresses depend on them... */
47         /*QSWLND        = 1, removed v2_7_50                 */
48         SOCKLND         = 2,
49         /*GMLND         = 3, removed v2_0_0-rc1a-16-gc660aac */
50         /*PTLLND        = 4, removed v2_7_50                 */
51         O2IBLND         = 5,
52         /*CIBLND        = 6, removed v2_0_0-rc1a-175-gd2b8a0e */
53         /*OPENIBLND     = 7, removed v2_0_0-rc1a-175-gd2b8a0e */
54         /*IIBLND        = 8, removed v2_0_0-rc1a-175-gd2b8a0e */
55         LOLND           = 9,
56         /*RALND         = 10, removed v2_7_50_0-34-g8be9e41    */
57         /*VIBLND        = 11, removed v2_0_0-rc1a-175-gd2b8a0e */
58         /*MXLND         = 12, removed v2_7_50_0-34-g8be9e41    */
59         GNILND          = 13,
60         GNIIPLND        = 14,
61         PTL4LND         = 15,
62 };
63
64 struct list_head;
65
66 #define LNET_NIDSTR_COUNT 1024  /* # of nidstrings */
67 #define LNET_NIDSTR_SIZE  32    /* size of each one (see below for usage) */
68
69 /* support decl needed by both kernel and user space */
70 char *libcfs_next_nidstring(void);
71 int libcfs_isknown_lnd(__u32 lnd);
72 char *libcfs_lnd2modname(__u32 lnd);
73 char *libcfs_lnd2str_r(__u32 lnd, char *buf, size_t buf_size);
74 static inline char *libcfs_lnd2str(__u32 lnd)
75 {
76         return libcfs_lnd2str_r(lnd, libcfs_next_nidstring(),
77                                 LNET_NIDSTR_SIZE);
78 }
79 int libcfs_str2lnd(const char *str);
80 char *libcfs_net2str_r(__u32 net, char *buf, size_t buf_size);
81 static inline char *libcfs_net2str(__u32 net)
82 {
83         return libcfs_net2str_r(net, libcfs_next_nidstring(),
84                                 LNET_NIDSTR_SIZE);
85 }
86 char *libcfs_nid2str_r(lnet_nid_t nid, char *buf, size_t buf_size);
87 static inline char *libcfs_nid2str(lnet_nid_t nid)
88 {
89         return libcfs_nid2str_r(nid, libcfs_next_nidstring(),
90                                 LNET_NIDSTR_SIZE);
91 }
92 __u32 libcfs_str2net(const char *str);
93 lnet_nid_t libcfs_str2nid(const char *str);
94 int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
95 char *libcfs_id2str(struct lnet_process_id id);
96 void cfs_free_nidlist(struct list_head *list);
97 int cfs_parse_nidlist(char *str, int len, struct list_head *list);
98 int cfs_print_nidlist(char *buffer, int count, struct list_head *list);
99 int cfs_match_nid(lnet_nid_t nid, struct list_head *list);
100
101 int cfs_ip_addr_parse(char *str, int len, struct list_head *list);
102 int cfs_ip_addr_match(__u32 addr, struct list_head *list);
103 int cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid,
104                                char *max_nid, size_t nidstr_length);
105
106 struct netstrfns {
107         __u32   nf_type;
108         char    *nf_name;
109         char    *nf_modname;
110         void    (*nf_addr2str)(__u32 addr, char *str, size_t size);
111         int     (*nf_str2addr)(const char *str, int nob, __u32 *addr);
112         int     (*nf_parse_addrlist)(char *str, int len,
113                                      struct list_head *list);
114         int     (*nf_print_addrlist)(char *buffer, int count,
115                                      struct list_head *list);
116         int     (*nf_match_addr)(__u32 addr, struct list_head *list);
117         int     (*nf_min_max)(struct list_head *nidlist, __u32 *min_nid,
118                               __u32 *max_nid);
119 };
120
121 #endif /* _LNET_NIDSTRINGS_H */