DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dan Gora <dg@adax.com>
To: dev@dpdk.org
Cc: Dan Gora <dg@adax.com>, Olivier Matz <olivier.matz@6wind.com>
Subject: [dpdk-dev] [PATCH v2 1/4] mbuf: add accessor function for private data area
Date: Mon, 18 Jun 2018 16:35:34 -0700	[thread overview]
Message-ID: <20180618233534.21611-1-dg@adax.com> (raw)

Add an inline accessor function to return the starting address of
the private data area in the supplied mbuf.

This allows applications to easily access the private data area between
the struct rte_mbuf and the data buffer in the specified mbuf without
creating private macros or accessor functions.

No checks are made to ensure that a private data area actually exists
in the buffer.

Signed-off-by: Dan Gora <dg@adax.com>
---
 lib/librte_mbuf/rte_mbuf.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 8e6b4d292..08c58335d 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -728,6 +728,24 @@ rte_mbuf_to_baddr(struct rte_mbuf *md)
 	return buffer_addr;
 }
 
+/**
+ * Return the starting address of the private data area embedded in
+ * the given mbuf.
+ *
+ * Note that no check is made to ensure that a private data area
+ * actually exists in the supplied mbuf.
+ *
+ * @param md
+ *   The pointer to the mbuf.
+ * @return
+ *   The starting address of the private data area of the given mbuf.
+ */
+static inline void * __rte_experimental
+rte_mbuf_to_priv(struct rte_mbuf *m)
+{
+	return RTE_PTR_ADD(m, sizeof(struct rte_mbuf));
+}
+
 /**
  * Returns TRUE if given mbuf is cloned by mbuf indirection, or FALSE
  * otherwise.
-- 
2.18.0.rc1.1.g6f333ff2f

             reply	other threads:[~2018-06-18 23:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18 23:35 Dan Gora [this message]
2018-06-19 12:56 ` Andrew Rybchenko
2018-06-26  7:39 ` Olivier Matz
2018-07-13 21:10   ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180618233534.21611-1-dg@adax.com \
    --to=dg@adax.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).