From patchwork Thu Jun 7 23:54:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Gora X-Patchwork-Id: 40789 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 27C406C93; Fri, 8 Jun 2018 01:55:15 +0200 (CEST) Received: from mail-qt0-f196.google.com (mail-qt0-f196.google.com [209.85.216.196]) by dpdk.org (Postfix) with ESMTP id 9CBD169D4 for ; Fri, 8 Jun 2018 01:55:13 +0200 (CEST) Received: by mail-qt0-f196.google.com with SMTP id l10-v6so6584993qtj.0 for ; Thu, 07 Jun 2018 16:55:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=Bo/o7XfjaNPjsTsdv4cY/8TnyMbElgA297jAz/76bJU=; b=WSviax/s5b0N4eruV6YQyiiOJ1d23TmgyfDDoj+PtiMnzZyHYVCAqnmO5iGehB02Ie bqqviaw5g+w+AukUwdiRCKXwNykQz/EpZLmNdEYobKcvwBjIO3ijMhoVhzr9A2/HNf3w EoReRNJe4x8tguxwAn2g+RMdvbok77zLMyCpubY19LvlEdY50T0n9FxQ1j+MnP8bJb/c YQ9iErAjNWPedPMAfxCS3J2w/wvLrcDmdPJZP1fHVm8rGMHrWjDWE/YYcXVahe/OWAbz 8Riz9UFOKNfu0iQxnuO9zQRds9xQpwY3b54osM+LE08nuaoNqWWtdwhpXCsGsIykK9zg 8Keg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=Bo/o7XfjaNPjsTsdv4cY/8TnyMbElgA297jAz/76bJU=; b=ct7hBla5n5n2FZMUiUzEi4v1QvzhRAD6oCFaXR1Up7xUXbc2rPV9ASZTBOmrIsPzse fFtt5tb8nsQgVINKqoyVMY/3vZZHcOxuHouPB2modS31u/2E4CH4aBZFlBwH0pr6ilN3 pvunlQWjWiOE6EOPw4l/aQvnTeTs0jej0avEPEEaHlRUCUKDrWQvoMi6gpcOQ7LcZXLh DWGWZwXLGvhnIIUBqtwGCLAse8EoATFKvlwL16aQvg8Qz9EXQSjH8AC8v2DbNMHOhfSf NQ8JZRLhlDIHnPiyZiRlCYb1JKWS8pGLzyssHBpe9ZI3Z8akIEWDuDt1wkpx9ZyCn+3f vo3w== X-Gm-Message-State: APt69E3sAsDfplAKgXJDd1pxCdWkBfEZKagIUhEXpfnrDSfeO6OAXtQ8 fI9uojBTcGLpUgxgn2glJTuB/A== X-Google-Smtp-Source: ADUXVKL9xS5uZY2+woIGrRHGHlJAbDAGlOdeyVzumUVTqLJOAC1Hr9352qhi+sulPLKErQJbpEDPzg== X-Received: by 2002:a0c:89dd:: with SMTP id 29-v6mr3548746qvs.233.1528415712555; Thu, 07 Jun 2018 16:55:12 -0700 (PDT) Received: from snappy.local.lan (201-1-204-188.dsl.telesp.net.br. [201.1.204.188]) by smtp.gmail.com with ESMTPSA id v29-v6sm11902268qkv.28.2018.06.07.16.55.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jun 2018 16:55:11 -0700 (PDT) From: Dan Gora To: dev@dpdk.org Cc: Dan Gora , Olivier Matz Date: Thu, 7 Jun 2018 20:54:54 -0300 Message-Id: <20180607235454.27832-1-dg@adax.com> X-Mailer: git-send-email 2.17.0.582.gccdcbd54c4 Subject: [dpdk-dev] [PATCH 1/4] mbuf: add accessor function for private data area 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" Add an inline accessor function to return the starting address of the private data area in the supplied mbuf. If the user did not allocate space for a private data area in the mbuf's memory pool, then return NULL. 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. Signed-off-by: Dan Gora --- lib/librte_mbuf/rte_mbuf.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 8e6b4d292..0c4f8f698 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -728,6 +728,25 @@ 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. + * + * @param md + * The pointer to the mbuf. + * @return + * The starting address of the private data area or NULL if there + * is no private data area. + */ +static inline void * +rte_mbuf_to_priv(struct rte_mbuf *md) +{ + if (md->priv_size == 0) + return NULL; + + return RTE_PTR_ADD(md, sizeof(struct rte_mbuf)); +} + /** * Returns TRUE if given mbuf is cloned by mbuf indirection, or FALSE * otherwise.