Motr  M0
link.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_H__
26 #define __MOTR_HA_LINK_H__
27 
120 #include "lib/chan.h" /* m0_chan */
121 #include "lib/types.h" /* bool */
122 #include "lib/tlist.h" /* m0_tlink */
123 #include "lib/semaphore.h" /* m0_semaphore */
124 #include "lib/time.h" /* m0_time_t */
125 
126 #include "sm/sm.h" /* m0_sm */
127 #include "fop/fom.h" /* m0_fom */
128 #include "fop/fop.h" /* m0_fop */
129 #include "rpc/link.h" /* m0_rpc_link */
130 
131 #include "ha/link_fops.h" /* m0_ha_link_params */
132 #include "ha/lq.h" /* m0_ha_lq */
133 
134 
135 struct m0_reqh;
136 struct m0_reqh_service;
137 struct m0_rpc_machine;
138 struct m0_locality;
139 struct m0_ha_link_msg_fop;
140 struct m0_ha_msg;
141 struct m0_rpc_session;
142 
156 };
157 
169  const char *hlcc_rpc_endpoint;
176 };
177 
179  struct m0_reqh *hlc_reqh;
184 };
185 
186 struct m0_ha_link {
204  struct m0_sm hln_sm;
207  struct m0_fom hln_fom;
228  uint64_t hln_req_fop_seq;
253 
254  /* Exponential backoff algorithm state. Protected by ::hln_lock */
256  uint64_t hln_backoff_nr;
257 
258  /* These fields are owned by m0_ha_link_service */
265 };
266 
267 M0_INTERNAL int m0_ha_link_init (struct m0_ha_link *hl,
268  struct m0_ha_link_cfg *hl_cfg);
269 M0_INTERNAL void m0_ha_link_fini (struct m0_ha_link *hl);
270 M0_INTERNAL void m0_ha_link_start(struct m0_ha_link *hl,
271  struct m0_ha_link_conn_cfg *hl_conn_cfg);
272 M0_INTERNAL void m0_ha_link_stop(struct m0_ha_link *hl, struct m0_clink *clink);
273 
274 M0_INTERNAL void m0_ha_link_reconnect_begin(struct m0_ha_link *hl,
275  struct m0_ha_link_params *lp);
276 M0_INTERNAL void
278  const struct m0_ha_link_conn_cfg *hl_conn_cfg);
279 M0_INTERNAL void m0_ha_link_reconnect_cancel(struct m0_ha_link *hl);
280 M0_INTERNAL void
281 m0_ha_link_reconnect_params(const struct m0_ha_link_params *lp_alive,
282  struct m0_ha_link_params *lp_alive_new,
283  struct m0_ha_link_params *lp_dead_new,
284  const struct m0_uint128 *id_alive,
285  const struct m0_uint128 *id_dead,
286  const struct m0_uint128 *id_connection);
287 
288 M0_INTERNAL struct m0_chan *m0_ha_link_chan(struct m0_ha_link *hl);
289 M0_INTERNAL enum m0_ha_link_state m0_ha_link_state_get(struct m0_ha_link *hl);
290 M0_INTERNAL const char *m0_ha_link_state_name(enum m0_ha_link_state state);
291 
292 M0_INTERNAL void m0_ha_link_send(struct m0_ha_link *hl,
293  const struct m0_ha_msg *msg,
294  uint64_t *tag);
295 M0_INTERNAL struct m0_ha_msg *m0_ha_link_recv(struct m0_ha_link *hl,
296  uint64_t *tag);
297 
298 M0_INTERNAL void m0_ha_link_delivered(struct m0_ha_link *hl,
299  struct m0_ha_msg *msg);
300 M0_INTERNAL bool m0_ha_link_msg_is_delivered(struct m0_ha_link *hl,
301  uint64_t tag);
303 M0_INTERNAL uint64_t m0_ha_link_delivered_consume(struct m0_ha_link *hl);
304 M0_INTERNAL uint64_t m0_ha_link_not_delivered_consume(struct m0_ha_link *hl);
305 
306 M0_INTERNAL void m0_ha_link_wait_delivery(struct m0_ha_link *hl,
307  uint64_t tag);
308 M0_INTERNAL void m0_ha_link_wait_arrival(struct m0_ha_link *hl);
309 M0_INTERNAL void m0_ha_link_wait_confirmation(struct m0_ha_link *hl,
310  uint64_t tag);
311 
317 M0_INTERNAL void m0_ha_link_flush(struct m0_ha_link *hl);
318 M0_INTERNAL void m0_ha_link_quiesce(struct m0_ha_link *hl);
319 
320 M0_INTERNAL void m0_ha_link_cb_disconnecting(struct m0_ha_link *hl);
321 M0_INTERNAL void m0_ha_link_cb_reused(struct m0_ha_link *hl);
322 
323 M0_INTERNAL struct m0_rpc_session *
325 
326 M0_INTERNAL void m0_ha_link_rpc_endpoint(struct m0_ha_link *hl,
327  char *buf,
328  m0_bcount_t buf_len);
329 
330 M0_INTERNAL int m0_ha_link_mod_init(void);
331 M0_INTERNAL void m0_ha_link_mod_fini(void);
332 
333 /* XXX move to internal */
336 
338 #endif /* __MOTR_HA_LINK_H__ */
339 
340 /*
341  * Local variables:
342  * c-indentation-style: "K&R"
343  * c-basic-offset: 8
344  * tab-width: 8
345  * fill-column: 80
346  * scroll-step: 1
347  * End:
348  */
349 /*
350  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
351  */
M0_INTERNAL bool m0_ha_link_msg_is_delivered(struct m0_ha_link *hl, uint64_t tag)
Definition: link.c:595
m0_ha_link_state
Definition: link.h:143
const struct m0_fom_type_ops m0_ha_link_outgoing_fom_type_ops
Definition: link.c:1707
M0_INTERNAL void m0_ha_link_stop(struct m0_ha_link *hl, struct m0_clink *clink)
Definition: link.c:412
const struct m0_fom_type_ops m0_ha_link_incoming_fom_type_ops
Definition: link.c:1056
M0_INTERNAL void m0_ha_link_wait_arrival(struct m0_ha_link *hl)
Definition: link.c:709
static uint64_t tag(uint8_t code, uint64_t id)
Definition: addb2.c:1047
uint64_t m0_time_t
Definition: time.h:37
M0_INTERNAL struct m0_ha_msg * m0_ha_link_recv(struct m0_ha_link *hl, uint64_t *tag)
Definition: link.c:568
M0_INTERNAL const char * m0_ha_link_state_name(enum m0_ha_link_state state)
Definition: link.c:543
uint64_t m0_bcount_t
Definition: types.h:77
Definition: sm.h:504
M0_INTERNAL struct m0_chan * m0_ha_link_chan(struct m0_ha_link *hl)
Definition: link.c:532
M0_INTERNAL void m0_ha_link_flush(struct m0_ha_link *hl)
Definition: link.c:767
Definition: sock.c:887
M0_INTERNAL void m0_ha_link_cb_reused(struct m0_ha_link *hl)
Definition: link.c:798
M0_INTERNAL void m0_ha_link_start(struct m0_ha_link *hl, struct m0_ha_link_conn_cfg *hl_conn_cfg)
Definition: link.c:382
M0_INTERNAL enum m0_ha_link_state m0_ha_link_state_get(struct m0_ha_link *hl)
Definition: link.c:537
M0_INTERNAL void m0_ha_link_send(struct m0_ha_link *hl, const struct m0_ha_msg *msg, uint64_t *tag)
Definition: link.c:556
Definition: lq.h:97
M0_INTERNAL void m0_ha_link_cb_disconnecting(struct m0_ha_link *hl)
Definition: link.c:787
M0_INTERNAL void m0_ha_link_reconnect_cancel(struct m0_ha_link *hl)
Definition: link.c:479
M0_INTERNAL int m0_ha_link_mod_init(void)
Definition: link.c:1726
Definition: msg.h:115
M0_INTERNAL void m0_ha_link_reconnect_begin(struct m0_ha_link *hl, struct m0_ha_link_params *lp)
Definition: link.c:422
Definition: reqh.h:94
Definition: chan.h:229
M0_INTERNAL void m0_ha_link_reconnect_end(struct m0_ha_link *hl, const struct m0_ha_link_conn_cfg *hl_conn_cfg)
Definition: link.c:441
static struct m0_clink clink[RDWR_REQUEST_MAX]
M0_INTERNAL uint64_t m0_ha_link_delivered_consume(struct m0_ha_link *hl)
Definition: link.c:606
M0_INTERNAL void m0_ha_link_delivered(struct m0_ha_link *hl, struct m0_ha_msg *msg)
Definition: link.c:584
M0_INTERNAL void m0_ha_link_wait_confirmation(struct m0_ha_link *hl, uint64_t tag)
Definition: link.c:753
Definition: fom.h:481
M0_INTERNAL void m0_ha_link_mod_fini(void)
Definition: link.c:1738
Definition: fid.h:38
M0_INTERNAL void m0_ha_link_wait_delivery(struct m0_ha_link *hl, uint64_t tag)
Definition: link.c:669
M0_INTERNAL void m0_ha_link_rpc_endpoint(struct m0_ha_link *hl, char *buf, m0_bcount_t buf_len)
Definition: link.c:1716
M0_INTERNAL void m0_ha_link_quiesce(struct m0_ha_link *hl)
Definition: sm.h:301
M0_INTERNAL void m0_ha_link_reconnect_params(const struct m0_ha_link_params *lp_alive, struct m0_ha_link_params *lp_alive_new, struct m0_ha_link_params *lp_dead_new, const struct m0_uint128 *id_alive, const struct m0_uint128 *id_dead, const struct m0_uint128 *id_connection)
Definition: link.c:486
M0_INTERNAL int m0_ha_link_init(struct m0_ha_link *hl, struct m0_ha_link_cfg *hl_cfg)
Definition: link.c:225
Definition: mutex.h:47
M0_INTERNAL void m0_ha_link_fini(struct m0_ha_link *hl)
Definition: link.c:269
M0_INTERNAL uint64_t m0_ha_link_not_delivered_consume(struct m0_ha_link *hl)
Definition: link.c:618
M0_INTERNAL struct m0_rpc_session * m0_ha_link_rpc_session(struct m0_ha_link *hl)
Definition: link.c:1711
Definition: fop.h:79