From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by dpdk.org (Postfix) with ESMTP id 0DEF8968 for ; Thu, 7 Sep 2017 14:19:19 +0200 (CEST) Received: by mail-wr0-f177.google.com with SMTP id k20so10223716wre.4 for ; Thu, 07 Sep 2017 05:19:19 -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=JreAk1yfsrvn+U8afKWU8YdGp8WsMKa4bXVL7yMH1LE=; b=R7MwjTNMjCe7AtC1Ni5y9XU0Ia7hF40QuBQsX4xitrouHxTLPr1l+2JwfzXq1NmirR kzM9Of3WibFWjjBG2W4a3/UFinSoga+3fe1WAGXdFkxOVXz4rWX9Uhz5kBUDCjYX1oM/ WvxWzD/4U/LPFzhVfevnBhJXnAAKzJGsq9sKfvavzZ4vNok+mJ5/Wf8GD9g8hvjKrPrf 32JRNmbZda3Psma/+M/6u/miIgVtKH/T+MaWeBq+IznXjdcx575F9I81bPsIzNcnw56W iadTCPrqUpEJ1BEDsaB06OJTFVzayiUOvf8MyBtCpkdCARrkHNNChaCVmKuz8ALgcD3f 54rw== 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=JreAk1yfsrvn+U8afKWU8YdGp8WsMKa4bXVL7yMH1LE=; b=YTNoZGztIg/++PhuI89JdPGndNWwlVpYkQD2quTJ3XxaYLQQoW5axDPrW2f49Cb4MP c9uPldtLJ09Z99ij4A7tC+8UglH1xtBwW1Dz9HWydgRnzSf7bNcj7poqmfnTu9HpVQOo RtJVEGYgmZ4idyByH84/WSaTFVhYHKkWUUMYLRoosLpEPGZ8ERcD45RyeHPaxlk4MzCa IIoRbX0fzdWBgKowrmcl9nyovUVNwLWtnUqLaUNz/R6Mvm23Vi9T80s72FlwUE0AKfza TM9QAFreEtiyMEA7wbkpJssegOIMZJAWtlLFS5/0NPcqZg0NFN+g55sH+Uy0SMUJvfWs CkSQ== X-Gm-Message-State: AHPjjUiN697pyYOTD36+8/7fj28VTZ43mCCMzfBT1hwjOm5n3LhGlISL 5Ud+MFxf+Z7Ljvah X-Google-Smtp-Source: ADKCNb5N3CDIxysWHojN4kRkvsDiN4SX7QY6Z+0+2rC80BiWV6gce7kLdxAbtoigeeH7Mi26jc1BMw== X-Received: by 10.223.175.217 with SMTP id y25mr1753832wrd.255.1504786758507; Thu, 07 Sep 2017 05:19:18 -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 x11sm2112786wrb.26.2017.09.07.05.19.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Sep 2017 05:19:17 -0700 (PDT) Date: Thu, 7 Sep 2017 14:19:08 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: Matan Azrad Cc: dev@dpdk.org Message-ID: <20170907121908.GL21444@bidouze.vm.6wind.com> References: <1504783873-4211-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: <1504783873-4211-1-git-send-email-matan@mellanox.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v2] net/failsafe: stat support enhancement 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, 07 Sep 2017 12:19:19 -0000 Hi Matan, You should send your v[N] In-Reply-To the Message-Id of your v[N-1] to help people reading. On Thu, Sep 07, 2017 at 02:31:13PM +0300, Matan Azrad wrote: > The previous stats code returned only the current TX sub > device stats. > > This enhancement extends it to return the sum of all sub > devices stats with history of removed sub-devices. > > Dedicated stats accumulator saves the stat history of all > sub device remove events. > > Each failsafe sub device contains the last stats asked by > the user and updates the accumulator in removal time. > > I would like to implement ultimate snapshot on removal time. > The stats_get API needs to be changed to return error in the > case it is too late to retrieve statistics. > By this way, failsafe can get stats snapshot in removal interrupt > callback for each PMD which can give stats after removal event. > > Signed-off-by: Matan Azrad Acked-by: Gaetan Rivet > --- > drivers/net/failsafe/failsafe_ether.c | 35 ++++++++++++++++++++++++++++++++- > drivers/net/failsafe/failsafe_ops.c | 16 +++++++++++---- > drivers/net/failsafe/failsafe_private.h | 5 +++++ > 3 files changed, 51 insertions(+), 5 deletions(-) > > > V2: > 1. Fix failsafe conventions. > 2. Move the stats saving from the interrupt to the remove func. > > > diff --git a/drivers/net/failsafe/failsafe_ether.c b/drivers/net/failsafe/failsafe_ether.c > index a3a8cce..dc2e6d1 100644 > --- a/drivers/net/failsafe/failsafe_ether.c > +++ b/drivers/net/failsafe/failsafe_ether.c > @@ -308,6 +308,14 @@ fs_dev_remove(struct sub_device *sdev) > failsafe_hotplug_alarm_install(sdev->fs_dev); > } > > +static void > +fs_dev_stats_save(struct sub_device *sdev) > +{ > + failsafe_stats_increment(&PRIV(sdev->fs_dev)->stats_accumulator, > + &sdev->stats_snapshot); > + memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats)); > +} > + > static inline int > fs_rxtx_clean(struct sub_device *sdev) > { > @@ -329,8 +337,10 @@ failsafe_dev_remove(struct rte_eth_dev *dev) > uint8_t i; > > FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) > - if (sdev->remove && fs_rxtx_clean(sdev)) > + if (sdev->remove && fs_rxtx_clean(sdev)) { > + fs_dev_stats_save(sdev); > fs_dev_remove(sdev); > + } > } > > int > @@ -399,6 +409,29 @@ failsafe_eth_dev_state_sync(struct rte_eth_dev *dev) > return ret; > } > > +void > +failsafe_stats_increment(struct rte_eth_stats *to, struct rte_eth_stats *from) > +{ > + uint32_t i; > + > + RTE_ASSERT(to != NULL && from != NULL); > + to->ipackets += from->ipackets; > + to->opackets += from->opackets; > + to->ibytes += from->ibytes; > + to->obytes += from->obytes; > + to->imissed += from->imissed; > + to->ierrors += from->ierrors; > + to->oerrors += from->oerrors; > + to->rx_nombuf += from->rx_nombuf; > + for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) { > + to->q_ipackets[i] += from->q_ipackets[i]; > + to->q_opackets[i] += from->q_opackets[i]; > + to->q_ibytes[i] += from->q_ibytes[i]; > + to->q_obytes[i] += from->q_obytes[i]; > + to->q_errors[i] += from->q_errors[i]; > + } > +} > + > int > failsafe_eth_rmv_event_callback(uint8_t port_id __rte_unused, > enum rte_eth_event_type event __rte_unused, > diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c > index ff9ad15..e0f1b0b 100644 > --- a/drivers/net/failsafe/failsafe_ops.c > +++ b/drivers/net/failsafe/failsafe_ops.c > @@ -586,9 +586,14 @@ static void > fs_stats_get(struct rte_eth_dev *dev, > struct rte_eth_stats *stats) > { > - if (TX_SUBDEV(dev) == NULL) > - return; > - rte_eth_stats_get(PORT_ID(TX_SUBDEV(dev)), stats); > + struct sub_device *sdev; > + uint8_t i; > + > + rte_memcpy(stats, &PRIV(dev)->stats_accumulator, sizeof(*stats)); > + FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { > + rte_eth_stats_get(PORT_ID(sdev), &sdev->stats_snapshot); > + failsafe_stats_increment(stats, &sdev->stats_snapshot); > + } > } > > static void > @@ -597,8 +602,11 @@ fs_stats_reset(struct rte_eth_dev *dev) > struct sub_device *sdev; > uint8_t i; > > - FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) > + FOREACH_SUBDEV_STATE(sdev, i, dev, DEV_ACTIVE) { > rte_eth_stats_reset(PORT_ID(sdev)); > + memset(&sdev->stats_snapshot, 0, sizeof(struct rte_eth_stats)); > + } > + memset(&PRIV(dev)->stats_accumulator, 0, sizeof(struct rte_eth_stats)); > } > > /** > diff --git a/drivers/net/failsafe/failsafe_private.h b/drivers/net/failsafe/failsafe_private.h > index 0361cf4..4861974 100644 > --- a/drivers/net/failsafe/failsafe_private.h > +++ b/drivers/net/failsafe/failsafe_private.h > @@ -102,6 +102,8 @@ struct sub_device { > uint8_t sid; > /* Device state machine */ > enum dev_state state; > + /* Last stats snapshot passed to user */ > + struct rte_eth_stats stats_snapshot; > /* Some device are defined as a command line */ > char *cmdline; > /* fail-safe device backreference */ > @@ -140,6 +142,7 @@ struct fs_priv { > * synchronized state. > */ > enum dev_state state; > + struct rte_eth_stats stats_accumulator; > unsigned int pending_alarm:1; /* An alarm is pending */ > /* flow isolation state */ > int flow_isolated:1; > @@ -180,6 +183,8 @@ int failsafe_eal_uninit(struct rte_eth_dev *dev); > > int failsafe_eth_dev_state_sync(struct rte_eth_dev *dev); > void failsafe_dev_remove(struct rte_eth_dev *dev); > +void failsafe_stats_increment(struct rte_eth_stats *to, > + struct rte_eth_stats *from); > int failsafe_eth_rmv_event_callback(uint8_t port_id, > enum rte_eth_event_type type, > void *arg, void *out); > -- > 2.7.4 > -- Gaëtan Rivet 6WIND