Don't let Keith see that comment. Acked-by: Justin Pettit <jpet...@nicira.com>
--Justin > On Aug 21, 2015, at 8:26 AM, Ben Pfaff <b...@nicira.com> wrote: > > Functions are nicer. > > Signed-off-by: Ben Pfaff <b...@nicira.com> > --- > lib/classifier.c | 2 +- > lib/flow.h | 16 ++++++++++------ > 2 files changed, 11 insertions(+), 7 deletions(-) > > diff --git a/lib/classifier.c b/lib/classifier.c > index e6227b9..a91d936 100644 > --- a/lib/classifier.c > +++ b/lib/classifier.c > @@ -1680,7 +1680,7 @@ check_tries(struct trie_ctx trie_ctx[CLS_MAX_TRIES], > unsigned int n_tries, > uint8_t be64ofs = be32ofs / 2; > > /* Is the trie field within the current range of fields? */ > - if (MINIFLOW_IN_MAP(range_map, be64ofs)) { > + if (miniflow_in_map(range_map, be64ofs)) { > /* On-demand trie lookup. */ > if (!ctx->lookup_done) { > memset(&ctx->match_plens, 0, sizeof ctx->match_plens); > diff --git a/lib/flow.h b/lib/flow.h > index d0a354c..da09c90 100644 > --- a/lib/flow.h > +++ b/lib/flow.h > @@ -599,15 +599,19 @@ miniflow_get__(const struct miniflow *mf, size_t > u64_idx) > : miniflow_values_get__(miniflow_get_values(mf), mf->tnl_map, > u64_idx); > } > > -#define MINIFLOW_IN_MAP(MF, U64_IDX) \ > - (OVS_LIKELY(U64_IDX >= FLOW_TNL_U64S) \ > - ? (MF)->pkt_map & (UINT64_C(1) << ((U64_IDX) - FLOW_TNL_U64S)) \ > - : (MF)->tnl_map & (UINT64_C(1) << (U64_IDX))) > +static inline bool > +miniflow_in_map(const struct miniflow *mf, size_t u64_idx) > +{ > + return (OVS_LIKELY(u64_idx >= FLOW_TNL_U64S) > + ? mf->pkt_map & (UINT64_C(1) << (u64_idx - FLOW_TNL_U64S)) > + : mf->tnl_map & (UINT64_C(1) << u64_idx)) != 0; > + > +} > > /* Get the value of 'FIELD' of an up to 8 byte wide integer type 'TYPE' of > * a miniflow. */ > #define MINIFLOW_GET_TYPE(MF, TYPE, OFS) \ > - (MINIFLOW_IN_MAP(MF, (OFS) / sizeof(uint64_t)) \ > + (miniflow_in_map(MF, (OFS) / sizeof(uint64_t)) \ > ? ((OVS_FORCE const TYPE *)miniflow_get__(MF, (OFS) / sizeof(uint64_t))) > \ > [(OFS) % sizeof(uint64_t) / sizeof(TYPE)] \ > : 0) > @@ -696,7 +700,7 @@ minimask_is_catchall(const struct minimask *mask) > static inline uint64_t miniflow_get(const struct miniflow *flow, > unsigned int u64_ofs) > { > - return MINIFLOW_IN_MAP(flow, u64_ofs) > + return miniflow_in_map(flow, u64_ofs) > ? *miniflow_get__(flow, u64_ofs) : 0; > } > > -- > 2.1.3 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev