From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by dpdk.org (Postfix) with ESMTP id 30FCA1D9E for ; Tue, 22 May 2018 10:57:21 +0200 (CEST) Received: by mail-wm0-f68.google.com with SMTP id n10-v6so31188167wmc.1 for ; Tue, 22 May 2018 01:57:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=B63tgI32/flgRbBEC6oZdFNSRu1dcfiQ2M3xcryykPA=; b=MaIlWjBKY5nh8tmTLSx5b2kp4kzvoQrFyedZC8MHbhJ1IJunapRIF2+TBpU9GHCB67 qtrnZyrg8rtwD71i9C6tm35VGPKqrx4I81g7ga9vhmuxrl/S2jSVWY6SfrSS9EHBzB9x ItKnQ3j5BPxmp8T/p+5I9z5MYUshFFtoGSriRS/DVhUrj8eVpHC4gF5ntBPgRf99ah+S wn8t/fqjv5hQxkkh2Ry43qSjt9GzR+g5427nUjczHLosZ9FV2CeNhoWOIZTURe5rHql3 LDyWwbpm1dFUPbofbMr/M3vdJTYcJ0gfiXTPOB1l//tw8o4bUyHoh7D2H6KFcVNpUql6 KaUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=B63tgI32/flgRbBEC6oZdFNSRu1dcfiQ2M3xcryykPA=; b=hWikG1o2D5hhiU9ycf7Xlv0HeC895iIebli66TSdICId1jWIoGa5IrKbY2ztJXmdLZ 2hA7Y8jCrMUerjQf4GczjuN2bUIJf6C9+iPGU1rmXjNWJwLxSg/jRtGXppMMOeL7qM3x LVI3g0c0yME4HnW3NAt8gYPH0f8/tS4XHsl2fXyMbY3uFIbY3Yg3S5u86ganee+xsmM2 L3IHGV86K+GThghazTHfkzHygEm4he3EVosrflptE+aNJ8ue7dQl8B2PYv+PxZBx9zS/ kn0fY0FljGV6DET+StVPOCOUd2O3L2Hh8x3MIFf0HOpVBY7kztVjhMznDVg4fRIKA4d1 oH7A== X-Gm-Message-State: ALKqPwe2R8ptJNGmE2koiR8CbIycxQNxbfOZXzDlzmI53SXnTKWzV+xO 5sjZ/ZbLZqwSrUHq3tYU13JXTw== X-Google-Smtp-Source: AB8JxZr8HcVf6G9c4vK52YHn/+fAgKS+o0ziGlxiNgB79nXvvBju79N2HVzs7ITzMA1rk890c4VupA== X-Received: by 2002:a1c:8b0b:: with SMTP id n11-v6mr468501wmd.12.1526979440574; Tue, 22 May 2018 01:57:20 -0700 (PDT) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id 60-v6sm1166862wrc.42.2018.05.22.01.57.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 May 2018 01:57:19 -0700 (PDT) Date: Tue, 22 May 2018 10:56:56 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Matan Azrad Cc: dev@dpdk.org, Ophir Munk , stable@dpdk.org Message-ID: <20180522085656.bx3r3e4c6lz4xwlp@bidouze.vm.6wind.com> References: <1526583136-21680-1-git-send-email-matan@mellanox.com> <1526932084-1120-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1526932084-1120-1-git-send-email-matan@mellanox.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v2 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: Tue, 22 May 2018 08:57:21 -0000 Hello Matan, On Mon, May 21, 2018 at 07:48:03PM +0000, Matan Azrad wrote: > 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; I agree with Ophir here, either the return value should not be ignored, and rmv_callback should only be set to 0 on success, or a proper justification (and an accompanying comment) should be given. The issue I could see is that even on error, there won't be a process to try again unregistering the callback. Maybe this could be added in failsafe_dev_remove()? Something like FOREACH_SUBDEV(sdev, i, dev) { if (sdev->rmv_callback && sdev->state <= DEV_PROBED) if (rte_eth_dev_callback_unregister(...) == 0) sdev->rmv_callback = 0; /* same for lsc_callback */ } Does it make sense to you? Do you think this is necessary, or should we ignore this? Thanks, -- Gaëtan Rivet 6WIND