get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/127715/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 127715,
    "url": "http://patchwork.dpdk.org/api/patches/127715/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230530100158.1428-14-anoobj@marvell.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20230530100158.1428-14-anoobj@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230530100158.1428-14-anoobj@marvell.com",
    "date": "2023-05-30T10:01:50",
    "name": "[v6,13/21] pdcp: implement t-Reordering and packet buffering",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "197fce62c711ccff15b901e89a00b45e2d0108e2",
    "submitter": {
        "id": 1205,
        "url": "http://patchwork.dpdk.org/api/people/1205/?format=api",
        "name": "Anoob Joseph",
        "email": "anoobj@marvell.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patchwork.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20230530100158.1428-14-anoobj@marvell.com/mbox/",
    "series": [
        {
            "id": 28249,
            "url": "http://patchwork.dpdk.org/api/series/28249/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=28249",
            "date": "2023-05-30T10:01:37",
            "name": "lib: add pdcp protocol",
            "version": 6,
            "mbox": "http://patchwork.dpdk.org/series/28249/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/127715/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/127715/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 73AAE42BE2;\n\tTue, 30 May 2023 12:03:42 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id A67BF4282D;\n\tTue, 30 May 2023 12:03:03 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174])\n by mails.dpdk.org (Postfix) with ESMTP id D63E842D20\n for <dev@dpdk.org>; Tue, 30 May 2023 12:03:01 +0200 (CEST)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id\n 34U7dahp000485; Tue, 30 May 2023 03:03:00 -0700",
            "from dc5-exch02.marvell.com ([199.233.59.182])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3quf7phhht-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Tue, 30 May 2023 03:03:00 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Tue, 30 May 2023 03:02:58 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend\n Transport; Tue, 30 May 2023 03:02:58 -0700",
            "from BG-LT92004.corp.innovium.com (unknown [10.193.69.246])\n by maili.marvell.com (Postfix) with ESMTP id B01203F7050;\n Tue, 30 May 2023 03:02:54 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0220;\n bh=Xsnfp+L5F7JyxOrdNCJ9SDpey/A7uDhBOk93NpZjdHI=;\n b=euM8rsOs3dqvrO0RKKhQd8h2+I9L3Zf2eroaAXMeL+C05zbJLj+9Nj/7Zwhg1KkmDNji\n IRJivBoyE6+9EmrbNReDkazfs1/aO+O5gjpYF0MtYiVQZiepPsitD4wVb0QqTQPXRTSA\n pAJHojG4sY/uAXSixwybEfouoCzrhHonH60C1FrpdqFDSlbo+2q2oM0NTIfDpIz3t+KU\n WPLvb+lXYUOieu9PUgAVa5VFP2+2SLNb8nA22inkz0nPz2pHFXoM+VNOhxpvv2iu2AvY\n SorOrIiypf3Qu7zD36yjQCm7tUoYQHzkPAml4GX9sAGS7XnHBBWmSv+VjzOxNZmu4euP iQ==",
        "From": "Anoob Joseph <anoobj@marvell.com>",
        "To": "Thomas Monjalon <thomas@monjalon.net>, Akhil Goyal <gakhil@marvell.com>,\n Jerin Jacob <jerinj@marvell.com>, Konstantin Ananyev\n <konstantin.v.ananyev@yandex.ru>",
        "CC": "Volodymyr Fialko <vfialko@marvell.com>,\n Hemant Agrawal <hemant.agrawal@nxp.com>,\n =?utf-8?q?Mattias_R=C3=B6nnblom?= <mattias.ronnblom@ericsson.com>,\n Kiran Kumar K <kirankumark@marvell.com>, <dev@dpdk.org>,\n Olivier Matz <olivier.matz@6wind.com>,\n Stephen Hemminger <stephen@networkplumber.org>",
        "Subject": "[PATCH v6 13/21] pdcp: implement t-Reordering and packet buffering",
        "Date": "Tue, 30 May 2023 15:31:50 +0530",
        "Message-ID": "<20230530100158.1428-14-anoobj@marvell.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20230530100158.1428-1-anoobj@marvell.com>",
        "References": "<20230527085910.972-1-anoobj@marvell.com>\n <20230530100158.1428-1-anoobj@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "FJGGRbvmiaq2g0krf-wWzGj6N9YIDqqh",
        "X-Proofpoint-ORIG-GUID": "FJGGRbvmiaq2g0krf-wWzGj6N9YIDqqh",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26\n definitions=2023-05-30_06,2023-05-29_02,2023-05-22_02",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "From: Volodymyr Fialko <vfialko@marvell.com>\n\nAdd in-order delivery of packets in PDCP. Delivery of packets in-order\nrelies on t-Reordering timer.\n\nWhen 'out-of-order delivery' is disabled, PDCP will buffer all received\npackets that are out of order. The t-Reordering timer determines the\ntime period these packets would be held in the buffer, waiting for any\nmissing packets to arrive.\n\nIntroduce packet buffering and state variables which indicate status of\nthe timer.\n\nSigned-off-by: Anoob Joseph <anoobj@marvell.com>\nSigned-off-by: Volodymyr Fialko <vfialko@marvell.com>\n---\n lib/pdcp/meson.build    |   3 +-\n lib/pdcp/pdcp_entity.h  |  19 +++++++\n lib/pdcp/pdcp_process.c | 117 ++++++++++++++++++++++++++++++----------\n lib/pdcp/pdcp_reorder.c |  27 ++++++++++\n lib/pdcp/pdcp_reorder.h |  62 +++++++++++++++++++++\n lib/pdcp/rte_pdcp.c     |  53 ++++++++++++++++--\n lib/pdcp/rte_pdcp.h     |   6 ++-\n 7 files changed, 252 insertions(+), 35 deletions(-)\n create mode 100644 lib/pdcp/pdcp_reorder.c\n create mode 100644 lib/pdcp/pdcp_reorder.h",
    "diff": "diff --git a/lib/pdcp/meson.build b/lib/pdcp/meson.build\nindex 75d476bf6d..f4f9246bcb 100644\n--- a/lib/pdcp/meson.build\n+++ b/lib/pdcp/meson.build\n@@ -12,9 +12,10 @@ sources = files(\n         'pdcp_crypto.c',\n         'pdcp_ctrl_pdu.c',\n         'pdcp_process.c',\n+        'pdcp_reorder.c',\n         'rte_pdcp.c',\n         )\n headers = files('rte_pdcp.h')\n indirect_headers += files('rte_pdcp_group.h')\n \n-deps += ['mbuf', 'net', 'cryptodev', 'security']\n+deps += ['mbuf', 'net', 'cryptodev', 'security', 'reorder']\ndiff --git a/lib/pdcp/pdcp_entity.h b/lib/pdcp/pdcp_entity.h\nindex 28691a504b..34341cdc11 100644\n--- a/lib/pdcp/pdcp_entity.h\n+++ b/lib/pdcp/pdcp_entity.h\n@@ -11,6 +11,8 @@\n #include <rte_pdcp.h>\n #include <rte_security.h>\n \n+#include \"pdcp_reorder.h\"\n+\n struct entity_priv;\n \n #define PDCP_HFN_MIN 0\n@@ -109,6 +111,17 @@ union cipher_iv_partial {\n \tuint64_t u64[2];\n };\n \n+enum timer_state {\n+\tTIMER_STOP,\n+\tTIMER_RUNNING,\n+\tTIMER_EXPIRED,\n+};\n+\n+struct pdcp_t_reordering {\n+\t/** Represent timer state */\n+\tenum timer_state state;\n+};\n+\n struct pdcp_cnt_bitmap {\n \t/** Number of entries that can be stored. */\n \tuint32_t size;\n@@ -145,6 +158,8 @@ struct entity_priv {\n \t\tuint64_t is_null_auth : 1;\n \t\t/** Is status report required.*/\n \t\tuint64_t is_status_report_required : 1;\n+\t\t/** Is out-of-order delivery enabled */\n+\t\tuint64_t is_out_of_order_delivery : 1;\n \t} flags;\n \t/** Crypto op pool. */\n \tstruct rte_mempool *cop_pool;\n@@ -161,6 +176,10 @@ struct entity_priv {\n struct entity_priv_dl_part {\n \t/** PDCP would need to track the count values that are already received.*/\n \tstruct pdcp_cnt_bitmap bitmap;\n+\t/** t-Reordering handles */\n+\tstruct pdcp_t_reordering t_reorder;\n+\t/** Reorder packet buffer */\n+\tstruct pdcp_reorder reorder;\n };\n \n struct entity_priv_ul_part {\ndiff --git a/lib/pdcp/pdcp_process.c b/lib/pdcp/pdcp_process.c\nindex ed1413db6d..84a0f3a43f 100644\n--- a/lib/pdcp/pdcp_process.c\n+++ b/lib/pdcp/pdcp_process.c\n@@ -837,25 +837,88 @@ pdcp_packet_strip(struct rte_mbuf *mb, const uint32_t hdr_trim_sz, const bool tr\n \t}\n }\n \n-static inline bool\n+static inline int\n pdcp_post_process_update_entity_state(const struct rte_pdcp_entity *entity,\n-\t\t\t\t      const uint32_t count)\n+\t\t\t\t      const uint32_t count, struct rte_mbuf *mb,\n+\t\t\t\t      struct rte_mbuf *out_mb[],\n+\t\t\t\t      const bool trim_mac)\n {\n \tstruct entity_priv *en_priv = entity_priv_get(entity);\n+\tstruct pdcp_t_reordering *t_reorder;\n+\tstruct pdcp_reorder *reorder;\n+\tuint16_t processed = 0;\n \n-\tif (count < en_priv->state.rx_deliv)\n-\t\treturn false;\n+\tstruct entity_priv_dl_part *dl = entity_dl_part_get(entity);\n+\tconst uint32_t hdr_trim_sz = en_priv->hdr_sz + en_priv->aad_sz;\n \n-\t/* t-Reordering timer is not supported - SDU will be delivered immediately.\n-\t * Update RX_DELIV to the COUNT value of the first PDCP SDU which has not\n-\t * been delivered to upper layers\n-\t */\n-\ten_priv->state.rx_next = count + 1;\n+\tif (count < en_priv->state.rx_deliv)\n+\t\treturn -EINVAL;\n \n \tif (count >= en_priv->state.rx_next)\n \t\ten_priv->state.rx_next = count + 1;\n \n-\treturn true;\n+\tpdcp_packet_strip(mb, hdr_trim_sz, trim_mac);\n+\n+\tif (en_priv->flags.is_out_of_order_delivery) {\n+\t\tout_mb[0] = mb;\n+\t\ten_priv->state.rx_deliv = count + 1;\n+\n+\t\treturn 1;\n+\t}\n+\n+\treorder = &dl->reorder;\n+\tt_reorder = &dl->t_reorder;\n+\n+\tif (count == en_priv->state.rx_deliv) {\n+\t\tif (reorder->is_active) {\n+\t\t\t/*\n+\t\t\t * This insert used only to increment reorder->min_seqn\n+\t\t\t * To remove it - min_seqn_set() has to work with non-empty buffer\n+\t\t\t */\n+\t\t\tpdcp_reorder_insert(reorder, mb, count);\n+\n+\t\t\t/* Get buffered packets */\n+\t\t\tstruct rte_mbuf **cached_mbufs = &out_mb[processed];\n+\t\t\tuint32_t nb_cached = pdcp_reorder_get_sequential(reorder,\n+\t\t\t\t\tcached_mbufs, entity->max_pkt_cache - processed);\n+\n+\t\t\tprocessed += nb_cached;\n+\t\t} else {\n+\t\t\tout_mb[processed++] = mb;\n+\t\t}\n+\n+\t\t/* Processed should never exceed the window size */\n+\t\ten_priv->state.rx_deliv = count + processed;\n+\n+\t} else {\n+\t\tif (!reorder->is_active)\n+\t\t\t/* Initialize reordering buffer with RX_DELIV */\n+\t\t\tpdcp_reorder_start(reorder, en_priv->state.rx_deliv);\n+\t\t/* Buffer the packet */\n+\t\tpdcp_reorder_insert(reorder, mb, count);\n+\t}\n+\n+\t/* Stop & reset current timer if rx_reord is received */\n+\tif (t_reorder->state == TIMER_RUNNING &&\n+\t\t\ten_priv->state.rx_deliv >= en_priv->state.rx_reord) {\n+\t\tt_reorder->state = TIMER_STOP;\n+\t\t/* Stop reorder buffer, only if it's empty */\n+\t\tif (en_priv->state.rx_deliv == en_priv->state.rx_next)\n+\t\t\tpdcp_reorder_stop(reorder);\n+\t}\n+\n+\t/*\n+\t * If t-Reordering is not running (includes the case when t-Reordering is stopped due to\n+\t * actions above).\n+\t */\n+\tif (t_reorder->state == TIMER_STOP && en_priv->state.rx_deliv < en_priv->state.rx_next) {\n+\t\t/* Update RX_REORD to RX_NEXT */\n+\t\ten_priv->state.rx_reord = en_priv->state.rx_next;\n+\t\t/* Start t-Reordering */\n+\t\tt_reorder->state = TIMER_RUNNING;\n+\t}\n+\n+\treturn processed;\n }\n \n static inline uint16_t\n@@ -863,16 +926,12 @@ pdcp_post_process_uplane_dl_flags(const struct rte_pdcp_entity *entity, struct r\n \t\t\t\t  struct rte_mbuf *out_mb[], uint16_t num, uint16_t *nb_err_ret,\n \t\t\t\t  const bool is_integ_protected)\n {\n-\tstruct entity_priv *en_priv = entity_priv_get(entity);\n-\tconst uint32_t aad_sz = en_priv->aad_sz;\n-\tint i, nb_success = 0, nb_err = 0;\n+\tint i, nb_processed, nb_success = 0, nb_err = 0;\n \trte_pdcp_dynfield_t *mb_dynfield;\n \tstruct rte_mbuf *err_mb[num];\n \tstruct rte_mbuf *mb;\n \tuint32_t count;\n \n-\tconst uint32_t hdr_trim_sz = en_priv->hdr_sz + aad_sz;\n-\n \tfor (i = 0; i < num; i++) {\n \t\tmb = in_mb[i];\n \t\tif (unlikely(mb->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED))\n@@ -881,11 +940,12 @@ pdcp_post_process_uplane_dl_flags(const struct rte_pdcp_entity *entity, struct r\n \t\tmb_dynfield = pdcp_dynfield(mb);\n \t\tcount = *mb_dynfield;\n \n-\t\tif (unlikely(!pdcp_post_process_update_entity_state(entity, count)))\n+\t\tnb_processed = pdcp_post_process_update_entity_state(\n+\t\t\t\tentity, count, mb, &out_mb[nb_success], is_integ_protected);\n+\t\tif (nb_processed < 0)\n \t\t\tgoto error;\n \n-\t\tpdcp_packet_strip(mb, hdr_trim_sz, is_integ_protected);\n-\t\tout_mb[nb_success++] = mb;\n+\t\tnb_success += nb_processed;\n \t\tcontinue;\n \n error:\n@@ -919,16 +979,12 @@ pdcp_post_process_cplane_sn_12_dl(const struct rte_pdcp_entity *entity,\n \t\t\t\t  struct rte_mbuf *out_mb[],\n \t\t\t\t  uint16_t num, uint16_t *nb_err_ret)\n {\n-\tstruct entity_priv *en_priv = entity_priv_get(entity);\n-\tconst uint32_t aad_sz = en_priv->aad_sz;\n-\tint i, nb_success = 0, nb_err = 0;\n+\tint i, nb_processed, nb_success = 0, nb_err = 0;\n \trte_pdcp_dynfield_t *mb_dynfield;\n \tstruct rte_mbuf *err_mb[num];\n \tstruct rte_mbuf *mb;\n \tuint32_t count;\n \n-\tconst uint32_t hdr_trim_sz = en_priv->hdr_sz + aad_sz;\n-\n \tfor (i = 0; i < num; i++) {\n \t\tmb = in_mb[i];\n \t\tif (unlikely(mb->ol_flags & RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED))\n@@ -937,12 +993,12 @@ pdcp_post_process_cplane_sn_12_dl(const struct rte_pdcp_entity *entity,\n \t\tmb_dynfield = pdcp_dynfield(mb);\n \t\tcount = *mb_dynfield;\n \n-\t\tif (unlikely(!pdcp_post_process_update_entity_state(entity, count)))\n+\t\tnb_processed = pdcp_post_process_update_entity_state(\n+\t\t\t\tentity, count, mb, &out_mb[nb_success], true);\n+\t\tif (nb_processed < 0)\n \t\t\tgoto error;\n \n-\t\tpdcp_packet_strip(mb, hdr_trim_sz, true);\n-\n-\t\tout_mb[nb_success++] = mb;\n+\t\tnb_success += nb_processed;\n \t\tcontinue;\n \n error:\n@@ -1105,6 +1161,13 @@ pdcp_entity_priv_populate(struct entity_priv *en_priv, const struct rte_pdcp_ent\n \t\ten_priv->flags.is_status_report_required = 1;\n \t}\n \n+\t/**\n+\t * flags.is_out_of_order_delivery\n+\t *\n+\t * Indicate whether the outoforder delivery is enabled for PDCP entity.\n+\t */\n+\ten_priv->flags.is_out_of_order_delivery = conf->out_of_order_delivery;\n+\n \t/**\n \t * hdr_sz\n \t *\ndiff --git a/lib/pdcp/pdcp_reorder.c b/lib/pdcp/pdcp_reorder.c\nnew file mode 100644\nindex 0000000000..5399f0dc28\n--- /dev/null\n+++ b/lib/pdcp/pdcp_reorder.c\n@@ -0,0 +1,27 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#include <rte_errno.h>\n+#include <rte_reorder.h>\n+\n+#include \"pdcp_reorder.h\"\n+\n+int\n+pdcp_reorder_create(struct pdcp_reorder *reorder, uint32_t window_size)\n+{\n+\treorder->buf = rte_reorder_create(\"reorder_buffer\", SOCKET_ID_ANY, window_size);\n+\tif (reorder->buf == NULL)\n+\t\treturn -rte_errno;\n+\n+\treorder->window_size = window_size;\n+\treorder->is_active = false;\n+\n+\treturn 0;\n+}\n+\n+void\n+pdcp_reorder_destroy(const struct pdcp_reorder *reorder)\n+{\n+\trte_reorder_free(reorder->buf);\n+}\ndiff --git a/lib/pdcp/pdcp_reorder.h b/lib/pdcp/pdcp_reorder.h\nnew file mode 100644\nindex 0000000000..6a2f61d6ae\n--- /dev/null\n+++ b/lib/pdcp/pdcp_reorder.h\n@@ -0,0 +1,62 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2023 Marvell.\n+ */\n+\n+#ifndef PDCP_REORDER_H\n+#define PDCP_REORDER_H\n+\n+#include <rte_reorder.h>\n+\n+struct pdcp_reorder {\n+\tstruct rte_reorder_buffer *buf;\n+\tuint32_t window_size;\n+\tbool is_active;\n+};\n+\n+int pdcp_reorder_create(struct pdcp_reorder *reorder, uint32_t window_size);\n+void pdcp_reorder_destroy(const struct pdcp_reorder *reorder);\n+\n+static inline uint32_t\n+pdcp_reorder_get_sequential(struct pdcp_reorder *reorder, struct rte_mbuf **mbufs,\n+\t\tuint32_t max_mbufs)\n+{\n+\treturn rte_reorder_drain(reorder->buf, mbufs, max_mbufs);\n+}\n+\n+static inline uint32_t\n+pdcp_reorder_up_to_get(struct pdcp_reorder *reorder, struct rte_mbuf **mbufs,\n+\t\t       uint32_t max_mbufs, uint32_t seqn)\n+{\n+\treturn rte_reorder_drain_up_to_seqn(reorder->buf, mbufs, max_mbufs, seqn);\n+}\n+\n+static inline void\n+pdcp_reorder_start(struct pdcp_reorder *reorder, uint32_t min_seqn)\n+{\n+\tint ret;\n+\n+\treorder->is_active = true;\n+\n+\tret = rte_reorder_min_seqn_set(reorder->buf, min_seqn);\n+\tRTE_VERIFY(ret == 0);\n+}\n+\n+static inline void\n+pdcp_reorder_stop(struct pdcp_reorder *reorder)\n+{\n+\treorder->is_active = false;\n+}\n+\n+static inline void\n+pdcp_reorder_insert(struct pdcp_reorder *reorder, struct rte_mbuf *mbuf,\n+\t\t    rte_reorder_seqn_t pkt_count)\n+{\n+\tint ret;\n+\n+\t*rte_reorder_seqn(mbuf) = pkt_count;\n+\n+\tret = rte_reorder_insert(reorder->buf, mbuf);\n+\tRTE_VERIFY(ret == 0);\n+}\n+\n+#endif /* PDCP_REORDER_H */\ndiff --git a/lib/pdcp/rte_pdcp.c b/lib/pdcp/rte_pdcp.c\nindex 96ad397667..be37ff392c 100644\n--- a/lib/pdcp/rte_pdcp.c\n+++ b/lib/pdcp/rte_pdcp.c\n@@ -49,6 +49,17 @@ pdcp_entity_size_get(const struct rte_pdcp_entity_conf *conf)\n \treturn RTE_ALIGN_CEIL(size, RTE_CACHE_LINE_SIZE);\n }\n \n+static int\n+pdcp_dl_establish(struct rte_pdcp_entity *entity, const struct rte_pdcp_entity_conf *conf)\n+{\n+\tconst uint32_t window_size = pdcp_window_size_get(conf->pdcp_xfrm.sn_size);\n+\tstruct entity_priv_dl_part *dl = entity_dl_part_get(entity);\n+\n+\tentity->max_pkt_cache = RTE_MAX(entity->max_pkt_cache, window_size);\n+\n+\treturn pdcp_reorder_create(&dl->reorder, window_size);\n+}\n+\n struct rte_pdcp_entity *\n rte_pdcp_entity_establish(const struct rte_pdcp_entity_conf *conf)\n {\n@@ -118,6 +129,12 @@ rte_pdcp_entity_establish(const struct rte_pdcp_entity_conf *conf)\n \tif (ret)\n \t\tgoto crypto_sess_destroy;\n \n+\tif (conf->pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_DOWNLINK) {\n+\t\tret = pdcp_dl_establish(entity, conf);\n+\t\tif (ret)\n+\t\t\tgoto crypto_sess_destroy;\n+\t}\n+\n \tret = pdcp_cnt_ring_create(entity, conf);\n \tif (ret)\n \t\tgoto crypto_sess_destroy;\n@@ -132,26 +149,50 @@ rte_pdcp_entity_establish(const struct rte_pdcp_entity_conf *conf)\n \treturn NULL;\n }\n \n+static int\n+pdcp_dl_release(struct rte_pdcp_entity *entity, struct rte_mbuf *out_mb[])\n+{\n+\tstruct entity_priv_dl_part *dl = entity_dl_part_get(entity);\n+\tstruct entity_priv *en_priv = entity_priv_get(entity);\n+\tint nb_out;\n+\n+\tnb_out = pdcp_reorder_up_to_get(&dl->reorder, out_mb, entity->max_pkt_cache,\n+\t\t\ten_priv->state.rx_next);\n+\n+\tpdcp_reorder_destroy(&dl->reorder);\n+\n+\treturn nb_out;\n+}\n+\n int\n rte_pdcp_entity_release(struct rte_pdcp_entity *pdcp_entity, struct rte_mbuf *out_mb[])\n {\n+\tstruct entity_priv *en_priv;\n+\tint nb_out = 0;\n+\n \tif (pdcp_entity == NULL)\n \t\treturn -EINVAL;\n \n+\ten_priv = entity_priv_get(pdcp_entity);\n+\n+\tif (!en_priv->flags.is_ul_entity)\n+\t\tnb_out = pdcp_dl_release(pdcp_entity, out_mb);\n+\n \t/* Teardown crypto sessions */\n \tpdcp_crypto_sess_destroy(pdcp_entity);\n \n \trte_free(pdcp_entity);\n \n-\tRTE_SET_USED(out_mb);\n-\treturn 0;\n+\treturn nb_out;\n }\n \n int\n rte_pdcp_entity_suspend(struct rte_pdcp_entity *pdcp_entity,\n \t\t\tstruct rte_mbuf *out_mb[])\n {\n+\tstruct entity_priv_dl_part *dl;\n \tstruct entity_priv *en_priv;\n+\tint nb_out = 0;\n \n \tif (pdcp_entity == NULL)\n \t\treturn -EINVAL;\n@@ -161,13 +202,15 @@ rte_pdcp_entity_suspend(struct rte_pdcp_entity *pdcp_entity,\n \tif (en_priv->flags.is_ul_entity) {\n \t\ten_priv->state.tx_next = 0;\n \t} else {\n+\t\tdl = entity_dl_part_get(pdcp_entity);\n+\t\tnb_out = pdcp_reorder_up_to_get(&dl->reorder, out_mb, pdcp_entity->max_pkt_cache,\n+\t\t\t\ten_priv->state.rx_next);\n+\t\tpdcp_reorder_stop(&dl->reorder);\n \t\ten_priv->state.rx_next = 0;\n \t\ten_priv->state.rx_deliv = 0;\n \t}\n \n-\tRTE_SET_USED(out_mb);\n-\n-\treturn 0;\n+\treturn nb_out;\n }\n \n struct rte_mbuf *\ndiff --git a/lib/pdcp/rte_pdcp.h b/lib/pdcp/rte_pdcp.h\nindex d7c2080358..9c4d06962a 100644\n--- a/lib/pdcp/rte_pdcp.h\n+++ b/lib/pdcp/rte_pdcp.h\n@@ -110,6 +110,8 @@ struct rte_pdcp_entity_conf {\n \t * such as entity re-establishment.\n \t */\n \tbool status_report_required;\n+\t/** Enable out of order delivery. */\n+\tbool out_of_order_delivery;\n };\n /* >8 End of structure rte_pdcp_entity_conf. */\n \n@@ -269,8 +271,8 @@ rte_pdcp_pkt_pre_process(const struct rte_pdcp_entity *entity,\n  * @param in_mb\n  *   The address of an array of *num* pointers to *rte_mbuf* structures.\n  * @param[out] out_mb\n- *   The address of an array of *num* pointers to *rte_mbuf* structures\n- *   to output packets after PDCP post-processing.\n+ *   The address of an array that can hold up to *rte_pdcp_entity.max_pkt_cache*\n+ *   pointers to *rte_mbuf* structures to output packets after PDCP post-processing.\n  * @param num\n  *   The maximum number of packets to process.\n  * @param[out] nb_err\n",
    "prefixes": [
        "v6",
        "13/21"
    ]
}