[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/50] e1000e: Fix tx/rx counters
|
From: |
Jason Wang |
|
Subject: |
[PULL 01/50] e1000e: Fix tx/rx counters |
|
Date: |
Tue, 23 May 2023 15:31:49 +0800 |
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>
---
hw/net/e1000.c | 5 ++---
hw/net/e1000e_core.c | 5 ++---
hw/net/e1000x_common.c | 5 ++---
hw/net/igb_core.c | 5 ++---
4 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 23d6606..59bacb5 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -637,9 +637,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 c0c09b6..cfa3f55 100644
--- a/hw/net/e1000e_core.c
+++ b/hw/net/e1000e_core.c
@@ -711,9 +711,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 b844af5..4c8e7dc 100644
--- a/hw/net/e1000x_common.c
+++ b/hw/net/e1000x_common.c
@@ -220,15 +220,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
diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c
index d733fed..826e7a6 100644
--- a/hw/net/igb_core.c
+++ b/hw/net/igb_core.c
@@ -538,9 +538,8 @@ igb_on_tx_done_update_stats(IGBCore *core, struct NetTxPkt
*tx_pkt, int qn)
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);
if (core->mac[MRQC] & 1) {
uint16_t pool = qn % IGB_NUM_VM_POOLS;
--
2.7.4
- [PULL 00/50] Net patches, Jason Wang, 2023/05/23
- [PULL 02/50] hw/net/net_tx_pkt: Decouple implementation from PCI, Jason Wang, 2023/05/23
- [PULL 01/50] e1000e: Fix tx/rx counters,
Jason Wang <=
- [PULL 05/50] igb: Fix Rx packet type encoding, Jason Wang, 2023/05/23
- [PULL 03/50] hw/net/net_tx_pkt: Decouple interface from PCI, Jason Wang, 2023/05/23
- [PULL 04/50] e1000x: Fix BPRC and MPRC, Jason Wang, 2023/05/23
- [PULL 06/50] igb: Do not require CTRL.VME for tx VLAN tagging, Jason Wang, 2023/05/23
- [PULL 07/50] igb: Clear IMS bits when committing ICR access, Jason Wang, 2023/05/23
- [PULL 08/50] net/net_rx_pkt: Use iovec for net_rx_pkt_set_protocols(), Jason Wang, 2023/05/23
- [PULL 09/50] e1000e: Always copy ethernet header, Jason Wang, 2023/05/23
- [PULL 10/50] igb: Always copy ethernet header, Jason Wang, 2023/05/23
- [PULL 11/50] Fix references to igb Avocado test, Jason Wang, 2023/05/23
- [PULL 12/50] tests/avocado: Remove unused imports, Jason Wang, 2023/05/23