1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) Meta Platforms, Inc. and affiliates. */ 3 4 #ifndef _FBNIC_HW_STATS_H_ 5 #define _FBNIC_HW_STATS_H_ 6 7 #include <linux/ethtool.h> 8 9 #include "fbnic_csr.h" 10 11 struct fbnic_stat_counter { 12 u64 value; 13 union { 14 u32 old_reg_value_32; 15 u64 old_reg_value_64; 16 } u; 17 bool reported; 18 }; 19 20 struct fbnic_hw_stat { 21 struct fbnic_stat_counter frames; 22 struct fbnic_stat_counter bytes; 23 }; 24 25 /* Note: not updated by fbnic_get_hw_stats() */ 26 struct fbnic_eth_ctrl_stats { 27 struct fbnic_stat_counter MACControlFramesTransmitted; 28 struct fbnic_stat_counter MACControlFramesReceived; 29 }; 30 31 /* Note: not updated by fbnic_get_hw_stats() */ 32 struct fbnic_rmon_stats { 33 struct fbnic_stat_counter undersize_pkts; 34 struct fbnic_stat_counter oversize_pkts; 35 struct fbnic_stat_counter fragments; 36 struct fbnic_stat_counter jabbers; 37 38 struct fbnic_stat_counter hist[ETHTOOL_RMON_HIST_MAX]; 39 struct fbnic_stat_counter hist_tx[ETHTOOL_RMON_HIST_MAX]; 40 }; 41 42 struct fbnic_eth_mac_stats { 43 struct fbnic_stat_counter FramesTransmittedOK; 44 struct fbnic_stat_counter FramesReceivedOK; 45 struct fbnic_stat_counter FrameCheckSequenceErrors; 46 struct fbnic_stat_counter AlignmentErrors; 47 struct fbnic_stat_counter OctetsTransmittedOK; 48 struct fbnic_stat_counter FramesLostDueToIntMACXmitError; 49 struct fbnic_stat_counter OctetsReceivedOK; 50 struct fbnic_stat_counter FramesLostDueToIntMACRcvError; 51 struct fbnic_stat_counter MulticastFramesXmittedOK; 52 struct fbnic_stat_counter BroadcastFramesXmittedOK; 53 struct fbnic_stat_counter MulticastFramesReceivedOK; 54 struct fbnic_stat_counter BroadcastFramesReceivedOK; 55 struct fbnic_stat_counter FrameTooLongErrors; 56 }; 57 58 struct fbnic_mac_stats { 59 struct fbnic_eth_mac_stats eth_mac; 60 struct fbnic_eth_ctrl_stats eth_ctrl; 61 struct fbnic_rmon_stats rmon; 62 }; 63 64 struct fbnic_tmi_stats { 65 struct fbnic_hw_stat drop; 66 struct fbnic_stat_counter ptp_illegal_req, ptp_good_ts, ptp_bad_ts; 67 }; 68 69 struct fbnic_tti_stats { 70 struct fbnic_hw_stat cm_drop, frame_drop, tbi_drop; 71 }; 72 73 struct fbnic_rpc_stats { 74 struct fbnic_stat_counter unkn_etype, unkn_ext_hdr; 75 struct fbnic_stat_counter ipv4_frag, ipv6_frag, ipv4_esp, ipv6_esp; 76 struct fbnic_stat_counter tcp_opt_err, out_of_hdr_err, ovr_size_err; 77 }; 78 79 struct fbnic_rxb_enqueue_stats { 80 struct fbnic_hw_stat drbo; 81 struct fbnic_stat_counter integrity_err, mac_err; 82 struct fbnic_stat_counter parser_err, frm_err; 83 }; 84 85 struct fbnic_rxb_fifo_stats { 86 struct fbnic_hw_stat drop, trunc; 87 struct fbnic_stat_counter trans_drop, trans_ecn; 88 struct fbnic_stat_counter level; 89 }; 90 91 struct fbnic_rxb_dequeue_stats { 92 struct fbnic_hw_stat intf, pbuf; 93 }; 94 95 struct fbnic_rxb_stats { 96 struct fbnic_rxb_enqueue_stats enq[FBNIC_RXB_ENQUEUE_INDICES]; 97 struct fbnic_rxb_fifo_stats fifo[FBNIC_RXB_FIFO_INDICES]; 98 struct fbnic_rxb_dequeue_stats deq[FBNIC_RXB_DEQUEUE_INDICES]; 99 }; 100 101 struct fbnic_hw_q_stats { 102 struct fbnic_stat_counter rde_pkt_err; 103 struct fbnic_stat_counter rde_pkt_cq_drop; 104 struct fbnic_stat_counter rde_pkt_bdq_drop; 105 }; 106 107 struct fbnic_pcie_stats { 108 struct fbnic_stat_counter ob_rd_tlp, ob_rd_dword; 109 struct fbnic_stat_counter ob_wr_tlp, ob_wr_dword; 110 struct fbnic_stat_counter ob_cpl_tlp, ob_cpl_dword; 111 112 struct fbnic_stat_counter ob_rd_no_tag; 113 struct fbnic_stat_counter ob_rd_no_cpl_cred; 114 struct fbnic_stat_counter ob_rd_no_np_cred; 115 }; 116 117 struct fbnic_hw_stats { 118 struct fbnic_mac_stats mac; 119 struct fbnic_tmi_stats tmi; 120 struct fbnic_tti_stats tti; 121 struct fbnic_rpc_stats rpc; 122 struct fbnic_rxb_stats rxb; 123 struct fbnic_hw_q_stats hw_q[FBNIC_MAX_QUEUES]; 124 struct fbnic_pcie_stats pcie; 125 }; 126 127 u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset); 128 129 void fbnic_reset_hw_stats(struct fbnic_dev *fbd); 130 void fbnic_get_hw_q_stats(struct fbnic_dev *fbd, 131 struct fbnic_hw_q_stats *hw_q); 132 void fbnic_get_hw_stats32(struct fbnic_dev *fbd); 133 void fbnic_get_hw_stats(struct fbnic_dev *fbd); 134 135 #endif /* _FBNIC_HW_STATS_H_ */ 136