RDMA/cxgb3: Fix severe limit on userspace memory registration size
[linux-2.6.git] / drivers / infiniband / hw / cxgb3 / iwch_provider.h
index 61e3278..836163f 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Copyright (c) 2006 Chelsio, Inc. All rights reserved.
- * Copyright (c) 2006 Open Grid Computing, 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
@@ -74,6 +73,7 @@ struct tpt_attributes {
 
 struct iwch_mr {
        struct ib_mr ibmr;
+       struct ib_umem *umem;
        struct iwch_dev *rhp;
        u64 kva;
        struct tpt_attributes attr;
@@ -118,6 +118,7 @@ enum IWCH_QP_FLAGS {
 };
 
 struct iwch_mpa_attributes {
+       u8 initiator;
        u8 recv_marker_enabled;
        u8 xmit_marker_enabled; /* iWARP: enable inbound Read Resp. */
        u8 crc_enabled;
@@ -179,7 +180,6 @@ static inline struct iwch_qp *to_iwch_qp(struct ib_qp *ibqp)
 
 void iwch_qp_add_ref(struct ib_qp *qp);
 void iwch_qp_rem_ref(struct ib_qp *qp);
-struct ib_qp *iwch_get_qp(struct ib_device *dev, int qpn);
 
 struct iwch_ucontext {
        struct ib_ucontext ibucontext;
@@ -214,7 +214,7 @@ static inline struct iwch_mm_entry *remove_mmap(struct iwch_ucontext *ucontext,
                if (mm->key == key && mm->len == len) {
                        list_del_init(&mm->entry);
                        spin_unlock(&ucontext->mmap_lock);
-                       PDBG("%s key 0x%x addr 0x%llx len %d\n", __FUNCTION__,
+                       PDBG("%s key 0x%x addr 0x%llx len %d\n", __func__,
                             key, (unsigned long long) mm->addr, mm->len);
                        return mm;
                }
@@ -227,7 +227,7 @@ static inline void insert_mmap(struct iwch_ucontext *ucontext,
                               struct iwch_mm_entry *mm)
 {
        spin_lock(&ucontext->mmap_lock);
-       PDBG("%s key 0x%x addr 0x%llx len %d\n", __FUNCTION__,
+       PDBG("%s key 0x%x addr 0x%llx len %d\n", __func__,
             mm->key, (unsigned long long) mm->addr, mm->len);
        list_add_tail(&mm->entry, &ucontext->mmaps);
        spin_unlock(&ucontext->mmap_lock);
@@ -288,27 +288,20 @@ static inline int iwch_convert_state(enum ib_qp_state ib_state)
        }
 }
 
-enum iwch_mem_perms {
-       IWCH_MEM_ACCESS_LOCAL_READ = 1 << 0,
-       IWCH_MEM_ACCESS_LOCAL_WRITE = 1 << 1,
-       IWCH_MEM_ACCESS_REMOTE_READ = 1 << 2,
-       IWCH_MEM_ACCESS_REMOTE_WRITE = 1 << 3,
-       IWCH_MEM_ACCESS_ATOMICS = 1 << 4,
-       IWCH_MEM_ACCESS_BINDING = 1 << 5,
-       IWCH_MEM_ACCESS_LOCAL =
-           (IWCH_MEM_ACCESS_LOCAL_READ | IWCH_MEM_ACCESS_LOCAL_WRITE),
-       IWCH_MEM_ACCESS_REMOTE =
-           (IWCH_MEM_ACCESS_REMOTE_WRITE | IWCH_MEM_ACCESS_REMOTE_READ)
-           /* cannot go beyond 1 << 31 */
-} __attribute__ ((packed));
-
-static inline u32 iwch_convert_access(int acc)
+static inline u32 iwch_ib_to_tpt_access(int acc)
 {
-       return (acc & IB_ACCESS_REMOTE_WRITE ? IWCH_MEM_ACCESS_REMOTE_WRITE : 0)
-           | (acc & IB_ACCESS_REMOTE_READ ? IWCH_MEM_ACCESS_REMOTE_READ : 0) |
-           (acc & IB_ACCESS_LOCAL_WRITE ? IWCH_MEM_ACCESS_LOCAL_WRITE : 0) |
-           (acc & IB_ACCESS_MW_BIND ? IWCH_MEM_ACCESS_BINDING : 0) |
-           IWCH_MEM_ACCESS_LOCAL_READ;
+       return (acc & IB_ACCESS_REMOTE_WRITE ? TPT_REMOTE_WRITE : 0) |
+              (acc & IB_ACCESS_REMOTE_READ ? TPT_REMOTE_READ : 0) |
+              (acc & IB_ACCESS_LOCAL_WRITE ? TPT_LOCAL_WRITE : 0) |
+              TPT_LOCAL_READ;
+}
+
+static inline u32 iwch_ib_to_mwbind_access(int acc)
+{
+       return (acc & IB_ACCESS_REMOTE_WRITE ? T3_MEM_ACCESS_REM_WRITE : 0) |
+              (acc & IB_ACCESS_REMOTE_READ ? T3_MEM_ACCESS_REM_READ : 0) |
+              (acc & IB_ACCESS_LOCAL_WRITE ? T3_MEM_ACCESS_LOCAL_WRITE : 0) |
+              T3_MEM_ACCESS_LOCAL_READ;
 }
 
 enum iwch_mmid_state {
@@ -330,6 +323,7 @@ enum iwch_qp_query_flags {
        IWCH_QP_QUERY_TEST_USERWRITE = 0x32     /* Test special */
 };
 
+u16 iwch_rqes_posted(struct iwch_qp *qhp);
 int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
                      struct ib_send_wr **bad_wr);
 int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
@@ -339,20 +333,21 @@ int iwch_bind_mw(struct ib_qp *qp,
                             struct ib_mw_bind *mw_bind);
 int iwch_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *wc);
 int iwch_post_terminate(struct iwch_qp *qhp, struct respQ_msg_t *rsp_msg);
+int iwch_post_zb_read(struct iwch_qp *qhp);
 int iwch_register_device(struct iwch_dev *dev);
 void iwch_unregister_device(struct iwch_dev *dev);
 int iwch_quiesce_qps(struct iwch_cq *chp);
 int iwch_resume_qps(struct iwch_cq *chp);
 void stop_read_rep_timer(struct iwch_qp *qhp);
 int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php,
-                                       struct iwch_mr *mhp,
-                                       int shift,
-                                       __be64 *page_list);
+                     struct iwch_mr *mhp, int shift);
 int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php,
                                        struct iwch_mr *mhp,
                                        int shift,
-                                       __be64 *page_list,
                                        int npages);
+int iwch_alloc_pbl(struct iwch_mr *mhp, int npages);
+void iwch_free_pbl(struct iwch_mr *mhp);
+int iwch_write_pbl(struct iwch_mr *mhp, __be64 *pages, int npages, int offset);
 int build_phys_page_list(struct ib_phys_buf *buffer_list,
                                        int num_phys_buf,
                                        u64 *iova_start,