From nobody Wed Nov 27 00:28:18 2024 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=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1703021706; cv=none; d=zohomail.com; s=zohoarc; b=SrqnWOJbev6y69EKd0IdyvXxmEM9gjojIIr5ep06hrd6F2rHtA63HBMctxmWFN6VMOe08U1CKdq1X535z3CuZDeMkUCwH0Lw9opOGvEFnCW4jf2zv2rcTyOPfGd/OiMBdm4HtXQ7PUhkuADXHGMboCJBL7FdJ+0FYWmaIN7V5WE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703021706; h=Content-Type: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=6MVv+DDUf69kht4r/Sr+TmqqYgXi1IiKqWHyvJobH2o=; b=X/5Svq4BN6gkQx3Cp1zbaSqvPAZ2V3ITlQpFxooT91yRxCTmcMiIUetUdA2/GIVA3TusiKnhyxdyYIVgQaCKSAz50XtAPWNehbzQWk5V7EFb97dAHW2s89jEKnO+Fq2ScXs3D+gqZiR7xNnwPBBZwth/bMJCttZddKb2Z5H4T5s= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1703021706585129.115250776905; Tue, 19 Dec 2023 13:35:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rFhiw-0007iI-Su; Tue, 19 Dec 2023 16:33: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 <3IgyCZQwKCnUgTUbaXlmXYTgZhhZeX.VhfjXfn-WXoXeghgZgn.hkZ@flex--nabihestefan.bounces.google.com>) id 1rFhiT-0007W8-JM for qemu-devel@nongnu.org; Tue, 19 Dec 2023 16:33:35 -0500 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3IgyCZQwKCnUgTUbaXlmXYTgZhhZeX.VhfjXfn-WXoXeghgZgn.hkZ@flex--nabihestefan.bounces.google.com>) id 1rFhiQ-0003yG-7y for qemu-devel@nongnu.org; Tue, 19 Dec 2023 16:33:27 -0500 Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-dbd633c0653so1010718276.2 for ; Tue, 19 Dec 2023 13:33:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703021602; x=1703626402; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6MVv+DDUf69kht4r/Sr+TmqqYgXi1IiKqWHyvJobH2o=; b=NnmZRHbu+TSbjGI0267KziT1RmuYdFwf8Ti9vrq2amEyGf4cfxjXA7oMzmVOQj5rQB vV+s+yXpDhANwGnWx+Bo5cocXoj18wz8YuL0ofk4i35qAMzbGOUQ+rVHmMitdQ9kqw0O kj+CiI4Iy0ZUtlprVQdEMPthoD2p+ErqrhAZ7HE/+BKT9Pq58EX+c/EYctTdR4Hynv2h pljEokxot8PYGFx7o+NvMGC3cl6X19FLNAvomIDkhD7b3Gg4TW/1W64YfCQL6j1tvgCc zhv4B7j4AorZEF6bifPlmYZmKzZmJvkmmeXPGdpVe0Yzjh+lXV0Yyjd5Tq/3oqzw8WP3 rjcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703021602; x=1703626402; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6MVv+DDUf69kht4r/Sr+TmqqYgXi1IiKqWHyvJobH2o=; b=G/PEGEUqzamei3xL+rVXI1bWJIZ84vc9aOGTXcedru0S4QtkcXXgGPnoY8nMhy898a uwC381TftxcoeSzXOSxj4wuVcdywjoVCxApgsUwQpdBy7AqgGMxQ3KJL3OiozlRU2sS9 hufpaqRnnJJpypmreautFx+eeyGTSPdC1RwaOSkgtgRA+Z6bbyjo+PA7VgH5dvxc0sia VVzeW570cNZ9qN8I39rzHwXAxjsmTaBSpcz6PfO9zZvykfIDlEsb+PHSnfjcsw3SrP4g /JKphtz+A8eJ3KaAszDLUq8Kj/TOphI/H15stunvKuE6j2JqfUqSUoUjDZ0l5leacNrB 9K7Q== X-Gm-Message-State: AOJu0YyRbReNIOMKr3TmyJW5yOCYdxrfvsFQhh76Jp4kdsZ3TpN0kmTl piXoNkE5fYX7V3h3hfAYjp4W+srOxl4KyDHO4+g= X-Google-Smtp-Source: AGHT+IG6x1hgSwBy97LHyLWfy8FNUMZzkYyW3dWtKJn9XcQgpYv0saI+B5MVnvtMx5qGR4zgW0rHiOeZyDG7k/mkjlI= X-Received: from nabihestefan.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:2737]) (user=nabihestefan job=sendgmr) by 2002:a05:6902:134a:b0:dbd:2f0:c763 with SMTP id g10-20020a056902134a00b00dbd02f0c763mr239458ybu.1.1703021602765; Tue, 19 Dec 2023 13:33:22 -0800 (PST) Date: Tue, 19 Dec 2023 21:32:52 +0000 In-Reply-To: <20231219213255.604535-1-nabihestefan@google.com> Mime-Version: 1.0 References: <20231219213255.604535-1-nabihestefan@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231219213255.604535-8-nabihestefan@google.com> Subject: [PATCH v9 07/10] include/hw/net: General GMAC Implementation From: Nabih Estefan To: peter.maydell@linaro.org Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, kfting@nuvoton.com, wuhaotsh@google.com, jasowang@redhat.com, avi.fishman@nuvoton.com, nabihestefan@google.com, kwliu@nuvoton.com, tomer.maimon@nuvoton.com, Hila.Miranda-Kuzi@nuvoton.com 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::b49; envelope-from=3IgyCZQwKCnUgTUbaXlmXYTgZhhZeX.VhfjXfn-WXoXeghgZgn.hkZ@flex--nabihestefan.bounces.google.com; helo=mail-yb1-xb49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable 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 @google.com) X-ZM-MESSAGEID: 1703021708182100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Nabih Estefan Diaz Implemented Classes and Masks for GMAC Descriptors - Implemeted classes for GMAC Receive and Transmit Descriptors - Implemented Masks for said descriptors - General GMAC Register handling - GMAC IRQ Handling Signed-off-by: Nabih Estefan Reviewed-by: Tyrone Ting --- hw/net/npcm_gmac.c | 40 ++++++++++++++++++++++++++++++++++++++++ hw/net/trace-events | 8 ++++++++ 2 files changed, 48 insertions(+) diff --git a/hw/net/npcm_gmac.c b/hw/net/npcm_gmac.c index 98b3c33c94..44c4ffaff4 100644 --- a/hw/net/npcm_gmac.c +++ b/hw/net/npcm_gmac.c @@ -149,6 +149,46 @@ static bool gmac_can_receive(NetClientState *nc) return true; } =20 +/* + * Function that updates the GMAC IRQ + * It find the logical OR of the enabled bits for NIS (if enabled) + * It find the logical OR of the enabled bits for AIS (if enabled) + */ +static void gmac_update_irq(NPCMGMACState *gmac) +{ + /* + * Check if the normal interrupts summary is enabled + * if so, add the bits for the summary that are enabled + */ + if (gmac->regs[R_NPCM_DMA_INTR_ENA] & gmac->regs[R_NPCM_DMA_STATUS] & + (NPCM_DMA_INTR_ENAB_NIE_BITS)) { + gmac->regs[R_NPCM_DMA_STATUS] |=3D NPCM_DMA_STATUS_NIS; + } + /* + * Check if the abnormal interrupts summary is enabled + * if so, add the bits for the summary that are enabled + */ + if (gmac->regs[R_NPCM_DMA_INTR_ENA] & gmac->regs[R_NPCM_DMA_STATUS] & + (NPCM_DMA_INTR_ENAB_AIE_BITS)) { + gmac->regs[R_NPCM_DMA_STATUS] |=3D NPCM_DMA_STATUS_AIS; + } + + /* Get the logical OR of both normal and abnormal interrupts */ + int level =3D !!((gmac->regs[R_NPCM_DMA_STATUS] & + gmac->regs[R_NPCM_DMA_INTR_ENA] & + NPCM_DMA_STATUS_NIS) | + (gmac->regs[R_NPCM_DMA_STATUS] & + gmac->regs[R_NPCM_DMA_INTR_ENA] & + NPCM_DMA_STATUS_AIS)); + + /* Set the IRQ */ + trace_npcm_gmac_update_irq(DEVICE(gmac)->canonical_path, + gmac->regs[R_NPCM_DMA_STATUS], + gmac->regs[R_NPCM_DMA_INTR_ENA], + level); + qemu_set_irq(gmac->irq, level); +} + static ssize_t gmac_receive(NetClientState *nc, const uint8_t *buf, size_t= len) { /* Placeholder. Function will be filled in following patches */ diff --git a/hw/net/trace-events b/hw/net/trace-events index 33514548b8..78efa2ec2c 100644 --- a/hw/net/trace-events +++ b/hw/net/trace-events @@ -473,6 +473,14 @@ npcm_gmac_reg_write(const char *name, uint64_t offset,= uint32_t value) "%s: offs npcm_gmac_mdio_access(const char *name, uint8_t is_write, uint8_t pa, uint= 8_t gr, uint16_t val) "%s: is_write: %" PRIu8 " pa: %" PRIu8 " gr: %" PRIu8= " val: 0x%04" PRIx16 npcm_gmac_reset(const char *name, uint16_t value) "%s: phy_regs[0][1]: 0x%= 04" PRIx16 npcm_gmac_set_link(bool active) "Set link: active=3D%u" +npcm_gmac_update_irq(const char *name, uint32_t status, uint32_t intr_en, = int level) "%s: Status Reg: 0x%04" PRIX32 " Interrupt Enable Reg: 0x%04" PR= IX32 " IRQ Set: %d" +npcm_gmac_packet_desc_read(const char* name, uint32_t desc_addr) "%s: atte= mpting to read descriptor @0x%04" PRIX32 +npcm_gmac_packet_receive(const char* name, uint32_t len) "%s: RX packet le= ngth: 0x%04" PRIX32 +npcm_gmac_packet_receiving_buffer(const char* name, uint32_t buf_len, uint= 32_t rx_buf_addr) "%s: Receiving into Buffer size: 0x%04" PRIX32 " at addre= ss 0x%04" PRIX32 +npcm_gmac_packet_received(const char* name, uint32_t len) "%s: Reception f= inished, packet left: 0x%04" PRIX32 +npcm_gmac_packet_sent(const char* name, uint16_t len) "%s: TX packet sent!= , length: 0x%04" PRIX16 +npcm_gmac_debug_desc_data(const char* name, void* addr, uint32_t des0, uin= t32_t des1, uint32_t des2, uint32_t des3)"%s: Address: %p Descriptor 0: 0x%= 04" PRIX32 " Descriptor 1: 0x%04" PRIX32 "Descriptor 2: 0x%04" PRIX32 " Des= criptor 3: 0x%04" PRIX32 +npcm_gmac_packet_tx_desc_data(const char* name, uint32_t tdes0, uint32_t t= des1) "%s: Tdes0: 0x%04" PRIX32 " Tdes1: 0x%04" PRIX32 =20 # npcm_pcs.c npcm_pcs_reg_read(const char *name, uint16_t indirect_access_baes, uint64_= t offset, uint16_t value) "%s: IND: 0x%02" PRIx16 " offset: 0x%04" PRIx64 "= value: 0x%04" PRIx16 --=20 2.43.0.472.g3155946c3a-goog