4 * Copyright (C) 2017 Cavium Inc. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <rte_mempool.h>
34 #include <rte_malloc.h>
37 #include "octeontx_fpavf.h"
40 octeontx_fpavf_alloc(struct rte_mempool *mp)
43 uint32_t memseg_count = mp->size;
48 /* virtual hugepage mapped addr */
49 va_start = ~(uint64_t)0;
51 object_size = mp->elt_size + mp->header_size + mp->trailer_size;
53 pool = octeontx_fpa_bufpool_create(object_size, memseg_count,
54 OCTEONTX_FPAVF_BUF_OFFSET,
57 rc = octeontx_fpa_bufpool_block_size(pool);
61 if ((uint32_t)rc != object_size)
62 fpavf_log_err("buffer size mismatch: %d instead of %u\n",
65 fpavf_log_info("Pool created %p with .. ", (void *)pool);
66 fpavf_log_info("obj_sz %d, cnt %d\n", object_size, memseg_count);
68 /* assign pool handle to mempool */
69 mp->pool_id = (uint64_t)pool;
78 octeontx_fpavf_free(struct rte_mempool *mp)
82 pool = (uintptr_t)mp->pool_id;
84 octeontx_fpa_bufpool_destroy(pool, mp->socket_id);
87 static struct rte_mempool_ops octeontx_fpavf_ops = {
88 .name = "octeontx_fpavf",
89 .alloc = octeontx_fpavf_alloc,
90 .free = octeontx_fpavf_free,
94 .get_capabilities = NULL,
95 .register_memory_area = NULL,
98 MEMPOOL_REGISTER_OPS(octeontx_fpavf_ops);