From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E70EAA04C7; Wed, 16 Sep 2020 11:10:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 806DB1C206; Wed, 16 Sep 2020 11:09:53 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by dpdk.org (Postfix) with ESMTP id 246F71C1FB for ; Wed, 16 Sep 2020 11:09:50 +0200 (CEST) Received: from dkrd2.smartsharesys.local ([192.168.4.12]) by smartserver.smartsharesystems.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 16 Sep 2020 11:09:49 +0200 From: =?UTF-8?q?Morten=20Br=C3=B8rup?= To: olivier.matz@6wind.com, thomas@monjalon.net Cc: dev@dpdk.org, =?UTF-8?q?Morten=20Br=C3=B8rup?= Date: Wed, 16 Sep 2020 11:09:43 +0200 Message-Id: <20200916090944.125128-2-mb@smartsharesystems.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200916090944.125128-1-mb@smartsharesystems.com> References: <20200916090944.125128-1-mb@smartsharesystems.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 16 Sep 2020 09:09:49.0006 (UTC) FILETIME=[20FD16E0:01D68C09] Subject: [dpdk-dev] [PATCH v2 1/2] mbuf: minor cleanup X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The mbuf header files had some commenting style errors that affected the API documentation. Also, the RTE_ prefix was missing on a macro and a definition. Note: This patch does not touch the offload and attachment flags that are also missing the RTE_ prefix. Changes only affecting documentation: * Removed the MBUF_INVALID_PORT definition from rte_mbuf.h; it is already defined in rte_mbuf_core.h. This removal also reestablished the description of the rte_pktmbuf_reset() function. * Corrected the comment related to RTE_MBUF_MAX_NB_SEGS. * Corrected the comment related to PKT_TX_QINQ_PKT. Changes regarding missing RTE_ prefix: * Converted the MBUF_RAW_ALLOC_CHECK() macro to an __rte_mbuf_raw_sanity_check() inline function. Added backwards compatible macro with the original name. * Renamed the MBUF_INVALID_PORT definition to RTE_MBUF_PORT_INVALID. Added backwards compatible definition with the original name. v2: * Use RTE_MBUF_PORT_INVALID intead of MBUF_INVALID_PORT in rte_mbuf.c. Signed-off-by: Morten Brørup --- lib/librte_mbuf/rte_mbuf.h | 47 ++++++++++++++++++++------------- lib/librte_mbuf/rte_mbuf_core.h | 9 ++++--- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 7259575a7..ec48da67d 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -554,12 +554,28 @@ __rte_experimental int rte_mbuf_check(const struct rte_mbuf *m, int is_header, const char **reason); -#define MBUF_RAW_ALLOC_CHECK(m) do { \ - RTE_ASSERT(rte_mbuf_refcnt_read(m) == 1); \ - RTE_ASSERT((m)->next == NULL); \ - RTE_ASSERT((m)->nb_segs == 1); \ - __rte_mbuf_sanity_check(m, 0); \ -} while (0) +/** + * Sanity checks on a reinitialized mbuf. + * + * Check the consistency of the given reinitialized mbuf. + * The function will cause a panic if corruption is detected. + * + * Check that the mbuf is properly reinitialized (refcnt=1, next=NULL, + * nb_segs=1), as done by rte_pktmbuf_prefree_seg(). + * + * @param m + * The mbuf to be checked. + */ +static __rte_always_inline void +__rte_mbuf_raw_sanity_check(const struct rte_mbuf *m) +{ + RTE_ASSERT(rte_mbuf_refcnt_read(m) == 1); + RTE_ASSERT(m->next == NULL); + RTE_ASSERT(m->nb_segs == 1); + __rte_mbuf_sanity_check(m, 0); +} +/** For backwards compatibility. */ +#define MBUF_RAW_ALLOC_CHECK(m) __rte_mbuf_raw_sanity_check(m) /** * Allocate an uninitialized mbuf from mempool *mp*. @@ -586,7 +602,7 @@ static inline struct rte_mbuf *rte_mbuf_raw_alloc(struct rte_mempool *mp) if (rte_mempool_get(mp, (void **)&m) < 0) return NULL; - MBUF_RAW_ALLOC_CHECK(m); + __rte_mbuf_raw_sanity_check(m); return m; } @@ -609,10 +625,7 @@ rte_mbuf_raw_free(struct rte_mbuf *m) { RTE_ASSERT(!RTE_MBUF_CLONED(m) && (!RTE_MBUF_HAS_EXTBUF(m) || RTE_MBUF_HAS_PINNED_EXTBUF(m))); - RTE_ASSERT(rte_mbuf_refcnt_read(m) == 1); - RTE_ASSERT(m->next == NULL); - RTE_ASSERT(m->nb_segs == 1); - __rte_mbuf_sanity_check(m, 0); + __rte_mbuf_raw_sanity_check(m); rte_mempool_put(m->pool, m); } @@ -858,8 +871,6 @@ static inline void rte_pktmbuf_reset_headroom(struct rte_mbuf *m) * @param m * The packet mbuf to be reset. */ -#define MBUF_INVALID_PORT UINT16_MAX - static inline void rte_pktmbuf_reset(struct rte_mbuf *m) { m->next = NULL; @@ -868,7 +879,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m) m->vlan_tci = 0; m->vlan_tci_outer = 0; m->nb_segs = 1; - m->port = MBUF_INVALID_PORT; + m->port = RTE_MBUF_PORT_INVALID; m->ol_flags &= EXT_ATTACHED_MBUF; m->packet_type = 0; @@ -931,22 +942,22 @@ static inline int rte_pktmbuf_alloc_bulk(struct rte_mempool *pool, switch (count % 4) { case 0: while (idx != count) { - MBUF_RAW_ALLOC_CHECK(mbufs[idx]); + __rte_mbuf_raw_sanity_check(mbufs[idx]); rte_pktmbuf_reset(mbufs[idx]); idx++; /* fall-through */ case 3: - MBUF_RAW_ALLOC_CHECK(mbufs[idx]); + __rte_mbuf_raw_sanity_check(mbufs[idx]); rte_pktmbuf_reset(mbufs[idx]); idx++; /* fall-through */ case 2: - MBUF_RAW_ALLOC_CHECK(mbufs[idx]); + __rte_mbuf_raw_sanity_check(mbufs[idx]); rte_pktmbuf_reset(mbufs[idx]); idx++; /* fall-through */ case 1: - MBUF_RAW_ALLOC_CHECK(mbufs[idx]); + __rte_mbuf_raw_sanity_check(mbufs[idx]); rte_pktmbuf_reset(mbufs[idx]); idx++; /* fall-through */ diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h index 8cd7137ac..4ac5609e3 100644 --- a/lib/librte_mbuf/rte_mbuf_core.h +++ b/lib/librte_mbuf/rte_mbuf_core.h @@ -272,7 +272,7 @@ extern "C" { * mbuf 'vlan_tci' & 'vlan_tci_outer' must be valid when this flag is set. */ #define PKT_TX_QINQ (1ULL << 49) -/* this old name is deprecated */ +/** This old name is deprecated. */ #define PKT_TX_QINQ_PKT PKT_TX_QINQ /** @@ -686,7 +686,7 @@ struct rte_mbuf_ext_shared_info { }; }; -/**< Maximum number of nb_segs allowed. */ +/** Maximum number of nb_segs allowed. */ #define RTE_MBUF_MAX_NB_SEGS UINT16_MAX /** @@ -714,7 +714,10 @@ struct rte_mbuf_ext_shared_info { #define RTE_MBUF_DIRECT(mb) \ (!((mb)->ol_flags & (IND_ATTACHED_MBUF | EXT_ATTACHED_MBUF))) -#define MBUF_INVALID_PORT UINT16_MAX +/** NULL value for the uint16_t port type. */ +#define RTE_MBUF_PORT_INVALID UINT16_MAX +/** For backwards compatibility. */ +#define MBUF_INVALID_PORT RTE_MBUF_PORT_INVALID /** * A macro that points to an offset into the data in the mbuf. -- 2.17.1