IB/core: Fix calculation of maximum RoCE MTU
authorParav Pandit <parav@mellanox.com>
Mon, 16 Oct 2017 05:45:16 +0000 (08:45 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Dec 2017 09:07:32 +0000 (10:07 +0100)
[ Upstream commit 99260132fde7bddc6e0132ce53da94d1c9ccabcb ]

The original code only took into consideration the largest header
possible after the IB_BTH_BYTES.  This was incorrect, as the largest
possible header size is the largest possible combination of headers we
might run into.  The new code accounts for all possible headers in the
largest possible combination and subtracts that from the MTU to make
sure that all packets will fit on the wire.

Link: https://www.spinics.net/lists/linux-rdma/msg54558.html
Fixes: 3c86aa70bf67 ("RDMA/cm: Add RDMA CM support for IBoE devices")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
Reported-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/rdma/ib_addr.h
include/rdma/ib_pack.h

index 1beab5532035dc2126405384d44457f183de2a90..818a38f9922122167cb11deebe6e87b6643fc522 100644 (file)
@@ -243,10 +243,11 @@ static inline void rdma_addr_set_dgid(struct rdma_dev_addr *dev_addr, union ib_g
 static inline enum ib_mtu iboe_get_mtu(int mtu)
 {
        /*
-        * reduce IB headers from effective IBoE MTU. 28 stands for
-        * atomic header which is the biggest possible header after BTH
+        * Reduce IB headers from effective IBoE MTU.
         */
-       mtu = mtu - IB_GRH_BYTES - IB_BTH_BYTES - 28;
+       mtu = mtu - (IB_GRH_BYTES + IB_UDP_BYTES + IB_BTH_BYTES +
+                    IB_EXT_XRC_BYTES + IB_EXT_ATOMICETH_BYTES +
+                    IB_ICRC_BYTES);
 
        if (mtu >= ib_mtu_enum_to_int(IB_MTU_4096))
                return IB_MTU_4096;
index b13419ce99ff5b52d666c2af7a91f58457f58100..e02b78a38ebacfd3c407e01cab590a1d6917e6c9 100644 (file)
 #include <uapi/linux/if_ether.h>
 
 enum {
-       IB_LRH_BYTES  = 8,
-       IB_ETH_BYTES  = 14,
-       IB_VLAN_BYTES = 4,
-       IB_GRH_BYTES  = 40,
-       IB_IP4_BYTES  = 20,
-       IB_UDP_BYTES  = 8,
-       IB_BTH_BYTES  = 12,
-       IB_DETH_BYTES = 8
+       IB_LRH_BYTES            = 8,
+       IB_ETH_BYTES            = 14,
+       IB_VLAN_BYTES           = 4,
+       IB_GRH_BYTES            = 40,
+       IB_IP4_BYTES            = 20,
+       IB_UDP_BYTES            = 8,
+       IB_BTH_BYTES            = 12,
+       IB_DETH_BYTES           = 8,
+       IB_EXT_ATOMICETH_BYTES  = 28,
+       IB_EXT_XRC_BYTES        = 4,
+       IB_ICRC_BYTES           = 4
 };
 
 struct ib_field {