From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0065.outbound.protection.outlook.com [104.47.2.65]) by dpdk.org (Postfix) with ESMTP id 4486D2C24; Thu, 3 May 2018 12:32:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ULt/R6mOdktT6ZYrifVwLKambL8ljyelrvPJMIPEnFo=; b=eG6NZfwVQJ1LJbpIvwKgCoVjztQedBQj1n8QlgwTXBHCJJaZPdFK9UDQykEiR5MjhDivgvphFF3GWYwhMlvhCBPTpXi5nv7KSJaTeB1OaQHhQMgQvoipBDr+iL6k7MXjfAGqQl2w++fDCzZv4vpIFhzRtEH4FxO75KGMGmxiqPg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR0501MB2665.eurprd05.prod.outlook.com (2603:10a6:3:cb::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.22; Thu, 3 May 2018 10:32:14 +0000 From: Matan Azrad To: Wenzhuo Lu , Jingjing Wu Cc: dev@dpdk.org, stable@dpdk.org Date: Thu, 3 May 2018 10:31:46 +0000 Message-Id: <1525343508-29487-5-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.9.5 In-Reply-To: <1525343508-29487-1-git-send-email-matan@mellanox.com> References: <1525343508-29487-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR08CA0058.eurprd08.prod.outlook.com (2603:10a6:7:2a::29) To HE1PR0501MB2665.eurprd05.prod.outlook.com (2603:10a6:3:cb::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:HE1PR0501MB2665; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2665; 3:nOmL6YEj0WhzfDmqOD7bbB683qtBRjGaeP4v33uOGy+dyQBSyhPi50a6NamwlA7fWsFeuRjVQB7uDAqR/c5VumJbjN6hGpXcOqAZdBsqscNvHuQRmOvYIdDkBGp5RLzylPXdDZaFR8NDP5MhqBJInTghqPuxx0vZGwf1PR2DUQHYiHL2FJr6dKI/OztqtK6EV4vm8pm7iOpevyyRsvSCXw9g3ZnmeNaHakih+7mITzvBvONJPdnEs+Mwj/oT7One; 25:HpVahDXWQTbzN0g8RH3h1KBX7lcOfHr46E6c0ZIsbE9ruqxv2H3EfegcMkbtmf9EVLlCHkCbEqt8SDujQsGffdrpgR0JCt/GwEqLk2fwdr7rLQnaEYQzqsPP0MZ3wm5+VQ9w+/kqj+68ormOefs69Bouc0+z68IRsdaspqbi/URdcLWYsfNs6/srHULxD79N7ZFrZRtTp/dsMu9Xxe1kx9G5O28IUHKc8PYLHPTBuEmkotJVea/bVMCcLD/0fhKM4zZGEThgDX0MMkMUFocHHp+kfuEEbRYwrarjPm5TuKey1WXqTI6UXJFUWy4bHoSI1IK4VHKQv4hy0kP/Wtms+A==; 31:TupmmJ3FplPap8K8CVcJVjYBeKMOliNx9ODWxxGQVJfb/UMbK4j3CgS6OJMlOUD0W71wCV3tdBez0a7N4PyPd38I9Qaqhl/qB08kL+g6EvWsNAlM0E1U6e1627jDprvHrU3q6Ty8CkaMQx54+yGnusm9gb0abhRbe+EdAmyEjmHunEB2AkO4bBeKqYOGaiPcajjtqfBf8sjzha70lD0SCBcJjuhhhDqNPFOJW6XsaGU= X-MS-TrafficTypeDiagnostic: HE1PR0501MB2665: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0501MB2665; 20:ToEl+Pc7j7yBxirh/KeNwOdgsp08uY4h0WVv+f0tWonTNQ3rquH7aK5oZzo/EMjNYt19BF5eGfdXXzuAE0xTYz8X5SAuet3qIzv8Rf92Sx+NDl+YGNYgk3FqoufsZndtxDnVMzr4eBcZNqL0GOVzokmC4TfP0baj/JW8LNIeFAAM5rgXHNoYrkR12Pkifg7vVUiBeai8WU++uqO5r+Jb5ACjQnPXRcIoTbVLkqwPcDie71Dk50aMy6i85WmZCOoSVaDJFOtioJ5/zd2aZ/YqgHj8xPB2+BQAA3JkrVD++WWftZIFEwqIxP9zzCaki3fVUAgn6uiJ4IXN1yp1wouAii7vV9r2KtrqZJaQZDTvZ2i61MUakq6KCdSG6h6BLQKzBf8APr67PTNo+Ld+y5S5DG4SXr9Tcmie+DRgOwshEVW1XIha4kWaLluO9WAPityNxtc0Za/STFs5W/QqW53sWloM3cxJ3b9oqiVf1hD6PsSjUOPdVPRGOriTnHkKi/Gu; 4:OUYaN9VbNN7Jxj+hDeqe/VpQA1lQ9Vn1sIeKXyaupQcJ+xMYc963nmGc4ve+RrXkBxiralcjd53VwK/UCCI8wwjxalDKxdoVm0yOpn9JqMOYAwW+4K1oMmpWQx9UMDWYXaw+cWE0U7NYI7I1g5Qy593TlUmmHjokQwLPw5hfgAWf1vSC67vOtBEOaU/WfRZReOF3eg8tG9c7dhVa/n8XStMt8ezt7XNmEshGxDVXjKYrsEY44KBzl0UdXHMMnzF/MFuwzJ0WNJY72B1UUakhIQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:HE1PR0501MB2665; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0501MB2665; X-Forefront-PRVS: 066153096A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(346002)(376002)(39380400002)(39860400002)(396003)(189003)(199004)(97736004)(47776003)(316002)(52116002)(51416003)(36756003)(7696005)(86362001)(25786009)(16586007)(110136005)(68736007)(5660300001)(2906002)(8676002)(81166006)(81156014)(8936002)(66066001)(53936002)(3846002)(6666003)(26005)(305945005)(33026002)(11346002)(69596002)(186003)(106356001)(386003)(50226002)(486006)(55016002)(105586002)(4326008)(6116002)(7736002)(76176011)(5890100001)(446003)(478600001)(476003)(21086003)(59450400001)(48376002)(50466002)(2616005)(956004)(16526019); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0501MB2665; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0501MB2665; 23:ltHOT0fNthP70s6PUx7a0UFY6m8xdJ2wbqCQAq4?= =?us-ascii?Q?Cl47xMGB6n1nvZYyc/MqNJrttMQ6WvAAv4N7DxvWBbQPe4RhPky8ihAZdawm?= =?us-ascii?Q?mIXCeNWVPr+UvjwsYOHvHXte+S0wer5YQC5IsDybtMjBnpg0NLUgNiks3wgQ?= =?us-ascii?Q?mILN1kVMwZPRLag967bILxas8baMRVFLkOjk3KOim0kT2K8tgw2x9drFvisA?= =?us-ascii?Q?aA4bd8Oqhc9Yqg4rghXaq07O9t9nO3UZ9bMs9rl0kvc6EiJ3D8oqUVQjYUyQ?= =?us-ascii?Q?JvFq5fxnJdqQ2+9nOIXx+gTt2y2YVwCVLcUA0wzMsV9HjjW7y+AdWvImnMUv?= =?us-ascii?Q?RGpApPTB6VE7WwRT1jQ2z3n4vk32hgtjgBAPQjaKRRCtm5MVlzz0kYWawiqA?= =?us-ascii?Q?yYHk2/VpRyEFUJDkf8UNrtDPLek9mS6YwE+4s3q6IDrhxTYyBKPfRX2p2wa+?= =?us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 7:fLZ1guulsgofxFjZQbvvqMFC3SGiIk6Fb1qvYG0wgmRXfWb0Odl9w4e9VTl69DKLcLdfmTlXfnsPALAaARJg3+Nlc32BQbbw6a42ZktsAF4KRGPHYBOzgdAanS8CVV9LA8NoXgDdjwVQpMGI9YfI28hu0o+vmt/2bn0yvwC05QT919GrQIwiFM3C24j3wDo8ovHyGlSDcdRQw96qblw8an1lPzJzKLRsrz6T+Q9XPJ5ucsUD9rQPzhwOZ9nwsLW9 X-MS-Office365-Filtering-Correlation-Id: c2e9663c-1558-4dd5-17c3-08d5b0e12363 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2018 10:32:14.2807 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2e9663c-1558-4dd5-17c3-08d5b0e12363 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0501MB2665 Subject: [dpdk-dev] [PATCH 4/6] app/testpmd: fix synchronic port hotplug X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 May 2018 10:32:16 -0000 When the user uses the synchronic hot-plug commands, attach\detach, in order to insert\remove a port from the system, the forward ports list update is missed in the current implementation. Thus, an invalid port may be used for data-path in case of detach because the detached port was not removed from the forward port list. In addition, a new port is not used for data-path in case of attach, as the default behavior of Testpmd, because the attached port was not inserted to the forward port list. Update the forward port list in the above cases to allow the correct port usage for data-path in the next packet forwarding start. Fixes: edab33b1c01d ("app/testpmd: support port hotplug") Cc: stable@dpdk.org Signed-off-by: Matan Azrad --- app/test-pmd/testpmd.c | 29 +++++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 1 + 2 files changed, 30 insertions(+) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 1d3ede1..35f97f0 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1215,6 +1215,31 @@ static void eth_dev_event_callback(char *device_name, } /* + * Update the forward ports list. + */ +void +update_fwd_ports(portid_t new_pid) +{ + unsigned int i; + unsigned int new_nb_fwd_ports = 0; + int move = 0; + + for (i = 0; i < nb_fwd_ports; ++i) { + if (port_id_is_invalid(fwd_ports_ids[i], DISABLED_WARN)) + move = 1; + else if (move) + fwd_ports_ids[new_nb_fwd_ports++] = fwd_ports_ids[i]; + else + new_nb_fwd_ports++; + } + if (new_pid < RTE_MAX_ETHPORTS) + fwd_ports_ids[new_nb_fwd_ports++] = new_pid; + + nb_fwd_ports = new_nb_fwd_ports; + nb_cfg_ports = new_nb_fwd_ports; +} + +/* * Launch packet forwarding configuration. */ void @@ -1934,6 +1959,8 @@ static void eth_dev_event_callback(char *device_name, ports[pi].port_status = RTE_PORT_STOPPED; + update_fwd_ports(pi); + printf("Port %d is attached. Now total ports is %d\n", pi, nb_ports); printf("Done\n"); } @@ -1960,6 +1987,8 @@ static void eth_dev_event_callback(char *device_name, nb_ports = rte_eth_dev_count_avail(); + update_fwd_ports(RTE_MAX_ETHPORTS); + printf("Port '%s' is detached. Now total ports is %d\n", name, nb_ports); printf("Done\n"); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 8dfd574..ee781d6 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -596,6 +596,7 @@ unsigned int parse_item_list(char* str, const char* item_name, void set_def_fwd_config(void); void reconfig(portid_t new_port_id, unsigned socket_id); int init_fwd_streams(void); +void update_fwd_ports(portid_t new_pid); void set_fwd_eth_peer(portid_t port_id, char *peer_addr); -- 1.9.5