2 * Copyright (c) 2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 #ifndef __included_ssvm_fifo_segment_h__
16 #define __included_ssvm_fifo_segment_h__
23 volatile svm_fifo_t **fifos;
25 } svm_fifo_segment_header_t;
30 svm_fifo_segment_header_t *h;
31 } svm_fifo_segment_private_t;
35 /** pool of segments */
36 svm_fifo_segment_private_t *segments;
37 /* Where to put the next one */
39 u32 timeout_in_seconds;
40 } svm_fifo_segment_main_t;
42 extern svm_fifo_segment_main_t svm_fifo_segment_main;
48 u32 new_segment_index;
49 } svm_fifo_segment_create_args_t;
51 static inline svm_fifo_segment_private_t *
52 svm_fifo_get_segment (u32 segment_index)
54 svm_fifo_segment_main_t *ssm = &svm_fifo_segment_main;
55 return vec_elt_at_index (ssm->segments, segment_index);
58 #define foreach_ssvm_fifo_segment_api_error \
59 _(OUT_OF_SPACE, "Out of space in segment", -200)
63 #define _(n,s,c) SSVM_FIFO_SEGMENT_API_ERROR_##n = c,
64 foreach_ssvm_fifo_segment_api_error
66 } ssvm_fifo_segment_api_error_enum_t;
68 int svm_fifo_segment_create (svm_fifo_segment_create_args_t * a);
69 int svm_fifo_segment_attach (svm_fifo_segment_create_args_t * a);
70 void svm_fifo_segment_delete (svm_fifo_segment_private_t * s);
72 svm_fifo_t *svm_fifo_segment_alloc_fifo (svm_fifo_segment_private_t * s,
73 u32 data_size_in_bytes);
74 void svm_fifo_segment_free_fifo (svm_fifo_segment_private_t * s,
77 void svm_fifo_segment_init (u64 baseva, u32 timeout_in_seconds);
79 u32 svm_fifo_segment_index (svm_fifo_segment_private_t * s);
81 #endif /* __included_ssvm_fifo_segment_h__ */
84 * fd.io coding-style-patch-verification: ON
87 * eval: (c-set-style "gnu")