]> git.proxmox.com Git - mirror_ovs.git/blobdiff - lib/netdev-dummy.c
cirrus: Use FreeBSD 12.2.
[mirror_ovs.git] / lib / netdev-dummy.c
index 3f90ffa09a76bdf7be8f1dfc439db6af088ae009..71df29184d9baf02527ab939e591432c0471fa19 100644 (file)
@@ -24,6 +24,7 @@
 #include "dp-packet.h"
 #include "dpif-netdev.h"
 #include "flow.h"
+#include "netdev-offload-provider.h"
 #include "netdev-provider.h"
 #include "netdev-vport.h"
 #include "odp-util.h"
@@ -1107,7 +1108,7 @@ netdev_dummy_send(struct netdev *netdev, int qid OVS_UNUSED,
         const void *buffer = dp_packet_data(packet);
         size_t size = dp_packet_size(packet);
 
-        if (packet->packet_type != htonl(PT_ETH)) {
+        if (!dp_packet_is_eth(packet)) {
             error = EPFNOSUPPORT;
             break;
         }
@@ -1433,7 +1434,7 @@ netdev_dummy_flow_put(struct netdev *netdev, struct match *match,
                       struct nlattr *actions OVS_UNUSED,
                       size_t actions_len OVS_UNUSED,
                       const ovs_u128 *ufid, struct offload_info *info,
-                      struct dpif_flow_stats *stats OVS_UNUSED)
+                      struct dpif_flow_stats *stats)
 {
     struct netdev_dummy *dev = netdev_dummy_cast(netdev);
     struct offloaded_flow *off_flow;
@@ -1475,12 +1476,15 @@ netdev_dummy_flow_put(struct netdev *netdev, struct match *match,
         ds_destroy(&ds);
     }
 
+    if (stats) {
+        memset(stats, 0, sizeof *stats);
+    }
     return 0;
 }
 
 static int
 netdev_dummy_flow_del(struct netdev *netdev, const ovs_u128 *ufid,
-                      struct dpif_flow_stats *stats OVS_UNUSED)
+                      struct dpif_flow_stats *stats)
 {
     struct netdev_dummy *dev = netdev_dummy_cast(netdev);
     struct offloaded_flow *off_flow;
@@ -1520,13 +1524,12 @@ exit:
         ds_destroy(&ds);
     }
 
+    if (stats) {
+        memset(stats, 0, sizeof *stats);
+    }
     return error ? -1 : 0;
 }
 
-#define DUMMY_FLOW_OFFLOAD_API                          \
-    .flow_put = netdev_dummy_flow_put,                  \
-    .flow_del = netdev_dummy_flow_del
-
 #define NETDEV_DUMMY_CLASS_COMMON                       \
     .run = netdev_dummy_run,                            \
     .wait = netdev_dummy_wait,                          \
@@ -1559,8 +1562,7 @@ exit:
     .rxq_dealloc = netdev_dummy_rxq_dealloc,            \
     .rxq_recv = netdev_dummy_rxq_recv,                  \
     .rxq_wait = netdev_dummy_rxq_wait,                  \
-    .rxq_drain = netdev_dummy_rxq_drain,                \
-    DUMMY_FLOW_OFFLOAD_API
+    .rxq_drain = netdev_dummy_rxq_drain
 
 static const struct netdev_class dummy_class = {
     NETDEV_DUMMY_CLASS_COMMON,
@@ -1578,6 +1580,20 @@ static const struct netdev_class dummy_pmd_class = {
     .is_pmd = true,
     .reconfigure = netdev_dummy_reconfigure
 };
+
+static int
+netdev_dummy_offloads_init_flow_api(struct netdev *netdev)
+{
+    return is_dummy_class(netdev->netdev_class) ? 0 : EOPNOTSUPP;
+}
+
+static const struct netdev_flow_api netdev_offload_dummy = {
+    .type = "dummy",
+    .flow_put = netdev_dummy_flow_put,
+    .flow_del = netdev_dummy_flow_del,
+    .init_flow_api = netdev_dummy_offloads_init_flow_api,
+};
+
 \f
 /* Helper functions. */
 
@@ -2024,5 +2040,7 @@ netdev_dummy_register(enum dummy_level level)
     netdev_register_provider(&dummy_internal_class);
     netdev_register_provider(&dummy_pmd_class);
 
+    netdev_register_flow_api_provider(&netdev_offload_dummy);
+
     netdev_vport_tunnel_register();
 }