]> git.droids-corp.org - dpdk.git/commitdiff
test/crypto: add IPsec security stats cases
authorAnkur Dwivedi <adwivedi@marvell.com>
Mon, 6 Dec 2021 11:07:55 +0000 (16:37 +0530)
committerAkhil Goyal <gakhil@marvell.com>
Fri, 21 Jan 2022 10:55:12 +0000 (11:55 +0100)
Add security stats test cases in IPSEC protocol testsuite.

Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
app/test/test_cryptodev.c
app/test/test_cryptodev_security_ipsec.c
app/test/test_cryptodev_security_ipsec.h

index 2adec1d524c976f81c7deaffd279bb2dfb7244b1..38648f4b92df9b1d5c254e5b7e56d85f5b37b339 100644 (file)
@@ -9332,6 +9332,11 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
                if (ret != TEST_SUCCESS)
                        goto crypto_op_free;
 
+               ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
+                                             flags, dir);
+               if (ret != TEST_SUCCESS)
+                       goto crypto_op_free;
+
                rte_crypto_op_free(ut_params->op);
                ut_params->op = NULL;
 
@@ -9652,6 +9657,18 @@ test_ipsec_proto_transport_v4(const void *data __rte_unused)
        return test_ipsec_proto_all(&flags);
 }
 
+static int
+test_ipsec_proto_stats(const void *data __rte_unused)
+{
+       struct ipsec_test_flags flags;
+
+       memset(&flags, 0, sizeof(flags));
+
+       flags.stats_success = true;
+
+       return test_ipsec_proto_all(&flags);
+}
+
 static int
 test_PDCP_PROTO_all(void)
 {
@@ -14656,6 +14673,10 @@ static struct unit_test_suite ipsec_proto_testsuite  = {
                        "Transport IPv4",
                        ut_setup_security, ut_teardown,
                        test_ipsec_proto_transport_v4),
+               TEST_CASE_NAMED_ST(
+                       "Statistics: success",
+                       ut_setup_security, ut_teardown,
+                       test_ipsec_proto_stats),
                TEST_CASES_END() /**< NULL terminate unit test array */
        }
 };
index 029fdd333a756c40dda42ab7e7eba8f48cc25584..6fa1d3d90a0648dfb01a68e2e1e3bdba41185640 100644 (file)
@@ -415,6 +415,8 @@ test_ipsec_td_prepare(const struct crypto_param *param1,
                                                RTE_SECURITY_IPSEC_TUNNEL_IPV4;
                }
 
+               if (flags->stats_success)
+                       td->ipsec_xform.options.stats = 1;
 
        }
 }
@@ -871,3 +873,30 @@ test_ipsec_status_check(struct rte_crypto_op *op,
 
        return ret;
 }
+
+int
+test_ipsec_stats_verify(struct rte_security_ctx *ctx,
+                       struct rte_security_session *sess,
+                       const struct ipsec_test_flags *flags,
+                       enum rte_security_ipsec_sa_direction dir)
+{
+       struct rte_security_stats stats = {0};
+       int ret = TEST_SUCCESS;
+
+       if (flags->stats_success) {
+               if (rte_security_session_stats_get(ctx, sess, &stats) < 0)
+                       return TEST_FAILED;
+
+               if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
+                       if (stats.ipsec.opackets != 1 ||
+                           stats.ipsec.oerrors != 0)
+                               ret = TEST_FAILED;
+               } else {
+                       if (stats.ipsec.ipackets != 1 ||
+                           stats.ipsec.ierrors != 0)
+                               ret = TEST_FAILED;
+               }
+       }
+
+       return ret;
+}
index 07d245306143a107749c79da90a8e64ddfeaf6d2..3565a8c5d2bafa169fdc42e474eff694af23b19a 100644 (file)
@@ -65,6 +65,7 @@ struct ipsec_test_flags {
        bool tunnel_ipv6;
        bool transport;
        bool fragment;
+       bool stats_success;
 };
 
 struct crypto_param {
@@ -188,4 +189,9 @@ int test_ipsec_status_check(struct rte_crypto_op *op,
                            enum rte_security_ipsec_sa_direction dir,
                            int pkt_num);
 
+int test_ipsec_stats_verify(struct rte_security_ctx *ctx,
+                           struct rte_security_session *sess,
+                           const struct ipsec_test_flags *flags,
+                           enum rte_security_ipsec_sa_direction dir);
+
 #endif