From: jan Date: Tue, 21 May 2024 19:49:06 +0000 (+0000) Subject: Refactor vmx(4) receive offloading. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1171ef0cf0b18d5ac21286a5586c74806fe0144c;p=openbsd Refactor vmx(4) receive offloading. - avoid combination of M_TCP_CSUM_IN_OK and M_UDP_CSUM_IN_OK - remove useless letoh32() calls - simplify the IPv4 checksum flag check ok bluhm@ --- diff --git a/sys/dev/pci/if_vmx.c b/sys/dev/pci/if_vmx.c index 28853b5471b..0c5883a1bca 100644 --- a/sys/dev/pci/if_vmx.c +++ b/sys/dev/pci/if_vmx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vmx.c,v 1.85 2024/05/13 01:15:51 jsg Exp $ */ +/* $OpenBSD: if_vmx.c,v 1.86 2024/05/21 19:49:06 jan Exp $ */ /* * Copyright (c) 2013 Tsubai Masanari @@ -203,7 +203,7 @@ void vmxnet3_rxintr(struct vmxnet3_softc *, struct vmxnet3_rxqueue *); void vmxnet3_rxfill_tick(void *); void vmxnet3_rxfill(struct vmxnet3_rxring *); void vmxnet3_iff(struct vmxnet3_softc *); -void vmxnet3_rx_csum(struct vmxnet3_rxcompdesc *, struct mbuf *); +void vmxnet3_rx_offload(struct vmxnet3_rxcompdesc *, struct mbuf *); void vmxnet3_stop(struct ifnet *); void vmxnet3_reset(struct vmxnet3_softc *); int vmxnet3_init(struct vmxnet3_softc *); @@ -1127,14 +1127,8 @@ vmxnet3_rxintr(struct vmxnet3_softc *sc, struct vmxnet3_rxqueue *rq) } m->m_pkthdr.len = m->m_len = len; - vmxnet3_rx_csum(rxcd, m); -#if NVLAN > 0 - if (letoh32(rxcd->rxc_word2 & VMXNET3_RXC_VLAN)) { - m->m_flags |= M_VLANTAG; - m->m_pkthdr.ether_vtag = letoh32((rxcd->rxc_word2 >> - VMXNET3_RXC_VLANTAG_S) & VMXNET3_RXC_VLANTAG_M); - } -#endif + vmxnet3_rx_offload(rxcd, m); + if (((letoh32(rxcd->rxc_word0) >> VMXNET3_RXC_RSSTYPE_S) & VMXNET3_RXC_RSSTYPE_M) != VMXNET3_RXC_RSSTYPE_NONE) { m->m_pkthdr.ph_flowid = letoh32(rxcd->rxc_word1); @@ -1215,22 +1209,39 @@ vmxnet3_iff(struct vmxnet3_softc *sc) void -vmxnet3_rx_csum(struct vmxnet3_rxcompdesc *rxcd, struct mbuf *m) +vmxnet3_rx_offload(struct vmxnet3_rxcompdesc *rxcd, struct mbuf *m) { - if (letoh32(rxcd->rxc_word0 & VMXNET3_RXC_NOCSUM)) + /* + * VLAN Offload + */ + +#if NVLAN > 0 + if (ISSET(rxcd->rxc_word2, VMXNET3_RXC_VLAN)) { + SET(m->m_flags, M_VLANTAG); + m->m_pkthdr.ether_vtag = letoh32((rxcd->rxc_word2 >> + VMXNET3_RXC_VLANTAG_S) & VMXNET3_RXC_VLANTAG_M); + } +#endif + + /* + * Checksum Offload + */ + + if (ISSET(rxcd->rxc_word0, VMXNET3_RXC_NOCSUM)) return; - if ((rxcd->rxc_word3 & (VMXNET3_RXC_IPV4 | VMXNET3_RXC_IPSUM_OK)) == - (VMXNET3_RXC_IPV4 | VMXNET3_RXC_IPSUM_OK)) - m->m_pkthdr.csum_flags |= M_IPV4_CSUM_IN_OK; + if (ISSET(rxcd->rxc_word3, VMXNET3_RXC_IPV4) && + ISSET(rxcd->rxc_word3, VMXNET3_RXC_IPSUM_OK)) + SET(m->m_pkthdr.csum_flags, M_IPV4_CSUM_IN_OK); - if (rxcd->rxc_word3 & VMXNET3_RXC_FRAGMENT) + if (ISSET(rxcd->rxc_word3, VMXNET3_RXC_FRAGMENT)) return; - if (rxcd->rxc_word3 & (VMXNET3_RXC_TCP | VMXNET3_RXC_UDP)) { - if (rxcd->rxc_word3 & VMXNET3_RXC_CSUM_OK) - m->m_pkthdr.csum_flags |= - M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK; + if (ISSET(rxcd->rxc_word3, VMXNET3_RXC_CSUM_OK)) { + if (ISSET(rxcd->rxc_word3, VMXNET3_RXC_TCP)) + SET(m->m_pkthdr.csum_flags, M_TCP_CSUM_IN_OK); + else if (ISSET(rxcd->rxc_word3, VMXNET3_RXC_UDP)) + SET(m->m_pkthdr.csum_flags, M_UDP_CSUM_IN_OK); } }