From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f170.google.com (mail-wr0-f170.google.com [209.85.128.170]) by dpdk.org (Postfix) with ESMTP id EE39C37AF for ; Mon, 4 Sep 2017 14:49:46 +0200 (CEST) Received: by mail-wr0-f170.google.com with SMTP id z4so1339685wrb.1 for ; Mon, 04 Sep 2017 05:49:46 -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=qXR7R8DE1m9B5svF8Wzi7XIfnG0+JFe6v+FVDQyzIc4=; b=KZbeof79FdfsydZP49gTfhtmmx/0KbIRYB5Um32PyDIvCmgimOP//9xRomFWlic8K0 DPrBxLF098osJFuZkdE9hmVMOy2/ZWi215Hr7F4pNQetJRluvHajttKRjTA3/ro7qSAH tHIPO04v2FLYs322W1NhhIPOrR/reRVxLxaYIs9cHODqRfCFTrDo2C778a6K1uJcBebc b6uVihh/F7ckEljQO9BWT4skYJJBHoohfCpGY6KnRvYE4Q1ju+TJwahxOfF+8x0XO0CY PZQSyz0LLSsK+970+Qdl4XO1PCgNFETRCMHAlnrVpxKpfpeDG9dbadSvozXRuV0LBdgK CXmw== 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=qXR7R8DE1m9B5svF8Wzi7XIfnG0+JFe6v+FVDQyzIc4=; b=jdVRsA+K2qqPwQcTqbiyKOVrp6GNLCMdXfgsth+h2rbL2BVZxOJnGgQusdQtMEkYMX zWSukmKCkxixFNDqk0Dg9wdQ8093pf1JPiWgN1qJXWqrhAd0vFFvZSg3s+aubhc3PTq1 zfrdmgEqQrEtxEt8MD57yQyE7yjAS4/EnokKCYMrmE4i6Q1sy3eWZoAMjsdhe4wyheZj 2hE2XdpgfY0MQ6X3BCUR6lzIYJtsTzBmlFB5Cio8zdm6x34EQ3VwnyfXE5QCh7UPbFo0 F9gISDevUejAmGaVwwT+JcCW27JwHISmF9Yu7WM9xlkn94VN9pDr9VEYRpOftvJstOAu HsVg== X-Gm-Message-State: AHPjjUjuff9bhg6PSqSGs7YGhuYhxL8SdFQYWVhVRHHYYVCOyb7YKinQ nJArQxN0ZdN8Fe4IQdXwXg== X-Google-Smtp-Source: ADKCNb4xK58A4aP87ky7nkRBCR+oD8zXO2iyEZapR8gKIA/BU2jC8AQI2oq+fDec9O2siGn0uXTILw== X-Received: by 10.223.198.19 with SMTP id n19mr299639wrg.282.1504529386437; Mon, 04 Sep 2017 05:49:46 -0700 (PDT) Received: from localhost (lan31-h07-89-80-147-20.dsl.sta.abo.bbox.fr. [89.80.147.20]) by smtp.gmail.com with ESMTPSA id n79sm15472974wmi.1.2017.09.04.05.49.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 04 Sep 2017 05:49:45 -0700 (PDT) Date: Mon, 4 Sep 2017 14:49:44 +0200 From: =?iso-8859-1?Q?N=E9lio?= Laranjeiro To: Matan Azrad Cc: dev@dpdk.org, Adrien Mazarguil Message-ID: <20170904124943.2pep4kbglu4q5qg4@localhost> References: <20170825082918.GU4544@autoinstall.dev.6wind.com> <1503995444-43359-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: <1503995444-43359-1-git-send-email-matan@mellanox.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v2] net/mlx5: support device removal event 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: Mon, 04 Sep 2017 12:49:47 -0000 Hi Matan, Please see comments below, On Tue, Aug 29, 2017 at 11:30:44AM +0300, Matan Azrad wrote: > Extend the LSC event handling to support the device removal as well. > The Verbs library may send several related events, which are > different from LSC event. > > The mlx5 event handling has been made capable of receiving and > signaling several event types at once. > > This support includes next: > 1. Removal event detection according to the user configuration. > 2. Calling to all registered mlx5 removal callbacks. > 3. Capabilities extension to include removal interrupt handling. > > Signed-off-by: Matan Azrad > --- > drivers/net/mlx5/mlx5.c | 2 +- > drivers/net/mlx5/mlx5_ethdev.c | 108 ++++++++++++++++++++++++++++------------- > 2 files changed, 76 insertions(+), 34 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c > index bd66a7c..1a3d7f1 100644 > --- a/drivers/net/mlx5/mlx5.c > +++ b/drivers/net/mlx5/mlx5.c > @@ -865,7 +865,7 @@ static struct rte_pci_driver mlx5_driver = { > }, > .id_table = mlx5_pci_id_map, > .probe = mlx5_pci_probe, > - .drv_flags = RTE_PCI_DRV_INTR_LSC, > + .drv_flags = RTE_PCI_DRV_INTR_LSC | RTE_PCI_DRV_INTR_RMV, > }; > > /** > diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c > index 57f6237..2cf7726 100644 > --- a/drivers/net/mlx5/mlx5_ethdev.c > +++ b/drivers/net/mlx5/mlx5_ethdev.c > @@ -1112,47 +1112,83 @@ mlx5_ibv_device_to_pci_addr(const struct ibv_device *device, > } > > /** > - * Link status handler. > + * Update the link status. > * > * @param priv > * Pointer to private structure. > - * @param dev > - * Pointer to the rte_eth_dev structure. > * > * @return > - * Nonzero if the callback process can be called immediately. > + * Zero if the callback process can be called immediately. > */ > static int > -priv_dev_link_status_handler(struct priv *priv, struct rte_eth_dev *dev) > +priv_link_status_update(struct priv *priv) > +{ > + struct rte_eth_link *link = &priv->dev->data->dev_link; > + > + mlx5_link_update(priv->dev, 0); > + if (((link->link_speed == 0) && link->link_status) || > + ((link->link_speed != 0) && !link->link_status)) { > + /* > + * Inconsistent status. > + * The link status is read from Ethtool through an IOCTL, > + * but as the PMD is working in polling mode it gets the port > + * event before the Kernel driver had time to process it. > + * PMD then request the link from the kernel but the event is > + * still not processed (due to more urgent interrupts) and > + * finally the PMD may get an inconsistent link. > + * Setting alarm for later checking. > + */ This comment is not totally correct, it is not the PMD which handles the LCS event, but the application. In testpmd the LSC event are polled in loop, there is no guarantee that another application will do the same. Remaining part is correct. > + if (!priv->pending_alarm) { > + priv->pending_alarm = 1; > + rte_eal_alarm_set(MLX5_ALARM_TIMEOUT_US, > + mlx5_dev_link_status_handler, > + priv->dev); Indentation. > + } > + return 1; > + } else if (unlikely(priv->pending_alarm)) { > + /* In case of link interrupt while link alarm was setting. */ > + priv->pending_alarm = 0; > + rte_eal_alarm_cancel(mlx5_dev_link_status_handler, priv->dev); > + } > + return 0; > +} > + > +/** > + * Device status handler. > + * > + * @param priv > + * Pointer to private structure. > + * @param events > + * Pointer to event flags holder. > + * > + * @return > + * Events bitmap of callback process which can be called immediately. > + */ > +static uint32_t > +priv_dev_status_handler(struct priv *priv) > { > struct ibv_async_event event; > - struct rte_eth_link *link = &dev->data->dev_link; > - int ret = 0; > + uint32_t ret = 0; > > /* Read all message and acknowledge them. */ > for (;;) { > if (ibv_get_async_event(priv->ctx, &event)) > break; > - > - if (event.event_type != IBV_EVENT_PORT_ACTIVE && > - event.event_type != IBV_EVENT_PORT_ERR) > + if ((event.event_type == IBV_EVENT_PORT_ACTIVE || > + event.event_type == IBV_EVENT_PORT_ERR) && > + (priv->dev->data->dev_conf.intr_conf.lsc == 1)) > + ret |= (1 << RTE_ETH_EVENT_INTR_LSC); > + else if (event.event_type == IBV_EVENT_DEVICE_FATAL && > + priv->dev->data->dev_conf.intr_conf.rmv == 1) > + ret |= (1 << RTE_ETH_EVENT_INTR_RMV); > + else > DEBUG("event type %d on port %d not handled", > - event.event_type, event.element.port_num); > + event.event_type, event.element.port_num); Why is this line modified?, the indentation was correct and nothing has been modified. > ibv_ack_async_event(&event); > } > - mlx5_link_update(dev, 0); > - if (((link->link_speed == 0) && link->link_status) || > - ((link->link_speed != 0) && !link->link_status)) { > - if (!priv->pending_alarm) { > - /* Inconsistent status, check again later. */ > - priv->pending_alarm = 1; > - rte_eal_alarm_set(MLX5_ALARM_TIMEOUT_US, > - mlx5_dev_link_status_handler, > - dev); > - } > - } else { > - ret = 1; > - } > + if (ret & (1 << RTE_ETH_EVENT_INTR_LSC)) > + if (priv_link_status_update(priv)) > + ret &= ~(1 << RTE_ETH_EVENT_INTR_LSC); > return ret; > } > > @@ -1172,11 +1208,11 @@ mlx5_dev_link_status_handler(void *arg) > priv_lock(priv); > assert(priv->pending_alarm == 1); > priv->pending_alarm = 0; > - ret = priv_dev_link_status_handler(priv, dev); > + ret = priv_link_status_update(priv); > priv_unlock(priv); > - if (ret) > + if (!ret) > _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, > - NULL); > + NULL); Same as above, why is this line modified? > } > > /** > @@ -1192,14 +1228,17 @@ mlx5_dev_interrupt_handler(void *cb_arg) > { > struct rte_eth_dev *dev = cb_arg; > struct priv *priv = dev->data->dev_private; > - int ret; > + uint32_t events; > > priv_lock(priv); > - ret = priv_dev_link_status_handler(priv, dev); > + events = priv_dev_status_handler(priv); > priv_unlock(priv); > - if (ret) > + if (events & (1 << RTE_ETH_EVENT_INTR_LSC)) > _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL, > - NULL); > + NULL); Same question here, > + if (events & (1 << RTE_ETH_EVENT_INTR_RMV)) > + _rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RMV, NULL, > + NULL); and here. Thanks, -- Nélio Laranjeiro 6WIND