From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id B0282B3B6 for ; Thu, 11 Sep 2014 15:11:32 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 11 Sep 2014 06:16:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,505,1406617200"; d="scan'208";a="598051476" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga002.fm.intel.com with ESMTP; 11 Sep 2014 06:15:49 -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 s8BDFngA002145; Thu, 11 Sep 2014 14:15:49 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s8BDFm2M023627; Thu, 11 Sep 2014 14:15:48 +0100 Received: (from bricha3@localhost) by sivswdev02.ir.intel.com with id s8BDFmxK023623; Thu, 11 Sep 2014 14:15:48 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Thu, 11 Sep 2014 14:15:38 +0100 Message-Id: <1410441347-22840-5-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1410441347-22840-1-git-send-email-bruce.richardson@intel.com> References: <1409759378-10113-1-git-send-email-bruce.richardson@intel.com> <1410441347-22840-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH v2 04/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: Thu, 11 Sep 2014 13:11:33 -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. Updated in V2: * Fix typo in comment in rte_mbuf.h Signed-off-by: Bruce Richardson --- 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 0e20e31..b9a1c66 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 */ @@ -471,6 +475,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 */ /** -- 1.9.3