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 1D3C94265E; Thu, 28 Sep 2023 11:24:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DB4B140273; Thu, 28 Sep 2023 11:24:06 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 8890340150 for ; Thu, 28 Sep 2023 11:24:04 +0200 (CEST) Received: from kwepemm000004.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rx7J447PlzVjN1; Thu, 28 Sep 2023 17:20:52 +0800 (CST) Received: from [10.67.121.59] (10.67.121.59) by kwepemm000004.china.huawei.com (7.193.23.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 28 Sep 2023 17:24:02 +0800 Message-ID: <50bbacdd-f763-2c7b-f7ff-0bec5ce316db@huawei.com> Date: Thu, 28 Sep 2023 17:24:01 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v2 1/8] lib/ethdev: update Rx and Tx queue status To: Jie Hai , , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko References: <20230908112901.1169869-1-haijie1@huawei.com> <20230928074305.2991100-1-haijie1@huawei.com> <20230928074305.2991100-2-haijie1@huawei.com> From: "lihuisong (C)" In-Reply-To: <20230928074305.2991100-2-haijie1@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.121.59] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm000004.china.huawei.com (7.193.23.18) X-CFilter-Loop: Reflected 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 在 2023/9/28 15:42, Jie Hai 写道: > The DPDK framework reports the queue status, which is stored in > 'dev->data->tx_queue_state' and 'dev->data->rx_queue_state'.The > state is currently maintained by the drivers. Users may determine > whether a queue participates in packet forwarding based on the > state. However, not all drivers correctly report the queue status. > This may cause forwarding problems. > > Since it is difficult to modify the queue status of all drivers, > we consider updating the queue status at the framework level. > Some drivers support queues for hairpin, leaving status updating > for such queues to the drivers. Some drivers support > 'deferred_start'. Assume that all drivers that support > 'deferred_start' can obtain the configuration through > 'rte_eth_tx_queue_info_get' and 'rte_eth_rx_queue_info_get'. So > we can directly update the queue status in 'rte_eth_dev_start' > and 'rte_eth_dev_stop'. > > Signed-off-by: Jie Hai > --- > lib/ethdev/rte_ethdev.c | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c > index 0840d2b5942a..e3aaa71eba9e 100644 > --- a/lib/ethdev/rte_ethdev.c > +++ b/lib/ethdev/rte_ethdev.c > @@ -1641,6 +1641,9 @@ rte_eth_dev_start(uint16_t port_id) > struct rte_eth_dev_info dev_info; > int diag; > int ret, ret_stop; > + uint16_t i; > + struct rte_eth_rxq_info rxq_info; > + struct rte_eth_txq_info txq_info; > > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > dev = &rte_eth_devices[port_id]; > @@ -1697,6 +1700,30 @@ rte_eth_dev_start(uint16_t port_id) > (*dev->dev_ops->link_update)(dev, 0); > } > > + for (i = 0; i < dev->data->nb_rx_queues; i++) { > + if (rte_eth_dev_is_rx_hairpin_queue(dev, i)) > + continue; > + > + memset(&rxq_info, 0, sizeof(rxq_info)); This memset() is unsed because this operation is already in the rte_eth_rx/tx_queue_info_get(). > + ret = rte_eth_rx_queue_info_get(port_id, i, &rxq_info); > + if (ret == 0 && rxq_info.conf.rx_deferred_start != 0) > + dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; > + else > + dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED; > + } > + > + for (i = 0; i < dev->data->nb_tx_queues; i++) { > + if (rte_eth_dev_is_tx_hairpin_queue(dev, i)) > + continue; > + > + memset(&txq_info, 0, sizeof(txq_info)); > + ret = rte_eth_tx_queue_info_get(port_id, i, &txq_info); > + if (ret == 0 && txq_info.conf.tx_deferred_start != 0) > + dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; > + else > + dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STARTED; > + } Suggest: extract a functon to start/stop Rx/Tx queue states. > + > /* expose selection of PMD fast-path functions */ > eth_dev_fp_ops_setup(rte_eth_fp_ops + port_id, dev); > > @@ -1708,6 +1735,7 @@ int > rte_eth_dev_stop(uint16_t port_id) > { > struct rte_eth_dev *dev; > + uint16_t i; > int ret; > > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > @@ -1731,6 +1759,18 @@ rte_eth_dev_stop(uint16_t port_id) > dev->data->dev_started = 0; > rte_ethdev_trace_stop(port_id, ret); > > + for (i = 0; i < dev->data->nb_rx_queues; i++) { > + if (rte_eth_dev_is_rx_hairpin_queue(dev, i)) > + continue; > + dev->data->rx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; > + } > + > + for (i = 0; i < dev->data->nb_tx_queues; i++) { > + if (rte_eth_dev_is_tx_hairpin_queue(dev, i)) > + continue; > + dev->data->tx_queue_state[i] = RTE_ETH_QUEUE_STATE_STOPPED; > + } > + > return ret; > } >