From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by dpdk.org (Postfix) with ESMTP id 6E86CAFCD for ; Mon, 19 May 2014 15:56:47 +0200 (CEST) Received: by mail-wi0-f170.google.com with SMTP id bs8so5248390wib.1 for ; Mon, 19 May 2014 06:56:56 -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=GS/i6lNQPjBJadFlyp/Y1Y9HD1v5lfoEdeObErHWnyc=; b=DEHUNZP4RI858acG62HoS2hN4xzzJXj3nTEyY/GgSmeeABVCRleSaFElW9K1UckRv+ g7h+qh3ioBUvr0WJZc+7Tib2zyEOCRvhgpfz6apP+odP1UM32ZDi78EWD/NPuBrX6RDC +lTSt1XWuCOrPo1WimjzYRcbwFUb++sh4PswBWzT6mvsMNh+U5caRpuuc1wP8wXercWt MhIqV3ckIfMYb32O6N9cBs092UZtJ4VRcPbklwOqj1MlHWquIzofnUdJJFDUam8isr9d SIyJcN64hmXiwVPQ8cosZhZzH5p9blg1o2k/L+t/B8dLeZ2bA7nmkzVBm6tTQ2fStP7n MkLA== X-Gm-Message-State: ALoCoQlw/dksDSvH1gsmZVm6kXiJ1JoB2BJL5Cb4Bvrq9449e5GCofv77PJ1RrpGuKgPds2Ry1bP X-Received: by 10.180.228.100 with SMTP id sh4mr13499287wic.40.1400507816315; Mon, 19 May 2014 06:56:56 -0700 (PDT) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id t18sm15201828wiv.16.2014.05.19.06.56.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 May 2014 06:56:55 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Mon, 19 May 2014 15:56:17 +0200 Message-Id: <1400507789-18453-6-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1400507789-18453-1-git-send-email-olivier.matz@6wind.com> References: <1400507789-18453-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v2 05/17] mbuf: merge physaddr and buf_len in a bitfield 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, 19 May 2014 13:56:47 -0000 The physical address is never greater than (1 << 48) = 256 TB. We can win 2 bytes in the mbuf structure by merging the physical address and the buffer length in the same bitfield. Signed-off-by: Olivier Matz --- lib/librte_mbuf/rte_mbuf.c | 3 ++- lib/librte_mbuf/rte_mbuf.h | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index bc9d462..9c4077a 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -104,7 +104,8 @@ rte_pktmbuf_init(struct rte_mempool *mp, m->buf_len = (uint16_t)buf_len; /* keep some headroom between start of buffer and data */ - m->data = (char*) m->buf_addr + RTE_MIN(RTE_PKTMBUF_HEADROOM, m->buf_len); + m->data = (char*) m->buf_addr + RTE_MIN(RTE_PKTMBUF_HEADROOM, + (uint16_t)m->buf_len); /* init some constant fields */ m->pool = mp; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 0743506..1777b8b 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -130,8 +130,8 @@ union rte_vlan_macip { struct rte_mbuf { struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */ void *buf_addr; /**< Virtual address of segment buffer. */ - phys_addr_t buf_physaddr; /**< Physical address of segment buffer. */ - uint16_t buf_len; /**< Length of segment buffer. */ + uint64_t buf_physaddr:48; /**< Physical address of segment buffer. */ + uint64_t buf_len:16; /**< Length of segment buffer. */ #ifdef RTE_MBUF_REFCNT /** * 16-bit Reference counter. @@ -148,8 +148,9 @@ struct rte_mbuf { #else uint16_t refcnt_reserved; /**< Do not use this field */ #endif - uint16_t reserved; /**< Unused field. Required for padding. */ + uint16_t ol_flags; /**< Offload features. */ + uint32_t reserved; /**< Unused field. Required for padding. */ /* valid for any segment */ struct rte_mbuf *next; /**< Next segment of scattered packet. */ -- 1.9.2