storm-watch.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2017, 2020 The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __STORM_WATCH_H
  7. #define __STORM_WATCH_H
  8. #include <linux/ktime.h>
  9. #include <linux/mutex.h>
  10. /**
  11. * Data used to track an event storm.
  12. *
  13. * @storm_period_ms: The maximum time interval between two events. If this limit
  14. * is exceeded then the event chain will be broken and removed
  15. * from consideration for a storm.
  16. * @max_storm_count: The number of chained events required to trigger a storm.
  17. * @storm_count: The current number of chained events.
  18. * @last_kt: Kernel time of the last event seen.
  19. * @storm_lock: Mutex lock to protect storm_watch data.
  20. */
  21. struct storm_watch {
  22. bool enabled;
  23. int storm_period_ms;
  24. int max_storm_count;
  25. int storm_count;
  26. ktime_t last_kt;
  27. struct mutex storm_lock;
  28. };
  29. bool is_storming(struct storm_watch *data);
  30. void reset_storm_count(struct storm_watch *data);
  31. void update_storm_count(struct storm_watch *data, int max_count);
  32. #endif