Whamcloud - gitweb
LU-10391 lnet: extend prefered nids in struct lnet_peer_ni
[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 #include <linux/types.h>
32 #include <linux/lnet/lnet-types.h>
33
34 /**
35  *  Lustre Network Driver types.
36  */
37 enum {
38         /* Only add to these values (i.e. don't ever change or redefine them):
39          * network addresses depend on them... */
40         /*QSWLND        = 1, removed v2_7_50                 */
41         SOCKLND         = 2,
42         /*GMLND         = 3, removed v2_0_0-rc1a-16-gc660aac */
43         /*PTLLND        = 4, removed v2_7_50                 */
44         O2IBLND         = 5,
45         /*CIBLND        = 6, removed v2_0_0-rc1a-175-gd2b8a0e */
46         /*OPENIBLND     = 7, removed v2_0_0-rc1a-175-gd2b8a0e */
47         /*IIBLND        = 8, removed v2_0_0-rc1a-175-gd2b8a0e */
48         LOLND           = 9,
49         /*RALND         = 10, removed v2_7_50_0-34-g8be9e41    */
50         /*VIBLND        = 11, removed v2_0_0-rc1a-175-gd2b8a0e */
51         /*MXLND         = 12, removed v2_7_50_0-34-g8be9e41    */
52         GNILND          = 13,
53         GNIIPLND        = 14,
54         PTL4LND         = 15,
55
56         NUM_LNDS
57 };
58
59 struct list_head;
60
61 #define LNET_NIDSTR_COUNT 1024  /* # of nidstrings */
62 #define LNET_NIDSTR_SIZE  64    /* size of each one (see below for usage) */
63
64 /* support decl needed by both kernel and user space */
65 char *libcfs_next_nidstring(void);
66 int libcfs_isknown_lnd(__u32 lnd);
67 char *libcfs_lnd2modname(__u32 lnd);
68 char *libcfs_lnd2str_r(__u32 lnd, char *buf, __kernel_size_t buf_size);
69 static inline char *libcfs_lnd2str(__u32 lnd)
70 {
71         return libcfs_lnd2str_r(lnd, libcfs_next_nidstring(),
72                                 LNET_NIDSTR_SIZE);
73 }
74 int libcfs_str2lnd(const char *str);
75 char *libcfs_net2str_r(__u32 net, char *buf, __kernel_size_t buf_size);
76 static inline char *libcfs_net2str(__u32 net)
77 {
78         return libcfs_net2str_r(net, libcfs_next_nidstring(),
79                                 LNET_NIDSTR_SIZE);
80 }
81 char *libcfs_nid2str_r(lnet_nid_t nid, char *buf, __kernel_size_t buf_size);
82 static inline char *libcfs_nid2str(lnet_nid_t nid)
83 {
84         return libcfs_nid2str_r(nid, libcfs_next_nidstring(),
85                                 LNET_NIDSTR_SIZE);
86 }
87 char *libcfs_nidstr_r(const struct lnet_nid *nid,
88                         char *buf, __kernel_size_t buf_size);
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 __u32 libcfs_str2net(const char *str);
95 lnet_nid_t libcfs_str2nid(const char *str);
96 int libcfs_strnid(struct lnet_nid *nid, const char *str);
97 int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
98 int libcfs_num_parse(char *str, int len, struct list_head *list);
99 char *libcfs_id2str(struct lnet_process_id id);
100 char *libcfs_idstr(struct lnet_processid *id);
101 void cfs_free_nidlist(struct list_head *list);
102 int cfs_parse_nidlist(char *str, int len, struct list_head *list);
103 int cfs_print_nidlist(char *buffer, int count, struct list_head *list);
104 int cfs_match_nid(lnet_nid_t nid, struct list_head *list);
105 int cfs_match_nid_net(struct lnet_nid *nid, __u32 net,
106                       struct list_head *net_num_list,
107                       struct list_head *addr);
108 int cfs_match_net(__u32 net_id, __u32 net_type,
109                   struct list_head *net_num_list);
110
111 int cfs_ip_addr_parse(char *str, int len, struct list_head *list);
112 int cfs_ip_addr_match(__u32 addr, struct list_head *list);
113 int cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid,
114                                char *max_nid, __kernel_size_t nidstr_length);
115 void cfs_expr_list_free_list(struct list_head *list);
116
117 #endif /* _LNET_NIDSTRINGS_H */