[...] > > Hi Lorenzo, > > any chance we could have some common code used both here and in > ice_rx_csum() ?
Hi Maciej,
ack, I will look into it.
Regards,
Lorenzo
>
> > +{
> > + const struct ice_xdp_buff *xdp_ext = (void *)ctx;
> > + const union ice_32b_rx_flex_desc *rx_desc = xdp_ext->eop_desc;
> > + u16 rx_status0, rx_status1, ptype = ice_get_ptype(rx_desc);
> > + struct libeth_rx_pt decoded = libie_rx_pt_parse(ptype);
> > + bool ipv4, ipv6;
> > +
> > + if (!libeth_rx_pt_has_checksum(xdp_ext->xdp_buff.rxq->dev, decoded))
> > + goto checksum_none;
> > +
> > + rx_status0 = le16_to_cpu(rx_desc->wb.status_error0);
> > + rx_status1 = le16_to_cpu(rx_desc->wb.status_error1);
> > + if ((xdp_ext->pkt_ctx->rxq_flags & ICE_RX_FLAGS_RING_GCS) &&
> > + rx_desc->wb.rxdid == ICE_RXDID_FLEX_NIC &&
> > + (decoded.inner_prot == LIBETH_RX_PT_INNER_TCP ||
> > + decoded.inner_prot == LIBETH_RX_PT_INNER_UDP ||
> > + decoded.inner_prot == LIBETH_RX_PT_INNER_ICMP)) {
> > + const struct ice_32b_rx_flex_desc_nic *desc;
> > + u16 csum;
> > +
> > + desc = (struct ice_32b_rx_flex_desc_nic *)rx_desc;
> > + *ip_summed = CHECKSUM_COMPLETE;
> > + csum = (__force u16)desc->raw_csum;
> > + *cksum_meta = csum_unfold((__force __sum16)swab16(csum));
> > + return 0;
> > + }
> > +
> > + /* check if HW has decoded the packet and checksum */
> > + if (!(rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_L3L4P_S)))
> > + goto checksum_none;
> > +
> > + ipv4 = libeth_rx_pt_get_ip_ver(decoded) == LIBETH_RX_PT_OUTER_IPV4;
> > + if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_EIPE_S))))
> > + goto checksum_none;
> > +
> > + if (ipv4 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_IPE_S))))
> > + goto checksum_none;
> > +
> > + ipv6 = libeth_rx_pt_get_ip_ver(decoded) == LIBETH_RX_PT_OUTER_IPV6;
> > + if (ipv6 && (rx_status0 & (BIT(ICE_RX_FLEX_DESC_STATUS0_IPV6EXADD_S))))
> > + goto checksum_none;
> > +
> > + /* check for L4 errors and handle packets that were not able to be
> > + * checksummed due to arrival speed
> > + */
> > + if (rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_L4E_S))
> > + goto checksum_none;
> > +
> > + /* check for outer UDP checksum error in tunneled packets */
> > + if ((rx_status1 & BIT(ICE_RX_FLEX_DESC_STATUS1_NAT_S)) &&
> > + (rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_XSUM_EUDPE_S)))
> > + goto checksum_none;
> > +
> > + /* If there is an outer header present that might contain a checksum
> > + * we need to bump the checksum level by 1 to reflect the fact that
> > + * we are indicating we validated the inner checksum.
> > + */
> > + if (decoded.tunnel_type >= LIBETH_RX_PT_TUNNEL_IP_GRENAT)
> > + *cksum_meta = 1;
> > +
> > + *ip_summed = CHECKSUM_UNNECESSARY;
> > + return 0;
> > +
> > +checksum_none:
> > + *ip_summed = CHECKSUM_NONE;
> > + *cksum_meta = 0;
> > +
> > + return 0;
> > +}
> > +
> > /**
> > * ice_xdp_rx_vlan_tag - VLAN tag XDP hint handler
> > * @ctx: XDP buff pointer
> > @@ -584,4 +665,5 @@ const struct xdp_metadata_ops ice_xdp_md_ops = {
> > .xmo_rx_timestamp = ice_xdp_rx_hw_ts,
> > .xmo_rx_hash = ice_xdp_rx_hash,
> > .xmo_rx_vlan_tag = ice_xdp_rx_vlan_tag,
> > + .xmo_rx_checksum = ice_xdp_rx_checksum,
> > };
> >
> > --
> > 2.51.0
> >
> >
signature.asc
Description: PGP signature
