> If ethdev enqueue or dequeue function is called during
> eth_dev_fp_ops_setup(), it may get pre-empted after setting
> the function pointers, but before setting the pointer to port data.
> In this case the newly registered enqueue/dequeue function will use
> dummy port data and end up in seg fault.
> 
> This patch moves the updation of each data pointers before updating
> corresponding function pointers.

First, such re-ordering wouldn't really fix that race condition.
Second, eth_dev_fp_ops_setup() supposed to be called only by dev/queue 
start/stop functions.
With current DPDK design it is not allowed to simultaneously call dev start/stop
and  data-path RX/TX functions and it is user responsibility to ensure that.
In other words - it is user responsibility to ensure that such race condition 
would 
not happen.
So, NACK.

> 
> Fixes: c87d435a4d79 ("ethdev: copy fast-path API into separate structure")
> Cc: sta...@dpdk.org
> 
> Signed-off-by: Ashok Kaladi <ashok.k.kal...@intel.com>
> 
> diff --git a/lib/ethdev/ethdev_private.c b/lib/ethdev/ethdev_private.c
> index 48090c879a..a0232c669f 100644
> --- a/lib/ethdev/ethdev_private.c
> +++ b/lib/ethdev/ethdev_private.c
> @@ -270,17 +270,17 @@ void
>  eth_dev_fp_ops_setup(struct rte_eth_fp_ops *fpo,
>               const struct rte_eth_dev *dev)
>  {
> +     fpo->rxq.data = dev->data->rx_queues;
>       fpo->rx_pkt_burst = dev->rx_pkt_burst;
> +     fpo->txq.data = dev->data->tx_queues;
>       fpo->tx_pkt_burst = dev->tx_pkt_burst;
>       fpo->tx_pkt_prepare = dev->tx_pkt_prepare;
>       fpo->rx_queue_count = dev->rx_queue_count;
>       fpo->rx_descriptor_status = dev->rx_descriptor_status;
>       fpo->tx_descriptor_status = dev->tx_descriptor_status;
> 
> -     fpo->rxq.data = dev->data->rx_queues;
>       fpo->rxq.clbk = (void **)(uintptr_t)dev->post_rx_burst_cbs;
> 
> -     fpo->txq.data = dev->data->tx_queues;
>       fpo->txq.clbk = (void **)(uintptr_t)dev->pre_tx_burst_cbs;
>  }
> 
> --
> 2.25.1

Reply via email to