Commit a2fe6fdf authored by tianx's avatar tianx
Browse files

drivers: Add GDR(GPU Direct RDMA) support

yunsilicon inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IALL3Y


CVE: NA

------------------------------------------

Add GPU Direct RDMA support

Reviewed-by: default avatarWei Honggang <weihg@yunsilicon.com>
Reviewed-by: default avatarWang Saochuang <wangsc@yunsilicon.com>
Signed-off-by: default avatarTian Xin <tianx@yunsilicon.com>
parent 80659f8a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6186,6 +6186,7 @@ CONFIG_INFINIBAND_ON_DEMAND_PAGING=y
CONFIG_INFINIBAND_ADDR_TRANS=y
CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS=y
CONFIG_INFINIBAND_VIRT_DMA=y
CONFIG_INFINIBAND_PEER_MEMORY=y
CONFIG_INFINIBAND_BNXT_RE=m
CONFIG_INFINIBAND_CXGB4=m
# CONFIG_INFINIBAND_EFA is not set
+1 −0
Original line number Diff line number Diff line
@@ -6855,6 +6855,7 @@ CONFIG_INFINIBAND_ON_DEMAND_PAGING=y
CONFIG_INFINIBAND_ADDR_TRANS=y
CONFIG_INFINIBAND_ADDR_TRANS_CONFIGFS=y
CONFIG_INFINIBAND_VIRT_DMA=y
CONFIG_INFINIBAND_PEER_MEMORY=y
CONFIG_INFINIBAND_BNXT_RE=m
CONFIG_INFINIBAND_CXGB4=m
# CONFIG_INFINIBAND_EFA is not set
+10 −0
Original line number Diff line number Diff line
@@ -74,6 +74,16 @@ config INFINIBAND_ADDR_TRANS_CONFIGFS
	  This allows the user to config the default GID type that the CM
	  uses for each device, when initiaing new connections.

config INFINIBAND_PEER_MEMORY
	bool "InfiniBand peer memory support"
	depends on INFINIBAND_USER_MEM
	default n
	help
	  Peer memory support for the InfinBand subsystem. This
	  enables GPU drivers to provide peer memory operations
	  and allows InfiniBand hardware drivers to utilize GPU
	  peer memory.

config INFINIBAND_VIRT_DMA
	def_bool !HIGHMEM

+1 −0
Original line number Diff line number Diff line
@@ -41,4 +41,5 @@ ib_uverbs-y := uverbs_main.o uverbs_cmd.o uverbs_marshall.o \
				uverbs_std_types_wq.o \
				uverbs_std_types_qp.o
ib_uverbs-$(CONFIG_INFINIBAND_USER_MEM) += umem.o umem_dmabuf.o
ib_uverbs-$(CONFIG_INFINIBAND_PEER_MEMORY) += peer_mem.o
ib_uverbs-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o
+65 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
/*
 * Copyright (c) 2014-2020,  Mellanox Technologies. All rights reserved.
 * Copyright (C) 2020-2021, NVIDIA CORPORATION & AFFILIATES. All Rights Reserved.
 */
#ifndef RDMA_IB_PEER_MEM_H
#define RDMA_IB_PEER_MEM_H

#include <rdma/peer_mem.h>
#include <linux/kobject.h>
#include <linux/xarray.h>
#include <rdma/ib_umem.h>

struct ib_peer_memory_statistics {
	atomic64_t num_alloc_mrs;
	atomic64_t num_dealloc_mrs;
	atomic64_t num_reg_pages;
	atomic64_t num_dereg_pages;
	atomic64_t num_reg_bytes;
	atomic64_t num_dereg_bytes;
	unsigned long num_free_callbacks;
};

struct ib_peer_memory_client {
	refcount_t usecnt;
	struct completion usecnt_zero;
	const struct peer_memory_client *peer_mem;
	struct list_head core_peer_list;
	struct ib_peer_memory_statistics stats;
	struct xarray umem_xa;
	u32 xa_cyclic_next;
	bool invalidation_required;
};

enum ib_umem_mapped_state {
	UMEM_PEER_UNMAPPED,
	UMEM_PEER_MAPPED,
	UMEM_PEER_INVALIDATED,
};

struct ib_umem_peer {
	struct ib_umem umem;
	struct kref kref;
	/* peer memory that manages this umem */
	struct ib_peer_memory_client *ib_peer_client;
	void *peer_client_context;
	umem_invalidate_func_t invalidation_func;
	void *invalidation_private;
	struct mutex mapping_lock;
	enum ib_umem_mapped_state mapped_state;
	u32 xa_id;
	struct scatterlist *first_sg;
	dma_addr_t first_dma_address;
	unsigned int first_dma_length;
	unsigned int first_length;
	struct scatterlist *last_sg;
	unsigned int last_dma_length;
	unsigned int last_length;
};

struct ib_umem *ib_peer_umem_get(struct ib_umem *old_umem, int old_ret,
				 unsigned long peer_mem_flags);
void ib_peer_umem_release(struct ib_umem *umem);

#endif
Loading