Skip to content

Commit 2951e60

Browse files
committed
Merge branch 'spinler-fix-etherStats' into 'devel'
fix(libnfb - rxmac): use correct value for pkts in etherStats See merge request ndk/swbase!144
2 parents 31a8457 + e6d99b8 commit 2951e60

File tree

4 files changed

+34
-21
lines changed

4 files changed

+34
-21
lines changed

libnfb/include/netcope/rxmac.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ struct nc_rxmac_etherstats {
6666
unsigned long long pkts256to511Octets; /*!< Total number of received packets that were between 256 and 511 bytes long */
6767
unsigned long long pkts512to1023Octets; /*!< Total number of received packets that were between 512 and 1023 bytes long */
6868
unsigned long long pkts1024to1518Octets; /*!< Total number of received packets that were between 1024 and 1518 bytes long */
69+
unsigned long long underMinPkts; /*!< Total number of received packets that were shorter than configured minimum */
70+
unsigned long long overMaxPkts; /*!< Total number of received packets that were longer than configured maximum */
6971
};
7072

7173
struct nc_rxmac_status {
@@ -112,9 +114,9 @@ static inline void nc_rxmac_set_error_mask(struct nc_rxmac *mac, uns
112114
#define RXMAC_REG_CNT_ES_CRC_ERR_LO 0x0100
113115
#define RXMAC_REG_CNT_ES_CRC_ERR_HI 0x0138
114116

115-
/* Total received packets over set MTU (etherStatsPkts) */
116-
#define RXMAC_REG_CNT_ES_PKTS_LO 0x0104
117-
#define RXMAC_REG_CNT_ES_PKTS_HI 0x013C
117+
/* Total received packets over set MTU */
118+
#define RXMAC_REG_CNT_ES_OVERSIZE_LO 0x0104
119+
#define RXMAC_REG_CNT_ES_OVERSIZE_HI 0x013C
118120

119121
/* Total received packets below set minimal length */
120122
#define RXMAC_REG_CNT_ES_UNDERSIZE_LO 0x0108
@@ -313,13 +315,19 @@ static inline int nc_rxmac_read_counters(struct nc_rxmac *mac, struct nc_rxmac_c
313315
{
314316
struct nfb_comp *comp = nfb_user_to_comp(mac);
315317

318+
unsigned long long cnt_total = 0;
319+
316320
if (!nfb_comp_lock(comp, RXMAC_COMP_LOCK))
317321
return -EAGAIN;
318322

319323
nfb_comp_write32(comp, RXMAC_REG_CONTROL, RXMAC_CMD_STROBE);
320324

325+
if (c || s) {
326+
cnt_total = RXMAC_READ_CNT(comp, PACKETS);
327+
}
328+
321329
if (c) {
322-
c->cnt_total = RXMAC_READ_CNT(comp, PACKETS);
330+
c->cnt_total = cnt_total;
323331
c->cnt_received = RXMAC_READ_CNT(comp, RECEIVED);
324332
c->cnt_overflowed = RXMAC_READ_CNT(comp, OVERFLOW);
325333
c->cnt_erroneous = RXMAC_READ_CNT(comp, DISCARDED) - c->cnt_overflowed;
@@ -328,15 +336,18 @@ static inline int nc_rxmac_read_counters(struct nc_rxmac *mac, struct nc_rxmac_c
328336

329337
if (s) {
330338
s->octets = RXMAC_READ_CNT(comp, ES_OCTETS);
331-
s->pkts = RXMAC_READ_CNT(comp, ES_PKTS);
339+
s->pkts = cnt_total;
332340
s->broadcastPkts = RXMAC_READ_CNT(comp, ES_BCAST);
333341
s->multicastPkts = RXMAC_READ_CNT(comp, ES_MCAST);
334342
s->CRCAlignErrors = RXMAC_READ_CNT(comp, ES_CRC_ERR);
335343
if (mac->has_counter_below_64) {
336344
s->undersizePkts = RXMAC_READ_CNT(comp, ES_FRAMES_BELOW_64);
337345
} else {
338-
s->undersizePkts = RXMAC_READ_CNT(comp, ES_UNDERSIZE);
346+
s->undersizePkts = 0;
339347
}
348+
349+
s->underMinPkts = RXMAC_READ_CNT(comp, ES_UNDERSIZE);
350+
s->overMaxPkts = RXMAC_READ_CNT(comp, ES_OVERSIZE);
340351
s->oversizePkts = RXMAC_READ_CNT(comp, ES_FRAMES_OVER_1518);
341352
s->fragments = RXMAC_READ_CNT(comp, ES_FRAGMENTS);
342353
s->jabbers = RXMAC_READ_CNT(comp, ES_JABBERS);

tools/eth/eth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ enum commands {
5858
CMD_USAGE,
5959
CMD_ENABLE,
6060
CMD_RESET,
61-
CMD_SET_MASK,
61+
CMD_SET_ERROR_MASK,
6262
CMD_SET_PMA_TYPE,
6363
CMD_SET_PMA_FEATURE,
6464
CMD_SET_MAX_LENGTH,

tools/eth/main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void usage(const char *progname, int verbose)
4545
printf("-S Show etherStats counters\n");
4646
printf("-l length Minimal allowed frame length\n");
4747
printf("-L length Maximal allowed frame length\n");
48-
/* printf("-m mask Set error mask 0-31\n"); */
48+
printf("-m mask Set RXMAC error bitmask value (integer; use -v to view current configuration)\n");
4949
printf("-c type Set PMA type/mode by name or enable/disable feature (+feat/-feat)\n");
5050
printf("-p repeater_cfg Set transmit data source%s\n", verbose ? "" : " (-hv for more info)");
5151
if (verbose) {
@@ -212,10 +212,9 @@ int main(int argc, char *argv[])
212212
p.param < 0 || p.param > 31) {
213213
errx(EXIT_FAILURE, "Wrong error mask.");
214214
}
215-
p.command = CMD_SET_MASK;
215+
p.command = CMD_SET_ERROR_MASK;
216216
cmds++;
217217
break;
218-
219218
case 'M':
220219
switch (tolower(optarg[0])) {
221220
case 's': p.command = CMD_SHOW_MACS; break;

tools/eth/rxmac.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ void rxmac_print_status(struct nc_rxmac *rxmac, struct eth_params *p)
5555
return;
5656

5757
printf("------------------------------ RXMAC Configuration ----\n");
58-
printf("Frame error from MII [1] : %s", (s.error_mask & 0x00000001) ? "enabled\n" : "disabled\n");
59-
printf("CRC check [2] : %s", (s.error_mask & 0x00000002) ? "enabled\n" : "disabled\n");
60-
printf("Minimum frame length [4] : %s\n"
61-
"* length : %d B\n",
58+
printf("Error mask register : 0x%02x\n", s.error_mask);
59+
printf(" * Frame error from MII [0]: %s\n", (s.error_mask & 0x00000001) ? "enabled" : "disabled");
60+
printf(" * CRC check [1]: %s\n", (s.error_mask & 0x00000002) ? "enabled" : "disabled");
61+
printf(" * Minimum frame length [2]: %s\n"
62+
" * length : %d B\n",
6263
(s.error_mask & 0x00000004) ? "enabled" : "disabled",
6364
s.frame_length_min);
64-
printf("MTU frame length [8] : %s\n"
65-
"* length : %d B",
65+
printf(" * MTU frame length [3]: %s\n"
66+
" * length : %d B",
6667
(s.error_mask & 0x00000008) ? "enabled" : "disabled",
6768
s.frame_length_max);
6869

@@ -78,8 +79,8 @@ void rxmac_print_status(struct nc_rxmac *rxmac, struct eth_params *p)
7879
case RXMAC_MAC_FILTER_TABLE_BCAST: text = "Filter by MAC address table, allow broadcast"; break;
7980
case RXMAC_MAC_FILTER_TABLE_BCAST_MCAST:text = "Filter by MAC address table, allow broadcast + multicast"; break;
8081
}
81-
printf("MAC address check [16] : %s\n"
82-
"* mode : %s\n",
82+
printf(" * MAC address check [4]: %s\n"
83+
" * mode : %s\n",
8384
(s.error_mask & 0x00000010) ? "enabled" : "disabled", text);
8485
printf("MAC address table size : %d\n", s.mac_addr_count);
8586
}
@@ -96,24 +97,23 @@ void rxmac_print_ether_stats(struct nc_rxmac *rxmac)
9697
}
9798

9899
printf("---------------------------- RXMAC etherStatsTable ----\n");
99-
// printf("etherStatsDropEvents : %llu\n")
100100
printf("etherStatsOctets : %llu\n", s.octets);
101101
printf("etherStatsPkts : %llu\n", s.pkts);
102102
printf("etherStatsBroadcastPkts : %llu\n", s.broadcastPkts);
103103
printf("etherStatsMulticastPkts : %llu\n", s.multicastPkts);
104104
printf("etherStatsCRCAlignErrors : %llu\n", s.CRCAlignErrors);
105105
printf("etherStatsUndersizePkts : %llu\n", s.undersizePkts);
106106
printf("etherStatsOversizePkts : %llu\n", s.oversizePkts);
107-
// printf("etherStatsOversizePkts : %llu\n");
108107
printf("etherStatsFragments : %llu\n", s.fragments);
109108
printf("etherStatsJabbers : %llu\n", s.jabbers);
110-
// printf("etherStatsCollisions : %llu\n");
111109
printf("etherStatsPkts64Octets : %llu\n", s.pkts64Octets);
112110
printf("etherStatsPkts65to127Octets : %llu\n", s.pkts65to127Octets);
113111
printf("etherStatsPkts128to255Octets : %llu\n", s.pkts128to255Octets);
114112
printf("etherStatsPkts256to511Octets : %llu\n", s.pkts256to511Octets);
115113
printf("etherStatsPkts512to1023Octets : %llu\n", s.pkts512to1023Octets);
116114
printf("etherStatsPkts1024to1518Octets: %llu\n", s.pkts1024to1518Octets);
115+
printf("underMinPkts : %llu\n", s.underMinPkts);
116+
printf("overMaxPkts : %llu\n", s.overMaxPkts);
117117
}
118118

119119
int clear_mac_addresses(struct nc_rxmac *rxmac)
@@ -238,6 +238,9 @@ int rxmac_execute_operation(struct nc_rxmac *rxmac, struct eth_params *p)
238238
nc_rxmac_set_frame_length(rxmac, p->param,
239239
p->command == CMD_SET_MAX_LENGTH ? RXMAC_FRAME_LENGTH_MAX : RXMAC_FRAME_LENGTH_MIN);
240240
break;
241+
case CMD_SET_ERROR_MASK:
242+
nc_rxmac_set_error_mask(rxmac, p->param);
243+
break;
241244
case CMD_SHOW_MACS:
242245
ret = show_mac_addresses(rxmac);
243246
break;

0 commit comments

Comments
 (0)