summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2024-03-04 05:06:56 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-03-04 05:06:56 +0000
commita0b290774b36d49c704d7c3b04c34bb90f8cb90e (patch)
tree73d33ab2e27b8acd43571d7f9b362df1c1e9f962
parentfbc36f398db015cdee87052706b0438a5e2a7db8 (diff)
parent851efcf150752130c18426923eec2bc9389b868a (diff)
downloadapf-a0b290774b36d49c704d7c3b04c34bb90f8cb90e.tar.gz
v5: document how to calculate filter_age_16384ths am: 851efcf150
Original change: https://android-review.googlesource.com/c/platform/hardware/google/apf/+/2986090 Change-Id: Ic3787c6b7d801e364db6ecc32350387f03d8f131 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--v5/apf_interpreter.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/v5/apf_interpreter.h b/v5/apf_interpreter.h
index 376991d..fe3e7af 100644
--- a/v5/apf_interpreter.h
+++ b/v5/apf_interpreter.h
@@ -129,6 +129,30 @@ int apf_transmit_buffer(void* ctx, uint8_t* ptr, uint32_t len, uint8_t dscp);
*
* @return non-zero if packet should be passed,
* zero if packet should be dropped.
+ *
+ * NOTE: How to calculate filter_age_16384ths:
+ *
+ * - if you have a u64 clock source counting nanoseconds:
+ * u64 nanoseconds = current_nanosecond_time_u64() - filter_installation_nanosecond_time_u64;
+ * u32 filter_age_16384ths = (u32)((nanoseconds << 5) / 1953125);
+ *
+ * - if you have a u64 clock source counting microseconds:
+ * u64 microseconds = current_microsecond_time_u64() - filter_installation_microsecond_time_u64;
+ * u32 filter_age_16384ths = (u32)((microseconds << 8) / 15625);
+ *
+ * - if you have a u64 clock source counting milliseconds:
+ * u64 milliseconds = current_millisecond_time_u64() - filter_installation_millisecond_time_u64;
+ * u32 filter_age_16384ths = (u32)((milliseconds << 11) / 125);
+ *
+ * - if you have a u32 clock source counting milliseconds and cannot use 64-bit arithmetic:
+ * u32 milliseconds = current_millisecond_time_u32() - filter_installation_millisecond_time_u32;
+ * u32 filter_age_16384ths = ((((((milliseconds << 4) / 5) << 2) / 5) << 2) / 5) << 3;
+ * or the less precise:
+ * u32 filter_age_16384ths = ((milliseconds << 4) / 125) << 7;
+ *
+ * - if you have a u32 clock source counting seconds:
+ * u32 seconds = current_second_time_u32() - filter_installation_second_time_u32;
+ * u32 filter_age_16384ths = seconds << 14;
*/
int apf_run(void* ctx, uint32_t* const program, const uint32_t program_len,
const uint32_t ram_len, const uint8_t* const packet,