From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id 6A61128F3 for ; Wed, 23 May 2018 14:11:41 +0200 (CEST) Received: by mail-wr0-f193.google.com with SMTP id i14-v6so26070728wre.2 for ; Wed, 23 May 2018 05:11:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DpKUq3T3xdCjfbTQfug+o3r+6sp3o9+/g3q7IgmSr/s=; b=mqYG13JQ44M86+5GGP3aoVvHiWq3VlJhW0044WSgj+pjO0SK9xKSGMOziSLzslA62X hv8a7ORA8ljK1Huq2pHAjzOyNr+NDWl40Sv8vQA0/QnTO4AemzP313Pgu+ps9kKyMabO sfcxBkyx39T8wBpSVyWVlDPAePln/JA5SoHMv3yUC6rbQ5LQs4nIbsLc4pY4Cckax+NZ NEhLY1WBtN3aBs8scVUdnZhlkniQL+auMD022fuBanjGE3aeblkD+8Up6EbzF51COg9T R3je6oQgn/cNMD6N+LC6GV17anDay17LggX/sKMjFi4fOL00Zv2SAMmTwpQBvZWVzx3X j92A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DpKUq3T3xdCjfbTQfug+o3r+6sp3o9+/g3q7IgmSr/s=; b=HoAOUq9+I/2QdGIoQQlOwco6SEfSvdsHF/FAioeZceR9FPRiRlkxiP1Y40y0TCMk5/ HBjM2lYb5JZZvVVMQGomQcAWjAuGSZwZoaAdJ9c8z3+IfkCAkziMcKQlFFJ2Bwfp4dKQ 8l7hJYDS2zZDDNoQnEC29pTgmYs+sQ7Y8ZRJWT2VGJ9K6pl3JGDtAXbCKAIOXI9iB8gV 3+5JaIseCHEFMFhp87qcXL1KPqNGYY08hPznrpkYcvRTwcyOzfx4e2QrRTVfZd3XygZV 6yQMqFStIddOF2+7gOs//zM1toFKMM0ykHUsF7Ljh2j4AjS6peq+h61y40/epi8rEA4t nTFQ== X-Gm-Message-State: ALKqPwdIqcdFETvmrCWSagLc+ZRaByDwBJ1RRCnHuH+ivJ6W4Cy/XQ0I Ub0AxgTT9JIachKzBSyY6h0= X-Google-Smtp-Source: AB8JxZohjv5K3jvNiSS8xIy4ZGfJS0jLuox3LsmgW8yE6k3sxkcImNBhL4vLs3OXv/iQvUYvhqMUdQ== X-Received: by 2002:adf:8442:: with SMTP id 60-v6mr2586281wrf.138.1527077501111; Wed, 23 May 2018 05:11:41 -0700 (PDT) Received: from localhost ([2a00:23c5:be9a:5200:ce4c:82c0:d567:ecbb]) by smtp.gmail.com with ESMTPSA id x130-v6sm3065402wme.24.2018.05.23.05.11.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 May 2018 05:11:40 -0700 (PDT) From: luca.boccassi@gmail.com To: Matan Azrad Cc: Gaetan Rivet , dpdk stable Date: Wed, 23 May 2018 13:10:04 +0100 Message-Id: <20180523121010.8385-53-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180523121010.8385-1-luca.boccassi@gmail.com> References: <20180516101323.2234-2-luca.boccassi@gmail.com> <20180523121010.8385-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'net/failsafe: fix removed sub-device cleanup' has been queued to stable release 18.02.2 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: Wed, 23 May 2018 12:11:41 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/25/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From 7e42c81e3d86de2a3c3209f4663f4210adf2adda Mon Sep 17 00:00:00 2001 From: Matan Azrad Date: Tue, 22 May 2018 12:38:46 +0000 Subject: [PATCH] net/failsafe: fix removed sub-device cleanup [ upstream commit 0545c580fc377d33711786eaed665ee60e801bbd ] 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") Signed-off-by: Matan Azrad Acked-by: Gaetan Rivet --- drivers/net/failsafe/failsafe_ether.c | 30 ++++++++++++++++++++++++++++++ drivers/net/failsafe/failsafe_ops.c | 5 +++++ drivers/net/failsafe/failsafe_private.h | 5 +++++ 3 files changed, 40 insertions(+) diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c index 780bfa4bc..9bf8d0802 100644 --- a/drivers/net/failsafe/failsafe_ether.c +++ b/drivers/net/failsafe/failsafe_ether.c @@ -260,6 +260,7 @@ fs_dev_remove(struct sub_device *sdev) 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 */ @@ -320,6 +321,35 @@ fs_rxtx_clean(struct sub_device *sdev) return 1; } +void +failsafe_eth_dev_unregister_callbacks(struct sub_device *sdev) +{ + int ret; + + if (sdev == NULL) + return; + if (sdev->rmv_callback) { + ret = rte_eth_dev_callback_unregister(PORT_ID(sdev), + RTE_ETH_EVENT_INTR_RMV, + failsafe_eth_rmv_event_callback, + sdev); + if (ret) + WARN("Failed to unregister RMV callback for sub_device" + " %d", SUB_ID(sdev)); + sdev->rmv_callback = 0; + } + if (sdev->lsc_callback) { + ret = rte_eth_dev_callback_unregister(PORT_ID(sdev), + RTE_ETH_EVENT_INTR_LSC, + failsafe_eth_lsc_event_callback, + sdev); + if (ret) + WARN("Failed to unregister LSC callback for sub_device" + " %d", SUB_ID(sdev)); + sdev->lsc_callback = 0; + } +} + void failsafe_dev_remove(struct rte_eth_dev *dev) { diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c index 057e435cf..2f9f60b16 100644 --- a/drivers/net/failsafe/failsafe_ops.c +++ b/drivers/net/failsafe/failsafe_ops.c @@ -153,6 +153,8 @@ fs_dev_configure(struct rte_eth_dev *dev) 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) { @@ -163,6 +165,8 @@ fs_dev_configure(struct rte_eth_dev *dev) 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; @@ -289,6 +293,7 @@ fs_dev_close(struct rte_eth_dev *dev) 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 155207423..404b24923 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 @@ int failsafe_eal_uninit(struct rte_eth_dev *dev); /* 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); -- 2.14.2