From patchwork Thu Aug 10 09:59:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Furong Xu <0x1207@gmail.com> X-Patchwork-Id: 13349193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59619C001DE for ; Thu, 10 Aug 2023 10:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Y/EwRhdg3rF4TRNTHJTpYTMn6e4av6i3KqsIhc/s34w=; b=N8ihDmijxd+bH6 Gtf/NrYwrpNtOwGNOnIREB152ZDAr8PamWrwC0PKbozGjem/f/my85NwN6WFCk8iZtFDD9NeIbtn+ VKYqM0qxlEsb6JuZD5liGINKG/4IqxQYhFo1Gcznwahc/qhqJu4Vfl2HBex1Zhae47L2aToSc7DKD eT0J/A0fSvwJqZ+azPwxS+MynoPphE+ely6U7TDuPY7xIV/9vOJ2WMdRKzymLeN/lgKJQ3BFsuTxa k7hWbgUUcWMIL5SRjq4149ueyyjRtIJz3mah0X21JnSi6Nw/yjWt8kZ1eRVxfz8U0VAWkkaJWMyHa zQfunijcpYY7oEWIaXmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qU2T0-0073ci-39; Thu, 10 Aug 2023 10:00:30 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qU2Sx-0073ZW-1a for linux-arm-kernel@lists.infradead.org; Thu, 10 Aug 2023 10:00:29 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1bba54f7eefso13238505ad.1 for ; Thu, 10 Aug 2023 03:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691661624; x=1692266424; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bsyKa5hEaaL0qGnptzE/bNHXrwjhSxbRsAekRJz5cRs=; b=NWKV8YebqVS1cHsP70Ml5POWU0s4gl8a6GnoIGML91LNf3M0eX7Hc5Dj4IVCQw7bSf JbebL5aTDZpUuDR/ertqnr0xdxjx/gELAUJAkwqcM3TVVwtNFf/EcKN51AmOMEDeAA1S GF1BFvSoy1zLBEOuTSwKjArsGEdw0W3D6eolVj6rL93e5FRSDeC+RIHnEDoIjMSA1Td/ iukQ9wrG1y/aPF1PRKt/AVthTULVmqndgiRpD9I+fsLGAXdn0RLUnKazL4+I7Q4VEplo On9nW23nfFk8Sh78iFIm6nlX1yhgzgIwV1MfuNcJpAQ6vAK9GyrxNdhu1LsXEAKN1YV6 4WMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691661624; x=1692266424; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bsyKa5hEaaL0qGnptzE/bNHXrwjhSxbRsAekRJz5cRs=; b=CyjB/Ng1CKhG9npZNDdg/hJNqB11W9M7b+evb94p2X9OtV17DVFC42oVJdaoFp3bCs DcNPti3dD3YnhSMOW+i+RpZWrm1nVdP+IxPOR3LxHL5diORJsCYwwCPyyVJsS+gy82+y doWBXxMkCtS3H0iTrx0ERPOq8R3Ru/5owQ8P61BeTiRzWm+69XGSfYc/+zN5txU5WM+6 ePwNIBo5T5cdTj584ATo+QS3GLVZyPWsMtzOrOfS1VZ3rQ40DbDJhHgZvbXzPYOzNWE/ QD/PmlTnX/VEDcQ5oiqoid5daod3e2DYeN8RQdewqicENXm+pKosymlhNAmHKTjbahjT mgkg== X-Gm-Message-State: AOJu0YzVrLOEGyzhmnUUDtDhYiRLkb4faqwn+M1VM1wvLMY8Ok3YtyGl GEIiIebp9J1KrfaHMXSKit0= X-Google-Smtp-Source: AGHT+IGpOVTj+SVU9Si57XPYju4r/bD7x0ZYxVBJQ00aI9Sq/3XAcPzRtCVj4bw0Nwg0v0q1mFJBQg== X-Received: by 2002:a17:90a:a787:b0:268:e3d:1251 with SMTP id f7-20020a17090aa78700b002680e3d1251mr2148307pjq.20.1691661623932; Thu, 10 Aug 2023 03:00:23 -0700 (PDT) Received: from localhost.localdomain ([198.211.45.220]) by smtp.googlemail.com with ESMTPSA id s23-20020a17090a1c1700b00263b4b1255esm3138978pjs.51.2023.08.10.03.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 03:00:23 -0700 (PDT) From: Furong Xu <0x1207@gmail.com> To: "David S. Miller" , Alexandre Torgue , Jose Abreu , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Joao Pinto , Simon Horman Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, xfr@outlook.com, rock.xu@nio.com, Furong Xu <0x1207@gmail.com> Subject: [PATCH 1/1] net: stmmac: dwmac4: extract MAC_HW_Feature regs MSB first Date: Thu, 10 Aug 2023 17:59:29 +0800 Message-Id: <20230810095929.246901-1-0x1207@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230810_030027_528580_EAF673C0 X-CRM114-Status: GOOD ( 12.83 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The bit extraction sequences are a little messy. No code changes, just reorder them. Signed-off-by: Furong Xu <0x1207@gmail.com> --- .../net/ethernet/stmicro/stmmac/dwmac4_dma.c | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c index 84d3a8551b03..3d9e20078193 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c @@ -379,27 +379,27 @@ static int dwmac4_get_hw_feature(void __iomem *ioaddr, { u32 hw_cap = readl(ioaddr + GMAC_HW_FEATURE0); - /* MAC HW feature0 */ - dma_cap->mbps_10_100 = (hw_cap & GMAC_HW_FEAT_MIISEL); - dma_cap->mbps_1000 = (hw_cap & GMAC_HW_FEAT_GMIISEL) >> 1; - dma_cap->half_duplex = (hw_cap & GMAC_HW_FEAT_HDSEL) >> 2; - dma_cap->vlhash = (hw_cap & GMAC_HW_FEAT_VLHASH) >> 4; + /* MAC HW feature0 */ + dma_cap->vlins = (hw_cap & GMAC_HW_FEAT_SAVLANINS) >> 27; dma_cap->multi_addr = (hw_cap & GMAC_HW_FEAT_ADDMAC) >> 18; - dma_cap->pcs = (hw_cap & GMAC_HW_FEAT_PCSSEL) >> 3; - dma_cap->sma_mdio = (hw_cap & GMAC_HW_FEAT_SMASEL) >> 5; - dma_cap->pmt_remote_wake_up = (hw_cap & GMAC_HW_FEAT_RWKSEL) >> 6; - dma_cap->pmt_magic_frame = (hw_cap & GMAC_HW_FEAT_MGKSEL) >> 7; - /* MMC */ - dma_cap->rmon = (hw_cap & GMAC_HW_FEAT_MMCSEL) >> 8; - /* IEEE 1588-2008 */ - dma_cap->atime_stamp = (hw_cap & GMAC_HW_FEAT_TSSEL) >> 12; - /* 802.3az - Energy-Efficient Ethernet (EEE) */ - dma_cap->eee = (hw_cap & GMAC_HW_FEAT_EEESEL) >> 13; /* TX and RX csum */ - dma_cap->tx_coe = (hw_cap & GMAC_HW_FEAT_TXCOSEL) >> 14; dma_cap->rx_coe = (hw_cap & GMAC_HW_FEAT_RXCOESEL) >> 16; - dma_cap->vlins = (hw_cap & GMAC_HW_FEAT_SAVLANINS) >> 27; + dma_cap->tx_coe = (hw_cap & GMAC_HW_FEAT_TXCOSEL) >> 14; + /* 802.3az - Energy-Efficient Ethernet (EEE) */ + dma_cap->eee = (hw_cap & GMAC_HW_FEAT_EEESEL) >> 13; + /* IEEE 1588-2008 */ + dma_cap->atime_stamp = (hw_cap & GMAC_HW_FEAT_TSSEL) >> 12; dma_cap->arpoffsel = (hw_cap & GMAC_HW_FEAT_ARPOFFSEL) >> 9; + /* MMC */ + dma_cap->rmon = (hw_cap & GMAC_HW_FEAT_MMCSEL) >> 8; + dma_cap->pmt_magic_frame = (hw_cap & GMAC_HW_FEAT_MGKSEL) >> 7; + dma_cap->pmt_remote_wake_up = (hw_cap & GMAC_HW_FEAT_RWKSEL) >> 6; + dma_cap->sma_mdio = (hw_cap & GMAC_HW_FEAT_SMASEL) >> 5; + dma_cap->vlhash = (hw_cap & GMAC_HW_FEAT_VLHASH) >> 4; + dma_cap->pcs = (hw_cap & GMAC_HW_FEAT_PCSSEL) >> 3; + dma_cap->half_duplex = (hw_cap & GMAC_HW_FEAT_HDSEL) >> 2; + dma_cap->mbps_1000 = (hw_cap & GMAC_HW_FEAT_GMIISEL) >> 1; + dma_cap->mbps_10_100 = (hw_cap & GMAC_HW_FEAT_MIISEL); /* MAC HW feature1 */ hw_cap = readl(ioaddr + GMAC_HW_FEATURE1); @@ -408,7 +408,6 @@ static int dwmac4_get_hw_feature(void __iomem *ioaddr, dma_cap->av = (hw_cap & GMAC_HW_FEAT_AVSEL) >> 20; dma_cap->tsoen = (hw_cap & GMAC_HW_TSOEN) >> 18; dma_cap->sphen = (hw_cap & GMAC_HW_FEAT_SPHEN) >> 17; - dma_cap->addr64 = (hw_cap & GMAC_HW_ADDR64) >> 14; switch (dma_cap->addr64) { case 0: @@ -424,31 +423,30 @@ static int dwmac4_get_hw_feature(void __iomem *ioaddr, dma_cap->addr64 = 32; break; } - /* RX and TX FIFO sizes are encoded as log2(n / 128). Undo that by * shifting and store the sizes in bytes. */ dma_cap->tx_fifo_size = 128 << ((hw_cap & GMAC_HW_TXFIFOSIZE) >> 6); dma_cap->rx_fifo_size = 128 << ((hw_cap & GMAC_HW_RXFIFOSIZE) >> 0); + /* MAC HW feature2 */ hw_cap = readl(ioaddr + GMAC_HW_FEATURE2); + /* Number of Auxiliary Snapshot Inputs */ + dma_cap->aux_snapshot_n = (hw_cap & GMAC_HW_FEAT_AUXSNAPNUM) >> 28; + /* PPS output */ + dma_cap->pps_out_num = (hw_cap & GMAC_HW_FEAT_PPSOUTNUM) >> 24; /* TX and RX number of channels */ - dma_cap->number_rx_channel = - ((hw_cap & GMAC_HW_FEAT_RXCHCNT) >> 12) + 1; dma_cap->number_tx_channel = ((hw_cap & GMAC_HW_FEAT_TXCHCNT) >> 18) + 1; + dma_cap->number_rx_channel = + ((hw_cap & GMAC_HW_FEAT_RXCHCNT) >> 12) + 1; /* TX and RX number of queues */ - dma_cap->number_rx_queues = - ((hw_cap & GMAC_HW_FEAT_RXQCNT) >> 0) + 1; dma_cap->number_tx_queues = ((hw_cap & GMAC_HW_FEAT_TXQCNT) >> 6) + 1; - /* PPS output */ - dma_cap->pps_out_num = (hw_cap & GMAC_HW_FEAT_PPSOUTNUM) >> 24; - + dma_cap->number_rx_queues = + ((hw_cap & GMAC_HW_FEAT_RXQCNT) >> 0) + 1; /* IEEE 1588-2002 */ dma_cap->time_stamp = 0; - /* Number of Auxiliary Snapshot Inputs */ - dma_cap->aux_snapshot_n = (hw_cap & GMAC_HW_FEAT_AUXSNAPNUM) >> 28; /* MAC HW feature3 */ hw_cap = readl(ioaddr + GMAC_HW_FEATURE3);