tunnel: Geneve TLV handling support for OpenFlow.
[cascardo/ovs.git] / lib / flow.h
index dd989ee..384a031 100644 (file)
@@ -32,13 +32,14 @@ struct dpif_flow_stats;
 struct ds;
 struct flow_wildcards;
 struct minimask;
-struct ofpbuf;
+struct dp_packet;
 struct pkt_metadata;
+struct match;
 
 /* This sequence number should be incremented whenever anything involving flows
  * or the wildcarding of flows changes.  This will cause build assertion
  * failures in places which likely need to be updated. */
-#define FLOW_WC_SEQ 30
+#define FLOW_WC_SEQ 32
 
 /* Number of Open vSwitch extension 32-bit registers. */
 #define FLOW_N_REGS 8
@@ -156,7 +157,7 @@ BUILD_ASSERT_DECL(sizeof(struct flow) % sizeof(uint64_t) == 0);
 /* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */
 BUILD_ASSERT_DECL(offsetof(struct flow, igmp_group_ip4) + sizeof(uint32_t)
                   == sizeof(struct flow_tnl) + 192
-                  && FLOW_WC_SEQ == 30);
+                  && FLOW_WC_SEQ == 32);
 
 /* Incremental points at which flow classification may be performed in
  * segments.
@@ -179,25 +180,11 @@ BUILD_ASSERT_DECL(FLOW_SEGMENT_3_ENDS_AT < sizeof(struct flow));
 
 extern const uint8_t flow_segment_u64s[];
 
-/* Represents the metadata fields of struct flow. */
-struct flow_metadata {
-    uint32_t dp_hash;                /* Datapath computed hash field. */
-    uint32_t recirc_id;              /* Recirculation ID. */
-    ovs_be64 tun_id;                 /* Encapsulating tunnel ID. */
-    ovs_be32 tun_src;                /* Tunnel outer IPv4 src addr */
-    ovs_be32 tun_dst;                /* Tunnel outer IPv4 dst addr */
-    ovs_be64 metadata;               /* OpenFlow 1.1+ metadata field. */
-    uint32_t regs[FLOW_N_REGS];      /* Registers. */
-    uint32_t pkt_mark;               /* Packet mark. */
-    ofp_port_t in_port;              /* OpenFlow port or zero. */
-};
-
-void flow_extract(struct ofpbuf *, const struct pkt_metadata *md,
-                  struct flow *);
+void flow_extract(struct dp_packet *, struct flow *);
 
 void flow_zero_wildcards(struct flow *, const struct flow_wildcards *);
 void flow_unwildcard_tp_ports(const struct flow *, struct flow_wildcards *);
-void flow_get_metadata(const struct flow *, struct flow_metadata *);
+void flow_get_metadata(const struct flow *, struct match *flow_metadata);
 
 char *flow_to_string(const struct flow *);
 void format_flags(struct ds *ds, const char *(*bit_to_string)(uint32_t),
@@ -230,7 +217,7 @@ void flow_set_mpls_tc(struct flow *, int idx, uint8_t tc);
 void flow_set_mpls_bos(struct flow *, int idx, uint8_t stack);
 void flow_set_mpls_lse(struct flow *, int idx, ovs_be32 lse);
 
-void flow_compose(struct ofpbuf *, const struct flow *);
+void flow_compose(struct dp_packet *, const struct flow *);
 
 static inline uint64_t
 flow_get_xreg(const struct flow *flow, int idx)
@@ -449,8 +436,7 @@ struct pkt_metadata;
 /* The 'dst->values' must be initialized with a buffer with space for
  * FLOW_U64S.  'dst->map' is ignored on input and set on output to
  * indicate which fields were extracted. */
-void miniflow_extract(struct ofpbuf *packet, const struct pkt_metadata *,
-                      struct miniflow *dst);
+void miniflow_extract(struct dp_packet *packet, struct miniflow *dst);
 void miniflow_init(struct miniflow *, const struct flow *);
 void miniflow_init_with_minimask(struct miniflow *, const struct flow *,
                                  const struct minimask *);
@@ -744,19 +730,15 @@ flow_union_with_miniflow(struct flow *dst, const struct miniflow *src)
     }
 }
 
-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 void
+pkt_metadata_from_flow(struct pkt_metadata *md, const struct flow *flow)
+{
+    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;
 }
 
 static inline bool is_ip_any(const struct flow *flow)