devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Simon Horman <horms@kernel.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	davem@davemloft.net, Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Richard Cochran <richardcochran@gmail.com>,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	Stefan Wahren <wahrenst@gmx.net>
Subject: Re: [net-next v4 4/5] net: mtip: The L2 switch driver for imx287
Date: Fri, 11 Apr 2025 14:54:30 +0200	[thread overview]
Message-ID: <20250411145430.3001f1db@wsk> (raw)
In-Reply-To: <20250409162854.069abe88@wsk>

[-- Attachment #1: Type: text/plain, Size: 2261 bytes --]

Hi Simon,

> > It is unclear why hwentry, which is a pointer, is being cast to an
> > integer and then back to a pointer. I see pointer arithmetic, but
> > that can operate on pointers just as well as integers, without
> > making assumptions about how wide pointers are with respect to
> > longs.
> > 
> > And in any case, can't the types be used to directly access the
> > offsets needed like this?
> > 
> > 	atable = fep->hwentry.mtip_table64b_entry;
> > 
> > 	*read_lo = readl(&atable[index].lo);
> > 	*read_hi = readl(&atable[index].hi);
> >   
> 
> The code as is seems to be OK.
> 
> The (atable) memory structure is as follows:
> 
> 1. You can store 2048 MAC addresses (2x32 bit each).
> 
> 2. Memory from point 1 is addressed as follows:
> 	2.1 -> from MAC address the CRC8 is calculated (0x00 - 0xFF).
> 	This is the 'index' in the original code.
> 	2.2 -> as it may happen that for two different MAC address the
> 	same CRC8 is calculated (i.e. 'index' is the same), each
> 	'index' can store 8 entries for MAC addresses (and it is
> 	searched in a linear way if needed).
> 
> IMHO, the index above shall be multiplied by 8.

I've double check it and it turned out that you were right :-)

The following code:

struct addr_table64b_entry *atable_base =
fep->hwentry->mtip_table64b_entry;

*read_lo = readl(&atable_base[index].lo);
*read_hi = readl(&atable_base[index].hi);

Is more readable than the current code.

The same would be used for atable_write()

I will change it for v5.

> 
> > Also, and perhaps more importantly, readl expects to be passed
> > a pointer to __iomem. But the appropriate annotations seem
> > to be missing (forcing them with a cast is not advisable here IMHO).
> >   
> 
> I think that the code below:
> unsigned long atable_base = (unsigned long)fep->hwentry;
> 
> could be replaced with
> void __iomem *atable_base = fep->hwentry;
> 
> and the (index << 3) with (index * ATABLE_ENTRY_PER_SLOT)




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2025-04-11 12:54 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07 14:51 [net-next v4 0/5] net: mtip: Add support for MTIP imx287 L2 switch driver Lukasz Majewski
2025-04-07 14:51 ` [net-next v4 1/5] dt-bindings: net: Add MTIP L2 switch description Lukasz Majewski
2025-04-10 20:59   ` Rob Herring
2025-04-11 10:36     ` Lukasz Majewski
2025-04-07 14:51 ` [net-next v4 2/5] ARM: dts: nxp: mxs: Adjust the imx28.dtsi " Lukasz Majewski
2025-04-07 14:51 ` [net-next v4 3/5] ARM: dts: nxp: mxs: Adjust XEA board's DTS to support L2 switch Lukasz Majewski
2025-04-09 21:06   ` Andrew Lunn
2025-04-11 13:32   ` Fabio Estevam
2025-04-11 15:45     ` Lukasz Majewski
2025-04-07 14:51 ` [net-next v4 4/5] net: mtip: The L2 switch driver for imx287 Lukasz Majewski
2025-04-08 15:14   ` Simon Horman
2025-04-09 14:28     ` Lukasz Majewski
2025-04-11 12:54       ` Lukasz Majewski [this message]
2025-04-09 17:53   ` Stefan Wahren
2025-04-10 13:37     ` Lukasz Majewski
2025-04-11 13:29       ` Stefan Wahren
2025-04-11 16:23         ` Lukasz Majewski
2025-04-09 21:26   ` Andrew Lunn
2025-04-10  7:35     ` Lukasz Majewski
2025-04-07 14:51 ` [net-next v4 5/5] ARM: mxs_defconfig: Enable CONFIG_FEC_MTIP_L2SW to support MTIP L2 switch Lukasz Majewski
2025-04-09 16:01   ` Stefan Wahren
2025-04-10  7:01     ` Lukasz Majewski
2025-04-10  7:08       ` Krzysztof Kozlowski
2025-04-10  9:23         ` Lukasz Majewski
2025-04-10  7:58       ` Stefan Wahren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250411145430.3001f1db@wsk \
    --to=lukma@denx.de \
    --cc=andrew+netdev@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=festevam@gmail.com \
    --cc=horms@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=wahrenst@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).