From 5436300437bd20c5e8e006fedc55c517cb090de5 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 20 Oct 2010 16:33:10 -0700 Subject: [PATCH] flow: Un-inline flow_wildcards functions. 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 3d0a8eb0..96487765 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 df16a77c..ba376812 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 */ -- 2.30.2