Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Adapt ena_rx_checksum() to NetBSD.
details: https://anonhg.NetBSD.org/src/rev/f15eda158037
branches: trunk
changeset: 837313:f15eda158037
user: bad <bad%NetBSD.org@localhost>
date: Wed Nov 28 11:50:48 2018 +0000
description:
Adapt ena_rx_checksum() to NetBSD.
It wasn't ported to the NetBSD conventions of indicating hardware checkum
status.
Compile tested only.
diffstat:
sys/dev/pci/if_ena.c | 55 +++++++++++++++++++++++++++++++++------------------
1 files changed, 35 insertions(+), 20 deletions(-)
diffs (73 lines):
diff -r d0b43e2f9364 -r f15eda158037 sys/dev/pci/if_ena.c
--- a/sys/dev/pci/if_ena.c Wed Nov 28 10:01:28 2018 +0000
+++ b/sys/dev/pci/if_ena.c Wed Nov 28 11:50:48 2018 +0000
@@ -31,7 +31,7 @@
#if 0
__FBSDID("$FreeBSD: head/sys/dev/ena/ena.c 333456 2018-05-10 09:37:54Z mw $");
#endif
-__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.5 2018/06/26 06:48:01 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.6 2018/11/28 11:50:48 bad Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1593,26 +1593,41 @@
struct mbuf *mbuf)
{
- /* if IP and error */
- if (unlikely((ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV4) &&
- ena_rx_ctx->l3_csum_err)) {
- /* ipv4 checksum error */
- mbuf->m_pkthdr.csum_flags = 0;
- counter_u64_add(rx_ring->rx_stats.bad_csum, 1);
- ena_trace(ENA_DBG, "RX IPv4 header checksum error");
- return;
+ /* IPv4 */
+ if ((ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV4)) {
+ mbuf->m_pkthdr.csum_flags |= M_CSUM_IPv4;
+ if (ena_rx_ctx->l3_csum_err) {
+ /* ipv4 checksum error */
+ mbuf->m_pkthdr.csum_flags |= M_CSUM_IPv4_BAD;
+ counter_u64_add(rx_ring->rx_stats.bad_csum, 1);
+ ena_trace(ENA_DBG, "RX IPv4 header checksum error");
+ return;
+ }
+
+ /* TCP/UDP */
+ if ((ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_TCP) ||
+ (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_UDP)) {
+ mbuf->m_pkthdr.csum_flags |= (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_TCP) ? M_CSUM_TCPv4 : M_CSUM_UDPv4;
+ if (ena_rx_ctx->l4_csum_err) {
+ /* TCP/UDP checksum error */
+ mbuf->m_pkthdr.csum_flags |= M_CSUM_TCP_UDP_BAD;
+ counter_u64_add(rx_ring->rx_stats.bad_csum, 1);
+ ena_trace(ENA_DBG, "RX L4 checksum error");
+ }
+ }
}
-
- /* if TCP/UDP */
- if ((ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_TCP) ||
- (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_UDP)) {
- if (ena_rx_ctx->l4_csum_err) {
- /* TCP/UDP checksum error */
- mbuf->m_pkthdr.csum_flags = M_CSUM_IPv4_BAD;
- counter_u64_add(rx_ring->rx_stats.bad_csum, 1);
- ena_trace(ENA_DBG, "RX L4 checksum error");
- } else {
- mbuf->m_pkthdr.csum_flags = M_CSUM_IPv4;
+ /* IPv6 */
+ else if ((ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV6)) {
+ /* TCP/UDP */
+ if ((ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_TCP) ||
+ (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_UDP)) {
+ mbuf->m_pkthdr.csum_flags |= (ena_rx_ctx->l4_proto == ENA_ETH_IO_L4_PROTO_TCP) ? M_CSUM_TCPv6 : M_CSUM_UDPv6;
+ if (ena_rx_ctx->l4_csum_err) {
+ /* TCP/UDP checksum error */
+ mbuf->m_pkthdr.csum_flags |= M_CSUM_TCP_UDP_BAD;
+ counter_u64_add(rx_ring->rx_stats.bad_csum, 1);
+ ena_trace(ENA_DBG, "RX L4 checksum error");
+ }
}
}
}
Home |
Main Index |
Thread Index |
Old Index