On Feb 21, 2014, at 11:41 AM, Jarno Rajahalme <jrajaha...@nicira.com> wrote:

> Minimize padding in sw_flow_key and move 'tp' top the main struct.
> These changes simplify code when accessing the transport port numbers
> and the tcp flags, and makes the sw_flow_key 8 bytes smaller on 64-bit
> systems (128->120 bytes).  These changes also make the keys for IPv4
> packets to fit in one cache line.
> 
> There is a valid concern for safety of packing the struct
> ovs_key_ipv4_tunnel, as it would be possible to take the address of
> the tun_id member as a __be64 * which could result in unaligned access
> in some systems. However:
> 
> - sw_flow_key itself is 64-bit aligned, so the tun_id within is always
>  64-bit aligned.
> - We never make arrays of ovs_key_ipv4_tunnel (which would force every
>  second tun_key to be misaligned).
> - We never take the address of the tun_id in to a __be64 *.
> - Whereever we use struct ovs_key_ipv4_tunnel outside the sw_flow_key,
>  it is in stack (on tunnel input functions), where compiler has full
>  control of the alignment.
> 
> Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com>
> ---
> datapath/datapath.c     |    6 +++
> datapath/flow.c         |   44 ++++++++-----------
> datapath/flow.h         |   29 +++++-------
> datapath/flow_netlink.c |  112 ++++++++++++++---------------------------------
> 4 files changed, 68 insertions(+), 123 deletions(-)
> 
> diff --git a/datapath/datapath.c b/datapath/datapath.c
> index 130300f..8a2c0af 100644
> --- a/datapath/datapath.c
> +++ b/datapath/datapath.c
> @@ -1929,6 +1929,12 @@ static int __init dp_init(void)
>       pr_info("Open vSwitch switching datapath %s, built "__DATE__" 
> "__TIME__"\n",
>               VERSION);
> 
> +     pr_info("Datapath sw_flow_key size: %ld bytes. ip.frag at %ld, tp.flags 
> at %ld, ipv4.addr at %ld\n",
> +             sizeof(struct sw_flow_key),
> +             offsetof(struct sw_flow_key, ip.frag),
> +             offsetof(struct sw_flow_key, tp.flags),
> +             offsetof(struct sw_flow_key, ipv4.addr));
> +

This is some debugging I accidentally left in, will removeā€¦

  Jarno

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to