diff mbox series

[v5,6/7] hw/mdio: Add VMState support

Message ID 20170922171323.10348-7-f4bug@amsat.org
State New
Headers show
Series [v5,1/7] hw/mdio: Generalize etraxfs MDIO bitbanging emulation | expand

Commit Message

Philippe Mathieu-Daudé Sept. 22, 2017, 5:13 p.m. UTC
From: Grant Likely <grant.likely@arm.com>


The MDIO model needs to have VMState support before it can be used by
devices that support VMState. This patch adds VMState macros for both
qemu_mdio and qemu_phy.

Signed-off-by: Grant Likely <grant.likely@arm.com>

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

[PMD: just rebased]
---
 include/hw/net/mdio.h | 22 ++++++++++++++++++++++
 hw/net/mdio.c         | 30 ++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

-- 
2.14.1

Comments

Alistair Francis Feb. 27, 2018, 10:42 p.m. UTC | #1
On Fri, Sep 22, 2017 at 10:13 AM, Philippe Mathieu-Daudé
<f4bug@amsat.org> wrote:
> From: Grant Likely <grant.likely@arm.com>

>

> The MDIO model needs to have VMState support before it can be used by

> devices that support VMState. This patch adds VMState macros for both

> qemu_mdio and qemu_phy.

>

> Signed-off-by: Grant Likely <grant.likely@arm.com>

> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> [PMD: just rebased]


Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>


Alistair

> ---

>  include/hw/net/mdio.h | 22 ++++++++++++++++++++++

>  hw/net/mdio.c         | 30 ++++++++++++++++++++++++++++++

>  2 files changed, 52 insertions(+)

>

> diff --git a/include/hw/net/mdio.h b/include/hw/net/mdio.h

> index 7fca19784e..b94e5ec337 100644

> --- a/include/hw/net/mdio.h

> +++ b/include/hw/net/mdio.h

> @@ -25,6 +25,8 @@

>   * THE SOFTWARE.

>   */

>

> +#include "migration/vmstate.h"

> +

>  /* PHY MII Register/Bit Definitions */

>  /* PHY Registers defined by IEEE */

>  #define PHY_CTRL         0x00 /* Control Register */

> @@ -61,6 +63,16 @@ struct qemu_phy {

>      void (*write)(struct qemu_phy *phy, unsigned int req, uint16_t data);

>  };

>

> +extern const VMStateDescription vmstate_mdio_phy;

> +

> +#define VMSTATE_MDIO_PHY(_field, _state) {                           \

> +    .name   = (stringify(_field)),                                   \

> +    .size   = sizeof(struct qemu_phy),                               \

> +    .vmsd   = &vmstate_mdio_phy,                                     \

> +    .flags  = VMS_STRUCT,                                            \

> +    .offset = vmstate_offset_value(_state, _field, struct qemu_phy), \

> +}

> +

>  struct qemu_mdio {

>      /* bitbanging state machine */

>      bool mdc;

> @@ -83,6 +95,16 @@ struct qemu_mdio {

>      struct qemu_phy *devs[32];

>  };

>

> +extern const VMStateDescription vmstate_mdio;

> +

> +#define VMSTATE_MDIO(_field, _state) {                                 \

> +    .name   = (stringify(_field)),                                     \

> +    .size   = sizeof(struct qemu_mdio),                                \

> +    .vmsd   = &vmstate_mdio,                                           \

> +    .flags  = VMS_STRUCT,                                              \

> +    .offset = vmstate_offset_value(_state, _field, struct qemu_mdio),  \

> +}

> +

>  void mdio_phy_init(struct qemu_phy *phy, uint16_t id1, uint16_t id2);

>  void mdio_attach(struct qemu_mdio *bus, struct qemu_phy *phy,

>                   unsigned int addr);

> diff --git a/hw/net/mdio.c b/hw/net/mdio.c

> index 96e10fada0..6c13cc7272 100644

> --- a/hw/net/mdio.c

> +++ b/hw/net/mdio.c

> @@ -248,3 +248,33 @@ void mdio_bitbang_set_clk(struct qemu_mdio *bus, bool mdc)

>          break;

>      }

>  }

> +

> +const VMStateDescription vmstate_mdio = {

> +    .name = "mdio",

> +    .version_id = 1,

> +    .minimum_version_id = 1,

> +    .minimum_version_id_old = 1,

> +    .fields = (VMStateField[]) {

> +        VMSTATE_BOOL(mdc, struct qemu_mdio),

> +        VMSTATE_BOOL(mdio, struct qemu_mdio),

> +        VMSTATE_UINT32(state, struct qemu_mdio),

> +        VMSTATE_UINT16(cnt, struct qemu_mdio),

> +        VMSTATE_UINT16(addr, struct qemu_mdio),

> +        VMSTATE_UINT16(opc, struct qemu_mdio),

> +        VMSTATE_UINT16(req, struct qemu_mdio),

> +        VMSTATE_UINT32(shiftreg, struct qemu_mdio),

> +        VMSTATE_END_OF_LIST()

> +    }

> +};

> +

> +const VMStateDescription vmstate_mdio_phy = {

> +    .name = "mdio",

> +    .version_id = 1,

> +    .minimum_version_id = 1,

> +    .minimum_version_id_old = 1,

> +    .fields = (VMStateField[]) {

> +        VMSTATE_UINT16_ARRAY(regs, struct qemu_phy, 32),

> +        VMSTATE_BOOL(link, struct qemu_phy),

> +        VMSTATE_END_OF_LIST()

> +    }

> +};

> --

> 2.14.1

>

>
diff mbox series

Patch

diff --git a/include/hw/net/mdio.h b/include/hw/net/mdio.h
index 7fca19784e..b94e5ec337 100644
--- a/include/hw/net/mdio.h
+++ b/include/hw/net/mdio.h
@@ -25,6 +25,8 @@ 
  * THE SOFTWARE.
  */
 
+#include "migration/vmstate.h"
+
 /* PHY MII Register/Bit Definitions */
 /* PHY Registers defined by IEEE */
 #define PHY_CTRL         0x00 /* Control Register */
@@ -61,6 +63,16 @@  struct qemu_phy {
     void (*write)(struct qemu_phy *phy, unsigned int req, uint16_t data);
 };
 
+extern const VMStateDescription vmstate_mdio_phy;
+
+#define VMSTATE_MDIO_PHY(_field, _state) {                           \
+    .name   = (stringify(_field)),                                   \
+    .size   = sizeof(struct qemu_phy),                               \
+    .vmsd   = &vmstate_mdio_phy,                                     \
+    .flags  = VMS_STRUCT,                                            \
+    .offset = vmstate_offset_value(_state, _field, struct qemu_phy), \
+}
+
 struct qemu_mdio {
     /* bitbanging state machine */
     bool mdc;
@@ -83,6 +95,16 @@  struct qemu_mdio {
     struct qemu_phy *devs[32];
 };
 
+extern const VMStateDescription vmstate_mdio;
+
+#define VMSTATE_MDIO(_field, _state) {                                 \
+    .name   = (stringify(_field)),                                     \
+    .size   = sizeof(struct qemu_mdio),                                \
+    .vmsd   = &vmstate_mdio,                                           \
+    .flags  = VMS_STRUCT,                                              \
+    .offset = vmstate_offset_value(_state, _field, struct qemu_mdio),  \
+}
+
 void mdio_phy_init(struct qemu_phy *phy, uint16_t id1, uint16_t id2);
 void mdio_attach(struct qemu_mdio *bus, struct qemu_phy *phy,
                  unsigned int addr);
diff --git a/hw/net/mdio.c b/hw/net/mdio.c
index 96e10fada0..6c13cc7272 100644
--- a/hw/net/mdio.c
+++ b/hw/net/mdio.c
@@ -248,3 +248,33 @@  void mdio_bitbang_set_clk(struct qemu_mdio *bus, bool mdc)
         break;
     }
 }
+
+const VMStateDescription vmstate_mdio = {
+    .name = "mdio",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_BOOL(mdc, struct qemu_mdio),
+        VMSTATE_BOOL(mdio, struct qemu_mdio),
+        VMSTATE_UINT32(state, struct qemu_mdio),
+        VMSTATE_UINT16(cnt, struct qemu_mdio),
+        VMSTATE_UINT16(addr, struct qemu_mdio),
+        VMSTATE_UINT16(opc, struct qemu_mdio),
+        VMSTATE_UINT16(req, struct qemu_mdio),
+        VMSTATE_UINT32(shiftreg, struct qemu_mdio),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+const VMStateDescription vmstate_mdio_phy = {
+    .name = "mdio",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT16_ARRAY(regs, struct qemu_phy, 32),
+        VMSTATE_BOOL(link, struct qemu_phy),
+        VMSTATE_END_OF_LIST()
+    }
+};