From patchwork Mon Dec 10 22:46:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Petr_=C5=A0tetiar?= X-Patchwork-Id: 1010760 X-Patchwork-Delegate: openwrt@kresin.me Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=true.cz Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Fvg0LtbD"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43DJB55txYz9s0t for ; Tue, 11 Dec 2018 09:47:41 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lN1wqmjgStgfMa4ZKDLH1minDecTMb25NkGRfyQqQb0=; b=Fvg0LtbDABEbq7 dDyoVZgV8zagGgIpLe2bg6cLa08WCR78nQD5AJSzMoiOlFiumH2DX4YOCbZgVP5Tt+eH1KycD7xLx nmKeW5rkOWsLVX6R4cDCCH9y5T+GRuktPy08koJ1i4JcWCLMJ4Lf+TqPfx4HLHfX/XJn2QEegoac9 6Pe3ToJmRH/lUvTC/NaRTGS7F4yROQoZ2AKRIDKsAWWSLZtrE8NGdTkqtqKvInpx7gGfzjQOx+CYC tU2/COmdCluvXSPvbF5M9QVO4VxobD6gBQkK8L94yCQbw9MnOX+HqqAGBCAqcxdCh7lfnU3rVCSPc X2qX5l4BZ6N6BNzstFZA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWUKu-0000LJ-6I; Mon, 10 Dec 2018 22:47:36 +0000 Received: from smtp-out.xnet.cz ([178.217.244.18]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWUK6-0007ru-F6 for openwrt-devel@lists.openwrt.org; Mon, 10 Dec 2018 22:46:49 +0000 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id C50614B60; Mon, 10 Dec 2018 23:46:43 +0100 (CET) Received: from localhost.localdomain (localhost [127.0.0.1]) by meh.true.cz (OpenSMTPD) with ESMTP id e4fa7223; Mon, 10 Dec 2018 23:46:42 +0100 (CET) From: =?utf-8?q?Petr_=C5=A0tetiar?= To: openwrt-devel@lists.openwrt.org Date: Mon, 10 Dec 2018 23:46:27 +0100 Message-Id: <1544481988-30032-5-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1544481988-30032-1-git-send-email-ynezz@true.cz> References: <1544481988-30032-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181210_144646_678508_DC762E6B X-CRM114-Status: GOOD ( 12.50 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [178.217.244.18 listed in list.dnswl.org] Subject: [OpenWrt-Devel] [PATCH 4/5] ath79: ag71xx: Ensure that appending of CRC to frames is always disabled X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Petr_=C5=A0tetiar?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org There seems to be some strange behaviour between snapshot ar71xx and ath79 kernels on Nanostation M5 XW where each kernel has different init values in ag71xx_probe: ar71xx: (running r8651-452b840) ( boot ) eth%d: mac_cfg1=00000000, mac_cfg2=00007000, ipg=40605060, hdx=00a1f037, mfl=00000600 ( ag71xx_hw_setup ) eth%d: mac_cfg1=0000000f, mac_cfg2=00007014, ipg=40605060, hdx=00a1f037, mfl=00000000 ath79: (running r8651-452b840) ( boot ) eth%d: mac_cfg1=0000000f, mac_cfg2=00007117, ipg=40605060, hdx=00a1f037, mfl=00000600 ( ag71xx_hw_setup ) eth%d: mac_cfg1=0000000f, mac_cfg2=00007117, ipg=40605060, hdx=00a1f037, mfl=00000000 Note the boot/init values of AG71XX_REG_MAC_CFG2 on ar71xx and ath79. On ar71xx we've the cfg2=0x7000 after the boot, which corresponds to the state in the datasheet, but on ath79 it's set to 0x7117 which unfortunately enables CRC in the frames, making the networking disfuctional on Nanostation M5 XW. This is happening on the same hardware, same U-Boot, network setup etc. the only difference in the mix are the kernels. So the fix seems to be always clearing the MAC_CFG2_CRC_EN bit in AG71XX_REG_MAC_CFG2 upon boot. I don't want to fix it by writing init/reset value of 0x7000 to AG71XX_REG_MAC_CFG2 as it's being done with AG71XX_REG_MAC_CFG1 register, since I only have datasheet for ar9344 so I don't know what this forced 0x7000 initial value might cause on other ar934x SoCs. Tested-by: Joe Ayers Signed-off-by: Petr Štetiar --- .../ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c index 70ca024..0ca0d18 100644 --- a/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c +++ b/target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c @@ -425,14 +425,18 @@ static void ag71xx_hw_setup(struct ag71xx *ag) { struct device_node *np = ag->pdev->dev.of_node; u32 init = MAC_CFG1_INIT; + u32 cfg2; /* setup MAC configuration registers */ if (of_property_read_bool(np, "flow-control")) init |= MAC_CFG1_TFC | MAC_CFG1_RFC; ag71xx_wr(ag, AG71XX_REG_MAC_CFG1, init); - ag71xx_sb(ag, AG71XX_REG_MAC_CFG2, - MAC_CFG2_PAD_CRC_EN | MAC_CFG2_LEN_CHECK); + /* ensure that CRC is disabled and not appended to frames */ + cfg2 = ag71xx_rr(ag, AG71XX_REG_MAC_CFG2); + cfg2 &= ~(MAC_CFG2_CRC_EN); + cfg2 |= MAC_CFG2_PAD_CRC_EN | MAC_CFG2_LEN_CHECK; + ag71xx_wr(ag, AG71XX_REG_MAC_CFG2, cfg2); /* setup max frame length to zero */ ag71xx_wr(ag, AG71XX_REG_MAC_MFL, 0);