[PATCH RESEND bpf-next 12/15] ice: Implement checksum level hint

Larysa Zaremba
2023-05-12T15:29:34Z

Implement .xmo_rx_csum_lvl callback to allow XDP code to determine,
whether checksum was checked by hardware and on what level.

Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com>
---
drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 24 ++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
index 39547feb6106..6a3ec925f20d 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c
@@ -161,6 +161,8 @@ ice_rx_csum_checked(union ice_32b_rx_flex_desc *rx_desc, u16 ptype,
*/
if (decoded.tunnel_type >= ICE_RX_PTYPE_TUNNEL_IP_GRENAT)
*csum_lvl_dst = 1;
+ else
+ *csum_lvl_dst = 0;

/* Only report checksum unnecessary for TCP, UDP, or SCTP */
switch (decoded.inner_prot) {
@@ -190,7 +192,7 @@ static void
ice_rx_csum_into_skb(struct ice_rx_ring *ring, struct sk_buff *skb,
union ice_32b_rx_flex_desc *rx_desc, u16 ptype)
{
- u8 csum_level = 0;
+ u8 csum_level;

/* Start with CHECKSUM_NONE and by default csum_level = 0 */
skb->ip_summed = CHECKSUM_NONE;
@@ -669,9 +671,29 @@ static int ice_xdp_rx_stag(const struct xdp_md *ctx, u16 *vlan_tag)
return 0;
}

+/**
+ * ice_xdp_rx_csum_lvl - Get level, at which HW has checked the checksum
+ * @ctx: XDP buff pointer
+ * @csum_lvl: destination address
+ *
+ * Copy HW checksum level (if was checked) to the destination address.
+ */
+static int ice_xdp_rx_csum_lvl(const struct xdp_md *ctx, u8 *csum_lvl)
+{
+ const struct ice_xdp_buff *xdp_ext = (void *)ctx;
+ u16 ptype = ice_get_ptype(xdp_ext->eop_desc);
+
+ if (!ice_rx_csum_checked(xdp_ext->eop_desc, ptype, csum_lvl,
+ xdp_ext->rx_ring))
+ return -EOPNOTSUPP;
+
+ return 0;
+}
+
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_ctag = ice_xdp_rx_ctag,
.xmo_rx_stag = ice_xdp_rx_stag,
+ .xmo_rx_csum_lvl = ice_xdp_rx_csum_lvl,
};
--
2.35.3