4 * Copyright(c) 2015 Intel Corporation. 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.
34 #include <rte_common.h>
36 #include "rte_mbuf_offload.h"
38 /** Initialize rte_mbuf_offload structure */
40 rte_pktmbuf_offload_init(struct rte_mempool *mp,
41 __rte_unused void *opaque_arg,
43 __rte_unused unsigned i)
45 struct rte_mbuf_offload *ol = _op_data;
47 memset(_op_data, 0, mp->elt_size);
49 ol->type = RTE_PKTMBUF_OL_NOT_SPECIFIED;
55 rte_pktmbuf_offload_pool_create(const char *name, unsigned size,
56 unsigned cache_size, uint16_t priv_size, int socket_id)
58 struct rte_pktmbuf_offload_pool_private *priv;
59 unsigned elt_size = sizeof(struct rte_mbuf_offload) + priv_size;
62 /* lookup mempool in case already allocated */
63 struct rte_mempool *mp = rte_mempool_lookup(name);
66 priv = (struct rte_pktmbuf_offload_pool_private *)
67 rte_mempool_get_priv(mp);
69 if (priv->offload_priv_size < priv_size ||
70 mp->elt_size != elt_size ||
71 mp->cache_size < cache_size ||
79 mp = rte_mempool_create(
84 sizeof(struct rte_pktmbuf_offload_pool_private),
87 rte_pktmbuf_offload_init,
95 priv = (struct rte_pktmbuf_offload_pool_private *)
96 rte_mempool_get_priv(mp);
98 priv->offload_priv_size = priv_size;