Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / infiniband / hw / ehca / ehca_classes.h
index daf823ea1acedb242caa59e22b35de602570d1b5..2d660ae189e544b54b3895cc4f0fc2f7d58312ea 100644 (file)
@@ -43,7 +43,6 @@
 #ifndef __EHCA_CLASSES_H__
 #define __EHCA_CLASSES_H__
 
-
 struct ehca_module;
 struct ehca_qp;
 struct ehca_cq;
@@ -54,6 +53,7 @@ struct ehca_pd;
 struct ehca_av;
 
 #include <linux/wait.h>
+#include <linux/mutex.h>
 
 #include <rdma/ib_verbs.h>
 #include <rdma/ib_user_verbs.h>
@@ -100,9 +100,14 @@ struct ehca_sport {
        struct ehca_sma_attr saved_attr;
 };
 
+#define HCA_CAP_MR_PGSIZE_4K  0x80000000
+#define HCA_CAP_MR_PGSIZE_64K 0x40000000
+#define HCA_CAP_MR_PGSIZE_1M  0x20000000
+#define HCA_CAP_MR_PGSIZE_16M 0x10000000
+
 struct ehca_shca {
        struct ib_device ib_device;
-       struct ibmebus_dev *ibmebus_dev;
+       struct of_device *ofdev;
        u8 num_ports;
        int hw_level;
        struct list_head shca_list;
@@ -115,6 +120,8 @@ struct ehca_shca {
        struct h_galpas galpas;
        struct mutex modify_mutex;
        u64 hca_cap;
+       /* MR pgsize: bit 0-3 means 4K, 64K, 1M, 16M respectively */
+       u32 hca_cap_mr_pgsize;
        int max_mtu;
 };
 
@@ -122,6 +129,10 @@ struct ehca_pd {
        struct ib_pd ib_pd;
        struct ipz_pd fw_pd;
        u32 ownpid;
+       /* small queue mgmt */
+       struct mutex lock;
+       struct list_head free[2];
+       struct list_head full[2];
 };
 
 enum ehca_ext_qp_type {
@@ -204,11 +215,12 @@ struct ehca_mr {
        spinlock_t mrlock;
 
        enum ehca_mr_flag flags;
-       u32 num_pages;          /* number of MR pages */
-       u32 num_4k;             /* number of 4k "page" portions to form MR */
+       u32 num_kpages;         /* number of kernel pages */
+       u32 num_hwpages;        /* number of hw pages to form MR */
+       u64 hwpage_size;        /* hw page size used for this MR */
        int acl;                /* ACL (stored here for usage in reregister) */
        u64 *start;             /* virtual start address (stored here for */
-                               /* usage in reregister) */
+                               /* usage in reregister) */
        u64 size;               /* size (stored here for usage in reregister) */
        u32 fmr_page_size;      /* page size for FMR */
        u32 fmr_max_pages;      /* max pages for FMR */
@@ -217,9 +229,6 @@ struct ehca_mr {
        /* fw specific data */
        struct ipz_mrmw_handle ipz_mr_handle;   /* MR handle for h-calls */
        struct h_galpas galpas;
-       /* data for userspace bridge */
-       u32 nr_of_pages;
-       void *pagearray;
 };
 
 struct ehca_mw {
@@ -241,26 +250,30 @@ enum ehca_mr_pgi_type {
 
 struct ehca_mr_pginfo {
        enum ehca_mr_pgi_type type;
-       u64 num_pages;
-       u64 page_cnt;
-       u64 num_4k;       /* number of 4k "page" portions */
-       u64 page_4k_cnt;  /* counter for 4k "page" portions */
-       u64 next_4k;      /* next 4k "page" portion in buffer/chunk/listelem */
-
-       /* type EHCA_MR_PGI_PHYS section */
-       int num_phys_buf;
-       struct ib_phys_buf *phys_buf_array;
-       u64 next_buf;
-
-       /* type EHCA_MR_PGI_USER section */
-       struct ib_umem *region;
-       struct ib_umem_chunk *next_chunk;
-       u64 next_nmap;
-
-       /* type EHCA_MR_PGI_FMR section */
-       u64 *page_list;
-       u64 next_listelem;
-       /* next_4k also used within EHCA_MR_PGI_FMR */
+       u64 num_kpages;
+       u64 kpage_cnt;
+       u64 hwpage_size;     /* hw page size used for this MR */
+       u64 num_hwpages;     /* number of hw pages */
+       u64 hwpage_cnt;      /* counter for hw pages */
+       u64 next_hwpage;     /* next hw page in buffer/chunk/listelem */
+
+       union {
+               struct { /* type EHCA_MR_PGI_PHYS section */
+                       int num_phys_buf;
+                       struct ib_phys_buf *phys_buf_array;
+                       u64 next_buf;
+               } phy;
+               struct { /* type EHCA_MR_PGI_USER section */
+                       struct ib_umem *region;
+                       struct ib_umem_chunk *next_chunk;
+                       u64 next_nmap;
+               } usr;
+               struct { /* type EHCA_MR_PGI_FMR section */
+                       u64 fmr_pgsize;
+                       u64 *page_list;
+                       u64 next_listelem;
+               } fmr;
+       } u;
 };
 
 /* output parameters for MR/FMR hipz calls */
@@ -298,6 +311,8 @@ int ehca_init_av_cache(void);
 void ehca_cleanup_av_cache(void);
 int ehca_init_mrmw_cache(void);
 void ehca_cleanup_mrmw_cache(void);
+int ehca_init_small_qp_cache(void);
+void ehca_cleanup_small_qp_cache(void);
 
 extern rwlock_t ehca_qp_idr_lock;
 extern rwlock_t ehca_cq_idr_lock;
@@ -315,13 +330,15 @@ struct ipzu_queue_resp {
        u32 queue_length; /* queue length allocated in bytes */
        u32 pagesize;
        u32 toggle_state;
-       u32 dummy; /* padding for 8 byte alignment */
+       u32 offset; /* save offset within a page for small_qp */
 };
 
 struct ehca_create_cq_resp {
        u32 cq_number;
        u32 token;
        struct ipzu_queue_resp ipz_queue;
+       u32 fw_handle_ofs;
+       u32 dummy;
 };
 
 struct ehca_create_qp_resp {
@@ -332,7 +349,8 @@ struct ehca_create_qp_resp {
        u32 qkey;
        /* qp_num assigned by ehca: sqp0/1 may have got different numbers */
        u32 real_qp_num;
-       u32 dummy; /* padding for 8 byte alignment */
+       u32 fw_handle_ofs;
+       u32 dummy;
        struct ipzu_queue_resp ipz_squeue;
        struct ipzu_queue_resp ipz_rqueue;
 };
@@ -357,15 +375,29 @@ enum ehca_ll_comp_flags {
        LLQP_COMP_MASK = 0x60,
 };
 
+struct ehca_alloc_queue_parms {
+       /* input parameters */
+       int max_wr;
+       int max_sge;
+       int page_size;
+       int is_small;
+
+       /* output parameters */
+       u16 act_nr_wqes;
+       u8  act_nr_sges;
+       u32 queue_size; /* bytes for small queues, pages otherwise */
+};
+
 struct ehca_alloc_qp_parms {
-/* input parameters */
+       struct ehca_alloc_queue_parms squeue;
+       struct ehca_alloc_queue_parms rqueue;
+
+       /* input parameters */
        enum ehca_service_type servicetype;
+       int qp_storage;
        int sigtype;
        enum ehca_ext_qp_type ext_type;
        enum ehca_ll_comp_flags ll_comp_flags;
-
-       int max_send_wr, max_recv_wr;
-       int max_send_sge, max_recv_sge;
        int ud_av_l_key_ctl;
 
        u32 token;
@@ -375,22 +407,14 @@ struct ehca_alloc_qp_parms {
 
        u32 srq_qpn, srq_token, srq_limit;
 
-/* output parameters */
+       /* output parameters */
        u32 real_qp_num;
        struct ipz_qp_handle qp_handle;
        struct h_galpas galpas;
-
-       u16 act_nr_send_wqes;
-       u16 act_nr_recv_wqes;
-       u8  act_nr_recv_sges;
-       u8  act_nr_send_sges;
-
-       u32 nr_rq_pages;
-       u32 nr_sq_pages;
 };
 
 int ehca_cq_assign_qp(struct ehca_cq *cq, struct ehca_qp *qp);
 int ehca_cq_unassign_qp(struct ehca_cq *cq, unsigned int qp_num);
-struct ehca_qpehca_cq_get_qp(struct ehca_cq *cq, int qp_num);
+struct ehca_qp *ehca_cq_get_qp(struct ehca_cq *cq, int qp_num);
 
 #endif