tc_counters.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /****************************************************************************
  3. * Driver for Solarflare network controllers and boards
  4. * Copyright 2022 Advanced Micro Devices, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation, incorporated herein by reference.
  9. */
  10. #ifndef EFX_TC_COUNTERS_H
  11. #define EFX_TC_COUNTERS_H
  12. #include <linux/refcount.h>
  13. #include "net_driver.h"
  14. #include "mcdi_pcol.h" /* for MAE_COUNTER_TYPE_* */
  15. enum efx_tc_counter_type {
  16. EFX_TC_COUNTER_TYPE_AR = MAE_COUNTER_TYPE_AR,
  17. EFX_TC_COUNTER_TYPE_CT = MAE_COUNTER_TYPE_CT,
  18. EFX_TC_COUNTER_TYPE_OR = MAE_COUNTER_TYPE_OR,
  19. EFX_TC_COUNTER_TYPE_MAX
  20. };
  21. struct efx_tc_counter {
  22. u32 fw_id; /* index in firmware counter table */
  23. enum efx_tc_counter_type type;
  24. struct rhash_head linkage; /* efx->tc->counter_ht */
  25. spinlock_t lock; /* Serialises updates to counter values */
  26. u32 gen; /* Generation count at which this counter is current */
  27. u64 packets, bytes;
  28. u64 old_packets, old_bytes; /* Values last time passed to userspace */
  29. /* jiffies of the last time we saw packets increase */
  30. unsigned long touched;
  31. struct work_struct work; /* For notifying encap actions */
  32. /* owners of corresponding count actions */
  33. struct list_head users;
  34. };
  35. struct efx_tc_counter_index {
  36. unsigned long cookie;
  37. struct rhash_head linkage; /* efx->tc->counter_id_ht */
  38. refcount_t ref;
  39. struct efx_tc_counter *cnt;
  40. };
  41. /* create/uncreate/teardown hashtables */
  42. int efx_tc_init_counters(struct efx_nic *efx);
  43. void efx_tc_destroy_counters(struct efx_nic *efx);
  44. void efx_tc_fini_counters(struct efx_nic *efx);
  45. struct efx_tc_counter *efx_tc_flower_allocate_counter(struct efx_nic *efx,
  46. int type);
  47. void efx_tc_flower_release_counter(struct efx_nic *efx,
  48. struct efx_tc_counter *cnt);
  49. struct efx_tc_counter_index *efx_tc_flower_get_counter_index(
  50. struct efx_nic *efx, unsigned long cookie,
  51. enum efx_tc_counter_type type);
  52. void efx_tc_flower_put_counter_index(struct efx_nic *efx,
  53. struct efx_tc_counter_index *ctr);
  54. struct efx_tc_counter_index *efx_tc_flower_find_counter_index(
  55. struct efx_nic *efx, unsigned long cookie);
  56. extern const struct efx_channel_type efx_tc_channel_type;
  57. #endif /* EFX_TC_COUNTERS_H */