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 EEF3242BE2; Tue, 30 May 2023 12:04:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B56B242D8F; Tue, 30 May 2023 12:03:32 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 4A28942D39 for ; Tue, 30 May 2023 12:03:31 +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 34U8uRuF006425; Tue, 30 May 2023 03:03:30 -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=915uVKm1YPfCk6DfaOJDcdJC8WbXEleDw/oQzBHyMGw=; b=VSUNIa0XLZ/rHoVHy1FWbUOAfhDrzUvHZDzIF8T8sTkSOtwnd0qV61ECsvSAUCs2TMMg 5wy1rWe0IaIEhgjoMsUV7APCkBHWt/leDokp7ZxoMilHbUH3khzclzz2m6XI07KvMrgv 6ZxK42vengUqAuzILqwzW8TyJfdz05pbSvI81iVgBCizPLy8nEk7COWRCQgTr//U2WfG 1WwzhVi1pBGQdsF9p9d+pfe7pbla3otIiKbwwOvRng2YD3Efc12madP0AaDIqsOUErBe RZHOYIYmSJHbEhCEtLnmapDxD0R3CXHNuoSmqEZ+0pDLDw9JN0PhjOYX4eW9RO/14+IA aw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3quhcm7u17-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 30 May 2023 03:03:30 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 30 May 2023 03:03:28 -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; Tue, 30 May 2023 03:03:28 -0700 Received: from BG-LT92004.corp.innovium.com (unknown [10.193.69.246]) by maili.marvell.com (Postfix) with ESMTP id 522CC3F7050; Tue, 30 May 2023 03:03:24 -0700 (PDT) From: Anoob Joseph To: Thomas Monjalon , Akhil Goyal , Jerin Jacob , Konstantin Ananyev CC: Volodymyr Fialko , Hemant Agrawal , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= , Kiran Kumar K , , Olivier Matz , Stephen Hemminger Subject: [PATCH v6 20/21] pdcp: allocate reorder buffer alongside with entity Date: Tue, 30 May 2023 15:31:57 +0530 Message-ID: <20230530100158.1428-21-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> <20230530100158.1428-1-anoobj@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: gAeb6MxZ6lgFeVoxFTNmyLI6FKTh4RH6 X-Proofpoint-ORIG-GUID: gAeb6MxZ6lgFeVoxFTNmyLI6FKTh4RH6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 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 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 a9b1428c7a..9f74b5d0e5 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 9865c620b7..1c6d2466b2 100644 --- a/lib/pdcp/rte_pdcp.c +++ b/lib/pdcp/rte_pdcp.c @@ -14,7 +14,15 @@ #define RTE_PDCP_DYNFIELD_NAME "rte_pdcp_dynfield" -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; +}; int rte_pdcp_dynfield_offset = -1; @@ -35,46 +43,54 @@ pdcp_dynfield_register(void) } 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; } @@ -82,10 +98,11 @@ 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; uint32_t count; + int ret; if (pdcp_dynfield_register() < 0) return NULL; @@ -118,13 +135,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; @@ -149,7 +167,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; } @@ -174,8 +192,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