Skip to content

Conversation

@spk-hebbar
Copy link
Contributor

@spk-hebbar spk-hebbar commented Jun 9, 2025

  • Implement per interface statistics
  • Export them via DPDK telemetry socket
  • Export them via grcli with show interface stats
  • Implement clear stats with clear stats

@spk-hebbar spk-hebbar force-pushed the iface_tele branch 2 times, most recently from ac6fb8d to b2b133a Compare June 10, 2025 10:41
@rjarry
Copy link
Collaborator

rjarry commented Jun 10, 2025

I'm thinking about this a bit more and the interface statistics should be attached to interfaces themselves.

Otherwise statistics will be displayed in multiple locations.

What do you think about splitting this in multiple steps:

  1. Implement per interface software statistics (rx_packets, rx_bytes, tx_packets, tx_bytes).
  2. Export these statistics via the grout API attached to struct gr_iface.
  3. Expose interface details under "/grout/ifaces".
    --> /grout/ifaces
    [
      {
        "name": "p0",
        "id": 1,
        "type": "port",
        "mtu": 1500,
        "flags": ["up", "running"],
        "mode": "l3",
        "vrf_id": 0
      },
      ...
    ]
  4. Include software statistics per interface in "/grout/ifaces".
    --> /grout/ifaces
    [
      {
        "name": "p0",
        "id": 1,
        "type": "port",
        "mtu": 1500,
        "flags": ["up", "running"],
        "mode": "l3",
        "vrf_id": 0,
        "statistics": {
           "rx_packets": 123501,
           "rx_bytes": 78135123501,
           "tx_packets": 123451,
           "tx_bytes": 81543213211
        }
      },
      ...
    ]
  5. Include extended hardware statistics for type=port interfaces.
    --> /grout/ifaces
    [
      {
        "name": "p0",
        "id": 1,
        "type": "port",
        "mtu": 1500,
        "flags": ["up", "running"],
        "mode": "l3",
        "vrf_id": 0,
        "statistics": {
           "rx_packets": 123501,
           "rx_bytes": 78135123501,
           "tx_packets": 123451,
           "tx_bytes": 81543213211,
           // extra hardware statistics
           "rx_missed": 2,
           "tx_errors": 1,
           // xstats
           "rx_good_packets": 2,
           "rx_good_bytes": 750,
           "rx_multicast_packets": 2,
           "rx_broadcast_packets": 1,
           "rx_unknown_protocol_packets": 3,
           "mac_remote_errors": 1,
           "rx_size_256_to_511_packets": 3
        }
      },
      ...
    ]

What do you think?

@spk-hebbar spk-hebbar force-pushed the iface_tele branch 2 times, most recently from f4e7732 to e12d289 Compare June 23, 2025 09:40
@spk-hebbar spk-hebbar marked this pull request as draft June 23, 2025 09:46
@spk-hebbar spk-hebbar force-pushed the iface_tele branch 2 times, most recently from 09bc9e2 to 7178082 Compare June 23, 2025 11:06
@spk-hebbar spk-hebbar marked this pull request as ready for review June 23, 2025 11:14
@spk-hebbar
Copy link
Contributor Author

@rjarry I agree with your suggestion, please have a look at what I have now.

Copy link
Collaborator

@rjarry rjarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you split that in multiple commits to follow the specs I gave earlier? Also, you forgot to update the grout API to expose the per-iface statistics.

@spk-hebbar
Copy link
Contributor Author

Thanks for the review @rjarry, I have incorporated the changes. I'm working getting another commit for grout API. Will mark the PR as WIP.

@spk-hebbar spk-hebbar marked this pull request as draft June 23, 2025 14:07
@spk-hebbar spk-hebbar changed the title infra: export hardware statistics through DPDK telemetry socket infra: export interface statistics through DPDK telemetry socket Jun 23, 2025
@spk-hebbar spk-hebbar force-pushed the iface_tele branch 2 times, most recently from 85dd5e1 to 1082673 Compare June 24, 2025 08:39
@spk-hebbar spk-hebbar marked this pull request as ready for review June 27, 2025 02:52
@spk-hebbar
Copy link
Contributor Author

@rjarry this is now ready for review. Please have a look. Thanks

Copy link
Collaborator

@rjarry rjarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to reset all interface statistics when the user calls clear stats. Also, Make sure to reset the stats for a given interface when creating a new one.

Copy link
Collaborator

@rjarry rjarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Spoorthi, thanks for the update. We're almost there :)

Could you squash the last commit (infra: clear interface stats) with the one that adds interface stats (infra: implement per interface statistics)? No need to have them separate.

Thanks!

Comment on lines -203 to +217
while ((iface = iface_next(GR_IFACE_TYPE_PORT, iface)) != NULL) {
struct iface_info_port *port = (struct iface_info_port *)iface->info;
if ((ret = rte_eth_stats_reset(port->port_id)) < 0)
return api_out(-ret, 0);
if ((ret = rte_eth_xstats_reset(port->port_id)) < 0)
return api_out(-ret, 0);

while ((iface = iface_next(GR_IFACE_TYPE_UNDEF, iface)) != NULL) {
struct iface_stats *sw_stats = iface_get_stats(iface->id);
// Reset software stats for all interface types.
if (sw_stats != NULL) {
memset(sw_stats, 0, sizeof(*sw_stats));
}

if (iface->type == GR_IFACE_TYPE_PORT) {
struct iface_info_port *port = (struct iface_info_port *)iface->info;
if ((ret = rte_eth_stats_reset(port->port_id)) < 0)
return api_out(-ret, 0);
if ((ret = rte_eth_xstats_reset(port->port_id)) < 0)
return api_out(-ret, 0);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was squashed into the wrong commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic to clear the stats is part of "infra: add API and CLI command to obtain and clear iface stats" commit - d5f812f, I think we are good?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. The statistics already exist in the first commit infra: implement per interface statistics even if they are not exposed in the API yet.

You should implement the reset of these statistics in this commit. Not the one that exposes the stats in the API.

Copy link
Collaborator

@rjarry rjarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could you reset stats when a new interface is created?

s.rx_bytes = 0;
s.tx_packets = 0;
s.tx_bytes = 0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjarry I'm already resetting the stats per iface_id before obtaining the stats. Isn't it enough?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean resetting the internal structure.

static struct iface_stats stats[MAX_IFACES];

So after this line:

ifaces[ifid] = iface;

You need to add:

memset(&stats[ifid], 0, sizeof(stats[ifid]));

So that new interfaces are created with all their statistics reset to 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines -203 to +217
while ((iface = iface_next(GR_IFACE_TYPE_PORT, iface)) != NULL) {
struct iface_info_port *port = (struct iface_info_port *)iface->info;
if ((ret = rte_eth_stats_reset(port->port_id)) < 0)
return api_out(-ret, 0);
if ((ret = rte_eth_xstats_reset(port->port_id)) < 0)
return api_out(-ret, 0);

while ((iface = iface_next(GR_IFACE_TYPE_UNDEF, iface)) != NULL) {
struct iface_stats *sw_stats = iface_get_stats(iface->id);
// Reset software stats for all interface types.
if (sw_stats != NULL) {
memset(sw_stats, 0, sizeof(*sw_stats));
}

if (iface->type == GR_IFACE_TYPE_PORT) {
struct iface_info_port *port = (struct iface_info_port *)iface->info;
if ((ret = rte_eth_stats_reset(port->port_id)) < 0)
return api_out(-ret, 0);
if ((ret = rte_eth_xstats_reset(port->port_id)) < 0)
return api_out(-ret, 0);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic to clear the stats is part of "infra: add API and CLI command to obtain and clear iface stats" commit - d5f812f, I think we are good?

Collect statistics per interface and later expose it via DPDK telemetry
and grout API.

Signed-off-by: Spoorthi K <[email protected]>
Output snippet:
--> /grout/iface
{
  "/grout/iface": {
    "p0": {
      "name": "p0",
      "id": 1,
      "type": "port",
      "mtu": 1500,
      "flags": [
        "up",
        "running"
      ],
      "mode": "l3",
      "vrf_id": 0,
      "statistics": {
        "rx_packets": 3,
        "rx_bytes": 1169,
        "tx_packets": 3,
        "tx_bytes": 150
        "rx_missed": 0,
        "tx_errors": 0,
        "rx_good_packets": 3,
        "tx_good_packets": 3,
        "rx_good_bytes": 1169,
        "tx_good_bytes": 180,
        "rx_multicast_packets": 3,
        "rx_broadcast_packets": 1,
        "rx_unknown_protocol_packets": 4,
        "tx_unicast_packets": 3,
        "mac_remote_errors": 1,
        "rx_size_256_to_511_packets": 4,
        "tx_size_64_packets": 3
      }
    }
  }
}

Signed-off-by: Spoorthi K <[email protected]>
Display interface statistics (rx_packets, rx_bytes, tx_packets and tx_bytes)
per interface using 'show interface stats' grcli command.
With clear stats, reset the these interface statistics along with software and
hardware stats.

Sample output:
grout# show interface
<return>             Validate command.
type                 Show interface details.
stats                Show interface statistics.
name                 Show interface details.

grout# show interface stats
INTERFACE  RX_PACKETS  RX_BYTES  TX_PACKETS  TX_BYTES
p0         7           2757      2           100
gr-loop0   0           0         0           0

grout# clear stats
grout# show interface stats
INTERFACE  RX_PACKETS  RX_BYTES  TX_PACKETS  TX_BYTES
p0         0           0         0           0
gr-loop0   0           0         0           0

Signed-off-by: Spoorthi K <[email protected]>
@rjarry rjarry merged commit 2190714 into DPDK:main Jun 30, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants