From: Tejasree Kondoj <ktejasree@marvell.com>
To: Akhil Goyal <gakhil@marvell.com>,
Declan Doherty <declan.doherty@intel.com>,
Fan Zhang <roy.fan.zhang@intel.com>,
"Pablo de Lara" <pablo.de.lara.guarch@intel.com>
Cc: Anoob Joseph <anoobj@marvell.com>,
Ankur Dwivedi <adwivedi@marvell.com>,
Archana Muniganti <marchana@marvell.com>,
Tejasree Kondoj <ktejasree@marvell.com>,
Hemant Agrawal <hemant.agrawal@nxp.com>,
"Radu Nicolau" <radu.nicolau@intel.com>,
Ciara Power <ciara.power@intel.com>,
Gagandeep Singh <g.singh@nxp.com>, <dev@dpdk.org>
Subject: [PATCH v2 1/2] test/crypto: add copy and set DSCP cases
Date: Mon, 31 Jan 2022 22:13:56 +0530 [thread overview]
Message-ID: <20220131164357.19126-2-ktejasree@marvell.com> (raw)
In-Reply-To: <20220131164357.19126-1-ktejasree@marvell.com>
From: Anoob Joseph <anoobj@marvell.com>
Add test cases to verify copy and set DSCP with IPv4 and IPv6 tunnels.
Signed-off-by: Anoob Joseph <anoobj@marvell.com>
---
app/test/test_cryptodev.c | 166 +++++++++++++++++++++++
app/test/test_cryptodev_security_ipsec.c | 150 ++++++++++++++++----
app/test/test_cryptodev_security_ipsec.h | 10 ++
3 files changed, 301 insertions(+), 25 deletions(-)
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index ec4a61bdf9..47ad991c31 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -9176,7 +9176,21 @@ test_ipsec_proto_process(const struct ipsec_test_data td[],
if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
ipsec_xform.tunnel.ipv4.df = 1;
+ if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
+ ipsec_xform.tunnel.ipv4.dscp = 0;
+
+ if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
+ ipsec_xform.tunnel.ipv4.dscp =
+ TEST_IPSEC_DSCP_VAL;
+
} else {
+ if (flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
+ ipsec_xform.tunnel.ipv6.dscp = 0;
+
+ if (flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0)
+ ipsec_xform.tunnel.ipv6.dscp =
+ TEST_IPSEC_DSCP_VAL;
+
memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
sizeof(v6_src));
memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
@@ -9761,6 +9775,126 @@ test_ipsec_proto_set_df_1_inner_0(const void *data __rte_unused)
return test_ipsec_proto_all(&flags);
}
+static int
+test_ipsec_proto_ipv4_copy_dscp_inner_0(const void *data __rte_unused)
+{
+ struct ipsec_test_flags flags;
+
+ memset(&flags, 0, sizeof(flags));
+
+ flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
+
+ return test_ipsec_proto_all(&flags);
+}
+
+static int
+test_ipsec_proto_ipv4_copy_dscp_inner_1(const void *data __rte_unused)
+{
+ struct ipsec_test_flags flags;
+
+ memset(&flags, 0, sizeof(flags));
+
+ flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
+
+ return test_ipsec_proto_all(&flags);
+}
+
+static int
+test_ipsec_proto_ipv4_set_dscp_0_inner_1(const void *data __rte_unused)
+{
+ struct ipsec_test_flags flags;
+
+ if (gbl_driver_id == rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
+ return TEST_SKIPPED;
+
+ memset(&flags, 0, sizeof(flags));
+
+ flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
+
+ return test_ipsec_proto_all(&flags);
+}
+
+static int
+test_ipsec_proto_ipv4_set_dscp_1_inner_0(const void *data __rte_unused)
+{
+ struct ipsec_test_flags flags;
+
+ if (gbl_driver_id == rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
+ return TEST_SKIPPED;
+
+ memset(&flags, 0, sizeof(flags));
+
+ flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
+
+ return test_ipsec_proto_all(&flags);
+}
+
+static int
+test_ipsec_proto_ipv6_copy_dscp_inner_0(const void *data __rte_unused)
+{
+ struct ipsec_test_flags flags;
+
+ memset(&flags, 0, sizeof(flags));
+
+ flags.ipv6 = true;
+ flags.tunnel_ipv6 = true;
+ flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_0;
+
+ return test_ipsec_proto_all(&flags);
+}
+
+static int
+test_ipsec_proto_ipv6_copy_dscp_inner_1(const void *data __rte_unused)
+{
+ struct ipsec_test_flags flags;
+
+ memset(&flags, 0, sizeof(flags));
+
+ flags.ipv6 = true;
+ flags.tunnel_ipv6 = true;
+ flags.dscp = TEST_IPSEC_COPY_DSCP_INNER_1;
+
+ return test_ipsec_proto_all(&flags);
+}
+
+static int
+test_ipsec_proto_ipv6_set_dscp_0_inner_1(const void *data __rte_unused)
+{
+ struct ipsec_test_flags flags;
+
+ if (gbl_driver_id == rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
+ return TEST_SKIPPED;
+
+ memset(&flags, 0, sizeof(flags));
+
+ flags.ipv6 = true;
+ flags.tunnel_ipv6 = true;
+ flags.dscp = TEST_IPSEC_SET_DSCP_0_INNER_1;
+
+ return test_ipsec_proto_all(&flags);
+}
+
+static int
+test_ipsec_proto_ipv6_set_dscp_1_inner_0(const void *data __rte_unused)
+{
+ struct ipsec_test_flags flags;
+
+ if (gbl_driver_id == rte_cryptodev_driver_id_get(
+ RTE_STR(CRYPTODEV_NAME_CN9K_PMD)))
+ return TEST_SKIPPED;
+
+ memset(&flags, 0, sizeof(flags));
+
+ flags.ipv6 = true;
+ flags.tunnel_ipv6 = true;
+ flags.dscp = TEST_IPSEC_SET_DSCP_1_INNER_0;
+
+ return test_ipsec_proto_all(&flags);
+}
+
static int
test_PDCP_PROTO_all(void)
{
@@ -14799,6 +14933,38 @@ static struct unit_test_suite ipsec_proto_testsuite = {
"Tunnel header set DF 1 (inner 0)",
ut_setup_security, ut_teardown,
test_ipsec_proto_set_df_1_inner_0),
+ TEST_CASE_NAMED_ST(
+ "Tunnel header IPv4 copy DSCP (inner 0)",
+ ut_setup_security, ut_teardown,
+ test_ipsec_proto_ipv4_copy_dscp_inner_0),
+ TEST_CASE_NAMED_ST(
+ "Tunnel header IPv4 copy DSCP (inner 1)",
+ ut_setup_security, ut_teardown,
+ test_ipsec_proto_ipv4_copy_dscp_inner_1),
+ TEST_CASE_NAMED_ST(
+ "Tunnel header IPv4 set DSCP 0 (inner 1)",
+ ut_setup_security, ut_teardown,
+ test_ipsec_proto_ipv4_set_dscp_0_inner_1),
+ TEST_CASE_NAMED_ST(
+ "Tunnel header IPv4 set DSCP 1 (inner 0)",
+ ut_setup_security, ut_teardown,
+ test_ipsec_proto_ipv4_set_dscp_1_inner_0),
+ TEST_CASE_NAMED_ST(
+ "Tunnel header IPv6 copy DSCP (inner 0)",
+ ut_setup_security, ut_teardown,
+ test_ipsec_proto_ipv6_copy_dscp_inner_0),
+ TEST_CASE_NAMED_ST(
+ "Tunnel header IPv6 copy DSCP (inner 1)",
+ ut_setup_security, ut_teardown,
+ test_ipsec_proto_ipv6_copy_dscp_inner_1),
+ TEST_CASE_NAMED_ST(
+ "Tunnel header IPv6 set DSCP 0 (inner 1)",
+ ut_setup_security, ut_teardown,
+ test_ipsec_proto_ipv6_set_dscp_0_inner_1),
+ TEST_CASE_NAMED_ST(
+ "Tunnel header IPv6 set DSCP 1 (inner 0)",
+ ut_setup_security, ut_teardown,
+ test_ipsec_proto_ipv6_set_dscp_1_inner_0),
TEST_CASES_END() /**< NULL terminate unit test array */
}
};
diff --git a/app/test/test_cryptodev_security_ipsec.c b/app/test/test_cryptodev_security_ipsec.c
index e662ea279f..54f59c7f79 100644
--- a/app/test/test_cryptodev_security_ipsec.c
+++ b/app/test/test_cryptodev_security_ipsec.c
@@ -430,6 +430,10 @@ test_ipsec_td_prepare(const struct crypto_param *param1,
if (flags->df == TEST_IPSEC_COPY_DF_INNER_0 ||
flags->df == TEST_IPSEC_COPY_DF_INNER_1)
td->ipsec_xform.options.copy_df = 1;
+
+ if (flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_0 ||
+ flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1)
+ td->ipsec_xform.options.copy_dscp = 1;
}
}
@@ -769,6 +773,87 @@ test_ipsec_res_d_prepare(struct rte_mbuf *m, const struct ipsec_test_data *td,
return TEST_SUCCESS;
}
+static int
+test_ipsec_iph4_hdr_validate(const struct rte_ipv4_hdr *iph4,
+ const struct ipsec_test_flags *flags)
+{
+ uint8_t tos, dscp;
+ uint16_t f_off;
+
+ if (!is_valid_ipv4_pkt(iph4)) {
+ printf("Tunnel outer header is not IPv4\n");
+ return -1;
+ }
+
+ f_off = rte_be_to_cpu_16(iph4->fragment_offset);
+ if (flags->df == TEST_IPSEC_COPY_DF_INNER_1 ||
+ flags->df == TEST_IPSEC_SET_DF_1_INNER_0) {
+ if (!(f_off & RTE_IPV4_HDR_DF_FLAG)) {
+ printf("DF bit is not set\n");
+ return -1;
+ }
+ } else {
+ if (f_off & RTE_IPV4_HDR_DF_FLAG) {
+ printf("DF bit is set\n");
+ return -1;
+ }
+ }
+
+ tos = iph4->type_of_service;
+ dscp = (tos & RTE_IPV4_HDR_DSCP_MASK) >> 2;
+
+ if (flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1 ||
+ flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0) {
+ if (dscp != TEST_IPSEC_DSCP_VAL) {
+ printf("DSCP value is not matching [exp: %x, actual: %x]\n",
+ TEST_IPSEC_DSCP_VAL, dscp);
+ return -1;
+ }
+ } else {
+ if (dscp != 0) {
+ printf("DSCP value is set [exp: 0, actual: %x]\n",
+ dscp);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+static int
+test_ipsec_iph6_hdr_validate(const struct rte_ipv6_hdr *iph6,
+ const struct ipsec_test_flags *flags)
+{
+ uint32_t vtc_flow;
+ uint8_t dscp;
+
+ if (!is_valid_ipv6_pkt(iph6)) {
+ printf("Tunnel outer header is not IPv6\n");
+ return -1;
+ }
+
+ vtc_flow = rte_be_to_cpu_32(iph6->vtc_flow);
+ dscp = (vtc_flow & RTE_IPV6_HDR_DSCP_MASK) >>
+ (RTE_IPV6_HDR_TC_SHIFT + 2);
+
+ if (flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1 ||
+ flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0) {
+ if (dscp != TEST_IPSEC_DSCP_VAL) {
+ printf("DSCP value is not matching [exp: %x, actual: %x]\n",
+ TEST_IPSEC_DSCP_VAL, dscp);
+ return -1;
+ }
+ } else {
+ if (dscp != 0) {
+ printf("DSCP value is set [exp: 0, actual: %x]\n",
+ dscp);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
int
test_ipsec_post_process(struct rte_mbuf *m, const struct ipsec_test_data *td,
struct ipsec_test_data *res_d, bool silent,
@@ -806,33 +891,12 @@ test_ipsec_post_process(struct rte_mbuf *m, const struct ipsec_test_data *td,
} else {
if (td->ipsec_xform.tunnel.type ==
RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
- uint16_t f_off;
-
- if (is_valid_ipv4_pkt(iph4) == false) {
- printf("Tunnel outer header is not IPv4\n");
+ if (test_ipsec_iph4_hdr_validate(iph4, flags))
return TEST_FAILED;
- }
-
- f_off = rte_be_to_cpu_16(iph4->fragment_offset);
-
- if (flags->df == TEST_IPSEC_COPY_DF_INNER_1 ||
- flags->df == TEST_IPSEC_SET_DF_1_INNER_0) {
- if (!(f_off & RTE_IPV4_HDR_DF_FLAG)) {
- printf("DF bit is not set\n");
- return TEST_FAILED;
- }
- } else {
- if ((f_off & RTE_IPV4_HDR_DF_FLAG)) {
- printf("DF bit is set\n");
- return TEST_FAILED;
- }
- }
} else {
iph6 = (const struct rte_ipv6_hdr *)output_text;
- if (is_valid_ipv6_pkt(iph6) == false) {
- printf("Tunnel outer header is not IPv6\n");
+ if (test_ipsec_iph6_hdr_validate(iph6, flags))
return TEST_FAILED;
- }
}
}
}
@@ -940,8 +1004,8 @@ int
test_ipsec_pkt_update(uint8_t *pkt, const struct ipsec_test_flags *flags)
{
struct rte_ipv4_hdr *iph4;
+ struct rte_ipv6_hdr *iph6;
bool cksum_dirty = false;
- uint16_t frag_off;
iph4 = (struct rte_ipv4_hdr *)pkt;
@@ -949,9 +1013,10 @@ test_ipsec_pkt_update(uint8_t *pkt, const struct ipsec_test_flags *flags)
flags->df == TEST_IPSEC_SET_DF_0_INNER_1 ||
flags->df == TEST_IPSEC_COPY_DF_INNER_0 ||
flags->df == TEST_IPSEC_SET_DF_1_INNER_0) {
+ uint16_t frag_off;
if (!is_ipv4(iph4)) {
- printf("Invalid packet type");
+ printf("Invalid packet type\n");
return -1;
}
@@ -967,6 +1032,41 @@ test_ipsec_pkt_update(uint8_t *pkt, const struct ipsec_test_flags *flags)
cksum_dirty = true;
}
+ if (flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1 ||
+ flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1 ||
+ flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_0 ||
+ flags->dscp == TEST_IPSEC_SET_DSCP_1_INNER_0) {
+
+ if (is_ipv4(iph4)) {
+ uint8_t tos;
+
+ tos = iph4->type_of_service;
+ if (flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1 ||
+ flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
+ tos |= (RTE_IPV4_HDR_DSCP_MASK &
+ (TEST_IPSEC_DSCP_VAL << 2));
+ else
+ tos &= ~RTE_IPV4_HDR_DSCP_MASK;
+
+ iph4->type_of_service = tos;
+ cksum_dirty = true;
+ } else {
+ uint32_t vtc_flow;
+
+ iph6 = (struct rte_ipv6_hdr *)pkt;
+
+ vtc_flow = rte_be_to_cpu_32(iph6->vtc_flow);
+ if (flags->dscp == TEST_IPSEC_COPY_DSCP_INNER_1 ||
+ flags->dscp == TEST_IPSEC_SET_DSCP_0_INNER_1)
+ vtc_flow |= (RTE_IPV6_HDR_DSCP_MASK &
+ (TEST_IPSEC_DSCP_VAL << (RTE_IPV6_HDR_TC_SHIFT + 2)));
+ else
+ vtc_flow &= ~RTE_IPV6_HDR_DSCP_MASK;
+
+ iph6->vtc_flow = rte_cpu_to_be_32(vtc_flow);
+ }
+ }
+
if (cksum_dirty && is_ipv4(iph4)) {
iph4->hdr_checksum = 0;
iph4->hdr_checksum = rte_ipv4_cksum(iph4);
diff --git a/app/test/test_cryptodev_security_ipsec.h b/app/test/test_cryptodev_security_ipsec.h
index 12a9b77c55..c4ecfafca6 100644
--- a/app/test/test_cryptodev_security_ipsec.h
+++ b/app/test/test_cryptodev_security_ipsec.h
@@ -57,6 +57,15 @@ enum df_flags {
TEST_IPSEC_SET_DF_1_INNER_0,
};
+#define TEST_IPSEC_DSCP_VAL 0x12
+
+enum dscp_flags {
+ TEST_IPSEC_COPY_DSCP_INNER_0 = 1,
+ TEST_IPSEC_COPY_DSCP_INNER_1,
+ TEST_IPSEC_SET_DSCP_0_INNER_1,
+ TEST_IPSEC_SET_DSCP_1_INNER_0,
+};
+
struct ipsec_test_flags {
bool display_alg;
bool sa_expiry_pkts_soft;
@@ -74,6 +83,7 @@ struct ipsec_test_flags {
bool fragment;
bool stats_success;
enum df_flags df;
+ enum dscp_flags dscp;
};
struct crypto_param {
--
2.27.0
next prev parent reply other threads:[~2022-01-31 15:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-31 16:43 [PATCH v2 0/2] Adding new cases to lookaside IPsec tests Tejasree Kondoj
2022-01-31 16:43 ` Tejasree Kondoj [this message]
2022-02-17 18:07 ` [PATCH v2 1/2] test/crypto: add copy and set DSCP cases Akhil Goyal
2022-01-31 16:43 ` [PATCH v2 2/2] test/cryptodev: add ESN and Antireplay tests Tejasree Kondoj
2022-02-17 18:07 ` Akhil Goyal
2022-02-17 18:17 ` [PATCH v2 0/2] Adding new cases to lookaside IPsec tests Akhil Goyal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220131164357.19126-2-ktejasree@marvell.com \
--to=ktejasree@marvell.com \
--cc=adwivedi@marvell.com \
--cc=anoobj@marvell.com \
--cc=ciara.power@intel.com \
--cc=declan.doherty@intel.com \
--cc=dev@dpdk.org \
--cc=g.singh@nxp.com \
--cc=gakhil@marvell.com \
--cc=hemant.agrawal@nxp.com \
--cc=marchana@marvell.com \
--cc=pablo.de.lara.guarch@intel.com \
--cc=radu.nicolau@intel.com \
--cc=roy.fan.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).