Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c8227d0 authored by Michael Chan's avatar Michael Chan Committed by David S. Miller
Browse files

bnxt_en: Add bnxt_get_num_stats() to centrally get the number of ethtool stats.



Instead of duplicating the logic multiple times.  Also, it is unnecessary
to zero the buffer in .get_ethtool_stats() because it is already zeroed
by the caller.

Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 39d8ba2e
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -198,12 +198,8 @@ static const struct {

#define BNXT_NUM_PORT_STATS ARRAY_SIZE(bnxt_port_stats_arr)

static int bnxt_get_sset_count(struct net_device *dev, int sset)
static int bnxt_get_num_stats(struct bnxt *bp)
{
	struct bnxt *bp = netdev_priv(dev);

	switch (sset) {
	case ETH_SS_STATS: {
	int num_stats = BNXT_NUM_STATS * bp->cp_nr_rings;

	if (bp->flags & BNXT_FLAG_PORT_STATS)
@@ -211,6 +207,14 @@ static int bnxt_get_sset_count(struct net_device *dev, int sset)

	return num_stats;
}

static int bnxt_get_sset_count(struct net_device *dev, int sset)
{
	struct bnxt *bp = netdev_priv(dev);

	switch (sset) {
	case ETH_SS_STATS:
		return bnxt_get_num_stats(bp);
	case ETH_SS_TEST:
		if (!bp->num_tests)
			return -EOPNOTSUPP;
@@ -225,11 +229,8 @@ static void bnxt_get_ethtool_stats(struct net_device *dev,
{
	u32 i, j = 0;
	struct bnxt *bp = netdev_priv(dev);
	u32 buf_size = sizeof(struct ctx_hw_stats) * bp->cp_nr_rings;
	u32 stat_fields = sizeof(struct ctx_hw_stats) / 8;

	memset(buf, 0, buf_size);

	if (!bp->bnapi)
		return;

@@ -835,7 +836,7 @@ static void bnxt_get_drvinfo(struct net_device *dev,
		strlcpy(info->fw_version, bp->fw_ver_str,
			sizeof(info->fw_version));
	strlcpy(info->bus_info, pci_name(bp->pdev), sizeof(info->bus_info));
	info->n_stats = BNXT_NUM_STATS * bp->cp_nr_rings;
	info->n_stats = bnxt_get_num_stats(bp);
	info->testinfo_len = bp->num_tests;
	/* TODO CHIMP_FW: eeprom dump details */
	info->eedump_len = 0;