[dpdk-dev] [PATCH] ethdev: check if queue setupped in queue-related APIs
Wei Hu (Xavier)
huwei013 at chinasoftinc.com
Mon Oct 12 05:22:35 CEST 2020
Hi, Kalesh Anakkur Purayil
On 2020/10/11 0:38, Kalesh Anakkur Purayil wrote:
>
>
> On Sat, Oct 10, 2020 at 12:42 PM Wei Hu (Xavier)
> <huwei013 at chinasoftinc.com <mailto:huwei013 at chinasoftinc.com>> wrote:
>
> From: Chengchang Tang <tangchengchang at huawei.com
> <mailto:tangchengchang at huawei.com>>
>
> This patch adds checking whether the related Tx or Rx queue has been
> setupped in the queue-related API functions to avoid illegal address
> access. And validity check of the queue_id is also added in the API
> functions rte_eth_dev_rx_intr_enable and rte_eth_dev_rx_intr_disable.
>
> Signed-off-by: Chengchang Tang <tangchengchang at huawei.com
> <mailto:tangchengchang at huawei.com>>
> Signed-off-by: Wei Hu (Xavier) <xavier.huwei at huawei.com
> <mailto:xavier.huwei at huawei.com>>
> Signed-off-by: Chengwen Feng <fengchengwen at huawei.com
> <mailto:fengchengwen at huawei.com>>
> ---
> lib/librte_ethdev/rte_ethdev.c | 56
> ++++++++++++++++++++++++++++++++++++++++++
> lib/librte_ethdev/rte_ethdev.h | 3 ++-
> 2 files changed, 58 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.c
> b/lib/librte_ethdev/rte_ethdev.c
> index 892c246..31a8eb3 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -897,6 +897,13 @@ rte_eth_dev_rx_queue_start(uint16_t port_id,
> uint16_t rx_queue_id)
> return -EINVAL;
> }
>
> + if (dev->data->rx_queues[rx_queue_id] == NULL) {
> + RTE_ETHDEV_LOG(ERR, "Rx queue %"PRIu16" of device
> with port_id=%"
> + PRIu16" has not been setupped\n",
> + rx_queue_id, port_id);
> + return -EINVAL;
> + }
> +
>
>
> Hi Xavier,
>
> How about having two common functions which validate RXQ/TXQ ids and
> whether it has been set up or not like below. This helps avoiding lot
> of duplicate code:
>
> static inline int
> rte_eth_dev_validate_rx_queue(uint16_t port_id, uint16_t rx_queue_id)
> {
> struct rte_eth_dev *dev;
>
> RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
>
> dev = &rte_eth_devices[port_id];
>
> if (rx_queue_id >= dev->data->nb_rx_queues) {
> RTE_ETHDEV_LOG(ERR, "Invalid RX queue_id=%u\n",
> rx_queue_id);
> return -EINVAL;
> }
>
> if (dev->data->rx_queues[rx_queue_id] == NULL) {
> RTE_ETHDEV_LOG(ERR,
> "Queue %u of device with port_id=%u has
> not been setup\n",
> rx_queue_id, port_id);
> return -EINVAL;
> }
>
> return 0;
> }
>
I fixed it in V2.
Thanks, xavier
> Regards,
> Kalesh
>
> --
> 2.9.5
>
>
>
> --
> Regards,
> Kalesh A P
More information about the dev
mailing list