[ovs-dev] [nxm 08/42] flow: Un-inline flow_wildcards functions.

Justin Pettit jpettit at nicira.com
Thu Oct 28 21:18:13 UTC 2010


Looks good.

--Justin


On Oct 28, 2010, at 10:27 AM, Ben Pfaff wrote:

> These functions really seem too big to inline.
> ---
> lib/flow.c |   27 +++++++++++++++++++++++++++
> lib/flow.h |   25 ++-----------------------
> 2 files changed, 29 insertions(+), 23 deletions(-)
> 
> diff --git a/lib/flow.c b/lib/flow.c
> index 2ba41c3..6bd9ffa 100644
> --- a/lib/flow.c
> +++ b/lib/flow.c
> @@ -348,3 +348,30 @@ flow_print(FILE *stream, const struct flow *flow)
>     fputs(s, stream);
>     free(s);
> }
> +
> +/* flow_wildcards functions. */
> +
> +/* Given the wildcard bit count in bits 'shift' through 'shift + 5' (inclusive)
> + * of 'wildcards', returns a 32-bit bit mask with a 1 in each bit that must
> + * match and a 0 in each bit that is wildcarded.
> + *
> + * The bits in 'wildcards' are in the format used in enum ofp_flow_wildcards: 0
> + * is exact match, 1 ignores the LSB, 2 ignores the 2 least-significant bits,
> + * ..., 32 and higher wildcard the entire field.  This is the *opposite* of the
> + * usual convention where e.g. /24 indicates that 8 bits (not 24 bits) are
> + * wildcarded. */
> +ovs_be32
> +flow_nw_bits_to_mask(uint32_t wildcards, int shift)
> +{
> +    wildcards = (wildcards >> shift) & 0x3f;
> +    return wildcards < 32 ? htonl(~((1u << wildcards) - 1)) : 0;
> +}
> +
> +void
> +flow_wildcards_init(struct flow_wildcards *wc, uint32_t wildcards)
> +{
> +    wc->wildcards = wildcards & OVSFW_ALL;
> +    wc->nw_src_mask = flow_nw_bits_to_mask(wc->wildcards, OFPFW_NW_SRC_SHIFT);
> +    wc->nw_dst_mask = flow_nw_bits_to_mask(wc->wildcards, OFPFW_NW_DST_SHIFT);
> +}
> +
> diff --git a/lib/flow.h b/lib/flow.h
> index df16a77..ba37681 100644
> --- a/lib/flow.h
> +++ b/lib/flow.h
> @@ -95,28 +95,7 @@ struct flow_wildcards {
>     ovs_be32 nw_dst_mask;       /* 1-bit in each significant nw_dst bit. */
> };
> 
> -/* Given the wildcard bit count in bits 'shift' through 'shift + 5' (inclusive)
> - * of 'wildcards', returns a 32-bit bit mask with a 1 in each bit that must
> - * match and a 0 in each bit that is wildcarded.
> - *
> - * The bits in 'wildcards' are in the format used in enum ofp_flow_wildcards: 0
> - * is exact match, 1 ignores the LSB, 2 ignores the 2 least-significant bits,
> - * ..., 32 and higher wildcard the entire field.  This is the *opposite* of the
> - * usual convention where e.g. /24 indicates that 8 bits (not 24 bits) are
> - * wildcarded. */
> -static inline ovs_be32
> -flow_nw_bits_to_mask(uint32_t wildcards, int shift)
> -{
> -    wildcards = (wildcards >> shift) & 0x3f;
> -    return wildcards < 32 ? htonl(~((1u << wildcards) - 1)) : 0;
> -}
> -
> -static inline void
> -flow_wildcards_init(struct flow_wildcards *wc, uint32_t wildcards)
> -{
> -    wc->wildcards = wildcards & OVSFW_ALL;
> -    wc->nw_src_mask = flow_nw_bits_to_mask(wc->wildcards, OFPFW_NW_SRC_SHIFT);
> -    wc->nw_dst_mask = flow_nw_bits_to_mask(wc->wildcards, OFPFW_NW_DST_SHIFT);
> -}
> +ovs_be32 flow_nw_bits_to_mask(uint32_t wildcards, int shift);
> +void flow_wildcards_init(struct flow_wildcards *, uint32_t wildcards);
> 
> #endif /* flow.h */
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list