From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by dpdk.org (Postfix) with ESMTP id B18065FEB for ; Mon, 20 Apr 2015 17:41:50 +0200 (CEST) Received: by wiun10 with SMTP id n10so96677665wiu.1 for ; Mon, 20 Apr 2015 08:41:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LvpzTp47HSI1t+o2lJ4tP1vjCeMeaV+SLTO/PrBL5ok=; b=TlAIj2H6hquvIyLFMt69DZB6PJvd22ro5JAVtbVFxcPs/r2IuKdSjfmvs+pbs8KIyh pSluAPh5IQu85Ec/A8lQvhsDtIY3iqFuaxwcUHED8NDXFZ+Vlje+5x0pkUDQZ6PN5Ril idNPthEM5rrIZZsjE78ZMRrz9VXqqFosqNE2FxbfAjO8r1db28btT2K0Ki/5sZKO+YU8 zj7Pl1Sz7UchjDjXN+JuJp4khb1e3xBVGu3762VopTk0F2qkVegPqIFPOUJSI9zVg1mE 2GANPzzyUsxYW6v5iUDohw8Dyrs94SyrrZII32c+naWpWAwJgfA07qiD4xZeQIR68F9n 7oXQ== X-Gm-Message-State: ALoCoQn6lrOPSdJ/TG2DZapSLvO4kwWniLhr1kAo7Hlw6vHzW7mwo3Cb1GsK5ijstaGrs+vJWS+V X-Received: by 10.180.35.234 with SMTP id l10mr21351152wij.72.1429544510625; Mon, 20 Apr 2015 08:41:50 -0700 (PDT) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id fm8sm11258951wib.9.2015.04.20.08.41.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Apr 2015 08:41:50 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Mon, 20 Apr 2015 17:41:28 +0200 Message-Id: <1429544496-22532-5-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429544496-22532-1-git-send-email-olivier.matz@6wind.com> References: <1427829784-12323-2-git-send-email-zer0@droids-corp.org> <1429544496-22532-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v4 04/12] mbuf: fix rte_pktmbuf_init when mbuf private size is not zero X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Apr 2015 15:41:50 -0000 Allow the user to use the default rte_pktmbuf_init() function even if the mbuf private size is not 0. Signed-off-by: Olivier Matz --- lib/librte_mbuf/rte_mbuf.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 231cfb8..d7f0380 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -119,16 +119,19 @@ rte_pktmbuf_init(struct rte_mempool *mp, __attribute__((unused)) unsigned i) { struct rte_mbuf *m = _m; - uint32_t buf_len = mp->elt_size - sizeof(struct rte_mbuf); + uint32_t mbuf_size, buf_len; - RTE_MBUF_ASSERT(mp->elt_size >= sizeof(struct rte_mbuf)); + mbuf_size = sizeof(struct rte_mbuf) + rte_pktmbuf_priv_size(mp); + buf_len = rte_pktmbuf_data_room_size(mp); + + RTE_MBUF_ASSERT(mp->elt_size >= mbuf_size); + RTE_MBUF_ASSERT(buf_len <= 0xffff); memset(m, 0, mp->elt_size); /* start of buffer is just after mbuf structure */ - m->buf_addr = (char *)m + sizeof(struct rte_mbuf); - m->buf_physaddr = rte_mempool_virt2phy(mp, m) + - sizeof(struct rte_mbuf); + m->buf_addr = (char *)m + mbuf_size; + m->buf_physaddr = rte_mempool_virt2phy(mp, m) + mbuf_size; m->buf_len = (uint16_t)buf_len; /* keep some headroom between start of buffer and data */ -- 2.1.4