brintos

brintos / linux-shallow public Read only

0
0
Text · 2.3 KiB · f18d71c Raw
67 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/****************************************************************************3 * Driver for Solarflare network controllers and boards4 * Copyright 2022 Advanced Micro Devices, Inc.5 *6 * This program is free software; you can redistribute it and/or modify it7 * under the terms of the GNU General Public License version 2 as published8 * by the Free Software Foundation, incorporated herein by reference.9 */10 11#ifndef EFX_TC_COUNTERS_H12#define EFX_TC_COUNTERS_H13#include <linux/refcount.h>14#include "net_driver.h"15 16#include "mcdi_pcol.h" /* for MAE_COUNTER_TYPE_* */17 18enum 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_MAX23};24 25struct 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 */31	u64 packets, bytes;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;35	struct work_struct work; /* For notifying encap actions */36	/* owners of corresponding count actions */37	struct list_head users;38};39 40struct efx_tc_counter_index {41	unsigned long cookie;42	struct rhash_head linkage; /* efx->tc->counter_id_ht */43	refcount_t ref;44	struct efx_tc_counter *cnt;45};46 47/* create/uncreate/teardown hashtables */48int efx_tc_init_counters(struct efx_nic *efx);49void efx_tc_destroy_counters(struct efx_nic *efx);50void efx_tc_fini_counters(struct efx_nic *efx);51 52struct efx_tc_counter *efx_tc_flower_allocate_counter(struct efx_nic *efx,53						      int type);54void efx_tc_flower_release_counter(struct efx_nic *efx,55				   struct efx_tc_counter *cnt);56struct efx_tc_counter_index *efx_tc_flower_get_counter_index(57				struct efx_nic *efx, unsigned long cookie,58				enum efx_tc_counter_type type);59void efx_tc_flower_put_counter_index(struct efx_nic *efx,60				     struct efx_tc_counter_index *ctr);61struct efx_tc_counter_index *efx_tc_flower_find_counter_index(62				struct efx_nic *efx, unsigned long cookie);63 64extern const struct efx_channel_type efx_tc_channel_type;65 66#endif /* EFX_TC_COUNTERS_H */67