|
3 | 3 |
|
4 | 4 | #include "fbnic.h" |
5 | 5 |
|
| 6 | +static void fbnic_hw_stat_rst32(struct fbnic_dev *fbd, u32 reg, |
| 7 | + struct fbnic_stat_counter *stat) |
| 8 | +{ |
| 9 | + /* We do not touch the "value" field here. |
| 10 | + * It gets zeroed out on fbd structure allocation. |
| 11 | + * After that we want it to grow continuously |
| 12 | + * through device resets and power state changes. |
| 13 | + */ |
| 14 | + stat->u.old_reg_value_32 = rd32(fbd, reg); |
| 15 | +} |
| 16 | + |
| 17 | +static void fbnic_hw_stat_rd32(struct fbnic_dev *fbd, u32 reg, |
| 18 | + struct fbnic_stat_counter *stat) |
| 19 | +{ |
| 20 | + u32 new_reg_value; |
| 21 | + |
| 22 | + new_reg_value = rd32(fbd, reg); |
| 23 | + stat->value += new_reg_value - stat->u.old_reg_value_32; |
| 24 | + stat->u.old_reg_value_32 = new_reg_value; |
| 25 | +} |
| 26 | + |
6 | 27 | u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset) |
7 | 28 | { |
8 | 29 | u32 prev_upper, upper, lower, diff; |
@@ -49,6 +70,53 @@ static void fbnic_hw_stat_rd64(struct fbnic_dev *fbd, u32 reg, s32 offset, |
49 | 70 | stat->u.old_reg_value_64 = new_reg_value; |
50 | 71 | } |
51 | 72 |
|
| 73 | +static void fbnic_reset_rpc_stats(struct fbnic_dev *fbd, |
| 74 | + struct fbnic_rpc_stats *rpc) |
| 75 | +{ |
| 76 | + fbnic_hw_stat_rst32(fbd, |
| 77 | + FBNIC_RPC_CNTR_UNKN_ETYPE, |
| 78 | + &rpc->unkn_etype); |
| 79 | + fbnic_hw_stat_rst32(fbd, |
| 80 | + FBNIC_RPC_CNTR_UNKN_EXT_HDR, |
| 81 | + &rpc->unkn_ext_hdr); |
| 82 | + fbnic_hw_stat_rst32(fbd, FBNIC_RPC_CNTR_IPV4_FRAG, &rpc->ipv4_frag); |
| 83 | + fbnic_hw_stat_rst32(fbd, FBNIC_RPC_CNTR_IPV6_FRAG, &rpc->ipv6_frag); |
| 84 | + fbnic_hw_stat_rst32(fbd, FBNIC_RPC_CNTR_IPV4_ESP, &rpc->ipv4_esp); |
| 85 | + fbnic_hw_stat_rst32(fbd, FBNIC_RPC_CNTR_IPV6_ESP, &rpc->ipv6_esp); |
| 86 | + fbnic_hw_stat_rst32(fbd, FBNIC_RPC_CNTR_TCP_OPT_ERR, &rpc->tcp_opt_err); |
| 87 | + fbnic_hw_stat_rst32(fbd, |
| 88 | + FBNIC_RPC_CNTR_OUT_OF_HDR_ERR, |
| 89 | + &rpc->out_of_hdr_err); |
| 90 | + fbnic_hw_stat_rst32(fbd, |
| 91 | + FBNIC_RPC_CNTR_OVR_SIZE_ERR, |
| 92 | + &rpc->ovr_size_err); |
| 93 | +} |
| 94 | + |
| 95 | +static void fbnic_get_rpc_stats32(struct fbnic_dev *fbd, |
| 96 | + struct fbnic_rpc_stats *rpc) |
| 97 | +{ |
| 98 | + fbnic_hw_stat_rd32(fbd, |
| 99 | + FBNIC_RPC_CNTR_UNKN_ETYPE, |
| 100 | + &rpc->unkn_etype); |
| 101 | + fbnic_hw_stat_rd32(fbd, |
| 102 | + FBNIC_RPC_CNTR_UNKN_EXT_HDR, |
| 103 | + &rpc->unkn_ext_hdr); |
| 104 | + |
| 105 | + fbnic_hw_stat_rd32(fbd, FBNIC_RPC_CNTR_IPV4_FRAG, &rpc->ipv4_frag); |
| 106 | + fbnic_hw_stat_rd32(fbd, FBNIC_RPC_CNTR_IPV6_FRAG, &rpc->ipv6_frag); |
| 107 | + |
| 108 | + fbnic_hw_stat_rd32(fbd, FBNIC_RPC_CNTR_IPV4_ESP, &rpc->ipv4_esp); |
| 109 | + fbnic_hw_stat_rd32(fbd, FBNIC_RPC_CNTR_IPV6_ESP, &rpc->ipv6_esp); |
| 110 | + |
| 111 | + fbnic_hw_stat_rd32(fbd, FBNIC_RPC_CNTR_TCP_OPT_ERR, &rpc->tcp_opt_err); |
| 112 | + fbnic_hw_stat_rd32(fbd, |
| 113 | + FBNIC_RPC_CNTR_OUT_OF_HDR_ERR, |
| 114 | + &rpc->out_of_hdr_err); |
| 115 | + fbnic_hw_stat_rd32(fbd, |
| 116 | + FBNIC_RPC_CNTR_OVR_SIZE_ERR, |
| 117 | + &rpc->ovr_size_err); |
| 118 | +} |
| 119 | + |
52 | 120 | static void fbnic_reset_pcie_stats_asic(struct fbnic_dev *fbd, |
53 | 121 | struct fbnic_pcie_stats *pcie) |
54 | 122 | { |
@@ -135,10 +203,18 @@ static void fbnic_get_pcie_stats_asic64(struct fbnic_dev *fbd, |
135 | 203 |
|
136 | 204 | void fbnic_reset_hw_stats(struct fbnic_dev *fbd) |
137 | 205 | { |
| 206 | + fbnic_reset_rpc_stats(fbd, &fbd->hw_stats.rpc); |
138 | 207 | fbnic_reset_pcie_stats_asic(fbd, &fbd->hw_stats.pcie); |
139 | 208 | } |
140 | 209 |
|
| 210 | +void fbnic_get_hw_stats32(struct fbnic_dev *fbd) |
| 211 | +{ |
| 212 | + fbnic_get_rpc_stats32(fbd, &fbd->hw_stats.rpc); |
| 213 | +} |
| 214 | + |
141 | 215 | void fbnic_get_hw_stats(struct fbnic_dev *fbd) |
142 | 216 | { |
| 217 | + fbnic_get_hw_stats32(fbd); |
| 218 | + |
143 | 219 | fbnic_get_pcie_stats_asic64(fbd, &fbd->hw_stats.pcie); |
144 | 220 | } |
0 commit comments