mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-19 21:56:31 +00:00
ib_srpt: Add support for kernels without ib_device.dma_ops
This commit is contained in:
@@ -92,6 +92,7 @@ CREATE_SEND_MAD_AH_FLAG := $(call run_conftest,create_send_mad_ah,-DCREATE_S
|
||||
ifeq ($(CREATE_SEND_MAD_AH_FLAG),)
|
||||
CREATE_SEND_MAD_BASE_FLAG := $(call run_conftest,create_send_mad_base,-DCREATE_SEND_MAD_HAS_BASE_ARG)
|
||||
endif
|
||||
HAVE_IB_DMA_MAP_OPS := $(call run_conftest,ib_dma_map_ops,-DHAVE_IB_DMA_MAP_OPS)
|
||||
GID_CHANGE_FLAG := $(call run_conftest,gid_change,-DHAVE_IB_EVENT_GID_CHANGE)
|
||||
REGISTER_MAD_AGENT_FLAG := $(call run_conftest,register_mad_agent,-DREGISTER_MAD_AGENT_HAS_FLAGS_ARG)
|
||||
QUERY_GID_FLAG := $(call run_conftest,query_gid,-DIB_QUERY_GID_HAS_ATTR_ARG)
|
||||
@@ -99,6 +100,7 @@ PRE_CFLAGS=$(OFED_CFLAGS) \
|
||||
$(CREATE_CQ_FLAG) \
|
||||
$(CREATE_SEND_MAD_AH_FLAG) \
|
||||
$(CREATE_SEND_MAD_BASE_FLAG) \
|
||||
$(HAVE_IB_DMA_MAP_OPS) \
|
||||
$(GID_CHANGE_FLAG) \
|
||||
$(REGISTER_MAD_AGENT_FLAG) \
|
||||
$(QUERY_GID_FLAG) \
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE)
|
||||
|
||||
obj-m += ib_dma_map_ops.o
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <linux/module.h>
|
||||
#include <rdma/ib_verbs.h>
|
||||
|
||||
static struct ib_device *dev;
|
||||
|
||||
static int modinit(void)
|
||||
{
|
||||
return dev->dma_ops != NULL;
|
||||
}
|
||||
|
||||
module_init(modinit);
|
||||
@@ -0,0 +1,136 @@
|
||||
#include <linux/dma-mapping.h>
|
||||
|
||||
/* <rdma/ib_verbs.h> */
|
||||
#ifndef HAVE_IB_DMA_MAP_OPS
|
||||
static inline int ib_dma_mapping_error(struct ib_device *dev, u64 dma_addr)
|
||||
{
|
||||
return dma_mapping_error(dev->dma_device, dma_addr);
|
||||
}
|
||||
|
||||
static inline u64 ib_dma_map_single(struct ib_device *dev,
|
||||
void *cpu_addr, size_t size,
|
||||
enum dma_data_direction direction)
|
||||
{
|
||||
return dma_map_single(dev->dma_device, cpu_addr, size, direction);
|
||||
}
|
||||
|
||||
static inline void ib_dma_unmap_single(struct ib_device *dev,
|
||||
u64 addr, size_t size,
|
||||
enum dma_data_direction direction)
|
||||
{
|
||||
dma_unmap_single(dev->dma_device, addr, size, direction);
|
||||
}
|
||||
|
||||
static inline u64 ib_dma_map_single_attrs(struct ib_device *dev,
|
||||
void *cpu_addr, size_t size,
|
||||
enum dma_data_direction direction,
|
||||
unsigned long dma_attrs)
|
||||
{
|
||||
return dma_map_single_attrs(dev->dma_device, cpu_addr, size,
|
||||
direction, dma_attrs);
|
||||
}
|
||||
|
||||
static inline void ib_dma_unmap_single_attrs(struct ib_device *dev,
|
||||
u64 addr, size_t size,
|
||||
enum dma_data_direction direction,
|
||||
unsigned long dma_attrs)
|
||||
{
|
||||
return dma_unmap_single_attrs(dev->dma_device, addr, size,
|
||||
direction, dma_attrs);
|
||||
}
|
||||
|
||||
static inline u64 ib_dma_map_page(struct ib_device *dev,
|
||||
struct page *page,
|
||||
unsigned long offset,
|
||||
size_t size,
|
||||
enum dma_data_direction direction)
|
||||
{
|
||||
return dma_map_page(dev->dma_device, page, offset, size, direction);
|
||||
}
|
||||
|
||||
static inline void ib_dma_unmap_page(struct ib_device *dev,
|
||||
u64 addr, size_t size,
|
||||
enum dma_data_direction direction)
|
||||
{
|
||||
dma_unmap_page(dev->dma_device, addr, size, direction);
|
||||
}
|
||||
|
||||
static inline int ib_dma_map_sg(struct ib_device *dev,
|
||||
struct scatterlist *sg, int nents,
|
||||
enum dma_data_direction direction)
|
||||
{
|
||||
return dma_map_sg(dev->dma_device, sg, nents, direction);
|
||||
}
|
||||
|
||||
static inline void ib_dma_unmap_sg(struct ib_device *dev,
|
||||
struct scatterlist *sg, int nents,
|
||||
enum dma_data_direction direction)
|
||||
{
|
||||
dma_unmap_sg(dev->dma_device, sg, nents, direction);
|
||||
}
|
||||
|
||||
static inline int ib_dma_map_sg_attrs(struct ib_device *dev,
|
||||
struct scatterlist *sg, int nents,
|
||||
enum dma_data_direction direction,
|
||||
unsigned long dma_attrs)
|
||||
{
|
||||
return dma_map_sg_attrs(dev->dma_device, sg, nents, direction,
|
||||
dma_attrs);
|
||||
}
|
||||
|
||||
static inline void ib_dma_unmap_sg_attrs(struct ib_device *dev,
|
||||
struct scatterlist *sg, int nents,
|
||||
enum dma_data_direction direction,
|
||||
unsigned long dma_attrs)
|
||||
{
|
||||
dma_unmap_sg_attrs(dev->dma_device, sg, nents, direction, dma_attrs);
|
||||
}
|
||||
|
||||
static inline u64 ib_sg_dma_address(struct ib_device *dev,
|
||||
struct scatterlist *sg)
|
||||
{
|
||||
return sg_dma_address(sg);
|
||||
}
|
||||
|
||||
static inline unsigned int ib_sg_dma_len(struct ib_device *dev,
|
||||
struct scatterlist *sg)
|
||||
{
|
||||
return sg_dma_len(sg);
|
||||
}
|
||||
|
||||
static inline void ib_dma_sync_single_for_cpu(struct ib_device *dev,
|
||||
u64 addr,
|
||||
size_t size,
|
||||
enum dma_data_direction dir)
|
||||
{
|
||||
dma_sync_single_for_cpu(dev->dma_device, addr, size, dir);
|
||||
}
|
||||
|
||||
static inline void ib_dma_sync_single_for_device(struct ib_device *dev,
|
||||
u64 addr,
|
||||
size_t size,
|
||||
enum dma_data_direction dir)
|
||||
{
|
||||
dma_sync_single_for_device(dev->dma_device, addr, size, dir);
|
||||
}
|
||||
|
||||
static inline void *ib_dma_alloc_coherent(struct ib_device *dev,
|
||||
size_t size,
|
||||
u64 *dma_handle,
|
||||
gfp_t flag)
|
||||
{
|
||||
dma_addr_t handle;
|
||||
void *ret;
|
||||
|
||||
ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag);
|
||||
*dma_handle = handle;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void ib_dma_free_coherent(struct ib_device *dev,
|
||||
size_t size, void *cpu_addr,
|
||||
u64 dma_handle)
|
||||
{
|
||||
dma_free_coherent(dev->dma_device, size, cpu_addr, dma_handle);
|
||||
}
|
||||
#endif
|
||||
@@ -59,6 +59,7 @@
|
||||
#endif
|
||||
#endif
|
||||
#include <rdma/ib_cache.h>
|
||||
#include "backport.h"
|
||||
#include "ib_srpt.h"
|
||||
#include "srp-ext.h"
|
||||
#define LOG_PREFIX "ib_srpt" /* Prefix for SCST tracing macros. */
|
||||
|
||||
Reference in New Issue
Block a user