From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6889E438FF; Fri, 19 Jan 2024 15:26:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D99DD4029F; Fri, 19 Jan 2024 15:26:55 +0100 (CET) Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by mails.dpdk.org (Postfix) with ESMTP id DFBC240279 for ; Fri, 19 Jan 2024 15:26:54 +0100 (CET) Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc236791689so1310227276.3 for ; Fri, 19 Jan 2024 06:26:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1705674414; x=1706279214; darn=dpdk.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=NPo2t2h4GWra/626LU94dPtI3/TGEQ4H+QaiuVfqMuA=; b=wqC8s+e6hcwTNOMo6v3A6SSED85fNkiS53NxGR1T1FoNJYmy+yxz8ogKJWqa1qBUQT 6Xv0RQMGzcpKzxZLhtpPKzW2XV8UrrPJEr8ogJ0eu0ZYX/S5WO/L13AsbfiM7e2SDV/7 mQT6uUwZuDnr+TTXDggnkf8Dfin9uQa76c3s1B1Ou+a2xkoCCyEHujfYKj1eP2gJYmoT cH5IyTf+KSwdDjzk5SihrBWpehi3JtdqzLXo4Us6GFAeB8YdMq/E2ZrkNLpHX/9fR4qe bdeScbpvWmVkm4Vg9lUjRTBZUEPIG9MYoYp99luWC+UqYehF/sqEghL5g+BcjdDGl8eh i1WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705674414; x=1706279214; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NPo2t2h4GWra/626LU94dPtI3/TGEQ4H+QaiuVfqMuA=; b=kGLnnLiiiFwhTwzMXDHqR49qzyzRRlITJPYL9oSXbpCbA/RktdtoFsF5b6nU8TyETe BhX5SFQ1IXvGnVpFBcHiJjMU4VdkqfDPZsl7fHPY58HqKGVyifAtL1X2X03IMQQMQaiX tB9Z3TmgW7eLyOzndTJq5eZHb5p2tf5UCl4D4XdxvtRW3d36r9Emt/Fz6dA+kZQHWlFj zm+PzoqvQSo5KyQKuZ8pKs+tUmiflUM6SX8JGVOMJItSxcb6ITmeu23aUB5Ua9YbRhs6 XnJ92CXKTtYwRrmcvpiHp1r19i2fq1j0WFb911wXG3sTLnau+kM3NWHEujR35ssxuR/l Ypvw== X-Gm-Message-State: AOJu0YyISNgskoWGyAMaRV1yRlzr7s4p18k9VUF2MIX2d/RGZo/K3M7/ B88/i8WNiiTtFYn73Q2r5/9kT7dffPeMgIUQkxSw0xkohVUZ/N2gJqRXBuBCvfoLg6DIo6/zLGn vxlBDSA== X-Google-Smtp-Source: AGHT+IE6wjsPkWaXh8E1sd06lyNF9lUg0UaKprckA4Q4i4UMOpyFPLMizod27VK3SMFHZlnH+fY993u5d6vM X-Received: from wrushilg.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2168]) (user=rushilg job=sendgmr) by 2002:a25:ae0d:0:b0:dc2:1c5d:eed5 with SMTP id a13-20020a25ae0d000000b00dc21c5deed5mr1103975ybj.12.1705674414162; Fri, 19 Jan 2024 06:26:54 -0800 (PST) Date: Fri, 19 Jan 2024 14:26:50 +0000 In-Reply-To: <20231222153953.1266615-1-rushilg@google.com> Mime-Version: 1.0 References: <20231222153953.1266615-1-rushilg@google.com> X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240119142650.3504824-1-rushilg@google.com> Subject: [v3] net/gve: enable imissed stats for GQ format From: Rushil Gupta To: junfeng.guo@intel.com, jeroendb@google.com, joshwash@google.com, ferruh.yigit@amd.com Cc: dev@dpdk.org, Rushil Gupta Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Read from shared region to retrieve imissed statistics for GQ from device. Signed-off-by: Rushil Gupta Reviewed-by: Joshua Washington --- drivers/net/gve/base/gve_adminq.h | 11 ++++ drivers/net/gve/gve_ethdev.c | 103 ++++++++++++++++++++++++++++++ drivers/net/gve/gve_ethdev.h | 6 ++ 3 files changed, 120 insertions(+) diff --git a/drivers/net/gve/base/gve_adminq.h b/drivers/net/gve/base/gve_adminq.h index e30b184913..f05362f85f 100644 --- a/drivers/net/gve/base/gve_adminq.h +++ b/drivers/net/gve/base/gve_adminq.h @@ -314,6 +314,17 @@ struct gve_stats_report { GVE_CHECK_STRUCT_LEN(8, gve_stats_report); +/* Numbers of gve tx/rx stats in stats report. */ +#define GVE_TX_STATS_REPORT_NUM 6 +#define GVE_RX_STATS_REPORT_NUM 2 + +/* Interval to schedule a stats report update, 20000ms. */ +#define GVE_STATS_REPORT_TIMER_PERIOD 20000 + +/* Numbers of NIC tx/rx stats in stats report. */ +#define NIC_TX_STATS_REPORT_NUM 0 +#define NIC_RX_STATS_REPORT_NUM 4 + enum gve_stat_names { /* stats from gve */ TX_WAKE_CNT = 1, diff --git a/drivers/net/gve/gve_ethdev.c b/drivers/net/gve/gve_ethdev.c index ecd37ff37f..723b9332b8 100644 --- a/drivers/net/gve/gve_ethdev.c +++ b/drivers/net/gve/gve_ethdev.c @@ -125,6 +125,78 @@ gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) return rte_eth_linkstatus_set(dev, &link); } +static int +gve_alloc_stats_report(struct gve_priv *priv, + uint16_t nb_tx_queues, uint16_t nb_rx_queues) +{ + char z_name[RTE_MEMZONE_NAMESIZE]; + int tx_stats_cnt; + int rx_stats_cnt; + + tx_stats_cnt = (GVE_TX_STATS_REPORT_NUM + NIC_TX_STATS_REPORT_NUM) * + nb_tx_queues; + rx_stats_cnt = (GVE_RX_STATS_REPORT_NUM + NIC_RX_STATS_REPORT_NUM) * + nb_rx_queues; + priv->stats_report_len = sizeof(struct gve_stats_report) + + sizeof(struct stats) * (tx_stats_cnt + rx_stats_cnt); + + snprintf(z_name, sizeof(z_name), "stats_report_%s", priv->pci_dev->device.name); + priv->gve_stats_report_mem = rte_memzone_reserve_aligned(z_name, + priv->stats_report_len, + rte_socket_id(), + RTE_MEMZONE_IOVA_CONTIG, PAGE_SIZE); + + if (!priv->gve_stats_report_mem) + return -ENOMEM; + + /* offset by skipping stats written by gve. */ + priv->stats_start_idx = (GVE_TX_STATS_REPORT_NUM * nb_tx_queues) + + (GVE_RX_STATS_REPORT_NUM * nb_rx_queues); + priv->stats_end_idx = priv->stats_start_idx + + (NIC_TX_STATS_REPORT_NUM * nb_tx_queues) + + (NIC_RX_STATS_REPORT_NUM * nb_rx_queues) - 1; + + return 0; +} + +static void +gve_free_stats_report(struct rte_eth_dev *dev) +{ + struct gve_priv *priv = dev->data->dev_private; + rte_memzone_free(priv->gve_stats_report_mem); + priv->gve_stats_report_mem = NULL; +} + +/* Read Rx NIC stats from shared region */ +static void +gve_get_imissed_from_nic(struct rte_eth_dev *dev) +{ + struct gve_stats_report *stats_report; + struct gve_rx_queue *rxq; + struct gve_priv *priv; + struct stats stat; + int queue_id; + int stat_id; + int i; + + priv = dev->data->dev_private; + if (!priv->gve_stats_report_mem) + return; + stats_report = (struct gve_stats_report *) + priv->gve_stats_report_mem->addr; + for (i = priv->stats_start_idx; i <= priv->stats_end_idx; i++) { + stat = stats_report->stats[i]; + queue_id = cpu_to_be32(stat.queue_id); + rxq = dev->data->rx_queues[queue_id]; + if (rxq == NULL) + continue; + stat_id = cpu_to_be32(stat.stat_name); + /* Update imissed. */ + if (stat_id == RX_NO_BUFFERS_POSTED) + rxq->stats.imissed = cpu_to_be64(stat.value); + } +} + static int gve_start_queues(struct rte_eth_dev *dev) { @@ -176,6 +248,7 @@ gve_start_queues(struct rte_eth_dev *dev) static int gve_dev_start(struct rte_eth_dev *dev) { + struct gve_priv *priv; int ret; ret = gve_start_queues(dev); @@ -187,6 +260,26 @@ gve_dev_start(struct rte_eth_dev *dev) dev->data->dev_started = 1; gve_link_update(dev, 0); + priv = dev->data->dev_private; + /* No stats available yet for Dqo. */ + if (gve_is_gqi(priv)) { + ret = gve_alloc_stats_report(priv, + dev->data->nb_tx_queues, + dev->data->nb_rx_queues); + if (ret != 0) { + PMD_DRV_LOG(ERR, + "Failed to allocate region for stats reporting."); + return ret; + } + ret = gve_adminq_report_stats(priv, priv->stats_report_len, + priv->gve_stats_report_mem->iova, + GVE_STATS_REPORT_TIMER_PERIOD); + if (ret != 0) { + PMD_DRV_LOG(ERR, "gve_adminq_report_stats command failed."); + return ret; + } + } + return 0; } @@ -200,6 +293,9 @@ gve_dev_stop(struct rte_eth_dev *dev) dev->data->dev_started = 0; + if (gve_is_gqi(dev->data->dev_private)) + gve_free_stats_report(dev); + return 0; } @@ -352,6 +448,8 @@ static int gve_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { uint16_t i; + if (gve_is_gqi(dev->data->dev_private)) + gve_get_imissed_from_nic(dev); for (i = 0; i < dev->data->nb_tx_queues; i++) { struct gve_tx_queue *txq = dev->data->tx_queues[i]; @@ -372,6 +470,7 @@ gve_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->ibytes += rxq->stats.bytes; stats->ierrors += rxq->stats.errors; stats->rx_nombuf += rxq->stats.no_mbufs; + stats->imissed += rxq->stats.imissed; } return 0; @@ -443,6 +542,7 @@ static const struct gve_xstats_name_offset rx_xstats_name_offset[] = { { "errors", RX_QUEUE_STATS_OFFSET(errors) }, { "mbuf_alloc_errors", RX_QUEUE_STATS_OFFSET(no_mbufs) }, { "mbuf_alloc_errors_bulk", RX_QUEUE_STATS_OFFSET(no_mbufs_bulk) }, + { "imissed", RX_QUEUE_STATS_OFFSET(imissed) }, }; static int @@ -471,6 +571,9 @@ gve_xstats_get(struct rte_eth_dev *dev, uint16_t i, j, count = gve_xstats_count(dev); const char *stats; + if (gve_is_gqi(dev->data->dev_private)) + gve_get_imissed_from_nic(dev); + if (xstats == NULL || size < count) return count; diff --git a/drivers/net/gve/gve_ethdev.h b/drivers/net/gve/gve_ethdev.h index 58d8943e71..6ffc5c2deb 100644 --- a/drivers/net/gve/gve_ethdev.h +++ b/drivers/net/gve/gve_ethdev.h @@ -85,6 +85,7 @@ struct gve_rx_stats { uint64_t errors; uint64_t no_mbufs; uint64_t no_mbufs_bulk; + uint64_t imissed; }; struct gve_xstats_name_offset { @@ -272,6 +273,11 @@ struct gve_priv { struct gve_tx_queue **txqs; struct gve_rx_queue **rxqs; + + uint32_t stats_report_len; + const struct rte_memzone *gve_stats_report_mem; + uint16_t stats_start_idx; /* start index of array of stats written by NIC */ + uint16_t stats_end_idx; /* end index of array of stats written by NIC */ }; static inline bool -- 2.34.1