Subject: Re: [PATCH net-next v6 1/8] net: wangxun: libwx add tx offload functions

From: Jakub Kicinski <[email-masked]>
Date: Wed, 24 May 2023 08:30:08 -0700

On Wed, 24 May 2023 14:59:54 +0800 [email-masked] wrote:
> > 2023年5月24日 12:06，Jakub Kicinski <[email-masked]> 写道：
> > On Tue, 23 May 2023 11:06:51 +0800 Mengyuan Lou wrote:  
> >> + if (skb->encapsulation) {
> >> + union network_header hdr;
> >> +
> >> + switch (first->protocol) {
> >> + case htons(ETH_P_IP):
> >> + tun_prot = ip_hdr(skb)->protocol;
> >> + if (ip_is_fragment(ip_hdr(skb)))
> >> + return WX_PTYPE_PKT_IP | WX_PTYPE_TYP_IPFRAG;
> >> + ptype = WX_PTYPE_TUN_IPV4;
> >> + break;
> >> + case htons(ETH_P_IPV6):
> >> + wx_get_ipv6_proto(skb, skb_network_offset(skb), &tun_prot);
> >> + if (tun_prot == NEXTHDR_FRAGMENT)
> >> + return WX_PTYPE_PKT_IP | WX_PTYPE_PKT_IPV6 |
> >> +       WX_PTYPE_TYP_IPFRAG;
> >> + ptype = WX_PTYPE_TUN_IPV6;  
> > 
> > Why does the HW care about fragmented packets?
> > AFAIU fragmented packets won't have any offloads enabled.
> 
> According to hardware spec(Packet type table), try to tell the ptypes for hardware.

Extracting information from the packet consumes CPU cycles.
If HW will not use the information anyway (because no offload 
is requested for the packet) those cycles are wasted.