@@ -6496,8 +6496,21 @@ static int igc_xdp_rx_timestamp(const struct xdp_md *_ctx, u64 *timestamp)
return -ENODATA;
}
+static int igc_xdp_rx_hash(const struct xdp_md *_ctx, u32 *hash)
+{
+ const struct igc_xdp_buff *ctx = (void *)_ctx;
+
+ if (!(ctx->xdp.rxq->dev->features & NETIF_F_RXHASH))
+ return -ENODATA;
+
+ *hash = le32_to_cpu(ctx->rx_desc->wb.lower.hi_dword.rss);
+
+ return 0;
+}
+
const struct xdp_metadata_ops igc_xdp_metadata_ops = {
.xmo_rx_timestamp = igc_xdp_rx_timestamp,
+ .xmo_rx_hash = igc_xdp_rx_hash,
};
/**
This implements XDP hints kfunc for RX-hash (xmo_rx_hash) straightforward by returning the u32 hash value. The associated RSS-type for the hash value isn't available to the BPF-prog caller. This is problematic if BPF-prog tries to do L4 load-balancing with the hardware hash, but the RSS hash type is L3 based. For this driver this issue occurs for UDP packets, as driver (default config) does L3 hashing for UDP packets (excludes UDP src/dest ports in hash calc). Tested that the igc_rss_type_num for UDP is either IGC_RSS_TYPE_HASH_IPV4 or IGC_RSS_TYPE_HASH_IPV6. Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> --- drivers/net/ethernet/intel/igc/igc_main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)