From nobody Thu Dec 18 19:31:18 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=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1617111037; cv=none; d=zohomail.com; s=zohoarc; b=BUJ5C70S/q9lmykfUG0THlVp1UaPIum85ilsZUuR2UdSCg1T7ofDyTzL1uSP2NTWGbaVOhoSDWhDUJJSWNq2/JGqNz0JmHGv4QGfm6M3kcGiCz3Babgl3wF2Vx4P2Va6dSaOhklWaHxhI8g6fceg0PJVFpS2hoh2KWiGo/gQJLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617111037; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bR9eSdSf4qznX0LV24L+tKEZx+CKvg1TgSxkuks1KkM=; b=oLYtRJ67TANUq4IiYFxw6I8kHRt59Z7T6oz6bJ4XUG7Tj4i+mOWOTDWe4q6DQ2PCsvLnhTKoBLjsRsphi+hMxXnapN1SVQNoERdh+vF38825XUDixTI9vu3Vw6C5B35kHCckp4QzwF9kXFy4p0vDR6EvW42/lAUtFnioLCyYdtM= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1617111037837776.352767047613; Tue, 30 Mar 2021 06:30:37 -0700 (PDT) Received: from localhost ([::1]:42238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRES4-0003Sq-GP for importer@patchew.org; Tue, 30 Mar 2021 09:30:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRENf-0006oS-Rm for qemu-devel@nongnu.org; Tue, 30 Mar 2021 09:26:03 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]:45980) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRENb-0003bW-O8 for qemu-devel@nongnu.org; Tue, 30 Mar 2021 09:26:03 -0400 Received: by mail-wr1-x433.google.com with SMTP id j9so14525101wrx.12 for ; Tue, 30 Mar 2021 06:25:59 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id p18sm33140892wrs.68.2021.03.30.06.25.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Mar 2021 06:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bR9eSdSf4qznX0LV24L+tKEZx+CKvg1TgSxkuks1KkM=; b=Mw/LK2+bA1T3fuE+T2rjLweWEJv1Vx3OOyvaUiy9Uxi6X7AcoKS8Pdbj4F+vFwO4Mk +MrL5bbOS39PhttX5WSI3szBDZqPx0RlbjpV0MmcSbjhl4Em3MRHYmXr2jYmuhZ+VLSd E5vMYzh5E9lPuqj0flLWNQ0AUt2aKd+0Iu/EpgZyG2tdxpWDgrxxCLds8eKF9QVF5KSB qlHwB4r97UDYizlwW9FVwUbbCPLaNpSxouH0VHtuWDVsWks2e/Wfda+o0Mwws5sgn0UK wPfKbHUEaw1/Wl2CmXI9riOwN2xGWYSsww2sz8xgOPl5bsuf2D/RfngzJm8oowOwpP+7 4akA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bR9eSdSf4qznX0LV24L+tKEZx+CKvg1TgSxkuks1KkM=; b=YherHVyIU/sVByeDiRt8Y/JrpyUXA3ZU1+wtQDDNRJi1/d4uvsYDL8VpkhT4hcFgVf 5tgbP+ICHF61g37M8ipJVXpI8QBsPp/FydsSIJpfs5Q0MRBgy8p2tWH2KEQc1RvwFCEZ NlwgjGqpT0IFGumSEL+E/OmsIU2kkFcPqU0r/qdLZsuyfCjYDfdJm4WoXu9kVFG6zOlm Tksal5mK3wcoKOGwWFBgSOJCrFaZJcS9nvZU7ZI4KxF3xen2ASQ3p2xmS7EheiLGPq+i yoOAIxmFfQjW8u0m3Xb8XPwku5Ynurc59kNgAnavWyy93BYKf2ZSeHiUJzyb9JrNud5P uLiQ== X-Gm-Message-State: AOAM533uEI64fqsU7PmRpUOmggIrt/WIKZGZ1WxcLyqTGDhqzh9ZsV4B gEwU2zMdy8U9nOy8eRzcZPHWq0e9iDwFV5uY X-Google-Smtp-Source: ABdhPJw/6fCbjS99bQfjmclGM5KfUZEi87MxsINO0zNcGcNhXpOSakhxfffr6xl91nEj99lMzgy89g== X-Received: by 2002:adf:b642:: with SMTP id i2mr33257940wre.8.1617110758101; Tue, 30 Mar 2021 06:25:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 1/5] net/npcm7xx_emc.c: Fix handling of receiving packets when RSDR not set Date: Tue, 30 Mar 2021 14:25:51 +0100 Message-Id: <20210330132555.8144-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210330132555.8144-1-peter.maydell@linaro.org> References: <20210330132555.8144-1-peter.maydell@linaro.org> 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=2a00:1450:4864:20::433; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x433.google.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, 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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" From: Doug Evans Turning REG_MCMDR_RXON is enough to start receiving packets. Signed-off-by: Doug Evans Message-id: 20210319195044.741821-1-dje@google.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/net/npcm7xx_emc.c | 4 +++- tests/qtest/npcm7xx_emc-test.c | 30 +++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/hw/net/npcm7xx_emc.c b/hw/net/npcm7xx_emc.c index 714a742ba7a..7c892f820fb 100644 --- a/hw/net/npcm7xx_emc.c +++ b/hw/net/npcm7xx_emc.c @@ -702,7 +702,9 @@ static void npcm7xx_emc_write(void *opaque, hwaddr offs= et, !(value & REG_MCMDR_RXON)) { emc->regs[REG_MGSTA] |=3D REG_MGSTA_RXHA; } - if (!(value & REG_MCMDR_RXON)) { + if (value & REG_MCMDR_RXON) { + emc->rx_active =3D true; + } else { emc_halt_rx(emc, 0); } break; diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c index 7a281731950..9eec71d87c1 100644 --- a/tests/qtest/npcm7xx_emc-test.c +++ b/tests/qtest/npcm7xx_emc-test.c @@ -492,9 +492,6 @@ static void enable_tx(QTestState *qts, const EMCModule = *mod, mcmdr |=3D REG_MCMDR_TXON; emc_write(qts, mod, REG_MCMDR, mcmdr); } - - /* Prod the device to send the packet. */ - emc_write(qts, mod, REG_TSDR, 1); } =20 static void emc_send_verify1(QTestState *qts, const EMCModule *mod, int fd, @@ -558,6 +555,9 @@ static void emc_send_verify(QTestState *qts, const EMCM= odule *mod, int fd, enable_tx(qts, mod, &desc[0], NUM_TX_DESCRIPTORS, desc_addr, with_irq ? REG_MIEN_ENTXINTR : 0); =20 + /* Prod the device to send the packet. */ + emc_write(qts, mod, REG_TSDR, 1); + /* * It's problematic to observe the interrupt for each packet. * Instead just wait until all the packets go out. @@ -643,13 +643,10 @@ static void enable_rx(QTestState *qts, const EMCModul= e *mod, mcmdr |=3D REG_MCMDR_RXON | mcmdr_flags; emc_write(qts, mod, REG_MCMDR, mcmdr); } - - /* Prod the device to accept a packet. */ - emc_write(qts, mod, REG_RSDR, 1); } =20 static void emc_recv_verify(QTestState *qts, const EMCModule *mod, int fd, - bool with_irq) + bool with_irq, bool pump_rsdr) { NPCM7xxEMCRxDesc desc[NUM_RX_DESCRIPTORS]; uint32_t desc_addr =3D DESC_ADDR; @@ -679,6 +676,15 @@ static void emc_recv_verify(QTestState *qts, const EMC= Module *mod, int fd, enable_rx(qts, mod, &desc[0], NUM_RX_DESCRIPTORS, desc_addr, with_irq ? REG_MIEN_ENRXINTR : 0, 0); =20 + /* + * If requested, prod the device to accept a packet. + * This isn't necessary, the linux driver doesn't do this. + * Test doing/not-doing this for robustness. + */ + if (pump_rsdr) { + emc_write(qts, mod, REG_RSDR, 1); + } + /* Send test packet to device's socket. */ ret =3D iov_send(fd, iov, 2, 0, sizeof(len) + sizeof(test)); g_assert_cmpint(ret, =3D=3D , sizeof(test) + sizeof(len)); @@ -826,8 +832,14 @@ static void test_rx(gconstpointer test_data) =20 qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic"); =20 - emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=3D*/false= ); - emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=3D*/true); + emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=3D*/false, + /*pump_rsdr=3D*/false); + emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=3D*/false, + /*pump_rsdr=3D*/true); + emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=3D*/true, + /*pump_rsdr=3D*/false); + emc_recv_verify(qts, td->module, test_sockets[0], /*with_irq=3D*/true, + /*pump_rsdr=3D*/true); emc_test_ptle(qts, td->module, test_sockets[0]); =20 qtest_quit(qts); --=20 2.20.1