RE: [PATCH v2 net-next 2/5] net: enetc: add Tx checksum offload for i.MX95 ENETC
From: Wei Fang
Date: Mon Nov 11 2024 - 20:51:02 EST
> -----Original Message-----
> From: Claudiu Manoil <claudiu.manoil@xxxxxxx>
> Sent: 2024年11月12日 0:11
> To: Wei Fang <wei.fang@xxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; imx@xxxxxxxxxxxxxxx;
> Vladimir Oltean <vladimir.oltean@xxxxxxx>; Clark Wang
> <xiaoning.wang@xxxxxxx>; andrew+netdev@xxxxxxx; davem@xxxxxxxxxxxxx;
> edumazet@xxxxxxxxxx; kuba@xxxxxxxxxx; pabeni@xxxxxxxxxx; Frank Li
> <frank.li@xxxxxxx>
> Subject: RE: [PATCH v2 net-next 2/5] net: enetc: add Tx checksum offload for
> i.MX95 ENETC
>
> > -----Original Message-----
> > From: Wei Fang <wei.fang@xxxxxxx>
> > Sent: Monday, November 11, 2024 11:26 AM
> [...]
> > Subject: RE: [PATCH v2 net-next 2/5] net: enetc: add Tx checksum offload for
> > i.MX95 ENETC
> >
> > > > --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> > > > +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> > > > @@ -143,6 +143,27 @@ static int enetc_ptp_parse(struct sk_buff *skb,
> > > > u8 *udp,
> > > > return 0;
> > > > }
> > > >
> > > > +static bool enetc_tx_csum_offload_check(struct sk_buff *skb) {
> > > > + if (ip_hdr(skb)->version == 4)
> > >
> > > I would avoid using ip_hdr(), or any form of touching packed data and
> > > try extract this kind of info directly from the skb metadata instead,
> > > see also comment below.
> > >
> > > i.e., why not:
> > > if (skb->protocol == htons(ETH_P_IPV6)) .. etc. ?
> >
> > skb->protocol may be VLAN protocol, such as ETH_P_8021Q,
> ETH_P_8021AD.
> > If so, it is impossible to determine whether it is an IPv4 or IPv6 frames
> through
> > protocol.
> >
>
> vlan_get_protocol() then?
> I see you're using this helper in the LSO patch, so let's be consistent then. :)
> I still think it's better than the ip_hdr(skb) approach.
Yes, vlan_get_protocol() can also help us get the IP version, so let's be
consistent. Thanks.