On 6/19/23 07:05, Chris Mi wrote:
> Iterate each registered offload API. It's not a problem for today
> since we only have one implementation.
>
> Signed-off-by: Chris Mi <[email protected]>
> Reviewed-by: Roi Dayan <[email protected]>
> ---
> lib/netdev-offload.c | 38 ++++++++++++++++++++++++++++++++++++++
> lib/netdev-offload.h | 5 +++++
> 2 files changed, 43 insertions(+)
>
> diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c
> index 403315deb..1374aa8ac 100644
> --- a/lib/netdev-offload.c
> +++ b/lib/netdev-offload.c
> @@ -257,6 +257,44 @@ 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) {
> + return 0;
> + }
> +
> + if (ret == EAGAIN) {
Should there be '!=' instead?
> + VLOG_DBG_RL(&rl, "Failed to receive offload packet, %s, "
> + "type: %s", ovs_strerror(ret),
> + rfa->flow_api->type);
> + }
> + } else {
> + ret = EAGAIN;
> + }
> + }
> + 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 47f8e6f48..d71e98418 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,
'upcall' and 'buf' names are not needed. The structure is self-explanatory.
> + uint32_t handler_id);
> +void netdev_offload_recv_wait(uint32_t handler_id);
> +
> #ifdef __cplusplus
> }
> #endif
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev