From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 14261A0A02; Tue, 27 Apr 2021 15:57:31 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CFE004124C; Tue, 27 Apr 2021 15:57:30 +0200 (CEST) Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mails.dpdk.org (Postfix) with ESMTP id A2C6A41243 for ; Tue, 27 Apr 2021 15:57:29 +0200 (CEST) Received: by mail-wr1-f42.google.com with SMTP id n2so6416298wrm.0 for ; Tue, 27 Apr 2021 06:57:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vos3FyYYsV04l2bLFI52GjyRQbLDhDV0DMug0ubWDeE=; b=Nip68lZJtHHogTtSM3T68BX2vHYRlbcGt/ssGzdW+3tnz5Q0hv+zD6yoC7GScgjQkM vf0XVSetKfcT3VYYu+SgoxjLvQ+vya4zx5K3EBztP6FMgZmSeSteRRr3v1TF6PLX0wdI QFHzzpgkzB/Rx8RlX9iOmxI4+u6EEyqK7C0WlnRQxDJ04BvAhmzc+R03IGTQszFizoX5 Nvn2dq17eeeoDbeWXg6Qfb+tBgzrjuDprWR4bH9RKB6I5VVx3i9pfb7dwe7HSgHnMAKA ckX9hDM8H5YE2X8Vyw3zUak9GaVKSsywUe/YjfcwM4VuMr56aypEmFPC2+aVlz+vqgWe P+aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vos3FyYYsV04l2bLFI52GjyRQbLDhDV0DMug0ubWDeE=; b=AlLlC703cqhxXxwrwRHiH0TtMEFO9OeJRCU5urreXqbqdf7vUv6lLuiG0GzWqhSf6V TrJKD5dOxQTzz1Z+rqETRB73SpziIVjRm4S/rbv3WDyYkmM6iCd7LHg6d+vSdQGWScJC s+bX0tqJiwKy8O+m6SvQvMJCtYRl7SJGvys9ZR/oGwhcf7mxkAv5Kru8xL46SENL8h2M 5dGwE4IY6ODxqrkV5fg0b+8WbbpeKJpWnU/MMHFBFy8jFcP9TibaWuUmUKi1CtTnW8Jk iu1TE7GvwgdsHHFJAWzaVK9LBVWHPCMarTeDuOaHAwdxysnkX7b8IQgNUwXm+nQysPu1 RZyA== X-Gm-Message-State: AOAM530P5zcKpdXT3At5Aslp1oB2F8GPnKWhncpTOfyBJnjkmr9raRI7 CebKEtHPs9XAvu7vCi+iN52UK8YNLOS9iw== X-Google-Smtp-Source: ABdhPJwKb4lxb2LsMTpxjH3g45QZ6ltPL43lsNv5R0mJVo/5xs42WgGYxQwdBdKv8vqw4K+HzEzCfQ== X-Received: by 2002:a05:6000:10:: with SMTP id h16mr8717009wrx.381.1619531849435; Tue, 27 Apr 2021 06:57:29 -0700 (PDT) Received: from gojira.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id m14sm11760341wmi.39.2021.04.27.06.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 06:57:29 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Andrew Rybchenko , Pallantla Poornima , Wenwu Ma , Peng Zhihong , Aaron Conole , Thomas Monjalon Date: Tue, 27 Apr 2021 15:56:46 +0200 Message-Id: <20210427135646.871-2-olivier.matz@6wind.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427135646.871-1-olivier.matz@6wind.com> References: <20210413200513.330399-1-wenwux.ma@intel.com> <20210427135646.871-1-olivier.matz@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 2/2] mbuf: better document usage of packet pool initializers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Clarify that the mempool private initializer and object initializer used for packet pools require that the mempool private size is large enough. Also add an assert (only enabled when -DRTE_ENABLE_ASSERT is passed) to check this constraint. Signed-off-by: Olivier Matz --- lib/mbuf/rte_mbuf.c | 5 +++++ lib/mbuf/rte_mbuf.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/mbuf/rte_mbuf.c b/lib/mbuf/rte_mbuf.c index 3ff0a69187..f7e3c1a187 100644 --- a/lib/mbuf/rte_mbuf.c +++ b/lib/mbuf/rte_mbuf.c @@ -43,6 +43,8 @@ rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg) struct rte_pktmbuf_pool_private default_mbp_priv; uint16_t roomsz; + RTE_ASSERT(mp->private_data_size >= + sizeof(struct rte_pktmbuf_pool_private)); RTE_ASSERT(mp->elt_size >= sizeof(struct rte_mbuf)); /* if no structure is provided, assume no mbuf private area */ @@ -83,6 +85,9 @@ rte_pktmbuf_init(struct rte_mempool *mp, struct rte_mbuf *m = _m; uint32_t mbuf_size, buf_len, priv_size; + RTE_ASSERT(mp->private_data_size >= + sizeof(struct rte_pktmbuf_pool_private)); + priv_size = rte_pktmbuf_priv_size(mp); mbuf_size = sizeof(struct rte_mbuf) + priv_size; buf_len = rte_pktmbuf_data_room_size(mp); diff --git a/lib/mbuf/rte_mbuf.h b/lib/mbuf/rte_mbuf.h index c4c9ebfaa0..a555f216ae 100644 --- a/lib/mbuf/rte_mbuf.h +++ b/lib/mbuf/rte_mbuf.h @@ -624,6 +624,9 @@ rte_mbuf_raw_free(struct rte_mbuf *m) * address, and so on). This function is given as a callback function to * rte_mempool_obj_iter() or rte_mempool_create() at pool creation time. * + * This function expects that the mempool private area was previously + * initialized with rte_pktmbuf_pool_init(). + * * @param mp * The mempool from which mbufs originate. * @param opaque_arg @@ -639,7 +642,7 @@ void rte_pktmbuf_init(struct rte_mempool *mp, void *opaque_arg, void *m, unsigned i); /** - * A packet mbuf pool constructor. + * A packet mbuf pool constructor. * * This function initializes the mempool private data in the case of a * pktmbuf pool. This private data is needed by the driver. The @@ -648,6 +651,9 @@ void rte_pktmbuf_init(struct rte_mempool *mp, void *opaque_arg, * pool creation. It can be extended by the user, for example, to * provide another packet size. * + * The mempool private area size must be at least equal to + * sizeof(struct rte_pktmbuf_pool_private). + * * @param mp * The mempool from which mbufs originate. * @param opaque_arg -- 2.29.2