diff options
author | Visa Hankala <visa@cvs.openbsd.org> | 2020-08-15 10:44:49 +0000 |
---|---|---|
committer | Visa Hankala <visa@cvs.openbsd.org> | 2020-08-15 10:44:49 +0000 |
commit | 67593168a7e282fbb22bbf3acbb5de725adbbb1d (patch) | |
tree | 7c4d77c0e5e19466a533b4e0a14106a3776747ae /sys | |
parent | 6a5220f6dad792431343f75ce7dbbb56404927a3 (diff) |
Inline handling of receive checksum offload
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/octeon/dev/cn30xxipd.c | 31 | ||||
-rw-r--r-- | sys/arch/octeon/dev/cn30xxipdvar.h | 3 | ||||
-rw-r--r-- | sys/arch/octeon/dev/if_cnmac.c | 17 |
3 files changed, 17 insertions, 34 deletions
diff --git a/sys/arch/octeon/dev/cn30xxipd.c b/sys/arch/octeon/dev/cn30xxipd.c index 28d907a0ed4..357334feebc 100644 --- a/sys/arch/octeon/dev/cn30xxipd.c +++ b/sys/arch/octeon/dev/cn30xxipd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cn30xxipd.c,v 1.12 2019/09/20 15:01:30 visa Exp $ */ +/* $OpenBSD: cn30xxipd.c,v 1.13 2020/08/15 10:44:48 visa Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -133,32 +133,3 @@ cn30xxipd_config(struct cn30xxipd_softc *sc) return 0; } - -/* - * octeon work queue entry offload - * L3 error & L4 error - */ -void -cn30xxipd_offload(uint64_t word2, uint16_t *rcflags) -{ - int cflags; - - /* Skip if the packet is non-IP. */ - if (ISSET(word2, PIP_WQE_WORD2_IP_NI)) - return; - - cflags = 0; - - /* Check IP checksum status. */ - if (!ISSET(word2, PIP_WQE_WORD2_IP_V6) && - !ISSET(word2, PIP_WQE_WORD2_IP_IE)) - SET(cflags, M_IPV4_CSUM_IN_OK); - - /* Check TCP/UDP checksum status. Skip if the packet is a fragment. */ - if (ISSET(word2, PIP_WQE_WORD2_IP_TU) && - !ISSET(word2, PIP_WQE_WORD2_IP_FR) && - !ISSET(word2, PIP_WQE_WORD2_IP_LE)) - SET(cflags, M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK); - - *rcflags = cflags; -} diff --git a/sys/arch/octeon/dev/cn30xxipdvar.h b/sys/arch/octeon/dev/cn30xxipdvar.h index 7a2c8ee6435..009a01d33f1 100644 --- a/sys/arch/octeon/dev/cn30xxipdvar.h +++ b/sys/arch/octeon/dev/cn30xxipdvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cn30xxipdvar.h,v 1.6 2019/09/20 15:01:30 visa Exp $ */ +/* $OpenBSD: cn30xxipdvar.h,v 1.7 2020/08/15 10:44:48 visa Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -50,6 +50,5 @@ void cn30xxipd_init(struct cn30xxipd_attach_args *, struct cn30xxipd_softc **); int cn30xxipd_enable(struct cn30xxipd_softc *); int cn30xxipd_config(struct cn30xxipd_softc *); -void cn30xxipd_offload(uint64_t, uint16_t *); #endif /* !_CN30XXIPDVAR_H_ */ diff --git a/sys/arch/octeon/dev/if_cnmac.c b/sys/arch/octeon/dev/if_cnmac.c index c9156f7db22..c45503c3d7f 100644 --- a/sys/arch/octeon/dev/if_cnmac.c +++ b/sys/arch/octeon/dev/if_cnmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cnmac.c,v 1.77 2020/07/10 13:26:36 patrick Exp $ */ +/* $OpenBSD: if_cnmac.c,v 1.78 2020/08/15 10:44:48 visa Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -1235,7 +1235,20 @@ cnmac_recv(struct cnmac_softc *sc, uint64_t *work, struct mbuf_list *ml) goto drop; } - cn30xxipd_offload(word2, &m->m_pkthdr.csum_flags); + m->m_pkthdr.csum_flags = 0; + if (__predict_true(!ISSET(word2, PIP_WQE_WORD2_IP_NI))) { + /* Check IP checksum status. */ + if (!ISSET(word2, PIP_WQE_WORD2_IP_V6) && + !ISSET(word2, PIP_WQE_WORD2_IP_IE)) + m->m_pkthdr.csum_flags |= M_IPV4_CSUM_IN_OK; + + /* Check TCP/UDP checksum status. */ + if (ISSET(word2, PIP_WQE_WORD2_IP_TU) && + !ISSET(word2, PIP_WQE_WORD2_IP_FR) && + !ISSET(word2, PIP_WQE_WORD2_IP_LE)) + m->m_pkthdr.csum_flags |= + M_TCP_CSUM_IN_OK | M_UDP_CSUM_IN_OK; + } ml_enqueue(ml, m); |