Skip to content

Commit

Permalink
feat(tool - eth): allow user to set RxMAC error mask with parameter -m
Browse files Browse the repository at this point in the history
  • Loading branch information
martinspinler committed Dec 3, 2024
1 parent 6b66e6b commit e6d99b8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tools/eth/eth.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions tools/eth/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
20 changes: 12 additions & 8 deletions tools/eth/rxmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e6d99b8

Please sign in to comment.