From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3A963A04B1; Sat, 10 Oct 2020 18:38:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B25811D536; Sat, 10 Oct 2020 18:38:43 +0200 (CEST) Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by dpdk.org (Postfix) with ESMTP id A23B01D534 for ; Sat, 10 Oct 2020 18:38:40 +0200 (CEST) Received: by mail-io1-f66.google.com with SMTP id y20so9335220iod.5 for ; Sat, 10 Oct 2020 09:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lqT+9tp+z1tOKoJ8V9XHbIeQ8gFp00+Hja24dg/gc34=; b=cm1hK9FK8eIL+pUAjXcb1/OhC4Hn7Z5mcpKaBcbfOiC8MINF8yXXadIOpngj8ufNoa BkgRH4HcRHtjglwn2GUMnku4+SL0UbMkLic2LBVHdl/DBK0Bq+kdHGYGEBG9+LTkKelC 9p4In4GQH1F5/YX+gll9ICgIyORzLjH5dIGwY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lqT+9tp+z1tOKoJ8V9XHbIeQ8gFp00+Hja24dg/gc34=; b=MLtQNvV1Z0UlYbRn/36e5m78u76ovZ66AGVdcFzRd32XTgykdlH3wZyxGmPnqI5KTa 94AkWuguofaOvVPYA0VL5q4nOXJx2orkBtIhaBb7aKqBb0XFKg1AFm9COaVArb7/JySx nsvEmBiqbRdgIalG5G3B5DFxYPe1P6m6jntTDIw7C0LHI5xMae9mGUM4fbIED1Fvd9cZ fiH93741vNYpi+Ws82IrU3fEONcsu/D7QCw6PFrx2H+O3yavMzC2Z24RgDkcD350DmKJ 0ApqY0W4p1tWM/60anV+pMAJtkJA67LEyirVebCm/Hf9KGenwDOMjBGqCXQDxkRZ86VN pz1Q== X-Gm-Message-State: AOAM5314a/zpugoNf83F5Tny0A0Jek+Rt8ZT1kW0+UmfQ9Ss6vm0ElEc e3rtBED4J8S/e2oZbxtpA7nYmgTES0mlcW0vZtyoqg== X-Google-Smtp-Source: ABdhPJz7tVbDyHPU5+NTDlZYj4jr4cac9W563AA+6OC7/5FT4Ye1HKr86V+Gukqd3WmBMeb3yGpr8EMKJf2CAQ2oyFE= X-Received: by 2002:a5e:c112:: with SMTP id v18mr12780946iol.195.1602347918695; Sat, 10 Oct 2020 09:38:38 -0700 (PDT) MIME-Version: 1.0 References: <20201010071212.24086-1-huwei013@chinasoftinc.com> In-Reply-To: <20201010071212.24086-1-huwei013@chinasoftinc.com> From: Kalesh Anakkur Purayil Date: Sat, 10 Oct 2020 22:08:28 +0530 Message-ID: To: "Wei Hu (Xavier)" Cc: dev@dpdk.org, Wei Hu Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] ethdev: check if queue setupped in queue-related APIs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Sat, Oct 10, 2020 at 12:42 PM Wei Hu (Xavier) wrote: > From: Chengchang Tang > > 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 > Signed-off-by: Wei Hu (Xavier) > Signed-off-by: Chengwen Feng > --- > 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; } Regards, Kalesh > -- > 2.9.5 > > -- Regards, Kalesh A P