* All rights reserved.
*/
+#include "test.h"
#include <string.h>
#include <rte_common.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_cryptodev.h>
+
+#ifdef RTE_EXEC_ENV_WINDOWS
+static int
+test_event_crypto_adapter(void)
+{
+ printf("event_crypto_adapter not supported on Windows, skipping test\n");
+ return TEST_SKIPPED;
+}
+
+#else
+
#include <rte_eventdev.h>
#include <rte_bus_vdev.h>
#include <rte_service.h>
#include <rte_event_crypto_adapter.h>
-#include "test.h"
#define PKT_TRACE 0
#define NUM 1
struct rte_mempool *session_priv_mpool;
struct rte_cryptodev_config *config;
uint8_t crypto_event_port_id;
+ uint8_t internal_port_op_fwd;
};
struct rte_event response_info = {
struct rte_event recv_ev;
int ret;
- ret = rte_event_enqueue_burst(evdev, TEST_APP_PORT_ID, ev, NUM);
- TEST_ASSERT_EQUAL(ret, NUM,
- "Failed to send event to crypto adapter\n");
+ if (params.internal_port_op_fwd)
+ ret = rte_event_crypto_adapter_enqueue(evdev, TEST_APP_PORT_ID,
+ ev, NUM);
+ else
+ ret = rte_event_enqueue_burst(evdev, TEST_APP_PORT_ID, ev, NUM);
+ TEST_ASSERT_EQUAL(ret, NUM, "Failed to send event to crypto adapter\n");
while (rte_event_dequeue_burst(evdev,
TEST_APP_PORT_ID, &recv_ev, NUM, 0) == 0)
cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
cipher_xform.next = NULL;
cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
+ cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
op = rte_crypto_op_alloc(params.op_mpool,
RTE_CRYPTO_OP_TYPE_SYMMETRIC);
if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
/* Fill in private user data information */
- rte_memcpy(&m_data.response_info, &response_info,
- sizeof(response_info));
- rte_memcpy(&m_data.request_info, &request_info,
- sizeof(request_info));
+ m_data.request_info.cdev_id = request_info.cdev_id;
+ m_data.request_info.queue_pair_id =
+ request_info.queue_pair_id;
+ m_data.response_info.event = response_info.event;
rte_cryptodev_sym_session_set_user_data(sess,
&m_data, sizeof(m_data));
}
op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
first_xform = &cipher_xform;
sym_op->xform = first_xform;
- uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH +
- (sizeof(struct rte_crypto_sym_xform) * 2);
+ uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH;
op->private_data_offset = len;
/* Fill in private data information */
- rte_memcpy(&m_data.response_info, &response_info,
- sizeof(response_info));
- rte_memcpy(&m_data.request_info, &request_info,
- sizeof(request_info));
+ m_data.request_info.cdev_id = request_info.cdev_id;
+ m_data.request_info.queue_pair_id = request_info.queue_pair_id;
+ m_data.response_info.event = response_info.event;
rte_memcpy((uint8_t *)op + len, &m_data, sizeof(m_data));
}
cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
cipher_xform.next = NULL;
cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
+ cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
op = rte_crypto_op_alloc(params.op_mpool,
RTE_CRYPTO_OP_TYPE_SYMMETRIC);
if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA) {
/* Fill in private user data information */
- rte_memcpy(&m_data.response_info, &response_info,
- sizeof(m_data));
+ m_data.response_info.event = response_info.event;
rte_cryptodev_sym_session_set_user_data(sess,
&m_data, sizeof(m_data));
}
op->sess_type = RTE_CRYPTO_OP_SESSIONLESS;
first_xform = &cipher_xform;
sym_op->xform = first_xform;
- uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH +
- (sizeof(struct rte_crypto_sym_xform) * 2);
+ uint32_t len = IV_OFFSET + MAXIMUM_IV_LENGTH;
op->private_data_offset = len;
/* Fill in private data information */
- rte_memcpy(&m_data.response_info, &response_info,
- sizeof(m_data));
+ m_data.response_info.event = response_info.event;
rte_memcpy((uint8_t *)op + len, &m_data, sizeof(m_data));
}
NUM_MBUFS, MBUF_CACHE_SIZE,
DEFAULT_NUM_XFORMS *
sizeof(struct rte_crypto_sym_xform) +
- MAXIMUM_IV_LENGTH,
+ MAXIMUM_IV_LENGTH +
+ sizeof(union rte_event_crypto_metadata),
rte_socket_id());
if (params.op_mpool == NULL) {
RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_QP_EV_BIND))
goto adapter_create;
- if ((mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) &&
- !(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD))
- return -ENOTSUP;
+ if (mode == RTE_EVENT_CRYPTO_ADAPTER_OP_FORWARD) {
+ if (cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD)
+ params.internal_port_op_fwd = 1;
+ else
+ return -ENOTSUP;
+ }
if ((mode == RTE_EVENT_CRYPTO_ADAPTER_OP_NEW) &&
!(cap & RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_NEW))
TEST_ASSERT_SUCCESS(ret, "Failed to add queue pair\n");
- ret = rte_event_crypto_adapter_event_port_get(TEST_ADAPTER_ID,
- ¶ms.crypto_event_port_id);
- TEST_ASSERT_SUCCESS(ret, "Failed to get event port\n");
+ if (!params.internal_port_op_fwd) {
+ ret = rte_event_crypto_adapter_event_port_get(TEST_ADAPTER_ID,
+ ¶ms.crypto_event_port_id);
+ TEST_ASSERT_SUCCESS(ret, "Failed to get event port\n");
+ }
return TEST_SUCCESS;
}
rte_service_runstate_set(evdev_service_id, 0);
rte_service_lcore_stop(slcore_id);
rte_service_lcore_del(slcore_id);
+ rte_cryptodev_stop(TEST_CDEV_ID);
+ rte_event_dev_stop(evdev);
+ } else {
+ rte_cryptodev_stop(TEST_CDEV_ID);
rte_event_dev_stop(evdev);
}
}
if (!crypto_adapter_setup_done) {
ret = configure_event_crypto_adapter(mode);
- if (!ret) {
+ if (ret)
+ return ret;
+ if (!params.internal_port_op_fwd) {
qid = TEST_CRYPTO_EV_QUEUE_ID;
ret = rte_event_port_link(evdev,
params.crypto_event_port_id, &qid, NULL, 1);
TEST_ASSERT(ret >= 0, "Failed to link queue %d "
"port=%u\n", qid,
params.crypto_event_port_id);
- } else {
- return ret;
}
crypto_adapter_setup_done = 1;
}
TEST_ASSERT_SUCCESS(rte_event_dev_start(evdev),
"Failed to start event device");
+ /* start the cryptodev */
+ TEST_ASSERT_SUCCESS(rte_cryptodev_start(TEST_CDEV_ID),
+ "Failed to start crypto device");
+
return TEST_SUCCESS;
}
return unit_test_suite_runner(&functional_testsuite);
}
+#endif /* !RTE_EXEC_ENV_WINDOWS */
+
REGISTER_TEST_COMMAND(event_crypto_adapter_autotest,
test_event_crypto_adapter);