his patch moved the hardware packet miss recover APIs to the netdev-offload provider.
Signed-off-by: Eelco Chaudron <[email protected]> --- lib/dpif-netdev.c | 3 ++- lib/dpif-offload-provider.h | 6 ++++++ lib/dpif-offload-rte_flow.c | 10 ++++++++++ lib/dpif-offload.c | 34 ++++++++++++++++++++++++++++++++++ lib/dpif-offload.h | 2 ++ lib/netdev-offload-dpdk.c | 3 +-- lib/netdev-offload-dpdk.h | 2 ++ lib/netdev-offload-provider.h | 6 ------ lib/netdev-offload.c | 28 ---------------------------- lib/netdev-offload.h | 1 - 10 files changed, 57 insertions(+), 38 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 97125514c..f548438d9 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -8426,7 +8426,8 @@ dp_netdev_hw_flow(const struct dp_netdev_pmd_thread *pmd, atomic_read_relaxed(&rxq->port->netdev->hw_info.miss_api_supported, &miss_api_supported); if (miss_api_supported) { - int err = netdev_hw_miss_packet_recover(rxq->port->netdev, packet); + int err = dpif_offload_netdev_hw_miss_packet_recover(rxq->port->netdev, + packet); if (err && err != EOPNOTSUPP) { COVERAGE_INC(datapath_drop_hw_miss_recover); return -1; diff --git a/lib/dpif-offload-provider.h b/lib/dpif-offload-provider.h index 7431474e0..53754cbda 100644 --- a/lib/dpif-offload-provider.h +++ b/lib/dpif-offload-provider.h @@ -168,6 +168,12 @@ struct dpif_offload_class { /* Deletes all offloaded flows on this netdev. Return 0 if successful, * otherwise returns a positive errno value. */ int (*netdev_flow_flush)(const struct dpif_offload *, struct netdev *); + + /* Recover the packet state (contents and data) for continued processing + * in software. Return 0 if successful, otherwise returns a positive + * errno value and takes ownership of a packet if errno != EOPNOTSUPP. */ + int (*netdev_hw_miss_packet_recover)(const struct dpif_offload *, + struct netdev *, struct dp_packet *); }; diff --git a/lib/dpif-offload-rte_flow.c b/lib/dpif-offload-rte_flow.c index ef278d0ce..9e2fff78b 100644 --- a/lib/dpif-offload-rte_flow.c +++ b/lib/dpif-offload-rte_flow.c @@ -288,6 +288,14 @@ dpif_offload_rte_netdev_flow_flush(const struct dpif_offload *offload return netdev_offload_dpdk_flow_flush(netdev); } +static int +dpif_offload_rte_netdev_hw_miss_packet_recover( + const struct dpif_offload *offload OVS_UNUSED, struct netdev *netdev, + struct dp_packet *packet) +{ + return netdev_offload_dpdk_hw_miss_packet_recover(netdev, packet); +} + struct dpif_offload_class dpif_offload_rte_flow_class = { .type = "rte_flow", .supported_dpif_types = (const char *const[]) { @@ -302,6 +310,8 @@ struct dpif_offload_class dpif_offload_rte_flow_class = { .port_del = dpif_offload_rte_port_del, .flow_get_n_offloaded = dpif_offload_rte_flow_get_n_offloaded, .netdev_flow_flush = dpif_offload_rte_netdev_flow_flush, + .netdev_hw_miss_packet_recover = \ + dpif_offload_rte_netdev_hw_miss_packet_recover, }; /* XXX: Temporary functions below, which will be removed once fully diff --git a/lib/dpif-offload.c b/lib/dpif-offload.c index c8bf4e7c7..786c1d0d1 100644 --- a/lib/dpif-offload.c +++ b/lib/dpif-offload.c @@ -834,6 +834,40 @@ dpif_offload_netdev_flush_flows(struct netdev *netdev) return EOPNOTSUPP; } +int +dpif_offload_netdev_hw_miss_packet_recover(struct netdev *netdev, + struct dp_packet *packet) +{ + const struct dpif_offload *offload; + bool miss_api_supported; + int rc; + + atomic_read_relaxed(&netdev->hw_info.miss_api_supported, + &miss_api_supported); + if (!miss_api_supported) { + return EOPNOTSUPP; + } + + offload = ovsrcu_get(const struct dpif_offload *, &netdev->dpif_offload); + + if (!offload || !offload->class->netdev_hw_miss_packet_recover) { + if (offload) { + /* Offload is configured and API unsupported by the port; + * avoid subsequent calls. */ + atomic_store_relaxed(&netdev->hw_info.miss_api_supported, false); + } + return EOPNOTSUPP; + } + + rc = offload->class->netdev_hw_miss_packet_recover(offload, netdev, + packet); + if (rc == EOPNOTSUPP) { + /* API unsupported by the port; avoid subsequent calls. */ + atomic_store_relaxed(&netdev->hw_info.miss_api_supported, false); + } + return rc; +} + struct dpif_offload_port_mgr * dpif_offload_port_mgr_init(void) diff --git a/lib/dpif-offload.h b/lib/dpif-offload.h index a75c80612..f8b22e4ab 100644 --- a/lib/dpif-offload.h +++ b/lib/dpif-offload.h @@ -75,5 +75,7 @@ void dpif_offload_meter_del(const struct dpif *dpif, ofproto_meter_id meter_id, /* Netdev specific function, which can be used in the fast path. */ int dpif_offload_netdev_flush_flows(struct netdev *); +int dpif_offload_netdev_hw_miss_packet_recover(struct netdev *, + struct dp_packet *); #endif /* DPIF_OFFLOAD_H */ diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index ad09ad530..53f6dcdac 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -2686,7 +2686,7 @@ get_vport_netdev(const char *dpif_type, return aux.vport; } -static int +int netdev_offload_dpdk_hw_miss_packet_recover(struct netdev *netdev, struct dp_packet *packet) { @@ -2804,5 +2804,4 @@ const struct netdev_flow_api netdev_offload_dpdk = { .init_flow_api = netdev_offload_dpdk_init_flow_api, .uninit_flow_api = netdev_offload_dpdk_uninit_flow_api, .flow_get = netdev_offload_dpdk_flow_get, - .hw_miss_packet_recover = netdev_offload_dpdk_hw_miss_packet_recover, }; diff --git a/lib/netdev-offload-dpdk.h b/lib/netdev-offload-dpdk.h index d5061b40c..475822e1b 100644 --- a/lib/netdev-offload-dpdk.h +++ b/lib/netdev-offload-dpdk.h @@ -24,5 +24,7 @@ struct netdev; * associated dpif offload provider. */ int netdev_offload_dpdk_flow_flush(struct netdev *); uint64_t netdev_offload_dpdk_flow_get_n_offloaded(struct netdev *); +int netdev_offload_dpdk_hw_miss_packet_recover(struct netdev *, + struct dp_packet *); #endif /* NETDEV_OFFLOAD_DPDK_H */ diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h index 898df8333..f762af19a 100644 --- a/lib/netdev-offload-provider.h +++ b/lib/netdev-offload-provider.h @@ -80,12 +80,6 @@ struct netdev_flow_api { int (*flow_del)(struct netdev *, const ovs_u128 *ufid, struct dpif_flow_stats *); - /* Recover the packet state (contents and data) for continued processing - * in software. - * Return 0 if successful, otherwise returns a positive errno value and - * takes ownership of a packet if errno != EOPNOTSUPP. */ - int (*hw_miss_packet_recover)(struct netdev *, struct dp_packet *); - /* Initializies the netdev flow api. * Return 0 if successful, otherwise returns a positive errno value. */ int (*init_flow_api)(struct netdev *); diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index 4e676b37b..bdc50da5d 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -253,34 +253,6 @@ netdev_flow_put(struct netdev *netdev, struct match *match, : EOPNOTSUPP; } -int -netdev_hw_miss_packet_recover(struct netdev *netdev, - struct dp_packet *packet) -{ - const struct netdev_flow_api *flow_api; - bool miss_api_supported; - int rv; - - atomic_read_relaxed(&netdev->hw_info.miss_api_supported, - &miss_api_supported); - if (!miss_api_supported) { - return EOPNOTSUPP; - } - - flow_api = ovsrcu_get(const struct netdev_flow_api *, &netdev->flow_api); - if (!flow_api || !flow_api->hw_miss_packet_recover) { - return EOPNOTSUPP; - } - - rv = flow_api->hw_miss_packet_recover(netdev, packet); - if (rv == EOPNOTSUPP) { - /* API unsupported by the port; avoid subsequent calls. */ - atomic_store_relaxed(&netdev->hw_info.miss_api_supported, false); - } - - return rv; -} - int netdev_flow_get(struct netdev *netdev, struct match *match, struct nlattr **actions, const ovs_u128 *ufid, diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 2b32179ec..111de378b 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -110,7 +110,6 @@ bool netdev_flow_dump_next(struct netdev_flow_dump *, struct match *, int netdev_flow_put(struct netdev *, struct match *, struct nlattr *actions, size_t actions_len, const ovs_u128 *, struct offload_info *, struct dpif_flow_stats *); -int netdev_hw_miss_packet_recover(struct netdev *, struct dp_packet *); int netdev_flow_get(struct netdev *, struct match *, struct nlattr **actions, const ovs_u128 *, struct dpif_flow_stats *, struct dpif_flow_attrs *, struct ofpbuf *wbuffer); -- 2.50.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
