/* spdx-license-identifier: bsd-3-clause
 * copyright 2019   silicom ltd. connectivity solutions
 */

#ifndef _fm10k_stats_h_
#define _fm10k_stats_h_

#include <stdint.h>

#define FM10K_STATS_VERSION		(1 << 4)

struct fm10k_scatter_gather_entry {
	uint32_t  addr;
	uint32_t  count;
	uint32_t *data;

};

struct fm10k_port_counters {
	uint64_t cnt_version;
	uint64_t cnt_rx_ucst_pkts;
	uint64_t cnt_rx_ucst_pkts_nonip;
	uint64_t cnt_rx_ucst_pkts_ipv4;
	uint64_t cnt_rx_ucst_pkts_ipv6;
	uint64_t cnt_rx_bcst_pkts;
	uint64_t cnt_rx_bcst_pkts_nonip;
	uint64_t cnt_rx_bcst_pkts_ipv4;
	uint64_t cnt_rx_bcst_pkts_ipv6;
	uint64_t cnt_rx_mcst_pkts;
	uint64_t cnt_rx_mcst_pkts_nonip;
	uint64_t cnt_rx_mcst_pkts_ipv4;
	uint64_t cnt_rx_mcst_pkts_ipv6;
	uint64_t cnt_rx_pause_pkts;
	uint64_t cnt_rx_cbpause_pkts;
	uint64_t cnt_rx_fcs_errors;
	uint64_t cnt_rx_symbol_errors;
	uint64_t cnt_rx_framesize_errors;
	uint64_t cnt_rx_framing_error_pkts;
	uint64_t cnt_rx_minto63_pkts;
	uint64_t cnt_rx_64_pkts;
	uint64_t cnt_rx_65to127_pkts;
	uint64_t cnt_rx_128to255_pkts;
	uint64_t cnt_rx_256to511_pkts;
	uint64_t cnt_rx_512to1023_pkts;
	uint64_t cnt_rx_1024to1522_pkts;
	uint64_t cnt_rx_1523to2047_pkts;
	uint64_t cnt_rx_2048to4095_pkts;
	uint64_t cnt_rx_4096to8191_pkts;
	uint64_t cnt_rx_8192to10239_pkts;
	uint64_t cnt_rx_10240tomax_pkts;
	uint64_t cnt_rx_minto63_octets;
	uint64_t cnt_rx_64_octets;
	uint64_t cnt_rx_65to127_octets;
	uint64_t cnt_rx_128to255_octets;
	uint64_t cnt_rx_256to511_octets;
	uint64_t cnt_rx_512to1023_octets;
	uint64_t cnt_rx_1024to1522_octets;
	uint64_t cnt_rx_1523to2047_octets;
	uint64_t cnt_rx_2048to4095_octets;
	uint64_t cnt_rx_4096to8191_octets;
	uint64_t cnt_rx_8192to10239_octets;
	uint64_t cnt_rx_10240tomax_octets;
	uint64_t cnt_rx_octets_nonip;
	uint64_t cnt_rx_octets_ipv4;
	uint64_t cnt_rx_octets_ipv6;
	uint64_t cnt_rx_ucst_octets_nonip;
	uint64_t cnt_rx_ucst_octets_ipv4;
	uint64_t cnt_rx_ucst_octets_ipv6;
	uint64_t cnt_rx_bcst_octets_nonip;
	uint64_t cnt_rx_bcst_octets_ipv4;
	uint64_t cnt_rx_bcst_octets_ipv6;
	uint64_t cnt_rx_mcst_octets_nonip;
	uint64_t cnt_rx_mcst_octets_ipv4;
	uint64_t cnt_rx_mcst_octets_ipv6;
	uint64_t cnt_rx_pause_octets;
	uint64_t cnt_rx_cbpause_octets;
	uint64_t cnt_rx_fcs_errors_octets;
	uint64_t cnt_rx_framing_error_octets;
	uint64_t cnt_rx_good_octets;
	uint64_t cnt_rx_bad_octets;
	uint64_t cnt_rx_priority_pkts[16];
	uint64_t cnt_rx_invalid_priority_pkts;
	uint64_t cnt_rx_priority_octets[16];
	uint64_t cnt_rx_invalid_priority_octets;
	uint64_t cnt_fid_forwarded_pkts;
	uint64_t cnt_flood_forwarded_pkts;
	uint64_t cnt_glort_switched_pkts;
	uint64_t cnt_glort_routed_pkts;
	uint64_t cnt_specially_handled_pkts;
	uint64_t cnt_parse_err_drop_pkts;
	uint64_t cnt_parity_error_pkts;
	uint64_t cnt_trapped_pkts;
	uint64_t cnt_pause_drop_pkts;
	uint64_t cnt_stp_drop_pkts;
	uint64_t cnt_stp_ingress_drops_pkts;
	uint64_t cnt_stp_egress_drops_pkts;
	uint64_t cnt_reserved_trap_pkts;
	uint64_t cnt_security_violation_pkts;
	uint64_t cnt_vlan_tag_drop_pkts;
	uint64_t cnt_vlan_ingressbv_pkts;
	uint64_t cnt_vlan_egressbv_pkts;
	uint64_t cnt_loopback_drops_pkts;
	uint64_t cnt_glort_miss_drop_pkts;
	uint64_t cnt_ffu_drop_pkts;
	uint64_t cnt_invalid_drop_pkts;
	uint64_t cnt_policer_drop_pkts;
	uint64_t cnt_ttl_drop_pkts;
	uint64_t cnt_global_wmdrop_pkts;
	uint64_t cnt_rx_mpdrop_pkts;
	uint64_t cnt_rx_hogdrop_pkts;
	uint64_t cnt_tx_hogdrop_pkts;
	uint64_t cnt_other_pkts;
	uint64_t cnt_flood_control_drop_pkts;
	uint64_t cnt_cmpriv_drop_pkts;
	uint64_t cnt_smp0_drop_pkts;
	uint64_t cnt_smp1_drop_pkts;
	uint64_t cnt_rx_hog0_drop_pkts;
	uint64_t cnt_rx_hog1_drop_pkts;
	uint64_t cnt_tx_hog0_drop_pkts;
	uint64_t cnt_tx_hog1_drop_pkts;
	uint64_t cnt_rate_limit0_drop_pkts;
	uint64_t cnt_rate_limit1_drop_pkts;
	uint64_t cnt_bad_smp_drop_pkts;
	uint64_t cnt_trigger_drop_redir_pkts;
	uint64_t cnt_trigger_drop_pkts;
	uint64_t cnt_trigger_redir_pkts;
	uint64_t cnt_glort_forwarded_pkts;
	uint64_t cnt_trigger_mirrored_pkts;
	uint64_t cnt_broadcast_drop_pkts;
	uint64_t cnt_dlf_drop_pkts;
	uint64_t cnt_rx_cm_drop_pkts;
	uint64_t cnt_fid_forwarded_octets;
	uint64_t cnt_flood_forwarded_octets;
	uint64_t cnt_specially_handled_octets;
	uint64_t cnt_parse_err_drop_octets;
	uint64_t cnt_parity_error_octets;
	uint64_t cnt_trapped_octets;
	uint64_t cnt_pause_drop_octets;
	uint64_t cnt_stp_drop_octets;
	uint64_t cnt_security_violation_octets;
	uint64_t cnt_vlan_tag_drop_octets;
	uint64_t cnt_vlan_ingressbv_octets;
	uint64_t cnt_vlan_egressbv_octets;
	uint64_t cnt_loopback_drop_octets;
	uint64_t cnt_glort_miss_drop_octets;
	uint64_t cnt_ffu_drop_octets;
	uint64_t cnt_policer_drop_octets;
	uint64_t cnt_ttl_drop_octets;
	uint64_t cnt_other_octets;
	uint64_t cnt_flood_control_drop_octets;
	uint64_t cnt_cmpriv_drop_octets;
	uint64_t cnt_smp0_drop_octets;
	uint64_t cnt_smp1_drop_octets;
	uint64_t cnt_rx_hog0_drop_octets;
	uint64_t cnt_rx_hog1_drop_octets;
	uint64_t cnt_tx_hog0_drop_octets;
	uint64_t cnt_tx_hog1_drop_octets;
	uint64_t cnt_trigger_drop_octets;
	uint64_t cnt_trigger_redir_octets;
	uint64_t cnt_glort_forwarded_octets;
	uint64_t cnt_tx_ucst_pkts;
	uint64_t cnt_tx_bcst_pkts;
	uint64_t cnt_tx_mcst_pkts;
	uint64_t cnt_tx_ucst_pkts_nonip;
	uint64_t cnt_tx_bcst_pkts_nonip;
	uint64_t cnt_tx_mcst_pkts_nonip;
	uint64_t cnt_tx_ucst_pkts_ip;
	uint64_t cnt_tx_bcst_pkts_ip;
	uint64_t cnt_tx_mcst_pkts_ip;
	uint64_t cnt_tx_pause_pkts;
	uint64_t cnt_tx_cbpause_pkts;
	uint64_t cnt_tx_fcs_err_drop_pkts;
	uint64_t cnt_tx_framing_error_pkts;
	uint64_t cnt_tx_error_sent_pkts;
	uint64_t cnt_tx_error_drop_pkts;
	uint64_t cnt_tx_timeout_pkts;
	uint64_t cnt_tx_outofmem_err_pkts;
	uint64_t cnt_tx_unrepair_ecc_pkts;
	uint64_t cnt_tx_loopback_pkts;
	uint64_t cnt_tx_ttl_drop_pkts;
	uint64_t cnt_tx_minto63_pkts;
	uint64_t cnt_tx_64_pkts;
	uint64_t cnt_tx_65to127_pkts;
	uint64_t cnt_tx_128to255_pkts;
	uint64_t cnt_tx_256to511_pkts;
	uint64_t cnt_tx_512to1023_pkts;
	uint64_t cnt_tx_1024to1522_pkts;
	uint64_t cnt_tx_1523to2047_pkts;
	uint64_t cnt_tx_2048to4095_pkts;
	uint64_t cnt_tx_4096to8191_pkts;
	uint64_t cnt_tx_8192to10239_pkts;
	uint64_t cnt_tx_10240tomax_pkts;
	uint64_t cnt_tx_minto63_octets;
	uint64_t cnt_tx_64_octets;
	uint64_t cnt_tx_65to127_octets;
	uint64_t cnt_tx_128to255_octets;
	uint64_t cnt_tx_256to511_octets;
	uint64_t cnt_tx_512to1023_octets;
	uint64_t cnt_tx_1024to1522_octets;
	uint64_t cnt_tx_1523to2047_octets;
	uint64_t cnt_tx_2048to4095_octets;
	uint64_t cnt_tx_4096to8191_octets;
	uint64_t cnt_tx_8192to10239_octets;
	uint64_t cnt_tx_10240tomax_octets;
	uint64_t cnt_tx_ucst_octets_nonip;
	uint64_t cnt_tx_bcst_octets_nonip;
	uint64_t cnt_tx_mcst_octets_nonip;
	uint64_t cnt_tx_ucst_octets_ip;
	uint64_t cnt_tx_bcst_octets_ip;
	uint64_t cnt_tx_mcst_octets_ip;
	uint64_t cnt_tx_ucst_octets;
	uint64_t cnt_tx_mcst_octets;
	uint64_t cnt_tx_bcst_octets;
	uint64_t cnt_tx_fcs_err_drop_octets;
	uint64_t cnt_tx_octets;
	uint64_t cnt_tx_error_octets;
	uint64_t cnt_tx_framing_error_octets;
	uint64_t cnt_tx_pause_octets;
	uint64_t cnt_tx_cbpause_octets;
	uint64_t cnt_tx_fcs_errored_octets;
	uint64_t cnt_tx_error_sent_octets;
	uint64_t cnt_tx_timeout_octets;
	uint64_t cnt_tx_outofmem_err_octets;
	uint64_t cnt_tx_unrepair_ecc_octets;
	uint64_t cnt_tx_loopback_octets;
	uint64_t cnt_tx_ttl_drop_octets;
	uint64_t cnt_tx_priority_octets[16];
	uint64_t cnt_under_run_pkts;
	uint64_t cnt_over_run_pkts;
	uint64_t cnt_rx_fragment_pkts;
	uint64_t cnt_rx_undersized_pkts;
	uint64_t cnt_rx_jabber_pkts;
	uint64_t cnt_corrupted_pkts;
	uint64_t cnt_code_errors;
	uint64_t cnt_rx_oversized_pkts;
	uint64_t cnt_tx_fcs_errored_pkts;
	uint64_t cnt_stats_drop_count_tx;
	uint64_t cnt_stats_drop_count_rx;
	uint64_t cnt_tx_mirror_pkts;
	uint64_t cnt_tx_mirror_octets;
	uint64_t cnt_tx_cmdrop_pkts;
	uint64_t timestamp;
};

void fm10k_stats_rule_count_reg(uint16_t rule_id);
void *fm10k_switch_process_stats(void *ctx_);

void fm10k_stats_epl_port_print(struct fm10k_switch *sw);
void fm10k_stats_dpdk_port_print(struct fm10k_switch *sw);
void fm10k_stats_ffu_count_print(struct fm10k_switch *sw);
void fm10k_stats_port_bank_print(struct fm10k_switch *sw);

#endif /* _fm10k_stats_h */
