From 89760ddf20a392c353d44c7962b3e891d2401df6 Mon Sep 17 00:00:00 2001 From: bluhm Date: Thu, 10 Feb 2022 16:22:00 +0000 Subject: [PATCH] Enable receive checksum offloading on ixl(4) network interfaces. from jan@; test and OK dlg@ --- sys/dev/pci/if_ixl.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/sys/dev/pci/if_ixl.c b/sys/dev/pci/if_ixl.c index 71dff53d323..6412e5a0760 100644 --- a/sys/dev/pci/if_ixl.c +++ b/sys/dev/pci/if_ixl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ixl.c,v 1.81 2022/02/09 11:12:21 dlg Exp $ */ +/* $OpenBSD: if_ixl.c,v 1.82 2022/02/10 16:22:00 bluhm Exp $ */ /* * Copyright (c) 2013-2015, Intel Corporation @@ -1399,6 +1399,7 @@ static int ixl_rxeof(struct ixl_softc *, struct ixl_rx_ring *); static void ixl_rxfill(struct ixl_softc *, struct ixl_rx_ring *); static void ixl_rxrefill(void *); static int ixl_rxrinfo(struct ixl_softc *, struct if_rxrinfo *); +static void ixl_rx_checksum(struct mbuf *, uint64_t); #if NKSTAT > 0 static void ixl_kstat_attach(struct ixl_softc *); @@ -3297,6 +3298,7 @@ ixl_rxeof(struct ixl_softc *sc, struct ixl_rx_ring *rxr) SET(m->m_flags, M_VLANTAG); } + ixl_rx_checksum(m, word); ml_enqueue(&ml, m); } else { ifp->if_ierrors++; /* XXX */ @@ -3429,6 +3431,23 @@ ixl_rxrinfo(struct ixl_softc *sc, struct if_rxrinfo *ifri) return (rv); } +static void +ixl_rx_checksum(struct mbuf *m, uint64_t word) +{ + if (!ISSET(word, IXL_RX_DESC_L3L4P)) + return; + + if (ISSET(word, IXL_RX_DESC_IPE)) + return; + + m->m_pkthdr.csum_flags |= M_IPV4_CSUM_IN_OK; + + if (ISSET(word, IXL_RX_DESC_L4E)) + return; + + m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK; +} + static int ixl_intr0(void *xsc) { -- 2.20.1