Motr  M0
link_fops.c
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 
30 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_HA
31 #include "lib/trace.h"
32 
33 #include "ha/link_fops.h"
34 #include "ha/link_fops_xc.h"
35 
36 #include "rpc/rpc_opcodes.h" /* M0_HA_LINK_INCOMING_REQ */
37 #include "fop/fom_generic.h" /* XXX m0_generic_conf */
38 #include "ha/link_service.h" /* m0_ha_link_service_type */
39 #include "ha/link.h" /* m0_ha_link_incoming_fom_type_ops */
40 
43 
44 M0_INTERNAL void m0_ha_link_tags_initial(struct m0_ha_link_tags *tags,
45  bool tag_even)
46 {
47  uint64_t tag = tag_even ? 2 : 1;
48 
49  *tags = (struct m0_ha_link_tags){
50  .hlt_delivered = tag,
51  .hlt_confirmed = tag,
52  .hlt_next = tag,
53  .hlt_assign = tag,
54  };
55 }
56 
57 M0_INTERNAL bool m0_ha_link_tags_eq(const struct m0_ha_link_tags *tags1,
58  const struct m0_ha_link_tags *tags2)
59 {
60  return tags1->hlt_delivered == tags2->hlt_delivered &&
61  tags1->hlt_confirmed == tags2->hlt_confirmed &&
62  tags1->hlt_next == tags2->hlt_next &&
63  tags1->hlt_assign == tags2->hlt_assign;
64 
65 }
66 
68  const struct m0_ha_link_params *src)
69 {
70  *dst = (struct m0_ha_link_params){
71  .hlp_id_local = src->hlp_id_remote,
72  .hlp_id_remote = src->hlp_id_local,
73  .hlp_id_connection = src->hlp_id_connection,
74  .hlp_tags_local = src->hlp_tags_remote,
75  .hlp_tags_remote = src->hlp_tags_local,
76  };
77 }
78 
79 M0_INTERNAL int m0_ha_link_fops_init(void)
80 {
82  .name = "HA link msg fop",
84  .xt = m0_ha_link_msg_fop_xc,
86  .sm = &m0_generic_conf, /* XXX make specific conf */
87  .svc_type = &m0_ha_link_service_type,
88  .rpc_flags = M0_RPC_ITEM_TYPE_REQUEST);
90  .name = "HA link msg fop reply",
92  .xt = m0_ha_link_msg_rep_fop_xc,
93  .svc_type = &m0_ha_link_service_type,
94  .rpc_flags = M0_RPC_ITEM_TYPE_REPLY);
95  return 0;
96 }
97 
98 M0_INTERNAL void m0_ha_link_fops_fini(void)
99 {
102 }
103 
104 #undef M0_TRACE_SUBSYSTEM
105 
108 /*
109  * Local variables:
110  * c-indentation-style: "K&R"
111  * c-basic-offset: 8
112  * tab-width: 8
113  * fill-column: 80
114  * scroll-step: 1
115  * End:
116  */
117 /*
118  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
119  */
static struct m0_bufvec dst
Definition: xform.c:61
#define M0_FOP_TYPE_INIT(ft,...)
Definition: fop.h:307
const struct m0_fom_type_ops m0_ha_link_incoming_fom_type_ops
Definition: link.c:1056
static uint64_t tag(uint8_t code, uint64_t id)
Definition: addb2.c:1047
void m0_fop_type_fini(struct m0_fop_type *fopt)
Definition: fop.c:232
M0_INTERNAL void m0_ha_link_fops_fini(void)
Definition: link_fops.c:98
static struct m0_xcode_type ** xt[]
Definition: protocol.c:64
const struct m0_sm_conf m0_generic_conf
Definition: fom_generic.c:838
int opcode
Definition: crate.c:301
struct m0_fop_type m0_ha_link_msg_rep_fopt
Definition: link_fops.c:42
const char * name
Definition: trace.c:110
M0_INTERNAL int m0_ha_link_fops_init(void)
Definition: link_fops.c:79
M0_INTERNAL void m0_ha_link_params_invert(struct m0_ha_link_params *dst, const struct m0_ha_link_params *src)
Definition: link_fops.c:67
M0_INTERNAL void m0_ha_link_tags_initial(struct m0_ha_link_tags *tags, bool tag_even)
Definition: link_fops.c:44
struct m0_reqh_service_type m0_ha_link_service_type
Definition: link_service.c:263
M0_INTERNAL bool m0_ha_link_tags_eq(const struct m0_ha_link_tags *tags1, const struct m0_ha_link_tags *tags2)
Definition: link_fops.c:57
struct m0_pdclust_src_addr src
Definition: fd.c:108
struct m0_fop_type m0_ha_link_msg_fopt
Definition: link_fops.c:41