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 A28C6423AC; Wed, 11 Jan 2023 13:52:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 962DF42C24; Wed, 11 Jan 2023 13:52:02 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2073.outbound.protection.outlook.com [40.107.237.73]) by mails.dpdk.org (Postfix) with ESMTP id 355F142C24 for ; Wed, 11 Jan 2023 13:52:01 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UGNvLM/ywBI1Ebybd7ium9F6SVcF+4ux9acojjQ5GQRFTu4B34QA1rz993Z5nS+YayXpgeGJtJozxbSnS+c6nPqWTQKfqHfGkUrrbFIG/UP7SI6hnUiaBCS/h3uMBFSEx/DEpxVGT8IFzATDJun15FgdTJnhdCi2qSo4ihG/reyZ+ADEGyzMfg3ps4cd2yR8cvHWGpYS5fig09Qg294C+Gj0IBUB5mCH88NqExVnsfCf5hAzqGJk+MYBJjdNvuWu15QGuHBhzc+2mKrRLeAKBtXJJyaiFY8fMwVAB5kZxQwUkMpdDIpx4y2zi8l7WosaZeDqPmHxUrOT0HuizkF2PA== 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=tm4TlfEjKdBGYJ2t+jK91Woikkb6C5jR+oFjeMmGEa0=; b=e3HV/5bzalx60tjr/vpxHGxTfbi9ZK09IqVQH1X5MT1zpvY8uIgoGN3nYR0VDn+nvCldLB6jztO8D9PQnEe6R0lidC0E8PECV6mvCHjG3vvHBdhmHci5YYFC9UiZ4K9Ob891DPAmxLtqh4fVhIz+s0yWh1EXNAGmEKFJwGab1sf9SoN3V6Qcp/uqKP6xSGfPjO6FmGb6waCCkbXJ8iTFCYEihBf8UPOFCZGmRKDDki4P8bxOjnpimk5WO2heMfajg+UFtyllJG7HnyVyeodEFiTI3drC4/nabOT642CGlNq5YL7L+U1SXe5MuZCSJ6I3KerRgpNkJ5Pyy7Gf28Q6lA== 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=tm4TlfEjKdBGYJ2t+jK91Woikkb6C5jR+oFjeMmGEa0=; b=B3C59+hhFkmpRnIPDkzKDldt+RbbCePCn1yr2fVTwLTTAltwEsKCPDiC7IB7aTJwDcJPZ1asHES/7/cXTHtQ4n4/mTn/lQlUUQKB8gcF4b53y00/mi8y1F4I4t/iT3BRh/rW5vyx3YfN/x1FXrQqaIcAzzXMVxUCOdJQJTw/M/8= 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 CH0PR12MB5332.namprd12.prod.outlook.com (2603:10b6:610:d7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Wed, 11 Jan 2023 12:51:59 +0000 Received: from CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a]) by CH2PR12MB4294.namprd12.prod.outlook.com ([fe80::4807:1f44:5e04:e05a%9]) with mapi id 15.20.5986.018; Wed, 11 Jan 2023 12:51:59 +0000 Message-ID: Date: Wed, 11 Jan 2023 12:51:54 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US To: Huisong Li , dev@dpdk.org, andrew.rybchenko@oktetlabs.ru Cc: thomas@monjalon.net, liudongdong3@huawei.com, huangdaode@huawei.com, fengchengwen@huawei.com, Aman Singh References: <20220825024425.10534-1-lihuisong@huawei.com> <20221206092649.8287-1-lihuisong@huawei.com> <20221206092649.8287-5-lihuisong@huawei.com> From: Ferruh Yigit Subject: Re: [PATCH V4 4/5] app/testpmd: add attach and detach port for multiple process In-Reply-To: <20221206092649.8287-5-lihuisong@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0225.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:315::10) To CH2PR12MB4294.namprd12.prod.outlook.com (2603:10b6:610:a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB4294:EE_|CH0PR12MB5332:EE_ X-MS-Office365-Filtering-Correlation-Id: c1662a99-b0ba-4cbc-6acf-08daf3d2a0df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bKy62d52kYvi3i54+Iek7tTnf8bYIrLBKUhjkjbyLl2zZ44n7jZo0x15SQQgAN5j9pkTbM7yvRmiFlaBOiMKEXfRPkTH3teD5N3sMM7VRjsc/d3mYWsx6HZiAW4FURB57IpnELQ/0NfkuVWukod33CpqP2RhzMBrNDvOZwEY3F4YM/vqUl57bdP3rp/325+OhgkxNX5Tf+3wQAr+y7TBZZwRzVT/2tF7dA+lpJtNS0wfs4nc4yY+GZ9fLFIerHZExlLTbwy+Lhw2eKzLM5DmMdtXyKZLBfCssmJXfXHGqVThjprPm0F1u0vqygqeX1dett38o8xI8ZxgO0R62r7ri1YOhgFSR9rqjkqVLKGrghrf1ITesy5flOTniI7kyYDy5T389KjljShsuF9voNChWR3T5PU1GJ6qsyh6npYq30eW2Mdu8b4dGPsmGFvYwfWj01XHf6Efm0nfyf3Y9XKR6yjWGlJscz4PHPYuIKugFKiyBrEpxy2dcwb30/8FR1oDsMcJ/DSER1DTpaN28IvdR/RyjgsiKzh0ALU7gNTRiq/p8E6EwIWaEDZojSYrnH74TC1usUF0TkjWqRRlljd3IKwGauLSk7KlHfS3Aq2RzcmwmTrMhA56HIGsrexriCvt0ACwUcFEoIYe27AwSIiy5nKBu+iSgi07rdTYoEgL2E2JG2fK5z4tH2d6S0mKTNcUYBQjTPh2LnUCMQVqSaGQqXzKhRVZV8lkL1JHf3+sQ9U= 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)(396003)(39860400002)(136003)(366004)(376002)(451199015)(6506007)(38100700002)(6666004)(53546011)(31686004)(2906002)(44832011)(478600001)(2616005)(6486002)(186003)(6512007)(26005)(316002)(5660300002)(31696002)(83380400001)(8936002)(36756003)(86362001)(66476007)(4326008)(8676002)(41300700001)(66556008)(66946007)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eEI1cHZ4dnBiWGZ4QW81VldRY2ZpK2ZlcUNVNzZkRzlBbHhaZXA4WUl0dGVV?= =?utf-8?B?ZkxQU2w0TFJuOEp3RWNxWG9aNzl3Ky8vQUpzTnRNMzZzWkh1MEJ5Y09NTGY0?= =?utf-8?B?NXNDMTBnL1lBWHNSZFJ3dlNOTG9WYVo2VlBQN3AvbXVlYzhVVlFyYUZrTHZv?= =?utf-8?B?a1V3eUZIZEdHQTFvbk1hL0VJVk1DbTZueE5Eb1JuRUd3QU1zaDhFd3VjUWNu?= =?utf-8?B?dWxnNlhIdTFheE1jSVNXb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TjRka2pB?= =?utf-8?B?MUM4Mm00VElLU0wvMjlNKzNscDBvYlJROURxZHhmVC9Cc21zZ01YNWM5Tkta?= =?utf-8?Q?Sm+U9lzQVBNQDAL0zLxGXRtlI?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1662a99-b0ba-4cbc-6acf-08daf3d2a0df X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB4294.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jan 2023 12:51:59.6055 (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: ZBiU3INYuQoELoE5pRmhbWGWXJxQ7R+LCEYuv+mTDIWlUoqKMXfB7N1+BPkWJ52t X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5332 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 12/6/2022 9:26 AM, Huisong Li wrote: > This patch supports attach and detach port in primary and secondary > process. > Hi Huisong, This patch moves port setup and remove (via alarm callback) to event callback, 1) I can see it is for MP but can you please give more details, what was the problem before, how this solves the issue 2) I am concerned about doing more work on the event callback and observe some unexpected side effects later, can't we handle this out of event callback > Signed-off-by: Huisong Li > Signed-off-by: Dongdong Liu > --- > app/test-pmd/testpmd.c | 38 ++++++++++++++++----------- > app/test-pmd/testpmd.h | 1 - > drivers/net/bonding/bonding_testpmd.c | 1 - > 3 files changed, 22 insertions(+), 18 deletions(-) > > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c > index bc25703490..2e6329c853 100644 > --- a/app/test-pmd/testpmd.c > +++ b/app/test-pmd/testpmd.c > @@ -3463,15 +3463,12 @@ attach_port(char *identifier) > return; > } > > - /* first attach mode: event */ > - if (setup_on_probe_event) { > - /* new ports are detected on RTE_ETH_EVENT_NEW event */ > - for (pi = 0; pi < RTE_MAX_ETHPORTS; pi++) > - if (ports[pi].port_status == RTE_PORT_HANDLING && > - ports[pi].need_setup != 0) > - setup_attached_port(pi); > + /* > + * first attach mode: event, setting up attached port is done in > + * probing callback. > + */ > + if (setup_on_probe_event) > return; > - } > > /* second attach mode: iterator */ > RTE_ETH_FOREACH_MATCHING_DEV(pi, identifier, &iterator) { > @@ -3502,7 +3499,6 @@ setup_attached_port(portid_t pi) > ports_ids[nb_ports++] = pi; > fwd_ports_ids[nb_fwd_ports++] = pi; > nb_cfg_ports = nb_fwd_ports; > - ports[pi].need_setup = 0; > ports[pi].port_status = RTE_PORT_STOPPED; > > printf("Port %d is attached. Now total ports is %d\n", pi, nb_ports); > @@ -3536,10 +3532,8 @@ detach_device(struct rte_device *dev) > TESTPMD_LOG(ERR, "Failed to detach device %s\n", rte_dev_name(dev)); > return; > } > - remove_invalid_ports(); > > printf("Device is detached\n"); > - printf("Now total ports is %d\n", nb_ports); > printf("Done\n"); > return; > } > @@ -3606,11 +3600,9 @@ detach_devargs(char *identifier) > return; > } > > - remove_invalid_ports(); > - > printf("Device %s is detached\n", identifier); > - printf("Now total ports is %d\n", nb_ports); > printf("Done\n"); > + > rte_devargs_reset(&da); > } > > @@ -3774,11 +3766,22 @@ rmv_port_callback(void *arg) > struct rte_device *device = dev_info.device; > close_port(port_id); > detach_device(device); /* might be already removed or have more ports */ > + remove_invalid_ports(); > + printf("Now total ports is %d\n", nb_ports); > } > if (need_to_start) > start_packet_forwarding(0); > } > > +static void > +remove_invalid_ports_callback(void *arg) > +{ > + RTE_SET_USED(arg); > + > + remove_invalid_ports(); > + printf("Now total ports is %d\n", nb_ports); > +} > + > /* This function is used by the interrupt thread */ > static int > eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param, > @@ -3803,8 +3806,8 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param, > > switch (type) { > case RTE_ETH_EVENT_NEW: > - ports[port_id].need_setup = 1; > - ports[port_id].port_status = RTE_PORT_HANDLING; > + if (setup_on_probe_event) > + setup_attached_port(port_id); > break; > case RTE_ETH_EVENT_INTR_RMV: > if (rte_eal_alarm_set(100000, > @@ -3815,6 +3818,9 @@ eth_event_callback(portid_t port_id, enum rte_eth_event_type type, void *param, > case RTE_ETH_EVENT_DESTROY: > ports[port_id].port_status = RTE_PORT_CLOSED; > printf("Port %u is closed\n", port_id); > + if (rte_eal_alarm_set(100000, remove_invalid_ports_callback, > + (void *)(intptr_t)port_id)) > + fprintf(stderr, "Could not set up deferred device released\n"); > break; > case RTE_ETH_EVENT_RX_AVAIL_THRESH: { > uint16_t rxq_id; > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h > index 7d24d25970..080d3a1139 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -306,7 +306,6 @@ struct rte_port { > uint16_t tx_vlan_id;/**< The tag ID */ > uint16_t tx_vlan_id_outer;/**< The outer tag ID */ > volatile uint16_t port_status; /**< port started or not */ > - uint8_t need_setup; /**< port just attached */ > uint8_t need_reconfig; /**< need reconfiguring port or not */ > uint8_t need_reconfig_queues; /**< need reconfiguring queues or not */ > uint8_t rss_flag; /**< enable rss or not */ > diff --git a/drivers/net/bonding/bonding_testpmd.c b/drivers/net/bonding/bonding_testpmd.c > index 9529e16fb6..9216271314 100644 > --- a/drivers/net/bonding/bonding_testpmd.c > +++ b/drivers/net/bonding/bonding_testpmd.c > @@ -765,7 +765,6 @@ static void cmd_create_bonded_device_parsed(void *parsed_result, > > ports[port_id].update_conf = 1; > ports[port_id].bond_flag = 1; > - ports[port_id].need_setup = 0; > ports[port_id].port_status = RTE_PORT_STOPPED; > } >