-static int
-test_perf_AES_CBC_HMAC_SHA256_encrypt_digest_vary_req_size(uint16_t dev_num)
-{
- uint16_t index;
- uint32_t burst_sent, burst_received;
- uint32_t b, num_sent, num_received;
- uint64_t failed_polls, retries, start_cycles, end_cycles;
- const uint64_t mhz = rte_get_tsc_hz()/1000000;
- double throughput, mmps;
-
- struct rte_crypto_op *c_ops[DEFAULT_BURST_SIZE];
- struct rte_crypto_op *proc_ops[DEFAULT_BURST_SIZE];
-
- struct crypto_testsuite_params *ts_params = &testsuite_params;
- struct crypto_unittest_params *ut_params = &unittest_params;
- struct crypto_data_params *data_params = aes_cbc_hmac_sha256_output;
-
- if (rte_cryptodev_count() == 0) {
- printf("\nNo crypto devices available. Is kernel driver loaded?\n");
- return TEST_FAILED;
- }
-
- /* Setup Cipher Parameters */
- ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
- ut_params->cipher_xform.next = &ut_params->auth_xform;
-
- ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
- ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
- ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
- ut_params->cipher_xform.cipher.key.length = CIPHER_IV_LENGTH_AES_CBC;
-
- /* Setup HMAC Parameters */
- ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
- ut_params->auth_xform.next = NULL;
-
- ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
- ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
- ut_params->auth_xform.auth.key.data = hmac_sha256_key;
- ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA256;
- ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA256;
-
- /* Create Crypto session*/
- ut_params->sess = rte_cryptodev_sym_session_create(ts_params->dev_id,
- &ut_params->cipher_xform);
-
- TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
-
- printf("\nThroughput test which will continually attempt to send "
- "AES128_CBC_SHA256_HMAC requests with a constant burst "
- "size of %u while varying payload sizes", DEFAULT_BURST_SIZE);
- printf("\nDev No\tQP No\tReq Size(B)\tNum Sent\tNum Received\t"
- "Mrps\tThoughput(Gbps)");
- printf("\tRetries (Attempted a burst, but the device was busy)");
- for (index = 0; index < MAX_PACKET_SIZE_INDEX; index++) {
- num_sent = 0;
- num_received = 0;
- retries = 0;
- failed_polls = 0;
-
- /* Generate Crypto op data structure(s) */
- for (b = 0; b < DEFAULT_BURST_SIZE ; b++) {
- struct rte_mbuf *m = setup_test_string(
- ts_params->mbuf_mp,
- (const uint8_t *)
- data_params[index].plaintext,
- data_params[index].length,
- 0);
-
- ut_params->digest = (uint8_t *)rte_pktmbuf_append(m,
- DIGEST_BYTE_LENGTH_SHA256);
- TEST_ASSERT_NOT_NULL(ut_params->digest
- , "no room to append digest");
-
- rte_memcpy(ut_params->digest,
- data_params[index].expected.digest,
- DIGEST_BYTE_LENGTH_SHA256);
-
- struct rte_crypto_op *op = rte_crypto_op_alloc(
- ts_params->op_mpool,
- RTE_CRYPTO_OP_TYPE_SYMMETRIC);
-
- rte_crypto_op_attach_sym_session(op, ut_params->sess);
-
- op->sym->auth.digest.data = ut_params->digest;
- op->sym->auth.digest.phys_addr =
- rte_pktmbuf_mtophys_offset(m,
- data_params[index].length);
- op->sym->auth.digest.length = DIGEST_BYTE_LENGTH_SHA256;
-
- op->sym->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
- op->sym->auth.data.length = data_params[index].length;
-
- op->sym->cipher.iv.data = (uint8_t *)
- rte_pktmbuf_prepend(m,
- CIPHER_IV_LENGTH_AES_CBC);
- op->sym->cipher.iv.phys_addr = rte_pktmbuf_mtophys(m);
- op->sym->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
-
- rte_memcpy(op->sym->cipher.iv.data, aes_cbc_iv,
- CIPHER_IV_LENGTH_AES_CBC);
-
- op->sym->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
- op->sym->cipher.data.length = data_params[index].length;
-
-
- op->sym->m_src = m;
-
- c_ops[b] = op;
- }
- start_cycles = rte_rdtsc_precise();
- while (num_sent < DEFAULT_NUM_REQS_TO_SUBMIT) {
- uint16_t burst_size = (DEFAULT_NUM_REQS_TO_SUBMIT -
- num_sent) < DEFAULT_BURST_SIZE ?
- DEFAULT_NUM_REQS_TO_SUBMIT -
- num_sent : DEFAULT_BURST_SIZE;
-
- burst_sent = rte_cryptodev_enqueue_burst(
- dev_num, 0, c_ops, burst_size);
- if (burst_sent == 0)
- retries++;
- else
- num_sent += burst_sent;
-
- burst_received = rte_cryptodev_dequeue_burst(dev_num,
- 0, proc_ops, DEFAULT_BURST_SIZE);
- if (burst_received == 0)
- failed_polls++;
- else
- num_received += burst_received;
- }
- while (num_received != DEFAULT_NUM_REQS_TO_SUBMIT) {
- if (gbl_cryptodev_preftest_devtype ==
- RTE_CRYPTODEV_AESNI_MB_PMD)
- rte_cryptodev_enqueue_burst(dev_num, 0,
- NULL, 0);
-
- burst_received = rte_cryptodev_dequeue_burst(
- dev_num, 0, proc_ops,
- DEFAULT_BURST_SIZE);
- if (burst_received == 0)
- failed_polls++;
- else
- num_received += burst_received;
- }
- end_cycles = rte_rdtsc_precise();
- mmps = ((double)num_received * mhz) /
- (end_cycles - start_cycles);
- throughput = (mmps * data_params[index].length * 8) / 1000;
-
- printf("\n%u\t%u\t%u\t\t%u\t%u", dev_num, 0,
- data_params[index].length,
- num_sent, num_received);
- printf("\t%.2f\t%.2f", mmps, throughput);
- printf("\t\t%"PRIu64, retries);
- for (b = 0; b < DEFAULT_BURST_SIZE ; b++) {
- rte_pktmbuf_free(c_ops[b]->sym->m_src);
- rte_crypto_op_free(c_ops[b]);
- }
- }
-
- printf("\n");
- return TEST_SUCCESS;
-}