From patchwork Thu Jun 11 06:32:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 71236 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8730CA00C5; Thu, 11 Jun 2020 08:32:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 60D962C4F; Thu, 11 Jun 2020 08:32:35 +0200 (CEST) Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) by dpdk.org (Postfix) with ESMTP id 34D2B2BF7; Thu, 11 Jun 2020 08:32:34 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 0972F334; Thu, 11 Jun 2020 02:32:32 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 11 Jun 2020 02:32:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=QkMag7MKWLD1V EPyrluNXJgNa6w28jOlnxFzXXj29lc=; b=cqAgQQZBvPcjVSE4h7wHajt1fGEcQ zHQnQbOKUNy1i9S01fy93Z1GTyTNNKZbAQT4UKwcKCNw6+02lVE9iZPCoTJfqaQ/ 8MRu9ryNz7VjsbuoEclft8Kz+imqdBTptxZOg70vb/rgtbEATDNjdXyCWR4W0vx4 Z8n/TftEVOKe7f/V2mQAHGu8k2fXJB8JUkHk16WMoAwIMtpD2Dna5gsjKGuUly5F bbDn1G4AVHUHE/CpLmiPTNPZu1WTAqTOuuPSqNz46hM+FI3XTfonJOyB/6FvWtWr DCopQtihTFeRF1nH6R30mwzIiQiuvj4NMwZorNlXdqq8AkKT/IyIfpysA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=QkMag7MKWLD1VEPyrluNXJgNa6w28jOlnxFzXXj29lc=; b=EL8C8Ho1 tPwZkoiLMtOQjFvdo8+nHdnbO9oLVpvKtmBUJLrCnyqk2iQKDWl41b/gAUR1qqFG eyG7yQF/FEYTnaVL8EqDc7EK1i+XvNaB/KLDZ92KYA8p5bugRSxLbZZzif6xzplu zhOOgFEdr/2TVVSDcsivXACwcs5dli/C5IuleDHpPdSFHRop+Ui1ReQ+eYUKrvWv MVcD2XsUL38z9Ej/bHPnI/ofk7K3tGu+2JMwojxfqe5w5sC6Uq73N/SinQaL1VTR 3d2uETX+2nDWhvEqHFRXkm9CO7ybW3gq3bVsVNqRl2TqvU+mnqZLRHOpQySe/V1f Kyj0hr5GzUbknw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudehjedguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepvfhhohhm rghsucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenuc ggtffrrghtthgvrhhnpeehtdduuefggeekveehueeitdefhfdvkeevtedvfeeivdffudeu udehudetiedvudenucffohhmrghinhepughpughkrdhorhhgnecukfhppeejjedrudefge drvddtfedrudekgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhl fhhrohhmpehthhhomhgrshesmhhonhhjrghlohhnrdhnvght X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 951153060FE7; Thu, 11 Jun 2020 02:32:31 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: techboard@dpdk.org, Olivier Matz , John McNamara , Marko Kovacevic Date: Thu, 11 Jun 2020 08:32:29 +0200 Message-Id: <20200611063229.3591726-1-thomas@monjalon.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200525212415.3173817-1-thomas@monjalon.net> References: <20200525212415.3173817-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2] mbuf: document guideline for new fields and flags 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" Since dynamic fields and flags were added in 19.11, the idea was to use them for new features, not only PMD-specific. The guideline is made more explicit in doxygen, in the mbuf guide, and in the contribution design guidelines. For more information about the original design, see the presentation https://www.dpdk.org/wp-content/uploads/sites/35/2019/10/DynamicMbuf.pdf This decision was discussed in the Technical Board: http://mails.dpdk.org/archives/dev/2020-June/169667.html Signed-off-by: Thomas Monjalon Acked-by: Olivier Matz Acked-by: Jerin Jacob --- v2: - replace "rule" with "guideline" - add few exception criterias - add URL of the techboard minutes --- doc/guides/contributing/design.rst | 16 ++++++++++++++++ doc/guides/prog_guide/mbuf_lib.rst | 23 +++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_core.h | 2 ++ 3 files changed, 41 insertions(+) diff --git a/doc/guides/contributing/design.rst b/doc/guides/contributing/design.rst index d3dd694b65..4b9fb8a84d 100644 --- a/doc/guides/contributing/design.rst +++ b/doc/guides/contributing/design.rst @@ -57,6 +57,22 @@ The following config options can be used: * ``CONFIG_RTE_EXEC_ENV`` is a string that contains the name of the executive environment. * ``CONFIG_RTE_EXEC_ENV_FREEBSD`` or ``CONFIG_RTE_EXEC_ENV_LINUX`` are defined only if we are building for this execution environment. +Mbuf features +------------- + +The ``rte_mbuf`` structure must be kept small (128 bytes). + +In order to add new features without wasting buffer space for unused features, +some fields and flags can be registered dynamically in a shared area. +The "dynamic" mbuf area is the default choice for the new features. + +The "dynamic" area is eating the remaining space in mbuf, +and some existing "static" fields may need to become "dynamic". + +Adding a new static field or flag must be an exception matching many criterias +like (non exhaustive): wide usage, performance, size. + + Library Statistics ------------------ diff --git a/doc/guides/prog_guide/mbuf_lib.rst b/doc/guides/prog_guide/mbuf_lib.rst index 0d3223b081..c3dbfb9221 100644 --- a/doc/guides/prog_guide/mbuf_lib.rst +++ b/doc/guides/prog_guide/mbuf_lib.rst @@ -207,6 +207,29 @@ The list of flags and their precise meaning is described in the mbuf API documentation (rte_mbuf.h). Also refer to the testpmd source code (specifically the csumonly.c file) for details. +Dynamic fields and flags +~~~~~~~~~~~~~~~~~~~~~~~~ + +The size of the mbuf is constrained and limited; +while the amount of metadata to save for each packet is quite unlimited. +The most basic networking information already find their place +in the existing mbuf fields and flags. + +If new features need to be added, the new fields and flags should fit +in the "dynamic space", by registering some room in the mbuf structure: + +dynamic field + named area in the mbuf structure, + with a given size (at least 1 byte) and alignment constraint. + +dynamic flag + named bit in the mbuf structure, + stored in the field ``ol_flags``. + +The dynamic fields and flags are managed with the functions ``rte_mbuf_dyn*``. + +It is not possible to unregister fields or flags. + .. _direct_indirect_buffer: Direct and Indirect Buffers diff --git a/lib/librte_mbuf/rte_mbuf_core.h b/lib/librte_mbuf/rte_mbuf_core.h index b9a59c879c..22be41e520 100644 --- a/lib/librte_mbuf/rte_mbuf_core.h +++ b/lib/librte_mbuf/rte_mbuf_core.h @@ -12,6 +12,8 @@ * packet offload flags and some related macros. * For majority of DPDK entities, it is not recommended to include * this file directly, use include instead. + * + * New fields and flags should fit in the "dynamic space". */ #include