Motr  M0
lq.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2016-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_HA_LINK_QUEUE_H__
26 #define __MOTR_HA_LINK_QUEUE_H__
27 
85 #include "lib/types.h" /* bool */
86 #include "ha/msg_queue.h" /* m0_ha_msg_queue */
87 #include "ha/link_fops.h" /* m0_ha_link_tags */
88 
89 struct m0_ha_lq_cfg {
91 };
92 
93 /*
94  * func: enqueue() next() delivered() dequeue()
95  * var: assign next delivered confirmed
96  */
97 struct m0_ha_lq {
101 };
102 
103 M0_INTERNAL void m0_ha_lq_init(struct m0_ha_lq *lq,
104  const struct m0_ha_lq_cfg *lq_cfg);
105 M0_INTERNAL void m0_ha_lq_fini(struct m0_ha_lq *lq);
106 M0_INTERNAL bool m0_ha_lq_invariant(const struct m0_ha_lq *lq);
107 
108 M0_INTERNAL void m0_ha_lq_tags_get(const struct m0_ha_lq *lq,
109  struct m0_ha_link_tags *tags);
110 M0_INTERNAL void m0_ha_lq_tags_set(struct m0_ha_lq *lq,
111  const struct m0_ha_link_tags *tags);
112 
113 M0_INTERNAL bool m0_ha_lq_has_tag(const struct m0_ha_lq *lq, uint64_t tag);
114 M0_INTERNAL struct m0_ha_msg *m0_ha_lq_msg(struct m0_ha_lq *lq, uint64_t tag);
115 M0_INTERNAL struct m0_ha_msg *m0_ha_lq_msg_next(struct m0_ha_lq *lq,
116  const struct m0_ha_msg *cur);
117 M0_INTERNAL struct m0_ha_msg *m0_ha_lq_msg_prev(struct m0_ha_lq *lq,
118  const struct m0_ha_msg *cur);
119 M0_INTERNAL bool m0_ha_lq_has_next(const struct m0_ha_lq *lq);
120 M0_INTERNAL bool m0_ha_lq_is_delivered(const struct m0_ha_lq *lq, uint64_t tag);
121 
122 M0_INTERNAL uint64_t m0_ha_lq_tag_assign(const struct m0_ha_lq *lq);
123 M0_INTERNAL uint64_t m0_ha_lq_tag_next(const struct m0_ha_lq *lq);
124 M0_INTERNAL uint64_t m0_ha_lq_tag_delivered(const struct m0_ha_lq *lq);
125 M0_INTERNAL uint64_t m0_ha_lq_tag_confirmed(const struct m0_ha_lq *lq);
126 
127 M0_INTERNAL uint64_t m0_ha_lq_enqueue(struct m0_ha_lq *lq,
128  const struct m0_ha_msg *msg);
129 M0_INTERNAL struct m0_ha_msg *m0_ha_lq_next(struct m0_ha_lq *lq);
130 M0_INTERNAL bool m0_ha_lq_try_unnext(struct m0_ha_lq *lq);
131 M0_INTERNAL void m0_ha_lq_mark_delivered(struct m0_ha_lq *lq, uint64_t tag);
132 M0_INTERNAL uint64_t m0_ha_lq_dequeue(struct m0_ha_lq *lq);
133 
135 #endif /* __MOTR_HA_LINK_QUEUE_H__ */
136 
137 /*
138  * Local variables:
139  * c-indentation-style: "K&R"
140  * c-basic-offset: 8
141  * tab-width: 8
142  * fill-column: 80
143  * scroll-step: 1
144  * End:
145  */
146 /*
147  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
148  */
M0_INTERNAL bool m0_ha_lq_has_tag(const struct m0_ha_lq *lq, uint64_t tag)
Definition: lq.c:101
M0_INTERNAL bool m0_ha_lq_try_unnext(struct m0_ha_lq *lq)
Definition: lq.c:216
M0_INTERNAL uint64_t m0_ha_lq_enqueue(struct m0_ha_lq *lq, const struct m0_ha_msg *msg)
Definition: lq.c:180
M0_INTERNAL void m0_ha_lq_fini(struct m0_ha_lq *lq)
Definition: lq.c:67
M0_INTERNAL struct m0_ha_msg * m0_ha_lq_next(struct m0_ha_lq *lq)
Definition: lq.c:203
M0_INTERNAL void m0_ha_lq_tags_set(struct m0_ha_lq *lq, const struct m0_ha_link_tags *tags)
Definition: lq.c:87
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
Definition: addb2.c:791
static uint64_t tag(uint8_t code, uint64_t id)
Definition: addb2.c:1047
struct m0_ha_lq_cfg hlq_cfg
Definition: lq.h:98
M0_INTERNAL uint64_t m0_ha_lq_tag_delivered(const struct m0_ha_lq *lq)
Definition: lq.c:168
struct m0_ha_msg_queue_cfg hlqc_msg_queue_cfg
Definition: lq.h:90
M0_INTERNAL uint64_t m0_ha_lq_dequeue(struct m0_ha_lq *lq)
Definition: lq.c:256
struct m0_ha_msg_queue hlq_mq
Definition: lq.h:99
M0_INTERNAL void m0_ha_lq_tags_get(const struct m0_ha_lq *lq, struct m0_ha_link_tags *tags)
Definition: lq.c:80
M0_INTERNAL bool m0_ha_lq_has_next(const struct m0_ha_lq *lq)
Definition: lq.c:141
M0_INTERNAL bool m0_ha_lq_is_delivered(const struct m0_ha_lq *lq, uint64_t tag)
Definition: lq.c:148
Definition: lq.h:97
M0_INTERNAL void m0_ha_lq_mark_delivered(struct m0_ha_lq *lq, uint64_t tag)
Definition: lq.c:228
M0_INTERNAL uint64_t m0_ha_lq_tag_confirmed(const struct m0_ha_lq *lq)
Definition: lq.c:174
M0_INTERNAL struct m0_ha_msg * m0_ha_lq_msg_prev(struct m0_ha_lq *lq, const struct m0_ha_msg *cur)
Definition: lq.c:130
M0_INTERNAL bool m0_ha_lq_invariant(const struct m0_ha_lq *lq)
Definition: lq.c:53
Definition: msg.h:115
M0_INTERNAL void m0_ha_lq_init(struct m0_ha_lq *lq, const struct m0_ha_lq_cfg *lq_cfg)
Definition: lq.c:58
M0_INTERNAL uint64_t m0_ha_lq_tag_assign(const struct m0_ha_lq *lq)
Definition: lq.c:156
struct m0_ha_link_tags hlq_tags
Definition: lq.h:100
M0_INTERNAL struct m0_ha_msg * m0_ha_lq_msg_next(struct m0_ha_lq *lq, const struct m0_ha_msg *cur)
Definition: lq.c:119
M0_INTERNAL struct m0_ha_msg * m0_ha_lq_msg(struct m0_ha_lq *lq, uint64_t tag)
Definition: lq.c:109
M0_INTERNAL uint64_t m0_ha_lq_tag_next(const struct m0_ha_lq *lq)
Definition: lq.c:162