From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B8F7D42943; Fri, 14 Apr 2023 19:47:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A58D142BC9; Fri, 14 Apr 2023 19:47:29 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 30CEE42BC9 for ; Fri, 14 Apr 2023 19:47:28 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33EGNfcF012935; Fri, 14 Apr 2023 10:47:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=uyGtb17UTcn2iyWc3cWuWLIzKXucVUVbmgTAQw6kJ3E=; b=d714kwHAH2KX2fBOn0/U0TH6SNmliIu0nbyO/+gyieHiqqNMcSB7MfXVUk5JSzaMRE8E MeJvpFeK2vDtR/I50NAceFAkWUURyzQkT/0lUfgzom0sUrSsMC9lgyj6eY5hXMBIA8oE imnNj7Y14YsLajwootm2n+8BsLsubD0cK1rdENVpo7mwSCHB1wPJPIdLJO+eOfeNrJ+M CO3hpvXyP6kz/RLGDDb6T4A72yhkUvGyR91UE9U/qfTVy9sIyaLqgBKFYXn5MqilVs9l i9JKDD5t063Y011JPe/r0UdsK1otGKmkiJbb/1PjjCmNPuu1t/QmJLxgUdIbSP3vVpgj Rw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3py646s6tk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 14 Apr 2023 10:47:27 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 14 Apr 2023 10:47:24 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Fri, 14 Apr 2023 10:47:24 -0700 Received: from BG-LT92004.corp.innovium.com (unknown [10.28.161.183]) by maili.marvell.com (Postfix) with ESMTP id EF3A03F7083; Fri, 14 Apr 2023 10:47:19 -0700 (PDT) From: Anoob Joseph To: Thomas Monjalon , Akhil Goyal , Jerin Jacob , Konstantin Ananyev , Bernard Iremonger CC: Volodymyr Fialko , Hemant Agrawal , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Kiran Kumar K , , Olivier Matz Subject: [PATCH v2 14/22] test/pdcp: add in-order delivery cases Date: Fri, 14 Apr 2023 23:15:04 +0530 Message-ID: <20230414174512.642-15-anoobj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230414174512.642-1-anoobj@marvell.com> References: <20221222092522.1628-1-anoobj@marvell.com> <20230414174512.642-1-anoobj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: vAhVzrEFSEZPJtcoPM5dZnmH4TEbymYA X-Proofpoint-ORIG-GUID: vAhVzrEFSEZPJtcoPM5dZnmH4TEbymYA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-14_10,2023-04-14_01,2023-02-09_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Volodymyr Fialko Add test cases to verify behaviour when in-order delivery is enabled and packets arrive in out-of-order. PDCP library is expected to buffer the packets and return packets in-order when the missing packet arrives. Signed-off-by: Anoob Joseph Signed-off-by: Volodymyr Fialko --- app/test/test_pdcp.c | 195 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) diff --git a/app/test/test_pdcp.c b/app/test/test_pdcp.c index 4ecb4d9572..c96ddc4f53 100644 --- a/app/test/test_pdcp.c +++ b/app/test/test_pdcp.c @@ -15,6 +15,15 @@ #define CDEV_INVALID_ID UINT8_MAX #define NB_TESTS RTE_DIM(pdcp_test_params) +/* Assert that condition is true, or goto the mark */ +#define ASSERT_TRUE_OR_GOTO(cond, mark, ...) do {\ + if (!(cond)) { \ + RTE_LOG(ERR, USER1, "Error at: %s:%d\n", __func__, __LINE__); \ + RTE_LOG(ERR, USER1, __VA_ARGS__); \ + goto mark; \ + } \ +} while (0) + /* According to formula(7.2.a Window_Size) */ #define PDCP_WINDOW_SIZE(sn_size) (1 << (sn_size - 1)) @@ -82,6 +91,14 @@ run_test_with_all_known_vec(const void *args) return run_test_foreach_known_vec(test, false); } +static int +run_test_with_all_known_vec_until_first_pass(const void *args) +{ + test_with_conf_t test = args; + + return run_test_foreach_known_vec(test, true); +} + static inline int pdcp_hdr_size_get(enum rte_security_pdcp_sn_size sn_size) { @@ -868,6 +885,7 @@ test_sn_range_type(enum sn_range_type type, struct pdcp_test_conf *conf) /* Configure Uplink to generate expected, encrypted packet */ pdcp_sn_to_raw_set(conf->input, new_sn, conf->entity.pdcp_xfrm.sn_size); + conf->entity.out_of_order_delivery = true; conf->entity.reverse_iv_direction = true; conf->entity.count = PDCP_SET_COUNT(new_hfn, new_sn, sn_size); conf->output_len = 0; @@ -913,6 +931,168 @@ test_sn_minus_outside(struct pdcp_test_conf *t_conf) return test_sn_range_type(SN_RANGE_MINUS_OUTSIDE, t_conf); } +static struct rte_mbuf * +generate_packet_for_dl_with_sn(struct pdcp_test_conf ul_conf, uint32_t sn) +{ + int ret; + + ul_conf.entity.count = sn; + ul_conf.entity.out_of_order_delivery = true; + ul_conf.entity.reverse_iv_direction = true; + ul_conf.output_len = 0; + + ret = test_attempt_single(&ul_conf); + if (ret != TEST_SUCCESS) + return NULL; + + return mbuf_from_data_create(ul_conf.output, ul_conf.output_len); +} + +static bool +array_asc_sorted_check(struct rte_mbuf *m[], uint32_t len, enum rte_security_pdcp_sn_size sn_size) +{ + uint32_t i; + + if (len < 2) + return true; + + for (i = 0; i < (len - 1); i++) { + if (pdcp_sn_from_raw_get(rte_pktmbuf_mtod(m[i], void *), sn_size) > + pdcp_sn_from_raw_get(rte_pktmbuf_mtod(m[i + 1], void *), sn_size)) + return false; + } + + return true; +} + +static int +test_reorder_gap_fill(struct pdcp_test_conf *ul_conf) +{ + struct rte_mbuf *m0 = NULL, *m1 = NULL, *out_mb[2] = {0}; + uint16_t nb_success = 0, nb_err = 0; + struct rte_pdcp_entity *pdcp_entity; + struct pdcp_test_conf dl_conf; + int ret = TEST_FAILED, nb_out; + uint8_t cdev_id; + + const int start_count = 0; + + if (ul_conf->entity.pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_DOWNLINK) + return TEST_SKIPPED; + + /* Create configuration for actual testing */ + uplink_to_downlink_convert(ul_conf, &dl_conf); + dl_conf.entity.count = start_count; + + pdcp_entity = test_entity_create(&dl_conf, &ret); + if (pdcp_entity == NULL) + return ret; + + const uint32_t sn_size = dl_conf.entity.pdcp_xfrm.sn_size; + cdev_id = dl_conf.entity.dev_id; + + /* Send packet with SN > RX_DELIV to create a gap */ + m1 = generate_packet_for_dl_with_sn(*ul_conf, start_count + 1); + ASSERT_TRUE_OR_GOTO(m1 != NULL, exit, "Could not allocate buffer for packet\n"); + + /* Buffered packets after insert [NULL, m1] */ + nb_success = test_process_packets(pdcp_entity, cdev_id, &m1, 1, out_mb, &nb_err); + ASSERT_TRUE_OR_GOTO(nb_err == 0, exit, "Error occurred during packet process\n"); + ASSERT_TRUE_OR_GOTO(nb_success == 0, exit, "Packet was not buffered as expected\n"); + m1 = NULL; /* Packet was moved to PDCP lib */ + + /* Generate packet to fill the existing gap */ + m0 = generate_packet_for_dl_with_sn(*ul_conf, start_count); + ASSERT_TRUE_OR_GOTO(m0 != NULL, exit, "Could not allocate buffer for packet\n"); + + /* + * Buffered packets after insert [m0, m1] + * Gap filled, all packets should be returned + */ + nb_success = test_process_packets(pdcp_entity, cdev_id, &m0, 1, out_mb, &nb_err); + ASSERT_TRUE_OR_GOTO(nb_err == 0, exit, "Error occurred during packet process\n"); + ASSERT_TRUE_OR_GOTO(nb_success == 2, exit, + "Packet count mismatch (received: %i, expected: 2)\n", nb_success); + m0 = NULL; /* Packet was moved to out_mb */ + + /* Check that packets in correct order */ + ASSERT_TRUE_OR_GOTO(array_asc_sorted_check(out_mb, nb_success, sn_size), exit, + "Error occurred during packet drain\n"); + + ret = TEST_SUCCESS; +exit: + rte_pktmbuf_free(m0); + rte_pktmbuf_free(m1); + rte_pktmbuf_free_bulk(out_mb, nb_success); + nb_out = rte_pdcp_entity_release(pdcp_entity, out_mb); + rte_pktmbuf_free_bulk(out_mb, nb_out); + return ret; +} + +static int +test_reorder_buffer_full_window_size_sn_12(const struct pdcp_test_conf *ul_conf) +{ + struct rte_mbuf *m1 = NULL, **out_mb = NULL; + uint16_t nb_success = 0, nb_err = 0; + struct rte_pdcp_entity *pdcp_entity; + struct pdcp_test_conf dl_conf; + const int rx_deliv = 0; + int ret = TEST_FAILED; + size_t i, nb_out; + uint8_t cdev_id; + + const uint32_t sn_size = ul_conf->entity.pdcp_xfrm.sn_size; + const uint32_t window_size = PDCP_WINDOW_SIZE(sn_size); + + if (ul_conf->entity.pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_DOWNLINK || + sn_size != RTE_SECURITY_PDCP_SN_SIZE_12) + return TEST_SKIPPED; + + /* Create configuration for actual testing */ + uplink_to_downlink_convert(ul_conf, &dl_conf); + dl_conf.entity.count = rx_deliv; + + pdcp_entity = test_entity_create(&dl_conf, &ret); + if (pdcp_entity == NULL) + return ret; + + ASSERT_TRUE_OR_GOTO(pdcp_entity->max_pkt_cache >= window_size, exit, + "PDCP max packet cache is too small"); + cdev_id = dl_conf.entity.dev_id; + out_mb = rte_zmalloc(NULL, pdcp_entity->max_pkt_cache * sizeof(uintptr_t), 0); + ASSERT_TRUE_OR_GOTO(out_mb != NULL, exit, + "Could not allocate buffer for holding out_mb buffers\n"); + + /* Send packets with SN > RX_DELIV to create a gap */ + for (i = rx_deliv + 1; i < window_size; i++) { + m1 = generate_packet_for_dl_with_sn(*ul_conf, i); + ASSERT_TRUE_OR_GOTO(m1 != NULL, exit, "Could not allocate buffer for packet\n"); + /* Buffered packets after insert [NULL, m1] */ + nb_success = test_process_packets(pdcp_entity, cdev_id, &m1, 1, out_mb, &nb_err); + ASSERT_TRUE_OR_GOTO(nb_err == 0, exit, "Error occurred during packet buffering\n"); + ASSERT_TRUE_OR_GOTO(nb_success == 0, exit, "Packet was not buffered as expected\n"); + } + + m1 = generate_packet_for_dl_with_sn(*ul_conf, rx_deliv); + ASSERT_TRUE_OR_GOTO(m1 != NULL, exit, "Could not allocate buffer for packet\n"); + /* Insert missing packet */ + nb_success = test_process_packets(pdcp_entity, cdev_id, &m1, 1, out_mb, &nb_err); + ASSERT_TRUE_OR_GOTO(nb_err == 0, exit, "Error occurred during packet buffering\n"); + ASSERT_TRUE_OR_GOTO(nb_success == window_size, exit, + "Packet count mismatch (received: %i, expected: %i)\n", + nb_success, window_size); + m1 = NULL; + + ret = TEST_SUCCESS; +exit: + rte_pktmbuf_free(m1); + rte_pktmbuf_free_bulk(out_mb, nb_success); + nb_out = rte_pdcp_entity_release(pdcp_entity, out_mb); + rte_pktmbuf_free_bulk(out_mb, nb_out); + rte_free(out_mb); + return ret; +} + static int test_combined(struct pdcp_test_conf *ul_conf) { @@ -969,10 +1149,25 @@ static struct unit_test_suite hfn_sn_test_cases = { } }; +static struct unit_test_suite reorder_test_cases = { + .suite_name = "PDCP reorder", + .unit_test_cases = { + TEST_CASE_NAMED_WITH_DATA("test_reorder_gap_fill", + ut_setup_pdcp, ut_teardown_pdcp, + run_test_with_all_known_vec, test_reorder_gap_fill), + TEST_CASE_NAMED_WITH_DATA("test_reorder_buffer_full_window_size_sn_12", + ut_setup_pdcp, ut_teardown_pdcp, + run_test_with_all_known_vec_until_first_pass, + test_reorder_buffer_full_window_size_sn_12), + TEST_CASES_END() /**< NULL terminate unit test array */ + } +}; + struct unit_test_suite *test_suites[] = { NULL, /* Place holder for known_vector_cases */ &combined_mode_cases, &hfn_sn_test_cases, + &reorder_test_cases, NULL /* End of suites list */ }; -- 2.25.1