From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <dev-bounces@dpdk.org> Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 71BC3A04B6; Mon, 12 Oct 2020 05:22:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4F1C01D5A9; Mon, 12 Oct 2020 05:22:39 +0200 (CEST) Received: from incedge.chinasoftinc.com (unknown [114.113.233.8]) by dpdk.org (Postfix) with ESMTP id 6922A1BCA9 for <dev@dpdk.org>; Mon, 12 Oct 2020 05:22:37 +0200 (CEST) X-ASG-Debug-ID: 1602472955-149d114caf12fec0001-TfluYd Received: from mail.chinasoftinc.com (inccas001.ito.icss [10.168.0.51]) by incedge.chinasoftinc.com with ESMTP id qImqvhrFoyWsgqfy (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 12 Oct 2020 11:22:35 +0800 (CST) X-Barracuda-Envelope-From: huwei013@chinasoftinc.com X-Barracuda-RBL-Trusted-Forwarder: 10.168.0.51 X-ASG-Whitelist: Client Received: from [192.168.1.199] (139.159.243.11) by INCCAS001.ito.icss (10.168.0.60) with Microsoft SMTP Server id 14.3.487.0; Mon, 12 Oct 2020 11:22:35 +0800 X-Barracuda-RBL-Trusted-Forwarder: 192.168.1.199 To: Kalesh Anakkur Purayil <kalesh-anakkur.purayil@broadcom.com> X-ASG-Orig-Subj: Re: [dpdk-dev] [PATCH] ethdev: check if queue setupped in queue-related APIs CC: <dev@dpdk.org>, Wei Hu <xavier.huwei@huawei.com> References: <20201010071212.24086-1-huwei013@chinasoftinc.com> <CAH-L+nPyrC9gcUWYaFydr-teThpN=udvUAFnkSHgti9TZuG=Rw@mail.gmail.com> From: "Wei Hu (Xavier)" <huwei013@chinasoftinc.com> Message-ID: <a5c61bc2-455e-2c9d-0722-8c34dc0e5efd@chinasoftinc.com> Date: Mon, 12 Oct 2020 11:22:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <CAH-L+nPyrC9gcUWYaFydr-teThpN=udvUAFnkSHgti9TZuG=Rw@mail.gmail.com> Content-Language: en-US X-Originating-IP: [139.159.243.11] X-Barracuda-Connect: inccas001.ito.icss[10.168.0.51] X-Barracuda-Start-Time: 1602472955 X-Barracuda-Encrypted: ECDHE-RSA-AES256-SHA X-Barracuda-URL: https://incspam.chinasofti.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at chinasoftinc.com X-Barracuda-Scan-Msg-Size: 9031 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit 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 <dev.dpdk.org> List-Unsubscribe: <https://mails.dpdk.org/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://mails.dpdk.org/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://mails.dpdk.org/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> 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@chinasoftinc.com <mailto:huwei013@chinasoftinc.com>> wrote: > > From: Chengchang Tang <tangchengchang@huawei.com > <mailto:tangchengchang@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@huawei.com > <mailto:tangchengchang@huawei.com>> > Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com > <mailto:xavier.huwei@huawei.com>> > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com > <mailto:fengchengwen@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