From: Andy Moreton <[email protected]>

On X4 the MAC hardware reports both over-size packets and CRC errors
in the RX event flag RX_TRUNC_ERR. Over-size packets are only likely
as a result of a misconfigured network, so count the RX_TRUNC_ERR
events as CRC errors.
This workaround is only needed for the per-queue counters maintained
by the driver. The DMA statistics counters maintained by firmware
are not affected.

Signed-off-by: Andy Moreton <[email protected]>
Signed-off-by: Viacheslav Galaktionov <[email protected]>
---
 drivers/common/sfc_efx/base/ef10_ev.c | 41 +++++++++++++++++++++------
 1 file changed, 33 insertions(+), 8 deletions(-)

diff --git a/drivers/common/sfc_efx/base/ef10_ev.c 
b/drivers/common/sfc_efx/base/ef10_ev.c
index a97c1bf43e..ea430d0d5f 100644
--- a/drivers/common/sfc_efx/base/ef10_ev.c
+++ b/drivers/common/sfc_efx/base/ef10_ev.c
@@ -418,6 +418,7 @@ ef10_ev_rx_packed_stream(
        __in            const efx_ev_callbacks_t *eecp,
        __in_opt        void *arg)
 {
+       efx_nic_t *enp = eep->ee_enp;
        uint32_t label;
        uint32_t pkt_count_lbits;
        uint16_t flags;
@@ -466,10 +467,22 @@ ef10_ev_rx_packed_stream(
 
        /* Check for errors that invalidate checksum and L3/L4 fields */
        if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_TRUNC_ERR) != 0) {
-               /* RX frame truncated */
-               EFX_EV_QSTAT_INCR(eep, EV_RX_FRM_TRUNC);
-               flags |= EFX_DISCARD;
-               goto deliver;
+               /*
+                * X4 uses RX_TRUNC_ERR for packet size and CRC errors. Count
+                * these as CRC errors (as over-size packets are only likely in
+                * a misconfigured network).
+                */
+               if (enp->en_family == EFX_FAMILY_MEDFORD4) {
+                       /* Bad Ethernet frame CRC */
+                       EFX_EV_QSTAT_INCR(eep, EV_RX_ETH_CRC_ERR);
+                       flags |= EFX_DISCARD;
+                       goto deliver;
+               } else {
+                       /* RX frame truncated */
+                       EFX_EV_QSTAT_INCR(eep, EV_RX_FRM_TRUNC);
+                       flags |= EFX_DISCARD;
+                       goto deliver;
+               }
        }
        if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_ECRC_ERR) != 0) {
                /* Bad Ethernet frame CRC */
@@ -630,10 +643,22 @@ ef10_ev_rx(
 
        /* Check for errors that invalidate checksum and L3/L4 fields */
        if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_TRUNC_ERR) != 0) {
-               /* RX frame truncated */
-               EFX_EV_QSTAT_INCR(eep, EV_RX_FRM_TRUNC);
-               flags |= EFX_DISCARD;
-               goto deliver;
+               /*
+                * X4 uses RX_TRUNC_ERR for packet size and CRC errors. Count
+                * these as CRC errors (as over-size packets are only likely in
+                * a misconfigured network).
+                */
+               if (enp->en_family == EFX_FAMILY_MEDFORD4) {
+                       /* Bad Ethernet frame CRC */
+                       EFX_EV_QSTAT_INCR(eep, EV_RX_ETH_CRC_ERR);
+                       flags |= EFX_DISCARD;
+                       goto deliver;
+               } else {
+                       /* RX frame truncated */
+                       EFX_EV_QSTAT_INCR(eep, EV_RX_FRM_TRUNC);
+                       flags |= EFX_DISCARD;
+                       goto deliver;
+               }
        }
        if (EFX_QWORD_FIELD(*eqp, ESF_DZ_RX_ECRC_ERR) != 0) {
                /* Bad Ethernet frame CRC */
-- 
2.47.3

Reply via email to