All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: Biju Das <biju.das.jz@bp.renesas.com>,
	Sergey Shtylyov <s.shtylyov@omp.ru>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: Sergei Shtylyov <sergei.shtylyov@gmail.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Sergey Shtylyov <s.shtylyov@omprussia.ru>,
	Adam Ford <aford173@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
	Yuusuke Ashizuka <ashiduka@fujitsu.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: RE: [RFC 07/12] ravb: Fillup ravb_rx_gbeth() stub
Date: Fri, 8 Oct 2021 06:46:32 +0000	[thread overview]
Message-ID: <OS0PR01MB5922165EFE14E02388B34F4086B29@OS0PR01MB5922.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <OS0PR01MB5922BCF31F520F8F975606B286B19@OS0PR01MB5922.jpnprd01.prod.outlook.com>

Hi Sergey,

> Subject: RE: [RFC 07/12] ravb: Fillup ravb_rx_gbeth() stub
> 
> Hi Sergey,
> 
> 
> Thanks for the feedback.
> 
> > Subject: Re: [RFC 07/12] ravb: Fillup ravb_rx_gbeth() stub
> >
> > On 10/7/21 8:49 AM, Biju Das wrote:
> >
> > [...]
> > >>>>> Fillup ravb_rx_gbeth() function to support RZ/G2L.
> > >>>>>
> > >>>>> This patch also renames ravb_rcar_rx to ravb_rx_rcar to be
> > >>>>> consistent with the naming convention used in sh_eth driver.
> > >>>>>
> > >>>>> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > >>>>> Reviewed-by: Lad Prabhakar
> > >>>>> <prabhakar.mahadev-lad.rj@bp.renesas.com>[...]
> > >>>>> diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > >>>>> b/drivers/net/ethernet/renesas/ravb_main.c
> > >>>>> index 37164a983156..42573eac82b9 100644
> > >>>>> --- a/drivers/net/ethernet/renesas/ravb_main.c
> > >>>>> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> > >>>>> @@ -720,6 +720,23 @@ static void ravb_get_tx_tstamp(struct
> > >>>>> net_device
> > >>>> *ndev)
> > >>>>>  	}
> > >>>>>  }
> > >>>>>
> > >>>>> +static void ravb_rx_csum_gbeth(struct sk_buff *skb) {
> > >>>>> +	u8 *hw_csum;
> > >>>>> +
> > >>>>> +	/* The hardware checksum is contained in sizeof(__sum16) (2)
> > bytes
> > >>>>> +	 * appended to packet data
> > >>>>> +	 */
> > >>>>> +	if (unlikely(skb->len < sizeof(__sum16)))
> > >>>>> +		return;
> > >>>>> +	hw_csum = skb_tail_pointer(skb) - sizeof(__sum16);
> > >>>>
> > >>>>    Not 32-bit? The manual says the IP checksum is stored in the
> > >>>> first
> > >>>> 2 bytes.
> > >>>
> > >>> It is 16 bit. It is on last 2 bytes.
> >
> >    The IP checksum is at the 1st 2 bytes of the overall 4-byte
> > checksum (coming after the packet payload), no?
> 
> Sorry, I got confused with your question earlier. Now it is clear for me.
> 
> I agree the checksum part is stored in last 4bytes. Of this, the first 2
> bytes IPV4 checksum and last 2 bytes TCP/UDP/ICMP checksum.
> 
> >
> > >>    So you're saying the manual is wrong?
> > >
> > > I am not sure which manual you are referring here.
> > >
> > > I am referring to Rev.1.00 Sep, 2021 of RZ/G2L hardware manual and
> >
> >    Same here.
> >
> > [...]
> >
> > > Please check the section 30.5.6.1 checksum calculation handling> And
> > > figure 30.25 the field of checksum attaching field
> >
> >    I have.
> >
> > > Also see Table 30.17 for checksum values for non-error conditions.
> >
> > > TCP/UDP/ICPM checksum is at last 2bytes.
> >
> >    What are you arguing with then? :-)
> >    My point was that your code fetched the TCP/UDP/ICMP checksum ISO
> > the IP checksum because it subtracts sizeof(__sum16), while should
> > probably subtract sizeof(__wsum)
> 
> Agreed. My code missed IP4 checksum result. May be we need to extract 2
> checksum info from last 4 bytes.  First checksum(2bytes) is IP4 header
> checksum and next checksum(2 bytes)  for TCP/UDP/ICMP and use this info
> finding the non error case mentioned in  Table 30.17.
> 
> For eg:-
> IPV6 non error-condition -->  "0xFFFF"-->IPV4HeaderCSum value and "0x0000"
> TCP/UDP/ICMP CSUM value
> 
> IPV4 non error-condition -->  "0x0000"-->IPV4HeaderCSum value and "0x0000"
> TCP/UDP/ICMP CSUM value
> 
> Do you agree?

What I meant here is some thing like below, please let me know if you have any issues with
this, otherwise I would like to send the patch with below changes.

Further improvements can happen later.

Please let me know.

+/* Hardware checksum status */
+#define IPV4_RX_CSUM_OK                0x00000000
+#define IPV6_RX_CSUM_OK                0xFFFF0000
+
 enum ravb_reg {
        /* AVB-DMAC registers */
        CCC     = 0x0000,
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index bbb42e5328e4..d9201fbbd472 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -722,16 +722,18 @@ static void ravb_get_tx_tstamp(struct net_device *ndev)
 
 static void ravb_rx_csum_gbeth(struct sk_buff *skb)
 {
-       u16 *hw_csum;
+       u32 csum_result;
+       u8 *hw_csum;
 
        /* The hardware checksum is contained in sizeof(__sum16) (2) bytes
         * appended to packet data
         */
-       if (unlikely(skb->len < sizeof(__sum16)))
+       if (unlikely(skb->len < sizeof(__wsum)))
                return;
-       hw_csum = (u16*)(skb_tail_pointer(skb) - sizeof(__sum16));
+       hw_csum = skb_tail_pointer(skb) - sizeof(__wsum);
+       csum_result = get_unaligned_le32(hw_csum);
 
-       if (*hw_csum == 0)
+       if (csum_result == IPV4_RX_CSUM_OK || csum_result == IPV6_RX_CSUM_OK)

Regards,
Biju

> 
> Regards,
> Biju
> >
> > >>>>> +
> > >>>>> +	if (*hw_csum == 0)
> > >>>>
> > >>>>    You only check the 1st byte, not the full checksum!
> > >>>
> > >>> As I said earlier, "0" value on last 16 bit, means no checksum
> error.
> > >>
> > >>    How's that? 'hw_csum' is declared as 'u8 *'!
> > >
> > > It is my mistake, which will be taken care in the next patch by
> > > using
> > u16 *.
> >
> >    Note that this 'u16' halfword can be unaligned, that's why the
> > current code uses get_unaligned_le16().
> >
> > >>>>> +		skb->ip_summed = CHECKSUM_UNNECESSARY;
> > >>>>> +	else
> > >>>>> +		skb->ip_summed = CHECKSUM_NONE;
> > >>>>
> > >>>>   So the TCP/UDP/ICMP checksums are not dealt with? Why enable
> > >>>> them
> > >> then?
> > >>>
> > >>> If last 2bytes is zero, means there is no checksum error w.r.to
> > >> TCP/UDP/ICMP checksums.
> > >>
> > >>    Why checksum them independently then?
> > >
> > > It is a hardware feature.
> >
> >    Switchable, isn't it?
> 
> >
> > > Regards,
> > > Biju
> >
> > [...]
> >
> > MBR, Sergey

  reply	other threads:[~2021-10-08  6:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05 11:06 [RFC 00/12] Add functional support for Gigabit Ethernet driver Biju Das
2021-10-05 11:06 ` [RFC 01/12] ravb: Use ALIGN macro for max_rx_len Biju Das
2021-10-05 12:14   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 02/12] ravb: Add rx_max_buf_size to struct ravb_hw_info Biju Das
2021-10-05 12:21   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 03/12] ravb: Fillup ravb_set_features_gbeth() stub Biju Das
2021-10-05 18:59   ` Sergey Shtylyov
2021-10-06  7:43     ` Biju Das
2021-10-09 17:53       ` Biju Das
2021-10-05 11:06 ` [RFC 04/12] ravb: Fillup ravb_alloc_rx_desc_gbeth() stub Biju Das
2021-10-05 19:14   ` Sergey Shtylyov
2021-10-06  6:50     ` Biju Das
2021-10-05 11:06 ` [RFC 05/12] ravb: Fillup ravb_rx_ring_free_gbeth() stub Biju Das
2021-10-05 19:41   ` Sergei Shtylyov
2021-10-05 11:06 ` [RFC 06/12] ravb: Fillup ravb_rx_ring_format_gbeth() stub Biju Das
2021-10-05 20:34   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 07/12] ravb: Fillup ravb_rx_gbeth() stub Biju Das
2021-10-06 19:38   ` Sergey Shtylyov
2021-10-06 20:22     ` Biju Das
2021-10-06 20:32       ` Sergey Shtylyov
2021-10-07  5:49         ` Biju Das
2021-10-07 19:04           ` Sergey Shtylyov
2021-10-07 20:09             ` Biju Das
2021-10-08  6:46               ` Biju Das [this message]
2021-10-08 17:59                 ` Sergey Shtylyov
2021-10-08 20:13                   ` Sergey Shtylyov
2021-10-09  8:27                     ` Biju Das
2021-10-09  8:34                       ` Sergei Shtylyov
2021-10-09  9:41                         ` Biju Das
2021-10-05 11:06 ` [RFC 08/12] ravb: Add carrier_counters to struct ravb_hw_info Biju Das
2021-10-06 16:41   ` Sergey Shtylyov
2021-10-06 17:00     ` Sergey Shtylyov
2021-10-06 17:22       ` Biju Das
2021-10-06 17:21     ` Biju Das
2021-10-05 11:06 ` [RFC 09/12] ravb: Add support to retrieve stats for GbEthernet Biju Das
2021-10-06 17:27   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 10/12] ravb: Rename "tsrq" variable Biju Das
2021-10-05 19:19   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 11/12] ravb: Optimize ravb_emac_init_gbeth function Biju Das
2021-10-05 19:19   ` Sergey Shtylyov
2021-10-05 11:06 ` [RFC 12/12] ravb: Update/Add comments Biju Das
2021-10-05 19:26   ` Sergey Shtylyov
2021-10-06  6:53     ` Biju Das
2021-10-05 11:54 ` [RFC 00/12] Add functional support for Gigabit Ethernet driver Sergey Shtylyov
2021-10-05 12:04   ` Biju Das

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=OS0PR01MB5922165EFE14E02388B34F4086B29@OS0PR01MB5922.jpnprd01.prod.outlook.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=aford173@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=ashiduka@fujitsu.com \
    --cc=biju.das@bp.renesas.com \
    --cc=davem@davemloft.net \
    --cc=geert+renesas@glider.be \
    --cc=kuba@kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=s.shtylyov@omp.ru \
    --cc=s.shtylyov@omprussia.ru \
    --cc=sergei.shtylyov@gmail.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.