examples/pipeline: improve learner table timers
Added the rearm counter to the statistics. Updated the learner table example to the new learner table timer operation. Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
This commit is contained in:
parent
e2ecc53582
commit
80dd28aff8
@ -2677,12 +2677,14 @@ cmd_pipeline_stats(char **tokens,
|
||||
"\t\tMiss (packets): %" PRIu64 "\n"
|
||||
"\t\tLearn OK (packets): %" PRIu64 "\n"
|
||||
"\t\tLearn error (packets): %" PRIu64 "\n"
|
||||
"\t\tRearm (packets): %" PRIu64 "\n"
|
||||
"\t\tForget (packets): %" PRIu64 "\n",
|
||||
learner_info.name,
|
||||
stats.n_pkts_hit,
|
||||
stats.n_pkts_miss,
|
||||
stats.n_pkts_learn_ok,
|
||||
stats.n_pkts_learn_err,
|
||||
stats.n_pkts_rearm,
|
||||
stats.n_pkts_forget);
|
||||
out_size -= strlen(out);
|
||||
out += strlen(out);
|
||||
|
@ -48,6 +48,9 @@ struct metadata_t {
|
||||
bit<32> port_in
|
||||
bit<32> port_out
|
||||
|
||||
// Key timeout.
|
||||
bit<32> timeout_id
|
||||
|
||||
// Arguments for the "fwd_action" action.
|
||||
bit<32> fwd_action_arg_port_out
|
||||
}
|
||||
@ -68,10 +71,14 @@ struct fwd_action_args_t {
|
||||
|
||||
action fwd_action args instanceof fwd_action_args_t {
|
||||
mov m.port_out t.port_out
|
||||
rearm
|
||||
return
|
||||
}
|
||||
|
||||
action learn_action args none {
|
||||
// Pick the key timeout. Timeout ID #1 (i.e. 120 seconds) is selected.
|
||||
mov m.timeout_id 1
|
||||
|
||||
// Read current counter value into m.fwd_action_arg_port_out.
|
||||
regrd m.fwd_action_arg_port_out counter 0
|
||||
|
||||
@ -84,7 +91,7 @@ action learn_action args none {
|
||||
// Add the current lookup key to the table with fwd_action as the key action. The action
|
||||
// arguments are read from the packet meta-data (the m.fwd_action_arg_port_out field). These
|
||||
// packet meta-data fields have to be written before the "learn" instruction is invoked.
|
||||
learn fwd_action m.fwd_action_arg_port_out
|
||||
learn fwd_action m.fwd_action_arg_port_out m.timeout_id
|
||||
|
||||
// Send the current packet to the same output port.
|
||||
mov m.port_out m.fwd_action_arg_port_out
|
||||
@ -110,7 +117,11 @@ learner fwd_table {
|
||||
|
||||
size 1048576
|
||||
|
||||
timeout 120
|
||||
timeout {
|
||||
60
|
||||
120
|
||||
180
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user