Motr  M0
rings.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_RM_RINGS_H__
26 #define __MOTR_RM_RINGS_H__
27 
28 #include "rm/rm.h"
29 #include "rm/ut/rmut.h"
30 
31 /* from http://en.wikipedia.org/wiki/Rings_of_Power */
32 enum {
33  /* Three Rings for the Elven-kings under the sky... */
34  /* Narya, the Ring of Fire (set with a ruby) */
35  NARYA = 1 << 0,
36  /* Nenya, the Ring of Water or Ring of Adamant (made of mithril and set
37  with a "white stone") */
38  NENYA = 1 << 1,
39  /* and Vilya, the Ring of Air, the "mightiest of the Three" (made of
40  gold and set with a sapphire)*/
41  VILYA = 1 << 2,
42 
43  /* Seven for the Dwarf-lords in their halls of stone... */
44  /* Ring of Durin */
45  DURIN = 1 << 3,
46  /* Ring of Thror */
47  THROR = 1 << 4,
48  /* Unnamed gnome rings... */
49  GR_2 = 1 << 5,
50  GR_3 = 1 << 6,
51  GR_4 = 1 << 7,
52  GR_5 = 1 << 8,
53  GR_6 = 1 << 9,
54 
55  /* Nine for Mortal Men doomed to die... */
56  /* Witch-king of Angmar */
57  ANGMAR = 1 << 10,
58  /* Khamul */
59  KHAMUL = 1 << 11,
60  /* unnamed man rings... */
61  MR_2 = 1 << 12,
62  MR_3 = 1 << 13,
63  MR_4 = 1 << 14,
64  MR_5 = 1 << 15,
65  MR_6 = 1 << 16,
66  MR_7 = 1 << 17,
67  MR_8 = 1 << 18,
68 
69  /* One for the Dark Lord on his dark throne */
70  THE_ONE = 1 << 19,
71 
72  /*
73  * Ring NOT in the story - ring that doesn't conflict with itself.
74  * It can be granted to multiple incoming requests.
75  */
76  SHARED_RING = 1 << 20,
77 
78  /* Ring NOT in the story - to test failure cases */
79  INVALID_RING = 1 << 21,
80 
81  /*
82  * Special value for the ring denoting any ring.
83  * Any cached or held credit is suitable for satisfying request
84  * for ANY_RING. Also, ANY_RING doesn't conflicts with any other
85  * particular ring (cro_conflicts(ANY_RING, _) == 0).
86  *
87  * ANY_RING is not borrowed or revoked "as is",
88  * some "real" ring is borrowed/revoked instead.
89  * This trick is made through rings_policy() callback.
90  *
91  * ANY_RING is introduced to test requests for
92  * non-conflicting credits.
93  */
94  ANY_RING = 1 << 22,
95 
97  GR_3 | GR_4 | GR_5 | GR_6 | ANGMAR | KHAMUL | MR_2 | MR_3 | MR_4 |
99 
101 
102  /*
103  * Rings incoming policy.
104  * Incoming policy affects only requests for ANY_RING.
105  */
107 };
108 
109 struct m0_rings {
111  uint64_t rs_id;
112 };
113 
115 extern const struct m0_rm_resource_ops rings_ops;
116 extern const struct m0_rm_resource_type_ops rings_rtype_ops;
117 extern const struct m0_rm_credit_ops rings_credit_ops;
118 extern const struct m0_rm_incoming_ops rings_incoming_ops;
119 
120 extern void rings_utdata_ops_set(struct rm_ut_data *data);
121 
122 /* __MOTR_RM_RINGS_H__ */
123 #endif
124 
125 /*
126  * Local variables:
127  * c-indentation-style: "K&R"
128  * c-basic-offset: 8
129  * tab-width: 8
130  * fill-column: 80
131  * scroll-step: 1
132  * End:
133  */
Definition: rings.h:61
Definition: rings.h:63
Definition: rings.h:52
uint64_t rs_id
Definition: rings.h:111
Definition: rings.h:62
Definition: rings.h:47
Definition: rings.h:59
Definition: rings.h:67
Definition: rings.h:49
const struct m0_rm_incoming_ops rings_incoming_ops
Definition: rings.c:296
struct m0_bufvec data
Definition: di.c:40
Definition: rings.h:65
Definition: rings.h:66
Definition: rings.h:50
const struct m0_rm_credit_ops rings_credit_ops
Definition: rings.c:272
Definition: rings.h:41
struct m0_rm_resource_type rings_resource_type
Definition: rings.c:37
Definition: rings.h:38
void rings_utdata_ops_set(struct rm_ut_data *data)
Definition: rings.c:375
Definition: rm.h:1176
Definition: rings.h:96
Definition: rings.h:51
Definition: rings.h:94
Definition: rings.h:35
Definition: rings.h:64
const struct m0_rm_resource_type_ops rings_rtype_ops
Definition: rings.c:149
Definition: rings.h:57
Definition: rings.h:45
const struct m0_rm_resource_ops rings_ops
Definition: rings.c:87
Definition: rings.h:53
struct m0_rm_resource rs_resource
Definition: rings.h:110
Definition: rings.h:70