1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2022 Advanced Micro Devices, Inc.
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.
11 #ifndef EFX_TC_COUNTERS_H
12 #define EFX_TC_COUNTERS_H
13 #include <linux/refcount.h>
14 #include "net_driver.h"
16 #include "mcdi_pcol.h" /* for MAE_COUNTER_TYPE_* */
18 enum efx_tc_counter_type {
19 EFX_TC_COUNTER_TYPE_AR = MAE_COUNTER_TYPE_AR,
20 EFX_TC_COUNTER_TYPE_CT = MAE_COUNTER_TYPE_CT,
21 EFX_TC_COUNTER_TYPE_OR = MAE_COUNTER_TYPE_OR,
22 EFX_TC_COUNTER_TYPE_MAX
25 struct efx_tc_counter {
26 u32 fw_id; /* index in firmware counter table */
27 enum efx_tc_counter_type type;
28 struct rhash_head linkage; /* efx->tc->counter_ht */
29 spinlock_t lock; /* Serialises updates to counter values */
30 u32 gen; /* Generation count at which this counter is current */
32 u64 old_packets, old_bytes; /* Values last time passed to userspace */
33 /* jiffies of the last time we saw packets increase */
34 unsigned long touched;
37 struct efx_tc_counter_index {
39 struct rhash_head linkage; /* efx->tc->counter_id_ht */
41 struct efx_tc_counter *cnt;
44 /* create/uncreate/teardown hashtables */
45 int efx_tc_init_counters(struct efx_nic *efx);
46 void efx_tc_destroy_counters(struct efx_nic *efx);
47 void efx_tc_fini_counters(struct efx_nic *efx);
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);
57 extern const struct efx_channel_type efx_tc_channel_type;
59 #endif /* EFX_TC_COUNTERS_H */