From e6d99b8df0ac04883c73d01a381b703cbe6d3c0c Mon Sep 17 00:00:00 2001 From: Martin Spinler Date: Tue, 3 Dec 2024 09:35:41 +0100 Subject: [PATCH] feat(tool - eth): allow user to set RxMAC error mask with parameter -m --- tools/eth/eth.h | 2 +- tools/eth/main.c | 5 ++--- tools/eth/rxmac.c | 20 ++++++++++++-------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tools/eth/eth.h b/tools/eth/eth.h index b2872403..2e1d3678 100644 --- a/tools/eth/eth.h +++ b/tools/eth/eth.h @@ -58,7 +58,7 @@ enum commands { CMD_USAGE, CMD_ENABLE, CMD_RESET, - CMD_SET_MASK, + CMD_SET_ERROR_MASK, CMD_SET_PMA_TYPE, CMD_SET_PMA_FEATURE, CMD_SET_MAX_LENGTH, diff --git a/tools/eth/main.c b/tools/eth/main.c index 6218e037..293786b9 100644 --- a/tools/eth/main.c +++ b/tools/eth/main.c @@ -45,7 +45,7 @@ void usage(const char *progname, int verbose) printf("-S Show etherStats counters\n"); printf("-l length Minimal allowed frame length\n"); printf("-L length Maximal allowed frame length\n"); -/* printf("-m mask Set error mask 0-31\n"); */ + printf("-m mask Set RXMAC error bitmask value (integer; use -v to view current configuration)\n"); printf("-c type Set PMA type/mode by name or enable/disable feature (+feat/-feat)\n"); printf("-p repeater_cfg Set transmit data source%s\n", verbose ? "" : " (-hv for more info)"); if (verbose) { @@ -212,10 +212,9 @@ int main(int argc, char *argv[]) p.param < 0 || p.param > 31) { errx(EXIT_FAILURE, "Wrong error mask."); } - p.command = CMD_SET_MASK; + p.command = CMD_SET_ERROR_MASK; cmds++; break; - case 'M': switch (tolower(optarg[0])) { case 's': p.command = CMD_SHOW_MACS; break; diff --git a/tools/eth/rxmac.c b/tools/eth/rxmac.c index 4a0b29f4..5c724bc1 100644 --- a/tools/eth/rxmac.c +++ b/tools/eth/rxmac.c @@ -55,14 +55,15 @@ void rxmac_print_status(struct nc_rxmac *rxmac, struct eth_params *p) return; printf("------------------------------ RXMAC Configuration ----\n"); - printf("Frame error from MII [1] : %s", (s.error_mask & 0x00000001) ? "enabled\n" : "disabled\n"); - printf("CRC check [2] : %s", (s.error_mask & 0x00000002) ? "enabled\n" : "disabled\n"); - printf("Minimum frame length [4] : %s\n" - "* length : %d B\n", + printf("Error mask register : 0x%02x\n", s.error_mask); + printf(" * Frame error from MII [0]: %s\n", (s.error_mask & 0x00000001) ? "enabled" : "disabled"); + printf(" * CRC check [1]: %s\n", (s.error_mask & 0x00000002) ? "enabled" : "disabled"); + printf(" * Minimum frame length [2]: %s\n" + " * length : %d B\n", (s.error_mask & 0x00000004) ? "enabled" : "disabled", s.frame_length_min); - printf("MTU frame length [8] : %s\n" - "* length : %d B", + printf(" * MTU frame length [3]: %s\n" + " * length : %d B", (s.error_mask & 0x00000008) ? "enabled" : "disabled", s.frame_length_max); @@ -78,8 +79,8 @@ void rxmac_print_status(struct nc_rxmac *rxmac, struct eth_params *p) case RXMAC_MAC_FILTER_TABLE_BCAST: text = "Filter by MAC address table, allow broadcast"; break; case RXMAC_MAC_FILTER_TABLE_BCAST_MCAST:text = "Filter by MAC address table, allow broadcast + multicast"; break; } - printf("MAC address check [16] : %s\n" - "* mode : %s\n", + printf(" * MAC address check [4]: %s\n" + " * mode : %s\n", (s.error_mask & 0x00000010) ? "enabled" : "disabled", text); printf("MAC address table size : %d\n", s.mac_addr_count); } @@ -237,6 +238,9 @@ int rxmac_execute_operation(struct nc_rxmac *rxmac, struct eth_params *p) nc_rxmac_set_frame_length(rxmac, p->param, p->command == CMD_SET_MAX_LENGTH ? RXMAC_FRAME_LENGTH_MAX : RXMAC_FRAME_LENGTH_MIN); break; + case CMD_SET_ERROR_MASK: + nc_rxmac_set_error_mask(rxmac, p->param); + break; case CMD_SHOW_MACS: ret = show_mac_addresses(rxmac); break;