netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* net: xilinx: axienet: Query about checksum partial implementation
@ 2024-07-26 12:07 Simon Horman
  2024-07-30 19:15 ` Pandey, Radhey Shyam
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2024-07-26 12:07 UTC (permalink / raw)
  To: Radhey Shyam Pandey
  Cc: Daniel Borkmann, Ariane Keller, Michal Simek, netdev,
	linux-arm-kernel

Hi Radhey, all,

I am wondering if you could shed some light on the following
checksum partial handling in the axienet_rx_poll():

                        /* if we're doing Rx csum offload, set it up */
                        if (lp->features & XAE_FEATURE_FULL_RX_CSUM) {
				...
                        } else if ((lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) != 0 &&
                                   skb->protocol == htons(ETH_P_IP) &&
                                   skb->len > 64) {
                                skb->csum = be32_to_cpu(cur_p->app3 & 0xFFFF);
                                ...
                        }

In particluar the "skb->csum =" line.

The type of cur_p->app3 is u32, and 0xFFFF is also host byte order.
So far so good. But after the bitwise operation it is treated
as a big-endian value by passing it to be32_to_cpu.

Perhaps I am missing something obvious, but my question is how does that work?

* Was it only tested on big endian sysgtems where be32_to_cpu() is a no-op

* Was it only tested on little endian systems where be32_to_cpu()
  is a byteswap and somehow that works (how?).

* Is the code unecessised because the XAE_FEATURE_FULL_RX_CSUM branch is
  always taken?

  A grep of dts files shows up arch/microblaze/boot/dts/system.dts which
  sets sets xlnx,rxcsum to 0, which corresponds to XAE_NO_CSUM_OFFLOAD.

* Something else

Flagged by Sparse

The in quesoitn code seems to have been introduced by
8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver")



^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: net: xilinx: axienet: Query about checksum partial implementation
  2024-07-26 12:07 net: xilinx: axienet: Query about checksum partial implementation Simon Horman
@ 2024-07-30 19:15 ` Pandey, Radhey Shyam
  2024-07-31  8:54   ` Simon Horman
  0 siblings, 1 reply; 3+ messages in thread
From: Pandey, Radhey Shyam @ 2024-07-30 19:15 UTC (permalink / raw)
  To: Simon Horman
  Cc: Daniel Borkmann, Ariane Keller, Simek, Michal,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Katakam, Harini

> -----Original Message-----
> From: Simon Horman <horms@kernel.org>
> Sent: Friday, July 26, 2024 5:37 PM
> To: Pandey, Radhey Shyam <radhey.shyam.pandey@amd.com>
> Cc: Daniel Borkmann <daniel@iogearbox.net>; Ariane Keller
> <ariane.keller@tik.ee.ethz.ch>; Simek, Michal <michal.simek@amd.com>;
> netdev@vger.kernel.org; linux-arm-kernel@lists.infradead.org
> Subject: net: xilinx: axienet: Query about checksum partial implementation
> 
> Hi Radhey, all,
> 
> I am wondering if you could shed some light on the following checksum
> partial handling in the axienet_rx_poll():
> 
>                         /* if we're doing Rx csum offload, set it up */
>                         if (lp->features & XAE_FEATURE_FULL_RX_CSUM) {
> 				...
>                         } else if ((lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) != 0
> &&
>                                    skb->protocol == htons(ETH_P_IP) &&
>                                    skb->len > 64) {
>                                 skb->csum = be32_to_cpu(cur_p->app3 & 0xFFFF);
>                                 ...
>                         }
> 
> In particluar the "skb->csum =" line.
> 
> The type of cur_p->app3 is u32, and 0xFFFF is also host byte order.
> So far so good. But after the bitwise operation it is treated as a big-endian
> value by passing it to be32_to_cpu.
> 
> Perhaps I am missing something obvious, but my question is how does that
> work?
> 
> * Was it only tested on big endian sysgtems where be32_to_cpu() is a no-op
> 
> * Was it only tested on little endian systems where be32_to_cpu()
>   is a byteswap and somehow that works (how?).
> 
> * Is the code unecessised because the XAE_FEATURE_FULL_RX_CSUM branch
> is
>   always taken?
> 
>   A grep of dts files shows up arch/microblaze/boot/dts/system.dts which
>   sets sets xlnx,rxcsum to 0, which corresponds to XAE_NO_CSUM_OFFLOAD.

+ Harini

Yes, IIRC default AXI Ethernet IP RX checksum is set to "No checksum offload"
so, it is default case and being set in most designs. Have added Harini to this
thread to confirm on partial checksum verification results.

Assuming partial implementation is functional then likely DMA IP updates
application field in big endian format and that is the reason we have this
be32 to CPU conversion in place. will dig a bit more and get back on it.

> 
> * Something else
> 
> Flagged by Sparse
> 
> The in quesoitn code seems to have been introduced by 8a3b7a252dca
> ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver")
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: net: xilinx: axienet: Query about checksum partial implementation
  2024-07-30 19:15 ` Pandey, Radhey Shyam
@ 2024-07-31  8:54   ` Simon Horman
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Horman @ 2024-07-31  8:54 UTC (permalink / raw)
  To: Pandey, Radhey Shyam
  Cc: Daniel Borkmann, Ariane Keller, Simek, Michal,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Katakam, Harini

On Tue, Jul 30, 2024 at 07:15:13PM +0000, Pandey, Radhey Shyam wrote:
> > -----Original Message-----
> > From: Simon Horman <horms@kernel.org>
> > Sent: Friday, July 26, 2024 5:37 PM
> > To: Pandey, Radhey Shyam <radhey.shyam.pandey@amd.com>
> > Cc: Daniel Borkmann <daniel@iogearbox.net>; Ariane Keller
> > <ariane.keller@tik.ee.ethz.ch>; Simek, Michal <michal.simek@amd.com>;
> > netdev@vger.kernel.org; linux-arm-kernel@lists.infradead.org
> > Subject: net: xilinx: axienet: Query about checksum partial implementation
> > 
> > Hi Radhey, all,
> > 
> > I am wondering if you could shed some light on the following checksum
> > partial handling in the axienet_rx_poll():
> > 
> >                         /* if we're doing Rx csum offload, set it up */
> >                         if (lp->features & XAE_FEATURE_FULL_RX_CSUM) {
> > 				...
> >                         } else if ((lp->features & XAE_FEATURE_PARTIAL_RX_CSUM) != 0
> > &&
> >                                    skb->protocol == htons(ETH_P_IP) &&
> >                                    skb->len > 64) {
> >                                 skb->csum = be32_to_cpu(cur_p->app3 & 0xFFFF);
> >                                 ...
> >                         }
> > 
> > In particluar the "skb->csum =" line.
> > 
> > The type of cur_p->app3 is u32, and 0xFFFF is also host byte order.
> > So far so good. But after the bitwise operation it is treated as a big-endian
> > value by passing it to be32_to_cpu.
> > 
> > Perhaps I am missing something obvious, but my question is how does that
> > work?
> > 
> > * Was it only tested on big endian sysgtems where be32_to_cpu() is a no-op
> > 
> > * Was it only tested on little endian systems where be32_to_cpu()
> >   is a byteswap and somehow that works (how?).
> > 
> > * Is the code unecessised because the XAE_FEATURE_FULL_RX_CSUM branch
> > is
> >   always taken?
> > 
> >   A grep of dts files shows up arch/microblaze/boot/dts/system.dts which
> >   sets sets xlnx,rxcsum to 0, which corresponds to XAE_NO_CSUM_OFFLOAD.
> 
> + Harini
> 
> Yes, IIRC default AXI Ethernet IP RX checksum is set to "No checksum offload"
> so, it is default case and being set in most designs. Have added Harini to this
> thread to confirm on partial checksum verification results.
> 
> Assuming partial implementation is functional then likely DMA IP updates
> application field in big endian format and that is the reason we have this
> be32 to CPU conversion in place. will dig a bit more and get back on it.

Thanks, much appreciated.

FWIIW, I do agree that the scenario you describe would mostly explain
things, although the mask with 0xFFFF still seems off.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-31  8:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-26 12:07 net: xilinx: axienet: Query about checksum partial implementation Simon Horman
2024-07-30 19:15 ` Pandey, Radhey Shyam
2024-07-31  8:54   ` Simon Horman

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).