]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bnxt_en: Fix counter overflow logic.
authorMichael Chan <michael.chan@broadcom.com>
Mon, 16 Nov 2020 00:27:51 +0000 (19:27 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Nov 2020 12:38:51 +0000 (13:38 +0100)
commit483c96993db2d47fc97d1025de1c5e3925e1b4eb
treeef1cc16bc453f27f85de8876dd9bf73a614806e4
parentca5bbd0fdd36e0430d7e5b79e0a68d5065ee0e53
bnxt_en: Fix counter overflow logic.

[ Upstream commit fa97f303fa4cf8469fd3d1ef29da69c0a3f6ddc8 ]

bnxt_add_one_ctr() adds a hardware counter to a software counter and
adjusts for the hardware counter wraparound against the mask.  The logic
assumes that the hardware counter is always smaller than or equal to
the mask.

This assumption is mostly correct.  But in some cases if the firmware
is older and does not provide the accurate mask, the driver can use
a mask that is smaller than the actual hardware mask.  This can cause
some extra carry bits to be added to the software counter, resulting in
counters that far exceed the actual value.  Fix it by masking the
hardware counter with the mask passed into bnxt_add_one_ctr().

Fixes: fea6b3335527 ("bnxt_en: Accumulate all counters.")
Reviewed-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c