The patch removes static allocation of recirc_depth parameter and moves the hash function to dpcls to allow for re-use by avx512 dpif and others.
Signed-off-by: Kumar Amber <[email protected]> Signed-off-by: Cian Ferriter <[email protected]> Co-authored-by: Cian Ferriter <[email protected]> --- lib/dpif-netdev-private-dpcls.h | 23 +++++++++++++++++++++++ lib/dpif-netdev-private-dpif.c | 2 ++ lib/dpif-netdev-private-dpif.h | 9 +++++++++ lib/dpif-netdev.c | 29 ++--------------------------- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/lib/dpif-netdev-private-dpcls.h b/lib/dpif-netdev-private-dpcls.h index 0d5da73c7..a86ea449b 100644 --- a/lib/dpif-netdev-private-dpcls.h +++ b/lib/dpif-netdev-private-dpcls.h @@ -25,6 +25,7 @@ #include "cmap.h" #include "openvswitch/thread.h" +#include "dpif-netdev-private-dpif.h" #ifdef __cplusplus extern "C" { @@ -124,6 +125,28 @@ dpif_netdev_packet_get_rss_hash_orig_pkt(struct dp_packet *packet, return hash; } +static inline uint32_t +dpif_netdev_packet_get_rss_hash(struct dp_packet *packet, + const struct miniflow *mf) +{ + uint32_t hash; + + if (OVS_LIKELY(dp_packet_rss_valid(packet))) { + hash = dp_packet_get_rss_hash(packet); + } else { + hash = miniflow_hash_5tuple(mf, 0); + dp_packet_set_rss_hash(packet, hash); + } + + /* The RSS hash must account for the recirculation depth to avoid + * collisions in the exact match cache */ + uint32_t recirc_depth = *recirc_depth_get(); + if (OVS_UNLIKELY(recirc_depth)) { + hash = hash_finish(hash, recirc_depth); + } + return hash; +} + /* Allow other implementations to call dpcls_lookup() for subtable search. */ bool dpcls_lookup(struct dpcls *cls, const struct netdev_flow_key *keys[], diff --git a/lib/dpif-netdev-private-dpif.c b/lib/dpif-netdev-private-dpif.c index 84d4ec156..4fe67a3c5 100644 --- a/lib/dpif-netdev-private-dpif.c +++ b/lib/dpif-netdev-private-dpif.c @@ -153,3 +153,5 @@ dp_netdev_impl_set_default_by_name(const char *name) return err; } + +DEFINE_EXTERN_PER_THREAD_DATA(recirc_depth, 0); diff --git a/lib/dpif-netdev-private-dpif.h b/lib/dpif-netdev-private-dpif.h index 0da639c55..0e29a02db 100644 --- a/lib/dpif-netdev-private-dpif.h +++ b/lib/dpif-netdev-private-dpif.h @@ -18,6 +18,11 @@ #define DPIF_NETDEV_PRIVATE_DPIF_H 1 #include "openvswitch/types.h" +#include "ovs-thread.h" + + +#define MAX_RECIRC_DEPTH 6 +DECLARE_EXTERN_PER_THREAD_DATA(uint32_t, recirc_depth); /* Forward declarations to avoid including files. */ struct dp_netdev_pmd_thread; @@ -76,4 +81,8 @@ dp_netdev_input_outer_avx512(struct dp_netdev_pmd_thread *pmd, struct dp_packet_batch *packets, odp_port_t in_port); +int32_t +dp_netdev_recirculate(struct dp_netdev_pmd_thread *, + struct dp_packet_batch *); + #endif /* netdev-private.h */ diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 720818e30..829f1dedf 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -98,8 +98,6 @@ VLOG_DEFINE_THIS_MODULE(dpif_netdev); #define FLOW_DUMP_MAX_BATCH 50 /* Use per thread recirc_depth to prevent recirculation loop. */ -#define MAX_RECIRC_DEPTH 6 -DEFINE_STATIC_PER_THREAD_DATA(uint32_t, recirc_depth, 0) /* Use instant packet send by default. */ #define DEFAULT_TX_FLUSH_INTERVAL 0 @@ -547,8 +545,6 @@ static void dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd, const struct flow *flow, const struct nlattr *actions, size_t actions_len); -static void dp_netdev_recirculate(struct dp_netdev_pmd_thread *, - struct dp_packet_batch *); static void dp_netdev_disable_upcall(struct dp_netdev *); static void dp_netdev_pmd_reload_done(struct dp_netdev_pmd_thread *pmd); @@ -7789,28 +7785,6 @@ dp_netdev_upcall(struct dp_netdev_pmd_thread *pmd, struct dp_packet *packet_, actions, wc, put_actions, dp->upcall_aux); } -static inline uint32_t -dpif_netdev_packet_get_rss_hash(struct dp_packet *packet, - const struct miniflow *mf) -{ - uint32_t hash, recirc_depth; - - if (OVS_LIKELY(dp_packet_rss_valid(packet))) { - hash = dp_packet_get_rss_hash(packet); - } else { - hash = miniflow_hash_5tuple(mf, 0); - dp_packet_set_rss_hash(packet, hash); - } - - /* The RSS hash must account for the recirculation depth to avoid - * collisions in the exact match cache */ - recirc_depth = *recirc_depth_get_unsafe(); - if (OVS_UNLIKELY(recirc_depth)) { - hash = hash_finish(hash, recirc_depth); - } - return hash; -} - struct packet_batch_per_flow { unsigned int byte_count; uint16_t tcp_flags; @@ -8497,11 +8471,12 @@ dp_netdev_input(struct dp_netdev_pmd_thread *pmd, return 0; } -static void +int32_t dp_netdev_recirculate(struct dp_netdev_pmd_thread *pmd, struct dp_packet_batch *packets) { dp_netdev_input__(pmd, packets, true, 0); + return 0; } struct dp_netdev_execute_aux { -- 2.25.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
