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 733F6A00C4; Thu, 30 Jun 2022 18:25:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 40E884069D; Thu, 30 Jun 2022 18:25:33 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id EED0140694 for ; Thu, 30 Jun 2022 18:25:31 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25UB16Mk032108; Thu, 30 Jun 2022 09:25:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=ga19rzCFQA9zTZ5bBfFGNuW9+vBzNtUgz5I30gW4/U8=; b=bXDElfNC404C0MubraMebM/37uURRfT/PSwM4nBLNBLIs8puyuPDjBMAJRWAABmAWl6w MJR9fx6/CAKjPsNf1JhkT3heyg9K/wk5FM9Z/l20XlM63SUh9Ss3veySMh2y4rIhfq2d 06A9VKlSr1CL9sYICpAtLOll62C4Md4kBmf1SYk7DZy1Z3LtOLok62m2vS2pfM/00uad 6FTjLyZdjHL/j/pb5nCRrm3VYTQWDL+YYQEQuhUg1GGl/eDeajLxbNXbcxPzxwFvmk9g VIiClZyUZHN7RbvlYMu/EjRS2cqt/IDQrQ0npdpNUl+JCXXq+jp/lvcEJeR2G1YtbsNt wA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3h1akbhbcy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 30 Jun 2022 09:25:29 -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.18; Thu, 30 Jun 2022 09:25: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.2 via Frontend Transport; Thu, 30 Jun 2022 09:25:28 -0700 Received: from localhost.localdomain (unknown [10.28.34.29]) by maili.marvell.com (Postfix) with ESMTP id A4D073F7077; Thu, 30 Jun 2022 09:25:26 -0700 (PDT) From: Shijith Thotton To: CC: , Shijith Thotton , , Olivier Matz Subject: [PATCH] mbuf: add mbuf physical address field to dynamic field Date: Thu, 30 Jun 2022 21:55:16 +0530 Message-ID: <57d2ab7fff672716d37ba4078e2e3bb2db126607.1656605763.git.sthotton@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: i-fPKNPJFxLDXtiWSDk8OITdo_cSU0Pe X-Proofpoint-ORIG-GUID: i-fPKNPJFxLDXtiWSDk8OITdo_cSU0Pe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-30_12,2022-06-28_01,2022-06-22_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 If all devices are configured to run in IOVA mode as VA, physical address field of mbuf (buf_iova) won't be used. In such cases, buf_iova space is free to use as a dynamic field. So a new dynamic field member (dynfield2) is added in mbuf structure to make use of that space. A new mbuf flag RTE_MBUF_F_DYNFIELD2 is introduced to help identify the mbuf that can use dynfield2. Signed-off-by: Shijith Thotton --- lib/mbuf/rte_mbuf.c | 8 ++++++++ lib/mbuf/rte_mbuf.h | 16 +++++++++++++--- lib/mbuf/rte_mbuf_core.h | 29 ++++++++++++++++++++++------- lib/mbuf/rte_mbuf_dyn.c | 3 +++ 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c index a2307cebe6..718b4505c4 100644 --- a/lib/mbuf/rte_mbuf.c +++ b/lib/mbuf/rte_mbuf.c @@ -101,6 +101,10 @@ rte_pktmbuf_init(struct rte_mempool *mp, m->port = RTE_MBUF_PORT_INVALID; rte_mbuf_refcnt_set(m, 1); m->next = NULL; + + /* enable dynfield2 if IOVA mode is VA */ + if (rte_eal_iova_mode() == RTE_IOVA_VA) + m->ol_flags = RTE_MBUF_F_DYNFIELD2; } /* @@ -206,6 +210,10 @@ __rte_pktmbuf_init_extmem(struct rte_mempool *mp, rte_mbuf_refcnt_set(m, 1); m->next = NULL; + /* enable dynfield2 if IOVA mode is VA */ + if (rte_eal_iova_mode() == RTE_IOVA_VA) + m->ol_flags |= RTE_MBUF_F_DYNFIELD2; + /* init external buffer shared info items */ shinfo = RTE_PTR_ADD(m, mbuf_size); m->shinfo = shinfo; diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h index 9811e8c760..59485f04ed 100644 --- a/lib/mbuf/rte_mbuf.h +++ b/lib/mbuf/rte_mbuf.h @@ -1056,9 +1056,11 @@ rte_pktmbuf_attach_extbuf(struct rte_mbuf *m, void *buf_addr, RTE_ASSERT(shinfo->free_cb != NULL); m->buf_addr = buf_addr; - m->buf_iova = buf_iova; m->buf_len = buf_len; + if (!RTE_MBUF_HAS_DYNFIELD2(m)) + m->buf_iova = buf_iova; + m->data_len = 0; m->data_off = 0; @@ -1087,6 +1089,10 @@ static inline void rte_mbuf_dynfield_copy(struct rte_mbuf *mdst, const struct rte_mbuf *msrc) { memcpy(&mdst->dynfield1, msrc->dynfield1, sizeof(mdst->dynfield1)); + + if (RTE_MBUF_HAS_DYNFIELD2(mdst)) + memcpy(&mdst->dynfield2, &msrc->dynfield2, + sizeof(mdst->dynfield2)); } /* internal */ @@ -1143,10 +1149,12 @@ static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *m) mi->data_off = m->data_off; mi->data_len = m->data_len; - mi->buf_iova = m->buf_iova; mi->buf_addr = m->buf_addr; mi->buf_len = m->buf_len; + if (!RTE_MBUF_HAS_DYNFIELD2(mi)) + mi->buf_iova = m->buf_iova; + mi->next = NULL; mi->pkt_len = mi->data_len; mi->nb_segs = 1; @@ -1245,11 +1253,13 @@ static inline void rte_pktmbuf_detach(struct rte_mbuf *m) m->priv_size = priv_size; m->buf_addr = (char *)m + mbuf_size; - m->buf_iova = rte_mempool_virt2iova(m) + mbuf_size; m->buf_len = (uint16_t)buf_len; rte_pktmbuf_reset_headroom(m); m->data_len = 0; m->ol_flags = 0; + + if (!RTE_MBUF_HAS_DYNFIELD2(m)) + m->buf_iova = rte_mempool_virt2iova(m) + mbuf_size; } /** diff --git a/lib/mbuf/rte_mbuf_core.h b/lib/mbuf/rte_mbuf_core.h index 3d6ddd6773..a549e36464 100644 --- a/lib/mbuf/rte_mbuf_core.h +++ b/lib/mbuf/rte_mbuf_core.h @@ -504,6 +504,8 @@ extern "C" { #define RTE_MBUF_F_INDIRECT (1ULL << 62) /**< Indirect attached mbuf */ #define IND_ATTACHED_MBUF RTE_DEPRECATED(IND_ATTACHED_MBUF) RTE_MBUF_F_INDIRECT +#define RTE_MBUF_F_DYNFIELD2 (1ULL << 63) /**< dynfield2 mbuf field enabled */ + /** Alignment constraint of mbuf private area. */ #define RTE_MBUF_PRIV_ALIGN 8 @@ -579,13 +581,18 @@ struct rte_mbuf { RTE_MARKER cacheline0; void *buf_addr; /**< Virtual address of segment buffer. */ - /** - * Physical address of segment buffer. - * Force alignment to 8-bytes, so as to ensure we have the exact - * same mbuf cacheline0 layout for 32-bit and 64-bit. This makes - * working on vector drivers easier. - */ - rte_iova_t buf_iova __rte_aligned(sizeof(rte_iova_t)); + RTE_STD_C11 + union { + /** + * Physical address of segment buffer if IOVA mode is not VA. + * Force alignment to 8-bytes, so as to ensure we have the exact + * same mbuf cacheline0 layout for 32-bit and 64-bit. This makes + * working on vector drivers easier. + */ + rte_iova_t buf_iova __rte_aligned(sizeof(rte_iova_t)); + /* Reserved for dynamic field if IOVA mode is VA. */ + uint64_t dynfield2; + }; /* next 8 bytes are initialised on RX descriptor rearm */ RTE_MARKER64 rearm_data; @@ -803,6 +810,14 @@ struct rte_mbuf_ext_shared_info { #define RTE_MBUF_DIRECT(mb) \ (!((mb)->ol_flags & (RTE_MBUF_F_INDIRECT | RTE_MBUF_F_EXTERNAL))) +/** + * + * Retrurns TRUE if given mbuf has dynfield2 field enabled, or FALSE otherwise. + * + * dynfield2 field can be enabled if IOVA mode is configured as VA. + */ +#define RTE_MBUF_HAS_DYNFIELD2(mb) (!!((mb)->ol_flags & RTE_MBUF_F_DYNFIELD2)) + /** Uninitialized or unspecified port. */ #define RTE_MBUF_PORT_INVALID UINT16_MAX /** For backwards compatibility. */ diff --git a/lib/mbuf/rte_mbuf_dyn.c b/lib/mbuf/rte_mbuf_dyn.c index 4ae79383b5..7bfe50e0e2 100644 --- a/lib/mbuf/rte_mbuf_dyn.c +++ b/lib/mbuf/rte_mbuf_dyn.c @@ -127,7 +127,10 @@ init_shared_mem(void) * rte_mbuf_dynfield_copy(). */ memset(shm, 0, sizeof(*shm)); + mark_free(dynfield1); + if (rte_eal_iova_mode() == RTE_IOVA_VA) + mark_free(dynfield2); /* init free_flags */ for (mask = RTE_MBUF_F_FIRST_FREE; mask <= RTE_MBUF_F_LAST_FREE; mask <<= 1) -- 2.25.1