Fix egress bit encoding in event counter setup, add direction to evcntr output#371
Open
arjunyg wants to merge 2 commits intoMicrosemi:masterfrom
Open
Fix egress bit encoding in event counter setup, add direction to evcntr output#371arjunyg wants to merge 2 commits intoMicrosemi:masterfrom
arjunyg wants to merge 2 commits intoMicrosemi:masterfrom
Conversation
added 2 commits
April 17, 2026 19:52
The egress (ingress/egress) bit belongs in bit 7 of the byte following the 32-bit mask field, alongside type mask bits 24-30 in bits 6:0. Previously, the egress flag was written as 0x01 into this byte instead of 0x80, and type mask bits 24-30 were not included. On readback, the egress flag was incorrectly extracted from bit 0 rather than bit 7, and the upper type mask bits were dropped entirely.
Add INGRESS/EGRESS label to the evcntr display for counters that count TLP types (ALL_TLPS, POSTED_TLP, COMP_TLP, NON_POSTED_TLP), where direction is meaningful.
d1242ce to
009dcf0
Compare
lsgunth
approved these changes
Apr 22, 2026
Collaborator
lsgunth
left a comment
There was a problem hiding this comment.
A couple suggestions, but on balance this makes sense.
| .counters = { | ||
| [0] = { | ||
| .mask = htole32((setup->type_mask << 8) | | ||
| .mask = htole32(((setup->type_mask & 0xFFFFFF) << 8) | |
Collaborator
There was a problem hiding this comment.
mask is only 32 bits to begin with, so I'm not sure that this change actually does anything.
| .mask = htole32(((setup->type_mask & 0xFFFFFF) << 8) | | ||
| (setup->port_mask & 0xFF)), | ||
| .ieg = setup->egress, | ||
| .ieg = (setup->egress ? 0x80 : 0x00) | |
Collaborator
There was a problem hiding this comment.
I'd suggest creating a definition in pmon.h for 0x80. SWITCHTEC_PMON_EVENT_EGRESS or something like that.
BenReed161
approved these changes
Apr 27, 2026
Collaborator
BenReed161
left a comment
There was a problem hiding this comment.
Address Logan's comments, everything else looks good to me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The ingress/egress direction bit was being encoded incorrectly in the
MRPC_PMON_SETUP_EV_COUNTERinput. Per the firmware spec, the I/E bit is bit 7 of the byte following the 32-bit mask field (alongside type mask bits 24–30 in bits 6:0). The code was writing the ieg byte as0x01into that byte instead of0x80, so the firmware always saw ingress (and a corrupt type mask bit 24). On readback,evcntr-showwould displayINGRESSregardless of how the counter was configured. Additionally, type mask bits 24–30 were not being included in that byte on write, nor recovered on readback.Changes
pmon: fix egress bit encoding and decoding in event counter setup
lib/pmon.cswitchtec_evcntr_setupto set bit 7 of theiegbyte for egress (0x80) and pack type mask bits 24–30 into bits 6:0switchtec_evcntr_get_setupto extract the egress flag from bit 7 ofiegand recover type mask bits 24–30 from bits 6:0evcntr: display ingress/egress direction in event counter output
cli/main.cINGRESS/EGRESSlabel toevcntroutput for counters measuring TLP types, where direction is meaningfulTesting
Configured 11 event counters on a G4 PFX device covering all TLP types in both directions, plus some error counters.
evcntroutput correctly shows direction for TLP counters and omits it for error counters.evcntr-showcorrectly reads back the configured direction:Event Counter Setup
Show Counter Configuration
Read Counters