[dpdk-dev] [RFC 2/9] ethdev: move queue id check in generic layer
Ferruh Yigit
ferruh.yigit at intel.com
Thu Nov 24 11:59:50 CET 2016
On 11/24/2016 9:54 AM, Olivier Matz wrote:
> The check of queue_id is done in all drivers implementing
> rte_eth_rx_queue_count(). Factorize this check in the generic function.
>
> Note that the nfp driver was doing the check differently, which could
> induce crashes if the queue index was too big.
>
> By the way, also move the is_supported test before the port valid and
> queue valid test.
>
> PR=52423
> Signed-off-by: Olivier Matz <olivier.matz at 6wind.com>
> Acked-by: Ivan Boule <ivan.boule at 6wind.com>
> ---
<...>
> diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> index c3edc23..9551cfd 100644
> --- a/lib/librte_ether/rte_ethdev.h
> +++ b/lib/librte_ether/rte_ethdev.h
> @@ -2693,7 +2693,7 @@ rte_eth_rx_burst(uint8_t port_id, uint16_t queue_id,
> * The queue id on the specific port.
> * @return
> * The number of used descriptors in the specific queue, or:
> - * (-EINVAL) if *port_id* is invalid
> + * (-EINVAL) if *port_id* or *queue_id* is invalid
> * (-ENOTSUP) if the device does not support this function
> */
> static inline int
> @@ -2701,8 +2701,10 @@ rte_eth_rx_queue_count(uint8_t port_id, uint16_t queue_id)
> {
> struct rte_eth_dev *dev = &rte_eth_devices[port_id];
>
> - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
> RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->rx_queue_count, -ENOTSUP);
> + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
Doing port validity check before accessing dev->dev_ops->rx_queue_count
can be good idea.
What about validating port_id even before accessing
rte_eth_devices[port_id]?
> + if (queue_id >= dev->data->nb_rx_queues)
> + return -EINVAL;
>
> return (*dev->dev_ops->rx_queue_count)(dev, queue_id);
> }
>
More information about the dev
mailing list