Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1 | /* |
| 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: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 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. |
| 14 | */ |
| 15 | |
| 16 | #include <svm/svm_fifo_segment.h> |
| 17 | |
| 18 | svm_fifo_segment_main_t svm_fifo_segment_main; |
| 19 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 20 | static void |
| 21 | preallocate_fifo_pairs (svm_fifo_segment_header_t * fsh, |
| 22 | svm_fifo_segment_create_args_t * a) |
| 23 | { |
| 24 | u32 rx_fifo_size, tx_fifo_size; |
| 25 | svm_fifo_t *f; |
| 26 | u8 *rx_fifo_space, *tx_fifo_space; |
| 27 | int i; |
| 28 | |
| 29 | /* Parameter check */ |
| 30 | if (a->rx_fifo_size == 0 || a->tx_fifo_size == 0 |
| 31 | || a->preallocated_fifo_pairs == 0) |
| 32 | return; |
| 33 | |
| 34 | /* Calculate space requirements */ |
| 35 | rx_fifo_size = (sizeof (*f) + a->rx_fifo_size) * a->preallocated_fifo_pairs; |
| 36 | tx_fifo_size = (sizeof (*f) + a->tx_fifo_size) * a->preallocated_fifo_pairs; |
| 37 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 38 | if (0) |
| 39 | clib_warning ("rx_fifo_size %u (%d mb), tx_fifo_size %u (%d mb)", |
| 40 | rx_fifo_size, rx_fifo_size >> 20, |
| 41 | tx_fifo_size, tx_fifo_size >> 20); |
| 42 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 43 | /* Allocate rx fifo space. May fail. */ |
| 44 | rx_fifo_space = clib_mem_alloc_aligned_at_offset |
| 45 | (rx_fifo_size, CLIB_CACHE_LINE_BYTES, 0 /* align_offset */ , |
| 46 | 0 /* os_out_of_memory */ ); |
| 47 | |
| 48 | /* Same for TX */ |
| 49 | tx_fifo_space = clib_mem_alloc_aligned_at_offset |
| 50 | (tx_fifo_size, CLIB_CACHE_LINE_BYTES, 0 /* align_offset */ , |
| 51 | 0 /* os_out_of_memory */ ); |
| 52 | |
| 53 | /* Make sure it worked. Clean up if it didn't... */ |
| 54 | if (rx_fifo_space == 0 || tx_fifo_space == 0) |
| 55 | { |
| 56 | if (rx_fifo_space) |
| 57 | clib_mem_free (rx_fifo_space); |
| 58 | else |
| 59 | clib_warning ("rx fifo preallocation failure: size %d npairs %d", |
| 60 | a->rx_fifo_size, a->preallocated_fifo_pairs); |
| 61 | |
| 62 | if (tx_fifo_space) |
| 63 | clib_mem_free (tx_fifo_space); |
| 64 | else |
| 65 | clib_warning ("tx fifo preallocation failure: size %d nfifos %d", |
| 66 | a->tx_fifo_size, a->preallocated_fifo_pairs); |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | /* Carve rx fifo space */ |
| 71 | f = (svm_fifo_t *) rx_fifo_space; |
| 72 | for (i = 0; i < a->preallocated_fifo_pairs; i++) |
| 73 | { |
| 74 | f->next = fsh->free_fifos[FIFO_SEGMENT_RX_FREELIST]; |
| 75 | fsh->free_fifos[FIFO_SEGMENT_RX_FREELIST] = f; |
| 76 | rx_fifo_space += sizeof (*f) + a->rx_fifo_size; |
| 77 | f = (svm_fifo_t *) rx_fifo_space; |
| 78 | } |
| 79 | /* Carve tx fifo space */ |
| 80 | f = (svm_fifo_t *) tx_fifo_space; |
| 81 | for (i = 0; i < a->preallocated_fifo_pairs; i++) |
| 82 | { |
| 83 | f->next = fsh->free_fifos[FIFO_SEGMENT_TX_FREELIST]; |
| 84 | fsh->free_fifos[FIFO_SEGMENT_TX_FREELIST] = f; |
| 85 | tx_fifo_space += sizeof (*f) + a->tx_fifo_size; |
| 86 | f = (svm_fifo_t *) tx_fifo_space; |
| 87 | } |
| 88 | } |
| 89 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 90 | /** (master) create an svm fifo segment */ |
| 91 | int |
| 92 | svm_fifo_segment_create (svm_fifo_segment_create_args_t * a) |
| 93 | { |
| 94 | int rv; |
| 95 | svm_fifo_segment_private_t *s; |
| 96 | svm_fifo_segment_main_t *sm = &svm_fifo_segment_main; |
| 97 | ssvm_shared_header_t *sh; |
| 98 | svm_fifo_segment_header_t *fsh; |
| 99 | void *oldheap; |
| 100 | |
| 101 | /* Allocate a fresh segment */ |
| 102 | pool_get (sm->segments, s); |
| 103 | memset (s, 0, sizeof (*s)); |
| 104 | |
| 105 | s->ssvm.ssvm_size = a->segment_size; |
| 106 | s->ssvm.i_am_master = 1; |
| 107 | s->ssvm.my_pid = getpid (); |
| 108 | s->ssvm.name = (u8 *) a->segment_name; |
| 109 | s->ssvm.requested_va = sm->next_baseva; |
| 110 | |
| 111 | rv = ssvm_master_init (&s->ssvm, s - sm->segments); |
| 112 | |
| 113 | if (rv) |
| 114 | { |
| 115 | _vec_len (s) = vec_len (s) - 1; |
| 116 | return (rv); |
| 117 | } |
| 118 | |
| 119 | /* Note; requested_va updated due to seg base addr randomization */ |
| 120 | sm->next_baseva = s->ssvm.requested_va + a->segment_size; |
| 121 | |
| 122 | sh = s->ssvm.sh; |
| 123 | oldheap = ssvm_push_heap (sh); |
| 124 | |
| 125 | /* Set up svm_fifo_segment shared header */ |
| 126 | fsh = clib_mem_alloc (sizeof (*fsh)); |
| 127 | memset (fsh, 0, sizeof (*fsh)); |
| 128 | sh->opaque[0] = fsh; |
| 129 | s->h = fsh; |
| 130 | fsh->segment_name = format (0, "%s%c", a->segment_name, 0); |
| 131 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 132 | preallocate_fifo_pairs (fsh, a); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 133 | |
| 134 | ssvm_pop_heap (oldheap); |
| 135 | |
| 136 | sh->ready = 1; |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 137 | vec_add1 (a->new_segment_indices, s - sm->segments); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 138 | return (0); |
| 139 | } |
| 140 | |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 141 | /** Create an svm fifo segment in process-private memory */ |
| 142 | int |
| 143 | svm_fifo_segment_create_process_private (svm_fifo_segment_create_args_t * a) |
| 144 | { |
| 145 | svm_fifo_segment_private_t *s; |
| 146 | svm_fifo_segment_main_t *sm = &svm_fifo_segment_main; |
| 147 | ssvm_shared_header_t *sh; |
| 148 | svm_fifo_segment_header_t *fsh; |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 149 | void *oldheap; |
| 150 | u8 **heaps = 0; |
| 151 | mheap_t *heap_header; |
| 152 | int segment_count = 1; |
| 153 | int i; |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 154 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 155 | if (a->private_segment_count && a->private_segment_size) |
| 156 | { |
| 157 | void *mem; |
| 158 | u8 *heap; |
| 159 | u32 pagesize = clib_mem_get_page_size (); |
| 160 | u32 rnd_size; |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 161 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 162 | for (i = 0; i < a->private_segment_count; i++) |
| 163 | { |
| 164 | rnd_size = (a->private_segment_size + (pagesize - 1)) & ~pagesize; |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 165 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 166 | mem = mmap (0, rnd_size, PROT_READ | PROT_WRITE, |
| 167 | MAP_PRIVATE | MAP_ANONYMOUS, |
| 168 | -1 /* fd */ , 0 /* offset */ ); |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 169 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 170 | if (mem == MAP_FAILED) |
| 171 | { |
| 172 | clib_unix_warning ("mmap"); |
| 173 | return -1; |
| 174 | } |
| 175 | heap = mheap_alloc (mem, rnd_size); |
| 176 | heap_header = mheap_header (heap); |
| 177 | heap_header->flags |= MHEAP_FLAG_THREAD_SAFE; |
| 178 | vec_add1 (heaps, heap); |
| 179 | } |
| 180 | segment_count = a->private_segment_count; |
| 181 | } |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 182 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 183 | /* Spread preallocated fifo pairs across segments */ |
| 184 | a->preallocated_fifo_pairs /= segment_count; |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 185 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 186 | /* Allocate segments */ |
| 187 | for (i = 0; i < segment_count; i++) |
| 188 | { |
| 189 | pool_get (sm->segments, s); |
| 190 | memset (s, 0, sizeof (*s)); |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 191 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 192 | s->ssvm.ssvm_size = ~0; |
| 193 | s->ssvm.i_am_master = 1; |
| 194 | s->ssvm.my_pid = getpid (); |
| 195 | s->ssvm.name = (u8 *) a->segment_name; |
| 196 | s->ssvm.requested_va = ~0; |
| 197 | |
| 198 | /* Allocate a [sic] shared memory header, in process memory... */ |
| 199 | sh = clib_mem_alloc_aligned (sizeof (*sh), CLIB_CACHE_LINE_BYTES); |
| 200 | s->ssvm.sh = sh; |
| 201 | |
| 202 | memset (sh, 0, sizeof (*sh)); |
| 203 | sh->heap = a->private_segment_count ? heaps[i] : clib_mem_get_heap (); |
| 204 | |
| 205 | /* Set up svm_fifo_segment shared header */ |
| 206 | fsh = clib_mem_alloc (sizeof (*fsh)); |
| 207 | memset (fsh, 0, sizeof (*fsh)); |
| 208 | sh->opaque[0] = fsh; |
| 209 | s->h = fsh; |
| 210 | fsh->segment_name = format (0, "%s%c", a->segment_name, 0); |
| 211 | |
| 212 | if (a->private_segment_count) |
| 213 | { |
| 214 | oldheap = clib_mem_get_heap (); |
| 215 | clib_mem_set_heap (sh->heap); |
| 216 | preallocate_fifo_pairs (fsh, a); |
| 217 | clib_mem_set_heap (oldheap); |
| 218 | } |
| 219 | |
| 220 | sh->ready = 1; |
| 221 | vec_add1 (a->new_segment_indices, s - sm->segments); |
| 222 | } |
| 223 | vec_free (heaps); |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 224 | return (0); |
| 225 | } |
| 226 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 227 | /** (slave) attach to an svm fifo segment */ |
| 228 | int |
| 229 | svm_fifo_segment_attach (svm_fifo_segment_create_args_t * a) |
| 230 | { |
| 231 | int rv; |
| 232 | svm_fifo_segment_private_t *s; |
| 233 | svm_fifo_segment_main_t *sm = &svm_fifo_segment_main; |
| 234 | ssvm_shared_header_t *sh; |
| 235 | svm_fifo_segment_header_t *fsh; |
| 236 | |
| 237 | /* Allocate a fresh segment */ |
| 238 | pool_get (sm->segments, s); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 239 | memset (s, 0, sizeof (*s)); |
| 240 | |
| 241 | s->ssvm.ssvm_size = a->segment_size; |
| 242 | s->ssvm.my_pid = getpid (); |
| 243 | s->ssvm.name = (u8 *) a->segment_name; |
| 244 | s->ssvm.requested_va = sm->next_baseva; |
| 245 | |
| 246 | rv = ssvm_slave_init (&s->ssvm, sm->timeout_in_seconds); |
| 247 | |
| 248 | if (rv) |
| 249 | { |
| 250 | _vec_len (s) = vec_len (s) - 1; |
| 251 | return (rv); |
| 252 | } |
| 253 | |
| 254 | /* Fish the segment header */ |
| 255 | sh = s->ssvm.sh; |
| 256 | fsh = (svm_fifo_segment_header_t *) sh->opaque[0]; |
| 257 | s->h = fsh; |
| 258 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 259 | vec_add1 (a->new_segment_indices, s - sm->segments); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 260 | return (0); |
| 261 | } |
| 262 | |
| 263 | void |
| 264 | svm_fifo_segment_delete (svm_fifo_segment_private_t * s) |
| 265 | { |
| 266 | svm_fifo_segment_main_t *sm = &svm_fifo_segment_main; |
| 267 | ssvm_delete (&s->ssvm); |
| 268 | pool_put (sm->segments, s); |
| 269 | } |
| 270 | |
| 271 | svm_fifo_t * |
| 272 | svm_fifo_segment_alloc_fifo (svm_fifo_segment_private_t * s, |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 273 | u32 data_size_in_bytes, |
| 274 | svm_fifo_segment_freelist_t list_index) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 275 | { |
| 276 | ssvm_shared_header_t *sh; |
| 277 | svm_fifo_segment_header_t *fsh; |
| 278 | svm_fifo_t *f; |
| 279 | void *oldheap; |
| 280 | |
| 281 | sh = s->ssvm.sh; |
| 282 | fsh = (svm_fifo_segment_header_t *) sh->opaque[0]; |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 283 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 284 | ssvm_lock_non_recursive (sh, 1); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 285 | oldheap = ssvm_push_heap (sh); |
| 286 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 287 | switch (list_index) |
| 288 | { |
| 289 | case FIFO_SEGMENT_RX_FREELIST: |
| 290 | case FIFO_SEGMENT_TX_FREELIST: |
| 291 | f = fsh->free_fifos[list_index]; |
| 292 | if (f) |
| 293 | { |
| 294 | fsh->free_fifos[list_index] = f->next; |
| 295 | /* (re)initialize the fifo, as in svm_fifo_create */ |
| 296 | memset (f, 0, sizeof (*f)); |
| 297 | f->nitems = data_size_in_bytes; |
| 298 | f->ooos_list_head = OOO_SEGMENT_INVALID_INDEX; |
| 299 | goto found; |
| 300 | } |
| 301 | /* FALLTHROUGH */ |
| 302 | case FIFO_SEGMENT_FREELIST_NONE: |
| 303 | break; |
| 304 | |
| 305 | default: |
| 306 | clib_warning ("ignore bogus freelist %d", list_index); |
| 307 | break; |
| 308 | } |
| 309 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 310 | /* Note: this can fail, in which case: create another segment */ |
| 311 | f = svm_fifo_create (data_size_in_bytes); |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 312 | if (PREDICT_FALSE (f == 0)) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 313 | { |
| 314 | ssvm_pop_heap (oldheap); |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 315 | ssvm_unlock_non_recursive (sh); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 316 | return (0); |
| 317 | } |
| 318 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 319 | found: |
| 320 | /* If rx_freelist add to active fifos list. When cleaning up segment, |
| 321 | * we need a list of active sessions that should be disconnected. Since |
| 322 | * both rx and tx fifos keep pointers to the session, it's enough to track |
| 323 | * only one. */ |
| 324 | if (list_index == FIFO_SEGMENT_RX_FREELIST) |
| 325 | { |
| 326 | if (fsh->fifos) |
| 327 | { |
| 328 | fsh->fifos->prev = f; |
| 329 | f->next = fsh->fifos; |
| 330 | } |
| 331 | fsh->fifos = f; |
| 332 | } |
| 333 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 334 | ssvm_pop_heap (oldheap); |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 335 | ssvm_unlock_non_recursive (sh); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 336 | return (f); |
| 337 | } |
| 338 | |
| 339 | void |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 340 | svm_fifo_segment_free_fifo (svm_fifo_segment_private_t * s, svm_fifo_t * f, |
| 341 | svm_fifo_segment_freelist_t list_index) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 342 | { |
| 343 | ssvm_shared_header_t *sh; |
| 344 | svm_fifo_segment_header_t *fsh; |
| 345 | void *oldheap; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 346 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 347 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 348 | sh = s->ssvm.sh; |
| 349 | fsh = (svm_fifo_segment_header_t *) sh->opaque[0]; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 350 | |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 351 | ssvm_lock_non_recursive (sh, 2); |
Florin Coras | a546481 | 2017-04-19 13:00:05 -0700 | [diff] [blame] | 352 | oldheap = ssvm_push_heap (sh); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 353 | |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 354 | switch (list_index) |
| 355 | { |
| 356 | case FIFO_SEGMENT_RX_FREELIST: |
| 357 | /* Remove from active list */ |
| 358 | if (f->prev) |
| 359 | f->prev->next = f->next; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 360 | else |
| 361 | fsh->fifos = f->next; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 362 | if (f->next) |
| 363 | f->next->prev = f->prev; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 364 | /* Fall through: we add only rx fifos to active pool */ |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 365 | case FIFO_SEGMENT_TX_FREELIST: |
| 366 | /* Add to free list */ |
| 367 | f->next = fsh->free_fifos[list_index]; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 368 | f->prev = 0; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 369 | fsh->free_fifos[list_index] = f; |
Florin Coras | f03a59a | 2017-06-09 21:07:32 -0700 | [diff] [blame] | 370 | break; |
Dave Barach | 10d8cc6 | 2017-05-30 09:30:07 -0400 | [diff] [blame] | 371 | case FIFO_SEGMENT_FREELIST_NONE: |
| 372 | break; |
| 373 | |
| 374 | default: |
| 375 | clib_warning ("ignore bogus freelist %d", list_index); |
| 376 | break; |
| 377 | } |
| 378 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 379 | ssvm_pop_heap (oldheap); |
Dave Barach | 2c25a62 | 2017-06-26 11:35:07 -0400 | [diff] [blame^] | 380 | ssvm_unlock_non_recursive (sh); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | void |
| 384 | svm_fifo_segment_init (u64 baseva, u32 timeout_in_seconds) |
| 385 | { |
| 386 | svm_fifo_segment_main_t *sm = &svm_fifo_segment_main; |
| 387 | |
| 388 | sm->next_baseva = baseva; |
| 389 | sm->timeout_in_seconds = timeout_in_seconds; |
| 390 | } |
| 391 | |
| 392 | u32 |
| 393 | svm_fifo_segment_index (svm_fifo_segment_private_t * s) |
| 394 | { |
| 395 | return s - svm_fifo_segment_main.segments; |
| 396 | } |
| 397 | |
| 398 | /* |
| 399 | * fd.io coding-style-patch-verification: ON |
| 400 | * |
| 401 | * Local Variables: |
| 402 | * eval: (c-set-style "gnu") |
| 403 | * End: |
| 404 | */ |