Whamcloud - gitweb
Merge "LU-9121 lnet: User Defined Selection Policy (UDSP)"
[fs/lustre-release.git] / lnet / include / lnet / udsp.h
1 /*
2  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
3  *
4  * Copyright (c) 2011, 2017, Intel Corporation.
5  *
6  * Copyright (c) 2018-2020 Data Direct Networks.
7  *
8  *   This file is part of Lustre, https://wiki.whamcloud.com/
9  *
10  *   Portals is free software; you can redistribute it and/or
11  *   modify it under the terms of version 2 of the GNU General Public
12  *   License as published by the Free Software Foundation.
13  *
14  *   Portals is distributed in the hope that it will be useful,
15  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *   GNU General Public License for more details.
18  *
19  *   You should have received a copy of the GNU General Public License
20  *   version 2 along with this program; If not, see
21  *   http://www.gnu.org/licenses/gpl-2.0.html
22  *
23  * Author: Amir Shehata
24  */
25
26 #ifndef UDSP_H
27 #define UDSP_H
28
29 #include <lnet/lib-lnet.h>
30
31 /**
32  * lnet_udsp_add_policy
33  *      Add a policy \new in position \idx
34  *      Must be called with api_mutex held
35  */
36 int lnet_udsp_add_policy(struct lnet_udsp *new, int idx);
37
38 /**
39  * lnet_udsp_get_policy
40  *      get a policy in position \idx
41  *      Must be called with api_mutex held
42  */
43 struct lnet_udsp *lnet_udsp_get_policy(int idx);
44
45 /**
46  * lnet_udsp_del_policy
47  *      Delete a policy from position \idx
48  *      Must be called with api_mutex held
49  */
50 int lnet_udsp_del_policy(int idx);
51
52 /**
53  * lnet_udsp_apply_policies
54  *      apply all stored policies across the system
55  *      Must be called with api_mutex held
56  *      Must NOT be called with lnet_net_lock held
57  *      udsp: NULL to apply on all existing udsps
58  *            non-NULL to apply to specified udsp
59  *      revert: true to revert policy application
60  */
61 int lnet_udsp_apply_policies(struct lnet_udsp *udsp, bool revert);
62
63 /**
64  * lnet_udsp_apply_policies_on_lpni
65  *      apply all stored policies on specified \lpni
66  *      Must be called with api_mutex held
67  *      Must be called with LNET_LOCK_EX
68  */
69 int lnet_udsp_apply_policies_on_lpni(struct lnet_peer_ni *lpni);
70
71 /**
72  * lnet_udsp_apply_policies_on_lpn
73  *      Must be called with api_mutex held
74  *      apply all stored policies on specified \lpn
75  *      Must be called with LNET_LOCK_EX
76  */
77 int lnet_udsp_apply_policies_on_lpn(struct lnet_peer_net *lpn);
78
79 /**
80  * lnet_udsp_apply_policies_on_ni
81  *      apply all stored policies on specified \ni
82  *      Must be called with api_mutex held
83  *      Must be called with LNET_LOCK_EX
84  */
85 int lnet_udsp_apply_policies_on_ni(struct lnet_ni *ni);
86
87 /**
88  * lnet_udsp_apply_policies_on_net
89  *      apply all stored policies on specified \net
90  *      Must be called with api_mutex held
91  *      Must be called with LNET_LOCK_EX
92  */
93 int lnet_udsp_apply_policies_on_net(struct lnet_net *net);
94
95 /**
96  * lnet_udsp_alloc
97  *      Allocates a UDSP block and initializes it.
98  *      Return NULL if allocation fails
99  *      pointer to UDSP otherwise.
100  */
101 struct lnet_udsp *lnet_udsp_alloc(void);
102
103 /**
104  * lnet_udsp_free
105  *      Free a UDSP and all its descriptors
106  */
107 void lnet_udsp_free(struct lnet_udsp *udsp);
108
109 /**
110  * lnet_udsp_destroy
111  *      Free all the UDSPs
112  *      force: true to indicate shutdown in progress
113  */
114 void lnet_udsp_destroy(bool shutdown);
115
116 /**
117  * lnet_get_udsp_size
118  *      Return the size needed to store the marshalled UDSP
119  */
120 size_t lnet_get_udsp_size(struct lnet_udsp *udsp);
121
122 /**
123  * lnet_udsp_marshal
124  *      Marshal the udsp into the bulk memory provided.
125  *      Return success/failure.
126  */
127 int lnet_udsp_marshal(struct lnet_udsp *udsp,
128                       struct lnet_ioctl_udsp *ioc_udsp);
129 /**
130  * lnet_udsp_demarshal_add
131  *      Given a bulk containing a single UDSP,
132  *      demarshal and populate a udsp structure then add policy
133  */
134 int lnet_udsp_demarshal_add(void *bulk, __u32 bulk_size);
135
136 /**
137  * lnet_udsp_get_construct_info
138  *      get information of how the UDSP policies impacted the given
139  *      construct.
140  */
141 void lnet_udsp_get_construct_info(struct lnet_ioctl_construct_udsp_info *info);
142
143 #endif /* UDSP_H */