Whamcloud - gitweb
LU-6142 lnet: SPDX for lnet/include/ and misc files
[fs/lustre-release.git] / lnet / include / lnet / udsp.h
1 // SPDX-License-Identifier: GPL-2.0
2
3 /* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
4  *
5  * Copyright (c) 2011, 2017, Intel Corporation.
6  *
7  * Copyright (c) 2018-2020 Data Direct Networks.
8  */
9
10 /* This file is part of Lustre, http://www.lustre.org/
11  *
12  * Author: Amir Shehata
13  */
14
15 #ifndef UDSP_H
16 #define UDSP_H
17
18 #include <lnet/lib-lnet.h>
19
20 /**
21  * lnet_udsp_add_policy
22  *      Add a policy \new in position \idx
23  *      Must be called with api_mutex held
24  */
25 int lnet_udsp_add_policy(struct lnet_udsp *new, int idx);
26
27 /**
28  * lnet_udsp_get_policy
29  *      get a policy in position \idx
30  *      Must be called with api_mutex held
31  */
32 struct lnet_udsp *lnet_udsp_get_policy(int idx);
33
34 /**
35  * lnet_udsp_del_policy
36  *      Delete a policy from position \idx
37  *      Must be called with api_mutex held
38  */
39 int lnet_udsp_del_policy(int idx);
40
41 /**
42  * lnet_udsp_apply_policies
43  *      apply all stored policies across the system
44  *      Must be called with api_mutex held
45  *      Must NOT be called with lnet_net_lock held
46  *      udsp: NULL to apply on all existing udsps
47  *            non-NULL to apply to specified udsp
48  *      revert: true to revert policy application
49  */
50 int lnet_udsp_apply_policies(struct lnet_udsp *udsp, bool revert);
51
52 /**
53  * lnet_udsp_apply_policies_on_lpni
54  *      apply all stored policies on specified \lpni
55  *      Must be called with api_mutex held
56  *      Must be called with LNET_LOCK_EX
57  */
58 int lnet_udsp_apply_policies_on_lpni(struct lnet_peer_ni *lpni);
59
60 /**
61  * lnet_udsp_apply_policies_on_lpn
62  *      Must be called with api_mutex held
63  *      apply all stored policies on specified \lpn
64  *      Must be called with LNET_LOCK_EX
65  */
66 int lnet_udsp_apply_policies_on_lpn(struct lnet_peer_net *lpn);
67
68 /**
69  * lnet_udsp_apply_policies_on_ni
70  *      apply all stored policies on specified \ni
71  *      Must be called with api_mutex held
72  *      Must be called with LNET_LOCK_EX
73  */
74 int lnet_udsp_apply_policies_on_ni(struct lnet_ni *ni);
75
76 /**
77  * lnet_udsp_apply_policies_on_net
78  *      apply all stored policies on specified \net
79  *      Must be called with api_mutex held
80  *      Must be called with LNET_LOCK_EX
81  */
82 int lnet_udsp_apply_policies_on_net(struct lnet_net *net);
83
84 /**
85  * lnet_udsp_alloc
86  *      Allocates a UDSP block and initializes it.
87  *      Return NULL if allocation fails
88  *      pointer to UDSP otherwise.
89  */
90 struct lnet_udsp *lnet_udsp_alloc(void);
91
92 /**
93  * lnet_udsp_free
94  *      Free a UDSP and all its descriptors
95  */
96 void lnet_udsp_free(struct lnet_udsp *udsp);
97
98 /**
99  * lnet_udsp_destroy
100  *      Free all the UDSPs
101  *      force: true to indicate shutdown in progress
102  */
103 void lnet_udsp_destroy(bool shutdown);
104
105 /**
106  * lnet_get_udsp_size
107  *      Return the size needed to store the marshalled UDSP
108  */
109 size_t lnet_get_udsp_size(struct lnet_udsp *udsp);
110
111 /**
112  * lnet_udsp_marshal
113  *      Marshal the udsp into the bulk memory provided.
114  *      Return success/failure.
115  */
116 int lnet_udsp_marshal(struct lnet_udsp *udsp,
117                       struct lnet_ioctl_udsp *ioc_udsp);
118 /**
119  * lnet_udsp_demarshal_add
120  *      Given a bulk containing a single UDSP,
121  *      demarshal and populate a udsp structure then add policy
122  */
123 int lnet_udsp_demarshal_add(void *bulk, __u32 bulk_size);
124
125 /**
126  * lnet_udsp_get_construct_info
127  *      get information of how the UDSP policies impacted the given
128  *      construct.
129  */
130 void lnet_udsp_get_construct_info(struct lnet_ioctl_construct_udsp_info *info,
131                                   struct lnet_nid *nid);
132
133 #endif /* UDSP_H */