get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 126121,
    "url": "http://patches.dpdk.org/api/patches/126121/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20230414174512.642-22-anoobj@marvell.com/",
    "project": {
        "id": 1,
        "url": "http://patches.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": "<20230414174512.642-22-anoobj@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230414174512.642-22-anoobj@marvell.com",
    "date": "2023-04-14T17:45:11",
    "name": "[v2,21/22] pdcp: add thread safe processing",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "ac14812aa4972058e45c8c5a7ecd5719bf63fb7c",
    "submitter": {
        "id": 1205,
        "url": "http://patches.dpdk.org/api/people/1205/?format=api",
        "name": "Anoob Joseph",
        "email": "anoobj@marvell.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patches.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20230414174512.642-22-anoobj@marvell.com/mbox/",
    "series": [
        {
            "id": 27723,
            "url": "http://patches.dpdk.org/api/series/27723/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=27723",
            "date": "2023-04-14T17:44:50",
            "name": "lib: add pdcp protocol",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/27723/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/126121/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/126121/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 7A92942943;\n\tFri, 14 Apr 2023 19:48:22 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 40A4742D5A;\n\tFri, 14 Apr 2023 19:48:12 +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 B93A042D0E\n for <dev@dpdk.org>; Fri, 14 Apr 2023 19:48:10 +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 33E909e5011326; Fri, 14 Apr 2023 10:48:09 -0700",
            "from dc5-exch01.marvell.com ([199.233.59.181])\n by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3py3tk2epx-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Fri, 14 Apr 2023 10:48:08 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com\n (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48;\n Fri, 14 Apr 2023 10:48:07 -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; Fri, 14 Apr 2023 10:48:07 -0700",
            "from BG-LT92004.corp.innovium.com (unknown [10.28.161.183])\n by maili.marvell.com (Postfix) with ESMTP id F06B73F7081;\n Fri, 14 Apr 2023 10:48:01 -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=3X/frPzvgt4vtIwDWitUyZlRWJpPt0C8yj/NROW4zvY=;\n b=UL8BlJwKNATLat22haYh593CWSqPuNA6m9f4SfwJdtGwW/RsV8jpgIODEPuouUckmIbv\n ByxPwThz6TE4JBb9HgQordAx330IifDtTxhFhApIkB0kzD0QaI7lJCv6ZgwbqVEFp8Y0\n JlEQglgEMCwcQChQ4Ry45B/5P6b603wMGMXM3e2jVxpwXtHkb7xgCXkYaDRLnBOGhJAk\n YgfocClaE22SYtja4glGLz0DarTeVrTJZv3RiWYzg5z3NMJJlWAryMDntp2VZzpJI0oK\n J2uVo+UOsPqLwR7ubkp4oUJwZ8BmBwf3h5s/JgaJtFOvCaJsVQtZIKe0e5BGiN4LJYin Tw==",
        "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>, Bernard Iremonger\n <bernard.iremonger@intel.com>",
        "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>",
        "Subject": "[PATCH v2 21/22] pdcp: add thread safe processing",
        "Date": "Fri, 14 Apr 2023 23:15:11 +0530",
        "Message-ID": "<20230414174512.642-22-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>\n <20230414174512.642-1-anoobj@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-GUID": "9eE4oJo5Sgu6qyNnEvmT_DJb5i4xIN52",
        "X-Proofpoint-ORIG-GUID": "9eE4oJo5Sgu6qyNnEvmT_DJb5i4xIN52",
        "X-Proofpoint-Virus-Version": "vendor=baseguard\n engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22\n 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 <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\nPDCP state has to be guarded for:\n\n- Uplink pre_process:\n    - tx_next atomic increment\n\n- Downlink pre_process:\n    - rx_deliv - read\n\n- Downlink post_process:\n    - rx_deliv, rx_reorder, rx_next - read/write\n    - bitmask/reorder buffer - read/write\n\nWhen application requires thread safe processing, the state variables\nneed to be updated atomically. Add config option to select this option\nper entity.\n\nSigned-off-by: Anoob Joseph <anoobj@marvell.com>\nSigned-off-by: Volodymyr Fialko <vfialko@marvell.com>\n---\n lib/pdcp/pdcp_entity.h  | 46 +++++++++++++++++++++++++++++++++++++++++\n lib/pdcp/pdcp_process.c | 34 +++++++++++++++++++++++++++---\n lib/pdcp/rte_pdcp.c     |  2 ++\n lib/pdcp/rte_pdcp.h     |  2 ++\n 4 files changed, 81 insertions(+), 3 deletions(-)",
    "diff": "diff --git a/lib/pdcp/pdcp_entity.h b/lib/pdcp/pdcp_entity.h\nindex 38fa71acef..2dd6d2417d 100644\n--- a/lib/pdcp/pdcp_entity.h\n+++ b/lib/pdcp/pdcp_entity.h\n@@ -10,6 +10,7 @@\n #include <rte_mempool.h>\n #include <rte_pdcp.h>\n #include <rte_security.h>\n+#include <rte_spinlock.h>\n \n #include \"pdcp_reorder.h\"\n \n@@ -162,6 +163,8 @@ struct entity_priv {\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\t/** Is thread safety disabled */\n+\t\tuint64_t is_thread_safety_disabled : 1;\n \t} flags;\n \t/** Crypto op pool. */\n \tstruct rte_mempool *cop_pool;\n@@ -175,6 +178,8 @@ struct entity_priv {\n \tuint8_t dev_id;\n };\n \n+typedef rte_spinlock_t pdcp_lock_t;\n+\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@@ -182,6 +187,8 @@ struct entity_priv_dl_part {\n \tstruct pdcp_t_reordering t_reorder;\n \t/** Reorder packet buffer */\n \tstruct pdcp_reorder reorder;\n+\t/* Lock to protect concurrent updates */\n+\tpdcp_lock_t lock;\n \t/** Bitmap memory region */\n \tuint8_t bitmap_mem[0];\n };\n@@ -257,4 +264,43 @@ pdcp_hfn_max(enum rte_security_pdcp_sn_size sn_size)\n \treturn (1 << (32 - sn_size)) - 1;\n }\n \n+static inline uint32_t\n+pdcp_atomic_inc(const struct entity_priv *en_priv, uint32_t *val)\n+{\n+\tif (en_priv->flags.is_thread_safety_disabled)\n+\t\treturn (*val)++;\n+\telse\n+\t\treturn __atomic_fetch_add(val, 1, __ATOMIC_RELAXED);\n+}\n+\n+static inline void\n+pdcp_lock_init(const struct rte_pdcp_entity *entity)\n+{\n+\tstruct entity_priv_dl_part *dl = entity_dl_part_get(entity);\n+\tstruct entity_priv *en_priv = entity_priv_get(entity);\n+\n+\tif (!en_priv->flags.is_thread_safety_disabled)\n+\t\trte_spinlock_init(&dl->lock);\n+}\n+\n+static inline void\n+pdcp_lock_lock(const struct rte_pdcp_entity *entity)\n+{\n+\tstruct entity_priv_dl_part *dl = entity_dl_part_get(entity);\n+\tstruct entity_priv *en_priv = entity_priv_get(entity);\n+\n+\tif (!en_priv->flags.is_thread_safety_disabled)\n+\t\trte_spinlock_lock(&dl->lock);\n+}\n+\n+static inline void\n+pdcp_lock_unlock(const struct rte_pdcp_entity *entity)\n+{\n+\tstruct entity_priv_dl_part *dl = entity_dl_part_get(entity);\n+\tstruct entity_priv *en_priv = entity_priv_get(entity);\n+\n+\tif (!en_priv->flags.is_thread_safety_disabled)\n+\t\trte_spinlock_unlock(&dl->lock);\n+}\n+\n #endif /* PDCP_ENTITY_H */\ndiff --git a/lib/pdcp/pdcp_process.c b/lib/pdcp/pdcp_process.c\nindex cdadc9b6b8..0bafa3447a 100644\n--- a/lib/pdcp/pdcp_process.c\n+++ b/lib/pdcp/pdcp_process.c\n@@ -369,7 +369,7 @@ pdcp_pre_process_uplane_sn_12_ul_set_sn(struct entity_priv *en_priv, struct rte_\n \t\treturn false;\n \n \t/* Update sequence num in the PDU header */\n-\t*count = en_priv->state.tx_next++;\n+\t*count = pdcp_atomic_inc(en_priv, &en_priv->state.tx_next);\n \tsn = pdcp_sn_from_count_get(*count, RTE_SECURITY_PDCP_SN_SIZE_12);\n \n \tpdu_hdr->d_c = RTE_PDCP_PDU_TYPE_DATA;\n@@ -451,7 +451,7 @@ pdcp_pre_process_uplane_sn_18_ul_set_sn(struct entity_priv *en_priv, struct rte_\n \t\treturn false;\n \n \t/* Update sequence num in the PDU header */\n-\t*count = en_priv->state.tx_next++;\n+\t*count = pdcp_atomic_inc(en_priv, &en_priv->state.tx_next);\n \tsn = pdcp_sn_from_count_get(*count, RTE_SECURITY_PDCP_SN_SIZE_18);\n \n \tpdu_hdr->d_c = RTE_PDCP_PDU_TYPE_DATA;\n@@ -561,7 +561,7 @@ pdcp_pre_process_cplane_sn_12_ul(const struct rte_pdcp_entity *entity, struct rt\n \t\t\tmemset(mac_i, 0, PDCP_MAC_I_LEN);\n \n \t\t/* Update sequence number in the PDU header */\n-\t\tcount = en_priv->state.tx_next++;\n+\t\tcount = pdcp_atomic_inc(en_priv, &en_priv->state.tx_next);\n \t\tsn = pdcp_sn_from_count_get(count, RTE_SECURITY_PDCP_SN_SIZE_12);\n \n \t\tpdu_hdr->sn_11_8 = ((sn & 0xf00) >> 8);\n@@ -654,7 +654,9 @@ pdcp_pre_process_uplane_sn_12_dl_flags(const struct rte_pdcp_entity *entity,\n \tnb_cop = rte_crypto_op_bulk_alloc(en_priv->cop_pool, RTE_CRYPTO_OP_TYPE_SYMMETRIC, cop,\n \t\t\t\t\t  num);\n \n+\tpdcp_lock_lock(entity);\n \tconst uint32_t rx_deliv = en_priv->state.rx_deliv;\n+\tpdcp_lock_unlock(entity);\n \n \tfor (i = 0; i < nb_cop; i++) {\n \t\tmb = in_mb[i];\n@@ -714,7 +716,9 @@ pdcp_pre_process_uplane_sn_18_dl_flags(const struct rte_pdcp_entity *entity,\n \tnb_cop = rte_crypto_op_bulk_alloc(en_priv->cop_pool, RTE_CRYPTO_OP_TYPE_SYMMETRIC, cop,\n \t\t\t\t\t  num);\n \n+\tpdcp_lock_lock(entity);\n \tconst uint32_t rx_deliv = en_priv->state.rx_deliv;\n+\tpdcp_lock_unlock(entity);\n \n \tfor (i = 0; i < nb_cop; i++) {\n \t\tmb = in_mb[i];\n@@ -775,7 +779,9 @@ pdcp_pre_process_cplane_sn_12_dl(const struct rte_pdcp_entity *entity, struct rt\n \tnb_cop = rte_crypto_op_bulk_alloc(en_priv->cop_pool, RTE_CRYPTO_OP_TYPE_SYMMETRIC, cop,\n \t\t\t\t\t  num);\n \n+\tpdcp_lock_lock(entity);\n \tconst uint32_t rx_deliv = en_priv->state.rx_deliv;\n+\tpdcp_lock_unlock(entity);\n \n \tfor (i = 0; i < nb_cop; i++) {\n \t\tmb = in_mb[i];\n@@ -925,6 +931,8 @@ pdcp_post_process_uplane_sn_12_dl_flags(const struct rte_pdcp_entity *entity,\n \tstruct rte_mbuf *mb;\n \tuint32_t count;\n \n+\tpdcp_lock_lock(entity);\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@@ -954,6 +962,8 @@ pdcp_post_process_uplane_sn_12_dl_flags(const struct rte_pdcp_entity *entity,\n \t\terr_mb[nb_err++] = mb;\n \t}\n \n+\tpdcp_lock_unlock(entity);\n+\n \tif (unlikely(nb_err != 0))\n \t\trte_memcpy(&out_mb[nb_success], err_mb, nb_err * sizeof(struct rte_mbuf *));\n \n@@ -994,6 +1004,7 @@ pdcp_post_process_uplane_sn_18_dl_flags(const struct rte_pdcp_entity *entity,\n \tint32_t rsn = 0;\n \tuint32_t count;\n \n+\tpdcp_lock_lock(entity);\n \n \tfor (i = 0; i < num; i++) {\n \t\tmb = in_mb[i];\n@@ -1026,6 +1037,8 @@ pdcp_post_process_uplane_sn_18_dl_flags(const struct rte_pdcp_entity *entity,\n \t\terr_mb[nb_err++] = mb;\n \t}\n \n+\tpdcp_lock_unlock(entity);\n+\n \tif (unlikely(nb_err != 0))\n \t\trte_memcpy(&out_mb[nb_success], err_mb, nb_err * sizeof(struct rte_mbuf *));\n \n@@ -1066,6 +1079,8 @@ pdcp_post_process_cplane_sn_12_dl(const struct rte_pdcp_entity *entity,\n \tuint32_t count;\n \tint32_t rsn;\n \n+\tpdcp_lock_lock(entity);\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@@ -1091,6 +1106,8 @@ pdcp_post_process_cplane_sn_12_dl(const struct rte_pdcp_entity *entity,\n \t\terr_mb[nb_err++] = mb;\n \t}\n \n+\tpdcp_lock_unlock(entity);\n+\n \tif (unlikely(nb_err != 0))\n \t\trte_memcpy(&out_mb[nb_success], err_mb, nb_err * sizeof(struct rte_mbuf *));\n \n@@ -1254,6 +1271,13 @@ pdcp_entity_priv_populate(struct entity_priv *en_priv, const struct rte_pdcp_ent\n \t */\n \ten_priv->flags.is_out_of_order_delivery = conf->out_of_order_delivery;\n \n+\t/**\n+\t * flags.disable_thread_safety\n+\t *\n+\t * Indicate whether the thread safety is disabled for PDCP entity.\n+\t */\n+\ten_priv->flags.is_thread_safety_disabled = conf->disable_thread_safety;\n+\n \t/**\n \t * hdr_sz\n \t *\n@@ -1316,6 +1340,8 @@ rte_pdcp_t_reordering_expiry_handle(const struct rte_pdcp_entity *entity, struct\n \t *   performing header decompression, if not decompressed before:\n \t */\n \n+\tpdcp_lock_lock(entity);\n+\n \t/*   - all stored PDCP SDU(s) with associated COUNT value(s) < RX_REORD; */\n \tnb_out = pdcp_reorder_up_to_get(&dl->reorder, out_mb, capacity, en_priv->state.rx_reord);\n \tcapacity -= nb_out;\n@@ -1347,5 +1373,7 @@ rte_pdcp_t_reordering_expiry_handle(const struct rte_pdcp_entity *entity, struct\n \t\tdl->t_reorder.state = TIMER_EXPIRED;\n \t}\n \n+\tpdcp_lock_unlock(entity);\n+\n \treturn nb_out;\n }\ndiff --git a/lib/pdcp/rte_pdcp.c b/lib/pdcp/rte_pdcp.c\nindex 95d2283cef..06b86c274e 100644\n--- a/lib/pdcp/rte_pdcp.c\n+++ b/lib/pdcp/rte_pdcp.c\n@@ -72,6 +72,8 @@ pdcp_dl_establish(struct rte_pdcp_entity *entity, const struct rte_pdcp_entity_c\n \tif (ret)\n \t\treturn ret;\n \n+\tpdcp_lock_init(entity);\n+\n \treturn 0;\n }\n \ndiff --git a/lib/pdcp/rte_pdcp.h b/lib/pdcp/rte_pdcp.h\nindex c077acce63..a8b824a7ee 100644\n--- a/lib/pdcp/rte_pdcp.h\n+++ b/lib/pdcp/rte_pdcp.h\n@@ -137,6 +137,8 @@ struct rte_pdcp_entity_conf {\n \tbool is_slrb;\n \t/** Enable security offload on the device specified. */\n \tbool en_sec_offload;\n+\t/** Disable usage of synchronization primitives for entity. */\n+\tbool disable_thread_safety;\n \t/** Device on which security/crypto session need to be created. */\n \tuint8_t dev_id;\n \t/** Reverse direction during IV generation. Can be used to simulate UE crypto processing.*/\n",
    "prefixes": [
        "v2",
        "21/22"
    ]
}