From patchwork Wed Sep 3 15:49:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 305 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 033FE5941 for ; Wed, 3 Sep 2014 17:45:39 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 03 Sep 2014 08:49:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,458,1406617200"; d="scan'208";a="593984534" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 03 Sep 2014 08:49:40 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s83FndBi025422; Wed, 3 Sep 2014 16:49:39 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s83FndAE010448; Wed, 3 Sep 2014 16:49:39 +0100 Received: (from bricha3@localhost) by sivswdev02.ir.intel.com with id s83Fndak010444; Wed, 3 Sep 2014 16:49:39 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Wed, 3 Sep 2014 16:49:30 +0100 Message-Id: <1409759378-10113-6-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1409759378-10113-1-git-send-email-bruce.richardson@intel.com> References: <1409759378-10113-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 05/13] mbuf: introduce a flag to indicate a control mbuf X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Sep 2014 15:45:40 -0000 Since the flags field is now 64-bits, we can allow one bit to be used to indicate a control i.e. non-packet mbuf. Dedicate the high bit (bit 63) for this purpose and add in a utility macro to test if a given mbuf has the bit set or not. Signed-off-by: Bruce Richardson Acked-by: Olivier Matz --- lib/librte_mbuf/rte_mbuf.c | 2 ++ lib/librte_mbuf/rte_mbuf.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 9dfcac3..52e7574 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -69,7 +69,9 @@ rte_ctrlmbuf_init(struct rte_mempool *mp, void *_m, __attribute__((unused)) unsigned i) { + struct rte_mbuf *m = _m; rte_pktmbuf_init(mp, opaque_arg, _m, i); + m->ol_flags |= CTRL_MBUF_FLAG; } /* diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 6af5b2f..7b0b4f2 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -91,6 +91,7 @@ extern "C" { #define PKT_TX_IPV4_CSUM 0x1000 /**< Alias of PKT_TX_IP_CKSUM. */ #define PKT_TX_IPV4 PKT_RX_IPV4_HDR /**< IPv4 with no IP checksum offload. */ #define PKT_TX_IPV6 PKT_RX_IPV6_HDR /**< IPv6 packet */ + /* * Bit 14~13 used for L4 packet type with checksum enabled. * 00: Reserved @@ -106,6 +107,9 @@ extern "C" { /* Bit 15 */ #define PKT_TX_IEEE1588_TMST 0x8000 /**< TX IEEE1588 packet to timestamp. */ +/* Use final bit of flags to indicate a control mbuf */ +#define CTRL_MBUF_FLAG (1ULL << 63) + /** * Bit Mask to indicate what bits required for building TX context */ @@ -466,6 +470,21 @@ void rte_ctrlmbuf_init(struct rte_mempool *mp, void *opaque_arg, */ #define rte_ctrlmbuf_len(m) rte_pktmbuf_data_len(m) +/** + * Tests if an mbuf is a control mbuf + * + * @param m + * The mbuf.to be tested + * @return + * - True (1) if the mbuf is a control mbuf + * - False(0) otherwise + */ +static inline int +rte_is_ctrlmbuf(struct rte_mbuf *m) +{ + return (!!(m->ol_flags & CTRL_MBUF_FLAG)); +} + /* Operations on pkt mbuf */ /**