The started field is currently 'bool', accessed in netdev-dpdk only under a mutex lock. In netdev-doca it will be used not under a lock. Move it to be atomic as a pre-step towards it.
Signed-off-by: Eli Britstein <[email protected]> --- lib/netdev-dpdk-common.h | 11 ++++++++++- lib/netdev-dpdk.c | 12 +++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/netdev-dpdk-common.h b/lib/netdev-dpdk-common.h index 547c3d4c6..16e5e8767 100644 --- a/lib/netdev-dpdk-common.h +++ b/lib/netdev-dpdk-common.h @@ -118,7 +118,7 @@ struct netdev_dpdk_common { uint16_t port_id; bool attached; bool is_representor; - bool started; + atomic_bool started; struct eth_addr hwaddr; int mtu; int socket_id; @@ -180,4 +180,13 @@ netdev_dpdk_common_cast(const struct netdev *netdev) return CONTAINER_OF(netdev, struct netdev_dpdk_common, up); } +static inline bool +dpdk_dev_is_started(struct netdev_dpdk_common *common) +{ + bool started; + + atomic_read_relaxed(&common->started, &started); + return started; +} + #endif /* NETDEV_DPDK_COMMON_H */ diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 667be4f23..78eaa8706 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1283,7 +1283,6 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) rte_strerror(-diag)); return -diag; } - dev->common.started = true; netdev_dpdk_configure_xstats(&dev->common); @@ -1303,6 +1302,9 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) mbp_priv = rte_mempool_get_priv(dev->common.dpdk_mp->mp); dev->buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM; + + atomic_store_explicit(&dev->common.started, true, memory_order_seq_cst); + return 0; } @@ -1369,7 +1371,7 @@ common_construct(struct netdev *netdev, dpdk_port_t port_no, int socket_id) dev->vhost_reconfigured = false; dev->virtio_features_state = OVS_VIRTIO_F_CLEAN; dev->common.attached = false; - dev->common.started = false; + atomic_init(&dev->common.started, false); ovsrcu_init(&dev->qos_conf, NULL); @@ -1578,7 +1580,7 @@ netdev_dpdk_destruct(struct netdev *netdev) dpdk_rx_steer_unconfigure(dev); rte_eth_dev_stop(dev->common.port_id); - dev->common.started = false; + atomic_store_explicit(&dev->common.started, false, memory_order_seq_cst); if (dev->common.attached) { bool dpdk_resources_still_used = false; @@ -6088,7 +6090,7 @@ netdev_dpdk_reconfigure(struct netdev *netdev) && dev->common.txq_size == dev->common.requested_txq_size && eth_addr_equals(dev->common.hwaddr, dev->common.requested_hwaddr) && dev->common.socket_id == dev->common.requested_socket_id - && dev->common.started && !pending_reset) { + && dpdk_dev_is_started(&dev->common) && !pending_reset) { /* Reconfiguration is unnecessary */ goto out; @@ -6110,7 +6112,7 @@ retry: rte_eth_dev_stop(dev->common.port_id); } - dev->common.started = false; + atomic_store_explicit(&dev->common.started, false, memory_order_seq_cst); err = netdev_dpdk_mempool_configure(dev); if (err && err != EEXIST) { -- 2.43.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
