Motr  M0
tx_credit.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2013-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 #ifndef __MOTR_BE_TX_CREDIT_H__
25 #define __MOTR_BE_TX_CREDIT_H__
26 
27 #include "lib/types.h" /* m0_bcount_t */
28 
64 #ifdef __KERNEL__
65 #define M0_DEBUG_BE_CREDITS (0)
66 #else
67 #define M0_DEBUG_BE_CREDITS (1)
68 #endif
69 
77 };
78 
89 };
90 
91 /* invalid m0_be_tx_credit value */
92 extern const struct m0_be_tx_credit m0_be_tx_credit_invalid;
93 
94 #define M0_BE_TX_CREDIT(nr, size) \
95  (struct m0_be_tx_credit){ .tc_reg_nr = (nr), .tc_reg_size = (size) }
96 
97 #define M0_BE_TX_CREDIT_TYPE(type) M0_BE_TX_CREDIT(1, sizeof(type))
98 #define M0_BE_TX_CREDIT_PTR(ptr) M0_BE_TX_CREDIT(1, sizeof *(ptr))
99 #define M0_BE_TX_CREDIT_BUF(buf) M0_BE_TX_CREDIT(1, (buf)->b_nob)
100 
102 #define BETXCR_F "(%lu,%lu)"
103 
113 #define BETXCR_P(c) (unsigned long)(c)->tc_reg_nr, \
114  (unsigned long)(c)->tc_reg_size
115 
116 
118 M0_INTERNAL void m0_be_tx_credit_add(struct m0_be_tx_credit *c0,
119  const struct m0_be_tx_credit *c1);
120 
122 M0_INTERNAL void m0_be_tx_credit_sub(struct m0_be_tx_credit *c0,
123  const struct m0_be_tx_credit *c1);
124 
126 M0_INTERNAL void m0_be_tx_credit_mul(struct m0_be_tx_credit *c, m0_bcount_t k);
127 
132 M0_INTERNAL void m0_be_tx_credit_mul_bp(struct m0_be_tx_credit *c, unsigned bp);
133 
138 M0_INTERNAL void m0_be_tx_credit_mac(struct m0_be_tx_credit *c,
139  const struct m0_be_tx_credit *c1,
140  m0_bcount_t k);
141 
146 M0_INTERNAL void m0_be_tx_credit_max(struct m0_be_tx_credit *c,
147  const struct m0_be_tx_credit *c0,
148  const struct m0_be_tx_credit *c1);
149 
150 /* c += m0_be_tx_credit_max(c, c0, c1) */
151 M0_INTERNAL void m0_be_tx_credit_add_max(struct m0_be_tx_credit *c,
152  const struct m0_be_tx_credit *c0,
153  const struct m0_be_tx_credit *c1);
154 
155 /* c0 <= c1 */
156 M0_INTERNAL bool m0_be_tx_credit_le(const struct m0_be_tx_credit *c0,
157  const struct m0_be_tx_credit *c1);
158 
159 /* c0 == c1 */
160 M0_INTERNAL bool m0_be_tx_credit_eq(const struct m0_be_tx_credit *c0,
161  const struct m0_be_tx_credit *c1);
162 
164 #endif /* __MOTR_BE_TX_CREDIT_H__ */
165 
166 /*
167  * Local variables:
168  * c-indentation-style: "K&R"
169  * c-basic-offset: 8
170  * tab-width: 8
171  * fill-column: 80
172  * scroll-step: 1
173  * End:
174  */
175 /*
176  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
177  */
M0_INTERNAL void m0_be_tx_credit_add_max(struct m0_be_tx_credit *c, const struct m0_be_tx_credit *c0, const struct m0_be_tx_credit *c1)
Definition: tx_credit.c:120
M0_INTERNAL void m0_be_tx_credit_sub(struct m0_be_tx_credit *c0, const struct m0_be_tx_credit *c1)
Definition: tx_credit.c:55
const struct m0_be_tx_credit m0_be_tx_credit_invalid
Definition: tx_credit.c:41
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL bool m0_be_tx_credit_eq(const struct m0_be_tx_credit *c0, const struct m0_be_tx_credit *c1)
Definition: tx_credit.c:105
m0_be_credit_users
Definition: tx_credit.h:70
M0_INTERNAL void m0_be_tx_credit_mac(struct m0_be_tx_credit *c, const struct m0_be_tx_credit *c1, m0_bcount_t k)
Definition: tx_credit.c:88
unsigned tc_balance[M0_BE_CU_NR]
Definition: tx_credit.h:88
static struct m0_addb2_callback c
Definition: consumer.c:41
M0_INTERNAL void m0_be_tx_credit_mul(struct m0_be_tx_credit *c, m0_bcount_t k)
Definition: tx_credit.c:73
M0_INTERNAL void m0_be_tx_credit_add(struct m0_be_tx_credit *c0, const struct m0_be_tx_credit *c1)
Definition: tx_credit.c:44
m0_bcount_t tc_reg_nr
Definition: tx_credit.h:84
static struct bulkio_params * bp
Definition: bulkio_ut.c:44
M0_INTERNAL bool m0_be_tx_credit_le(const struct m0_be_tx_credit *c0, const struct m0_be_tx_credit *c1)
Definition: tx_credit.c:98
M0_INTERNAL void m0_be_tx_credit_mul_bp(struct m0_be_tx_credit *c, unsigned bp)
Definition: tx_credit.c:82
M0_INTERNAL void m0_be_tx_credit_max(struct m0_be_tx_credit *c, const struct m0_be_tx_credit *c0, const struct m0_be_tx_credit *c1)
Definition: tx_credit.c:112
m0_bcount_t tc_reg_size
Definition: tx_credit.h:86