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 E7AE2A0542; Mon, 14 Nov 2022 18:10:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CA5F140150; Mon, 14 Nov 2022 18:10:12 +0100 (CET) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2082.outbound.protection.outlook.com [40.107.95.82]) by mails.dpdk.org (Postfix) with ESMTP id 90C2B4014F for ; Mon, 14 Nov 2022 18:10:11 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IeMQE9oLNDa2BVCEOnKWTTgiAz/4nBFujqnMwMkHSHqnKrqtAwllLaUdtzB+7/F2zJNo9UR/XlUR0PZnopiM8k6Yb8UldZiJlGZjRx/yKbuPXpXHLt/PnLZvVOATdlSRUBygRK1uMvaXFHAEOo79m1439anOLAKEf1WHetVSJX5cNpe5DPZ9v7raJ0asViCxmNLc+Xp3ETLnloMbTE1oR4X7+O/Nn6Pw+QYnj+bpJCSCehNPiu5bWVK4dRgGndnUlRBqeZCwTYK8GoWg9usa1RGA/OlUwT05SZfjKbMbN+Q968ZqRy3e5a0IzoMFTZBMLCzhSjJeTmdM8suHS1rHTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=u5LenvXbp9o4gmN1Llt3x2/Jbfa3ULB5Wrq1RV09Zac=; b=WLm5udclixMNxJlPkREYVLG2Jq8evqpoRDKtgvAQS6L6HFDZmpD32+CVOPB06DAGJ9Q9NmnJ8nlpwFtP2mUhKyZEnP5x8WVlWS7hzOXlTNv6BjSuApeUMoq1jJx1rXDK2j8xmDHxqlILj8MqO1FOzZPoijhzfQHHyCHAd2bBlHnK2dhYyfXtLavpe4utUyHEF51Xfb4xRMd0mS4Op5fMSdkJM6v+8hlhW9a+yZgzCFbW1Pfxrg6XPjvef1FM3NxqdfNkvHFEYaltqSJCAQ55WY26+BGaEgFZ0s1HN9NmhVi/XXDnmQxO3HlABrH51NchH8F6Ura3DEEMCCKSLN5D9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u5LenvXbp9o4gmN1Llt3x2/Jbfa3ULB5Wrq1RV09Zac=; b=q+IeVCHlf8igKuuix6hEDWFZkgEJ6+9fXSVwOAEk/q//ndTuUZnkhX/cSXzbUCaypKOK++kkpqWLi7UY3eTTu3WUlnkD5iC8QbCChGQuFtZHNrJPOtSefcLX60oXcRTBxG+SY4+01wEp9pv2B9HQSwviuPECFrHjgXgZAj8g008= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) by MW3PR12MB4395.namprd12.prod.outlook.com (2603:10b6:303:5c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Mon, 14 Nov 2022 17:10:09 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::b482:d5bd:c7d0:3842]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::b482:d5bd:c7d0:3842%9]) with mapi id 15.20.5813.017; Mon, 14 Nov 2022 17:10:09 +0000 Message-ID: Date: Mon, 14 Nov 2022 17:10:04 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: en-US To: Dariusz Sosnowski , Aman Singh , Yuying Zhang , "NBU-Contact-Thomas Monjalon (EXTERNAL)" , Andrew Rybchenko Cc: "dev@dpdk.org" References: <20221109190639.886457-1-dsosnowski@nvidia.com> <20221109190639.886457-4-dsosnowski@nvidia.com> <2f11dfbb-fa91-6fcc-c88b-8723e6d55753@amd.com> From: Ferruh Yigit Subject: Re: [PATCH v2 3/3] ethdev: document special cases of port start and stop In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0393.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18f::20) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|MW3PR12MB4395:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a6634a0-022b-41eb-2d4f-08dac6631575 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zS9O0fmkr4t5QC59qtOGtna0QQbjfc4I2VjTdD+oEEYNt3zRyrDQKwZgQKUIKclkq3EbZpsidfRZSZMiJ8UQ0SnnVTFIuJjlIOxbYk0O3ykmuQ4lw6Q/RRrJOYjIGZbXWTcfQ1Djpc9s/Rm1xxuYeQUUIBj4U/sudIvc83X4LPBupJhFICt/W7eJdEGVvLR+0K5s9MZLX50wD+UvmsvFEet5AjF4Xuh7C70oquKZg230X+J4ydrhA7EgcMz89yKyUJ0IpVePf25auhUKZOqSjkKJP31U+hV8sxm6LLnMFAKcvX4CWcYVnZg++D0dQvHA2X15txdck9nmePf24T5CsdlYWrQkR2yFwDodBcKdwSEGm3NfOvV+A9sB84Hcy3lpQwhCGo6j8ISlqOWYr4rBabthaJoQowaWKDmeemH45zvKTqjVoqZK5aFzRiA2hh434kSz2wso5sJmvGSw2A1y3oxp0iNSj4o5AxhTLwfGDUI7Irgj8at0fVmu8x4IByw1LrfH5fEFsXRfjPYGqlwUFLLuaf8JhZoeNLb8OWcrjHYbP5xoU+4xhlO/2qf9564rf4fw1I98EBK1N90bGDXSqZcTbbyAGXWOPZT7JZCC9s5zTVlBErFNNHn4sOw8T0vPC5F3AAlccRg1g9/gmkVlwnSoMW5e5ITe/jI9ef/1IV2i9J6s80wYtA4Co5oSIhxD9xssU2cv0H+HbWX4u34D9VesOlOrsMKCGPQEehRU7XY9L+ksIRRQD6YpMF2pBtwRoV7c+efHm5a+MzjHK3GhyujGPTAvbvonSSuMMSc+/uI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB4294.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(346002)(39860400002)(396003)(136003)(376002)(366004)(451199015)(2616005)(2906002)(6506007)(316002)(53546011)(66946007)(8676002)(41300700001)(36756003)(83380400001)(6512007)(26005)(5660300002)(8936002)(186003)(4326008)(66476007)(66556008)(44832011)(31686004)(110136005)(86362001)(38100700002)(6486002)(478600001)(31696002)(6666004)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bVhwZVhFb1FqTUNEbHB4NVRBYzAzcXNUWmJya3QvOTcvam1VVWFOdldLbk1m?= =?utf-8?B?d3h3bU03dWdKZ1dJTHo0Rnkvb0thbVZJMGcwUTRlemlRWENmNHByMXdmdmZR?= =?utf-8?B?dXNOVnM1SzI1ZS9VU0JpNXl4Q1p2T1hUZWRDUmJmNDM1UmllM2lMNTcvcllV?= =?utf-8?B?ZTY5dmRWS01PdzRBQXJKKzdDbjF4ckJuRktWZjVFZForTVlPRmZBZHFG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MUZFeHg3RThTSGhRNnBNYjNMQnU5aThlZCtFbzgv?= =?utf-8?B?RUV3ZXlTdWt5bG80TnAzTDEwZ2l4M2tpUzRBa1l3cHY1SHYyOGJnUmJhUEVm?= =?utf-8?Q?iRaDxqtt9k0SyW9wSJytrzjFW?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a6634a0-022b-41eb-2d4f-08dac6631575 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2022 17:10:09.2284 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VkF7TxbbiJoebQ/JE/BuwcE6qr7N3vDPHYkqxvBN91GdYRbrDK/zqW6SKOc+VGM8 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4395 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 On 11/14/2022 4:12 PM, Dariusz Sosnowski wrote: > Hi Ferruh, > >> -----Original Message----- >> From: Ferruh Yigit >> Sent: Monday, November 14, 2022 15:08 >> To: Dariusz Sosnowski ; Aman Singh >> ; Yuying Zhang ; >> NBU-Contact-Thomas Monjalon (EXTERNAL) ; >> Andrew Rybchenko >> Cc: dev@dpdk.org >> Subject: Re: [PATCH v2 3/3] ethdev: document special cases of port start and >> stop >> >> External email: Use caution opening links or attachments >> >> >> On 11/9/2022 7:06 PM, Dariusz Sosnowski wrote: >>> This patch clarifies the handling of following cases in the ethdev API >>> docs: >>> >>> - If rte_eth_dev_start() returns (-EAGAIN) for some port, >>> it cannot be started until other port is started. >>> - If rte_eth_dev_stop() returns (-EBUSY) for some port, >>> it cannot be stopped until other port is stopped. >>> >> >> EAGAIN and EBUSY has kind of standard meaning, I am not sure if it is good >> idea to change this meaning to a specific "dependency to other port" use >> case. >> Why not keep common generic meanings of the error codes? > > In my opinion, using standard error meanings for EAGAIN and EBUSY would make the returned errors too vague for the API user. > If we used the standard meanings, it's not clear why the port cannot be started or stopped and what the user should do about it. > Providing specific reasons in the API makes it more understandable. On top of that, they are "subcases" of standard errors: > I think generic error meaning is not vague, although underlying reason is. > - "Port cannot be stopped because another port depends on it" is a special case of "Device or resource is busy". > - "Port cannot be started because it depends on other port being started" is a special case of "Resource temporarily unavailable". > > However, I see your concern, so maybe let's do the following. To not limit the API, we could for example: > > - In the documentation of returned values - provide the generic meaning for the EAGAIN and EBUSY: > - rte_eth_dev_stop(): EBUSY is returned if stopping the port is not allowed in the current state. > - rte_eth_dev_start(): EAGAIN is returned if start operation must be retried. > - In the function description provide the specific use case of "dependency on other port" as an example > of EBUSY/EAGAIN usage > - Depending on the use cases emerging in the future, new examples can be added, > if EBUSY/EAGAIN is suitable for the new use cases. > > What do you think? OK to above generic error documentation. And what do you think to document "dependency on other port" in the driver dev_ops function comment, since it will be an instance of the generic error message. > >>> When stopping the port in testpmd fails due to (-EBUSY), port's state >>> is switched back to STARTED to allow users to manually retry stopping >>> the port. >>> >>> No additional changes in testpmd are required to handle failure to >>> start port with (-EAGAIN). >>> If rte_eth_dev_start() fails, port's state is switched to STOPPED and >>> users are allowed to retry the operation. >>> >>> Signed-off-by: Dariusz Sosnowski >>> --- >>> app/test-pmd/testpmd.c | 10 +++++++++- >>> lib/ethdev/rte_ethdev.h | 9 +++++++++ >>> 2 files changed, 18 insertions(+), 1 deletion(-) >>> >>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index >>> aa7ea29f15..5a69e3c77a 100644 >>> --- a/app/test-pmd/testpmd.c >>> +++ b/app/test-pmd/testpmd.c >>> @@ -3118,6 +3118,7 @@ stop_port(portid_t pid) >>> int need_check_link_status = 0; >>> portid_t peer_pl[RTE_MAX_ETHPORTS]; >>> int peer_pi; >>> + int ret; >>> >>> if (port_id_is_invalid(pid, ENABLED_WARN)) >>> return; >>> @@ -3167,9 +3168,16 @@ stop_port(portid_t pid) >>> if (port->flow_list) >>> port_flow_flush(pi); >>> >>> - if (eth_dev_stop_mp(pi) != 0) >>> + ret = eth_dev_stop_mp(pi); >>> + if (ret != 0) { >>> RTE_LOG(ERR, EAL, "rte_eth_dev_stop failed for port %u\n", >>> pi); >>> + if (ret == -EBUSY) { >>> + /* Allow to retry stopping the port. */ >>> + port->port_status = RTE_PORT_STARTED; >> >> If the stop() failed, isn't the current status should be STARTED independent >> from the error type? > > Correct. I'll update it in v3. > >>> + continue; >>> + } >>> + } >>> >>> if (port->port_status == RTE_PORT_HANDLING) >>> port->port_status = RTE_PORT_STOPPED; diff --git >>> a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index >>> 13fe73d5a3..abf5a24f92 100644 >>> --- a/lib/ethdev/rte_ethdev.h >>> +++ b/lib/ethdev/rte_ethdev.h >>> @@ -2701,10 +2701,14 @@ int rte_eth_dev_tx_queue_stop(uint16_t >> port_id, uint16_t tx_queue_id); >>> * On success, all basic functions exported by the Ethernet API (link status, >>> * receive/transmit, and so on) can be invoked. >>> * >>> + * If the port depends on another one being started, >>> + * PMDs might return (-EAGAIN) to notify about such requirement. >>> + * >>> * @param port_id >>> * The port identifier of the Ethernet device. >>> * @return >>> * - 0: Success, Ethernet device started. >>> + * - -EAGAIN: If it depends on another port to be started first. >>> * - <0: Error code of the driver device start function. >>> */ >>> int rte_eth_dev_start(uint16_t port_id); @@ -2713,10 +2717,15 @@ int >>> rte_eth_dev_start(uint16_t port_id); >>> * Stop an Ethernet device. The device can be restarted with a call to >>> * rte_eth_dev_start() >>> * >>> + * If the port provides some resources for other ports >>> + * and it cannot be stopped before them, >>> + * PMDs might return (-EBUSY) to notify about such requirement. >>> + * >>> * @param port_id >>> * The port identifier of the Ethernet device. >>> * @return >>> * - 0: Success, Ethernet device stopped. >>> + * - -EBUSY: If it depends on another port to be stopped first. >>> * - <0: Error code of the driver device stop function. >>> */ >>> int rte_eth_dev_stop(uint16_t port_id); > > Best regards, > Dariusz Sosnowski >