[{"id":1865296,"web_url":"http://patchwork.ozlabs.org/comment/1865296/","msgid":"<CAKmqyKMw=DFaKwc-oXak_k_h1B3pC_vP2Ouq3axdmOy_9asS3g@mail.gmail.com>","list_archive_url":null,"date":"2018-02-27T22:42:49","subject":"Re: [Qemu-devel] [PATCH v5 6/7] hw/mdio: Add VMState support","submitter":{"id":64571,"url":"http://patchwork.ozlabs.org/api/people/64571/","name":"Alistair Francis","email":"alistair23@gmail.com"},"content":"On Fri, Sep 22, 2017 at 10:13 AM, Philippe Mathieu-Daudé\n<f4bug@amsat.org> wrote:\n> From: Grant Likely <grant.likely@arm.com>\n>\n> The MDIO model needs to have VMState support before it can be used by\n> devices that support VMState. This patch adds VMState macros for both\n> qemu_mdio and qemu_phy.\n>\n> Signed-off-by: Grant Likely <grant.likely@arm.com>\n> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\n> [PMD: just rebased]\n\nReviewed-by: Alistair Francis <alistair.francis@xilinx.com>\n\nAlistair\n\n> ---\n>  include/hw/net/mdio.h | 22 ++++++++++++++++++++++\n>  hw/net/mdio.c         | 30 ++++++++++++++++++++++++++++++\n>  2 files changed, 52 insertions(+)\n>\n> diff --git a/include/hw/net/mdio.h b/include/hw/net/mdio.h\n> index 7fca19784e..b94e5ec337 100644\n> --- a/include/hw/net/mdio.h\n> +++ b/include/hw/net/mdio.h\n> @@ -25,6 +25,8 @@\n>   * THE SOFTWARE.\n>   */\n>\n> +#include \"migration/vmstate.h\"\n> +\n>  /* PHY MII Register/Bit Definitions */\n>  /* PHY Registers defined by IEEE */\n>  #define PHY_CTRL         0x00 /* Control Register */\n> @@ -61,6 +63,16 @@ struct qemu_phy {\n>      void (*write)(struct qemu_phy *phy, unsigned int req, uint16_t data);\n>  };\n>\n> +extern const VMStateDescription vmstate_mdio_phy;\n> +\n> +#define VMSTATE_MDIO_PHY(_field, _state) {                           \\\n> +    .name   = (stringify(_field)),                                   \\\n> +    .size   = sizeof(struct qemu_phy),                               \\\n> +    .vmsd   = &vmstate_mdio_phy,                                     \\\n> +    .flags  = VMS_STRUCT,                                            \\\n> +    .offset = vmstate_offset_value(_state, _field, struct qemu_phy), \\\n> +}\n> +\n>  struct qemu_mdio {\n>      /* bitbanging state machine */\n>      bool mdc;\n> @@ -83,6 +95,16 @@ struct qemu_mdio {\n>      struct qemu_phy *devs[32];\n>  };\n>\n> +extern const VMStateDescription vmstate_mdio;\n> +\n> +#define VMSTATE_MDIO(_field, _state) {                                 \\\n> +    .name   = (stringify(_field)),                                     \\\n> +    .size   = sizeof(struct qemu_mdio),                                \\\n> +    .vmsd   = &vmstate_mdio,                                           \\\n> +    .flags  = VMS_STRUCT,                                              \\\n> +    .offset = vmstate_offset_value(_state, _field, struct qemu_mdio),  \\\n> +}\n> +\n>  void mdio_phy_init(struct qemu_phy *phy, uint16_t id1, uint16_t id2);\n>  void mdio_attach(struct qemu_mdio *bus, struct qemu_phy *phy,\n>                   unsigned int addr);\n> diff --git a/hw/net/mdio.c b/hw/net/mdio.c\n> index 96e10fada0..6c13cc7272 100644\n> --- a/hw/net/mdio.c\n> +++ b/hw/net/mdio.c\n> @@ -248,3 +248,33 @@ void mdio_bitbang_set_clk(struct qemu_mdio *bus, bool mdc)\n>          break;\n>      }\n>  }\n> +\n> +const VMStateDescription vmstate_mdio = {\n> +    .name = \"mdio\",\n> +    .version_id = 1,\n> +    .minimum_version_id = 1,\n> +    .minimum_version_id_old = 1,\n> +    .fields = (VMStateField[]) {\n> +        VMSTATE_BOOL(mdc, struct qemu_mdio),\n> +        VMSTATE_BOOL(mdio, struct qemu_mdio),\n> +        VMSTATE_UINT32(state, struct qemu_mdio),\n> +        VMSTATE_UINT16(cnt, struct qemu_mdio),\n> +        VMSTATE_UINT16(addr, struct qemu_mdio),\n> +        VMSTATE_UINT16(opc, struct qemu_mdio),\n> +        VMSTATE_UINT16(req, struct qemu_mdio),\n> +        VMSTATE_UINT32(shiftreg, struct qemu_mdio),\n> +        VMSTATE_END_OF_LIST()\n> +    }\n> +};\n> +\n> +const VMStateDescription vmstate_mdio_phy = {\n> +    .name = \"mdio\",\n> +    .version_id = 1,\n> +    .minimum_version_id = 1,\n> +    .minimum_version_id_old = 1,\n> +    .fields = (VMStateField[]) {\n> +        VMSTATE_UINT16_ARRAY(regs, struct qemu_phy, 32),\n> +        VMSTATE_BOOL(link, struct qemu_phy),\n> +        VMSTATE_END_OF_LIST()\n> +    }\n> +};\n> --\n> 2.14.1\n>\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=gmail.com","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"kLrQwuyD\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3zrYdY5GZyz9s1n\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 28 Feb 2018 09:43:45 +1100 (AEDT)","from localhost ([::1]:40511 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1eqnyJ-00058u-Ti\n\tfor incoming@patchwork.ozlabs.org; Tue, 27 Feb 2018 17:43:43 -0500","from eggs.gnu.org ([2001:4830:134:3::10]:50417)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <alistair23@gmail.com>) id 1eqnxy-00058P-H9\n\tfor qemu-devel@nongnu.org; Tue, 27 Feb 2018 17:43:23 -0500","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <alistair23@gmail.com>) id 1eqnxx-0000CZ-Co\n\tfor qemu-devel@nongnu.org; Tue, 27 Feb 2018 17:43:22 -0500","from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:42144)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <alistair23@gmail.com>)\n\tid 1eqnxx-0000Bl-4D\n\tfor qemu-devel@nongnu.org; Tue, 27 Feb 2018 17:43:21 -0500","by mail-lf0-x244.google.com with SMTP id t204so645017lff.9\n\tfor <qemu-devel@nongnu.org>; Tue, 27 Feb 2018 14:43:20 -0800 (PST)","by 10.46.32.215 with HTTP; Tue, 27 Feb 2018 14:42:49 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc:content-transfer-encoding;\n\tbh=1YuT44a6b+yU9wCuIPYZ6Wm5Hk/jx94Xw7AJuFgkBbs=;\n\tb=kLrQwuyDQ/+DaSYXnbDHsQIo/GM3+FaFWXng5xsaYOI4i4S1wfCn/kd59920RD304M\n\tuCBwmlhuxAkh3Mp4JapB7ywBBtYG/l+R9n2WNSbiziRmCH+fQamPTOp2gGae76UoAw/v\n\t/VYZHbcgURQbshcN03XaB95ozCFc4nm0P0B2HlighVCcdAH6qQ2kQ616hLU5h9arBYZM\n\tW0rC0sClCCEhOgSyj/QC396ci+hK5NCQ/aRBsIZMMTrUScA4hLQ03giOJtPz7rwVcAud\n\tDXOfMHjOYQh4sjkrymf033r5wCtjo94uc+YabpYUqJP4Ak6l6SWKOYhcMtxq8NnMLKWT\n\tLOdw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=1YuT44a6b+yU9wCuIPYZ6Wm5Hk/jx94Xw7AJuFgkBbs=;\n\tb=QEvUi4xvUG3BrSLXoy9JK1My17N3/gqKTjJ5qcYVremgukADXo+7sCQIvrtgM3HTjP\n\trzGNCBDbSeyDaDHaVKtBLXG2CAed/rhBbsVxn4qEx5JSdaetkd0caWQMvnBgWsgPlJvm\n\t7R32ZrgsRY7uLD+ED46OYLYWhej2wYNItABCZ4BRpzvxXl7O+5d2iJer3wxP1iNqEKkF\n\tW4d/hHjDyYr8B4l/0K9Hxh58UMYYrturL66eobzD3Nxw34vm9aSNs+lOXlEnsZmrLMmw\n\tJK0fP5u3fkNxLzmF4Xe2wNTUaNB2bl8bSMY2pJUQa1Yp4IbIrPVUaGgd/zo4Txwrxsb8\n\tO2XQ==","X-Gm-Message-State":"APf1xPAxQ/v9NVzVR3d4I2GLbmqGvbhNfoXEA4ZWOBDEJevK7nFp8J3V\n\tOPSgjLaQCqjUH83BGL0zFPVIzfTgJ0awnzPw3HM=","X-Google-Smtp-Source":"AG47ELtFy39ue/rPhWqQ3yOZh1R4CxnE5xmAK6qJYKK9qzUIWXeSE4qBXWILaAHAot9aUODkkzcNXtZKFLJuxBag5+4=","X-Received":"by 10.25.24.203 with SMTP id 72mr11445924lfy.132.1519771399824; \n\tTue, 27 Feb 2018 14:43:19 -0800 (PST)","MIME-Version":"1.0","In-Reply-To":"<20170922171323.10348-7-f4bug@amsat.org>","References":"<20170922171323.10348-1-f4bug@amsat.org>\n\t<20170922171323.10348-7-f4bug@amsat.org>","From":"Alistair Francis <alistair23@gmail.com>","Date":"Tue, 27 Feb 2018 14:42:49 -0800","Message-ID":"<CAKmqyKMw=DFaKwc-oXak_k_h1B3pC_vP2Ouq3axdmOy_9asS3g@mail.gmail.com>","To":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2a00:1450:4010:c07::244","Subject":"Re: [Qemu-devel] [PATCH v5 6/7] hw/mdio: Add VMState support","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Peter Maydell <peter.maydell@linaro.org>,\n\tJason Wang <jasowang@redhat.com>, Grant Likely <grant.likely@arm.com>,\n\t\"qemu-devel@nongnu.org Developers\" <qemu-devel@nongnu.org>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]