Motr  M0
common.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2015-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_ADDB2_UT_COMMON_H__
26 #define __MOTR_ADDB2_UT_COMMON_H__
27 
34 #include "lib/types.h"
35 #include "addb2/addb2.h"
36 #include "addb2/consumer.h"
37 #include "addb2/storage.h"
38 
39 extern int submitted;
40 
41 extern int (*submit)(const struct m0_addb2_mach *mach,
42  struct m0_addb2_trace *trace);
43 extern void (*idle)(const struct m0_addb2_mach *mach);
44 struct m0_addb2_mach *mach_set(int (*s)(const struct m0_addb2_mach *,
45  struct m0_addb2_trace *));
46 extern const struct m0_addb2_sensor_ops sensor_ops;
47 extern const uint64_t SENSOR_MARKER;
48 extern uint64_t seq;
49 extern bool sensor_finalised;
50 
51 void mach_fini(struct m0_addb2_mach *m);
52 void mach_put(struct m0_addb2_mach *m);
53 int fill_one(struct m0_addb2_mach *m);
54 
55 /* define a smaller record type to fit into kernel stack frame. */
56 struct small_record {
58  unsigned ar_label_nr;
60 };
61 
62 #define VAL(id, ...) { \
63  .va_id = (id), \
64  .va_nr = ARRAY_SIZE(((const uint64_t[]) { __VA_ARGS__ })), \
65  .va_data = ((const uint64_t[]) { __VA_ARGS__ } ) \
66 }
67 
68 bool valeq(const struct m0_addb2_value *v0, const struct m0_addb2_value *v1);
69 bool receq(const struct m0_addb2_record *r0, const struct small_record *r1);
70 
72 #endif /* __MOTR_ADDB2_UT_COMMON_H__ */
73 
74 /*
75  * Local variables:
76  * c-indentation-style: "K&R"
77  * c-basic-offset: 8
78  * tab-width: 8
79  * fill-column: 80
80  * scroll-step: 1
81  * End:
82  */
83 /*
84  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
85  */
void mach_fini(struct m0_addb2_mach *m)
Definition: common.c:78
static struct m0_addb2_mach * m
Definition: consumer.c:38
struct m0_addb2_value ar_label[4]
Definition: common.h:59
bool sensor_finalised
Definition: common.c:98
static struct m0_addb2_mach * mach
Definition: storage.c:42
unsigned ar_label_nr
Definition: common.h:58
int submitted
Definition: common.c:30
int(* submit)(const struct m0_addb2_mach *mach, struct m0_addb2_trace *trace)
Definition: common.c:32
void mach_put(struct m0_addb2_mach *m)
Definition: common.c:89
void(* idle)(const struct m0_addb2_mach *mach)
Definition: common.c:34
const uint64_t SENSOR_MARKER
Definition: common.c:96
bool receq(const struct m0_addb2_record *r0, const struct small_record *r1)
Definition: common.c:134
struct m0_addb2_mach * mach_set(int(*s)(const struct m0_addb2_mach *, struct m0_addb2_trace *))
Definition: common.c:65
struct m0_addb2_value ar_val
Definition: common.h:57
const struct m0_addb2_sensor_ops sensor_ops
Definition: common.c:112
bool valeq(const struct m0_addb2_value *v0, const struct m0_addb2_value *v1)
Definition: common.c:127
int fill_one(struct m0_addb2_mach *m)
Definition: common.c:117
static struct m0_addb2_source * s
Definition: consumer.c:39
uint64_t seq
Definition: common.c:97