From aa57af8328f10bb4c41ef65e2cbd9b5a8eba9dc5 Mon Sep 17 00:00:00 2001 From: Hareesh Kesireddy Date: Fri, 19 Apr 2024 22:01:09 +0530 Subject: [PATCH] osi dma: fix mgbe rx checksum flags Issue description: - IPV4 CSUM SW flag is always set without checking HW flags. Fix description: - Set IPV4 CSUM SW flag only if packet type is > 0 in rdes3. - Check for IPHE and CSUM errors from rdes3.ellt only if rdes3.es bit is set. Bug 4611476 Change-Id: Iaaf56b4cc122fd51e29f12f759ac7e3a3905a067 Signed-off-by: Hareesh Kesireddy Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/3119885 GVS: Gerrit_Virtual_Submit (cherry picked from commit 39e36ad2cad9c7e4254c2f6eef91a7f074b207df) Reviewed-on: https://git-master.nvidia.com/r/c/kernel/nvethernetrm/+/3137117 Reviewed-by: Srinivas Ramachandran GVS: buildbot_gerritrpt --- osi/dma/mgbe_desc.c | 59 ++++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/osi/dma/mgbe_desc.c b/osi/dma/mgbe_desc.c index 1328d9a..eddc07c 100644 --- a/osi/dma/mgbe_desc.c +++ b/osi/dma/mgbe_desc.c @@ -153,34 +153,39 @@ static void mgbe_get_rx_csum(const struct osi_rx_desc *const rx_desc, nveu32_t ellt = rx_desc->rdes3 & RDES3_ELLT; nveu32_t pkt_type; - /* Always include either checksum none/unnecessary - * depending on status fields in desc. - * Hence no need to explicitly add OSI_PKT_CX_CSUM flag. - */ - if ((ellt != RDES3_ELLT_IPHE) && (ellt != RDES3_ELLT_CSUM_ERR)) { - rx_pkt_cx->rxcsum |= OSI_CHECKSUM_UNNECESSARY; - } - - rx_pkt_cx->rxcsum |= OSI_CHECKSUM_IPv4; - if (ellt == RDES3_ELLT_IPHE) { - rx_pkt_cx->rxcsum |= OSI_CHECKSUM_IPv4_BAD; - } - - pkt_type = rx_desc->rdes3 & MGBE_RDES3_PT_MASK; - if (pkt_type == MGBE_RDES3_PT_IPV4_TCP) { - rx_pkt_cx->rxcsum |= OSI_CHECKSUM_TCPv4; - } else if (pkt_type == MGBE_RDES3_PT_IPV4_UDP) { - rx_pkt_cx->rxcsum |= OSI_CHECKSUM_UDPv4; - } else if (pkt_type == MGBE_RDES3_PT_IPV6_TCP) { - rx_pkt_cx->rxcsum |= OSI_CHECKSUM_TCPv6; - } else if (pkt_type == MGBE_RDES3_PT_IPV6_UDP) { - rx_pkt_cx->rxcsum |= OSI_CHECKSUM_UDPv6; + if ((rx_desc->rdes3 & RDES3_ES_MGBE) != 0U) { + if (ellt == RDES3_ELLT_CSUM_ERR) { + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_TCP_UDP_BAD; + } else if (ellt == RDES3_ELLT_IPHE) { + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_IPv4_BAD; + } else { + /* Do nothing */ + } } else { - /* Do nothing */ - } - - if (ellt == RDES3_ELLT_CSUM_ERR) { - rx_pkt_cx->rxcsum |= OSI_CHECKSUM_TCP_UDP_BAD; + pkt_type = rx_desc->rdes3 & MGBE_RDES3_PT_MASK; + if (pkt_type != 0U) { + /* ES is zero and PT is non-zero means + * HW validated CSUM, hence set UNNECESSARY flag for + * Linux OSD. + * Remaining flags are for QNX OSD. + */ + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_UNNECESSARY; + if (pkt_type == MGBE_RDES3_PT_IPV4_TCP) { + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_TCPv4; + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_IPv4; + } else if (pkt_type == MGBE_RDES3_PT_IPV4_UDP) { + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_UDPv4; + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_IPv4; + } else if (pkt_type == MGBE_RDES3_PT_IPV6_TCP) { + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_TCPv6; + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_IPv4; + } else if (pkt_type == MGBE_RDES3_PT_IPV6_UDP) { + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_UDPv6; + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_IPv4; + } else { + rx_pkt_cx->rxcsum |= OSI_CHECKSUM_IPv4; + } + } } }