Commit 7a197e97 authored by Adam Wujek's avatar Adam Wujek 💬

[Feature: 1195] userspace/tools: add vlans and multiple ptp instances to wr_mon

Add support of multiple ptp instances on the same port and vlans to the wr_mon.
After the change output looks like:
 wri6 : Link down  WR Master  NoLock      i5 : no-ptp
 wri7 : Link up    Non WR     NoLock      i6 : peer: 00:00:00:00:00:00 ptp state master(6)
                                          i8 : peer: 00:1b:c5:09:0c:b8 ptp state master(6) vlans: 4,7,65
 wri8 : Link down  WR Master  NoLock      i7 : no-ptp
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 16564c53
...@@ -262,6 +262,8 @@ void show_ports(void) ...@@ -262,6 +262,8 @@ void show_ports(void)
char datestr[32]; char datestr[32];
struct hal_port_state *port_state; struct hal_port_state *port_state;
struct pp_instance *pp_array; struct pp_instance *pp_array;
int vlan_i;
int nvlans;
pp_array = wrs_shm_follow(ppsi_head, ppg->pp_instances); pp_array = wrs_shm_follow(ppsi_head, ppg->pp_instances);
...@@ -285,6 +287,7 @@ void show_ports(void) ...@@ -285,6 +287,7 @@ void show_ports(void)
char if_mode[15]; char if_mode[15];
int print_port = 0; int print_port = 0;
int print_mode_color = 0; int print_mode_color = 0;
int instance_port = 0;
snprintf(if_name, 10, "wri%d", i + 1); snprintf(if_name, 10, "wri%d", i + 1);
...@@ -365,37 +368,61 @@ void show_ports(void) ...@@ -365,37 +368,61 @@ void show_ports(void)
else else
term_cprintf(C_RED, "NoLock "); term_cprintf(C_RED, "NoLock ");
instance_port = 0;
/* /*
* Actually, what is interesting is the PTP state. * Actually, what is interesting is the PTP state.
* For this lookup, the port in ppsi shmem * For this lookup, the port in ppsi shmem
*/ */
for (j = 0; j < ppg->nlinks; j++) { for (j = 0; j < ppg->nlinks; j++) {
if (!strcmp(if_name, if (strcmp(if_name,
pp_array[j].cfg.iface_name)) pp_array[j].cfg.iface_name)) {
break; /* Instance not for this interface
} * skip */
/* Warning: we may have more pp instances per port */ continue;
if (j == ppg->nlinks || !state_up(port_state->state)) { }
term_cprintf(C_RED, "no-ptp\n"); if (instance_port > 0) {
} else { term_cprintf(C_WHITE, "\n "
unsigned char *p = pp_array[j].peer; " ");
}
term_cprintf(C_WHITE, instance_port++;
"peer: %02x:%02x:%02x:%02x:%02x:%02x ", /* print instance number */
p[0], p[1], p[2], p[3], p[4], p[5]); term_cprintf(C_WHITE, " i%-2d:", j);
if (pp_array[j].state < PP_INSTANCE_STATE_MAX) { /* Warning: we may have more pp instances per
/* Known state */ * port */
term_cprintf(C_GREEN, if (!state_up(port_state->state)) {
"ptp state %s(%i)\n", term_cprintf(C_RED, " no-ptp");
pp_instance_state_to_name[pp_array[j].state],
pp_array[j].state);
} else { } else {
/* Unknown ptp state */ unsigned char *p = pp_array[j].peer;
term_cprintf(C_GREEN,
"ptp state unknown(%i)\n", term_cprintf(C_WHITE," peer: %02x:%02x"
pp_array[j].state); ":%02x:%02x:%02x:%02x",
p[0], p[1], p[2], p[3],
p[4], p[5]);
if (pp_array[j].state < PP_INSTANCE_STATE_MAX) {
/* Known state */
term_cprintf(C_GREEN, " ptp "
"state %s(%i)",
pp_instance_state_to_name[pp_array[j].state],
pp_array[j].state);
} else {
/* Unknown ptp state */
term_cprintf(C_GREEN, " ptp "
"state unknown(%i)",
pp_array[j].state);
}
}
nvlans = pp_array[j].nvlans;
if (nvlans > 0) {
term_cprintf(C_WHITE, " vlans: ");
}
for (vlan_i = 0; vlan_i < nvlans; vlan_i++) {
term_cprintf(C_WHITE, "%d",
pp_array[j].vlans[vlan_i]);
if (vlan_i < nvlans - 1)
term_cprintf(C_WHITE, ",");
} }
} }
term_cprintf(C_WHITE, "\n");
} else if (mode & WEB_INTERFACE) { } else if (mode & WEB_INTERFACE) {
printf("%s ", state_up(port_state->state) printf("%s ", state_up(port_state->state)
? "up" : "down"); ? "up" : "down");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment