Whamcloud - gitweb
7f7781b67975b81633edde508acd1c27ddfed7ca
[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         /*QSWLND        = 1, removed v2_7_50                 */
24         SOCKLND         = 2,
25         /*GMLND         = 3, removed v2_0_0-rc1a-16-gc660aac */
26         /*PTLLND        = 4, removed v2_7_50                 */
27         O2IBLND         = 5,
28         /*CIBLND        = 6, removed v2_0_0-rc1a-175-gd2b8a0e */
29         /*OPENIBLND     = 7, removed v2_0_0-rc1a-175-gd2b8a0e */
30         /*IIBLND        = 8, removed v2_0_0-rc1a-175-gd2b8a0e */
31         LOLND           = 9,
32         /*RALND         = 10, removed v2_7_50_0-34-g8be9e41    */
33         /*VIBLND        = 11, removed v2_0_0-rc1a-175-gd2b8a0e */
34         /*MXLND         = 12, removed v2_7_50_0-34-g8be9e41    */
35         GNILND          = 13,
36         GNIIPLND        = 14,
37         PTL4LND         = 15,
38         KFILND          = 16,
39
40         NUM_LNDS
41 };
42
43 struct list_head;
44
45 #define LNET_NIDSTR_COUNT 1024  /* # of nidstrings */
46 #define LNET_NIDSTR_SIZE  64    /* size of each one (see below for usage) */
47
48 /* support decl needed by both kernel and user space */
49 char *libcfs_next_nidstring(void);
50 int libcfs_isknown_lnd(__u32 lnd);
51 char *libcfs_lnd2modname(__u32 lnd);
52 char *libcfs_lnd2str_r(__u32 lnd, char *buf, __kernel_size_t buf_size);
53 static inline char *libcfs_lnd2str(__u32 lnd)
54 {
55         return libcfs_lnd2str_r(lnd, libcfs_next_nidstring(),
56                                 LNET_NIDSTR_SIZE);
57 }
58 int libcfs_str2lnd(const char *str);
59 char *libcfs_net2str_r(__u32 net, char *buf, __kernel_size_t buf_size);
60 static inline char *libcfs_net2str(__u32 net)
61 {
62         return libcfs_net2str_r(net, libcfs_next_nidstring(),
63                                 LNET_NIDSTR_SIZE);
64 }
65 char *libcfs_nid2str_r(lnet_nid_t nid, char *buf, __kernel_size_t buf_size);
66 static inline char *libcfs_nid2str(lnet_nid_t nid)
67 {
68         return libcfs_nid2str_r(nid, libcfs_next_nidstring(),
69                                 LNET_NIDSTR_SIZE);
70 }
71
72 char *libcfs_nidstr_r(const struct lnet_nid *nid,
73                       char *buf, __kernel_size_t buf_size);
74
75 static inline char *libcfs_nidstr(const struct lnet_nid *nid)
76 {
77         return libcfs_nidstr_r(nid, libcfs_next_nidstring(),
78                                LNET_NIDSTR_SIZE);
79 }
80
81 int libcfs_strnid(struct lnet_nid *nid, const char *str);
82 #ifdef __KERNEL__
83 char *libcfs_idstr(struct lnet_processid *id);
84 #endif
85 __u32 libcfs_str2net(const char *str);
86 lnet_nid_t libcfs_str2nid(const char *str);
87 int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
88 int libcfs_num_parse(char *str, int len, struct list_head *list);
89 char *libcfs_id2str(struct lnet_process_id id);
90 void cfs_free_nidlist(struct list_head *list);
91 #ifdef __KERNEL__
92 int cfs_parse_nidlist(char *str, struct list_head *list);
93 #else
94 int cfs_parse_nidlist(char *str, int len, struct list_head *list);
95 #endif
96 int cfs_print_nidlist(char *buffer, int count, struct list_head *list);
97 int cfs_match_nid(struct lnet_nid *nid, struct list_head *list);
98 int cfs_match_net(__u32 net_id, __u32 net_type,
99                   struct list_head *net_num_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, __kernel_size_t nidstr_length);
105 void cfs_expr_list_free_list(struct list_head *list);
106
107 #endif /* _LNET_NIDSTRINGS_H */