From patchwork Fri Sep 22 17:13:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 114068 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3537706qgf; Fri, 22 Sep 2017 10:17:18 -0700 (PDT) X-Received: by 10.55.127.70 with SMTP id a67mr8459814qkd.90.1506100638367; Fri, 22 Sep 2017 10:17:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506100638; cv=none; d=google.com; s=arc-20160816; b=EDkurZNmq0isqxYl7+M8qBRnh74vqioKvUyAfmS4fd606rjMM9yo4ekQNvppXrMC7k EUd1W3DBpTSRL/qQHqehx/7ONg4zdkTEC8VjlLH7+onhwZsbJWRtdFgEoJXQMufGr1sR 6HZWWvP8Uj1hO3nWGhRhE7O+fMdW6lvMZ/u81wm2w1hDkpygBpgH3j3aL9dp1Z676ZVG +j5feS5rT3xXZqZHtzqVa6jkX9QrTn0KrTTdOvROhnbOKV2PpzJGhwjE3s5ejTkHtIR6 RYlGlW1GBfVUw+S9Yp38OnwSyeqpyDf1DBazhDO/S5SBL6zFIVHcIjudj40Uvpw66IZd lIow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=/uYu4uuFxDkoaslS0IXjyrZpP1KOsmMM+Jx/vmcm260=; b=yv49mQ/NFfKPBSmfmVjn+vT5r0imfkgkvFBikQT1pHJ19k4ZViWYObfXm2oyhsKtMl FiFua5V7QqCSRUGKVeEqjge9ucoSz0IdgqEXOJOAomIGmFXd5boquODGl6Jqwjw6J4+U uXPNZoNeOiRfQjDvKlL2wWwAcKb4LQpyv5zFsTLDs02WAV07YF//z5/wiL1WEOHeE4Ng tJ5NE8S26e84Uv4TZBPdR8R7lp7t/vMhO9vSkUC8P8UPol2VkQ4bsL5g6McfM/G2JsRi XKpjJJylZS99on3tW2twTO+fHzHbct2R9bsxquaxZFgoWuELR2D7UZNHTYmOWn3AnBvo RnWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UEgrMXkQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id o29si246997qtc.347.2017.09.22.10.17.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Sep 2017 10:17:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UEgrMXkQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:60300 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvRZk-0006rH-Ar for patch@linaro.org; Fri, 22 Sep 2017 13:17:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvRWX-0003bE-Un for qemu-devel@nongnu.org; Fri, 22 Sep 2017 13:13:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvRWW-0003ZK-QP for qemu-devel@nongnu.org; Fri, 22 Sep 2017 13:13:57 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:34738) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dvRWW-0003Z4-M6 for qemu-devel@nongnu.org; Fri, 22 Sep 2017 13:13:56 -0400 Received: by mail-qk0-x241.google.com with SMTP id d70so1028194qkc.1 for ; Fri, 22 Sep 2017 10:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/uYu4uuFxDkoaslS0IXjyrZpP1KOsmMM+Jx/vmcm260=; b=UEgrMXkQj/aRiYqXl7o6iS8Pda9PmW3IaeZGJhNd4JFmXDi3SCHJh+aQ0eCMmEoaXQ WYII1m4/Ls5ES99MrBKOX4d+HOpCuKiz6I5GEYFTaAgxdaZCw9x8OHIfVqY7bLPmPIup Hk9JVRSiZhMh910etJYpvWHfZIf7eln0Lj/7LB+vo3EZsYNx1bxVbgByYluZ86975p7A UsB9tXj++vvLOOFs4DpXRwfgrnf6WKt+p5BlmvZ2/l6T/S/S9yKbZj3picaNRzmMO3Gh /AMaAbMvKDB3iLITiTrqRb32/T5cCWcyTl+n1k8q63zBL7G2C6zkqNOLWlR+ouYnsiVz akMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/uYu4uuFxDkoaslS0IXjyrZpP1KOsmMM+Jx/vmcm260=; b=TMtvem+YWNu4QkNNPpAYOnML6ByLUmmvq2tK5DOX9rMcyQtPHBzbB7ZX4m3WeCakQR JCmCcuiSgZscPCQ6f701GtqD+fEmU65YAeM9O17RHHQXqCp38fhvhpjGu8I4uPoe+Lpx NJeCPBG+EctO8NLS0ZiizBfyjsUeO/gI9K7hXp7yHyAq5W4MryI5gddaWFU4o7ISqI3T pjflW1F0/p39WI4+xBXrS6EL3ZQMLjvtAUb3Q0TWFe7TPLEElnnuLMYjbzMtQO6AokUn h1j60XTrlwNfCKo5WkF7Cym4caLoXmHtHtjMaIXbx1kVMCy9XEa/NFy0vq3ofOIOmXNt NwGA== X-Gm-Message-State: AHPjjUj7YBoKcmz1BliOQqut239wMaSIGXH+LdmhrL8EgK2fbvXL48xP KFjhPfkDXNXuOq6Vv8jwVnA= X-Google-Smtp-Source: AOwi7QC/b5kxFgJ6ELzkvdUw+IBPLCzz7da8xc0OyL11evkV2dj+J0WpCtZG40vCnjMeSMANeuO9lA== X-Received: by 10.55.66.22 with SMTP id p22mr9027891qka.78.1506100436286; Fri, 22 Sep 2017 10:13:56 -0700 (PDT) Received: from yoga.lan ([181.93.89.178]) by smtp.gmail.com with ESMTPSA id f69sm238468qke.27.2017.09.22.10.13.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Sep 2017 10:13:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: Peter Maydell , Grant Likely , Jason Wang Date: Fri, 22 Sep 2017 14:13:22 -0300 Message-Id: <20170922171323.10348-7-f4bug@amsat.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170922171323.10348-1-f4bug@amsat.org> References: <20170922171323.10348-1-f4bug@amsat.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::241 Subject: [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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Grant Likely 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 Signed-off-by: Philippe Mathieu-Daudé [PMD: just rebased] --- include/hw/net/mdio.h | 22 ++++++++++++++++++++++ hw/net/mdio.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) -- 2.14.1 Reviewed-by: Alistair Francis 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() + } +};