Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cee2688e authored by yonatanc's avatar yonatanc Committed by Doug Ledford
Browse files

IB/rxe: Offload CRC calculation when possible



Use CPU ability to perform CRC calculations, by
replacing direct calls to crc32_le() with crypto_shash_updata().

The overall performance gain measured with ib_send_bw tool is 10% and it
was tested on "Intel CPU ES-2660 v2 @ 2.20Ghz" CPU.

ib_send_bw -d rxe0  -x 1 -n 9000 -e  -s $((1024 * 1024 )) -l 100

---------------------------------------------------------------------------------------------
|             | bytes   | iterations | BW peak[MB/sec] | BW average[MB/sec] | MsgRate[Mpps] |
---------------------------------------------------------------------------------------------
| crc32_le    | 1048576 | 9000       | inf             | 497.60             | 0.000498      |
| CRC offload | 1048576 | 9000       | inf             | 546.70             | 0.000547      |
---------------------------------------------------------------------------------------------

Fixes: 8700e3e7 ("Soft RoCE driver")
Signed-off-by: default avatarYonatan Cohen <yonatanc@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 0d38ac8a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ config RDMA_RXE
	tristate "Software RDMA over Ethernet (RoCE) driver"
	depends on INET && PCI && INFINIBAND
	depends on NET_UDP_TUNNEL
	depends on CRYPTO_CRC32
	select DMA_VIRT_OPS
	---help---
	This driver implements the InfiniBand RDMA transport over
+2 −0
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ static void rxe_cleanup(struct rxe_dev *rxe)
	rxe_pool_cleanup(&rxe->mc_elem_pool);

	rxe_cleanup_ports(rxe);

	crypto_free_shash(rxe->tfm);
}

/* called when all references have been dropped */
+20 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
#include <rdma/ib_umem.h>
#include <rdma/ib_cache.h>
#include <rdma/ib_addr.h>
#include <crypto/hash.h>

#include "rxe_net.h"
#include "rxe_opcode.h"
@@ -64,6 +65,25 @@

#define RXE_ROCE_V2_SPORT		(0xc000)

static inline u32 rxe_crc32(struct rxe_dev *rxe,
			    u32 crc, void *next, size_t len)
{
	int err;

	SHASH_DESC_ON_STACK(shash, rxe->tfm);

	shash->tfm = rxe->tfm;
	shash->flags = 0;
	*(u32 *)shash_desc_ctx(shash) = crc;
	err = crypto_shash_update(shash, next, len);
	if (unlikely(err)) {
		pr_warn_ratelimited("failed crc calculation, err: %d\n", err);
		return crc32_le(crc, next, len);
	}

	return *(u32 *)shash_desc_ctx(shash);
}

int rxe_set_mtu(struct rxe_dev *rxe, unsigned int dev_mtu);

int rxe_add(struct rxe_dev *rxe, unsigned int mtu);
+3 −3
Original line number Diff line number Diff line
@@ -87,10 +87,10 @@ u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt, struct sk_buff *skb)
	bth->qpn |= cpu_to_be32(~BTH_QPN_MASK);

	length = hdr_size + RXE_BTH_BYTES;
	crc = crc32_le(crc, pshdr, length);
	crc = rxe_crc32(pkt->rxe, crc, pshdr, length);

	/* And finish to compute the CRC on the remainder of the headers. */
	crc = crc32_le(crc, pkt->hdr + RXE_BTH_BYTES,
	crc = rxe_crc32(pkt->rxe, crc, pkt->hdr + RXE_BTH_BYTES,
			rxe_opcode[pkt->opcode].length - RXE_BTH_BYTES);
	return crc;
}
+4 −2
Original line number Diff line number Diff line
@@ -370,7 +370,8 @@ int rxe_mem_copy(struct rxe_mem *mem, u64 iova, void *addr, int length,
			((void *)(uintptr_t)iova) : addr;

		if (crcp)
			*crcp = crc32_le(*crcp, src, length);
			crc = rxe_crc32(to_rdev(mem->pd->ibpd.device),
					*crcp, src, length);

		memcpy(dest, src, length);

@@ -403,7 +404,8 @@ int rxe_mem_copy(struct rxe_mem *mem, u64 iova, void *addr, int length,
			bytes = length;

		if (crcp)
			crc = crc32_le(crc, src, bytes);
			crc = rxe_crc32(to_rdev(mem->pd->ibpd.device),
					crc, src, bytes);

		memcpy(dest, src, bytes);

Loading