-
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.
Mohsin Bashir says: ==================== eth: Add basic ethtool support for fbnic This patch series adds basic ethtool support for fbnic. Specifically, the two patches focus on the following two features respectively: 1: Enable 'ethtool -i <dev>' to provide driver, firmware and bus information. 2: Provide mac group stats. Changes since v2: - Fix v1 reference link - Fix nit --- v2: https://lore.kernel.org/netdev/20240827205904.1944066-2-mohsin.bashr@gmail.com v1: https://lore.kernel.org/netdev/20240822184944.3882360-1-mohsin.bashr@gmail.com ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Showing
12 changed files
with
260 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include <linux/ethtool.h> | ||
#include <linux/netdevice.h> | ||
#include <linux/pci.h> | ||
|
||
#include "fbnic.h" | ||
#include "fbnic_netdev.h" | ||
#include "fbnic_tlv.h" | ||
|
||
static void | ||
fbnic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) | ||
{ | ||
struct fbnic_net *fbn = netdev_priv(netdev); | ||
struct fbnic_dev *fbd = fbn->fbd; | ||
|
||
fbnic_get_fw_ver_commit_str(fbd, drvinfo->fw_version, | ||
sizeof(drvinfo->fw_version)); | ||
} | ||
|
||
static void fbnic_set_counter(u64 *stat, struct fbnic_stat_counter *counter) | ||
{ | ||
if (counter->reported) | ||
*stat = counter->value; | ||
} | ||
|
||
static void | ||
fbnic_get_eth_mac_stats(struct net_device *netdev, | ||
struct ethtool_eth_mac_stats *eth_mac_stats) | ||
{ | ||
struct fbnic_net *fbn = netdev_priv(netdev); | ||
struct fbnic_mac_stats *mac_stats; | ||
struct fbnic_dev *fbd = fbn->fbd; | ||
const struct fbnic_mac *mac; | ||
|
||
mac_stats = &fbd->hw_stats.mac; | ||
mac = fbd->mac; | ||
|
||
mac->get_eth_mac_stats(fbd, false, &mac_stats->eth_mac); | ||
|
||
fbnic_set_counter(ð_mac_stats->FramesTransmittedOK, | ||
&mac_stats->eth_mac.FramesTransmittedOK); | ||
fbnic_set_counter(ð_mac_stats->FramesReceivedOK, | ||
&mac_stats->eth_mac.FramesReceivedOK); | ||
fbnic_set_counter(ð_mac_stats->FrameCheckSequenceErrors, | ||
&mac_stats->eth_mac.FrameCheckSequenceErrors); | ||
fbnic_set_counter(ð_mac_stats->AlignmentErrors, | ||
&mac_stats->eth_mac.AlignmentErrors); | ||
fbnic_set_counter(ð_mac_stats->OctetsTransmittedOK, | ||
&mac_stats->eth_mac.OctetsTransmittedOK); | ||
fbnic_set_counter(ð_mac_stats->FramesLostDueToIntMACXmitError, | ||
&mac_stats->eth_mac.FramesLostDueToIntMACXmitError); | ||
fbnic_set_counter(ð_mac_stats->OctetsReceivedOK, | ||
&mac_stats->eth_mac.OctetsReceivedOK); | ||
fbnic_set_counter(ð_mac_stats->FramesLostDueToIntMACRcvError, | ||
&mac_stats->eth_mac.FramesLostDueToIntMACRcvError); | ||
fbnic_set_counter(ð_mac_stats->MulticastFramesXmittedOK, | ||
&mac_stats->eth_mac.MulticastFramesXmittedOK); | ||
fbnic_set_counter(ð_mac_stats->BroadcastFramesXmittedOK, | ||
&mac_stats->eth_mac.BroadcastFramesXmittedOK); | ||
fbnic_set_counter(ð_mac_stats->MulticastFramesReceivedOK, | ||
&mac_stats->eth_mac.MulticastFramesReceivedOK); | ||
fbnic_set_counter(ð_mac_stats->BroadcastFramesReceivedOK, | ||
&mac_stats->eth_mac.BroadcastFramesReceivedOK); | ||
fbnic_set_counter(ð_mac_stats->FrameTooLongErrors, | ||
&mac_stats->eth_mac.FrameTooLongErrors); | ||
} | ||
|
||
static const struct ethtool_ops fbnic_ethtool_ops = { | ||
.get_drvinfo = fbnic_get_drvinfo, | ||
.get_eth_mac_stats = fbnic_get_eth_mac_stats, | ||
}; | ||
|
||
void fbnic_set_ethtool_ops(struct net_device *dev) | ||
{ | ||
dev->ethtool_ops = &fbnic_ethtool_ops; | ||
} |
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
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