On 4/12/2023 10:07 PM, Eelco Chaudron wrote:
On 29 Mar 2023, at 13:42, Chris Mi wrote:

Iterate each registered offload API. It's not a problem for today
since we only have one implementation.
See comment inline.

//Eelco

Signed-off-by: Chris Mi<[email protected]>
Reviewed-by: Roi Dayan<[email protected]>
---
  lib/netdev-offload.c | 35 +++++++++++++++++++++++++++++++++++
  lib/netdev-offload.h |  5 +++++
  2 files changed, 40 insertions(+)

diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c
index 84503ec8b..ec61e1cc0 100644
--- a/lib/netdev-offload.c
+++ b/lib/netdev-offload.c
@@ -257,6 +257,41 @@ meter_offload_del(ofproto_meter_id meter_id, struct 
ofputil_meter_stats *stats)
      return 0;
  }

+int
+netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf,
+                    uint32_t handler_id)
+{
+    struct netdev_registered_flow_api *rfa;
+    int ret = EAGAIN;
+
+    CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) {
+        if (rfa->flow_api->recv) {
+            ret = rfa->flow_api->recv(upcall, buf, handler_id);
+            if (ret) {
See the previous conversation on not logging on EAGAIN.
                    if (ret != EAGAIN) {

+                VLOG_DBG_RL(&rl, "Failed to receive offload packet, %s, "
+                            "type: %s", ovs_strerror(ret),
+                            rfa->flow_api->type);
+            } else {
+                return ret;
Maybe just return 0; so it's explicit we return ok here? What about (notice 
also the ret change, or else we might return an old error):
Done.
int
netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf,
                     uint32_t handler_id)
{
     struct netdev_registered_flow_api *rfa;
     int ret;
I changed above line to
    int ret = EAGAIN;
to avoid uninitialized error.
     CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) {
         if (rfa->flow_api->recv) {
             ret = rfa->flow_api->recv(upcall, buf, handler_id);
             if (!ret) {
                 return 0;
             }

             if (ret == EAGAIN) {
                 VLOG_DBG_RL(&rl, "Failed to receive offload packet, %s, "
                             "type: %s", ovs_strerror(ret),
                             rfa->flow_api->type);
             }
         } else {
             ret = EAGAIN;
        }
     }
     return ret;
}


+            }
+        }
+    }
+
+    return ret;
+}
+
+void
+netdev_offload_recv_wait(uint32_t handler_id)
+{
+    struct netdev_registered_flow_api *rfa;
+
+    CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) {
+        if (rfa->flow_api->recv_wait) {
+            rfa->flow_api->recv_wait(handler_id);
+        }
+    }
+}
+
  int
  netdev_flow_flush(struct netdev *netdev)
  {
diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h
index edc843cd9..09cdb6db2 100644
--- a/lib/netdev-offload.h
+++ b/lib/netdev-offload.h
@@ -33,6 +33,7 @@ extern "C" {

  struct dp_packet_batch;
  struct dp_packet;
+struct dpif_upcall;
  struct netdev_class;
  struct netdev_rxq;
  struct netdev_saved_flags;
@@ -162,6 +163,10 @@ void meter_offload_set(ofproto_meter_id, struct 
ofputil_meter_config *);
  int meter_offload_get(ofproto_meter_id, struct ofputil_meter_stats *);
  int meter_offload_del(ofproto_meter_id, struct ofputil_meter_stats *);

+int netdev_offload_recv(struct dpif_upcall *upcall, struct ofpbuf *buf,
+                        uint32_t handler_id);
+void netdev_offload_recv_wait(uint32_t handler_id);
+
  #ifdef  __cplusplus
  }
  #endif
--
2.26.3
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to