Module Name: src
Committed By: msaitoh
Date: Wed Jan 19 10:30:04 UTC 2022
Modified Files:
src/sys/dev/pci/ixgbe: ixgbe_vf.h ixv.c
Log Message:
Improve ixv(4)'s some event counters.
- The virtual function's packet counter registers are not cleared on read.
To solve this problem, <REGNAME>, base_<REGNAME>, last_<REGNAME> and
saved_reset_<REGNAME> are in the struct ixgbevf_hw_stats and some
functions use them. However, saved_reset_<REGNAME> is set but never
referenced. base_<REGNAME> is set and it's only used for
saved_reset_<REGNAME>, so it's also unused in reality. THERE ARE A LOT
OF GARBAGE. Remove them.
- Call ixv_init_stats() in ixv_clear_evcnt() to make ifconfig -z ixvN
work correctly.
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/pci/ixgbe/ixgbe_vf.h
cvs rdiff -u -r1.175 -r1.176 src/sys/dev/pci/ixgbe/ixv.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/ixgbe/ixgbe_vf.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.15 src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.16
--- src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.15 Fri Dec 24 05:02:11 2021
+++ src/sys/dev/pci/ixgbe/ixgbe_vf.h Wed Jan 19 10:30:04 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_vf.h,v 1.15 2021/12/24 05:02:11 msaitoh Exp $ */
+/* $NetBSD: ixgbe_vf.h,v 1.16 2022/01/19 10:30:04 msaitoh Exp $ */
/******************************************************************************
SPDX-License-Identifier: BSD-3-Clause
@@ -101,12 +101,6 @@ struct ixgbevf_hw_stats {
struct evcnt l4cs;
struct evcnt l4cs_bad;
- u64 base_vfgprc;
- u64 base_vfgptc;
- u64 base_vfgorc;
- u64 base_vfgotc;
- u64 base_vfmprc;
-
u64 last_vfgprc;
u64 last_vfgptc;
u64 last_vfgorc;
@@ -118,12 +112,6 @@ struct ixgbevf_hw_stats {
struct evcnt vfgorc;
struct evcnt vfgotc;
struct evcnt vfmprc;
-
- u64 saved_reset_vfgprc;
- u64 saved_reset_vfgptc;
- u64 saved_reset_vfgorc;
- u64 saved_reset_vfgotc;
- u64 saved_reset_vfmprc;
};
s32 ixgbe_init_ops_vf(struct ixgbe_hw *hw);
Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.175 src/sys/dev/pci/ixgbe/ixv.c:1.176
--- src/sys/dev/pci/ixgbe/ixv.c:1.175 Tue Jan 18 10:06:59 2022
+++ src/sys/dev/pci/ixgbe/ixv.c Wed Jan 19 10:30:04 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: ixv.c,v 1.175 2022/01/18 10:06:59 msaitoh Exp $ */
+/* $NetBSD: ixv.c,v 1.176 2022/01/19 10:30:04 msaitoh Exp $ */
/******************************************************************************
@@ -35,7 +35,7 @@
/*$FreeBSD: head/sys/dev/ixgbe/if_ixv.c 331224 2018-03-19 20:55:05Z erj $*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.175 2022/01/18 10:06:59 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixv.c,v 1.176 2022/01/19 10:30:04 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -131,7 +131,6 @@ static int ixv_register_vlan(struct adap
static int ixv_unregister_vlan(struct adapter *, u16);
static void ixv_add_device_sysctls(struct adapter *);
-static void ixv_save_stats(struct adapter *);
static void ixv_init_stats(struct adapter *);
static void ixv_update_stats(struct adapter *);
static void ixv_add_stats_sysctls(struct adapter *);
@@ -561,7 +560,6 @@ ixv_attach(device_t parent, device_t dev
IXGBE_MAX_VF_MC, M_DEVBUF, M_WAITOK);
/* Do the stats setup */
- ixv_save_stats(adapter);
ixv_init_stats(adapter);
ixv_add_stats_sysctls(adapter);
@@ -2400,34 +2398,11 @@ ixv_configure_ivars(struct adapter *adap
/************************************************************************
- * ixv_save_stats
+ * ixv_init_stats
*
* The VF stats registers never have a truly virgin
- * starting point, so this routine tries to make an
- * artificial one, marking ground zero on attach as
- * it were.
- ************************************************************************/
-static void
-ixv_save_stats(struct adapter *adapter)
-{
- struct ixgbevf_hw_stats *stats = &adapter->stats.vf;
-
- if (stats->vfgprc.ev_count || stats->vfgptc.ev_count) {
- stats->saved_reset_vfgprc +=
- stats->vfgprc.ev_count - stats->base_vfgprc;
- stats->saved_reset_vfgptc +=
- stats->vfgptc.ev_count - stats->base_vfgptc;
- stats->saved_reset_vfgorc +=
- stats->vfgorc.ev_count - stats->base_vfgorc;
- stats->saved_reset_vfgotc +=
- stats->vfgotc.ev_count - stats->base_vfgotc;
- stats->saved_reset_vfmprc +=
- stats->vfmprc.ev_count - stats->base_vfmprc;
- }
-} /* ixv_save_stats */
-
-/************************************************************************
- * ixv_init_stats
+ * starting point, so this routine save initial vaules to
+ * last_<REGNAME>.
************************************************************************/
static void
ixv_init_stats(struct adapter *adapter)
@@ -2445,22 +2420,13 @@ ixv_init_stats(struct adapter *adapter)
(((u64)(IXGBE_READ_REG(hw, IXGBE_VFGOTC_MSB))) << 32);
adapter->stats.vf.last_vfmprc = IXGBE_READ_REG(hw, IXGBE_VFMPRC);
-
- adapter->stats.vf.base_vfgprc = adapter->stats.vf.last_vfgprc;
- adapter->stats.vf.base_vfgorc = adapter->stats.vf.last_vfgorc;
- adapter->stats.vf.base_vfgptc = adapter->stats.vf.last_vfgptc;
- adapter->stats.vf.base_vfgotc = adapter->stats.vf.last_vfgotc;
- adapter->stats.vf.base_vfmprc = adapter->stats.vf.last_vfmprc;
} /* ixv_init_stats */
#define UPDATE_STAT_32(reg, last, count) \
{ \
u32 current = IXGBE_READ_REG(hw, (reg)); \
- if (current < (last)) \
- count.ev_count += 0x100000000LL; \
+ count.ev_count += current - last; \
(last) = current; \
- count.ev_count &= 0xFFFFFFFF00000000LL; \
- count.ev_count |= current; \
}
#define UPDATE_STAT_36(lsb, msb, last, count) \
@@ -2468,11 +2434,8 @@ ixv_init_stats(struct adapter *adapter)
u64 cur_lsb = IXGBE_READ_REG(hw, (lsb)); \
u64 cur_msb = IXGBE_READ_REG(hw, (msb)); \
u64 current = ((cur_msb << 32) | cur_lsb); \
- if (current < (last)) \
- count.ev_count += 0x1000000000LL; \
+ count.ev_count += current - last; \
(last) = current; \
- count.ev_count &= 0xFFFFFFF000000000LL; \
- count.ev_count |= current; \
}
/************************************************************************
@@ -2859,7 +2822,11 @@ ixv_clear_evcnt(struct adapter *adapter)
stats->ipcs_bad.ev_count = 0;
stats->l4cs_bad.ev_count = 0;
- /* Packet Reception Stats */
+ /*
+ * Packet Reception Stats.
+ * Call ixv_init_stats() to save last VF counters' values.
+ */
+ ixv_init_stats(adapter);
stats->vfgprc.ev_count = 0;
stats->vfgorc.ev_count = 0;
stats->vfmprc.ev_count = 0;