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 17584A034D; Thu, 6 Jan 2022 10:48:47 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5627F4114D; Thu, 6 Jan 2022 10:48:43 +0100 (CET) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mails.dpdk.org (Postfix) with ESMTP id C901441144 for ; Thu, 6 Jan 2022 10:48:42 +0100 (CET) Received: by mail-wr1-f51.google.com with SMTP id k18so3596851wrg.11 for ; Thu, 06 Jan 2022 01:48:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=QuZGEoh3jhNu2Frp+7yq8D4wo0iHgTQ+uLg1zBa/vME=; b=hUoPpOlBXxItz9CRarsLHo+xDkM40Ed8aZquv+o2qCgEk/Xb3Mx1J7t78zBMr24a8V B8IOxKV1Ub7n4TmbKq0SJRRjYOHOQpUxCPIzlqvA3hGUwpDYzXAWGjZqBZao61bfuTvN NXTtuwiXihovNXyGLj64UaMl1+U4DP6eNA8VZg4j0I4EjzqKxGHhPVk2MMPYb+bUlJCK gvLxLzScXQHKdDLSW7zuRtGc6iS3RE7tj1jvx3YV8XmhMgvo+FELMwEa8MsBf64yJedF cHaUjEONO+UtulsAssMriseljmnm1Cz5NPGr7FHptq+m+gXZKwu9ZOi9e9ecll42BSee 2RWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=QuZGEoh3jhNu2Frp+7yq8D4wo0iHgTQ+uLg1zBa/vME=; b=mtSZxfSUbnF35f+CzvgI4bQYISRSksn7sqdnM2iobrXr4O5uqswxEgQNHg7t0jwSle PguGCjJAyRmvTjcaA1w6Q+1g5GCPRvOTEQccNvSQMoVCF84ZmKWEZGCCbaA6rAinEuZo kafd9ch+BIGjK/OmAjlu7T3dz77AaHlqub9Ha7x8cb9GTlqYlqVJUVjamVt5CtGpbClZ 6SWokO7NvChznjYtb8p2oFDb/9TX+aEwMwfqYyWFx98IMMkEx0e8uqbB3AevJQfQDJjp NU7qqJkG3SYo9ejQpx5mq2Wgi87FEuHGBXHqFm8p2xnpqEYlRkGOQqvVHMxhJu+5I4+C GDcg== X-Gm-Message-State: AOAM533w8S1hvk6cljoDBZeqF4AbSrfTmvFGgUmUGxBAagGjrTB3xIWL lc5xWcH7JfwE9HtI7crPai4n4OMFzrZWrg== X-Google-Smtp-Source: ABdhPJy38/MR2hRyorlMCMJTmAnpbnln7q6VV4UvnR/3lPXwm10Zs7TFg/sFXdaCPdMXmPB6ckzJtQ== X-Received: by 2002:a5d:4b07:: with SMTP id v7mr2192275wrq.668.1641462522617; Thu, 06 Jan 2022 01:48:42 -0800 (PST) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id ay39sm1279207wmb.29.2022.01.06.01.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 01:48:42 -0800 (PST) Date: Thu, 6 Jan 2022 10:48:41 +0100 From: Olivier Matz To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: dev@dpdk.org Subject: Re: mbuf headroom question Message-ID: References: <98CBD80474FA8B44BF855DF32C47DC35D86DE0@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D86DE0@smartserver.smartshare.dk> 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 Hi Morten, On Thu, Jan 06, 2022 at 10:29:11AM +0100, Morten Brørup wrote: > Hi Olivier, > > The data_room_size parameter description for the mbuf pool creation functions says: > "Size of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM." > > Furthermore, both rte_mbuf_data_iova_default() and rte_mbuf_data_addr_default() simply add RTE_PKTMBUF_HEADROOM to the return value. > > Based on the above, I would think that it is impossible for m->buf_len to be smaller than RTE_PKTMBUF_HEADROOM. > > So why does rte_pktmbuf_reset_headroom() use RTE_MIN(m->buf_len, RTE_PKTMBUF_HEADROOM), instead of just RTE_PKTMBUF_HEADROOM? What am I missing here? It is legal to create a packet pool that has no data buffer: this pool can be used to allocate packets clones that will be attached to mbufs containing data. There is an example in test_mbuf.c. It is also technically possible to create a packet pool with small mbufs (whose buffer length is less than RTE_PKTMBUF_HEADROOM). These mbufs cannot be used by drivers which use rte_mbuf_data_iova_default(), but they could be used internally. To create valid mbufs in these 2 cases, this is why RTE_MIN(m->buf_len, RTE_PKTMBUF_HEADROOM) is used ; "valid" means that headroom is not larger than buffer length. Olivier