Add security stats test cases in IPSEC protocol testsuite.
Signed-off-by: Ankur Dwivedi <adwivedi@marvell.com>
Acked-by: Akhil Goyal <gakhil@marvell.com>
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;
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)
{
"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 */
}
};
RTE_SECURITY_IPSEC_TUNNEL_IPV4;
}
+ if (flags->stats_success)
+ td->ipsec_xform.options.stats = 1;
}
}
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;
+}
bool tunnel_ipv6;
bool transport;
bool fragment;
+ bool stats_success;
};
struct crypto_param {
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