Motr  M0
dispatcher.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_DISPATCHER_H__
26 #define __MOTR_HA_DISPATCHER_H__
27 
34 #include "lib/types.h" /* bool */
35 #include "lib/tlist.h" /* m0_tl */
36 #include "module/module.h" /* m0_module */
37 
38 struct m0_ha;
39 struct m0_ha_link;
40 struct m0_ha_msg;
41 struct m0_ha_note_handler;
43 struct m0_ha_fvec_handler;
44 
49 };
50 
54  /*
55  * Is not protected by any lock.
56  * User is responsible for non-concurrent modifications.
57  * Handlers can be added only between m0_motr_ha_init() and
58  * m0_motr_ha_start().
59  */
61  /* m0_ha_note_set(), m0_ha_note_get() handler */
65 };
66 
67 struct m0_ha_handler {
68  struct m0_tlink hh_link;
69  uint64_t hh_magic;
70  void *hh_data;
71  void (*hh_msg_received_cb)(struct m0_ha_handler *hh,
72  struct m0_ha *ha,
73  struct m0_ha_link *hl,
74  struct m0_ha_msg *msg,
75  uint64_t tag,
76  void *data);
77 };
78 
79 M0_INTERNAL int m0_ha_dispatcher_init(struct m0_ha_dispatcher *hd,
80  struct m0_ha_dispatcher_cfg *hd_cfg);
81 M0_INTERNAL void m0_ha_dispatcher_fini(struct m0_ha_dispatcher *hd);
82 
83 M0_INTERNAL void m0_ha_dispatcher_attach(struct m0_ha_dispatcher *hd,
84  struct m0_ha_handler *hh);
85 M0_INTERNAL void m0_ha_dispatcher_detach(struct m0_ha_dispatcher *hd,
86  struct m0_ha_handler *hh);
87 
88 M0_INTERNAL void m0_ha_dispatcher_handle(struct m0_ha_dispatcher *hd,
89  struct m0_ha *ha,
90  struct m0_ha_link *hl,
91  struct m0_ha_msg *msg,
92  uint64_t tag);
93 
95 #endif /* __MOTR_HA_DISPATCHER_H__ */
96 
97 /*
98  * Local variables:
99  * c-indentation-style: "K&R"
100  * c-basic-offset: 8
101  * tab-width: 8
102  * fill-column: 80
103  * scroll-step: 1
104  * End:
105  */
106 /*
107  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
108  */
struct m0_tl hds_handlers
Definition: dispatcher.h:60
static uint64_t tag(uint8_t code, uint64_t id)
Definition: addb2.c:1047
struct m0_bufvec data
Definition: di.c:40
void(* hh_msg_received_cb)(struct m0_ha_handler *hh, struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg, uint64_t tag, void *data)
Definition: dispatcher.h:71
uint64_t hh_magic
Definition: dispatcher.h:69
struct m0_tlink hh_link
Definition: dispatcher.h:68
M0_INTERNAL void m0_ha_dispatcher_handle(struct m0_ha_dispatcher *hd, struct m0_ha *ha, struct m0_ha_link *hl, struct m0_ha_msg *msg, uint64_t tag)
Definition: dispatcher.c:231
struct m0_ha_keepalive_handler * hds_keepalive_handler
Definition: dispatcher.h:64
struct m0_module hds_module
Definition: dispatcher.h:53
Definition: tlist.h:251
struct m0_ha_dispatcher_cfg hds_cfg
Definition: dispatcher.h:52
Definition: msg.h:115
M0_INTERNAL void m0_ha_dispatcher_fini(struct m0_ha_dispatcher *hd)
Definition: dispatcher.c:212
M0_INTERNAL void m0_ha_dispatcher_attach(struct m0_ha_dispatcher *hd, struct m0_ha_handler *hh)
Definition: dispatcher.c:219
Definition: ha.h:289
M0_INTERNAL int m0_ha_dispatcher_init(struct m0_ha_dispatcher *hd, struct m0_ha_dispatcher_cfg *hd_cfg)
Definition: dispatcher.c:192
M0_INTERNAL void m0_ha_dispatcher_detach(struct m0_ha_dispatcher *hd, struct m0_ha_handler *hh)
Definition: dispatcher.c:225
struct m0_ha_fvec_handler * hds_fvec_handler
Definition: dispatcher.h:63
struct m0_ha_note_handler * hds_note_handler
Definition: dispatcher.h:62
void * hh_data
Definition: dispatcher.h:70