On 2026/06/16 7:18, Josh Hilke wrote:
Add VMState representation for the Transmit Rate Limiter (TRL) state to
support migration. This includes the TRL timers and target rates per
queue.
Signed-off-by: Josh Hilke <[email protected]>
---
hw/net/igb.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/hw/net/igb.c b/hw/net/igb.c
index c076807..04c48f1 100644
--- a/hw/net/igb.c
+++ b/hw/net/igb.c
@@ -563,6 +563,45 @@ static const VMStateDescription igb_vmstate_intr_timer = {
VMSTATE_STRUCT_ARRAY(_f, _s, _num, 0, \
igb_vmstate_intr_timer, IGBIntrDelayTimer)
+static bool igb_trl_needed(void *opaque)
+{
+ IGBState *s = opaque;
+
+ for (int i = 0; i < IGB_NUM_QUEUES; i++) {
+ if (igb_trl_enabled(s->core.trl[i].trlrc)) {
It will lose bits else E1000_TRLRC_RS_ENA when E1000_TRLRC_RS_ENA is not
set. It should return true when any bit is set.
Regards,
Akihiko Odaki
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static const VMStateDescription igb_vmstate_trl_queue = {
+ .name = "igb-trl-queue",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (const VMStateField[]) {
+ VMSTATE_TIMER_PTR(timer, IGBTrlQueue),
+ VMSTATE_UINT32(trlrc, IGBTrlQueue),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+#define VMSTATE_IGB_TRL_QUEUE_ARRAY(_f, _s, _num) \
+ VMSTATE_STRUCT_ARRAY(_f, _s, _num, 0, \
+ igb_vmstate_trl_queue, IGBTrlQueue)
+
+static const VMStateDescription igb_vmstate_trl_state = {
+ .name = "igb/trl_state",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = igb_trl_needed,
+ .fields = (const VMStateField[]) {
+ VMSTATE_IGB_TRL_QUEUE_ARRAY(core.trl, IGBState, IGB_NUM_QUEUES),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static const VMStateDescription igb_vmstate = {
.name = "igb",
.version_id = 1,
@@ -591,6 +630,10 @@ static const VMStateDescription igb_vmstate = {
VMSTATE_INT64(core.timadj, IGBState),
VMSTATE_END_OF_LIST()
+ },
+ .subsections = (const VMStateDescription * const []) {
+ &igb_vmstate_trl_state,
+ NULL
}
};