diff options
author | Jonathan Matthew <jmatthew@cvs.openbsd.org> | 2020-05-21 02:08:32 +0000 |
---|---|---|
committer | Jonathan Matthew <jmatthew@cvs.openbsd.org> | 2020-05-21 02:08:32 +0000 |
commit | 618c4dfbd5680d3c5cdc86813ee6493e3afdc01b (patch) | |
tree | 3151796ddd91911a5ffa376babbb1d939c5ebb05 /sys/dev/pci/if_mcx.c | |
parent | 6d9f49a693f7ccc94afaae92924133039173b689 (diff) |
Make use of checksum offloads. Very little effort required from the
driver here.
remi@ observed a small but noticeable improvement in packet forwarding
performance, and I saw a significant increase in TCP receive throughput,
especially with high MTU.
ok dlg@
Diffstat (limited to 'sys/dev/pci/if_mcx.c')
-rw-r--r-- | sys/dev/pci/if_mcx.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/dev/pci/if_mcx.c b/sys/dev/pci/if_mcx.c index 85b4a6af366..6c540f64e35 100644 --- a/sys/dev/pci/if_mcx.c +++ b/sys/dev/pci/if_mcx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mcx.c,v 1.44 2020/04/24 07:28:37 mestre Exp $ */ +/* $OpenBSD: if_mcx.c,v 1.45 2020/05/21 02:08:31 jmatthew Exp $ */ /* * Copyright (c) 2017 David Gwynne <dlg@openbsd.org> @@ -1255,6 +1255,10 @@ struct mcx_cq_entry { uint32_t cq_checksum; uint32_t __reserved__; uint32_t cq_flags; +#define MCX_CQ_ENTRY_FLAGS_L4_OK (1 << 26) +#define MCX_CQ_ENTRY_FLAGS_L3_OK (1 << 25) +#define MCX_CQ_ENTRY_FLAGS_L2_OK (1 << 24) + uint32_t cq_lro_srqn; uint32_t __reserved__[2]; uint32_t cq_byte_cnt; @@ -2355,7 +2359,9 @@ mcx_attach(struct device *parent, struct device *self, void *aux) ifp->if_qstart = mcx_start; ifp->if_watchdog = mcx_watchdog; ifp->if_hardmtu = sc->sc_hardmtu; - ifp->if_capabilities = IFCAP_VLAN_MTU; + ifp->if_capabilities = IFCAP_VLAN_MTU | IFCAP_CSUM_IPv4 | + IFCAP_CSUM_UDPv4 | IFCAP_CSUM_UDPv6 | IFCAP_CSUM_TCPv4 | + IFCAP_CSUM_TCPv6; IFQ_SET_MAXLEN(&ifp->if_snd, 1024); ifmedia_init(&sc->sc_media, IFM_IMASK, mcx_media_change, @@ -5662,6 +5668,7 @@ mcx_process_rx(struct mcx_softc *sc, struct mcx_cq_entry *cqe, struct mcx_slot *ms; struct mbuf *m; int slot; + uint32_t flags; slot = betoh16(cqe->cq_wqe_count) % (1 << MCX_LOG_RQ_SIZE); @@ -5680,6 +5687,13 @@ mcx_process_rx(struct mcx_softc *sc, struct mcx_cq_entry *cqe, betoh32(cqe->cq_rx_hash); } + flags = bemtoh32(&cqe->cq_flags); + if (flags & MCX_CQ_ENTRY_FLAGS_L3_OK) + m->m_pkthdr.csum_flags = M_IPV4_CSUM_IN_OK; + if (flags & MCX_CQ_ENTRY_FLAGS_L4_OK) + m->m_pkthdr.csum_flags |= M_TCP_CSUM_IN_OK | + M_UDP_CSUM_IN_OK; + if (c->c_tdiff) { uint64_t t = bemtoh64(&cqe->cq_timestamp) - c->c_timestamp; t *= c->c_udiff; @@ -6343,6 +6357,7 @@ mcx_start(struct ifqueue *ifq) sqe->sqe_signature = htobe32(MCX_SQE_CE_CQE_ALWAYS); /* eth segment */ + sqe->sqe_mss_csum = htobe32(MCX_SQE_L3_CSUM | MCX_SQE_L4_CSUM); sqe->sqe_inline_header_size = htobe16(MCX_SQ_INLINE_SIZE); m_copydata(m, 0, MCX_SQ_INLINE_SIZE, (caddr_t)sqe->sqe_inline_headers); |