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 A87FDA0C48; Wed, 7 Jul 2021 04:56:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 288A34069E; Wed, 7 Jul 2021 04:56:33 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id B5A394003C for ; Wed, 7 Jul 2021 04:56:31 +0200 (CEST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GKP7S5x33zXqGD; Wed, 7 Jul 2021 10:51:00 +0800 (CST) Received: from dggema767-chm.china.huawei.com (10.1.198.209) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Wed, 7 Jul 2021 10:56:28 +0800 Received: from [10.66.74.184] (10.66.74.184) by dggema767-chm.china.huawei.com (10.1.198.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 7 Jul 2021 10:56:28 +0800 To: Andrew Rybchenko , CC: , , , "david.marchand@redhat.com" , Ray Kinsella References: <1620460836-38506-1-git-send-email-lihuisong@huawei.com> <1625544608-30590-1-git-send-email-lihuisong@huawei.com> <966ec9cd-9142-b40d-b059-b63c8ece66bf@oktetlabs.ru> From: Huisong Li Message-ID: <759fb9f8-3068-a5a2-e7cb-2445581aa960@huawei.com> Date: Wed, 7 Jul 2021 10:55:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <966ec9cd-9142-b40d-b059-b63c8ece66bf@oktetlabs.ru> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.66.74.184] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggema767-chm.china.huawei.com (10.1.198.209) X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH V2] ethdev: add dev configured flag 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" 在 2021/7/6 16:36, Andrew Rybchenko 写道: > @David, could you take a look at the ABI breakage warnings for > the patch. May we ignore it since ABI looks backward > compatible? Or should be marked as a minor change ABI > which is backward compatible with DPDK_21? > > On 7/6/21 7:10 AM, Huisong Li wrote: >> Currently, if dev_configure is not called or fails to be called, users >> can still call dev_start successfully. So it is necessary to have a flag >> which indicates whether the device is configured, to control whether >> dev_start can be called and eliminate dependency on user invocation order. >> >> The flag stored in "struct rte_eth_dev_data" is more reasonable than >> "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the >> primary and secondary processes, and can be independently controlled. >> However, the secondary process does not make resource allocations and >> does not call dev_configure(). These are done by the primary process >> and can be obtained or used by the secondary process. So this patch >> adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started". >> >> Signed-off-by: Huisong Li > Reviewed-by: Andrew Rybchenko > >> --- >> v1 -> v2: >> - adjusting the description of patch. >> >> --- >> lib/ethdev/rte_ethdev.c | 16 ++++++++++++++++ >> lib/ethdev/rte_ethdev_core.h | 6 +++++- >> 2 files changed, 21 insertions(+), 1 deletion(-) >> >> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c >> index c607eab..6540432 100644 >> --- a/lib/ethdev/rte_ethdev.c >> +++ b/lib/ethdev/rte_ethdev.c >> @@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, >> return -EBUSY; >> } >> >> + /* >> + * Ensure that "dev_configured" is always 0 each time prepare to do >> + * dev_configure() to avoid any non-anticipated behaviour. >> + * And set to 1 when dev_configure() is executed successfully. >> + */ >> + dev->data->dev_configured = 0; >> + >> /* Store original config, as rollback required on failure */ >> memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf)); >> >> @@ -1606,6 +1613,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q, >> } >> >> rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0); >> + dev->data->dev_configured = 1; >> + > I think it should be inserted before the trace, since tracing > is intentionally put close to return without any empty lines > in between. All right. Do I need to send a patch V3? >> return 0; >> reset_queues: >> eth_dev_rx_queue_config(dev, 0); >> @@ -1751,6 +1760,13 @@ rte_eth_dev_start(uint16_t port_id) >> >> RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP); >> >> + if (dev->data->dev_configured == 0) { >> + RTE_ETHDEV_LOG(INFO, >> + "Device with port_id=%"PRIu16" is not configured.\n", >> + port_id); >> + return -EINVAL; >> + } >> + >> if (dev->data->dev_started != 0) { >> RTE_ETHDEV_LOG(INFO, >> "Device with port_id=%"PRIu16" already started\n", >> diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h >> index 4679d94..edf96de 100644 >> --- a/lib/ethdev/rte_ethdev_core.h >> +++ b/lib/ethdev/rte_ethdev_core.h >> @@ -167,7 +167,11 @@ struct rte_eth_dev_data { >> scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */ >> all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */ >> dev_started : 1, /**< Device state: STARTED(1) / STOPPED(0). */ >> - lro : 1; /**< RX LRO is ON(1) / OFF(0) */ >> + lro : 1, /**< RX LRO is ON(1) / OFF(0) */ >> + dev_configured : 1; >> + /**< Indicates whether the device is configured. >> + * CONFIGURED(1) / NOT CONFIGURED(0). >> + */ >> uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT]; >> /**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */ >> uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT]; >> > .