From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 70F4AA04FF; Tue, 14 Jan 2020 16:50:30 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 994AA1C0D5; Tue, 14 Jan 2020 16:50:29 +0100 (CET) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by dpdk.org (Postfix) with ESMTP id B4FF11C0C2 for ; Tue, 14 Jan 2020 16:50:28 +0100 (CET) Received: by mail-pj1-f66.google.com with SMTP id n96so5872574pjc.3 for ; Tue, 14 Jan 2020 07:50:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l4ei9G0aYhcrB5XYKMANCst3sqlc6otIqM6Pk7xkduo=; b=JeWcPZDdLuEZtkzhKe5insh/A6dqtgEJd1JO8KPJOCv3oNra6M4plWspvbCa56w15v kYbnneYrM/Y9/sn9Z+tbC778w9/c9Ltl2aSYok/gHTWj/jKtXW4CR13fQf1EViK55JwK C5uO9UCSUJT3G3K5i0/QV1dRAbzcojyGQd7n0H6DpGCFTeLJeP5I/tWFFZGGbueVczBF vf9RidiWkqygwtlltq6Klhf+ykGML5MauJVinlPsntHEx9G5t2ONu6ju3BxY7IPd2qfD 0P9Mn+JD5/xafwOnA6tTJzp9uNaCUgrvAnBnlYJUxXu7vihUuxnspnVAQYj5w8pKo3Y9 2EvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=l4ei9G0aYhcrB5XYKMANCst3sqlc6otIqM6Pk7xkduo=; b=SU+HWEDn1W0wH30ASG/pIFlllgxSlJpNxWDt5o9eqVYfXVfRdWXlJWPylMbvOIA9Q/ 8JrBiNPNRmER74ZvWpeOF/lTfHTRPn7D86ztA2cpofv4Jsl4BiaIPQ0QXZ7m8+eYpm+z V92Z+GUzpQFtwyTEpYnmZb2z7WW8y/wisllOlh18i7SzrMfVbDFIAajPZKK0d7Z9QdTk wqEOpYl7ie2aNOZfsSuDOfi/Nymmwbw+pHP+aavGpPjfim8Y1ouWkHNwkglCdHZKHT7K yLmr5s9CkH+J1msosxi58BJM4n5lJOLTwwPKsXPxYI7FG6noBbRESuViH4S+Zcmmz+ZU 5mBw== X-Gm-Message-State: APjAAAXhZBqjQZpD3Km66EIhZeTqYcZi+BPFecXEDDp972Jw/ZUcvqk4 TFPJke2PMUHGNmo1/ymg4g6DiQ== X-Google-Smtp-Source: APXvYqzWGdQ0QLhTNfwZTwkEpKMwM8/ywF+7c8Y/SFCwlx8vg9fRIfjWsfcloNSMljA8A13R6HqeAA== X-Received: by 2002:a17:90a:b10b:: with SMTP id z11mr30366339pjq.132.1579017027735; Tue, 14 Jan 2020 07:50:27 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id d23sm17980916pfo.176.2020.01.14.07.50.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2020 07:50:27 -0800 (PST) Date: Tue, 14 Jan 2020 07:50:17 -0800 From: Stephen Hemminger To: Viacheslav Ovsiienko Cc: dev@dpdk.org, matan@mellanox.com, rasland@mellanox.com, orika@mellanox.com, shahafs@mellanox.com, olivier.matz@6wind.com Message-ID: <20200114075017.1d7fe291@hermes.lan> In-Reply-To: <1578993305-15165-2-git-send-email-viacheslavo@mellanox.com> References: <20191118094938.192850-1-shahafs@mellanox.com> <1578993305-15165-1-git-send-email-viacheslavo@mellanox.com> <1578993305-15165-2-git-send-email-viacheslavo@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 1/4] mbuf: detach mbuf with pinned external buffer 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" On Tue, 14 Jan 2020 09:15:02 +0000 Viacheslav Ovsiienko wrote: > +/** > + * Returns TRUE if given mbuf has an pinned external buffer, or FALSE > + * otherwise. The pinned external buffer is allocated at pool creation > + * time and should not be freed. > + * > + * External buffer is a user-provided anonymous buffer. > + */ > +#ifdef ALLOW_EXPERIMENTAL_API > +#define RTE_MBUF_HAS_PINNED_EXTBUF(mb) rte_mbuf_has_pinned_extbuf(mb) > +#else > +#define RTE_MBUF_HAS_PINNED_EXTBUF(mb) false > +#endif This is worse than just letting new code in. If you have to use conditional compilation, then please base it off an config value. And make the resulting function an inline, this avoid introducing yet another macro. MACROS ARE HARDER TO READ. #ifdef RTE_CONFIG_MBUF_PINNED static inline bool rte_mbuf_has_pinned_extbuf(const struct rte_mbuf *m) { ... } #else static inline bool rte_mbuf_has_pinned_extbuf(const struct rte_mbuf *m) { return false; } #endif > +__rte_experimental > +static inline uint32_t > +rte_mbuf_has_pinned_extbuf(const struct rte_mbuf *m) > +{ > + if (RTE_MBUF_HAS_EXTBUF(m)) { > + /* > + * The mbuf has the external attached buffer, > + * we should check the type of the memory pool where > + * the mbuf was allocated from. > + */ > + struct rte_pktmbuf_pool_private *priv = > + (struct rte_pktmbuf_pool_private *) > + rte_mempool_get_priv(m->pool); Since rte_mempool_get_priv() returns void *, the cast is unnecessary in standard C. Maybe you still need it for people using rte_mbuf.h in C++