net/octeontx2: support flow action port ID
[dpdk.git] / app / test / test_cryptodev_blockcipher.c
index 473dad9..135e57b 100644 (file)
@@ -103,11 +103,11 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
 
        if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SESSIONLESS) {
                if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
-                       printf("Device doesn't support sesionless operations "
+                       printf("Device doesn't support sessionless operations "
                                "Test Skipped.\n");
                        snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
                                "SKIPPED");
-                       return 0;
+                       return TEST_SKIPPED;
                }
        }
        if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_SG) {
@@ -120,7 +120,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
                                        "Test Skipped.\n");
                                snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
                                        "SKIPPED");
-                               return 0;
+                               return TEST_SKIPPED;
                        }
                } else {
                        if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
@@ -129,13 +129,21 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
                                        "Test Skipped.\n");
                                snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
                                        "SKIPPED");
-                               return 0;
+                               return TEST_SKIPPED;
                        }
                }
 
                nb_segs = 3;
        }
 
+       if (global_api_test_type == CRYPTODEV_RAW_API_TEST &&
+               !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)) {
+               printf("Device doesn't support raw data-path APIs. "
+                       "Test Skipped.\n");
+               snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "SKIPPED");
+               return TEST_SKIPPED;
+       }
+
        if (t->feature_mask & BLOCKCIPHER_TEST_FEATURE_OOP) {
                uint64_t oop_flags = RTE_CRYPTODEV_FF_OOP_LB_IN_LB_OUT |
                        RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT |
@@ -146,7 +154,14 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
                                "Test Skipped.\n");
                        snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
                                "SKIPPED");
-                       return 0;
+                       return TEST_SKIPPED;
+               }
+               if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
+                       printf("Raw Data Path APIs do not support OOP, "
+                               "Test Skipped.\n");
+                       snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "SKIPPED");
+                       status = TEST_SUCCESS;
+                       goto error_exit;
                }
        }
 
@@ -163,7 +178,7 @@ test_blockcipher_one_case(const struct blockcipher_test_case *t,
                        "Device does not support this algorithm."
                        "Test Skipped.\n");
                snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "SKIPPED");
-               return 0;
+               return TEST_SKIPPED;
        }
 
        /* preparing data */
@@ -379,7 +394,11 @@ iterate:
                cipher_xform->cipher.key.data = cipher_key;
                cipher_xform->cipher.key.length = tdata->cipher_key.len;
                cipher_xform->cipher.iv.offset = IV_OFFSET;
-               cipher_xform->cipher.iv.length = tdata->iv.len;
+
+               if (tdata->crypto_algo == RTE_CRYPTO_CIPHER_NULL)
+                       cipher_xform->cipher.iv.length = 0;
+               else
+                       cipher_xform->cipher.iv.length = tdata->iv.len;
 
                sym_op->cipher.data.offset = tdata->cipher_offset;
                sym_op->cipher.data.length = tdata->ciphertext.len -
@@ -427,9 +446,14 @@ iterate:
                        nb_iterates == 0) {
                sess = rte_cryptodev_sym_session_create(sess_mpool);
 
-               rte_cryptodev_sym_session_init(dev_id, sess, init_xform,
-                               sess_priv_mpool);
-               if (!sess) {
+               status = rte_cryptodev_sym_session_init(dev_id, sess,
+                               init_xform, sess_priv_mpool);
+               if (status == -ENOTSUP) {
+                       snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "UNSUPPORTED");
+                       status = TEST_SKIPPED;
+                       goto error_exit;
+               }
+               if (!sess || status < 0) {
                        snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN, "line %u "
                                "FAILED: %s", __LINE__,
                                "Session creation failed");
@@ -453,25 +477,36 @@ iterate:
        }
 
        /* Process crypto operation */
-       if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
-               snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
-                       "line %u FAILED: %s",
-                       __LINE__, "Error sending packet for encryption");
-               status = TEST_FAILED;
-               goto error_exit;
-       }
+       if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
+               uint8_t is_cipher = 0, is_auth = 0;
+               if (t->op_mask & BLOCKCIPHER_TEST_OP_CIPHER)
+                       is_cipher = 1;
+               if (t->op_mask & BLOCKCIPHER_TEST_OP_AUTH)
+                       is_auth = 1;
 
-       op = NULL;
+               process_sym_raw_dp_op(dev_id, 0, op, is_cipher, is_auth, 0,
+                               tdata->iv.len);
+       } else {
+               if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
+                       snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
+                               "line %u FAILED: %s",
+                               __LINE__, "Error sending packet for encryption");
+                       status = TEST_FAILED;
+                       goto error_exit;
+               }
 
-       while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
-               rte_pause();
+               op = NULL;
 
-       if (!op) {
-               snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
-                       "line %u FAILED: %s",
-                       __LINE__, "Failed to process sym crypto op");
-               status = TEST_FAILED;
-               goto error_exit;
+               while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
+                       rte_pause();
+
+               if (!op) {
+                       snprintf(test_msg, BLOCKCIPHER_TEST_MSG_LEN,
+                               "line %u FAILED: %s",
+                               __LINE__, "Failed to process sym crypto op");
+                       status = TEST_FAILED;
+                       goto error_exit;
+               }
        }
 
        debug_hexdump(stdout, "m_src(after):",
@@ -772,9 +807,8 @@ test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
                printf("  %u) TestCase %s %s\n", test_index ++,
                        tc->test_descr, test_msg);
 
-               if (status != TEST_SUCCESS) {
-                       if (overall_status == TEST_SUCCESS)
-                               overall_status = status;
+               if (status == TEST_FAILED) {
+                       overall_status = status;
 
                        if (tc->feature_mask & BLOCKCIPHER_TEST_FEATURE_STOPPER)
                                break;