From patchwork Tue Mar 7 07:08:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 659732 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2246292wrb; Mon, 6 Mar 2023 23:16:24 -0800 (PST) X-Google-Smtp-Source: AK7set9Z7C4pc/vROfU+BBk8K8escyujlSeWg8jsTgCLfJTdf586BMVlQROPsTl1psWyo++Y6bMF X-Received: by 2002:a05:6214:1c4c:b0:56b:ec30:67eb with SMTP id if12-20020a0562141c4c00b0056bec3067ebmr24281189qvb.39.1678173384670; Mon, 06 Mar 2023 23:16:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678173384; cv=none; d=google.com; s=arc-20160816; b=s3KAUzMK0BlnJtl3/vzTVoSm1NxpGxG6KDBVnnQbn82HD7L7+bmXaq5grm8ABdpbnS MdTleIuOCHPiuNG/86vpjMITzkNIB5cCmk7lXD+jA0+u5y607ELFznAHJeYb3OAFC2Y+ 6Lb5sWVZ7gv3yqUIS+Dca5vp+l4VeXMq+SYyfkvtRRRrhV2zQJC88AcpgZJRy9KTQV+j QvPijFvG6m+b1gEOPKnisTPuNWICC06e/EHP/vftRAq0ASq/waQxgQf1QA/o6T+D6CUD aAj2WnA5usPNPkvFgthca2LDnjgg6O8SYN/23v87juJWGTMx2/cN//9NRIgwFcUzt8WH a+4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2rR0pQE5H3PbTtM8rztov3wJmNgdX7ZC1gpqYUZ5/7A=; b=KDICXwXTqiz3SPsu9Xz62o1Cdl8/1Z4kfza7ThGWV5wZiYbErz3t1/rl5agEoYl19u cFoCKOnER61fjlQcy8yPUE/frknZz+ZaLAIXNBOz1VNVIgTCT33DzR7YFbpjHS5j9W4q KDMGWV3CVmv15xrr7GZDxHyrRKaOX7Ba0lVF8c8ha+ekwhpcyWRUxWsa2/F7urpCl9Ov rMAqyhfHqYJ/c3QY0Rfkc+0lXbbNalaxExobBykXVpZaTMQgJ+Gf+asmaxTCqZ7nqkRZ 4A1Ooa1y6/CXsKYQkEOw2Z+pBfAfK6sZbkqkNFP8XGce81yHFCjncoMUGnG57kmYy1Mf wt2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="HMs/bBWr"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m2-20020a05620a24c200b007429b95c2dfsi10159373qkn.477.2023.03.06.23.16.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Mar 2023 23:16:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="HMs/bBWr"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZRU5-0006K3-8c; Tue, 07 Mar 2023 02:11:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTm-0005mU-DJ for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTb-0005rt-2y for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678173070; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2rR0pQE5H3PbTtM8rztov3wJmNgdX7ZC1gpqYUZ5/7A=; b=HMs/bBWrlXTlTkbGkw1xaHcx8FXNQ2JcOASi0CNgfbcc4CENexHagrngAAp2G8bfp8a0Go uHwEdk5V01JW9U467szqpwwUD70eH2RcvxKzecr0SA9P6uw61h+Ycu4tWiBYt6S3wdiLpk pVnBHURL8H2L5NMIO9Cb5lCwmjAPAq0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-20-ougGEE9bNF2vMAxEh0iVtw-1; Tue, 07 Mar 2023 02:11:07 -0500 X-MC-Unique: ougGEE9bNF2vMAxEh0iVtw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F3E771C08967; Tue, 7 Mar 2023 07:11:06 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AA6E40C10FA; Tue, 7 Mar 2023 07:11:04 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL 45/51] hw/net/eepro100: Abort if pci_add_capability() ever fail Date: Tue, 7 Mar 2023 15:08:10 +0800 Message-Id: <20230307070816.34833-46-jasowang@redhat.com> In-Reply-To: <20230307070816.34833-1-jasowang@redhat.com> References: <20230307070816.34833-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé If pci_add_capability() ever fail, the EEPRO100 device is broken, which is a bug. No need to report that to the user, abort instead. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang --- hw/net/eepro100.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index dc07984..dce7503 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -549,13 +549,8 @@ static void e100_pci_reset(EEPRO100State *s, Error **errp) if (info->power_management) { /* Power Management Capabilities */ int cfg_offset = 0xdc; - int r = pci_add_capability(&s->dev, PCI_CAP_ID_PM, - cfg_offset, PCI_PM_SIZEOF, - errp); - if (r < 0) { - return; - } - + pci_add_capability(&s->dev, PCI_CAP_ID_PM, cfg_offset, PCI_PM_SIZEOF, + &error_abort); pci_set_word(pci_conf + cfg_offset + PCI_PM_PMC, 0x7e21); #if 0 /* TODO: replace dummy code for power management emulation. */ /* TODO: Power Management Control / Status. */ From patchwork Tue Mar 7 07:08:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 659729 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2246094wrb; Mon, 6 Mar 2023 23:15:41 -0800 (PST) X-Google-Smtp-Source: AK7set+XJXLR5JO1PvQW54nca/arnx6vrxpF8sbSqakufZKRuXR9NS5wX2WemjQ1YfXOmXdTYjYL X-Received: by 2002:ac8:5b53:0:b0:3b8:6ae9:b10d with SMTP id n19-20020ac85b53000000b003b86ae9b10dmr21325860qtw.2.1678173341721; Mon, 06 Mar 2023 23:15:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678173341; cv=none; d=google.com; s=arc-20160816; b=tuMf0UfqveqhmQWBexuNW/9+UCv13n7LsKRKXseuI5WAvUFGct4B+dSSr25v1C1bQ/ +VY1ZPb77ca6HfFwazjc5Is+EcGfmfFFOxxSHYtn2oVb0XqZebMMLmbs/Gl9EKVDfH9R WgOTsx9u/IN2jhDLpQYW6+WhDgsQCvbWE8chSjWjnPSChu+vNiZcyyVepDykZzEwaC97 myvMrjDRcCfxm62o5JuBFZK9TmAS0NSv3AcBzcoY+E0F2JAzEwXAaL3BMEbdci2FLOgg /wGx8b6P5xbPLKjb+LAslqosFZr4BlMVx2o3KXgZ3XuapbPZsT1+JTBwXyKEEc1zlwdG oVQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Cq5G3WEGJ/6Zz+rrPCWfk8i0GOn43bnChlWjtdUE1gc=; b=agNZNO1fVseIMoDEZZlm8ey+APHtbzohkfdjIYdiHr9MJvQnaBs4Z9AN6lRQJd2vKP K4lotIdfpnhgTis2suxusTdda3KH3NvgjBMboX7xQf1By9tomvOII15zIl6xVi7rXuY2 zZ9ptghUldktA5H/7/nf1L9mywR8inds5CJB6D7+jgK2hreL+tmqAcb72uTQuaHz2kRd eOwFF5uW+p9TGR6OA5YHmkhXfJimIWedwXmzeaZQR2WE1H7O/yaDsF7VybCepvmdKnhw aBM7kwlrnMEoCFz0n/iebsFYkq53jwKHVcXkLJDyR0keBfbBf+TyqiRNkPadxqHHlvQ3 rvnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DpcIdyLR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h9-20020a05620a400900b0073b45062385si10469770qko.588.2023.03.06.23.15.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Mar 2023 23:15:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DpcIdyLR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZRUP-0006tG-HL; Tue, 07 Mar 2023 02:12:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTm-0005me-BN for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTf-0005sG-HK for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678173075; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cq5G3WEGJ/6Zz+rrPCWfk8i0GOn43bnChlWjtdUE1gc=; b=DpcIdyLRtA0sJ/7fU+AsEI9nmuc/4gUIKCtJLahTdrTuLyiILsgl5vSPMuguOs0HH3UfKO lyyFAxsRnEiuu1/nbn8tzOqCforzFosZxfw1OcbAD1DCB6YzKNkdcGDzc+xK70jpKSRlZZ kCR990l1WjG/GxZBT+jc2qmG3xk2oNg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-231-AI6uAQhLMQSAWcmK7X_eAQ-1; Tue, 07 Mar 2023 02:11:09 -0500 X-MC-Unique: AI6uAQhLMQSAWcmK7X_eAQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8582F18A6461; Tue, 7 Mar 2023 07:11:09 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 96E84400F8FA; Tue, 7 Mar 2023 07:11:07 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL 46/51] hw/net/eepro100: Introduce TYPE_EEPRO100 QOM abstract parent Date: Tue, 7 Mar 2023 15:08:11 +0800 Message-Id: <20230307070816.34833-47-jasowang@redhat.com> In-Reply-To: <20230307070816.34833-1-jasowang@redhat.com> References: <20230307070816.34833-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Have all the EEPRO100-based devices share a common (abstract) QOM parent. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang --- hw/net/eepro100.c | 60 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index dce7503..4b5d455 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -235,8 +235,20 @@ typedef enum { ru_ready = 4 } ru_state_t; -typedef struct { +#define TYPE_EEPRO100 "eepro100" +OBJECT_DECLARE_TYPE(EEPRO100State, EEPRO100Class, EEPRO100) + +struct EEPRO100Class { + /*< private >*/ + PCIDeviceClass parent_class; + /*< public >*/ +}; + +struct EEPRO100State { + /*< private >*/ PCIDevice dev; + /*< public >*/ + /* Hash register (multicast mask array, multiple individual addresses). */ uint8_t mult[8]; MemoryRegion mmio_bar; @@ -279,7 +291,7 @@ typedef struct { /* Quasi static device properties (no need to save them). */ uint16_t stats_size; bool has_extended_tcb_support; -} EEPRO100State; +}; /* Word indices in EEPROM. */ typedef enum { @@ -2055,43 +2067,55 @@ static Property e100_properties[] = { DEFINE_PROP_END_OF_LIST(), }; -static void eepro100_class_init(ObjectClass *klass, void *data) +static void eepro100_base_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); E100PCIDeviceInfo *info; - info = eepro100_get_class_by_name(object_class_get_name(klass)); set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); device_class_set_props(dc, e100_properties); - dc->desc = info->desc; k->vendor_id = PCI_VENDOR_ID_INTEL; k->class_id = PCI_CLASS_NETWORK_ETHERNET; k->romfile = "pxe-eepro100.rom"; k->realize = e100_nic_realize; k->exit = pci_nic_uninit; + + info = eepro100_get_class_by_name(object_class_get_name(klass)); + if (!info) { + /* base class */ + return; + } + dc->desc = info->desc; k->device_id = info->device_id; k->revision = info->revision; k->subsystem_vendor_id = info->subsystem_vendor_id; k->subsystem_id = info->subsystem_id; } +static const TypeInfo eepro100_base_info = { + .name = TYPE_EEPRO100, + .parent = TYPE_PCI_DEVICE, + .abstract = true, + .class_init = eepro100_base_class_init, + .class_size = sizeof(EEPRO100Class), + .instance_size = sizeof(EEPRO100State), + .instance_init = eepro100_instance_init, + .interfaces = (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, +}; + static void eepro100_register_types(void) { - size_t i; - for (i = 0; i < ARRAY_SIZE(e100_devices); i++) { - TypeInfo type_info = {}; - E100PCIDeviceInfo *info = &e100_devices[i]; - - type_info.name = info->name; - type_info.parent = TYPE_PCI_DEVICE; - type_info.class_init = eepro100_class_init; - type_info.instance_size = sizeof(EEPRO100State); - type_info.instance_init = eepro100_instance_init; - type_info.interfaces = (InterfaceInfo[]) { - { INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, + type_register_static(&eepro100_base_info); + + for (size_t i = 0; i < ARRAY_SIZE(e100_devices); i++) { + TypeInfo type_info = { + .name = e100_devices[i].name, + .parent = TYPE_EEPRO100, }; type_register(&type_info); From patchwork Tue Mar 7 07:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 659726 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2245649wrb; Mon, 6 Mar 2023 23:14:28 -0800 (PST) X-Google-Smtp-Source: AK7set/zYkDQiIEpSwTy9ELymeOooHP/7dEQCfGzCfl87giDrumJnaVZWyuCX0cQfwqWyCZq6c4U X-Received: by 2002:a05:6214:2484:b0:56e:c18d:ca79 with SMTP id gi4-20020a056214248400b0056ec18dca79mr26606484qvb.30.1678173267813; Mon, 06 Mar 2023 23:14:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678173267; cv=none; d=google.com; s=arc-20160816; b=E+rnjsAO9DGpRb/YA5WbK7YiOy70IYMSKkZdg3XBHvDH0JC4yyhzxwAaTGQXWAEFx4 h/Av7b7mojWY/BswYwWRZDxQ8nRzqzubB6x2DFCza/htH+dKvbvApmqAVzbKRjnRyuJm KmLXwJdoLTHxObc5hyu3M+XqyYwW1loGqbd/bb21j7sVA1SIasrc97SSadp4jgA/Js3N 99zPvbf9WcjkazE6jOelJWJhF5xxBMryewPqYPoI/5RMzRZlaWV9D45kLvSf2sxz7oma L/Yy3+lcCCZognO1G0uj1URfZBUUqgnMrN/1s4pFHrn1+hYkP7Ywxqocz9qTquBkXoKz bNzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=upOlGMHWjHNNBfJuoRRwinF5pbnBznfwUp5wdi6JWFY=; b=u5iwxGVVnKaiLzxvmH7U7WFAsPBXmYhzbqO+A/z4IxZb5YHPsBbj/fiukfOzBksBpH /+ILn7i3+kQ3qi7xkM1lIToyfnVRkrwaJp6NIOK1y9qpftVY81WEXKoLOt8khMcvCeAd D6oZzHd5aQjw+nRTZfdH0RBN1rIQmpe2NvmBy8ZZG/JfrVKsaDTnFMvt+zC4AISi6DNH +A8VsiWAKdkITt7LiCWAoulv/fh2WaGVmKP9b8wNLdAvRguyiWOXZ5S/0Ex7OKqDySAk jwibtW3ZKuqmPt/anSVDO58PTpVtAq4CDyfajvNP1TMv8/DRI00kgDT+vMo8keDKXhqU GgFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EKzG24Ov; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j18-20020ac85f92000000b003b8685dfa2bsi9474770qta.386.2023.03.06.23.14.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Mar 2023 23:14:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EKzG24Ov; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZRU4-0006HU-6g; Tue, 07 Mar 2023 02:11:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTm-0005mg-Ah for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTg-0005sM-JM for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678173076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=upOlGMHWjHNNBfJuoRRwinF5pbnBznfwUp5wdi6JWFY=; b=EKzG24Ov5DaTFy2RIJrpm24K98V4vZA9VzBjSiYE3UWvB3Lx+61waRNcVqUxoJbEPHUfoN 7RjQ1tWDehj5FvVuj7Vjd2i0WLy20hJXfOHYyMXOnjvMeWdYFhtOAZpr9qcACEzpqRFzcs NBY7vwP7ka/yoPXSa+MfEKYgwWflag4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-533-WmsibDdYMnGDBr5Glnqfww-1; Tue, 07 Mar 2023 02:11:12 -0500 X-MC-Unique: WmsibDdYMnGDBr5Glnqfww-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 292002808E60; Tue, 7 Mar 2023 07:11:12 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3977340C10FA; Tue, 7 Mar 2023 07:11:09 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL 47/51] hw/net/eepro100: Convert reset handler to DeviceReset Date: Tue, 7 Mar 2023 15:08:12 +0800 Message-Id: <20230307070816.34833-48-jasowang@redhat.com> In-Reply-To: <20230307070816.34833-1-jasowang@redhat.com> References: <20230307070816.34833-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang --- hw/net/eepro100.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 4b5d455..722fb55 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -486,8 +486,9 @@ static void eepro100_fcp_interrupt(EEPRO100State * s) } #endif -static void e100_pci_reset(EEPRO100State *s, Error **errp) +static void e100_pci_reset(DeviceState *dev) { + EEPRO100State *s = EEPRO100(dev); E100PCIDeviceInfo *info = eepro100_get_class(s); uint32_t device = s->device; uint8_t *pci_conf = s->dev.config; @@ -1847,18 +1848,11 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) { EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); E100PCIDeviceInfo *info = eepro100_get_class(s); - Error *local_err = NULL; TRACE(OTHER, logout("\n")); s->device = info->device; - e100_pci_reset(s, &local_err); - if (local_err) { - error_propagate(errp, local_err); - return; - } - /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ s->eeprom = eeprom93xx_new(&pci_dev->qdev, EEPROM_SIZE); @@ -2076,6 +2070,7 @@ static void eepro100_base_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); device_class_set_props(dc, e100_properties); + dc->reset = e100_pci_reset; k->vendor_id = PCI_VENDOR_ID_INTEL; k->class_id = PCI_CLASS_NETWORK_ETHERNET; k->romfile = "pxe-eepro100.rom"; From patchwork Tue Mar 7 07:08:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 659731 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2246197wrb; Mon, 6 Mar 2023 23:16:01 -0800 (PST) X-Google-Smtp-Source: AK7set935TINngjIpe3BBRj7SPCwpSMgwR5qDodBCADqJMlZwWE/2YsFNKsVWWo+/PCgVpegHx50 X-Received: by 2002:a05:6214:2681:b0:56e:af8a:a85b with SMTP id gm1-20020a056214268100b0056eaf8aa85bmr24091200qvb.7.1678173361154; Mon, 06 Mar 2023 23:16:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678173361; cv=none; d=google.com; s=arc-20160816; b=npDZk84dZWGACBAhHecyve69rKJ95fAujR9ICkcSqQHhelmcLB3FYhRSi5qi6LHLJM mt/2Y8fvO7i8oiAZC8okid/jhW0rEBsrLWkb/falbA6wdD2aiGk0HybSfYwyQKxxNPFE je9swm0eAd9ivvV0GiAQUyXWRhbhSFV2muJrrI8hZ3HWpvOCSWCbjqW/7IHdxOd4ezAM r/lKWEvFsv/Dyxb3YJ4Y0Hi5K7moPmG0F3vMf8jbu+Q3mJr3BgMb8/qnF/DQHEdxsoFw eT5tG/x7EtIlFNOjzQV39CMIL4CQOb6GWkMZvEhVVvlfEIXuRMXvJxSjI3NzxHvQj642 vI8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=orfRvQD16z46Lzfsgv60vvB0123u5ES8okmizwx/Ha8=; b=hLtobPdeo/Clv/2+hgUzIUR+9Gep0/iTTHfJDwucaYE+kzrdDQcElC35X1IrgqJCU9 fwAgbAwNjD4imX+8zN8n7nLetKISRTqBbFYcKSMRNQhfrBDtIx8KStMluXXqVt9FeKye gXkjO+mwSdiNo/R/1gDGTp+xz9Ca5jm+uo8Iea1KeaefZSXAck/rQp980EdLINBQ3DRy A+WQfgMDMI6MIyukO0rSlwUdApCCGWRB9nAxHHeZWgYm2Kf7YHGpL4qSLkRohDtBGN+g aUg7UaWTPJUuCaBr6972GfeA2DSWEg5669ExGHNdnesw5SemCbkgqyG6x9tQo5RhX6Ox DGnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aE+61bMU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x2-20020a0cb202000000b0056bfa655111si9301957qvd.27.2023.03.06.23.16.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Mar 2023 23:16:01 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aE+61bMU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZRU5-0006Ka-Cz; Tue, 07 Mar 2023 02:11:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTm-0005mm-BX for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTj-0005si-H6 for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678173078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=orfRvQD16z46Lzfsgv60vvB0123u5ES8okmizwx/Ha8=; b=aE+61bMU4a7MotvmjkAQM2IbxF9QArjGzEvKPG1qoxq+lMb0WoK10he1VV8XJXTXirkqH7 Pf//W68FBy96i6lmRGdsmItzOClp4iPGURFKmD3+ueXnsLDHe4z1LHwVqD09MzEfoLo8CL e1+IbyeRANy6XxC9KyT2qUWhomqM+8M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-618-Lo0U6cqoMxuSY4C6PLmnMg-1; Tue, 07 Mar 2023 02:11:15 -0500 X-MC-Unique: Lo0U6cqoMxuSY4C6PLmnMg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C43B287B2A3; Tue, 7 Mar 2023 07:11:14 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6E4040C1106; Tue, 7 Mar 2023 07:11:12 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL 48/51] hw/net/eepro100: Pass E100PCIDeviceInfo as class init data Date: Tue, 7 Mar 2023 15:08:13 +0800 Message-Id: <20230307070816.34833-49-jasowang@redhat.com> In-Reply-To: <20230307070816.34833-1-jasowang@redhat.com> References: <20230307070816.34833-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé QOM already provides the TypeInfo::class_data to set class-specific data. Use it instead of reinventing the wheel with eepro100_get_class_by_name(). This finishes the QDev conversion started 12 years ago in commit 40021f0888 ("pci: convert to QEMU Object Model"). Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang --- hw/net/eepro100.c | 63 ++++++++++++++++++------------------------------------- 1 file changed, 20 insertions(+), 43 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 722fb55..ab20558 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -242,6 +242,8 @@ struct EEPRO100Class { /*< private >*/ PCIDeviceClass parent_class; /*< public >*/ + + const E100PCIDeviceInfo *info; }; struct EEPRO100State { @@ -338,8 +340,6 @@ static const uint16_t eepro100_mdi_mask[] = { 0xffff, 0xffff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; -static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s); - /* Read a 16 bit control/status (CSR) register. */ static uint16_t e100_read_reg2(EEPRO100State *s, E100RegisterOffset addr) { @@ -489,8 +489,9 @@ static void eepro100_fcp_interrupt(EEPRO100State * s) static void e100_pci_reset(DeviceState *dev) { EEPRO100State *s = EEPRO100(dev); - E100PCIDeviceInfo *info = eepro100_get_class(s); - uint32_t device = s->device; + EEPRO100Class *ek = EEPRO100_GET_CLASS(s); + const E100PCIDeviceInfo *info = ek->info; + uint32_t device = info->device; uint8_t *pci_conf = s->dev.config; TRACE(OTHER, logout("%p\n", s)); @@ -1847,11 +1848,11 @@ static NetClientInfo net_eepro100_info = { static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) { EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); - E100PCIDeviceInfo *info = eepro100_get_class(s); + EEPRO100Class *ek = EEPRO100_GET_CLASS(s); TRACE(OTHER, logout("\n")); - s->device = info->device; + s->device = ek->info->device; /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ @@ -2028,32 +2029,19 @@ static E100PCIDeviceInfo e100_devices[] = { } }; -static E100PCIDeviceInfo *eepro100_get_class_by_name(const char *typename) +static void eepro100_class_init(ObjectClass *klass, void *data) { - E100PCIDeviceInfo *info = NULL; - int i; - - /* This is admittedly awkward but also temporary. QOM allows for - * parameterized typing and for subclassing both of which would suitable - * handle what's going on here. But class_data is already being used as - * a stop-gap hack to allow incremental qdev conversion so we cannot use it - * right now. Once we merge the final QOM series, we can come back here and - * do this in a much more elegant fashion. - */ - for (i = 0; i < ARRAY_SIZE(e100_devices); i++) { - if (strcmp(e100_devices[i].name, typename) == 0) { - info = &e100_devices[i]; - break; - } - } - assert(info != NULL); - - return info; -} + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + EEPRO100Class *ek = EEPRO100_CLASS(klass); + const E100PCIDeviceInfo *info = data; -static E100PCIDeviceInfo *eepro100_get_class(EEPRO100State *s) -{ - return eepro100_get_class_by_name(object_get_typename(OBJECT(s))); + dc->desc = info->desc; + k->device_id = info->device_id; + k->revision = info->revision; + k->subsystem_vendor_id = info->subsystem_vendor_id; + k->subsystem_id = info->subsystem_id; + ek->info = info; } static Property e100_properties[] = { @@ -2065,8 +2053,6 @@ static void eepro100_base_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); - E100PCIDeviceInfo *info; - set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); device_class_set_props(dc, e100_properties); @@ -2076,17 +2062,6 @@ static void eepro100_base_class_init(ObjectClass *klass, void *data) k->romfile = "pxe-eepro100.rom"; k->realize = e100_nic_realize; k->exit = pci_nic_uninit; - - info = eepro100_get_class_by_name(object_class_get_name(klass)); - if (!info) { - /* base class */ - return; - } - dc->desc = info->desc; - k->device_id = info->device_id; - k->revision = info->revision; - k->subsystem_vendor_id = info->subsystem_vendor_id; - k->subsystem_id = info->subsystem_id; } static const TypeInfo eepro100_base_info = { @@ -2111,6 +2086,8 @@ static void eepro100_register_types(void) TypeInfo type_info = { .name = e100_devices[i].name, .parent = TYPE_EEPRO100, + .class_init = eepro100_class_init, + .class_data = (void *)&e100_devices[i], }; type_register(&type_info); From patchwork Tue Mar 7 07:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 659727 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2245803wrb; Mon, 6 Mar 2023 23:14:56 -0800 (PST) X-Google-Smtp-Source: AK7set990p+SpBaHFqZR64UGwdM/HrNnNf68gnBSeUz/kSdTVzkIAVRXYxtCoYL0fbRc8mr6BKxn X-Received: by 2002:a05:622a:1aa4:b0:3bd:156f:6666 with SMTP id s36-20020a05622a1aa400b003bd156f6666mr23973651qtc.26.1678173296512; Mon, 06 Mar 2023 23:14:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678173296; cv=none; d=google.com; s=arc-20160816; b=LGhUqENZcDR66QGRmAjYcaHb73DybrdeHJTAFFtk7LOuAZ1mehCaeJhVhmdM1DLH9z qrmq+hw+OcUZfWOkATGJNokroGelAAQGg/Z1NQNakiPc5nEpoa5Gmug8ZyoBB7Jut8EX /4ewAZEUL9J7f5I2LZMjpLmJiEfcHhooCPKIcY84yiTskaGHJ1AZI4Ns58/fMOhWI9Zy mDjnoJBcR8O5xMdqbnfqZxAUpxzg3HhWpVbWJWx9Os8bEouqwhzBgPVxk7sOPfSR5p7n BLrzh+tFTnIumOSh14vHDsgjlIcQ1W7Ylaa5ewqdPQKsQPB768fqSEZ6JmFapH630AU8 5uWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BLatR455SQenKyYVpWh240L3nFv0DcBK5c+gRwnaS90=; b=wFe/pxz+3/wTrO9D83xZ7Ry3lBqmndRQFy362T/vBzF+dYQA7P3rYTRYfBCBzGc0bX nsfhzwK9J+h/D/r0XtqudRAzBkTSycNIZwhqttwuUPjvqqRBAivUDjQOSA+GMQZCCw2U dTklCv3zK3J6xwCgWwfVZR0bAwI1RCZmN/tDX9iLm5j3wiDIys2pYcoQdNBEr6coBGdb HL7w25Wlq2IRHkj7le5hrspaj8pRXksfxHVZSoj3sSPGBoaK08VsixBZLXqHq0DT+kr1 +XQwJ++GV3B7i/sohlIijMWWhVj8vWSsNHed0c9wWX2rGE2a73JQwYWs/jV7EwcJ141u ERVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="bhiKQV8/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e16-20020ac85dd0000000b003bfa09edb7csi9125645qtx.633.2023.03.06.23.14.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Mar 2023 23:14:56 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="bhiKQV8/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZRUT-0006zH-D2; Tue, 07 Mar 2023 02:12:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTn-0005nl-Qz for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTm-0005ss-7y for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678173081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BLatR455SQenKyYVpWh240L3nFv0DcBK5c+gRwnaS90=; b=bhiKQV8/W7NQahjZdRJv8TEZWWt3PbHfIuOhSJvy/gvU6Jq6SzAkquoIXk3VLPxhwxQeoz YvDMBCorOixTK5YHz1urq1X2Z5bGzUm17dw8JXP7Ca1QK/fnWxprnJ443Hxc6w63yh/hln c0c7o2OV7vauK5KDj1p+BhYEP5WBVgM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-649-2QLa0Ci8M82W98dJh4-tUg-1; Tue, 07 Mar 2023 02:11:17 -0500 X-MC-Unique: 2QLa0Ci8M82W98dJh4-tUg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6397B85A588; Tue, 7 Mar 2023 07:11:17 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BE6440C10FA; Tue, 7 Mar 2023 07:11:15 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL 49/51] hw/net/eepro100: Remove instance EEPRO100State::has_extended_tcb_support Date: Tue, 7 Mar 2023 15:08:14 +0800 Message-Id: <20230307070816.34833-50-jasowang@redhat.com> In-Reply-To: <20230307070816.34833-1-jasowang@redhat.com> References: <20230307070816.34833-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé 'has_extended_tcb_support' is accessed read-only and is present in the class definition. No need to duplicate it in the instance state. Directly access the class field. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang --- hw/net/eepro100.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index ab20558..d775790 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -292,7 +292,6 @@ struct EEPRO100State { /* Quasi static device properties (no need to save them). */ uint16_t stats_size; - bool has_extended_tcb_support; }; /* Word indices in EEPROM. */ @@ -511,7 +510,6 @@ static void e100_pci_reset(DeviceState *dev) pci_set_byte(pci_conf + PCI_MAX_LAT, 0x18); s->stats_size = info->stats_size; - s->has_extended_tcb_support = info->has_extended_tcb_support; switch (device) { case i82550: @@ -746,6 +744,8 @@ static void read_cb(EEPRO100State *s) static void tx_command(EEPRO100State *s) { + EEPRO100Class *ek = EEPRO100_GET_CLASS(s); + const E100PCIDeviceInfo *info = ek->info; const MemTxAttrs attrs = MEMTXATTRS_UNSPECIFIED; uint32_t tbd_array = s->tx.tbd_array_addr; uint16_t tcb_bytes = s->tx.tcb_bytes & 0x3fff; @@ -782,7 +782,7 @@ static void tx_command(EEPRO100State *s) uint16_t tx_buffer_size; uint16_t tx_buffer_el; - if (s->has_extended_tcb_support && !(s->configuration[6] & BIT(4))) { + if (info->has_extended_tcb_support && !(s->configuration[6] & BIT(4))) { /* Extended Flexible TCB. */ for (; tbd_count < 2; tbd_count++) { ldl_le_pci_dma(&s->dev, tbd_address, &tx_buffer_address, attrs); From patchwork Tue Mar 7 07:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 659730 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2246097wrb; Mon, 6 Mar 2023 23:15:42 -0800 (PST) X-Google-Smtp-Source: AK7set93X+uNkWJdQEKuQrZOuwK1oFEFPwqK7NFQESpQe27ueWaIcGM5ljLtuiBM+AzK6arJUoJc X-Received: by 2002:ac8:5748:0:b0:3bd:16cf:2f10 with SMTP id 8-20020ac85748000000b003bd16cf2f10mr22093695qtx.35.1678173341956; Mon, 06 Mar 2023 23:15:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678173341; cv=none; d=google.com; s=arc-20160816; b=uGmS43HJwqyQ81Ks3kgRPewe3PutNN91NTeitZL/bSZmsEskddXrOn1XN237Nmmyfj p0rFYzNmQBYvYXOemLyrXmN1w8LkyCGAD9izJ23Ey52t6HgQitn8lneE3naz3jmTRz7T OKuJXtinvKU6WEhCFptapCfgCqwFGmcSZDbKAWdUfU/1Qz6k30ExzlQS3V7xhWTgNXSA 17s5c2bZzlBf/oChQ/W4nuCkWUThQXd3WxQu1mdB2QJh3OknxjZ9xHkKYD9yT5VaSPH6 pWF7sxoS5USLFIRII7xcgg9b6E8pHrGZ+nu1OvxE7X8N1GUvK/4oEDt13zLQW9HVBOLk 2gKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JcyiYnvGgawhqpXMi/hKtFZZl6mKyXeQycfGfT+K0ZQ=; b=wuJ9Fj+nxLGnc7Ys3jiaj7OUej7XH70wst4CpV+prH+e8yNZrE3GzAO++gFHV+ojQY y+NlyMtIvT1X6BInIXchVm7z6U7gs7/9B9zo00aLeJkOtzO70RfXuGYC0ptpgwt5sYN1 /GTFwq6V5cJDIYeHE3gl6qPNnunzLQfaFVYHyvr8jo8semACPmHCbmTFxAr0kNpwjxXL iaNvzOLN5goeGjPmZ2EQO+o8QSXmo+dcGzQmoHr3oq88RcruTEtCKFSBTcBLXG8BEr/6 UAp8yRQA8JbpaDXIoGUDGX3gS4QEK7GUuU4aeY5p1x5m53uGTCP3YsqZjh1h79T1IxnF 017Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jLH6a5SA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h13-20020ac85e0d000000b003b9b6686babsi227721qtx.271.2023.03.06.23.15.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Mar 2023 23:15:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jLH6a5SA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZRUM-0006ma-Gh; Tue, 07 Mar 2023 02:11:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTo-0005nz-1C for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:30 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTm-0005t4-8h for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678173081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JcyiYnvGgawhqpXMi/hKtFZZl6mKyXeQycfGfT+K0ZQ=; b=jLH6a5SAPZZdPaK6sLXRt6ImW5g40ldogdlwm6L28V27GapHNlP3PAh9Nd/m7++9yjHK6q LFAeYTVA0X28PIgRZw+dLEVNw4LwOWJGRbLN3ZwAEigos/2ds7E1q47s1k49yp59zV78do jCbOeCIuXDjmyq36xo2LZWJcN8z2Xuw= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-q1kpXDBvPrKD7vJS7TzUjw-1; Tue, 07 Mar 2023 02:11:20 -0500 X-MC-Unique: q1kpXDBvPrKD7vJS7TzUjw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 07A0B1C08968; Tue, 7 Mar 2023 07:11:20 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F82F40C10FA; Tue, 7 Mar 2023 07:11:17 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL 50/51] hw/net/eepro100: Remove instance's EEPRO100State::device Date: Tue, 7 Mar 2023 15:08:15 +0800 Message-Id: <20230307070816.34833-51-jasowang@redhat.com> In-Reply-To: <20230307070816.34833-1-jasowang@redhat.com> References: <20230307070816.34833-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.129.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé 'device' is accessed read-only and is present in the class definition. No need to duplicate it in the instance state. Directly access the class field. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang --- hw/net/eepro100.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index d775790..bce3776 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -263,7 +263,6 @@ struct EEPRO100State { /* region must not be saved by nic_save. */ uint16_t mdimem[32]; eeprom_t *eeprom; - uint32_t device; /* device variant */ /* (cu_base + cu_offset) address the next command block in the command block list. */ uint32_t cu_base; /* CU base address */ uint32_t cu_offset; /* CU address offset */ @@ -591,6 +590,9 @@ static void e100_pci_reset(DeviceState *dev) static void nic_selective_reset(EEPRO100State * s) { + EEPRO100Class *ek = EEPRO100_GET_CLASS(s); + const E100PCIDeviceInfo *info = ek->info; + size_t i; uint16_t *eeprom_contents = eeprom93xx_data(s->eeprom); #if 0 @@ -598,8 +600,9 @@ static void nic_selective_reset(EEPRO100State * s) #endif memcpy(eeprom_contents, s->conf.macaddr.a, 6); eeprom_contents[EEPROM_ID] = EEPROM_ID_VALID; - if (s->device == i82557B || s->device == i82557C) + if (info->device == i82557B || info->device == i82557C) { eeprom_contents[5] = 0x0100; + } eeprom_contents[EEPROM_PHY_ID] = 1; uint16_t sum = 0; for (i = 0; i < EEPROM_SIZE - 1; i++) { @@ -1794,7 +1797,7 @@ static const VMStateDescription vmstate_eepro100 = { VMSTATE_UNUSED(19*4), VMSTATE_UINT16_ARRAY(mdimem, EEPRO100State, 32), /* The eeprom should be saved and restored by its own routines. */ - VMSTATE_UINT32(device, EEPRO100State), + VMSTATE_UNUSED(sizeof(uint32_t)), /* was device variant */ /* TODO check device. */ VMSTATE_UINT32(cu_base, EEPRO100State), VMSTATE_UINT32(cu_offset, EEPRO100State), @@ -1848,12 +1851,9 @@ static NetClientInfo net_eepro100_info = { static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) { EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); - EEPRO100Class *ek = EEPRO100_GET_CLASS(s); TRACE(OTHER, logout("\n")); - s->device = ek->info->device; - /* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ s->eeprom = eeprom93xx_new(&pci_dev->qdev, EEPROM_SIZE); From patchwork Tue Mar 7 07:08:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 659728 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2245989wrb; Mon, 6 Mar 2023 23:15:22 -0800 (PST) X-Google-Smtp-Source: AK7set+8KeoFil4phoKlLKFoFPRUDGcpjAg+wgR8t0EjKOPuyTfYEdov43kzZoenI7Fe2Xx8Tanp X-Received: by 2002:ac8:5c83:0:b0:3a8:e35:258f with SMTP id r3-20020ac85c83000000b003a80e35258fmr24146321qta.31.1678173322719; Mon, 06 Mar 2023 23:15:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678173322; cv=none; d=google.com; s=arc-20160816; b=Q/s1/QQi0H+4Nw134ZSXzK8ycpoqSUj5GtXePikVY3i3kkQwBXyNGA1ttp/NxgJQex MMvY8E1aXOIItTFJJ+ktOMcq/mdStuDAfNDOB8r+aZon+r6hpkuLSejUiOnYgq5RGbh7 6/hfWFoiJz0cvmrethIerlvMjjXir/pJ6SSHWQ1ZBiyVyd3G5kxnraFfocobC//Cgx5M +S8Bc+SWMIfzsYATmlLzVFfCRaTuZZMTCIBBKm0iq1VGWK2jD78DiAs6E2kaY7NfHl7Q 7U/qnMBlcxHNjZVQbi9Q2T92nbMdYLpkgu9hmDuq56HWwGsL0FhK3FnDeHOL3QjcxINy 3OMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HLLjG5kOCNoyaewDXrK36oNt9Rl+dEqttWCJ+eMA080=; b=zFf7YFvCexJKH0wXANd9t8kjeX3FnYdcVXgvWyo1WCCp40w8VyeCQy0nDPN2dOQyCJ XE2qnhVMwGstLXtHHHhEh/wDiYLVW2Ef3+qJD+2bnC8zMKi81S6fUsTUjj3Yb0cQWWZ0 tSHoEdlYtd5oK8FWCmA7Ujyt6yCEaehF5c4jav6O2AZClRbhqjW9xTh0ovYcaZP9CCj7 rk/IqipECzMAWue8GqnrXdq2/jSTtyAazVPWQW+4yOtAbg0ktzzMcUkMtGH/roPGyMsk dVQBAlmJeGtQ+XEP0mvXJjxzG7zO4VwGtC1Cr/WJli3zaciPnVJDQEhNKYAQo2+nqoWj iOqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cmzzdtZ6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t17-20020a05622a01d100b003bb8704f3dasi9421715qtw.150.2023.03.06.23.15.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Mar 2023 23:15:22 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cmzzdtZ6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZRUK-0006hA-IE; Tue, 07 Mar 2023 02:11:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTr-0005og-Ab for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZRTp-0005tM-Ni for qemu-devel@nongnu.org; Tue, 07 Mar 2023 02:11:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678173084; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HLLjG5kOCNoyaewDXrK36oNt9Rl+dEqttWCJ+eMA080=; b=cmzzdtZ6GUSnjg5LmSBdbXHD49Eu0NZEuYuucy6NE7ndpqRkMchxHhk82ixU04qpKkWRKN 4mcd+XnyfESsp1iqr4DYnR1KItvxxJwU9/GYnYDvTXElfL9/Bsh/MXGz3/WLsKtdz0IL6V KnHZVRBghTYZu49k7r3YGEOliQs4058= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-JpOXkSc7MXatiKaiRnY8tw-1; Tue, 07 Mar 2023 02:11:22 -0500 X-MC-Unique: JpOXkSc7MXatiKaiRnY8tw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9E8612808E62; Tue, 7 Mar 2023 07:11:22 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-78.pek2.redhat.com [10.72.12.78]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA7E8400F8FA; Tue, 7 Mar 2023 07:11:20 +0000 (UTC) From: Jason Wang To: qemu-devel@nongnu.org, peter.maydell@linaro.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Jason Wang Subject: [PULL 51/51] hw/net/eepro100: Replace DO_UPCAST(EEPRO100State) by EEPRO100() Date: Tue, 7 Mar 2023 15:08:16 +0800 Message-Id: <20230307070816.34833-52-jasowang@redhat.com> In-Reply-To: <20230307070816.34833-1-jasowang@redhat.com> References: <20230307070816.34833-1-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.133.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Use the EEPRO100() QOM type-checking macro to avoid DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Jason Wang --- hw/net/eepro100.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index bce3776..6db15f1 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -1834,7 +1834,7 @@ static const VMStateDescription vmstate_eepro100 = { static void pci_nic_uninit(PCIDevice *pci_dev) { - EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); + EEPRO100State *s = EEPRO100(pci_dev); vmstate_unregister(VMSTATE_IF(&pci_dev->qdev), s->vmstate, s); g_free(s->vmstate); @@ -1850,7 +1850,7 @@ static NetClientInfo net_eepro100_info = { static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) { - EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, pci_dev); + EEPRO100State *s = EEPRO100(pci_dev); TRACE(OTHER, logout("\n")); @@ -1891,7 +1891,7 @@ static void e100_nic_realize(PCIDevice *pci_dev, Error **errp) static void eepro100_instance_init(Object *obj) { - EEPRO100State *s = DO_UPCAST(EEPRO100State, dev, PCI_DEVICE(obj)); + EEPRO100State *s = EEPRO100(obj); device_add_bootindex_property(obj, &s->conf.bootindex, "bootindex", "/ethernet-phy@0", DEVICE(s));