[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.3 47/53] e1000e: Fix tx/rx counters
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.3 47/53] e1000e: Fix tx/rx counters |
Date: |
Sun, 28 May 2023 09:59:20 +0300 |
From: "timothee.cocault@gmail.com" <timothee.cocault@gmail.com>
The bytes and packets counter registers are cleared on read.
Copying the "total counter" registers to the "good counter" registers has
side effects.
If the "total" register is never read by the OS, it only gets incremented.
This leads to exponential growth of the "good" register.
This commit increments the counters individually to avoid this.
Signed-off-by: Timothée Cocault <timothee.cocault@gmail.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
(cherry picked from commit 8d689f6aae8be096b4a1859be07c1b083865f755)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(Mjt: removed hw/net/igb_core.c part: igb introduced in 8.0)
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 9cd3d6f495..0dfdf47313 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -632,9 +632,8 @@ xmit_seg(E1000State *s)
e1000x_inc_reg_if_not_full(s->mac_reg, TPT);
e1000x_grow_8reg_if_not_full(s->mac_reg, TOTL, s->tx.size + 4);
- s->mac_reg[GPTC] = s->mac_reg[TPT];
- s->mac_reg[GOTCL] = s->mac_reg[TOTL];
- s->mac_reg[GOTCH] = s->mac_reg[TOTH];
+ e1000x_inc_reg_if_not_full(s->mac_reg, GPTC);
+ e1000x_grow_8reg_if_not_full(s->mac_reg, GOTCL, s->tx.size + 4);
}
static void
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
index fc9cdb4528..c71d82ce1d 100644
--- a/hw/net/e1000e_core.c
+++ b/hw/net/e1000e_core.c
@@ -687,9 +687,8 @@ e1000e_on_tx_done_update_stats(E1000ECore *core, struct
NetTxPkt *tx_pkt)
g_assert_not_reached();
}
- core->mac[GPTC] = core->mac[TPT];
- core->mac[GOTCL] = core->mac[TOTL];
- core->mac[GOTCH] = core->mac[TOTH];
+ e1000x_inc_reg_if_not_full(core->mac, GPTC);
+ e1000x_grow_8reg_if_not_full(core->mac, GOTCL, tot_len);
}
static void
diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c
index a8d93870b5..3fdc34f753 100644
--- a/hw/net/e1000x_common.c
+++ b/hw/net/e1000x_common.c
@@ -217,15 +217,14 @@ e1000x_update_rx_total_stats(uint32_t *mac,
e1000x_increase_size_stats(mac, PRCregs, data_fcs_size);
e1000x_inc_reg_if_not_full(mac, TPR);
- mac[GPRC] = mac[TPR];
+ e1000x_inc_reg_if_not_full(mac, GPRC);
/* TOR - Total Octets Received:
* This register includes bytes received in a packet from the <Destination
* Address> field through the <CRC> field, inclusively.
* Always include FCS length (4) in size.
*/
e1000x_grow_8reg_if_not_full(mac, TORL, data_size + 4);
- mac[GORCL] = mac[TORL];
- mac[GORCH] = mac[TORH];
+ e1000x_grow_8reg_if_not_full(mac, GORCL, data_size + 4);
}
void
--
2.39.2
- [Stable-7.2.3 v3 00/42] Patch Round-up for stable 7.2.3, frozen on 2023-05-27, Michael Tokarev, 2023/05/28
- [Stable-7.2.3 46/53] e1000: Count CRC in Tx statistics, Michael Tokarev, 2023/05/28
- [Stable-7.2.3 47/53] e1000e: Fix tx/rx counters,
Michael Tokarev <=
- [Stable-7.2.3 49/53] rtl8139: fix large_send_mss divide-by-zero, Michael Tokarev, 2023/05/28
- [Stable-7.2.3 48/53] e1000x: Fix BPRC and MPRC, Michael Tokarev, 2023/05/28
- [Stable-7.2.3 51/53] usb/ohci: Set pad to 0 after frame update, Michael Tokarev, 2023/05/28
- [Stable-7.2.3 52/53] hw/scsi/lsi53c895a: Fix reentrancy issues in the LSI controller (CVE-2023-0330), Michael Tokarev, 2023/05/28
- [Stable-7.2.3 53/53] machine: do not crash if default RAM backend name has been stolen, Michael Tokarev, 2023/05/28
- [Stable-7.2.3 50/53] util/vfio-helpers: Use g_file_read_link(), Michael Tokarev, 2023/05/28