-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eth: fbnic: Add support to fetch group stats
Add support for group stats for mac. The fbnic_set_counter help preserve the default values for counters which are not touched by the driver. The 'reset' flag in 'get_eth_mac_stats' allows to choose between resetting the counter to recent most value or fetching the aggregated values of the counter. The 'fbnic_stat_rd64' read 64b stats counters in an atomic fashion using read-read-read approach. This allows to isolate cases where counter is moving too fast making accuracy of the counter questionable. Command: ethtool -S eth0 --groups eth-mac Example Output: eth-mac-FramesTransmittedOK: 421644 eth-mac-FramesReceivedOK: 3849708 eth-mac-FrameCheckSequenceErrors: 0 eth-mac-AlignmentErrors: 0 eth-mac-OctetsTransmittedOK: 64799060 eth-mac-FramesLostDueToIntMACXmitError: 0 eth-mac-OctetsReceivedOK: 5134513531 eth-mac-FramesLostDueToIntMACRcvError: 0 eth-mac-MulticastFramesXmittedOK: 568 eth-mac-BroadcastFramesXmittedOK: 454 eth-mac-MulticastFramesReceivedOK: 276106 eth-mac-BroadcastFramesReceivedOK: 26119 eth-mac-FrameTooLongErrors: 0 Signed-off-by: Mohsin Bashir <mohsin.bashr@gmail.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Mohsin Bashir
authored and
David S. Miller
committed
Sep 4, 2024
1 parent
bd2557a
commit 4eb7f20
Showing
8 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "fbnic.h" | ||
|
||
u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset) | ||
{ | ||
u32 prev_upper, upper, lower, diff; | ||
|
||
prev_upper = rd32(fbd, reg + offset); | ||
lower = rd32(fbd, reg); | ||
upper = rd32(fbd, reg + offset); | ||
|
||
diff = upper - prev_upper; | ||
if (!diff) | ||
return ((u64)upper << 32) | lower; | ||
|
||
if (diff > 1) | ||
dev_warn_once(fbd->dev, | ||
"Stats inconsistent, upper 32b of %#010x updating too quickly\n", | ||
reg * 4); | ||
|
||
/* Return only the upper bits as we cannot guarantee | ||
* the accuracy of the lower bits. We will add them in | ||
* when the counter slows down enough that we can get | ||
* a snapshot with both upper values being the same | ||
* between reads. | ||
*/ | ||
return ((u64)upper << 32); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#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_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_hw_stats { | ||
struct fbnic_mac_stats mac; | ||
}; | ||
|
||
u64 fbnic_stat_rd64(struct fbnic_dev *fbd, u32 reg, u32 offset); | ||
|
||
void fbnic_get_hw_stats(struct fbnic_dev *fbd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters