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 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 ; 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 X-ASG-Orig-Subj: Re: [dpdk-dev] [PATCH] ethdev: check if queue setupped in queue-related APIs CC: , Wei Hu References: <20201010071212.24086-1-huwei013@chinasoftinc.com> From: "Wei Hu (Xavier)" Message-ID: 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: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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) > > 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; > } > I fixed it in V2. Thanks, xavier > Regards, > Kalesh > > -- > 2.9.5 > > > > -- > Regards, > Kalesh A P