From patchwork Tue Dec 19 02:13:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rushil Gupta X-Patchwork-Id: 135323 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id DE3474373B; Tue, 19 Dec 2023 03:13:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 651FA402D0; Tue, 19 Dec 2023 03:13:25 +0100 (CET) Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by mails.dpdk.org (Postfix) with ESMTP id 7BF49402B1 for ; Tue, 19 Dec 2023 03:13:24 +0100 (CET) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5d0c4ba7081so42831487b3.0 for ; Mon, 18 Dec 2023 18:13:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702952004; x=1703556804; darn=dpdk.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=xcs3c/T8Bc36JpkQfx3s1u24Q0o6oh+FkrMLwvvxupc=; b=Ub7lN4VYdCR9F6wLbJfV/k6CIRIMDtpJ9Z69jOUyQIS+2we82V0g9c7ENNe5XXw9Dl a5ovPY4jG0oGefbprXMWYL+9oYa6yxPGdT7gp2QFMLjycTYltGXIx/lHdobe5IWkD6H+ Zd8Tiwqn+vY4mM5Gja5YHaltrTykJRa/p0IomRbnaH/q2J9rY0QV16zjzs5fkeZrvUgv Otho7nHzmeayUHCzPu4xMGeMB6IqlhZD0arV8QNj/dy5NgkbUU0aHI3+6rVx5UuUVDjy rK25UnORZx+OqAi+mZQt4BD3D9MlU8u9EKru6XduhoroacMVNBJ3DzJ3etzvaUw3wxvO /WqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702952004; x=1703556804; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xcs3c/T8Bc36JpkQfx3s1u24Q0o6oh+FkrMLwvvxupc=; b=bMUuQkinyWTAMqoMoow81ZA7mniZtjAY3U8sZZ5LFhsSR2wa7Q7Vqjx9BSDGJQkvih 3lHmYv1Q9QhtkMwvZP1+/kfRCdc/1ptWz50WBKCCwQx2rjOnkHai84Z72ZKUNjSLx/r6 ydaEo2P0uhwEzK4aYP/Sm/K6L63Vv+CzoVttZYVDtRr81JjDoX4kX7tahxrdqZdnzGZM Kn8iaalZTKNhRr3ikFa9unmzCTbe/f8dV1l5qKlQFkc/vjjPCnE0k/U8NR2jM6ffHd0u LG7W5OL7NmwInqpfy+cGrNR/qn/6HDGAQVEhLBjjH615wqD8XPP60m5HYN6sRAyEYm0B H9lQ== X-Gm-Message-State: AOJu0YwEG5auG50LyvhPGeLmex0pdWaYb/7165YMuRNbDDD7EdqinJzy KOXBHhPt71LiIxEVBrHYfXZtHqE8p9Q2 X-Google-Smtp-Source: AGHT+IFRiOdbhi8jAoQ9Pn1ab8POvy4KueAgCms+ugpjDDVPMy76nu0D8wKZ6pvVS7M+/5ow1nDHbcTYjsrl X-Received: from wrushilg.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2168]) (user=rushilg job=sendgmr) by 2002:a25:bcce:0:b0:dbd:547e:4aac with SMTP id l14-20020a25bcce000000b00dbd547e4aacmr7888ybm.5.1702952003886; Mon, 18 Dec 2023 18:13:23 -0800 (PST) Date: Tue, 19 Dec 2023 02:13:21 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231219021321.548345-1-rushilg@google.com> Subject: [PATCH] net/gve: Enable stats reporting 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 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. Tested using `show port xstats ` in interactive mode. This metric can be triggered by using queues > cores. Signed-off-by: Rushil Gupta Reviewed-by: Joshua Washington --- drivers/net/gve/base/gve_adminq.h | 11 ++++ drivers/net/gve/gve_ethdev.c | 84 +++++++++++++++++++++++++++++++ drivers/net/gve/gve_ethdev.h | 6 +++ 3 files changed, 101 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..0829c17fc2 100644 --- a/drivers/net/gve/gve_ethdev.c +++ b/drivers/net/gve/gve_ethdev.c @@ -125,6 +125,70 @@ 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) +{ + 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); + priv->stats_report_mem = rte_memzone_reserve_aligned("report_stats", + priv->stats_report_len, + rte_socket_id(), + RTE_MEMZONE_IOVA_CONTIG, PAGE_SIZE); + + if (!priv->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->stats_report_mem); +} + +/* 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; + stats_report = (struct gve_stats_report *) + priv->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 +240,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 +252,18 @@ 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)) + { + gve_alloc_stats_report(priv, + dev->data->nb_tx_queues, + dev->data->nb_rx_queues); + ret = gve_adminq_report_stats(priv, priv->stats_report_len, + priv->stats_report_mem->iova, + GVE_STATS_REPORT_TIMER_PERIOD); + } + return 0; } @@ -200,6 +277,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 +432,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 +454,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 +526,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 diff --git a/drivers/net/gve/gve_ethdev.h b/drivers/net/gve/gve_ethdev.h index 58d8943e71..9893fcfee6 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 *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