Motr  M0
fi_service.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2017-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 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_OTHER
24 
25 #include "lib/trace.h"
26 #include "lib/errno.h"
27 #include "lib/memory.h" /* M0_ALLOC_PTR */
28 #include "fis/fi_command_fops.h"
29 #include "fis/fi_service.h"
30 
52 
59 static int fis_allocate(struct m0_reqh_service **service,
60  const struct m0_reqh_service_type *stype);
61 
62 static int fis_start(struct m0_reqh_service *service)
63 {
64  M0_ENTRY();
70  return M0_RC(0);
71 }
72 
73 static void fis_stop(struct m0_reqh_service *service)
74 {
75  M0_ENTRY();
77  M0_LEAVE();
78 }
79 
80 static void fis_fini(struct m0_reqh_service *service)
81 {
82  /* Nothing to finalise here. */
83 }
84 
85 static const struct m0_reqh_service_type_ops fis_type_ops = {
87 };
88 
89 static const struct m0_reqh_service_ops fis_ops = {
91  .rso_stop = fis_stop,
92  .rso_fini = fis_fini,
93 };
94 
97  .rst_ops = &fis_type_ops,
98  .rst_level = M0_RPC_SVC_LEVEL,
99  .rst_typecode = M0_CST_FIS,
100 };
101 
102 static const struct m0_bob_type fis_bob = {
104  .bt_magix_offset = offsetof(struct m0_reqh_fi_service, fis_magic),
105  .bt_magix = M0_FI_SERVICE_MAGIC,
106  .bt_check = NULL
107 };
108 
110 
116  const struct m0_reqh_service_type *stype)
117 {
118  struct m0_reqh_fi_service *fis;
119 
120  M0_ENTRY();
121  M0_PRE(service != NULL && stype != NULL);
122 
123  M0_ALLOC_PTR(fis);
124  if (fis == NULL)
125  return M0_ERR(-ENOMEM);
126  m0_reqh_fi_service_bob_init(fis);
127  *service = &fis->fis_svc;
128  (*service)->rs_ops = &fis_ops;
129  return M0_RC(0);
130 }
131 
132 M0_INTERNAL int m0_fis_register(void)
133 {
134  M0_ENTRY();
136  return M0_RC(0);
137 }
138 
139 M0_INTERNAL void m0_fis_unregister(void)
140 {
141  M0_ENTRY();
143  M0_LEAVE();
144 }
145 
147 #undef M0_TRACE_SUBSYSTEM
148 
149 /*
150  * Local variables:
151  * c-indentation-style: "K&R"
152  * c-basic-offset: 8
153  * tab-width: 8
154  * fill-column: 80
155  * scroll-step: 1
156  * End:
157  */
#define M0_PRE(cond)
int(* rso_start)(struct m0_reqh_service *service)
Definition: reqh_service.h:360
#define NULL
Definition: misc.h:38
M0_LEAVE()
#define FI_SERVICE_NAME
Definition: fi_service.h:69
int m0_reqh_service_type_register(struct m0_reqh_service_type *rstype)
Definition: reqh_service.c:473
const char * bt_name
Definition: bob.h:73
M0_INTERNAL int m0_fis_register(void)
Definition: fi_service.c:132
return M0_RC(rc)
#define M0_ENTRY(...)
Definition: trace.h:170
M0_INTERNAL void m0_fis_unregister(void)
Definition: fi_service.c:139
return M0_ERR(-EOPNOTSUPP)
static const struct socktype stype[]
Definition: sock.c:1156
const char * rst_name
Definition: reqh_service.h:447
struct m0_reqh_service fis_svc
Definition: fi_service.h:74
static void fis_fini(struct m0_reqh_service *service)
Definition: fi_service.c:80
M0_INTERNAL void m0_fi_command_fop_init(void)
static void fis_stop(struct m0_reqh_service *service)
Definition: fi_service.c:73
static const struct m0_bob_type fis_bob
Definition: fi_service.c:102
static const struct m0_reqh_service_type_ops fis_type_ops
Definition: fi_service.c:85
int(* rsto_service_allocate)(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
Definition: reqh_service.h:435
static const struct m0_reqh_service_ops fis_ops
Definition: fi_service.c:89
static int fis_start(struct m0_reqh_service *service)
Definition: fi_service.c:62
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
M0_BOB_DEFINE(M0_INTERNAL, &fis_bob, m0_reqh_fi_service)
struct m0_reqh_service_type m0_fis_type
Definition: fi_service.c:95
M0_INTERNAL void m0_fi_command_fop_fini(void)
void m0_reqh_service_type_unregister(struct m0_reqh_service_type *rstype)
Definition: reqh_service.c:490
static struct m0_reqh_service * service[REQH_IN_UT_MAX]
Definition: long_lock_ut.c:46
#define offsetof(typ, memb)
Definition: misc.h:29
static int fis_allocate(struct m0_reqh_service **service, const struct m0_reqh_service_type *stype)
Definition: fi_service.c:115
const struct m0_reqh_service_ops * rs_ops
Definition: reqh_service.h:254