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-private.h | 11 ++++++++++- lib/netdev-dpdk.c | 12 +++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/netdev-dpdk-private.h b/lib/netdev-dpdk-private.h index 9b82db750..79aa2292a 100644 --- a/lib/netdev-dpdk-private.h +++ b/lib/netdev-dpdk-private.h @@ -109,7 +109,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; @@ -170,4 +170,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(&common->started, &started); + return started; +} + #endif /* NETDEV_DPDK_PRIVATE_H */ diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 5167ef1b0..02b346561 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -1311,7 +1311,6 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev) rte_strerror(-diag)); return -diag; } - dev->common.started = true; netdev_dpdk_configure_xstats(&dev->common); @@ -1331,6 +1330,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(&dev->common.started, true); + return 0; } @@ -1399,7 +1401,7 @@ common_construct(struct netdev *netdev, dpdk_port_t port_no, 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); @@ -1610,7 +1612,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(&dev->common.started, false); if (dev->common.attached) { bool dpdk_resources_still_used = false; @@ -6113,7 +6115,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; @@ -6135,7 +6137,7 @@ retry: rte_eth_dev_stop(dev->common.port_id); } - dev->common.started = false; + atomic_store(&dev->common.started, false); err = netdev_dpdk_mempool_configure(dev); if (err && err != EEXIST) { -- 2.34.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
