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 B9CB742943; Fri, 14 Apr 2023 19:48:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0EA2642D53; Fri, 14 Apr 2023 19:48:06 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 56FFA42D0E for ; Fri, 14 Apr 2023 19:48:04 +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 33EGNfCF012938; Fri, 14 Apr 2023 10:48:03 -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=1jkkjwIDUYYWhP5vVAaiXgdr6KkOgEm9UlGmCDMVCVw=; b=g/Hr6WBm66Ao/qP22ka/KHuZoGXyvndoOxf420oELi03mnUdhCKXdSpTW5t6ysPuEohQ S3DhlpZL1drDciHzcrr0IHx+A+kf3t3eDlibrzx8EejMEMPeZbpCzbRDDFRMneASoA4m W+x9pgVsWlqQcP85woennaap6MF6ak33SJANuMdPOJCfkCOZlWCua8YNLqMl5DlgYA0g c+ocITW/KoF016qfkB/PZyVaaRIviw0C3LjoTm/MQeV5kF774HND/KVRTI1csFdsQjAt 0dvL53OrFvXdDO3W9sN6YsCUrz8Rycf2G6rlrT1VBbu9IpBxRih8cxJF3FbpXr0tXFWm GQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3py646s6wq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 14 Apr 2023 10:48:03 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 14 Apr 2023 10:48:01 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Fri, 14 Apr 2023 10:48:00 -0700 Received: from BG-LT92004.corp.innovium.com (unknown [10.28.161.183]) by maili.marvell.com (Postfix) with ESMTP id 9FE333F7081; Fri, 14 Apr 2023 10:47:55 -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 20/22] pdcp: allocate reorder buffer alongside with entity Date: Fri, 14 Apr 2023 23:15:10 +0530 Message-ID: <20230414174512.642-21-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: 7paThd-LU_WAMYK_Vju3FZVie9GusVuW X-Proofpoint-ORIG-GUID: 7paThd-LU_WAMYK_Vju3FZVie9GusVuW 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 Instead of allocating reorder buffer separately on heap, allocate memory for it together with rest of entity, and then only initialize buffer via `rte_reorder_init()`. Signed-off-by: Anoob Joseph Signed-off-by: Volodymyr Fialko --- lib/pdcp/pdcp_cnt.c | 9 +++---- lib/pdcp/pdcp_cnt.h | 3 ++- lib/pdcp/pdcp_entity.h | 2 +- lib/pdcp/pdcp_reorder.c | 11 ++------ lib/pdcp/pdcp_reorder.h | 12 ++++++--- lib/pdcp/rte_pdcp.c | 58 ++++++++++++++++++++++++++--------------- 6 files changed, 55 insertions(+), 40 deletions(-) diff --git a/lib/pdcp/pdcp_cnt.c b/lib/pdcp/pdcp_cnt.c index af027b00d3..e1d0634b4d 100644 --- a/lib/pdcp/pdcp_cnt.c +++ b/lib/pdcp/pdcp_cnt.c @@ -20,15 +20,14 @@ pdcp_cnt_bitmap_get_memory_footprint(const struct rte_pdcp_entity_conf *conf) } int -pdcp_cnt_bitmap_create(struct entity_priv_dl_part *dl, void *bitmap_mem, uint32_t window_size) +pdcp_cnt_bitmap_create(struct entity_priv_dl_part *dl, uint32_t nb_elem, + void *bitmap_mem, uint32_t mem_size) { - uint32_t mem_size = rte_bitmap_get_memory_footprint(window_size); - - dl->bitmap.bmp = rte_bitmap_init(window_size, bitmap_mem, mem_size); + dl->bitmap.bmp = rte_bitmap_init(nb_elem, bitmap_mem, mem_size); if (dl->bitmap.bmp == NULL) return -EINVAL; - dl->bitmap.size = window_size; + dl->bitmap.size = nb_elem; return 0; } diff --git a/lib/pdcp/pdcp_cnt.h b/lib/pdcp/pdcp_cnt.h index 5941b7a406..87b011f9dc 100644 --- a/lib/pdcp/pdcp_cnt.h +++ b/lib/pdcp/pdcp_cnt.h @@ -10,7 +10,8 @@ #include "pdcp_entity.h" uint32_t pdcp_cnt_bitmap_get_memory_footprint(const struct rte_pdcp_entity_conf *conf); -int pdcp_cnt_bitmap_create(struct entity_priv_dl_part *dl, void *bitmap_mem, uint32_t window_size); +int pdcp_cnt_bitmap_create(struct entity_priv_dl_part *dl, uint32_t nb_elem, + void *bitmap_mem, uint32_t mem_size); void pdcp_cnt_bitmap_set(struct pdcp_cnt_bitmap bitmap, uint32_t count); bool pdcp_cnt_bitmap_is_set(struct pdcp_cnt_bitmap bitmap, uint32_t count); diff --git a/lib/pdcp/pdcp_entity.h b/lib/pdcp/pdcp_entity.h index 8e1d6254dd..38fa71acef 100644 --- a/lib/pdcp/pdcp_entity.h +++ b/lib/pdcp/pdcp_entity.h @@ -132,7 +132,7 @@ struct pdcp_cnt_bitmap { }; /* - * Layout of PDCP entity: [rte_pdcp_entity] [entity_priv] [entity_dl/ul] + * Layout of PDCP entity: [rte_pdcp_entity] [entity_priv] [entity_dl/ul] [reorder/bitmap] */ struct entity_priv { diff --git a/lib/pdcp/pdcp_reorder.c b/lib/pdcp/pdcp_reorder.c index 5399f0dc28..bc45f2e19b 100644 --- a/lib/pdcp/pdcp_reorder.c +++ b/lib/pdcp/pdcp_reorder.c @@ -8,20 +8,13 @@ #include "pdcp_reorder.h" int -pdcp_reorder_create(struct pdcp_reorder *reorder, uint32_t window_size) +pdcp_reorder_create(struct pdcp_reorder *reorder, size_t nb_elem, void *mem, size_t mem_size) { - reorder->buf = rte_reorder_create("reorder_buffer", SOCKET_ID_ANY, window_size); + reorder->buf = rte_reorder_init(mem, mem_size, "reorder_buffer", nb_elem); if (reorder->buf == NULL) return -rte_errno; - reorder->window_size = window_size; reorder->is_active = false; return 0; } - -void -pdcp_reorder_destroy(const struct pdcp_reorder *reorder) -{ - rte_reorder_free(reorder->buf); -} diff --git a/lib/pdcp/pdcp_reorder.h b/lib/pdcp/pdcp_reorder.h index 6a2f61d6ae..7e4f079d4b 100644 --- a/lib/pdcp/pdcp_reorder.h +++ b/lib/pdcp/pdcp_reorder.h @@ -9,12 +9,18 @@ struct pdcp_reorder { struct rte_reorder_buffer *buf; - uint32_t window_size; bool is_active; }; -int pdcp_reorder_create(struct pdcp_reorder *reorder, uint32_t window_size); -void pdcp_reorder_destroy(const struct pdcp_reorder *reorder); +int pdcp_reorder_create(struct pdcp_reorder *reorder, size_t nb_elem, void *mem, size_t mem_size); + +/* NOTE: replace with `rte_reorder_memory_footprint_get` after DPDK 23.07 */ +#define SIZE_OF_REORDER_BUFFER (4 * RTE_CACHE_LINE_SIZE) +static inline size_t +pdcp_reorder_memory_footprint_get(size_t nb_elem) +{ + return SIZE_OF_REORDER_BUFFER + (2 * nb_elem * sizeof(struct rte_mbuf *)); +} static inline uint32_t pdcp_reorder_get_sequential(struct pdcp_reorder *reorder, struct rte_mbuf **mbufs, diff --git a/lib/pdcp/rte_pdcp.c b/lib/pdcp/rte_pdcp.c index ce846d687e..95d2283cef 100644 --- a/lib/pdcp/rte_pdcp.c +++ b/lib/pdcp/rte_pdcp.c @@ -12,49 +12,65 @@ #include "pdcp_entity.h" #include "pdcp_process.h" -static int bitmap_mem_offset; +struct entity_layout { + size_t bitmap_offset; + size_t bitmap_size; + + size_t reorder_buf_offset; + size_t reorder_buf_size; + + size_t total_size; +}; static int -pdcp_entity_size_get(const struct rte_pdcp_entity_conf *conf) +pdcp_entity_layout_get(const struct rte_pdcp_entity_conf *conf, struct entity_layout *layout) { - int size; + size_t size; + const uint32_t window_size = pdcp_window_size_get(conf->pdcp_xfrm.sn_size); size = sizeof(struct rte_pdcp_entity) + sizeof(struct entity_priv); if (conf->pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_DOWNLINK) { size += sizeof(struct entity_priv_dl_part); + /* Bitmap require memory to be cache aligned */ size = RTE_CACHE_LINE_ROUNDUP(size); - bitmap_mem_offset = size; - size += pdcp_cnt_bitmap_get_memory_footprint(conf); + layout->bitmap_offset = size; + layout->bitmap_size = pdcp_cnt_bitmap_get_memory_footprint(conf); + size += layout->bitmap_size; + layout->reorder_buf_offset = size; + layout->reorder_buf_size = pdcp_reorder_memory_footprint_get(window_size); + size += layout->reorder_buf_size; } else if (conf->pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_UPLINK) size += sizeof(struct entity_priv_ul_part); else return -EINVAL; - return RTE_ALIGN_CEIL(size, RTE_CACHE_LINE_SIZE); + layout->total_size = size; + + return 0; } static int -pdcp_dl_establish(struct rte_pdcp_entity *entity, const struct rte_pdcp_entity_conf *conf) +pdcp_dl_establish(struct rte_pdcp_entity *entity, const struct rte_pdcp_entity_conf *conf, + const struct entity_layout *layout) { const uint32_t window_size = pdcp_window_size_get(conf->pdcp_xfrm.sn_size); struct entity_priv_dl_part *dl = entity_dl_part_get(entity); - void *bitmap_mem; + void *memory; int ret; entity->max_pkt_cache = RTE_MAX(entity->max_pkt_cache, window_size); dl->t_reorder.handle = conf->t_reordering; - ret = pdcp_reorder_create(&dl->reorder, window_size); + memory = RTE_PTR_ADD(entity, layout->reorder_buf_offset); + ret = pdcp_reorder_create(&dl->reorder, window_size, memory, layout->reorder_buf_size); if (ret) return ret; - bitmap_mem = RTE_PTR_ADD(entity, bitmap_mem_offset); - ret = pdcp_cnt_bitmap_create(dl, bitmap_mem, window_size); - if (ret) { - pdcp_reorder_destroy(&dl->reorder); + memory = RTE_PTR_ADD(entity, layout->bitmap_offset); + ret = pdcp_cnt_bitmap_create(dl, window_size, memory, layout->bitmap_size); + if (ret) return ret; - } return 0; } @@ -62,9 +78,10 @@ pdcp_dl_establish(struct rte_pdcp_entity *entity, const struct rte_pdcp_entity_c struct rte_pdcp_entity * rte_pdcp_entity_establish(const struct rte_pdcp_entity_conf *conf) { + struct entity_layout entity_layout = { 0 }; struct rte_pdcp_entity *entity = NULL; struct entity_priv *en_priv; - int ret, entity_size; + int ret; if (conf == NULL || conf->cop_pool == NULL || conf->ctr_pdu_pool == NULL) { rte_errno = -EINVAL; @@ -94,13 +111,14 @@ rte_pdcp_entity_establish(const struct rte_pdcp_entity_conf *conf) return NULL; } - entity_size = pdcp_entity_size_get(conf); - if (entity_size < 0) { + ret = pdcp_entity_layout_get(conf, &entity_layout); + if (ret < 0) { rte_errno = -EINVAL; return NULL; } - entity = rte_zmalloc_socket("pdcp_entity", entity_size, RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY); + entity = rte_zmalloc_socket("pdcp_entity", entity_layout.total_size, RTE_CACHE_LINE_SIZE, + SOCKET_ID_ANY); if (entity == NULL) { rte_errno = -ENOMEM; return NULL; @@ -123,7 +141,7 @@ rte_pdcp_entity_establish(const struct rte_pdcp_entity_conf *conf) goto crypto_sess_destroy; if (conf->pdcp_xfrm.pkt_dir == RTE_SECURITY_PDCP_DOWNLINK) { - ret = pdcp_dl_establish(entity, conf); + ret = pdcp_dl_establish(entity, conf, &entity_layout); if (ret) goto crypto_sess_destroy; } @@ -148,8 +166,6 @@ pdcp_dl_release(struct rte_pdcp_entity *entity, struct rte_mbuf *out_mb[]) nb_out = pdcp_reorder_up_to_get(&dl->reorder, out_mb, entity->max_pkt_cache, en_priv->state.rx_next); - pdcp_reorder_destroy(&dl->reorder); - return nb_out; } -- 2.25.1