Skip to content

Support pfc port stats - #509

Open
indraniBh wants to merge 4 commits into
masterfrom
dev-pfc-stats
Open

indraniBh wants to merge 4 commits into
masterfrom
dev-pfc-stats

Conversation

@indraniBh

@indraniBh indraniBh commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Feature Overview

  • Related Issue: N/A
  • Brief Description:
    This PR adds support for Priority Flow Control (PFC) per-class statistics to the port metrics in the Open Traffic Generator models.

Feature Details

  • Redocly docs for this feature/branch

  • New Locations/Nomenclature:
    The new PFC per-class statistics have been added to the Port metrics model:

    Port.Metric.pfc_class_0_frames_rx through Port.Metric.pfc_class_7_frames_rx (fields 17-24)
    Port.Metrics.Request.column_names now includes enums for all 8 PFC classes (fields 15-22)

  • Dev-Snappi branch reference

  • Example command to fetch the dev-snappi branch:

    go get github.com/open-traffic-generator/snappi/gosnappi@dev-pfc-stats
    

Code snippets

Python Example:

# Configure port metrics request to retrieve PFC class statistics
config = Config()
port = config.ports.add(name="port1", location="192.168.1.100:5555")

# Request PFC statistics for all 8 priority classes
request = PortMetricsRequest(
    port_names=["port1"],
    column_names=[
        "frames_tx",
        "frames_rx",
        "pfc_class_0_frames_rx",
        "pfc_class_1_frames_rx",
        "pfc_class_2_frames_rx",
        "pfc_class_3_frames_rx",
        "pfc_class_4_frames_rx",
        "pfc_class_5_frames_rx",
        "pfc_class_6_frames_rx",
        "pfc_class_7_frames_rx",
    ]
)

# Retrieve metrics
api = SnappiApi()
api.set_config(config)
metrics = api.get_port_metrics(request)

# Verify PFC frames received on each class
for metric in metrics.port_metrics:
    print(f"Port: {metric.name}")
    for class_id in range(8):
        pfc_field = f"pfc_class_{class_id}_frames_rx"
        pfc_count = getattr(metric, pfc_field)
        print(f"  PFC Class {class_id}: {pfc_count} frames received")

GO Example:

// Configure port metrics request to retrieve PFC class statistics
config := snappi.NewConfig()
port := config.Ports().Add().SetName("port1").SetLocation("192.168.1.100:5555")

// Request PFC statistics for all 8 priority classes
request := snappi.NewPortMetricsRequest().
    SetPortNames([]string{"port1"}).
    SetColumnNames([]string{
        "frames_tx",
        "frames_rx",
        "pfc_class_0_frames_rx",
        "pfc_class_1_frames_rx",
        "pfc_class_2_frames_rx",
        "pfc_class_3_frames_rx",
        "pfc_class_4_frames_rx",
        "pfc_class_5_frames_rx",
        "pfc_class_6_frames_rx",
        "pfc_class_7_frames_rx",
    })

// Retrieve metrics
api := snappi.NewApi()
api.SetConfig(config)
metrics := api.GetPortMetrics(request)

// Verify PFC frames received on each class
for _, metric := range metrics.PortMetrics().Items() {
    fmt.Printf("Port: %s\n", metric.Name())
    for classID := 0; classID < 8; classID++ {
        pfcCount := metric.PfcClass0FramesRx() // Use corresponding getter for each class
        fmt.Printf("  PFC Class %d: %d frames received\n", classID, pfcCount)
    }

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