lib/ofpbuf: Compact
authorJarno Rajahalme <jrajahalme@nicira.com>
Mon, 24 Mar 2014 16:17:01 +0000 (09:17 -0700)
committerJarno Rajahalme <jrajahalme@nicira.com>
Sun, 30 Mar 2014 00:22:19 +0000 (17:22 -0700)
commit437d0d22ab42d4101157b48a75fa844e7039e326
treeaaa1a5ddd0d48576cd03eca870a490756b7a03e5
parentd81eef1b874c3c51669fa56f57e69ba5e77ad2c5
lib/ofpbuf: Compact

This patch shrinks the struct ofpbuf from 104 to 48 bytes on 64-bit
systems, or from 52 to 36 bytes on 32-bit systems (counting in the
'l7' removal from an earlier patch).  This may help contribute to
cache efficiency, and will speed up initializing, copying and
manipulating ofpbufs.  This is potentially important for the DPDK
datapath, but the rest of the code base may also see a little benefit.

Changes are:

- Remove 'l7' pointer (previous patch).
- Use offsets instead of layer pointers for l2_5, l3, and l4 using
  'l2' as basis.  Usually 'data' is the same as 'l2', but this is not
  always the case (e.g., when parsing or constructing a packet), so it
  can not be easily used as the offset basis.  Also, packet parsing is
  faster if we do not need to maintain the offsets each time we pull
  data from the ofpbuf.
- Use uint32_t for 'allocated' and 'size', as 2^32 is enough even for
  largest possible messages/packets.
- Use packed enum for 'source'.
- Rearrange to avoid unnecessary padding.
- Remove 'private_p', which was used only in two cases, both of which
  had the invariant ('l2' == 'data'), so we can temporarily use 'l2'
  as a private pointer.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
23 files changed:
lib/cfm.c
lib/flow.c
lib/lacp.c
lib/netlink.c
lib/nx-match.c
lib/odp-execute.c
lib/ofp-actions.c
lib/ofp-msgs.c
lib/ofp-print.c
lib/ofp-util.c
lib/ofpbuf.c
lib/ofpbuf.h
lib/packets.c
lib/pcap-file.c
lib/rconn.c
lib/stp.c
lib/util.h
ofproto/ofproto-dpif.c
ofproto/ofproto-provider.h
tests/test-netflow.c
tests/test-odp.c
tests/test-stp.c
utilities/ovs-ofctl.c