Commit 7ea3380a authored by Alessandro Rubini's avatar Alessandro Rubini

diag: use new 'fsm' diagnostics

This converts fsm.c to use the new diagnostics. We keep printing
the timestamp for fsm messages, which means diag.c::__pp_diag is
somehow duplicated here (in what was called pp_timed_printf).

This is the output with "-d 1" (or "-d "100") on a forced-slave ("-g"):

  diag level: 10000000
  diag-fsm-1-eth0: 1362666577.043: ENTER initializing, packet len 0
  diag-fsm-1-eth0: 1362666577.045: LEAVE initializing (next:   4 in 0 ms)
  diag-fsm-1-eth0: 1362666577.045: ENTER listening, packet len 0
  diag-fsm-1-eth0: 1362666577.045: listening: reenter in 11999 ms
  diag-fsm-1-eth0: 1362666587.204: listening: reenter in 1840 ms
  diag-fsm-1-eth0: 1362666588.388: LEAVE listening (next:   9 in 0 ms)
  diag-fsm-1-eth0: 1362666588.388: ENTER slave, packet len 44
  diag-fsm-1-eth0: 1362666588.389: slave: reenter in 889 ms
  diag-fsm-1-eth0: 1362666589.219: slave: reenter in 59 ms
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 5e962ecb
...@@ -5,19 +5,27 @@ ...@@ -5,19 +5,27 @@
unsigned long pp_global_flags; /* This is the only "global" file in ppsi */ unsigned long pp_global_flags; /* This is the only "global" file in ppsi */
static void pp_timed_printf(struct pp_instance *ppi, char *fmt, ...) /*
* This is somehow a duplicate of __pp_diag, but I still want
* explicit timing in the fsm enter/stay/leave messages,
* while there's no need to add times to all diagnostic messages
*/
static void pp_fsm_printf(struct pp_instance *ppi, char *fmt, ...)
{ {
va_list args; va_list args;
TimeInternal t; TimeInternal t;
unsigned long oflags = pp_global_flags; unsigned long oflags = pp_global_flags;
if (!__PP_DIAG_ALLOW(ppi, pp_dt_fsm, 1))
return;
/* temporarily set NOTIMELOG, as we'll print the time ourselves */ /* temporarily set NOTIMELOG, as we'll print the time ourselves */
pp_global_flags |= PP_FLAG_NOTIMELOG; pp_global_flags |= PP_FLAG_NOTIMELOG;
ppi->t_ops->get(&t); ppi->t_ops->get(&t);
pp_global_flags = oflags; pp_global_flags = oflags;
pp_printf("%09d.%03d ", (int)t.seconds, pp_printf("diag-fsm-1-%s: %09d.%03d: ", OPTS(ppi)->iface_name,
(int)t.nanoseconds / 1000000); (int)t.seconds, (int)t.nanoseconds / 1000000);
va_start(args, fmt); va_start(args, fmt);
pp_vprintf(fmt, args); pp_vprintf(fmt, args);
va_end(args); va_end(args);
...@@ -37,17 +45,17 @@ static void pp_diag_fsm(struct pp_instance *ppi, char *name, int sequence, ...@@ -37,17 +45,17 @@ static void pp_diag_fsm(struct pp_instance *ppi, char *name, int sequence,
{ {
if (sequence == STATE_ENTER) { if (sequence == STATE_ENTER) {
/* enter with or without a packet len */ /* enter with or without a packet len */
pp_timed_printf(ppi, "fsm: ENTER %s, packet len %i\n", pp_fsm_printf(ppi, "ENTER %s, packet len %i\n",
name, plen); name, plen);
return; return;
} }
if (sequence == STATE_LOOP) { if (sequence == STATE_LOOP) {
pp_timed_printf(ppi, "fsm: %s: reenter in %i ms\n", name, pp_fsm_printf(ppi, "%s: reenter in %i ms\n", name,
ppi->next_delay); ppi->next_delay);
return; return;
} }
/* leave has one \n more, so different states are separate */ /* leave has one \n more, so different states are separate */
pp_timed_printf(ppi, "fsm: LEAVE %s (next: %3i in %i ms)\n\n", pp_fsm_printf(ppi, "LEAVE %s (next: %3i in %i ms)\n\n",
name, ppi->next_state, ppi->next_delay); name, ppi->next_state, ppi->next_delay);
} }
......
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