/*
* Copyright (c) 2017 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <vppinfra/maplog.h>
/**
* @brief Initialize a maplog object
*
* Compute record and file size parameters
* Create and map two log segments to seed the process
*
* @param[in/out] a init args structure
* @return 0 => success, <0 => failure
*/
__clib_export int
clib_maplog_init (clib_maplog_init_args_t *a)
{
int i, fd, limit;
int rv = 0;
u8 zero = 0;
u32 record_size_in_cache_lines;
u64 file_size_in_records;
clib_maplog_main_t *mm;
clib_maplog_header_t _h, *h = &_h;
ASSERT (a && a->mm);
mm = a->mm;
/* Already initialized? */
if (mm->flags & CLIB_MAPLOG_FLAG_INIT)
return (-2);
clib_memset (mm, 0, sizeof (*mm));
record_size_in_cache_lines =
(a->record_size_in_bytes + CLIB_CACHE_LINE_BYTES -
1) / CLIB_CACHE_LINE_BYTES;
file_size_in_records