+
+\f
+/* Returns true if 'mask' matches every packet, false if 'mask' fixes any bits
+ * or fields. */
+static inline bool
+minimask_is_catchall(const struct minimask *mask)
+{
+ /* For every 1-bit in mask's map, the corresponding value is non-zero,
+ * so the only way the mask can not fix any bits or fields is for the
+ * map the be zero. */
+ return mask->masks.map == 0;
+}
+
+/* Returns the VID within the vlan_tci member of the "struct flow" represented
+ * by 'flow'. */
+static inline uint16_t
+miniflow_get_vid(const struct miniflow *flow)
+{
+ ovs_be16 tci = MINIFLOW_GET_BE16(flow, vlan_tci);
+ return vlan_tci_to_vid(tci);
+}
+
+/* Returns the VID mask within the vlan_tci member of the "struct
+ * flow_wildcards" represented by 'mask'. */
+static inline uint16_t
+minimask_get_vid_mask(const struct minimask *mask)
+{
+ return miniflow_get_vid(&mask->masks);
+}
+
+/* Returns the value of the "tcp_flags" field in 'flow'. */
+static inline uint16_t
+miniflow_get_tcp_flags(const struct miniflow *flow)
+{
+ return ntohs(MINIFLOW_GET_BE16(flow, tcp_flags));
+}
+
+/* Returns the value of the OpenFlow 1.1+ "metadata" field in 'flow'. */
+static inline ovs_be64
+miniflow_get_metadata(const struct miniflow *flow)
+{
+ union {
+ ovs_be64 be64;
+ struct {
+ ovs_be32 hi;
+ ovs_be32 lo;
+ };
+ } value;
+
+ enum { MD_OFS = offsetof(struct flow, metadata) };
+ BUILD_ASSERT_DECL(MD_OFS % sizeof(uint32_t) == 0);
+ value.hi = MINIFLOW_GET_TYPE(flow, ovs_be32, MD_OFS);
+ value.lo = MINIFLOW_GET_TYPE(flow, ovs_be32, MD_OFS + 4);
+
+ return value.be64;
+}
+
+/* Returns the mask for the OpenFlow 1.1+ "metadata" field in 'mask'.
+ *
+ * The return value is all-1-bits if 'mask' matches on the whole value of the
+ * metadata field, all-0-bits if 'mask' entirely wildcards the metadata field,
+ * or some other value if the metadata field is partially matched, partially
+ * wildcarded. */
+static inline ovs_be64
+minimask_get_metadata_mask(const struct minimask *mask)
+{
+ return miniflow_get_metadata(&mask->masks);
+}
+
+/* Perform a bitwise OR of miniflow 'src' flow data with the equivalent
+ * fields in 'dst', storing the result in 'dst'. */
+static inline void
+flow_union_with_miniflow(struct flow *dst, const struct miniflow *src)
+{
+ uint32_t *dst_u32 = (uint32_t *) dst;
+ const uint32_t *p = miniflow_get_u32_values(src);
+ uint64_t map;
+
+ for (map = src->map; map; map = zero_rightmost_1bit(map)) {
+ dst_u32[raw_ctz(map)] |= *p++;
+ }
+}
+
+static inline struct pkt_metadata
+pkt_metadata_from_flow(const struct flow *flow)
+{
+ struct pkt_metadata md;
+
+ md.recirc_id = flow->recirc_id;
+ md.dp_hash = flow->dp_hash;
+ md.tunnel = flow->tunnel;
+ md.skb_priority = flow->skb_priority;
+ md.pkt_mark = flow->pkt_mark;
+ md.in_port = flow->in_port;
+
+ return md;
+}
+
+static inline bool is_ip_any(const struct flow *flow)
+{
+ return dl_type_is_ip_any(flow->dl_type);
+}
+
+static inline bool is_icmpv4(const struct flow *flow)
+{
+ return (flow->dl_type == htons(ETH_TYPE_IP)
+ && flow->nw_proto == IPPROTO_ICMP);
+}
+
+static inline bool is_icmpv6(const struct flow *flow)
+{
+ return (flow->dl_type == htons(ETH_TYPE_IPV6)
+ && flow->nw_proto == IPPROTO_ICMPV6);
+}
+
+static inline bool is_stp(const struct flow *flow)
+{
+ return (eth_addr_equals(flow->dl_dst, eth_addr_stp)
+ && flow->dl_type == htons(FLOW_DL_TYPE_NONE));
+}