mlx5: fix Rx checksum offload in non L3/L4 packets
authorYaacov Hazan <yaacovh@mellanox.com>
Thu, 3 Mar 2016 14:27:39 +0000 (15:27 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 16 Mar 2016 17:52:18 +0000 (18:52 +0100)
Change rxq_cq_to_ol_flags() to set checksum flags according to packet type,
so for non L3/L4 packets the mbuf chksum_bad flags will not be set.

Fixes: 67fa62bc672d ("mlx5: support checksum offload")

Signed-off-by: Yaacov Hazan <yaacovh@mellanox.com>
doc/guides/rel_notes/release_16_04.rst
drivers/net/mlx5/Makefile
drivers/net/mlx5/mlx5_rxtx.c

index 5b386f1..1cc1115 100644 (file)
@@ -287,6 +287,10 @@ Drivers
 
   Prevented reception of multicast frames outside of configured VLANs.
 
+* **mlx5: Fixed RX checksum offload in non L3/L4 packets.**
+
+  Fixed report of bad checksum for packets of unknown type.
+
 * **aesni_mb: Fixed wrong return value when creating a device.**
 
   cryptodev_aesni_mb_init() was returning the device id of the device created,
index 29185f0..c4f7c5f 100644 (file)
@@ -126,6 +126,11 @@ mlx5_autoconf.h: $(RTE_SDK)/scripts/auto-config-h.sh
                infiniband/verbs.h \
                enum IBV_EXP_DEVICE_ATTR_VLAN_OFFLOADS \
                $(AUTOCONF_OUTPUT)
+       $Q sh -- '$<' '$@' \
+               HAVE_EXP_CQ_RX_TCP_PACKET \
+               infiniband/verbs.h \
+               enum IBV_EXP_CQ_RX_TCP_PACKET \
+               $(AUTOCONF_OUTPUT)
 
 $(SRCS-$(CONFIG_RTE_LIBRTE_MLX5_PMD):.c=.o): mlx5_autoconf.h
 
index 4c53c7a..4919189 100644 (file)
@@ -719,14 +719,24 @@ rxq_cq_to_ol_flags(const struct rxq *rxq, uint32_t flags)
 {
        uint32_t ol_flags = 0;
 
-       if (rxq->csum)
-               ol_flags |=
-                       TRANSPOSE(~flags,
-                                 IBV_EXP_CQ_RX_IP_CSUM_OK,
-                                 PKT_RX_IP_CKSUM_BAD) |
-                       TRANSPOSE(~flags,
-                                 IBV_EXP_CQ_RX_TCP_UDP_CSUM_OK,
-                                 PKT_RX_L4_CKSUM_BAD);
+       if (rxq->csum) {
+               /* Set IP checksum flag only for IPv4/IPv6 packets. */
+               if (flags &
+                   (IBV_EXP_CQ_RX_IPV4_PACKET | IBV_EXP_CQ_RX_IPV6_PACKET))
+                       ol_flags |=
+                               TRANSPOSE(~flags,
+                                       IBV_EXP_CQ_RX_IP_CSUM_OK,
+                                       PKT_RX_IP_CKSUM_BAD);
+#ifdef HAVE_EXP_CQ_RX_TCP_PACKET
+               /* Set L4 checksum flag only for TCP/UDP packets. */
+               if (flags &
+                   (IBV_EXP_CQ_RX_TCP_PACKET | IBV_EXP_CQ_RX_UDP_PACKET))
+#endif /* HAVE_EXP_CQ_RX_TCP_PACKET */
+                       ol_flags |=
+                               TRANSPOSE(~flags,
+                                       IBV_EXP_CQ_RX_TCP_UDP_CSUM_OK,
+                                       PKT_RX_L4_CKSUM_BAD);
+       }
        /*
         * PKT_RX_IP_CKSUM_BAD and PKT_RX_L4_CKSUM_BAD are used in place
         * of PKT_RX_EIP_CKSUM_BAD because the latter is not functional