Motr  M0
buffer_pool.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-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_BUFFER_POOL_H__
26 #define __MOTR_BUFFER_POOL_H__
27 
28 #include "lib/types.h" /* uint64_t */
29 #include "lib/mutex.h"
30 #include "net/net.h" /* m0_net_buffer, m0_net_domain */
31 #include "lib/tlist.h"
32 
140 enum {
143 };
144 
145 struct m0_net_buffer_pool;
146 
153 };
154 
156 M0_INTERNAL bool m0_net_buffer_pool_invariant(const struct m0_net_buffer_pool
157  *pool);
158 
173 M0_INTERNAL int m0_net_buffer_pool_init(struct m0_net_buffer_pool *pool,
174  struct m0_net_domain *ndom,
175  uint32_t threshold, uint32_t seg_nr,
176  m0_bcount_t seg_size, uint32_t colours,
177  unsigned shift, bool dont_dump);
178 
191  uint32_t buf_nr);
195 M0_INTERNAL void m0_net_buffer_pool_fini(struct m0_net_buffer_pool *pool);
196 
198 M0_INTERNAL void m0_net_buffer_pool_lock(struct m0_net_buffer_pool *pool);
199 
201 M0_INTERNAL bool m0_net_buffer_pool_is_locked(const struct m0_net_buffer_pool
202  *pool);
203 
205 M0_INTERNAL bool m0_net_buffer_pool_is_not_locked(const struct
207 
209 M0_INTERNAL void m0_net_buffer_pool_unlock(struct m0_net_buffer_pool *pool);
210 
221 M0_INTERNAL struct m0_net_buffer *
222 m0_net_buffer_pool_get(struct m0_net_buffer_pool *pool, uint32_t colour);
223 
234 M0_INTERNAL void m0_net_buffer_pool_put(struct m0_net_buffer_pool *pool,
235  struct m0_net_buffer *buf,
236  uint32_t colour);
237 
242 M0_INTERNAL bool m0_net_buffer_pool_prune(struct m0_net_buffer_pool *pool);
243 
247  uint32_t nbp_free;
249  uint32_t nbp_threshold;
251  uint32_t nbp_seg_nr;
253  uint32_t nbp_buf_nr;
265  uint32_t nbp_colours_nr;
275  unsigned nbp_align;
285  struct m0_tl nbp_lru;
286 };
287  /* end of net_buffer_pool */
289 #endif
290 
291 /*
292  * Local variables:
293  * c-indentation-style: "K&R"
294  * c-basic-offset: 8
295  * tab-width: 8
296  * fill-column: 79
297  * scroll-step: 1
298  * End:
299  */
static m0_bcount_t seg_size
Definition: net.c:118
M0_INTERNAL void m0_net_buffer_pool_fini(struct m0_net_buffer_pool *pool)
Definition: buffer_pool.c:154
static uint32_t seg_nr
Definition: net.c:119
m0_bcount_t nbp_seg_size
Definition: buffer_pool.h:255
M0_INTERNAL struct m0_net_buffer * m0_net_buffer_pool_get(struct m0_net_buffer_pool *pool, uint32_t colour)
Definition: buffer_pool.c:215
M0_INTERNAL void m0_net_buffer_pool_unlock(struct m0_net_buffer_pool *pool)
Definition: buffer_pool.c:203
const struct m0_net_buffer_pool_ops * nbp_ops
Definition: buffer_pool.h:263
struct m0_tl * nbp_colours
Definition: buffer_pool.h:273
struct m0_tl nbp_lru
Definition: buffer_pool.h:285
uint64_t m0_bcount_t
Definition: types.h:77
Definition: sock.c:887
uint32_t nbp_threshold
Definition: buffer_pool.h:249
M0_INTERNAL bool m0_net_buffer_pool_is_locked(const struct m0_net_buffer_pool *pool)
Definition: buffer_pool.c:191
M0_INTERNAL bool m0_net_buffer_pool_invariant(const struct m0_net_buffer_pool *pool)
Definition: buffer_pool.c:50
void(* nbpo_below_threshold)(struct m0_net_buffer_pool *)
Definition: buffer_pool.h:152
M0_INTERNAL bool m0_net_buffer_pool_prune(struct m0_net_buffer_pool *pool)
Definition: buffer_pool.c:310
M0_INTERNAL bool m0_net_buffer_pool_is_not_locked(const struct m0_net_buffer_pool *pool)
Definition: buffer_pool.c:197
Definition: tlist.h:251
void(* nbpo_not_empty)(struct m0_net_buffer_pool *)
Definition: buffer_pool.h:150
M0_INTERNAL void m0_net_buffer_pool_lock(struct m0_net_buffer_pool *pool)
Definition: buffer_pool.c:186
uint32_t nbp_colours_nr
Definition: buffer_pool.h:265
static struct m0_pool pool
Definition: iter_ut.c:58
struct m0_net_domain * nbp_ndom
Definition: buffer_pool.h:261
struct m0_mutex nbp_mutex
Definition: buffer_pool.h:259
M0_INTERNAL int m0_net_buffer_pool_provision(struct m0_net_buffer_pool *pool, uint32_t buf_nr)
Definition: buffer_pool.c:125
M0_INTERNAL void m0_net_buffer_pool_put(struct m0_net_buffer_pool *pool, struct m0_net_buffer *buf, uint32_t colour)
Definition: buffer_pool.c:243
Definition: mutex.h:47
M0_INTERNAL int m0_net_buffer_pool_init(struct m0_net_buffer_pool *pool, struct m0_net_domain *ndom, uint32_t threshold, uint32_t seg_nr, m0_bcount_t seg_size, uint32_t colours, unsigned shift, bool dont_dump)
Definition: buffer_pool.c:82