RE: [PATCH net-next v18 06/13] rtase: Implement .ndo_start_xmit function

From: Justin Lai
Date: Sun May 12 2024 - 23:44:30 EST


>
> > +static u32 rtase_tx_csum(struct sk_buff *skb, const struct net_device
> > +*dev) {
> > + u32 csum_cmd = 0;
> > + u8 ip_protocol;
> > +
> > + switch (vlan_get_protocol(skb)) {
> > + case htons(ETH_P_IP):
> > + csum_cmd = RTASE_TX_IPCS_C;
> > + ip_protocol = ip_hdr(skb)->protocol;
> > + break;
> > +
> > + case htons(ETH_P_IPV6):
> > + csum_cmd = RTASE_TX_IPV6F_C;
> > + ip_protocol = ipv6_hdr(skb)->nexthdr;
> > + break;
> > +
> > + default:
> > + ip_protocol = IPPROTO_RAW;
> > + break;
> > + }
> > +
> > + if (ip_protocol == IPPROTO_TCP)
> > + csum_cmd |= RTASE_TX_TCPCS_C;
> > + else if (ip_protocol == IPPROTO_UDP)
> > + csum_cmd |= RTASE_TX_UDPCS_C;
> > + else
> > + WARN_ON_ONCE(1);
>
> I'm not so sure about this WARN_ON_ONCE(). It looks like if i send a custom
> packet which is not IPv4 or IPv6 it will fire. There are other protocols then IP.
> Connecting to an Ethernet switch using DSA tags would be a good example. So
> i don't think you want this warning.
>
> Andrew

Hi Andrew,
The condition for entering this function is checksum_partial, which requires
hardware to help calculate the checksum, so protocols that are not supported
by the hardware will issue warn_on_once.