Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function to set expire timer of an added entry. #44

Merged
merged 2 commits into from
Jul 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions pna.p4
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,31 @@ extern void update_expire_info(
in ExpireTimeProfileId_t expire_time_profile_id);


// Set the expire time of the matched entry in the table to the value
// specified in the parameter expire_time_profile_id, if condition
// in the first parameter evaluates to true. Otherwise, the function
// has no effect.
//
// @param condition The boolean expression to evaluate to determine
// if the expire time will be set.
// @param expire_time_profile_id
// The expire time to set for the matched entry,
// if the data and value parameters are equal.
//
// Examples:
// set_expire_time_if(hdr.tcp.flags == TCP_FLG_SYN &&
// meta.direction == OUTBOUND,
// tcp_connection_start_time_profile_id);
Copy link
Contributor

@jfingerh jfingerh Jun 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the new parameters for set_expire_time_if were a single additional parameter in bool condition, then the example above could be written as shown below:

set_expire_time_if((hdr.tcp.flags == TCP_FLG_SYN) && (meta.direction == OUTBOUND),
                   tcp_connection_start_time_profile_id);

// set_expire_time_if(hdr.tcp.flags == TCP_FLG_ACK,
// tcp_connection_continuation_time_protile_id);
// set_expire_time_if(hdr.tcp.flags == TCP_FLG_FIN,
// tcp_connection_close_time_profile_id);

extern void set_entry_expire_time_if(
in bool condition,
in ExpireTimeProfileId_t expire_time_profile_id);


// SelectByDirection is a simple pure function that behaves exactly as
// the P4_16 function definition given in comments below. It is an
// extern function to ensure that the front/mid end of the p4c
Expand Down