linux-loongson/drivers/net/ethernet/meta/fbnic/fbnic_hw_stats.h
Mohsin Bashir 6913e873e7 eth: fbnic: Expand coverage of mac stats
Expand coverage of MAC stats via ethtool by adding rmon and eth-ctrl
stats.

ethtool -S eth0 --groups eth-ctrl
Standard stats for eth0:
eth-ctrl-MACControlFramesTransmitted: 0
eth-ctrl-MACControlFramesReceived: 0

ethtool -S eth0 --groups rmon
Standard stats for eth0:
rmon-etherStatsUndersizePkts: 0
rmon-etherStatsOversizePkts: 0
rmon-etherStatsFragments: 0
rmon-etherStatsJabbers: 0
rx-rmon-etherStatsPkts64Octets: 32807689
rx-rmon-etherStatsPkts65to127Octets: 567512968
rx-rmon-etherStatsPkts128to255Octets: 64730266
rx-rmon-etherStatsPkts256to511Octets: 20136039
rx-rmon-etherStatsPkts512to1023Octets: 28476870
rx-rmon-etherStatsPkts1024to1518Octets: 6958335
rx-rmon-etherStatsPkts1519to2047Octets: 164
rx-rmon-etherStatsPkts2048to4095Octets: 3844
rx-rmon-etherStatsPkts4096to8191Octets: 21814
rx-rmon-etherStatsPkts8192to9216Octets: 6540818
rx-rmon-etherStatsPkts9217to9742Octets: 4180897
tx-rmon-etherStatsPkts64Octets: 8786
tx-rmon-etherStatsPkts65to127Octets: 31475804
tx-rmon-etherStatsPkts128to255Octets: 3581331
tx-rmon-etherStatsPkts256to511Octets: 2483038
tx-rmon-etherStatsPkts512to1023Octets: 4500916
tx-rmon-etherStatsPkts1024to1518Octets: 38741270
tx-rmon-etherStatsPkts1519to2047Octets: 15521
tx-rmon-etherStatsPkts2048to4095Octets: 4109
tx-rmon-etherStatsPkts4096to8191Octets: 20817
tx-rmon-etherStatsPkts8192to9216Octets: 6904055
tx-rmon-etherStatsPkts9217to9742Octets: 6757746

Signed-off-by: Mohsin Bashir <mohsin.bashr@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20250610171109.1481229-3-mohsin.bashr@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-06-11 16:41:53 -07:00

136 lines
3.8 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/* Copyright (c) Meta Platforms, Inc. and affiliates. */
#ifndef _FBNIC_HW_STATS_H_
#define _FBNIC_HW_STATS_H_
#include <linux/ethtool.h>
#include "fbnic_csr.h"
struct fbnic_stat_counter {
u64 value;
union {
u32 old_reg_value_32;
u64 old_reg_value_64;
} u;
bool reported;
};
struct fbnic_hw_stat {
struct fbnic_stat_counter frames;
struct fbnic_stat_counter bytes;
};
/* Note: not updated by fbnic_get_hw_stats() */
struct fbnic_eth_ctrl_stats {
struct fbnic_stat_counter MACControlFramesTransmitted;
struct fbnic_stat_counter MACControlFramesReceived;
};
/* Note: not updated by fbnic_get_hw_stats() */
struct fbnic_rmon_stats {
struct fbnic_stat_counter undersize_pkts;
struct fbnic_stat_counter oversize_pkts;
struct fbnic_stat_counter fragments;
struct fbnic_stat_counter jabbers;
struct fbnic_stat_counter hist[ETHTOOL_RMON_HIST_MAX];
struct fbnic_stat_counter hist_tx[ETHTOOL_RMON_HIST_MAX];
};
struct fbnic_eth_mac_stats {
struct fbnic_stat_counter FramesTransmittedOK;
struct fbnic_stat_counter FramesReceivedOK;
struct fbnic_stat_counter FrameCheckSequenceErrors;
struct fbnic_stat_counter AlignmentErrors;
struct fbnic_stat_counter OctetsTransmittedOK;
struct fbnic_stat_counter FramesLostDueToIntMACXmitError;
struct fbnic_stat_counter OctetsReceivedOK;
struct fbnic_stat_counter FramesLostDueToIntMACRcvError;
struct fbnic_stat_counter MulticastFramesXmittedOK;
struct fbnic_stat_counter BroadcastFramesXmittedOK;
struct fbnic_stat_counter MulticastFramesReceivedOK;
struct fbnic_stat_counter BroadcastFramesReceivedOK;
struct fbnic_stat_counter FrameTooLongErrors;
};
struct fbnic_mac_stats {
struct fbnic_eth_mac_stats eth_mac;
struct fbnic_eth_ctrl_stats eth_ctrl;
struct fbnic_rmon_stats rmon;
};
struct fbnic_tmi_stats {
struct fbnic_hw_stat drop;
struct fbnic_stat_counter ptp_illegal_req, ptp_good_ts, ptp_bad_ts;
};
struct fbnic_tti_stats {
struct fbnic_hw_stat cm_drop, frame_drop, tbi_drop;
};
struct fbnic_rpc_stats {
struct fbnic_stat_counter unkn_etype, unkn_ext_hdr;
struct fbnic_stat_counter ipv4_frag, ipv6_frag, ipv4_esp, ipv6_esp;
struct fbnic_stat_counter tcp_opt_err, out_of_hdr_err, ovr_size_err;
};
struct fbnic_rxb_enqueue_stats {
struct fbnic_hw_stat drbo;
struct fbnic_stat_counter integrity_err, mac_err;
struct fbnic_stat_counter parser_err, frm_err;
};
struct fbnic_rxb_fifo_stats {
struct fbnic_hw_stat drop, trunc;
struct fbnic_stat_counter trans_drop, trans_ecn;
struct fbnic_stat_counter level;
};
struct fbnic_rxb_dequeue_stats {
struct fbnic_hw_stat intf, pbuf;
};
struct fbnic_rxb_stats {
struct fbnic_rxb_enqueue_stats enq[FBNIC_RXB_ENQUEUE_INDICES];
struct fbnic_rxb_fifo_stats fifo[FBNIC_RXB_FIFO_INDICES];
struct fbnic_rxb_dequeue_stats deq[FBNIC_RXB_DEQUEUE_INDICES];
};
struct fbnic_hw_q_stats {
struct fbnic_stat_counter rde_pkt_err;
struct fbnic_stat_counter rde_pkt_cq_drop;
struct fbnic_stat_counter rde_pkt_bdq_drop;
};
struct fbnic_pcie_stats {
struct fbnic_stat_counter ob_rd_tlp, ob_rd_dword;
struct fbnic_stat_counter ob_wr_tlp, ob_wr_dword;
struct fbnic_stat_counter ob_cpl_tlp, ob_cpl_dword;
struct fbnic_stat_counter ob_rd_no_tag;
struct fbnic_stat_counter ob_rd_no_cpl_cred;
struct fbnic_stat_counter ob_rd_no_np_cred;
};
struct fbnic_hw_stats {
struct fbnic_mac_stats mac;
struct fbnic_tmi_stats tmi;
struct fbnic_tti_stats tti;
struct fbnic_rpc_stats rpc;
struct fbnic_rxb_stats rxb;
struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES];
struct fbnic_pcie_stats pcie;
};
u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset);
void fbnic_reset_hw_stats(struct fbnic_dev *fbd);
void fbnic_get_hw_q_stats(struct fbnic_dev *fbd,
struct fbnic_hw_q_stats *hw_q);
void fbnic_get_hw_stats32(struct fbnic_dev *fbd);
void fbnic_get_hw_stats(struct fbnic_dev *fbd);
#endif /* _FBNIC_HW_STATS_H_ */