eventdev: fix Rx SW adapter stop
authorNikhil Rao <nikhil.rao@intel.com>
Mon, 4 Jun 2018 12:55:17 +0000 (18:25 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 18 Jun 2018 22:09:36 +0000 (00:09 +0200)
The Rx adapter stop call does not guarantee that the
SW service function will not execute after the
rte_event_eth_rx_adapter_stop() call.

Add a "started" flag to prevent the adapter from executing
if stop has been called.

Fixes: 9c38b704d280 ("eventdev: add eth Rx adapter implementation")
Cc: stable@dpdk.org
Signed-off-by: Nikhil Rao <nikhil.rao@intel.com>
lib/librte_eventdev/rte_event_eth_rx_adapter.c

index ad174ac..ce1f62d 100644 (file)
@@ -91,6 +91,8 @@ struct rte_event_eth_rx_adapter {
        int socket_id;
        /* Per adapter EAL service */
        uint32_t service_id;
+       /* Adapter started flag */
+       uint8_t rxa_started;
 } __rte_cache_aligned;
 
 /* Per eth device */
@@ -556,6 +558,10 @@ event_eth_rx_adapter_service_func(void *args)
 
        if (rte_spinlock_trylock(&rx_adapter->rx_lock) == 0)
                return 0;
+       if (!rx_adapter->rxa_started) {
+               return 0;
+               rte_spinlock_unlock(&rx_adapter->rx_lock);
+       }
        eth_rx_poll(rx_adapter);
        rte_spinlock_unlock(&rx_adapter->rx_lock);
        return 0;
@@ -847,8 +853,12 @@ rx_adapter_ctrl(uint8_t id, int start)
                                                &rte_eth_devices[i]);
        }
 
-       if (use_service)
+       if (use_service) {
+               rte_spinlock_lock(&rx_adapter->rx_lock);
+               rx_adapter->rxa_started = start;
                rte_service_runstate_set(rx_adapter->service_id, start);
+               rte_spinlock_unlock(&rx_adapter->rx_lock);
+       }
 
        return 0;
 }