[ofa-general] [PATCH ofed-1.2-rc3 3/3] ehca: backport for rhel-4.5 - use introduced dma_ops
Stefan Roscher
ossrosch at linux.vnet.ibm.com
Thu May 10 05:41:57 PDT 2007
use introduced dma_ops
Signed-off-by: Stefan Roscher <stefan.roscher at de.ibm.com>
---
Makefile | 2
ehca_dma.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ehca_main.c | 2
3 files changed, 197 insertions(+), 1 deletion(-)
diff -Nurp ofa_kernel-1.2_orig/drivers/infiniband/hw/ehca/ehca_dma.c ofa_kernel-1.2_new/drivers/infiniband/hw/ehca/ehca_dma.c
--- ofa_kernel-1.2_orig/drivers/infiniband/hw/ehca/ehca_dma.c 1970-01-01 01:00:00.000000000 +0100
+++ ofa_kernel-1.2_new/drivers/infiniband/hw/ehca/ehca_dma.c 2007-05-03 16:25:30.000000000 +0200
@@ -0,0 +1,194 @@
+/*
+ * IBM eServer eHCA Infiniband device driver for Linux on POWER
+ *
+ * eHCA dma mapping via ibmebus
+ *
+ * Authors: Stefan Roscher <stefan.roscher at de.ibm.com>
+ * Hoang-Nam Nguyen <hnguyen at de.ibm.com>
+ *
+ * Copyright (c) 2007 IBM Corporation
+ *
+ * All rights reserved.
+ *
+ * This source code is distributed under a dual license of GPL v2.0 and OpenIB
+ * BSD.
+ *
+ * OpenIB BSD License
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <asm/ibmebus.h>
+#include <rdma/ib_verbs.h>
+
+static int ehca_mapping_error(struct ib_device *dev, u64 dma_addr);
+
+static u64 ehca_dma_map_single(struct ib_device *dev,
+ void *cpu_addr, size_t size,
+ enum dma_data_direction direction);
+
+static void ehca_dma_unmap_single(struct ib_device *dev,
+ u64 addr, size_t size,
+ enum dma_data_direction direction);
+
+static u64 ehca_dma_map_page(struct ib_device *dev,
+ struct page *page,
+ unsigned long offset,
+ size_t size,
+ enum dma_data_direction direction);
+
+static void ehca_dma_unmap_page(struct ib_device *dev,
+ u64 addr, size_t size,
+ enum dma_data_direction direction);
+
+int ehca_map_sg(struct ib_device *dev, struct scatterlist *sg, int nents,
+ enum dma_data_direction direction);
+
+static void ehca_unmap_sg(struct ib_device *dev,
+ struct scatterlist *sg, int nents,
+ enum dma_data_direction direction);
+
+static u64 ehca_sg_dma_address(struct ib_device *dev, struct scatterlist *sg);
+
+static unsigned int ehca_sg_dma_len(struct ib_device *dev,
+ struct scatterlist *sg);
+
+static void ehca_sync_single_for_cpu(struct ib_device *dev,
+ u64 addr,
+ size_t size,
+ enum dma_data_direction dir);
+
+static void ehca_sync_single_for_device(struct ib_device *dev,
+ u64 addr,
+ size_t size,
+ enum dma_data_direction dir);
+
+static void *ehca_dma_alloc_coherent(struct ib_device *dev, size_t size,
+ u64 *dma_handle, gfp_t flag);
+
+static void ehca_dma_free_coherent(struct ib_device *dev, size_t size,
+ void *cpu_addr, dma_addr_t dma_handle);
+
+struct ib_dma_mapping_ops ehca_dma_mapping_ops = {
+ ehca_mapping_error,
+ ehca_dma_map_single,
+ ehca_dma_unmap_single,
+ ehca_dma_map_page,
+ ehca_dma_unmap_page,
+ ehca_map_sg,
+ ehca_unmap_sg,
+ ehca_sg_dma_address,
+ ehca_sg_dma_len,
+ ehca_sync_single_for_cpu,
+ ehca_sync_single_for_device,
+ ehca_dma_alloc_coherent,
+ ehca_dma_free_coherent
+};
+
+static int ehca_mapping_error(struct ib_device *dev, u64 dma_addr)
+{
+ return dma_addr == 0L;
+}
+
+static u64 ehca_dma_map_single(struct ib_device *dev,
+ void *cpu_addr, size_t size,
+ enum dma_data_direction direction)
+{
+ return ibmebus_map_single(dev, cpu_addr, size, direction);
+}
+
+static void ehca_dma_unmap_single(struct ib_device *dev,
+ u64 addr, size_t size,
+ enum dma_data_direction direction)
+{
+ ibmebus_unmap_single(dev, addr, size, direction);
+}
+
+static u64 ehca_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 void ehca_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);
+}
+
+int ehca_map_sg(struct ib_device *dev, struct scatterlist *sg, int nents,
+ enum dma_data_direction direction)
+{
+ return ibmebus_map_sg(dev, sg, nents, direction);
+}
+
+static void ehca_unmap_sg(struct ib_device *dev,
+ struct scatterlist *sg, int nents,
+ enum dma_data_direction direction)
+{
+ ibmebus_unmap_sg(dev, sg, nents, direction);
+}
+
+static u64 ehca_sg_dma_address(struct ib_device *dev, struct scatterlist *sg)
+{
+ return sg_dma_address(sg);
+}
+
+static unsigned int ehca_sg_dma_len(struct ib_device *dev,
+ struct scatterlist *sg)
+{
+ return sg_dma_len(sg);
+}
+
+static void ehca_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 void ehca_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 void *ehca_dma_alloc_coherent(struct ib_device *dev, size_t size,
+ u64 *dma_handle, gfp_t flag)
+{
+ return ibmebus_alloc_coherent(dev, size, dma_handle, flag);
+}
+
+static void ehca_dma_free_coherent(struct ib_device *dev, size_t size,
+ void *cpu_addr, dma_addr_t dma_handle)
+{
+ ibmebus_free_coherent(dev, size, cpu_addr, dma_handle);
+}
diff -Nurp ofa_kernel-1.2_orig/drivers/infiniband/hw/ehca/ehca_main.c ofa_kernel-1.2_new/drivers/infiniband/hw/ehca/ehca_main.c
--- ofa_kernel-1.2_orig/drivers/infiniband/hw/ehca/ehca_main.c 2007-04-29 15:10:56.000000000 +0200
+++ ofa_kernel-1.2_new/drivers/infiniband/hw/ehca/ehca_main.c 2007-05-03 16:19:28.000000000 +0200
@@ -279,6 +279,7 @@ init_node_guid1:
int ehca_init_device(struct ehca_shca *shca)
{
+ extern struct ib_dma_mapping_ops ehca_dma_mapping_ops;
int ret;
ret = init_node_guid(shca);
@@ -354,6 +355,7 @@ int ehca_init_device(struct ehca_shca *s
shca->ib_device.detach_mcast = ehca_detach_mcast;
/* shca->ib_device.process_mad = ehca_process_mad; */
shca->ib_device.mmap = ehca_mmap;
+ shca->ib_device.dma_ops = &ehca_dma_mapping_ops;
return ret;
}
diff -Nurp ofa_kernel-1.2_orig/drivers/infiniband/hw/ehca/Makefile ofa_kernel-1.2_new/drivers/infiniband/hw/ehca/Makefile
--- ofa_kernel-1.2_orig/drivers/infiniband/hw/ehca/Makefile 2007-04-29 15:10:56.000000000 +0200
+++ ofa_kernel-1.2_new/drivers/infiniband/hw/ehca/Makefile 2007-05-03 16:26:13.000000000 +0200
@@ -12,5 +12,5 @@ obj-$(CONFIG_INFINIBAND_EHCA) += ib_ehca
ib_ehca-objs = ehca_main.o ehca_hca.o ehca_mcast.o ehca_pd.o ehca_av.o ehca_eq.o \
ehca_cq.o ehca_qp.o ehca_sqp.o ehca_mrmw.o ehca_reqs.o ehca_irq.o \
- ehca_uverbs.o ipz_pt_fn.o hcp_if.o hcp_phyp.o
+ ehca_uverbs.o ehca_dma.o ipz_pt_fn.o hcp_if.o hcp_phyp.o
More information about the general
mailing list