]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/rds/ib.h
rds: more FMRs are faster
[net-next-2.6.git] / net / rds / ib.h
index 64df4e79b29f27ffcb8e8242df4b344284734e74..d2dd23d5c1a0e987def8c60e32d955737a09a9a8 100644 (file)
@@ -3,11 +3,13 @@
 
 #include <rdma/ib_verbs.h>
 #include <rdma/rdma_cm.h>
+#include <linux/pci.h>
+#include <linux/slab.h>
 #include "rds.h"
 #include "rdma_transport.h"
 
 #define RDS_FMR_SIZE                   256
-#define RDS_FMR_POOL_SIZE              4096
+#define RDS_FMR_POOL_SIZE              8192
 
 #define RDS_IB_MAX_SGE                 8
 #define RDS_IB_RECV_SGE                2
@@ -19,6 +21,8 @@
 
 #define RDS_IB_SUPPORTED_PROTOCOLS     0x00000003      /* minor versions supported */
 
+#define RDS_IB_RECYCLE_BATCH_COUNT     32
+
 extern struct list_head rds_ib_devices;
 
 /*
@@ -26,20 +30,29 @@ extern struct list_head rds_ib_devices;
  * try and minimize the amount of memory tied up both the device and
  * socket receive queues.
  */
-/* page offset of the final full frag that fits in the page */
-#define RDS_PAGE_LAST_OFF (((PAGE_SIZE  / RDS_FRAG_SIZE) - 1) * RDS_FRAG_SIZE)
 struct rds_page_frag {
        struct list_head        f_item;
-       struct page             *f_page;
-       unsigned long           f_offset;
-       dma_addr_t              f_mapped;
+       struct list_head        f_cache_entry;
+       struct scatterlist      f_sg;
 };
 
 struct rds_ib_incoming {
        struct list_head        ii_frags;
+       struct list_head        ii_cache_entry;
        struct rds_incoming     ii_inc;
 };
 
+struct rds_ib_cache_head {
+       struct list_head *first;
+       unsigned long count;
+};
+
+struct rds_ib_refill_cache {
+       struct rds_ib_cache_head *percpu;
+       struct list_head         *xfer;
+       struct list_head         *ready;
+};
+
 struct rds_ib_connect_private {
        /* Add new fields at the end, and don't permute existing fields. */
        __be32                  dp_saddr;
@@ -53,8 +66,7 @@ struct rds_ib_connect_private {
 };
 
 struct rds_ib_send_work {
-       struct rds_message      *s_rm;
-       struct rds_rdma_op      *s_op;
+       void                    *s_op;
        struct ib_send_wr       s_wr;
        struct ib_sge           s_sge[RDS_IB_MAX_SGE];
        unsigned long           s_queued;
@@ -92,7 +104,7 @@ struct rds_ib_connection {
 
        /* tx */
        struct rds_ib_work_ring i_send_ring;
-       struct rds_message      *i_rm;
+       struct rm_data_op       *i_data_op;
        struct rds_header       *i_send_hdrs;
        u64                     i_send_hdrs_dma;
        struct rds_ib_send_work *i_sends;
@@ -106,8 +118,9 @@ struct rds_ib_connection {
        struct rds_header       *i_recv_hdrs;
        u64                     i_recv_hdrs_dma;
        struct rds_ib_recv_work *i_recvs;
-       struct rds_page_frag    i_frag;
        u64                     i_ack_recv;     /* last ACK received */
+       struct rds_ib_refill_cache i_cache_incs;
+       struct rds_ib_refill_cache i_cache_frags;
 
        /* sending acks */
        unsigned long           i_ack_flags;
@@ -138,7 +151,6 @@ struct rds_ib_connection {
 
        /* Batched completions */
        unsigned int            i_unsignaled_wrs;
-       long                    i_unsignaled_bytes;
 };
 
 /* This assumes that atomic_t is at least 32 bits */
@@ -164,9 +176,17 @@ struct rds_ib_device {
        unsigned int            max_fmrs;
        int                     max_sge;
        unsigned int            max_wrs;
+       unsigned int            max_initiator_depth;
+       unsigned int            max_responder_resources;
        spinlock_t              spinlock;       /* protect the above */
+       atomic_t                refcount;
+       struct work_struct      free_work;
 };
 
+#define pcidev_to_node(pcidev) pcibus_to_node(pcidev->bus)
+#define ibdev_to_node(ibdev) pcidev_to_node(to_pci_dev(ibdev->dma_device))
+#define rdsibdev_to_node(rdsibdev) ibdev_to_node(rdsibdev->dev)
+
 /* bits for i_ack_flags */
 #define IB_ACK_IN_FLIGHT       0
 #define IB_ACK_REQUESTED       1
@@ -202,6 +222,8 @@ struct rds_ib_statistics {
        uint64_t        s_ib_rdma_mr_pool_flush;
        uint64_t        s_ib_rdma_mr_pool_wait;
        uint64_t        s_ib_rdma_mr_pool_depleted;
+       uint64_t        s_ib_atomic_cswp;
+       uint64_t        s_ib_atomic_fadd;
 };
 
 extern struct workqueue_struct *rds_ib_wq;
@@ -243,6 +265,8 @@ static inline void rds_ib_dma_sync_sg_for_device(struct ib_device *dev,
 extern struct rds_transport rds_ib_transport;
 extern void rds_ib_add_one(struct ib_device *device);
 extern void rds_ib_remove_one(struct ib_device *device);
+struct rds_ib_device *rds_ib_get_client_data(struct ib_device *device);
+void rds_ib_dev_put(struct rds_ib_device *rds_ibdev);
 extern struct ib_client rds_ib_client;
 
 extern unsigned int fmr_pool_size;
@@ -297,9 +321,9 @@ void rds_ib_flush_mrs(void);
 int __init rds_ib_recv_init(void);
 void rds_ib_recv_exit(void);
 int rds_ib_recv(struct rds_connection *conn);
-int rds_ib_recv_refill(struct rds_connection *conn, gfp_t kptr_gfp,
-                      gfp_t page_gfp, int prefill);
-void rds_ib_inc_purge(struct rds_incoming *inc);
+int rds_ib_recv_alloc_caches(struct rds_ib_connection *ic);
+void rds_ib_recv_free_caches(struct rds_ib_connection *ic);
+int rds_ib_recv_refill(struct rds_connection *conn, int prefill);
 void rds_ib_inc_free(struct rds_incoming *inc);
 int rds_ib_inc_copy_to_user(struct rds_incoming *inc, struct iovec *iov,
                             size_t size);
@@ -331,11 +355,12 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm,
 void rds_ib_send_cq_comp_handler(struct ib_cq *cq, void *context);
 void rds_ib_send_init_ring(struct rds_ib_connection *ic);
 void rds_ib_send_clear_ring(struct rds_ib_connection *ic);
-int rds_ib_xmit_rdma(struct rds_connection *conn, struct rds_rdma_op *op);
+int rds_ib_xmit_rdma(struct rds_connection *conn, struct rm_rdma_op *op);
 void rds_ib_send_add_credits(struct rds_connection *conn, unsigned int credits);
 void rds_ib_advertise_credits(struct rds_connection *conn, unsigned int posted);
 int rds_ib_send_grab_credits(struct rds_ib_connection *ic, u32 wanted,
                             u32 *adv_credits, int need_posted, int max_posted);
+int rds_ib_xmit_atomic(struct rds_connection *conn, struct rm_atomic_op *op);
 
 /* ib_stats.c */
 DECLARE_PER_CPU(struct rds_ib_statistics, rds_ib_stats);
@@ -354,28 +379,4 @@ extern unsigned long rds_ib_sysctl_max_recv_allocation;
 extern unsigned int rds_ib_sysctl_flow_control;
 extern ctl_table rds_ib_sysctl_table[];
 
-/*
- * Helper functions for getting/setting the header and data SGEs in
- * RDS packets (not RDMA)
- *
- * From version 3.1 onwards, header is in front of data in the sge.
- */
-static inline struct ib_sge *
-rds_ib_header_sge(struct rds_ib_connection *ic, struct ib_sge *sge)
-{
-       if (ic->conn->c_version > RDS_PROTOCOL_3_0)
-               return &sge[0];
-       else
-               return &sge[1];
-}
-
-static inline struct ib_sge *
-rds_ib_data_sge(struct rds_ib_connection *ic, struct ib_sge *sge)
-{
-       if (ic->conn->c_version > RDS_PROTOCOL_3_0)
-               return &sge[1];
-       else
-               return &sge[0];
-}
-
 #endif