From eb5bf3fab07a5c7eb1e605ecdaa7b48a26e883b2 Mon Sep 17 00:00:00 2001 From: Roop Mukherjee Date: Tue, 31 May 2022 22:14:55 +0300 Subject: [PATCH 1/2] Function to set expire timer of an added entry. --- pna.p4 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pna.p4 b/pna.p4 index 98c50fe..19ec6e4 100644 --- a/pna.p4 +++ b/pna.p4 @@ -743,6 +743,35 @@ 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 the value +// parameter is equal to the data parameter. If the value and data +// parameters are not equal, the function has no effect. +// +// @param D Tuple of fields of data to match with value. +// @param data Data that is matched to the value parameter +// to determine if the expire time will be set. +// @param value Value that is matched with corresponding +// data parameter. +// @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, meta.direction}, +// {TCP_FLG_SYN, 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 D data, + in D value, + 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 From 2e71be3cd172ea7e69d3a108d6c442014c4bd4a9 Mon Sep 17 00:00:00 2001 From: Roop Mukherjee Date: Wed, 29 Jun 2022 18:50:06 +0300 Subject: [PATCH 2/2] Replace match arguments with a condition. --- pna.p4 | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/pna.p4 b/pna.p4 index 19ec6e4..2702836 100644 --- a/pna.p4 +++ b/pna.p4 @@ -744,31 +744,27 @@ extern void update_expire_info( // Set the expire time of the matched entry in the table to the value -// specified in the parameter expire_time_profile_id, if the value -// parameter is equal to the data parameter. If the value and data -// parameters are not equal, the function has no effect. +// specified in the parameter expire_time_profile_id, if condition +// in the first parameter evaluates to true. Otherwise, the function +// has no effect. // -// @param D Tuple of fields of data to match with value. -// @param data Data that is matched to the value parameter -// to determine if the expire time will be set. -// @param value Value that is matched with corresponding -// data parameter. -// @expire_time_profile_id +// @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, meta.direction}, -// {TCP_FLG_SYN, OUTBOUND}, +// 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, +// 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, +// set_expire_time_if(hdr.tcp.flags == TCP_FLG_FIN, // tcp_connection_close_time_profile_id); -extern void set_entry_expire_time_if( - in D data, - in D value, +extern void set_entry_expire_time_if( + in bool condition, in ExpireTimeProfileId_t expire_time_profile_id);