diff options
author | Cian Ferriter <cian.ferriter@intel.com> | 2022-02-21 16:01:26 +0000 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2022-03-11 21:07:34 +0100 |
commit | c356f6c0b9ed5f028d8a15e7eb1078904e7be59a (patch) | |
tree | 3d20f80d14e76b73116e7c8cf617614e4be29525 | |
parent | f77dbc1eb2da2523625cd36922c6fccfcb3f3eb7 (diff) | |
download | openvswitch-c356f6c0b9ed5f028d8a15e7eb1078904e7be59a.tar.gz |
dpif-netdev: Simplify atomic function pointer stores.
The same pattern for atomic stores and initialization was used for the
DPIF and MFEX function pointers declared in struct dp_netdev_pmd_thread.
Simplify this pattern for all stores to 'miniflow_extract_opt' and
'netdev_input_func'.
Also replace the first store to 'miniflow_extract_opt' which was a
atomic_store_relaxed() with atomic_init().
Signed-off-by: Cian Ferriter <cian.ferriter@intel.com>
Acked-by: Kumar Amber <kumar.amber@intel.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r-- | lib/dpif-netdev-extract-study.c | 12 | ||||
-rw-r--r-- | lib/dpif-netdev-private-extract.c | 8 | ||||
-rw-r--r-- | lib/dpif-netdev.c | 16 |
3 files changed, 11 insertions, 25 deletions
diff --git a/lib/dpif-netdev-extract-study.c b/lib/dpif-netdev-extract-study.c index 5a9370669..69077c844 100644 --- a/lib/dpif-netdev-extract-study.c +++ b/lib/dpif-netdev-extract-study.c @@ -120,19 +120,15 @@ mfex_study_traffic(struct dp_packet_batch *packets, /* If 50% of the packets hit, enable the function. */ if (max_hits >= (mfex_study_pkts_count / 2)) { - miniflow_extract_func mf_func = - miniflow_funcs[best_func_index].extract_func; - atomic_uintptr_t *pmd_func = (void *)&pmd->miniflow_extract_opt; - atomic_store_relaxed(pmd_func, (uintptr_t) mf_func); + atomic_store_relaxed(&pmd->miniflow_extract_opt, + miniflow_funcs[best_func_index].extract_func); VLOG_INFO("MFEX study chose impl %s: (hits %u/%u pkts)", miniflow_funcs[best_func_index].name, max_hits, stats->pkt_count); } else { /* Set the implementation to null for default miniflow. */ - miniflow_extract_func mf_func = - miniflow_funcs[MFEX_IMPL_SCALAR].extract_func; - atomic_uintptr_t *pmd_func = (void *)&pmd->miniflow_extract_opt; - atomic_store_relaxed(pmd_func, (uintptr_t) mf_func); + atomic_store_relaxed(&pmd->miniflow_extract_opt, + miniflow_funcs[MFEX_IMPL_SCALAR].extract_func); VLOG_INFO("Not enough packets matched (%u/%u), disabling" " optimized MFEX.", max_hits, stats->pkt_count); } diff --git a/lib/dpif-netdev-private-extract.c b/lib/dpif-netdev-private-extract.c index a29bdcfa7..4b2f12015 100644 --- a/lib/dpif-netdev-private-extract.c +++ b/lib/dpif-netdev-private-extract.c @@ -241,9 +241,7 @@ dpif_miniflow_extract_autovalidator(struct dp_packet_batch *packets, struct netdev_flow_key test_keys[NETDEV_MAX_BURST]; if (keys_size < cnt) { - miniflow_extract_func default_func = NULL; - atomic_uintptr_t *pmd_func = (void *)&pmd->miniflow_extract_opt; - atomic_store_relaxed(pmd_func, (uintptr_t) default_func); + atomic_store_relaxed(&pmd->miniflow_extract_opt, NULL); VLOG_ERR("Invalid key size supplied, Key_size: %d less than" "batch_size: %" PRIuSIZE"\n", keys_size, cnt); VLOG_ERR("Autovalidatior is disabled.\n"); @@ -350,9 +348,7 @@ dpif_miniflow_extract_autovalidator(struct dp_packet_batch *packets, /* Having dumped the debug info for the batch, disable autovalidator. */ if (batch_failed) { - miniflow_extract_func default_func = NULL; - atomic_uintptr_t *pmd_func = (void *)&pmd->miniflow_extract_opt; - atomic_store_relaxed(pmd_func, (uintptr_t) default_func); + atomic_store_relaxed(&pmd->miniflow_extract_opt, NULL); } /* Preserve packet correctness by storing back the good offsets in diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 9f35713ef..720818e30 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1167,9 +1167,8 @@ dpif_netdev_impl_set(struct unixctl_conn *conn, int argc OVS_UNUSED, /* Initialize DPIF function pointer to the newly configured * default. */ - dp_netdev_input_func default_func = dp_netdev_impl_get_default(); - atomic_uintptr_t *pmd_func = (void *) &pmd->netdev_input_func; - atomic_store_relaxed(pmd_func, (uintptr_t) default_func); + atomic_store_relaxed(&pmd->netdev_input_func, + dp_netdev_impl_get_default()); }; free(pmd_list); @@ -1358,8 +1357,7 @@ dpif_miniflow_extract_impl_set(struct unixctl_conn *conn, int argc, } pmd_thread_update_done = true; - atomic_uintptr_t *pmd_func = (void *) &pmd->miniflow_extract_opt; - atomic_store_relaxed(pmd_func, (uintptr_t) mfex_func); + atomic_store_relaxed(&pmd->miniflow_extract_opt, mfex_func); }; free(pmd_list); @@ -7459,14 +7457,10 @@ dp_netdev_configure_pmd(struct dp_netdev_pmd_thread *pmd, struct dp_netdev *dp, cmap_init(&pmd->tx_bonds); /* Initialize DPIF function pointer to the default configured version. */ - dp_netdev_input_func default_func = dp_netdev_impl_get_default(); - atomic_uintptr_t *pmd_func = (void *) &pmd->netdev_input_func; - atomic_init(pmd_func, (uintptr_t) default_func); + atomic_init(&pmd->netdev_input_func, dp_netdev_impl_get_default()); /* Init default miniflow_extract function */ - miniflow_extract_func mfex_func = dp_mfex_impl_get_default(); - atomic_uintptr_t *pmd_func_mfex = (void *)&pmd->miniflow_extract_opt; - atomic_store_relaxed(pmd_func_mfex, (uintptr_t) mfex_func); + atomic_init(&pmd->miniflow_extract_opt, dp_mfex_impl_get_default()); /* init the 'flow_cache' since there is no * actual thread created for NON_PMD_CORE_ID. */ |