[ovs-dev,4/9] dp-packet: Add flow_mark support for non-DPDK case.

Message ID 20181029124926.12199-5-i.maximets@samsung.com
State Superseded
Headers show
Series
  • dpif-netdev: Partial HWOL fixes/refactoring/unit-tests.
Related show

Commit Message

Ilya Maximets Oct. 29, 2018, 12:49 p.m.
Additionally, new API call 'dp_packet_set_flow_mark' is needed
for packet clone. Mostly for dummy HWOL implementation.

Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
---
 lib/dp-packet.h | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

Patch

diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index 0e04b2302..a8574ae33 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -60,7 +60,9 @@  struct dp_packet {
     uint32_t size_;             /* Number of bytes in use. */
     uint32_t ol_flags;          /* Offloading flags. */
 #define DP_PACKET_OL_RSS_HASH_MASK   0x1 /* Is the 'rss_hash' valid? */
+#define DP_PACKET_OL_FLOW_MARK_MASK  0x2 /* Is the 'flow_mark' valid? */
     uint32_t rss_hash;          /* Packet hash. */
+    uint32_t flow_mark;         /* Packet flow mark. */
 #endif
     enum dp_packet_source source;  /* Source of memory allocated as 'base'. */
 
@@ -537,6 +539,13 @@  dp_packet_has_flow_mark(const struct dp_packet *p, uint32_t *mark)
     return false;
 }
 
+static inline void
+dp_packet_set_flow_mark(struct dp_packet *p, uint32_t mark)
+{
+    p->mbuf.hash.fdir.hi = mark;
+    p->mbuf.ol_flags |= PKT_RX_FDIR_ID;
+}
+
 #else /* DPDK_NETDEV */
 static inline void *
 dp_packet_base(const struct dp_packet *b)
@@ -638,11 +647,21 @@  dp_packet_l4_checksum_bad(const struct dp_packet *p OVS_UNUSED)
 }
 
 static inline bool
-dp_packet_has_flow_mark(const struct dp_packet *p OVS_UNUSED,
-                        uint32_t *mark OVS_UNUSED)
+dp_packet_has_flow_mark(const struct dp_packet *p, uint32_t *mark)
 {
+    if (p->ol_flags & DP_PACKET_OL_FLOW_MARK_MASK) {
+        *mark = p->flow_mark;
+        return true;
+    }
     return false;
 }
+
+static inline void
+dp_packet_set_flow_mark(struct dp_packet *p, uint32_t mark)
+{
+    p->flow_mark = mark;
+    p->ol_flags |= DP_PACKET_OL_FLOW_MARK_MASK;
+}
 #endif /* DPDK_NETDEV */
 
 static inline void