From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D039DA0C47; Tue, 6 Jul 2021 10:06:25 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B104E40688; Tue, 6 Jul 2021 10:06:25 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id ED1FF4067E for ; Tue, 6 Jul 2021 10:06:24 +0200 (CEST) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 8560C7F4FE; Tue, 6 Jul 2021 11:06:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 8560C7F4FE DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1625558784; bh=KI+fuLiuPgij4YQ8dJMjzUtNV89rKk3tBcGBuJxQdB0=; h=Subject:To:References:From:Date:In-Reply-To; b=J0ZGlUOtjwKVYiJ8aN5KjKNL9HfsCTmFK/FHRcqPiwJYNxaT+aVvZ81MSy7h8dgfR MWfMH9BI0OASg/bSG5gHJj0eo5lZK+bkgkCXVNVOmkv+SvRVfFs+q9qyacxzqVimMY kpo9O0DkYYTg3Op1vuScRbC1bNnwWDUKsSHpv2yA= To: Jiawen Wu , dev@dpdk.org References: <20210617110005.4132926-1-jiawenwu@trustnetic.com> <20210617110005.4132926-13-jiawenwu@trustnetic.com> <6d34d736-eaf6-a69a-47b5-9f42e0c09b5c@oktetlabs.ru> <00a801d77178$d6d645e0$8482d1a0$@trustnetic.com> <00ac01d7723c$0cce7460$266b5d20$@trustnetic.com> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: Date: Tue, 6 Jul 2021 11:06:24 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <00ac01d7723c$0cce7460$266b5d20$@trustnetic.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v6 12/19] net/ngbe: add Rx queue setup and release X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 7/6/21 10:53 AM, Jiawen Wu wrote: > On July 5, 2021 5:08 PM, Andrew Rybchenko wrote: >> On 7/5/21 11:36 AM, Jiawen Wu wrote: >>> On July 3, 2021 12:36 AM, Andrew Rybchenko wrote: >>>> On 6/17/21 1:59 PM, Jiawen Wu wrote: >>>>> Setup device Rx queue and release Rx queue. >>>>> >>>>> Signed-off-by: Jiawen Wu >>>>> --- >>>>> drivers/net/ngbe/meson.build | 1 + >>>>> drivers/net/ngbe/ngbe_ethdev.c | 37 +++- >>>>> drivers/net/ngbe/ngbe_ethdev.h | 16 ++ >>>>> drivers/net/ngbe/ngbe_rxtx.c | 308 +++++++++++++++++++++++++++++++++ >>>>> drivers/net/ngbe/ngbe_rxtx.h | 96 ++++++++++ >>>>> 5 files changed, 457 insertions(+), 1 deletion(-) create mode >>>>> 100644 drivers/net/ngbe/ngbe_rxtx.c create mode 100644 >>>>> drivers/net/ngbe/ngbe_rxtx.h >>>>> >>>>> a/drivers/net/ngbe/ngbe_ethdev.c b/drivers/net/ngbe/ngbe_ethdev.c >>>>> index c952023e8b..e73606c5f3 100644 >>>>> --- a/drivers/net/ngbe/ngbe_ethdev.c >>>>> +++ b/drivers/net/ngbe/ngbe_ethdev.c >>>>> @@ -37,6 +38,12 @@ static const struct rte_pci_id pci_id_ngbe_map[] = { >>>>> { .vendor_id = 0, /* sentinel */ }, }; >>>>> >>>>> +static const struct rte_eth_desc_lim rx_desc_lim = { >>>>> + .nb_max = NGBE_RING_DESC_MAX, >>>>> + .nb_min = NGBE_RING_DESC_MIN, >>>>> + .nb_align = NGBE_RXD_ALIGN, >>>>> +}; >>>>> + >>>>> static const struct eth_dev_ops ngbe_eth_dev_ops; >>>>> >>>>> static inline void >>>>> @@ -266,11 +280,30 @@ ngbe_dev_close(struct rte_eth_dev *dev) >>>>> static int ngbe_dev_info_get(struct rte_eth_dev *dev, struct >>>>> rte_eth_dev_info *dev_info) { >>>>> - RTE_SET_USED(dev); >>>>> + struct ngbe_hw *hw = ngbe_dev_hw(dev); >>>>> + >>>>> + dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues; >>>>> + >>>>> + dev_info->default_rxconf = (struct rte_eth_rxconf) { >>>>> + .rx_thresh = { >>>>> + .pthresh = NGBE_DEFAULT_RX_PTHRESH, >>>>> + .hthresh = NGBE_DEFAULT_RX_HTHRESH, >>>>> + .wthresh = NGBE_DEFAULT_RX_WTHRESH, >>>>> + }, >>>>> + .rx_free_thresh = NGBE_DEFAULT_RX_FREE_THRESH, >>>>> + .rx_drop_en = 0, >>>>> + .offloads = 0, >>>>> + }; >>>>> + >>>>> + dev_info->rx_desc_lim = rx_desc_lim; >>>>> > <...> >>>>> +int __rte_cold >>>>> +ngbe_dev_rx_queue_setup(struct rte_eth_dev *dev, >>>>> + uint16_t queue_idx, >>>>> + uint16_t nb_desc, >>>>> + unsigned int socket_id, >>>>> + const struct rte_eth_rxconf *rx_conf, >>>>> + struct rte_mempool *mp) >>>>> +{ >>>>> + const struct rte_memzone *rz; >>>>> + struct ngbe_rx_queue *rxq; >>>>> + struct ngbe_hw *hw; >>>>> + uint16_t len; >>>>> + struct ngbe_adapter *adapter = ngbe_dev_adapter(dev); >>>>> + >>>>> + PMD_INIT_FUNC_TRACE(); >>>>> + hw = ngbe_dev_hw(dev); >>>>> + >>>>> + /* >>>>> + * Validate number of receive descriptors. >>>>> + * It must not exceed hardware maximum, and must be multiple >>>>> + * of NGBE_ALIGN. >>>>> + */ >>>>> + if (nb_desc % NGBE_RXD_ALIGN != 0 || >>>>> + nb_desc > NGBE_RING_DESC_MAX || >>>>> + nb_desc < NGBE_RING_DESC_MIN) { >>>>> + return -EINVAL; >>>>> + } >>>> >>>> rte_eth_rx_queue_setup cares about it >>>> >>> >>> I don't quite understand. >> >> ethdev does the check based dev_info provided by the driver: >> >> if (nb_rx_desc > dev_info.rx_desc_lim.nb_max || >> nb_rx_desc < dev_info.rx_desc_lim.nb_min || >> nb_rx_desc % dev_info.rx_desc_lim.nb_align != 0) { >> RTE_ETHDEV_LOG(ERR, >> "Invalid value for nb_rx_desc(=%hu), should be: <= %hu, >= %hu, >> and a product of %hu\n", >> nb_rx_desc, dev_info.rx_desc_lim.nb_max, >> dev_info.rx_desc_lim.nb_min, >> dev_info.rx_desc_lim.nb_align); >> return -EINVAL; >> } > > 'dev_info.rx_desc_lim' was set up in function 'ngbe_dev_info_get' with the struct 'rx_desc_lim' defined. > So I think it is appropriate to check with macros. However, the log can be Sorry, but I don't understand why do you want to duplicate check which is already done in a generic code.