ut/crypto: remove internal rte_cryptodev headers
Those were added to allow us mocking DPDK functions originaly defined as static inline. They are based on a fixed DPDK version and currently require a lot of effort to update for DPDK 19.02+. There's a different way of mocking them: > #define rte_crypto_op_bulk_alloc mock_rte_crypto_op_bulk_alloc > static inline unsigned mock_rte_crypto_op_bulk_alloc() { ... } This patch uses the above method to mock all static inline functions before including the crypto source file in crypto_ut. As a result we can get rid of the rte_ header copies from SPDK, which greatly reduces the effort required to make crypto_ut work with DPDK 19.02. Change-Id: I0f07a9ff4f1c63036e058dffd3fcf0c21e77bff3 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/443592 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
1f2a1dfc6c
commit
06ccc49eef
@ -37,20 +37,13 @@
|
||||
#include "spdk_internal/mock.h"
|
||||
#include "unit/lib/json_mock.c"
|
||||
|
||||
/* these rte_ headers are our local copies of the DPDK headers hacked to mock some functions
|
||||
* included in them that can't be done with our mock library.
|
||||
*/
|
||||
#include "rte_crypto.h"
|
||||
#include "rte_cryptodev.h"
|
||||
#include "bdev/crypto/vbdev_crypto.c"
|
||||
#include <rte_crypto.h>
|
||||
#include <rte_cryptodev.h>
|
||||
|
||||
#define MAX_TEST_BLOCKS 8192
|
||||
struct rte_crypto_op *g_test_crypto_ops[MAX_TEST_BLOCKS];
|
||||
struct rte_crypto_op *g_test_dev_full_ops[MAX_TEST_BLOCKS];
|
||||
|
||||
/* These globals are externs in our local rte_ header files so we can control
|
||||
* specific functions for mocking.
|
||||
*/
|
||||
uint16_t g_dequeue_mock;
|
||||
uint16_t g_enqueue_mock;
|
||||
unsigned ut_rte_crypto_op_bulk_alloc;
|
||||
@ -58,10 +51,14 @@ int ut_rte_crypto_op_attach_sym_session = 0;
|
||||
int ut_rte_cryptodev_info_get = 0;
|
||||
bool ut_rte_cryptodev_info_get_mocked = false;
|
||||
|
||||
/* Used in testing device full condition */
|
||||
/* Those functions are defined as static inline in DPDK, so we can't
|
||||
* mock them straight away. We use defines to redirect them into
|
||||
* our custom functions.
|
||||
*/
|
||||
#define rte_cryptodev_enqueue_burst mock_rte_cryptodev_enqueue_burst
|
||||
static inline uint16_t
|
||||
rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
|
||||
struct rte_crypto_op **ops, uint16_t nb_ops)
|
||||
mock_rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
|
||||
struct rte_crypto_op **ops, uint16_t nb_ops)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -84,9 +81,10 @@ rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
|
||||
* no more IOs to drain.
|
||||
*/
|
||||
int g_test_overflow = 0;
|
||||
#define rte_cryptodev_dequeue_burst mock_rte_cryptodev_dequeue_burst
|
||||
static inline uint16_t
|
||||
rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
|
||||
struct rte_crypto_op **ops, uint16_t nb_ops)
|
||||
mock_rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
|
||||
struct rte_crypto_op **ops, uint16_t nb_ops)
|
||||
{
|
||||
CU_ASSERT(nb_ops > 0);
|
||||
|
||||
@ -108,10 +106,11 @@ rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
|
||||
/* Instead of allocating real memory, assign the allocations to our
|
||||
* test array for assertion in tests.
|
||||
*/
|
||||
#define rte_crypto_op_bulk_alloc mock_rte_crypto_op_bulk_alloc
|
||||
static inline unsigned
|
||||
rte_crypto_op_bulk_alloc(struct rte_mempool *mempool,
|
||||
enum rte_crypto_op_type type,
|
||||
struct rte_crypto_op **ops, uint16_t nb_ops)
|
||||
mock_rte_crypto_op_bulk_alloc(struct rte_mempool *mempool,
|
||||
enum rte_crypto_op_type type,
|
||||
struct rte_crypto_op **ops, uint16_t nb_ops)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -121,20 +120,24 @@ rte_crypto_op_bulk_alloc(struct rte_mempool *mempool,
|
||||
return ut_rte_crypto_op_bulk_alloc;
|
||||
}
|
||||
|
||||
#define rte_mempool_put_bulk mock_rte_mempool_put_bulk
|
||||
static __rte_always_inline void
|
||||
rte_mempool_put_bulk(struct rte_mempool *mp, void *const *obj_table,
|
||||
unsigned int n)
|
||||
mock_rte_mempool_put_bulk(struct rte_mempool *mp, void *const *obj_table,
|
||||
unsigned int n)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#define rte_crypto_op_attach_sym_session mock_rte_crypto_op_attach_sym_session
|
||||
static inline int
|
||||
rte_crypto_op_attach_sym_session(struct rte_crypto_op *op,
|
||||
struct rte_cryptodev_sym_session *sess)
|
||||
mock_rte_crypto_op_attach_sym_session(struct rte_crypto_op *op,
|
||||
struct rte_cryptodev_sym_session *sess)
|
||||
{
|
||||
return ut_rte_crypto_op_attach_sym_session;
|
||||
}
|
||||
|
||||
#include "bdev/crypto/vbdev_crypto.c"
|
||||
|
||||
/* SPDK stubs */
|
||||
DEFINE_STUB(spdk_conf_find_section, struct spdk_conf_section *,
|
||||
(struct spdk_conf *cp, const char *name), NULL);
|
||||
@ -186,13 +189,7 @@ DEFINE_STUB(rte_cryptodev_sym_session_init, int, (uint8_t dev_id,
|
||||
DEFINE_STUB(rte_vdev_init, int, (const char *name, const char *args), 0);
|
||||
DEFINE_STUB(rte_cryptodev_sym_session_free, int, (struct rte_cryptodev_sym_session *sess), 0);
|
||||
|
||||
void __attribute__((noreturn)) __rte_panic(const char *funcname, const char *format, ...)
|
||||
{
|
||||
abort();
|
||||
}
|
||||
struct rte_mempool_ops_table rte_mempool_ops_table;
|
||||
struct rte_cryptodev *rte_cryptodevs;
|
||||
__thread unsigned per_lcore__lcore_id = 0;
|
||||
|
||||
/* global vars and setup/cleanup functions used for all test functions */
|
||||
struct spdk_bdev_io *g_bdev_io;
|
||||
|
@ -1,95 +0,0 @@
|
||||
/*-
|
||||
* BSD LICENSE
|
||||
*
|
||||
* Copyright (c) Intel Corporation.
|
||||
* Copyright(c) 2016 6WIND S.A.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Intel Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUcryptoION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _RTE_CRYPTO_H_
|
||||
#define _RTE_CRYPTO_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* In order to mock some DPDK functions, we place headers here with the name name as the DPDK headers
|
||||
* so these definitions wil be picked up. Only what's mocked is included.
|
||||
*/
|
||||
|
||||
#include "rte_mbuf.h"
|
||||
#include "rte_mempool.h"
|
||||
#include "rte_crypto_sym.h"
|
||||
|
||||
enum rte_crypto_op_type {
|
||||
RTE_CRYPTO_OP_TYPE_UNDEFINED,
|
||||
RTE_CRYPTO_OP_TYPE_SYMMETRIC,
|
||||
};
|
||||
|
||||
enum rte_crypto_op_status {
|
||||
RTE_CRYPTO_OP_STATUS_SUCCESS,
|
||||
RTE_CRYPTO_OP_STATUS_NOT_PROCESSED,
|
||||
RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
|
||||
RTE_CRYPTO_OP_STATUS_INVALID_SESSION,
|
||||
RTE_CRYPTO_OP_STATUS_INVALID_ARGS,
|
||||
RTE_CRYPTO_OP_STATUS_ERROR,
|
||||
};
|
||||
|
||||
struct rte_crypto_op {
|
||||
uint8_t type;
|
||||
uint8_t status;
|
||||
uint8_t sess_type;
|
||||
uint8_t reserved[5];
|
||||
struct rte_mempool *mempool;
|
||||
rte_iova_t phys_addr;
|
||||
__extension__
|
||||
union {
|
||||
struct rte_crypto_sym_op sym[0];
|
||||
};
|
||||
};
|
||||
|
||||
extern struct rte_mempool *
|
||||
rte_crypto_op_pool_create(const char *name, enum rte_crypto_op_type type,
|
||||
unsigned nb_elts, unsigned cache_size, uint16_t priv_size,
|
||||
int socket_id);
|
||||
|
||||
static inline unsigned
|
||||
rte_crypto_op_bulk_alloc(struct rte_mempool *mempool,
|
||||
enum rte_crypto_op_type type,
|
||||
struct rte_crypto_op **ops, uint16_t nb_ops);
|
||||
|
||||
static inline int
|
||||
rte_crypto_op_attach_sym_session(struct rte_crypto_op *op,
|
||||
struct rte_cryptodev_sym_session *sess);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,153 +0,0 @@
|
||||
/*-
|
||||
*
|
||||
* Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
|
||||
* Copyright 2014 6WIND S.A.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Intel Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _RTE_CRYPTODEV_H_
|
||||
#define _RTE_CRYPTODEV_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* In order to mock some DPDK functions, we place headers here with the name name as the DPDK headers
|
||||
* so these definitions wil be picked up. Only what's mocked is included.
|
||||
*/
|
||||
|
||||
uint8_t dummy[16];
|
||||
#define rte_crypto_op_ctod_offset(c, t, o) &dummy[0]
|
||||
|
||||
#define RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER (1ULL << 9)
|
||||
|
||||
struct rte_cryptodev_info {
|
||||
const char *driver_name;
|
||||
uint8_t driver_id;
|
||||
struct rte_pci_device *pci_dev;
|
||||
uint64_t feature_flags;
|
||||
const struct rte_cryptodev_capabilities *capabilities;
|
||||
unsigned max_nb_queue_pairs;
|
||||
struct {
|
||||
unsigned max_nb_sessions;
|
||||
unsigned int max_nb_sessions_per_qp;
|
||||
} sym;
|
||||
};
|
||||
|
||||
enum rte_cryptodev_event_type {
|
||||
RTE_CRYPTODEV_EVENT_UNKNOWN,
|
||||
RTE_CRYPTODEV_EVENT_ERROR,
|
||||
RTE_CRYPTODEV_EVENT_MAX
|
||||
};
|
||||
|
||||
struct rte_cryptodev_qp_conf {
|
||||
uint32_t nb_descriptors;
|
||||
};
|
||||
|
||||
struct rte_cryptodev_stats {
|
||||
uint64_t enqueued_count;
|
||||
uint64_t dequeued_count;
|
||||
uint64_t enqueue_err_count;
|
||||
uint64_t dequeue_err_count;
|
||||
};
|
||||
|
||||
#define RTE_CRYPTODEV_NAME_MAX_LEN (64)
|
||||
|
||||
extern uint8_t
|
||||
rte_cryptodev_count(void);
|
||||
|
||||
extern uint8_t
|
||||
rte_cryptodev_device_count_by_driver(uint8_t driver_id);
|
||||
|
||||
extern int
|
||||
rte_cryptodev_socket_id(uint8_t dev_id);
|
||||
|
||||
struct rte_cryptodev_config {
|
||||
int socket_id;
|
||||
uint16_t nb_queue_pairs;
|
||||
};
|
||||
|
||||
extern int
|
||||
rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
|
||||
|
||||
extern int
|
||||
rte_cryptodev_start(uint8_t dev_id);
|
||||
|
||||
extern void
|
||||
rte_cryptodev_stop(uint8_t dev_id);
|
||||
|
||||
extern int
|
||||
rte_cryptodev_queue_pair_setup(uint8_t dev_id, uint16_t queue_pair_id,
|
||||
const struct rte_cryptodev_qp_conf *qp_conf, int socket_id,
|
||||
struct rte_mempool *session_pool);
|
||||
|
||||
extern void
|
||||
rte_cryptodev_info_get(uint8_t dev_id, struct rte_cryptodev_info *dev_info);
|
||||
|
||||
static inline uint16_t
|
||||
rte_cryptodev_dequeue_burst(uint8_t dev_id, uint16_t qp_id,
|
||||
struct rte_crypto_op **ops, uint16_t nb_ops);
|
||||
|
||||
static inline uint16_t
|
||||
rte_cryptodev_enqueue_burst(uint8_t dev_id, uint16_t qp_id,
|
||||
struct rte_crypto_op **ops, uint16_t nb_ops);
|
||||
|
||||
struct rte_cryptodev_sym_session {
|
||||
__extension__ void *sess_private_data[0];
|
||||
};
|
||||
|
||||
struct rte_cryptodev_asym_session {
|
||||
__extension__ void *sess_private_data[0];
|
||||
};
|
||||
|
||||
struct rte_crypto_asym_xform;
|
||||
|
||||
struct rte_cryptodev_sym_session *
|
||||
rte_cryptodev_sym_session_create(struct rte_mempool *mempool);
|
||||
|
||||
int
|
||||
rte_cryptodev_sym_session_free(struct rte_cryptodev_sym_session *sess);
|
||||
|
||||
int
|
||||
rte_cryptodev_sym_session_init(uint8_t dev_id,
|
||||
struct rte_cryptodev_sym_session *sess,
|
||||
struct rte_crypto_sym_xform *xforms,
|
||||
struct rte_mempool *mempool);
|
||||
|
||||
int
|
||||
rte_cryptodev_sym_session_clear(uint8_t dev_id,
|
||||
struct rte_cryptodev_sym_session *sess);
|
||||
|
||||
unsigned int
|
||||
rte_cryptodev_sym_get_private_session_size(uint8_t dev_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,148 +0,0 @@
|
||||
/*-
|
||||
*
|
||||
* Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
|
||||
* Copyright 2014 6WIND S.A.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Intel Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _RTE_MBUF_H_
|
||||
#define _RTE_MBUF_H_
|
||||
|
||||
#include "rte_mempool.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* In order to mock some DPDK functions, we place headers here with the name name as the DPDK headers
|
||||
* so these definitions wil be picked up. Only what's mocked is included.
|
||||
*/
|
||||
|
||||
__extension__
|
||||
typedef void *MARKER[0];
|
||||
__extension__
|
||||
typedef uint8_t MARKER8[0];
|
||||
__extension__
|
||||
typedef uint64_t MARKER64[0];
|
||||
|
||||
struct rte_mbuf {
|
||||
MARKER cacheline0;
|
||||
void *buf_addr;
|
||||
RTE_STD_C11
|
||||
union {
|
||||
rte_iova_t buf_iova;
|
||||
rte_iova_t buf_physaddr;
|
||||
} __rte_aligned(sizeof(rte_iova_t));
|
||||
MARKER64 rearm_data;
|
||||
uint16_t data_off;
|
||||
RTE_STD_C11
|
||||
union {
|
||||
rte_atomic16_t refcnt_atomic;
|
||||
uint16_t refcnt;
|
||||
};
|
||||
uint16_t nb_segs;
|
||||
uint16_t port;
|
||||
uint64_t ol_flags;
|
||||
MARKER rx_descriptor_fields1;
|
||||
RTE_STD_C11
|
||||
union {
|
||||
uint32_t packet_type;
|
||||
struct {
|
||||
uint32_t l2_type: 4;
|
||||
uint32_t l3_type: 4;
|
||||
uint32_t l4_type: 4;
|
||||
uint32_t tun_type: 4;
|
||||
RTE_STD_C11
|
||||
union {
|
||||
uint8_t inner_esp_next_proto;
|
||||
__extension__
|
||||
struct {
|
||||
uint8_t inner_l2_type: 4;
|
||||
uint8_t inner_l3_type: 4;
|
||||
};
|
||||
};
|
||||
uint32_t inner_l4_type: 4;
|
||||
};
|
||||
};
|
||||
uint32_t pkt_len;
|
||||
uint16_t data_len;
|
||||
uint16_t vlan_tci;
|
||||
union {
|
||||
uint32_t rss;
|
||||
struct {
|
||||
RTE_STD_C11
|
||||
union {
|
||||
struct {
|
||||
uint16_t hash;
|
||||
uint16_t id;
|
||||
};
|
||||
uint32_t lo;
|
||||
};
|
||||
uint32_t hi;
|
||||
} fdir;
|
||||
struct {
|
||||
uint32_t lo;
|
||||
uint32_t hi;
|
||||
} sched;
|
||||
uint32_t usr;
|
||||
} hash;
|
||||
uint16_t vlan_tci_outer;
|
||||
uint16_t buf_len;
|
||||
uint64_t timestamp;
|
||||
MARKER cacheline1 __rte_cache_min_aligned;
|
||||
RTE_STD_C11
|
||||
union {
|
||||
void *userdata;
|
||||
uint64_t udata64;
|
||||
};
|
||||
struct rte_mempool *pool;
|
||||
struct rte_mbuf *next;
|
||||
RTE_STD_C11
|
||||
union {
|
||||
uint64_t tx_offload;
|
||||
__extension__
|
||||
struct {
|
||||
uint64_t l2_len: 7;
|
||||
uint64_t l3_len: 9;
|
||||
uint64_t l4_len: 8;
|
||||
uint64_t tso_segsz: 16;
|
||||
uint64_t outer_l3_len: 9;
|
||||
uint64_t outer_l2_len: 7;
|
||||
};
|
||||
};
|
||||
uint16_t priv_size;
|
||||
uint16_t timesync;
|
||||
uint32_t seqn;
|
||||
|
||||
} __rte_cache_aligned;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,145 +0,0 @@
|
||||
/*-
|
||||
*
|
||||
* Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
|
||||
* Copyright 2014 6WIND S.A.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Intel Corporation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _RTE_MEMPOOL_H_
|
||||
#define _RTE_MEMPOOL_H_
|
||||
|
||||
/**
|
||||
* @file
|
||||
* RTE Mempool.
|
||||
*
|
||||
* A memory pool is an allocator of fixed-size object. It is
|
||||
* identified by its name, and uses a ring to store free objects. It
|
||||
* provides some other optional services, like a per-core object
|
||||
* cache, and an alignment helper to ensure that objects are padded
|
||||
* to spread them equally on all RAM channels, ranks, and so on.
|
||||
*
|
||||
* Objects owned by a mempool should never be added in another
|
||||
* mempool. When an object is freed using rte_mempool_put() or
|
||||
* equivalent, the object data is not modified; the user can save some
|
||||
* meta-data in the object data and retrieve them when allocating a
|
||||
* new object.
|
||||
*
|
||||
* Note: the mempool implementation is not preemptible. An lcore must not be
|
||||
* interrupted by another task that uses the same mempool (because it uses a
|
||||
* ring which is not preemptible). Also, usual mempool functions like
|
||||
* rte_mempool_get() or rte_mempool_put() are designed to be called from an EAL
|
||||
* thread due to the internal per-lcore cache. Due to the lack of caching,
|
||||
* rte_mempool_get() or rte_mempool_put() performance will suffer when called
|
||||
* by non-EAL threads. Instead, non-EAL threads should call
|
||||
* rte_mempool_generic_get() or rte_mempool_generic_put() with a user cache
|
||||
* created with rte_mempool_cache_create().
|
||||
*/
|
||||
|
||||
#include <rte_config.h>
|
||||
#include <rte_spinlock.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_ring.h>
|
||||
#include <rte_memcpy.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* In order to mock some DPDK functions, we place headers here with the name name as the DPDK headers
|
||||
* so these definitions wil be picked up. Only what's mocked is included.
|
||||
*/
|
||||
|
||||
STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
|
||||
STAILQ_HEAD(rte_mempool_memhdr_list, rte_mempool_memhdr);
|
||||
struct rte_mempool {
|
||||
char name[RTE_MEMZONE_NAMESIZE];
|
||||
RTE_STD_C11
|
||||
union {
|
||||
void *pool_data;
|
||||
uint64_t pool_id;
|
||||
};
|
||||
void *pool_config;
|
||||
const struct rte_memzone *mz;
|
||||
unsigned int flags;
|
||||
int socket_id;
|
||||
uint32_t size;
|
||||
uint32_t cache_size;
|
||||
uint32_t elt_size;
|
||||
uint32_t header_size;
|
||||
uint32_t trailer_size;
|
||||
unsigned private_data_size;
|
||||
int32_t ops_index;
|
||||
struct rte_mempool_cache *local_cache;
|
||||
uint32_t populated_size;
|
||||
struct rte_mempool_objhdr_list elt_list;
|
||||
uint32_t nb_mem_chunks;
|
||||
struct rte_mempool_memhdr_list mem_list;
|
||||
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
|
||||
struct rte_mempool_debug_stats stats[RTE_MAX_LCORE];
|
||||
#endif
|
||||
} __rte_cache_aligned;
|
||||
#define RTE_MEMPOOL_OPS_NAMESIZE 32
|
||||
typedef int (*rte_mempool_alloc_t)(struct rte_mempool *mp);
|
||||
typedef void (*rte_mempool_free_t)(struct rte_mempool *mp);
|
||||
typedef int (*rte_mempool_enqueue_t)(struct rte_mempool *mp,
|
||||
void *const *obj_table, unsigned int n);
|
||||
typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp,
|
||||
void **obj_table, unsigned int n);
|
||||
typedef unsigned(*rte_mempool_get_count)(const struct rte_mempool *mp);
|
||||
typedef int (*rte_mempool_get_capabilities_t)(const struct rte_mempool *mp,
|
||||
unsigned int *flags);
|
||||
typedef int (*rte_mempool_ops_register_memory_area_t)
|
||||
(const struct rte_mempool *mp, char *vaddr, rte_iova_t iova, size_t len);
|
||||
struct rte_mempool_ops {
|
||||
char name[RTE_MEMPOOL_OPS_NAMESIZE];
|
||||
rte_mempool_alloc_t alloc;
|
||||
rte_mempool_free_t free;
|
||||
rte_mempool_enqueue_t enqueue;
|
||||
rte_mempool_dequeue_t dequeue;
|
||||
rte_mempool_get_count get_count;
|
||||
rte_mempool_get_capabilities_t get_capabilities;
|
||||
rte_mempool_ops_register_memory_area_t register_memory_area;
|
||||
} __rte_cache_aligned;
|
||||
#define RTE_MEMPOOL_MAX_OPS_IDX 16
|
||||
struct rte_mempool_ops_table {
|
||||
rte_spinlock_t sl;
|
||||
uint32_t num_ops;
|
||||
struct rte_mempool_ops ops[RTE_MEMPOOL_MAX_OPS_IDX];
|
||||
} __rte_cache_aligned;
|
||||
extern struct rte_mempool_ops_table rte_mempool_ops_table;
|
||||
void
|
||||
rte_mempool_free(struct rte_mempool *mp);
|
||||
static __rte_always_inline void
|
||||
rte_mempool_put_bulk(struct rte_mempool *mp, void *const *obj_table,
|
||||
unsigned int n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _RTE_MEMPOOL_H_ */
|
Loading…
Reference in New Issue
Block a user