summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2015-10-24 05:35:43 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2015-10-24 05:35:43 +0000
commit6e53dfbb15caaeb7fc46a31f09f885df08123d70 (patch)
tree0ec6960a9d7a099610f56cf9e97593b339cdf0d5 /sys
parentf62fa0b75e0b00e50a32292706cb1117b9414243 (diff)
Make use of hardware RX checksum validation.
ok naddy@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/octeon/dev/cn30xxipd.c58
-rw-r--r--sys/arch/octeon/dev/cn30xxipdvar.h4
-rw-r--r--sys/arch/octeon/dev/if_cnmac.c4
3 files changed, 16 insertions, 50 deletions
diff --git a/sys/arch/octeon/dev/cn30xxipd.c b/sys/arch/octeon/dev/cn30xxipd.c
index ee059a047f7..ca040c1fb23 100644
--- a/sys/arch/octeon/dev/cn30xxipd.c
+++ b/sys/arch/octeon/dev/cn30xxipd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cn30xxipd.c,v 1.5 2014/08/11 18:29:56 miod Exp $ */
+/* $OpenBSD: cn30xxipd.c,v 1.6 2015/10/24 05:35:42 visa Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -39,11 +39,6 @@
#include <octeon/dev/cn30xxipdreg.h>
#include <octeon/dev/cn30xxipdvar.h>
-#include <netinet/in.h>
-
-#define IP_OFFSET(data, word2) \
- ((caddr_t)(data) + ((word2 & PIP_WQE_WORD2_IP_OFFSET) >> PIP_WQE_WORD2_IP_OFFSET_SHIFT))
-
#ifdef OCTEON_ETH_DEBUG
void cn30xxipd_intr_rml(void *);
int cn30xxipd_intr_drop(void *);
@@ -163,55 +158,26 @@ cn30xxipd_config(struct cn30xxipd_softc *sc)
* L3 error & L4 error
*/
void
-cn30xxipd_offload(uint64_t word2, caddr_t data, uint16_t *rcflags)
+cn30xxipd_offload(uint64_t word2, uint16_t *rcflags)
{
-#if 0 /* XXX */
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);
- if (!ISSET(word2, PIP_WQE_WORD2_IP_V6))
- SET(cflags, M_CSUM_IPv4);
-
- if (ISSET(word2, PIP_WQE_WORD2_IP_TU)) {
- SET(cflags,
- !ISSET(word2, PIP_WQE_WORD2_IP_V6) ?
- (M_CSUM_TCPv4 | M_CSUM_UDPv4) :
- (M_CSUM_TCPv6 | M_CSUM_UDPv6));
- }
-
- /* check L3 (IP) error */
- if (ISSET(word2, PIP_WQE_WORD2_IP_IE)) {
- struct ip *ip;
-
- switch (word2 & PIP_WQE_WORD2_IP_OPECODE) {
- case IPD_WQE_L3_V4_CSUM_ERR:
- /* CN31XX_Pass_1.1_Issues_v1.5 2.4.5.1 */
- ip = (struct ip *)(IP_OFFSET(data, word2));
- if (ip->ip_hl == 5)
- SET(cflags, M_CSUM_IPv4_BAD);
- break;
- default:
- break;
- }
- }
-
- /* check L4 (UDP / TCP) error */
- if (ISSET(word2, PIP_WQE_WORD2_IP_LE)) {
- switch (word2 & PIP_WQE_WORD2_IP_OPECODE) {
- case IPD_WQE_L4_CSUM_ERR:
- SET(cflags, M_CSUM_TCP_UDP_BAD);
- break;
- default:
- break;
- }
- }
+ /* 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;
-#endif
}
void
diff --git a/sys/arch/octeon/dev/cn30xxipdvar.h b/sys/arch/octeon/dev/cn30xxipdvar.h
index 1bb1b4b7cce..2abd262524d 100644
--- a/sys/arch/octeon/dev/cn30xxipdvar.h
+++ b/sys/arch/octeon/dev/cn30xxipdvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cn30xxipdvar.h,v 1.3 2014/08/11 18:29:56 miod Exp $ */
+/* $OpenBSD: cn30xxipdvar.h,v 1.4 2015/10/24 05:35:42 visa Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -51,7 +51,7 @@ void cn30xxipd_init(struct cn30xxipd_attach_args *,
int cn30xxipd_enable(struct cn30xxipd_softc *);
int cn30xxipd_config(struct cn30xxipd_softc *);
void cn30xxipd_sub_port_fcs(struct cn30xxipd_softc *, int);
-void cn30xxipd_offload(uint64_t, caddr_t, uint16_t *);
+void cn30xxipd_offload(uint64_t, uint16_t *);
#ifdef OCTEON_ETH_DEBUG
void cn30xxipd_int_enable(struct cn30xxipd_softc *, int);
diff --git a/sys/arch/octeon/dev/if_cnmac.c b/sys/arch/octeon/dev/if_cnmac.c
index 42fbf6e334e..c2403cf0fcb 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.25 2015/10/15 14:06:04 visa Exp $ */
+/* $OpenBSD: if_cnmac.c,v 1.26 2015/10/24 05:35:42 visa Exp $ */
/*
* Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -1389,7 +1389,7 @@ octeon_eth_recv(struct octeon_eth_softc *sc, uint64_t *work)
OCTEON_ETH_KASSERT(m != NULL);
- cn30xxipd_offload(word2, m->m_data, &m->m_pkthdr.csum_flags);
+ cn30xxipd_offload(word2, &m->m_pkthdr.csum_flags);
ml_enqueue(&ml, m);
if_input(ifp, &ml);