From mboxrd@z Thu Jan 1 00:00:00 1970 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 smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.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 159EEC77B72 for ; Fri, 14 Apr 2023 12:32:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 92E32400F1; Fri, 14 Apr 2023 12:32:38 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 92E32400F1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1681475558; bh=4sIonJ+a/uKNvZ21EJ3IR4/ns6mpes59HkLt2HS6/Cw=; h=From:To:Date:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=nFypUgTYJIQF4voW4HTATMq6S6HY+OTMg+99klq2lm8OlgY6eHZTW3vtWhe9tmyEv 1RaAVPrEss1qeb0hBBnqOEYiASVCyESKom2yokIKdMXKM1j6vkLSJXQLpy5k+7wkki B6GqIFvsWXqn7ATdQnT3/QsS5CP9Sd7RPuDOXE6O1lPL2K6/wJejci8vr1e0S2EeUt mjjcXEy2m236ljwqirQpCPMuIsTy3Lfg40DT4AIbolw5VFclU0pW5T1N9XqKDpL2S7 fEvueRfiI+HQ7vbKK0o23zwXRRgAHKaYuux3O83hoUtMV9IWJZH0K8XDX1CblR5Gez Re98+3vwyY1RA== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L9xuoZRQTQS1; Fri, 14 Apr 2023 12:32:37 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id ACCC442B1E; Fri, 14 Apr 2023 12:32:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org ACCC442B1E Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 070211C3EA9 for ; Fri, 14 Apr 2023 12:32:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D2490842C8 for ; Fri, 14 Apr 2023 12:32:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D2490842C8 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id art3ZFauMWFr for ; Fri, 14 Apr 2023 12:32:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 3AF9A8434F Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3AF9A8434F for ; Fri, 14 Apr 2023 12:32:34 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-185-VqRPGaRUPQWesYHLYOoMpg-1; Fri, 14 Apr 2023 13:32:30 +0100 X-MC-Unique: VqRPGaRUPQWesYHLYOoMpg-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 14 Apr 2023 13:32:27 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Fri, 14 Apr 2023 13:32:27 +0100 From: David Laight To: "'Song, Yoong Siang'" , Jesper Dangaard Brouer , "Brandeburg, Jesse" , "Nguyen, Anthony L" , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , "Jesper Dangaard Brouer" , John Fastabend , "Fijalkowski, Maciej" , Vedang Patel , "Joseph, Jithu" , "Andre Guedes" , Stanislav Fomichev , "Keller, Jacob E" Thread-Topic: [PATCH net v2 1/1] igc: read before write to SRRCTL register Thread-Index: AQHZbnY42u7Gz9ET40eYzbfYWKvVVq8qkCGAgAAQJMCAABqMIA== Date: Fri, 14 Apr 2023 12:32:27 +0000 Message-ID: <4dc9ea6c77ff49138a49d7f73f7301fd@AcuMS.aculab.com> References: <20230414020915.1869456-1-yoong.siang.song@intel.com> <8214fb10-8caa-4418-8435-85b6ac27b69e@redhat.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Subject: Re: [Intel-wired-lan] [PATCH net v2 1/1] igc: read before write to SRRCTL register X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "xdp-hints@xdp-project.net" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , "intel-wired-lan@lists.osuosl.org" , "Brouer, Jesper" , "bpf@vger.kernel.org" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" From: Song, Yoong Siang > Sent: 14 April 2023 12:16 ... > >I have checked Foxville manual for SRRCTL (Split and Replication Receive > >Control) register and below GENMASKs looks correct. > > > >> -#define IGC_SRRCTL_BSIZEPKT_SHIFT 10 /* Shift _right_ */ > >> -#define IGC_SRRCTL_BSIZEHDRSIZE_SHIFT 2 /* Shift _left_ */ > >> +#define IGC_SRRCTL_BSIZEPKT_MASK GENMASK(6, 0) > >> +#define IGC_SRRCTL_BSIZEPKT_SHIFT 10 /* Shift _right_ */ > > > >Shift due to 1 KB resolution of BSIZEPKT (manual field BSIZEPACKET) > > Ya, 1K = BIT(10), so need to shift right 10 bits. I bet the code would be easier to read if it did 'value / 1024u'. The object code will be (much) the same. > >> +#define IGC_SRRCTL_BSIZEHDRSIZE_MASK GENMASK(13, 8) > >> +#define IGC_SRRCTL_BSIZEHDRSIZE_SHIFT 2 /* Shift _left_ */ > > > >This shift is suspicious, but as you inherited it I guess it works. > >I did the math, and it happens to work, knowing (from manual) value is in 64 bytes > >resolution. > > It is in 64 = BIT(6) resolution, so need to shift right 6 bits. > But it start on 8th bit, so need to shift left 8 bits. > Thus, total = shift left 2 bits. > > I dint put the explanation into the header file because it is too lengthy > and user can know from databook. > > How do you feel on the necessary of explaining the shifting logic? Not everyone trying to grok the code will have the manual. Even writing (8 - 6) will help. Or (I think) if the value is in bits 13-8 in units of 64 then just: ((value >> 8) & 0x1f) * 64 gcc will do a single shift right and a mask 9at some point). You might want some defines, but if they aren't used much just comments that refer to the names in the manual/datasheet can be enough. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan