From nobody Fri Nov 14 21:03:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1761193041; cv=none; d=zohomail.com; s=zohoarc; b=A+k2nl8dH7t2jWMRLhz0a4Y0mu5b+FOINGfqYSKMGkjZFstjiWiX5ykC1Tm7959JFy5xY0rs7IcnXexHGDfH7vJI3bZ3ly9hYlmy2eSV/Go99piwF4Q5lw0+tRtYbR0SucfgTWcVqVh2i9Lk1tpjn+dQ6HebOPg/AXprM7yXV04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761193041; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DaV098G5oL4FGgdKQrx8xC9vbZLN/Fck1L4/UQZrfQY=; b=gsOHqcQGqQrwqyMtFJbq6yRt1xZ1ALHNUzzoEbkkzsj8vDCgcXlzS3Ur5S+m1mtxLh+Pm/NEDAWZSXjPI1P2heDKkMVNsm8wHR/s5FkDynbho60weSfj3qxMka8gmL1mwP5IOMLHYP0XhHLrO5BTsr7JcirzsMwfOuQfOZA4Upg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176119304139871.36063463933374; Wed, 22 Oct 2025 21:17:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBmjj-0000ni-HC; Thu, 23 Oct 2025 00:15:39 -0400 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 1vBmji-0000nU-Tl for qemu-devel@nongnu.org; Thu, 23 Oct 2025 00:15:38 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vBmjg-0007MO-PR for qemu-devel@nongnu.org; Thu, 23 Oct 2025 00:15:38 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-79ef9d1805fso378590b3a.1 for ; Wed, 22 Oct 2025 21:15:36 -0700 (PDT) Received: from toolbx.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7a274abe5f0sm961640b3a.34.2025.10.22.21.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Oct 2025 21:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761192935; x=1761797735; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DaV098G5oL4FGgdKQrx8xC9vbZLN/Fck1L4/UQZrfQY=; b=AGp0wK1C0bUfotdxSMhUomvKUXr+suL+8TZj57nPommKiNza4G4wFErX/IMDHM0449 WnUGi5HbYIGrYCXNyNSXbx1J3nl8++MV4hK3+gj41DTBfXU37j80izlMIkPQzufvWK94 s2eJikWSNvIsitDBmgGY/Rm6PPeMhQiwm5iuzaIhf5QHccsTyAH3CTie4sbuaUekJ8HL Z+VC24GzORTFH512kg1x4RmsbJVVYwF8SriWvz8n6wnTdINrU64se7hMLGOqGC4kdeqr 9xaWQDL7mjTh+9CT0AsB+2BLIazpNGT9bTdz6KPweb1wNFZzwqp/goxEuqpD0gDirkhJ pq4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761192935; x=1761797735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DaV098G5oL4FGgdKQrx8xC9vbZLN/Fck1L4/UQZrfQY=; b=pVoYFUDuJZuD6XPNQ3vdwZZWLbiwuB7gbbSXryuNQa8gjk4NDZsfFimqdfpayultVt Pulb0Lw4VE4YLQoyzVgRr3VDUxL5K1wp/nD1ma/xgHgffcXHq+GepY8w7R26F+xpuURM c4TeqvXtjJrudeKd5QVp2lGD13d2Zagre2aLZz13oZAkxVSHSu2bsKLDWFmTQZufEHWr ejRDwG+wMvznvWUspNEnDCJ1P6y2tK5p6fPw3h0ORJ5+g/Wi5i5dsxLdqFQmacr3Anf7 VT0OzQr3UXWBLFPQ79CXHj2ukEQeIK6ggQPBxLGusEt08r7ObXwNC4eTUU2xZR+eOhql r5Ww== X-Gm-Message-State: AOJu0Yw8/T4H0hmaDje0eU+f9DgUmQ3kGz0T+r1CDOVey/jzpOqv0jgc Og6EBFZu4kDyxoUrQ+4ST3JORzzCoGRYTAwGc50pFdmd63LOpWji3ep0Ex//Gg== X-Gm-Gg: ASbGncuHnkd1DWprzEiQyd0VrqS1BxKrc1wL0wRkzcmYnoyI/1QW4vfShiPvlfpj0CK +IuWu/xP81n2W0xFkU3MK165CtcuMLYsdzZtCSkRFjCVqbGfxHFwMyZlQe6mB1d6NBOYVLIiY6K Byh5POb72P3c+4fWMswLSVvz5sb+EmYY8v5SH/+MYwL2lpeH0UJ3v7tWvb8OOd78o0Mw658QVJo UHGxN6GCHv1v46OhA3+AwFejXWhKQux0/6jZ8fMS7srUWmvXCJHPndLoxc00tuCpQD8DPbkf2Fy Ai/JVoEC7FVxooA/ZLiHf8zcOf/HzsUsbpvXiKKVidgRUJzwOfGMzKFSERk0qftZK0dckNFKuWN nGUB/4IiQN7wPuOjqlvxR3TZpLxLHFwzQW+99bED78Wo3b852sYxZBi9p9GsauOMQC5YWNXKXal 9zM0N+TN2am9ZhMpnfcQq1CFrEZZkcmqmCKfZYsjlec1xdyid95BHA4qS26bZtr4tTepKNab9Ud emL9u7RHs6sWa5WtpEQ X-Google-Smtp-Source: AGHT+IFUc7zBAuGrOhaEzFmBf6PKJhYtMK5Ma4zNgtwhr1JB1Kmgp1XsmcBjYC4c9hmJSbB6QtWf1A== X-Received: by 2002:a05:6a00:1742:b0:77d:6a00:1cd1 with SMTP id d2e1a72fcca58-7a274ba91e4mr1683937b3a.12.1761192934853; Wed, 22 Oct 2025 21:15:34 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Guenter Roeck , Alistair Francis Subject: [PULL 14/37] hw/net/cadence_gem: Support two Ethernet interfaces connected to single MDIO bus Date: Thu, 23 Oct 2025 14:14:12 +1000 Message-ID: <20251023041435.1775208-15-alistair.francis@wdc.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251023041435.1775208-1-alistair.francis@wdc.com> References: <20251023041435.1775208-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=alistair23@gmail.com; helo=mail-pf1-x429.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1761193043289154100 Content-Type: text/plain; charset="utf-8" From: Guenter Roeck The Microchip PolarFire SoC Icicle Kit supports two Ethernet interfaces. The PHY on each may be connected to separate MDIO busses, or both may be connected on the same MDIO bus using different PHY addresses. To be able to support two PHY instances on a single MDIO bus, two properties are needed: First, there needs to be a flag indicating if the MDIO bus on a given Ethernet interface is connected. If not, attempts to read from this bus must always return 0xffff. Implement this property as phy-connected. Second, if the MDIO bus on an interface is active, it needs a link to the consumer interface to be able to provide PHY access for it. Implement this property as phy-consumer. Signed-off-by: Guenter Roeck Acked-by: Alistair Francis Message-ID: <20251004200049.871646-2-linux@roeck-us.net> Signed-off-by: Alistair Francis --- include/hw/net/cadence_gem.h | 3 +++ hw/net/cadence_gem.c | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/include/hw/net/cadence_gem.h b/include/hw/net/cadence_gem.h index 91ebb5c8ae..21e7319f53 100644 --- a/include/hw/net/cadence_gem.h +++ b/include/hw/net/cadence_gem.h @@ -81,6 +81,9 @@ struct CadenceGEMState { =20 uint8_t phy_loop; /* Are we in phy loopback? */ =20 + bool phy_connected; /* true if connected */ + struct CadenceGEMState *phy_consumer; + /* The current DMA descriptor pointers */ uint32_t rx_desc_addr[MAX_PRIORITY_QUEUES]; uint32_t tx_desc_addr[MAX_PRIORITY_QUEUES]; diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index 44446666de..520324adfd 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -1541,12 +1541,20 @@ static void gem_handle_phy_access(CadenceGEMState *= s) { uint32_t val =3D s->regs[R_PHYMNTNC]; uint32_t phy_addr, reg_num; + CadenceGEMState *ps =3D s; + uint32_t op; =20 phy_addr =3D FIELD_EX32(val, PHYMNTNC, PHY_ADDR); + op =3D FIELD_EX32(val, PHYMNTNC, OP); =20 - if (phy_addr !=3D s->phy_addr) { - /* no phy at this address */ - if (FIELD_EX32(val, PHYMNTNC, OP) =3D=3D MDIO_OP_READ) { + /* Switch phy to consumer interface if there is an address match */ + if (s->phy_consumer && phy_addr =3D=3D s->phy_consumer->phy_addr) { + ps =3D s->phy_consumer; + } + + if (!s->phy_connected || phy_addr !=3D ps->phy_addr) { + /* phy not connected or no phy at this address */ + if (op =3D=3D MDIO_OP_READ) { s->regs[R_PHYMNTNC] =3D FIELD_DP32(val, PHYMNTNC, DATA, 0xffff= ); } return; @@ -1554,14 +1562,14 @@ static void gem_handle_phy_access(CadenceGEMState *= s) =20 reg_num =3D FIELD_EX32(val, PHYMNTNC, REG_ADDR); =20 - switch (FIELD_EX32(val, PHYMNTNC, OP)) { + switch (op) { case MDIO_OP_READ: s->regs[R_PHYMNTNC] =3D FIELD_DP32(val, PHYMNTNC, DATA, - gem_phy_read(s, reg_num)); + gem_phy_read(ps, reg_num)); break; =20 case MDIO_OP_WRITE: - gem_phy_write(s, reg_num, val); + gem_phy_write(ps, reg_num, val); break; =20 default: @@ -1813,6 +1821,10 @@ static const Property gem_properties[] =3D { num_type2_screeners, 4), DEFINE_PROP_UINT16("jumbo-max-len", CadenceGEMState, jumbo_max_len, 10240), + DEFINE_PROP_BOOL("phy-connected", CadenceGEMState, phy_connected, true= ), + DEFINE_PROP_LINK("phy-consumer", CadenceGEMState, phy_consumer, + TYPE_CADENCE_GEM, CadenceGEMState *), + DEFINE_PROP_LINK("dma", CadenceGEMState, dma_mr, TYPE_MEMORY_REGION, MemoryRegion *), }; --=20 2.51.0