Subject: Re: [net PATCH 1/2] net: dsa: qca8k: fix inband mgmt for big-endian systems

From: Christian Marangi <[email-masked]>
Date: Wed, 12 Oct 2022 14:34:22 +0200

On Wed, Oct 12, 2022 at 02:29:26PM +0200, Andrew Lunn wrote:
> On Mon, Oct 10, 2022 at 02:44:46PM +0200, Christian Marangi wrote:
> > On Mon, Oct 10, 2022 at 08:53:01PM +0200, Andrew Lunn wrote:
> > > >  /* Special struct emulating a Ethernet header */
> > > >  struct qca_mgmt_ethhdr {
> > > > -	u32 command;		/* command bit 31:0 */
> > > > -	u32 seq;		/* seq 63:32 */
> > > > -	u32 mdio_data;		/* first 4byte mdio */
> > > > +	__le32 command;		/* command bit 31:0 */
> > > > +	__le32 seq;		/* seq 63:32 */
> > > > +	__le32 mdio_data;		/* first 4byte mdio */
> > > >  	__be16 hdr;		/* qca hdr */
> > > >  } __packed;
> > > 
> > > It looks odd that hdr is BE while the rest are LE. Did you check this?
> > > 
> > >    Andrew
> > 
> > Yes we did many test to analyze this and I just checked with some
> > tcpdump that the hdr is BE everytime.
> 
> That might actual make sense. The comment says:
> 
> > > >  /* Special struct emulating a Ethernet header */
> 
> And hdr is where the Ether type would be, which is network endian,
> i.e. big endian.
> 
>      Andrew

Yes that is my theory... hdr is in the ether type position so it's the
only part that the switch treat in a standard way as it has to be like
that or a dev creating a tagger driver would have no way to understand
if the packet is autocast, in band ack or a simple packet so who created
the fw for the switch had this concern in mind and stick to keeping at
least the hdr in a standard way.

-- 
	Ansuel