From: Ben Pfaff Date: Mon, 2 Mar 2009 19:44:50 +0000 (-0800) Subject: New function and data structure for handling flow wildcards. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3dfd39bf72af6ec87feca21129dbe1ca7cfd1f67;p=openvswitch New function and data structure for handling flow wildcards. --- diff --git a/lib/flow.h b/lib/flow.h index bf3aaa88..66479099 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -37,6 +37,7 @@ #include #include #include +#include "openflow/openflow.h" #include "hash.h" #include "util.h" @@ -93,6 +94,13 @@ flow_hash(const struct flow *flow, uint32_t basis) sizeof *flow / sizeof(uint32_t), basis); } +/* Information on wildcards for a flow, as a supplement to flow_t. */ +struct flow_wildcards { + uint32_t wildcards; /* enum ofp_flow_wildcards (in host order). */ + uint32_t nw_src_mask; /* 1-bit in each significant nw_src bit. */ + uint32_t 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. @@ -112,4 +120,12 @@ flow_nw_bits_to_mask(uint32_t wildcards, int shift) return wildcards < 32 ? htonl(~((1u << wildcards) - 1)) : 0; } +static inline void +flow_wildcards_init(struct flow_wildcards *wc, uint32_t wildcards) +{ + wc->wildcards = wildcards & OFPFW_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); +} + #endif /* flow.h */