Skip to contentSkip to conversation

net/gve: Enable stats reporting for GQ format

PATCH Superseded Rushil Gupta 3 participants 12 messages Dec 22, 2023 – Jan 22, 2024 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/gve: Enable stats reporting for GQ format

Read from shared region to retrieve imissed statistics for GQ from device. Tested using show port xstats <port-id> in interactive mode. This metric can be triggered by using queues > cores.

---
 drivers/net/gve/base/gve_adminq.h | 11 ++++
 drivers/net/gve/gve_ethdev.c      | 95 +++++++++++++++++++++++++++++++
 drivers/net/gve/gve_ethdev.h      |  6 ++
 3 files changed, 112 insertions(+)
drivers/net/gve/base/gve_adminq.h +11 -0
index e30b184913..f05362f85f 100644
@@ -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,
drivers/net/gve/gve_ethdev.c +95 -0

137 lines not on this page · raw message

drivers/net/gve/gve_ethdev.h +6 -0
index 58d8943e71..9893fcfee6 100644
@@ -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
Signature · 1 line
2.43.0.472.g3155946c3a-goog
#1 lore raw
Quoted 4 lines · Rushil Gupta

Read from shared region to retrieve imissed statistics for GQ from device. Tested using show port xstats <port-id> in interactive mode. This metric can be triggered by using queues > cores.

Looks good but please check following comments:

Checkpatch gives warning on the patch title, and this patch adds 'imissed' support so it can be added to the patch title, something like:
"net/gve: enable imissed stats for GQ format"

<...>

Quoted 6 lines
drivers/net/gve/gve_ethdev.c +5 -0
+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;

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) · line 142

Quoted 10 lines
drivers/net/gve/gve_ethdev.c +10 -0
+	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);

Can you please add 'gve_' prefix to the memzone name, to prevent any possible collision.

<...>

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) · line 164

Quoted 5 lines
drivers/net/gve/gve_ethdev.c +4 -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);

What will happen if user asks stats/xstats after port stopped?

<...>

drivers/net/gve/gve_ethdev.c static int · line 447

Quoted 6 lines

gve_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) {

drivers/net/gve/gve_ethdev.c +2 -0
 	uint16_t i;
+	if (gve_is_gqi(dev->data->dev_private))
+		gve_get_imissed_from_nic(dev);

This updates imissed in RxQ struct for all queues for basic stats, but what if user only calls xstats, I guess in that case stat won't be updated.

#2 lore raw
Quoted 32 lines · Ferruh Yigit
Quoted 1 line · Rushil Gupta

Read from shared region to retrieve imissed statistics for GQ from

device.

Quoted 3 lines

Tested using show port xstats <port-id> in interactive mode. This metric can be triggered by using queues > cores.

Looks good but please check following comments:

Checkpatch gives warning on the patch title, and this patch adds 'imissed' support so it can be added to the patch title, something like:
"net/gve: enable imissed stats for GQ format"

<...>

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)

Quoted 8 lines
drivers/net/gve/gve_ethdev.c +8 -0
+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)

*

Review

Quoted 2 lines
(quoted diff) +2 -0
+             nb_tx_queues;
+     rx_stats_cnt = (GVE_RX_STATS_REPORT_NUM + NIC_RX_STATS_REPORT_NUM)

*

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)

Quoted 5 lines
drivers/net/gve/gve_ethdev.c +5 -0
+             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->
Quoted 6 lines

device.name);

Quoted 1 line

Can you please add 'gve_' prefix to the memzone name, to prevent any possible collision.

Done.

Quoted 11 lines

<...>

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) · line 164

Quoted 5 lines
drivers/net/gve/gve_ethdev.c +4 -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);

What will happen if user asks stats/xstats after port stopped?

Good catch. I have added a null check so that the driver doesn't try to read stats from memory region that doesn't exist.

Quoted 10 lines

<...>

drivers/net/gve/gve_ethdev.c static int · line 447

Quoted 6 lines

gve_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)

 {
      uint16_t i;
drivers/net/gve/gve_ethdev.c +2 -0
+     if (gve_is_gqi(dev->data->dev_private))
+             gve_get_imissed_from_nic(dev);
Quoted 3 lines

This updates imissed in RxQ struct for all queues for basic stats, but what if user only calls xstats, I guess in that case stat won't be updated.

Yes; that is expected. Since imissed is a member of rte_eth_stats; calling gve_dev_stats_get is the right way to get this stat.

#3 lore raw
Quoted 11 lines
Quoted 11 lines

<...>

Quoted 6 lines

gve_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)

 {
      uint16_t i;
drivers/net/gve/gve_ethdev.c +2 -0
+     if (gve_is_gqi(dev->data->dev_private))
+             gve_get_imissed_from_nic(dev);
Quoted 8 lines
Quoted 4 lines

This updates imissed in RxQ struct for all queues for basic stats, but what if user only calls xstats, I guess in that case stat won't be updated.

Yes; that is expected. Since imissed is a member of rte_eth_stats; calling gve_dev_stats_get is the right way to get this stat.

I actually think that this should be a counter backed by an xstat as well. As far as I can tell xstats is meant to be a more flexible version of stats, and ultimately should be able to handle a superset of what basic stats can handle, for the purposes of querying, etc.

Quoted 76 lines · Rushil Gupta
Quoted 32 lines · Ferruh Yigit
Quoted 1 line · Rushil Gupta

Read from shared region to retrieve imissed statistics for GQ from

device.

Quoted 3 lines

Tested using show port xstats <port-id> in interactive mode. This metric can be triggered by using queues > cores.

Looks good but please check following comments:

Checkpatch gives warning on the patch title, and this patch adds 'imissed' support so it can be added to the patch title, something like:
"net/gve: enable imissed stats for GQ format"

<...>

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)

Quoted 8 lines
drivers/net/gve/gve_ethdev.c +8 -0
+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) *

Review

Quoted 2 lines
(quoted diff) +2 -0
+             nb_tx_queues;
+     rx_stats_cnt = (GVE_RX_STATS_REPORT_NUM +

NIC_RX_STATS_REPORT_NUM) *

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)

Quoted 5 lines
drivers/net/gve/gve_ethdev.c +5 -0
+             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",
Quoted 6 lines

priv->pci_dev->device.name);

Quoted 1 line

Can you please add 'gve_' prefix to the memzone name, to prevent any possible collision.

Done.

Quoted 11 lines

<...>

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) · line 164

Quoted 5 lines
drivers/net/gve/gve_ethdev.c +4 -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);

What will happen if user asks stats/xstats after port stopped?

Good catch. I have added a null check so that the driver doesn't try to read stats from memory region that doesn't exist.

Quoted 10 lines

<...>

drivers/net/gve/gve_ethdev.c static int · line 447

Quoted 6 lines

gve_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)

 {
      uint16_t i;
drivers/net/gve/gve_ethdev.c +2 -0
+     if (gve_is_gqi(dev->data->dev_private))
+             gve_get_imissed_from_nic(dev);
Quoted 4 lines

This updates imissed in RxQ struct for all queues for basic stats, but what if user only calls xstats, I guess in that case stat won't be updated.

Yes; that is expected. Since imissed is a member of rte_eth_stats; calling gve_dev_stats_get is the right way to get this stat.

Signature · 1 line
Joshua Washington | Software Engineer | [email protected] | (414) 366-4423
#4 lore raw
In reply to Rushil Gupta
Quoted 74 lines · Rushil Gupta

On Fri, Jan 12, 2024 at 8:36 PM Ferruh Yigit <[email protected] <mailto:[email protected]>> wrote:

    On 12/22/2023 3:39 PM, Rushil Gupta wrote:
    > Read from shared region to retrieve imissed statistics for GQ from
    device.
    > Tested using `show port xstats <port-id>` in interactive mode.
    > This metric can be triggered by using queues > cores.
    >

    Looks good but please check following comments:

    Checkpatch gives warning on the patch title, and this patch adds
    'imissed' support so it can be added to the patch title, something like:
    "net/gve: enable imissed stats for GQ format"

    <...>

    > +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 <http://device.name>);
    >

    Can you please add 'gve_' prefix to the memzone name, to prevent any
    possible collision.

Done.

    <...>

    > +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);
    >

    What will happen if user asks stats/xstats after port stopped?

Good catch. I have added a null check so that the driver doesn't try to read stats from memory region that doesn't exist.

    <...>

    >  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);
    > 

    This updates imissed in RxQ struct for all queues for basic stats, but
    what if user only calls xstats, I guess in that case stat won't be
    updated.
Quoted 4 lines


Yes; that is expected. Since imissed is a member of rte_eth_stats; calling gve_dev_stats_get is the right way to get this stat.

I don't think it is expected.
xstats contains the basic stats too, if users calls xstats API, expectation is to get correct values.

#5 lore raw

Those are fair points. I'll fix this by simply
calling gve_get_imissed_from_nic from gve_xstats_get in the v3 patch.

Quoted 87 lines · Ferruh Yigit
Quoted 12 lines · Rushil Gupta

On Fri, Jan 12, 2024 at 8:36 PM Ferruh Yigit <[email protected] <mailto:[email protected]>> wrote:

On 12/22/2023 3:39 PM, Rushil Gupta wrote:
> Read from shared region to retrieve imissed statistics for GQ from device.
> Tested using show port xstats <port-id> in interactive mode. > This metric can be triggered by using queues > cores. >

Quoted 4 lines

Looks good but please check following comments:

Checkpatch gives warning on the patch title, and this patch adds 'imissed' support so it can be added to the patch title, something

like:

Quoted 44 lines
    "net/gve: enable imissed stats for GQ format"

    <...>

    > +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 <http://device.name>);
    >

    Can you please add 'gve_' prefix to the memzone name, to prevent any
    possible collision.

Done.

    <...>

    > +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);
    >

    What will happen if user asks stats/xstats after port stopped?

Good catch. I have added a null check so that the driver doesn't try to read stats from memory region that doesn't exist.

Quoted 11 lines
    <...>

    >  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);
    >

    This updates imissed in RxQ struct for all queues for basic stats,

but

Quoted 7 lines

what if user only calls xstats, I guess in that case stat won't be updated.

Yes; that is expected. Since imissed is a member of rte_eth_stats; calling gve_dev_stats_get is the right way to get this stat.

I don't think it is expected.
xstats contains the basic stats too, if users calls xstats API, expectation is to get correct values.

#6 lore raw

PATCH v2 1/1 net/gve: enable imissed stats for GQ format

In reply to Rushil Gupta

Read from shared region to retrieve imissed statistics for GQ from device. Tested using show port xstats <port-id> in interactive mode.

---
 drivers/net/gve/base/gve_adminq.h |  11 ++++
 drivers/net/gve/gve_ethdev.c      | 100 ++++++++++++++++++++++++++++++
 drivers/net/gve/gve_ethdev.h      |   6 ++
 3 files changed, 117 insertions(+)
drivers/net/gve/base/gve_adminq.h +11 -0
index e30b184913..f05362f85f 100644
@@ -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,
drivers/net/gve/gve_ethdev.c +100 -0

142 lines not on this page · raw message

drivers/net/gve/gve_ethdev.h +6 -0
index 58d8943e71..6ffc5c2deb 100644
@@ -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
Signature · 1 line
2.34.1
#7 lore raw

PATCH v3 1/1 net/gve: enable imissed stats for GQ format

In reply to Rushil Gupta

Read from shared region to retrieve imissed statistics for GQ from device.

---
 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(+)
drivers/net/gve/base/gve_adminq.h +11 -0
index e30b184913..f05362f85f 100644
@@ -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,
drivers/net/gve/gve_ethdev.c +103 -0

151 lines not on this page · raw message

drivers/net/gve/gve_ethdev.h +6 -0
index 58d8943e71..6ffc5c2deb 100644
@@ -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
Signature · 1 line
2.34.1
#8 lore raw

Re: [v3] net/gve: enable imissed stats for GQ format

Quoted 5 lines · Rushil Gupta

Read from shared region to retrieve imissed statistics for GQ from device.

<...>

Quoted 11 lines
drivers/net/gve/gve_ethdev.c +10 -0
+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;

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) · line 147

Quoted 10 lines
drivers/net/gve/gve_ethdev.c +10 -0
+	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);

Adding 'gve_' prefix to memzone name comment seems missed.

#9 lore raw

Re: [v3] net/gve: enable imissed stats for GQ format

I misinterpreted your comment earlier and prefixed memzone variable name with "gve" instead of memzone name. Will fix it in v4. Thanks!

Quoted 38 lines · Ferruh Yigit
Quoted 1 line · Rushil Gupta

Read from shared region to retrieve imissed statistics for GQ from

device.

Quoted 4 lines

<...>

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)

Quoted 9 lines
drivers/net/gve/gve_ethdev.c +9 -0
+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)

*

Review

Quoted 2 lines
(quoted diff) +2 -0
+             nb_tx_queues;
+     rx_stats_cnt = (GVE_RX_STATS_REPORT_NUM + NIC_RX_STATS_REPORT_NUM)

*

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete)

Quoted 5 lines
drivers/net/gve/gve_ethdev.c +5 -0
+             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);

drivers/net/gve/gve_ethdev.c gve_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) · line 147

Quoted 5 lines
drivers/net/gve/gve_ethdev.c +4 -0
+     priv->gve_stats_report_mem = rte_memzone_reserve_aligned(z_name,
+                     priv->stats_report_len,
+                     rte_socket_id(),
+                     RTE_MEMZONE_IOVA_CONTIG, PAGE_SIZE);

Adding 'gve_' prefix to memzone name comment seems missed.

#10 lore raw

PATCH v4 1/1 net/gve: enable imissed stats for GQ format

In reply to Rushil Gupta

Read from shared region to retrieve imissed statistics for GQ from device.

---
 drivers/net/gve/base/gve_adminq.h |  11 ++++
 drivers/net/gve/gve_ethdev.c      | 104 ++++++++++++++++++++++++++++++
 drivers/net/gve/gve_ethdev.h      |   6 ++
 3 files changed, 121 insertions(+)
drivers/net/gve/base/gve_adminq.h +11 -0
index e30b184913..f05362f85f 100644
@@ -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,
drivers/net/gve/gve_ethdev.c +104 -0

152 lines not on this page · raw message

drivers/net/gve/gve_ethdev.h +6 -0
index 58d8943e71..9893fcfee6 100644
@@ -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
Signature · 1 line
2.34.1