From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10070.outbound.protection.outlook.com [40.107.1.70]) by dpdk.org (Postfix) with ESMTP id DFEDA152A; Mon, 21 May 2018 21:48:38 +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:X-MS-Exchange-SenderADCheck; bh=DLBUym+BFDbZlO2/sIWeDRWU3J/t3mNYoCVcxL3W+08=; b=RvJ7SqKPMUMR0TSw37FgSAMarRABwJ6Q4p1m8AFKv5lW75I8h/fpuGhYnMC+JqC/rsvyahZKK+flw92sgboaws8HHPnxDNfB3CFi3GNBRrzhNQfG0uwB4BdSNsNLzT9cgAFX4POzlLdMOTAQHq4tYC3KQaSIY0FZKj0ISCLn6QA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by DB6PR0501MB2597.eurprd05.prod.outlook.com (2603:10a6:4:5f::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.776.11; Mon, 21 May 2018 19:48:34 +0000 From: Matan Azrad To: Gaetan Rivet Cc: dev@dpdk.org, Ophir Munk , stable@dpdk.org Date: Mon, 21 May 2018 19:48:03 +0000 Message-Id: <1526932084-1120-1-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.9.5 In-Reply-To: <1526583136-21680-1-git-send-email-matan@mellanox.com> References: <1526583136-21680-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR08CA0154.eurprd08.prod.outlook.com (2603:10a6:800:d5::32) To DB6PR0501MB2597.eurprd05.prod.outlook.com (2603:10a6:4:5f::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603328)(7153060)(7193020); SRVR:DB6PR0501MB2597; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2597; 3:Gh4DR0NRN3ZxZMD/5wJi5JlmcMyq2ssIMiOKXtx8PKBdpkmijKC6Yhrb/kSCs7uwOYJYpq8xWumrIJh0o9CJ1TwkODAR+EIga67yI1SLveFLT04G040QL/Oci2X3L3+vQ/vSulZPexz+JY9GVVN4dqjlyC7KZvfnX5zIr70Yb2JZOEPEE6hoyJ46G2QDTuC1N475A8xyvVY4z8TiBGv3X4G1toTxETQecVhEstPfvj4/auLwKj+1dKeTMEgZ68db; 25:LYGsyDK+AZ1eLri/39nGVF+ac3OpEs7dnxlnBZyy0e3yfkQBLHPzE05SDfzl/PxA2obIMK41Dda1WcETj6CEwCpz5SrMKBUZDaFTa3KfQ9eZKUZmdORiIljlri9GXgawvhMvrBWxWamYDZ/GCiuo1Zs3hiewvX+AopvzOXj+wyuksMxHpb0psIGpNJGQ4QTdcdak/tzo3x3aTgxgUjeilLW00N3/BdGNB6k4bV1ykhB+N0m9UknX4tCk9y0B72lulxvCxKiMb07PplAZscOZZNgIftLHqHbLhQPdfM8wQE8hxCGF4coqjT8Lasd32hlFU/tJw6gjoMuhLM+xKAaTJw==; 31:lbJguyhMM4WMdtdz7DA+ngh1jNTTqXcc7RQLBDws8EgutrhYTLVkukKQ2gPrF5d4NaDupeK5ngFN4iwnDtHAJU6oLh4OQJhJcKYSvVKECQZPzw8r07Q2x42WN8uQIB1cztol+paCVFNeKCdqPKR0v/z5oFomLyfU+khmRdbD3WOZTmrWAbd7ohsbmFyyRgiBOzTRRAb7OWYyEdiM/lhmPDUw7xluxZFzgM1mS14xnYc= X-MS-TrafficTypeDiagnostic: DB6PR0501MB2597: X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2597; 20:it7D7wBWMVchWD9knD+TaIfbvzIsANYC4M4S9f2vkCD0XlyfpFm2/YJbj0ayIBs42YWiKIHlQenJsNJtptBai8a3eTlgeDn+VBg/sNOvOcXF0L/A88dCPyb2OkDTae7I8ZoDOoggZ4XFQIS3+XM1sgI6SLDBvjcZ0R/HwoAk6kX4cH586F/P3PQ9IM9TRthUT21k/3uvsPH4SA6igd2GZUnMGoIjuPBaTHesdwWxhbWCawYrZ+rEl+5AQqW3oYH8lcRPwDBngUVpX+AKWeScRaMHxqb9EchPE0dXEluJZ280Nz8VWYluHCXv4H1ZMGg8tcCAiAOgI/0iwrQXh8bGq7Y6ymdPwfKlxAnleex+iNxlq9yku3USJisrMaWGva14p23CXtux9rd+ols+MzNk9gyn7cBLYLPiwjpMfiTs35wEzix8o6dylzk4XeoXKZOVTQ26Ki7Mc06QTJYIsBNRC2BtzYU0Ra2BuqY9PLjd4wx4utBp4thH/IOXbHOxDcMI; 4:4QigdrORQUXS5mrNtEIXvnfErv2E5KvHUtTe0Fx+MbFruIQRok6wWDhXr5CCfmDI7HvRoSIsxI6kDEgVkB+5a4Db9a6Pb0GQV3j5uRN/R2U3vBsreC6m0cUDgt9SDDjoaES8HfQA45QxfUEBdL/Too2USflUPIO1G7gbZFaZvHhYpj/kMRafRgYMVhoajXx6HuGST6s+Fd//mHkE1e0eQZKoEkcMEM43jk9z7pHxBwU8Aiu42fOxbcdNqCUs0mdS24mytynAOGU8hAATxU3w6g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231254)(944501410)(52105095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:DB6PR0501MB2597; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0501MB2597; X-Forefront-PRVS: 06793E740F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(376002)(39380400002)(396003)(366004)(199004)(189003)(6666003)(6916009)(69596002)(478600001)(316002)(68736007)(16586007)(33026002)(55016002)(36756003)(66066001)(47776003)(86362001)(25786009)(2906002)(59450400001)(26005)(186003)(476003)(2616005)(76176011)(5660300001)(52116002)(446003)(486006)(53936002)(386003)(48376002)(50466002)(81156014)(81166006)(7736002)(305945005)(8676002)(4326008)(16526019)(6116002)(3846002)(21086003)(97736004)(50226002)(956004)(11346002)(51416003)(105586002)(106356001)(8936002)(7696005); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0501MB2597; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:3; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0501MB2597; 23:yaYIs7rqC3XjP52oGi7vo2OObVADI7GjT346Mwu?= =?us-ascii?Q?pTpwEuSLVxpYIUbaf0PuyYi93yafActLw0BI+ExumaM7XVYt1GuZDC8Pw58X?= =?us-ascii?Q?cH/v0XmIi/ZuPX1rFtwtSBrGPp1NqbinfMUvdRkngtlDLkm2rcl/d1A8G3ro?= =?us-ascii?Q?y6FbLpLLMb6Ut+bJhxzRsblMjAfX/n5H/c7yiMmSLRlG71tWSRWpgn95sehr?= =?us-ascii?Q?nb08Vc9hovcN8PgesVB6nZvCmtTZpGNDJm6yMj1vkAhSVwDKIw6lrXzxsOvE?= =?us-ascii?Q?KxZ2CIv8/H7Zb29WklV64/73prDs9PpuUtNUi/l8lsoqVSBB+698/ZXSiezs?= =?us-ascii?Q?fZBfPS4Eu3qU3u5MfQ2NvEuASdSiG8VJ2r0L8nS3U44dL8NnX8CBb79WzeYY?= =?us-ascii?Q?i+zcW5SyacTHA2sromE2nLRHfzKz9nEZC6IvJtR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16OGq/Ngttk6iM1iGqB83E8/swJjy6Uxp0PUXGgp2q0ot4i1m2ZrH1NL4dT5bArUxh/jJXddYYh46df2Vrvr/Fb22xU7eTYOey70cx5WzRI84gcwwY9p04C1ZN2oR9XOinZHrWWFoJCioaw0B9MbeqETxEC6GOJXX/wd X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2597; 6:W9PtjLg1EckCNYAi1Ig+BiiYtjq5Vv8SnCVCfk8REimQPXmkSjzpULjAEydlECpxc8eeEYk+NGWyGY7yUlu39oO9O9DogBRl6qWWNRntRDZpaz81+J67QRme5AbTtmh93lZ3M3WxcZpANoWxz3bJKzr0aTn+61rtiicfm3dn20re7wIRzsiSZ+/RAnaiZ1kci6mjPHc8lJxhaxzKYTXgADKM8Crecrkv3AJSPNBooDUDJSNYj0n3yVu8AicboYwcjuH8/GmGD30j5tnKNznl4QnpPJVCFxEm7jZTCe9gqAugmgZGwNa3UWsLKQJhSeBhfn+X3oV+PReZO4GShMtwf5u3vkI89oIIrbj8Nk8hUNKO1/BaJu7aseet4z8/qYDO/HW1QwacEyjwS9FidcCs1d6EctlwygLeVTDgge6aXrG8lG8yO6uZYpIAre1QClbH0RYU9SvN7Ps4m3THyMnLXw==; 5:v2VK+hyDE0bNAd3qX438oYTrtyvzbxmXOe6eiCZymoKn5q0IEhgHUqLyuN46YbzoOdMI0kPIbXFQ7Utp+l1AWuUxsXC/0I77uh+w5B+QAg1fn2xeExX+L0LliO34qRdw8XJRqgpm73IBs+rkaJy0JA0aYeXu6J7gY5SiC9mD2mo=; 24:FyKLrQrGeNYtn72kM2HHKfdSp41K+iNHe2278dvQbkmBznpL069JvClmst/bEY7eGzxKEjVOlKvQF7UwemVgDe6WPvSHe4RPVRwQGheP628= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2597; 7:mmXyA78CPENiP2ELbCgq7gGq1zOfq/YHU0xjQu2fP1hQY/+XdT8tl4SLsJ0kT8fK2JdDo38uwcVvdFJWPmlPkda1B0iLr7jkYKp65WOK4meBgp7PHi2ShMpuZ0FP02G3YNOs9awAySnzGaddbNGef1dNaZR2aAY+dNb3pIuXK3iGo93KZZGepuY/0Bf0nK4Q2+BtMA+gDnBFln9PUL40U9BCEimdJa3JVNe5Du7jw+G9iw7BLRDFeKBgRgKx7D1X X-MS-Office365-Filtering-Correlation-Id: ae036ca6-572a-4887-e486-08d5bf53d6c8 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2018 19:48:34.1505 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae036ca6-572a-4887-e486-08d5bf53d6c8 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2597 Subject: [dpdk-stable] [PATCH v2 1/2] net/failsafe: fix removed sub-device cleanup X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2018 19:48:39 -0000 The fail-safe PMD registers to RMV event for each removable sub-device port in order to cleanup the sub-device resources and switch the Tx sub-device directly when it is plugged-out. During removal time, the fail-safe PMD stops and closes the sub-device but it doesn't unregister the LSC and RMV callbacks of the sub-device port. It can lead the callbacks to be called for a port which is no more associated with the fail-safe sub-device, because there is not a guarantee that a sub-device gets the same port ID for each plug-in process. This port, for example, may belong to another sub-device of a different fail-safe device. Unregister the LSC and RMV callbacks for sub-devices which are not used. Fixes: 598fb8aec6f6 ("net/failsafe: support device removal") Cc: stable@dpdk.org Signed-off-by: Matan Azrad --- drivers/net/failsafe/failsafe_ether.c | 22 ++++++++++++++++++++++ drivers/net/failsafe/failsafe_ops.c | 5 +++++ drivers/net/failsafe/failsafe_private.h | 5 +++++ 3 files changed, 32 insertions(+) V2: Improve the commit log and add code comments for the new sub-dev fields (Ophir suggestion). diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index 733e95d..2bbee82 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -260,6 +260,7 @@ sdev->state = DEV_ACTIVE; /* fallthrough */ case DEV_ACTIVE: + failsafe_eth_dev_unregister_callbacks(sdev); rte_eth_dev_close(PORT_ID(sdev)); sdev->state = DEV_PROBED; /* fallthrough */ @@ -321,6 +322,27 @@ } void +failsafe_eth_dev_unregister_callbacks(struct sub_device *sdev) +{ + if (sdev == NULL) + return; + if (sdev->rmv_callback) { + rte_eth_dev_callback_unregister(PORT_ID(sdev), + RTE_ETH_EVENT_INTR_RMV, + failsafe_eth_rmv_event_callback, + sdev); + sdev->rmv_callback = 0; + } + if (sdev->lsc_callback) { + rte_eth_dev_callback_unregister(PORT_ID(sdev), + RTE_ETH_EVENT_INTR_LSC, + failsafe_eth_lsc_event_callback, + sdev); + sdev->lsc_callback = 0; + } +} + +void failsafe_dev_remove(struct rte_eth_dev *dev) { struct sub_device *sdev; diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index d04277b..e0570b6 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -146,6 +146,8 @@ if (ret) WARN("Failed to register RMV callback for sub_device %d", SUB_ID(sdev)); + else + sdev->rmv_callback = 1; } dev->data->dev_conf.intr_conf.rmv = 0; if (lsc_interrupt) { @@ -156,6 +158,8 @@ if (ret) WARN("Failed to register LSC callback for sub_device %d", SUB_ID(sdev)); + else + sdev->lsc_callback = 1; } dev->data->dev_conf.intr_conf.lsc = lsc_enabled; sdev->state = DEV_ACTIVE; @@ -282,6 +286,7 @@ PRIV(dev)->state = DEV_ACTIVE - 1; FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { DEBUG("Closing sub_device %d", i); + failsafe_eth_dev_unregister_callbacks(sdev); rte_eth_dev_close(PORT_ID(sdev)); sdev->state = DEV_ACTIVE - 1; } diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h index 7e6a3f8..886af86 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -119,6 +119,10 @@ struct sub_device { volatile unsigned int remove:1; /* flow isolation state */ int flow_isolated:1; + /* RMV callback registration state */ + unsigned int rmv_callback:1; + /* LSC callback registration state */ + unsigned int lsc_callback:1; }; struct fs_priv { @@ -211,6 +215,7 @@ uint16_t failsafe_tx_burst_fast(void *txq, /* ETH_DEV */ int failsafe_eth_dev_state_sync(struct rte_eth_dev *dev); +void failsafe_eth_dev_unregister_callbacks(struct sub_device *sdev); void failsafe_dev_remove(struct rte_eth_dev *dev); void failsafe_stats_increment(struct rte_eth_stats *to, struct rte_eth_stats *from); -- 1.9.5