/* * Copyright (c) 2005 Ammasso, Inc. All rights reserved. * Copyright (c) 2006-2009 Open Grid Computing, Inc. All rights reserved. * Copyright (c) 2019 Pensando Systems, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include #include #include #include #include #if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0) #include #else #include #endif #include #include #if defined(RHEL_RELEASE_VERSION) #define IONIC_KCOMPAT_KERN_VERSION_PRIOR_TO(LX_MAJ, LX_MIN, RH_MAJ, RH_MIN) \ (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(RH_MAJ, RH_MIN)) #else #define IONIC_KCOMPAT_KERN_VERSION_PRIOR_TO(LX_MAJ, LX_MIN, RH_MAJ, RH_MIN) \ (LINUX_VERSION_CODE < KERNEL_VERSION(LX_MAJ, LX_MIN, 0)) #endif #if defined(OFA_KERNEL) /* MLNX_OFED_LINUX-4.2-1.2.0.0-debian9.0-x86_64 */ #define OFA_COMPAT_f8de107 MLNX_OFED_4_2 #define MLNX_OFED_4_2__support 1 #define MLNX_OFED_4_2__4_19b 1 #define MLNX_OFED_4_2__5_0 1 /* MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu18.04-x86_64 */ #define OFA_COMPAT_d647238 MLNX_OFED_4_4 #define MLNX_OFED_4_4__support 1 #define MLNX_OFED_4_4__4_19b 1 #define MLNX_OFED_4_4__5_0 1 /* MLNX_OFED_LINUX-4.5-1.0.1.0-debian9.0-x86_64 */ /* MLNX_OFED_LINUX-4.5-1.0.1.0-ubuntu18.04-x86_64 */ #define OFA_COMPAT_b4fdfac MLNX_OFED_4_5 #define MLNX_OFED_4_5__support 1 #define MLNX_OFED_4_5__4_19b 1 #define MLNX_OFED_4_5__5_0 1 /* MLNX_OFED_LINUX-4.6-1.0.1.1-ubuntu18.04-x86_64 */ #define OFA_COMPAT_a2cfe08 MLNX_OFED_4_6 #define MLNX_OFED_4_6__support 1 #define MLNX_OFED_4_6__5_0 1 /* MLNX_OFED_LINUX-4.7-3.2.9.0-rhel7.6-x86_64 */ #define OFA_COMPAT_457f064 MLNX_OFED_4_7 #define MLNX_OFED_4_7__support 1 /* macro magic... * OFA_COMPAT_CHECK(OFA_KERNEL, OFA) * -> _OFA_COMPAT_CHECK(OFA_COMPAT_ ## f8de107, support) * -> __OFA_COMPAT_CHECK(OFA_COMPAT_f8de107, support) * -> ___OFA_COMPAT_CHECK(MLNX_OFED_4_2, support) * -> MLNX_OFED_4_2__support */ #define OFA_COMPAT_CHECK(OFA_KERNEL, OFA) \ _OFA_COMPAT_CHECK(OFA_KERNEL, OFA) #define _OFA_COMPAT_CHECK(OFA_KERNEL, OFA) \ __OFA_COMPAT_CHECK(OFA_COMPAT_ ## OFA_KERNEL, OFA) #define __OFA_COMPAT_CHECK(OFA_COMPAT, OFA) \ ___OFA_COMPAT_CHECK(OFA_COMPAT, OFA) #define ___OFA_COMPAT_CHECK(OFA_COMPAT, OFA) \ OFA_COMPAT ## __ ## OFA #if ! OFA_COMPAT_CHECK(OFA_KERNEL, support) #error Missing support for OFED version #endif #define IONIC_KCOMPAT_VERSION_PRIOR_TO(LX_MAJ, LX_MIN, RH_MAJ, RH_MIN, OFA) \ OFA_COMPAT_CHECK(OFA_KERNEL, OFA) #else #define IONIC_KCOMPAT_VERSION_PRIOR_TO(LX_MAJ, LX_MIN, RH_MAJ, RH_MIN, OFA) \ IONIC_KCOMPAT_KERN_VERSION_PRIOR_TO(LX_MAJ, LX_MIN, RH_MAJ, RH_MIN) #endif struct krping_stats { unsigned long long send_bytes; unsigned long long send_msgs; unsigned long long recv_bytes; unsigned long long recv_msgs; unsigned long long write_bytes; unsigned long long write_msgs; unsigned long long read_bytes; unsigned long long read_msgs; char name[16]; }; #define PFX "krping: " #define PRIx64 "%Lx" #define uintmax_t uint64_t /* See upstream kernel commit d34ac5cd3a73 */ #if IONIC_KCOMPAT_VERSION_PRIOR_TO(/* Linux */ 4,19, /* RHEL */ 99,99, /* OFA */ 4_19b) #define ud_wr(wr) ud_wr((struct ib_send_wr *)(wr)) #define rdma_wr(wr) rdma_wr((struct ib_send_wr *)(wr)) #define atomic_wr(wr) atomic_wr((struct ib_send_wr *)(wr)) #define reg_wr(wr) reg_wr((struct ib_send_wr *)(wr)) #define WRCONST #else #define WRCONST const #endif #if IONIC_KCOMPAT_VERSION_PRIOR_TO(/* Linux */ 5,0, /* RHEL */ 99,99, /* OFA */ 5_0) #else /* 5.0 and later */ #define LINUX_DEV_OPS #endif #if IONIC_KCOMPAT_KERN_VERSION_PRIOR_TO(/* Linux */ 5,6, /* RHEL */ 99,99) #else /* 5.6 and later */ #define LINUX_PROC_OPS #endif #define spin_lock_destroy(...) {} static inline struct ib_pd * krping_alloc_pd(struct ib_device *ibdev) { #if IONIC_KCOMPAT_VERSION_PRIOR_TO(/* Linux */ 4,9, /* RHEL */ 7,4, /* OFA */ 4_9) return ib_alloc_pd(ibdev); #else return ib_alloc_pd(ibdev, 0); #endif } extern int krping_debug; #define DEBUG_LOG(...) do { if (krping_debug) printk(__VA_ARGS__); } while (0) #define DEBUG_LOG2(...) {} int krping_doit(char *); void krping_walk_cb_list(void (*)(u32, struct krping_stats *, void *), void *);