RE: [PATCH v2 net-next 2/5] net: enetc: add Tx checksum offload for i.MX95 ENETC

From: Claudiu Manoil
Date: Mon Nov 11 2024 - 11:11:13 EST


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