From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0082.outbound.protection.outlook.com [104.47.2.82]) by dpdk.org (Postfix) with ESMTP id 539D16CD2; Thu, 17 May 2018 20:52:37 +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=tccZPAfT5t+bEMYHqO6SlIfkXgsixS/+Uqx9tQ1/f2w=; b=mH1DEsMeAgAZ+9HylXkZZsBV+ZlxZIoR0znt9PpIMIwY3MMwGU+y8SVnwkKjVJ/YYLcUTA/DHXtD2JMFpisS1Cdf/loRSXToCTAg2DRsZiweBOoqtHhwFOWOr0nm313NoEwCD7qvH6bSMdWj5fvmFjq56Q0LNEZEVedqkTjcZi0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matan@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM5PR0501MB2593.eurprd05.prod.outlook.com (2603:10a6:203:d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.776.11; Thu, 17 May 2018 18:52:35 +0000 From: Matan Azrad To: Gaetan Rivet Cc: dev@dpdk.org, stable@dpdk.org Date: Thu, 17 May 2018 18:52:15 +0000 Message-Id: <1526583136-21680-1-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.9.5 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0102CA0019.eurprd01.prod.exchangelabs.com (2603:10a6:802::32) To AM5PR0501MB2593.eurprd05.prod.outlook.com (2603:10a6:203:d::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(48565401081)(2017052603328)(7153060)(7193020); SRVR:AM5PR0501MB2593; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0501MB2593; 3:vgwZkSUCkgG+Xq/HiVbpdwbijokymCI/znFWL7ZJh2iSExsuDqXjM8ZR38/Ruhwur0sudXQWV/HfoYTL9zg1we5CqdSPLfjYGk2zE73qgzwkWxvjqe48LC8zCVi4BBeEqmznZpsmAf/+WV3xVYiIZNqm5YZ0dLuOBLU3C9oBpn12lfbUu2qTMFbh3vk9RL1XRUSuq8JlFUKkXHNsULjhvRRbgJuRwZIDRCwmagnTjOKUAJkMD92iuWI04i7PMEAB; 25:W2PbXaeoBisySsxFPoYsdZfFTN1Z9GZe0z+x4brAdKsIfrLwHWZOZbDxn/6IpbiU5YaXZEy5oOWPIaHOmoa7tOSLJc9MyDN8+7Onm/0TNlrGj8hid0LJHYOFqzEwFnpHIldd6BK5M+pvqtkw8AQ7oGB6l/euk4bN873OGbVQInHamHb+YMbsD48XTC+xV0Ti+hHc9bUT6lanCSlwxOd8T0+1B1uyb+z/grRmLtGPLXCymUGrFeJwWEKpdkku9Qt+mnBzR/p3C9OxtWn7PohgcodljymmD3oCyg2jeBkLdHK20qScc5wiUzQf+irVJV7/r31aT6hc5SyhJepBPhNo6Q==; 31:UrIWJ5c+xXS7ZdawvXwZucBhvaFLre5E4jra6xIzheGKmYUoJc8TL/E6nUaBnMI0xM0gMpsuv4c7urOHnuV1voQiK0LPO1PbtLweOc7v3po5ya/RSIjM7+3TBTmFSfXWd6qXmW+QN5eM55kSN2LeaFP9s/N91XSBG5pf1ja/kkNFuewEtaD0TW59mGRsDw2/zSULdFsqAa5uCv8ZCfGw1Wzn2PCLRGwbmxZJEJTyyD4= X-MS-TrafficTypeDiagnostic: AM5PR0501MB2593: X-Microsoft-Exchange-Diagnostics: 1; AM5PR0501MB2593; 20:CUJn1zXOCrMkCkBYPCO6SIncaAMuU4/YIDgXQ9eWw9cffNdWdw3Y8soY2X1d81S9d10UHF/giY6yXdkHAIH8ZNrmAXRWQDBwI1GI/uvwgG2rmubLqQ/cUKaDkpIqCxmp5TpjrhT3h9Jj8X8apz0sxGo95ndIKqUCNDb/KcHuHw+5esWWmJoxshS/qNcEAaF2TE4H0moLxzw40fuL+Lpoq23HqgzNWF6nSS323yHTtXN18MMdhcg0RG6fROMPCFIfqYe/TzAAkLepLrgMBLPif13a/yYZgYgrGvarrx0UpUcA8U3pkktU+2rpujSSCiVB4iJrDa1u17PVXpxlnnU3ixN/NLQ9gi8qjgs00toRNtl0SUAMJIX5RnVO/oiLmXza/tB/cI9S3D7skPYg4/JhEHmO2GxblJxdCoTqiVXaD75qOysoD8xkfsOA4EOrfOW2rfyXpr24E9883/TPFdAVxWZxOobscVls1DyA2pWVLdRB8QK3GUfA9nXN5hgfJ68Q; 4:Ehzb7NceQgL/BFPkWXsIvFJ6DaIuTnAzg7oTifP5sVA3B3hbzYgly62brm8yDA/ClILqLeKPnlrsFbHulYZnab2Doh7nV0uO7UbhxuCcStjVHnCz2kNRoOTx4yDfzhqhN9pYIv0zn+CtN1wSPjlQk9yzNDt8CzA5Zl+6svOK1+tmYGh2COUvUv7HEUEj1HIGxwKoekwanl4HK1/AxPSD1p2P3e+wcWpoyw/yYs54TX2LRj2+F6jXRarvUVz8huP7j/9jBNciyp3OIWhe3q+xzw== 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)(5005006)(8121501046)(93006095)(93001095)(3231254)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:AM5PR0501MB2593; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0501MB2593; X-Forefront-PRVS: 067553F396 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39380400002)(396003)(366004)(39860400002)(376002)(199004)(189003)(186003)(16526019)(386003)(51416003)(7696005)(52116002)(81166006)(6666003)(33026002)(6916009)(26005)(21086003)(305945005)(36756003)(8676002)(81156014)(50466002)(48376002)(59450400001)(486006)(2616005)(7736002)(4326008)(476003)(956004)(53936002)(55016002)(478600001)(47776003)(69596002)(68736007)(316002)(50226002)(86362001)(66066001)(106356001)(8936002)(105586002)(6116002)(3846002)(2906002)(97736004)(25786009)(16586007)(5660300001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0501MB2593; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0501MB2593; 23:bE07iDTMYMqo3/sLJraXUu/qgB3131bRCW2oxhG?= =?us-ascii?Q?k2pocAKPs5wSh3CtN3Ketu2nqvALNFu0YGMJ5EpkYNTJ9VoE/WiboXJHEE1n?= =?us-ascii?Q?ht2+VCVgLkZ9IccKkl1kt8kJ/ttX00K81z8h9MO3se+0u0IrD8gMTkxKYx9A?= =?us-ascii?Q?1EFi0gjtehFXEtKH1vlINIlCHOby1VyS2rknw+sq9GC2J/WzjNb2f7B+X5Gt?= =?us-ascii?Q?POQkOcRRN836lY2yP0HwVLTP6I/84DeRbXN7nNBDDZ/g/Hm9DI5ewgw6sMcw?= =?us-ascii?Q?7cC3WcKUv8TnCCqtr0qU6PfMqWHY30OnGLK5DwTXvyFDrKCy5rl0cheMv/VJ?= =?us-ascii?Q?2ZsUS5UUXVj7hes+ztpEO0un7R3iAu9DWYRdUAu0bWo7ZiGPwhOP5ku6lppv?= =?us-ascii?Q?840o6zxMx0c9oh9bWJ2zNXFIz7Y2o3YdqGm3k95hOWqWXqrEaG5PvlqfU1rm?= =?us-ascii?Q?IJYey4xns0BTpUsyKihDTZdN1uc3tJ4R8Kb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VW8A00Ek/Hg8r79RHm X-Microsoft-Exchange-Diagnostics: 1; AM5PR0501MB2593; 6:6kNhrxP4KYLHdmmfSMR9HgK8rM70aI4tQnLo+UVrj/F24EjNT087qJh4QyGFubNvNfx2nUdVjCZtwWYR1z9a7qOvFc+eqi1hDUtDZVX+6EGAZY2PE32etVqye9xzDizompNRPDNDmn7FPfzpucluiv3wpqrVNTtNsbxTMqrwxF9vhsaDpisBk5EHkDOvqf8+P5PSeuAEKW15GUG3BpIdFzLkwgsTNVqktnss3LNK91jggoBqFDU35izOoMURBkTn6qubhIjXj9mcAWgiw00Q+6jACHf0HHtrW2e+p2U2IxB8DO0U4/hv7PG/Mh563DnozcYFt5nIfoRle8hsR++60l5CV0bYVfXPjq7sDTGe4prJSddf+kw/tGbPOCaRS5uHEJbFaaukhuG4feHlsoLAbOVwzaRdBaPzLb0iErA0+jKCC+NYmxqBJo5QGADrTFEGEIsHEDksSVMWU4FhHt28gg==; 5:GKw7xFut79oB/0NgjqqHtY2Kleed5j35Gtt60cTHhG9mr7wgu2LwSDTT1BM0k7upYGtbzQYcuFw9LYRX6y4UWRQWFdS4vpLITBzpL95mvk6PDpq4PPuRFEbkTFBOPeUbDG4x/E9Ccc3Ls312UgTIA9xnYbeX0GZmXO/CS5JmDvA=; 24:rybx2bmzOtJxdjq/sh98OLbdOdG/8PzRPT3gLc2KeE8AxrbkofKKojPbe8aUbI8r4lW/hL4r07Y+oM88zckBQouZkjqIHegmqDfeOUj/fnA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0501MB2593; 7:wGPh/Gf70BCzov+mgYkYl9lKpZpU1pdvw+gX+m2DgME4zaeUeYYEUZt7+mt/FXdst6TGet5aS7EcyzGYINqGo7jnpyIfyDhuiw+wcA5HPrq3zr2DSyE8Qa0TSGgfPU1vTl0pRIGCaN92Nu7psnWR+xiUYKlVwHRHc8IGKMk4frb3GFiY0nPc1h7CZV/FhAPUZC6/VWnK62A6quAvcHwPDyeWayJu7INao0P6nZFb5QmLERndCGKcURc7gwr4vNJp X-MS-Office365-Filtering-Correlation-Id: ce4b3b9e-33ae-4d90-4b93-08d5bc275b0e X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2018 18:52:35.3707 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce4b3b9e-33ae-4d90-4b93-08d5bc275b0e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0501MB2593 Subject: [dpdk-dev] [PATCH 1/2] net/failsafe: fix removed sub-device cleanup 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, 17 May 2018 18:52:37 -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. In the 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 to the fail-safe sub-device, because there is not a guaranty 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 | 3 +++ 3 files changed, 30 insertions(+) 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..3222653 100644 --- a/drivers/net/failsafe/failsafe_private.h +++ b/drivers/net/failsafe/failsafe_private.h @@ -119,6 +119,8 @@ struct sub_device { volatile unsigned int remove:1; /* flow isolation state */ int flow_isolated:1; + unsigned int rmv_callback:1; + unsigned int lsc_callback:1; }; struct fs_priv { @@ -211,6 +213,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