diff --git a/cli/main.c b/cli/main.c index 4fb1f153..e9071aab 100644 --- a/cli/main.c +++ b/cli/main.c @@ -2622,7 +2622,12 @@ static int display_event_counters(struct switchtec_dev *dev, int stack, if (strlen(buf) > 39) strcpy(buf, "MANY"); - printf("%-40s %10u\n", buf, counts[i]); + if (setups[i].type_mask & ALL_TLPS) + printf("%-40s %-8s %10u\n", buf, + setups[i].egress ? "EGRESS" : "INGRESS", + counts[i]); + else + printf("%-40s %-8s %10u\n", buf, "", counts[i]); count++; } diff --git a/inc/switchtec/pmon.h b/inc/switchtec/pmon.h index a3274d2c..4dabe484 100644 --- a/inc/switchtec/pmon.h +++ b/inc/switchtec/pmon.h @@ -28,6 +28,9 @@ #include #include +#define SWITCHTEC_PMON_EVENT_EGRESS 0x80 +#define SWITCHTEC_PMON_EVENT_INGRESS 0x00 + #pragma pack(push, 1) struct pmon_event_counter_setup { diff --git a/lib/pmon.c b/lib/pmon.c index cb9625c2..0c89710e 100644 --- a/lib/pmon.c +++ b/lib/pmon.c @@ -150,7 +150,9 @@ int switchtec_evcntr_setup(struct switchtec_dev *dev, unsigned stack_id, [0] = { .mask = htole32((setup->type_mask << 8) | (setup->port_mask & 0xFF)), - .ieg = setup->egress, + .ieg = (setup->egress ? SWITCHTEC_PMON_EVENT_EGRESS : + SWITCHTEC_PMON_EVENT_INGRESS) | + ((setup->type_mask >> 24) & 0x7F), .thresh = htole32(setup->threshold), }, }, @@ -231,9 +233,12 @@ int switchtec_evcntr_get_setup(struct switchtec_dev *dev, unsigned stack_id, return ret; for (i = 0; i < nr_cntrs; i++) { - res[i].port_mask = le32toh(data[i].mask) & 0xFF; - res[i].type_mask = le32toh(data[i].mask) >> 8; - res[i].egress = data[i].ieg; + uint32_t m = le32toh(data[i].mask); + + res[i].port_mask = m & 0xFF; + res[i].type_mask = ((m >> 8) & 0xFFFFFF) | + ((data[i].ieg & 0x7F) << 24); + res[i].egress = (data[i].ieg >> 7) & 1; res[i].threshold = le32toh(data[i].thresh); }