Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 1 | #ifndef _RDS_IB_H |
| 2 | #define _RDS_IB_H |
| 3 | |
| 4 | #include <rdma/ib_verbs.h> |
| 5 | #include <rdma/rdma_cm.h> |
Alexey Dobriyan | a6b7a40 | 2011-06-06 10:43:46 +0000 | [diff] [blame] | 6 | #include <linux/interrupt.h> |
Andy Grover | e4c52c9 | 2010-04-23 10:49:53 -0700 | [diff] [blame] | 7 | #include <linux/pci.h> |
| 8 | #include <linux/slab.h> |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 9 | #include "rds.h" |
| 10 | #include "rdma_transport.h" |
| 11 | |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 12 | #define RDS_IB_MAX_SGE 8 |
| 13 | #define RDS_IB_RECV_SGE 2 |
| 14 | |
| 15 | #define RDS_IB_DEFAULT_RECV_WR 1024 |
| 16 | #define RDS_IB_DEFAULT_SEND_WR 256 |
Santosh Shilimkar | 5601245 | 2016-03-08 09:19:01 -0800 | [diff] [blame] | 17 | #define RDS_IB_DEFAULT_FR_WR 256 |
| 18 | #define RDS_IB_DEFAULT_FR_INV_WR 256 |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 19 | |
Santosh Shilimkar | fab8688d | 2016-07-04 15:31:21 -0700 | [diff] [blame] | 20 | #define RDS_IB_DEFAULT_RETRY_COUNT 1 |
Andy Grover | 3ba23ad | 2009-07-17 13:13:22 +0000 | [diff] [blame] | 21 | |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 22 | #define RDS_IB_SUPPORTED_PROTOCOLS 0x00000003 /* minor versions supported */ |
| 23 | |
Chris Mason | 3324412 | 2010-05-26 22:05:37 -0700 | [diff] [blame] | 24 | #define RDS_IB_RECYCLE_BATCH_COUNT 32 |
| 25 | |
Santosh Shilimkar | f4f943c | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 26 | #define RDS_IB_WC_MAX 32 |
| 27 | |
Zach Brown | ea81986 | 2010-07-15 12:34:33 -0700 | [diff] [blame] | 28 | extern struct rw_semaphore rds_ib_devices_lock; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 29 | extern struct list_head rds_ib_devices; |
| 30 | |
| 31 | /* |
| 32 | * IB posts RDS_FRAG_SIZE fragments of pages to the receive queues to |
| 33 | * try and minimize the amount of memory tied up both the device and |
| 34 | * socket receive queues. |
| 35 | */ |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 36 | struct rds_page_frag { |
| 37 | struct list_head f_item; |
Chris Mason | 3324412 | 2010-05-26 22:05:37 -0700 | [diff] [blame] | 38 | struct list_head f_cache_entry; |
Andy Grover | 0b088e0 | 2010-05-24 20:12:41 -0700 | [diff] [blame] | 39 | struct scatterlist f_sg; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | struct rds_ib_incoming { |
| 43 | struct list_head ii_frags; |
Chris Mason | 3324412 | 2010-05-26 22:05:37 -0700 | [diff] [blame] | 44 | struct list_head ii_cache_entry; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 45 | struct rds_incoming ii_inc; |
| 46 | }; |
| 47 | |
Chris Mason | 3324412 | 2010-05-26 22:05:37 -0700 | [diff] [blame] | 48 | struct rds_ib_cache_head { |
| 49 | struct list_head *first; |
| 50 | unsigned long count; |
| 51 | }; |
| 52 | |
| 53 | struct rds_ib_refill_cache { |
Shan Wei | ae4b46e | 2012-11-12 15:52:01 +0000 | [diff] [blame] | 54 | struct rds_ib_cache_head __percpu *percpu; |
Chris Mason | 3324412 | 2010-05-26 22:05:37 -0700 | [diff] [blame] | 55 | struct list_head *xfer; |
| 56 | struct list_head *ready; |
| 57 | }; |
| 58 | |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 59 | struct rds_ib_connect_private { |
| 60 | /* Add new fields at the end, and don't permute existing fields. */ |
| 61 | __be32 dp_saddr; |
| 62 | __be32 dp_daddr; |
| 63 | u8 dp_protocol_major; |
| 64 | u8 dp_protocol_minor; |
| 65 | __be16 dp_protocol_minor_mask; /* bitmask */ |
| 66 | __be32 dp_reserved1; |
| 67 | __be64 dp_ack_seq; |
| 68 | __be32 dp_credit; /* non-zero enables flow ctl */ |
| 69 | }; |
| 70 | |
| 71 | struct rds_ib_send_work { |
Andy Grover | ff3d7d3 | 2010-03-01 14:03:09 -0800 | [diff] [blame] | 72 | void *s_op; |
Christoph Hellwig | e622f2f | 2015-10-08 09:16:33 +0100 | [diff] [blame] | 73 | union { |
| 74 | struct ib_send_wr s_wr; |
| 75 | struct ib_rdma_wr s_rdma_wr; |
| 76 | struct ib_atomic_wr s_atomic_wr; |
| 77 | }; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 78 | struct ib_sge s_sge[RDS_IB_MAX_SGE]; |
| 79 | unsigned long s_queued; |
| 80 | }; |
| 81 | |
| 82 | struct rds_ib_recv_work { |
| 83 | struct rds_ib_incoming *r_ibinc; |
| 84 | struct rds_page_frag *r_frag; |
| 85 | struct ib_recv_wr r_wr; |
| 86 | struct ib_sge r_sge[2]; |
| 87 | }; |
| 88 | |
| 89 | struct rds_ib_work_ring { |
| 90 | u32 w_nr; |
| 91 | u32 w_alloc_ptr; |
| 92 | u32 w_alloc_ctr; |
| 93 | u32 w_free_ptr; |
| 94 | atomic_t w_free_ctr; |
| 95 | }; |
| 96 | |
Santosh Shilimkar | f4f943c | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 97 | /* Rings are posted with all the allocations they'll need to queue the |
| 98 | * incoming message to the receiving socket so this can't fail. |
| 99 | * All fragments start with a header, so we can make sure we're not receiving |
| 100 | * garbage, and we can tell a small 8 byte fragment from an ACK frame. |
| 101 | */ |
| 102 | struct rds_ib_ack_state { |
| 103 | u64 ack_next; |
| 104 | u64 ack_recv; |
| 105 | unsigned int ack_required:1; |
| 106 | unsigned int ack_next_valid:1; |
| 107 | unsigned int ack_recv_valid:1; |
| 108 | }; |
| 109 | |
| 110 | |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 111 | struct rds_ib_device; |
| 112 | |
| 113 | struct rds_ib_connection { |
| 114 | |
| 115 | struct list_head ib_node; |
| 116 | struct rds_ib_device *rds_ibdev; |
| 117 | struct rds_connection *conn; |
| 118 | |
| 119 | /* alphabet soup, IBTA style */ |
| 120 | struct rdma_cm_id *i_cm_id; |
| 121 | struct ib_pd *i_pd; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 122 | struct ib_cq *i_send_cq; |
| 123 | struct ib_cq *i_recv_cq; |
Santosh Shilimkar | 0c28c04 | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 124 | struct ib_wc i_send_wc[RDS_IB_WC_MAX]; |
Santosh Shilimkar | f4f943c | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 125 | struct ib_wc i_recv_wc[RDS_IB_WC_MAX]; |
| 126 | |
santosh.shilimkar@oracle.com | ad6832f | 2016-03-01 15:20:53 -0800 | [diff] [blame] | 127 | /* To control the number of wrs from fastreg */ |
| 128 | atomic_t i_fastreg_wrs; |
Santosh Shilimkar | 5601245 | 2016-03-08 09:19:01 -0800 | [diff] [blame] | 129 | atomic_t i_fastunreg_wrs; |
santosh.shilimkar@oracle.com | ad6832f | 2016-03-01 15:20:53 -0800 | [diff] [blame] | 130 | |
Santosh Shilimkar | f4f943c | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 131 | /* interrupt handling */ |
Santosh Shilimkar | 0c28c04 | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 132 | struct tasklet_struct i_send_tasklet; |
Santosh Shilimkar | f4f943c | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 133 | struct tasklet_struct i_recv_tasklet; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 134 | |
| 135 | /* tx */ |
| 136 | struct rds_ib_work_ring i_send_ring; |
Andy Grover | ff3d7d3 | 2010-03-01 14:03:09 -0800 | [diff] [blame] | 137 | struct rm_data_op *i_data_op; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 138 | struct rds_header *i_send_hdrs; |
| 139 | u64 i_send_hdrs_dma; |
| 140 | struct rds_ib_send_work *i_sends; |
Zach Brown | f046011 | 2010-07-14 13:55:35 -0700 | [diff] [blame] | 141 | atomic_t i_signaled_sends; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 142 | |
| 143 | /* rx */ |
| 144 | struct mutex i_recv_mutex; |
| 145 | struct rds_ib_work_ring i_recv_ring; |
| 146 | struct rds_ib_incoming *i_ibinc; |
| 147 | u32 i_recv_data_rem; |
| 148 | struct rds_header *i_recv_hdrs; |
| 149 | u64 i_recv_hdrs_dma; |
| 150 | struct rds_ib_recv_work *i_recvs; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 151 | u64 i_ack_recv; /* last ACK received */ |
Chris Mason | 3324412 | 2010-05-26 22:05:37 -0700 | [diff] [blame] | 152 | struct rds_ib_refill_cache i_cache_incs; |
| 153 | struct rds_ib_refill_cache i_cache_frags; |
Santosh Shilimkar | 09b2b8f | 2016-07-09 17:14:02 -0700 | [diff] [blame^] | 154 | atomic_t i_cache_allocs; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 155 | |
| 156 | /* sending acks */ |
| 157 | unsigned long i_ack_flags; |
Andy Grover | 8cbd960 | 2009-04-01 08:20:20 +0000 | [diff] [blame] | 158 | #ifdef KERNEL_HAS_ATOMIC64 |
| 159 | atomic64_t i_ack_next; /* next ACK to send */ |
| 160 | #else |
| 161 | spinlock_t i_ack_lock; /* protect i_ack_next */ |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 162 | u64 i_ack_next; /* next ACK to send */ |
Andy Grover | 8cbd960 | 2009-04-01 08:20:20 +0000 | [diff] [blame] | 163 | #endif |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 164 | struct rds_header *i_ack; |
| 165 | struct ib_send_wr i_ack_wr; |
| 166 | struct ib_sge i_ack_sge; |
| 167 | u64 i_ack_dma; |
| 168 | unsigned long i_ack_queued; |
| 169 | |
| 170 | /* Flow control related information |
| 171 | * |
| 172 | * Our algorithm uses a pair variables that we need to access |
| 173 | * atomically - one for the send credits, and one posted |
| 174 | * recv credits we need to transfer to remote. |
| 175 | * Rather than protect them using a slow spinlock, we put both into |
| 176 | * a single atomic_t and update it using cmpxchg |
| 177 | */ |
| 178 | atomic_t i_credits; |
| 179 | |
| 180 | /* Protocol version specific information */ |
| 181 | unsigned int i_flowctl:1; /* enable/disable flow ctl */ |
| 182 | |
| 183 | /* Batched completions */ |
| 184 | unsigned int i_unsignaled_wrs; |
Santosh Shilimkar | 581d53c | 2016-07-09 18:31:38 -0700 | [diff] [blame] | 185 | |
| 186 | /* Endpoint role in connection */ |
| 187 | bool i_active_side; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 188 | }; |
| 189 | |
| 190 | /* This assumes that atomic_t is at least 32 bits */ |
| 191 | #define IB_GET_SEND_CREDITS(v) ((v) & 0xffff) |
| 192 | #define IB_GET_POST_CREDITS(v) ((v) >> 16) |
| 193 | #define IB_SET_SEND_CREDITS(v) ((v) & 0xffff) |
| 194 | #define IB_SET_POST_CREDITS(v) ((v) << 16) |
| 195 | |
| 196 | struct rds_ib_ipaddr { |
| 197 | struct list_head list; |
| 198 | __be32 ipaddr; |
Santosh Shilimkar | 59fe460 | 2012-02-03 11:09:23 -0500 | [diff] [blame] | 199 | struct rcu_head rcu; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 200 | }; |
| 201 | |
Santosh Shilimkar | 0676651 | 2015-09-10 21:20:57 -0700 | [diff] [blame] | 202 | enum { |
| 203 | RDS_IB_MR_8K_POOL, |
| 204 | RDS_IB_MR_1M_POOL, |
| 205 | }; |
| 206 | |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 207 | struct rds_ib_device { |
| 208 | struct list_head list; |
| 209 | struct list_head ipaddr_list; |
| 210 | struct list_head conn_list; |
| 211 | struct ib_device *dev; |
| 212 | struct ib_pd *pd; |
santosh.shilimkar@oracle.com | 2cb2912 | 2016-03-01 15:20:52 -0800 | [diff] [blame] | 213 | bool has_fmr; |
| 214 | bool has_fr; |
| 215 | bool use_fastreg; |
| 216 | |
santosh.shilimkar@oracle.com | f6df683 | 2016-03-01 15:20:46 -0800 | [diff] [blame] | 217 | unsigned int max_mrs; |
Santosh Shilimkar | 0676651 | 2015-09-10 21:20:57 -0700 | [diff] [blame] | 218 | struct rds_ib_mr_pool *mr_1m_pool; |
| 219 | struct rds_ib_mr_pool *mr_8k_pool; |
| 220 | unsigned int fmr_max_remaps; |
santosh.shilimkar@oracle.com | f6df683 | 2016-03-01 15:20:46 -0800 | [diff] [blame] | 221 | unsigned int max_8k_mrs; |
| 222 | unsigned int max_1m_mrs; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 223 | int max_sge; |
| 224 | unsigned int max_wrs; |
Andy Grover | 40589e7 | 2010-01-12 10:50:48 -0800 | [diff] [blame] | 225 | unsigned int max_initiator_depth; |
| 226 | unsigned int max_responder_resources; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 227 | spinlock_t spinlock; /* protect the above */ |
Zach Brown | 3e0249f | 2010-05-18 15:48:51 -0700 | [diff] [blame] | 228 | atomic_t refcount; |
| 229 | struct work_struct free_work; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 230 | }; |
| 231 | |
Thadeu Lima de Souza Cascardo | a0c6ffb | 2012-05-28 08:52:05 +0000 | [diff] [blame] | 232 | #define ibdev_to_node(ibdev) dev_to_node(ibdev->dma_device) |
Andy Grover | e4c52c9 | 2010-04-23 10:49:53 -0700 | [diff] [blame] | 233 | #define rdsibdev_to_node(rdsibdev) ibdev_to_node(rdsibdev->dev) |
| 234 | |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 235 | /* bits for i_ack_flags */ |
| 236 | #define IB_ACK_IN_FLIGHT 0 |
| 237 | #define IB_ACK_REQUESTED 1 |
| 238 | |
| 239 | /* Magic WR_ID for ACKs */ |
| 240 | #define RDS_IB_ACK_WR_ID (~(u64) 0) |
| 241 | |
| 242 | struct rds_ib_statistics { |
| 243 | uint64_t s_ib_connect_raced; |
| 244 | uint64_t s_ib_listen_closed_stale; |
Santosh Shilimkar | f4f943c | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 245 | uint64_t s_ib_evt_handler_call; |
| 246 | uint64_t s_ib_tasklet_call; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 247 | uint64_t s_ib_tx_cq_event; |
| 248 | uint64_t s_ib_tx_ring_full; |
| 249 | uint64_t s_ib_tx_throttle; |
| 250 | uint64_t s_ib_tx_sg_mapping_failure; |
| 251 | uint64_t s_ib_tx_stalled; |
| 252 | uint64_t s_ib_tx_credit_updates; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 253 | uint64_t s_ib_rx_cq_event; |
| 254 | uint64_t s_ib_rx_ring_empty; |
| 255 | uint64_t s_ib_rx_refill_from_cq; |
| 256 | uint64_t s_ib_rx_refill_from_thread; |
| 257 | uint64_t s_ib_rx_alloc_limit; |
Santosh Shilimkar | 09b2b8f | 2016-07-09 17:14:02 -0700 | [diff] [blame^] | 258 | uint64_t s_ib_rx_total_frags; |
| 259 | uint64_t s_ib_rx_total_incs; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 260 | uint64_t s_ib_rx_credit_updates; |
| 261 | uint64_t s_ib_ack_sent; |
| 262 | uint64_t s_ib_ack_send_failure; |
| 263 | uint64_t s_ib_ack_send_delayed; |
| 264 | uint64_t s_ib_ack_send_piggybacked; |
| 265 | uint64_t s_ib_ack_received; |
Santosh Shilimkar | 0676651 | 2015-09-10 21:20:57 -0700 | [diff] [blame] | 266 | uint64_t s_ib_rdma_mr_8k_alloc; |
| 267 | uint64_t s_ib_rdma_mr_8k_free; |
| 268 | uint64_t s_ib_rdma_mr_8k_used; |
| 269 | uint64_t s_ib_rdma_mr_8k_pool_flush; |
| 270 | uint64_t s_ib_rdma_mr_8k_pool_wait; |
| 271 | uint64_t s_ib_rdma_mr_8k_pool_depleted; |
| 272 | uint64_t s_ib_rdma_mr_1m_alloc; |
| 273 | uint64_t s_ib_rdma_mr_1m_free; |
| 274 | uint64_t s_ib_rdma_mr_1m_used; |
| 275 | uint64_t s_ib_rdma_mr_1m_pool_flush; |
| 276 | uint64_t s_ib_rdma_mr_1m_pool_wait; |
| 277 | uint64_t s_ib_rdma_mr_1m_pool_depleted; |
santosh.shilimkar@oracle.com | db42753 | 2016-03-01 15:20:51 -0800 | [diff] [blame] | 278 | uint64_t s_ib_rdma_mr_8k_reused; |
| 279 | uint64_t s_ib_rdma_mr_1m_reused; |
Andy Grover | 51e2cba | 2010-03-29 17:47:30 -0700 | [diff] [blame] | 280 | uint64_t s_ib_atomic_cswp; |
| 281 | uint64_t s_ib_atomic_fadd; |
Santosh Shilimkar | 09b2b8f | 2016-07-09 17:14:02 -0700 | [diff] [blame^] | 282 | uint64_t s_ib_recv_added_to_cache; |
| 283 | uint64_t s_ib_recv_removed_from_cache; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 284 | }; |
| 285 | |
| 286 | extern struct workqueue_struct *rds_ib_wq; |
| 287 | |
| 288 | /* |
| 289 | * Fake ib_dma_sync_sg_for_{cpu,device} as long as ib_verbs.h |
| 290 | * doesn't define it. |
| 291 | */ |
| 292 | static inline void rds_ib_dma_sync_sg_for_cpu(struct ib_device *dev, |
Fabian Frederick | d2a9ec6 | 2015-06-16 20:44:07 +0200 | [diff] [blame] | 293 | struct scatterlist *sglist, |
| 294 | unsigned int sg_dma_len, |
| 295 | int direction) |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 296 | { |
Fabian Frederick | d2a9ec6 | 2015-06-16 20:44:07 +0200 | [diff] [blame] | 297 | struct scatterlist *sg; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 298 | unsigned int i; |
| 299 | |
Fabian Frederick | d2a9ec6 | 2015-06-16 20:44:07 +0200 | [diff] [blame] | 300 | for_each_sg(sglist, sg, sg_dma_len, i) { |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 301 | ib_dma_sync_single_for_cpu(dev, |
Fabian Frederick | d2a9ec6 | 2015-06-16 20:44:07 +0200 | [diff] [blame] | 302 | ib_sg_dma_address(dev, sg), |
| 303 | ib_sg_dma_len(dev, sg), |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 304 | direction); |
| 305 | } |
| 306 | } |
| 307 | #define ib_dma_sync_sg_for_cpu rds_ib_dma_sync_sg_for_cpu |
| 308 | |
| 309 | static inline void rds_ib_dma_sync_sg_for_device(struct ib_device *dev, |
Fabian Frederick | d2a9ec6 | 2015-06-16 20:44:07 +0200 | [diff] [blame] | 310 | struct scatterlist *sglist, |
| 311 | unsigned int sg_dma_len, |
| 312 | int direction) |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 313 | { |
Fabian Frederick | d2a9ec6 | 2015-06-16 20:44:07 +0200 | [diff] [blame] | 314 | struct scatterlist *sg; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 315 | unsigned int i; |
| 316 | |
Fabian Frederick | d2a9ec6 | 2015-06-16 20:44:07 +0200 | [diff] [blame] | 317 | for_each_sg(sglist, sg, sg_dma_len, i) { |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 318 | ib_dma_sync_single_for_device(dev, |
Fabian Frederick | d2a9ec6 | 2015-06-16 20:44:07 +0200 | [diff] [blame] | 319 | ib_sg_dma_address(dev, sg), |
| 320 | ib_sg_dma_len(dev, sg), |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 321 | direction); |
| 322 | } |
| 323 | } |
| 324 | #define ib_dma_sync_sg_for_device rds_ib_dma_sync_sg_for_device |
| 325 | |
| 326 | |
| 327 | /* ib.c */ |
| 328 | extern struct rds_transport rds_ib_transport; |
Zach Brown | 3e0249f | 2010-05-18 15:48:51 -0700 | [diff] [blame] | 329 | struct rds_ib_device *rds_ib_get_client_data(struct ib_device *device); |
| 330 | void rds_ib_dev_put(struct rds_ib_device *rds_ibdev); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 331 | extern struct ib_client rds_ib_client; |
| 332 | |
Andy Grover | 3ba23ad | 2009-07-17 13:13:22 +0000 | [diff] [blame] | 333 | extern unsigned int rds_ib_retry_count; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 334 | |
| 335 | extern spinlock_t ib_nodev_conns_lock; |
| 336 | extern struct list_head ib_nodev_conns; |
| 337 | |
| 338 | /* ib_cm.c */ |
| 339 | int rds_ib_conn_alloc(struct rds_connection *conn, gfp_t gfp); |
| 340 | void rds_ib_conn_free(void *arg); |
Sowmini Varadhan | b04e855 | 2016-06-30 16:11:16 -0700 | [diff] [blame] | 341 | int rds_ib_conn_path_connect(struct rds_conn_path *cp); |
Sowmini Varadhan | 226f7a7 | 2016-06-30 16:11:10 -0700 | [diff] [blame] | 342 | void rds_ib_conn_path_shutdown(struct rds_conn_path *cp); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 343 | void rds_ib_state_change(struct sock *sk); |
Zach Brown | ef87b7e | 2010-07-09 12:26:20 -0700 | [diff] [blame] | 344 | int rds_ib_listen_init(void); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 345 | void rds_ib_listen_stop(void); |
Nicolas Iooss | 6cdaf03 | 2016-08-05 22:11:12 +0200 | [diff] [blame] | 346 | __printf(2, 3) |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 347 | void __rds_ib_conn_error(struct rds_connection *conn, const char *, ...); |
| 348 | int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id, |
| 349 | struct rdma_cm_event *event); |
| 350 | int rds_ib_cm_initiate_connect(struct rdma_cm_id *cm_id); |
| 351 | void rds_ib_cm_connect_complete(struct rds_connection *conn, |
| 352 | struct rdma_cm_event *event); |
| 353 | |
| 354 | |
| 355 | #define rds_ib_conn_error(conn, fmt...) \ |
| 356 | __rds_ib_conn_error(conn, KERN_WARNING "RDS/IB: " fmt) |
| 357 | |
| 358 | /* ib_rdma.c */ |
| 359 | int rds_ib_update_ipaddr(struct rds_ib_device *rds_ibdev, __be32 ipaddr); |
Andy Grover | 745cbcc | 2009-04-01 08:20:19 +0000 | [diff] [blame] | 360 | void rds_ib_add_conn(struct rds_ib_device *rds_ibdev, struct rds_connection *conn); |
| 361 | void rds_ib_remove_conn(struct rds_ib_device *rds_ibdev, struct rds_connection *conn); |
Zach Brown | 8aeb1ba | 2010-06-25 14:58:16 -0700 | [diff] [blame] | 362 | void rds_ib_destroy_nodev_conns(void); |
Avinash Repaka | 1659185 | 2016-03-01 15:20:54 -0800 | [diff] [blame] | 363 | void rds_ib_mr_cqe_handler(struct rds_ib_connection *ic, struct ib_wc *wc); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 364 | |
| 365 | /* ib_recv.c */ |
Zach Brown | ef87b7e | 2010-07-09 12:26:20 -0700 | [diff] [blame] | 366 | int rds_ib_recv_init(void); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 367 | void rds_ib_recv_exit(void); |
Sowmini Varadhan | 2da43c4 | 2016-06-30 16:11:15 -0700 | [diff] [blame] | 368 | int rds_ib_recv_path(struct rds_conn_path *conn); |
Chris Mason | 3324412 | 2010-05-26 22:05:37 -0700 | [diff] [blame] | 369 | int rds_ib_recv_alloc_caches(struct rds_ib_connection *ic); |
| 370 | void rds_ib_recv_free_caches(struct rds_ib_connection *ic); |
santosh.shilimkar@oracle.com | 73ce431 | 2015-08-22 15:45:26 -0700 | [diff] [blame] | 371 | void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 372 | void rds_ib_inc_free(struct rds_incoming *inc); |
Al Viro | c310e72 | 2014-11-20 09:21:14 -0500 | [diff] [blame] | 373 | int rds_ib_inc_copy_to_user(struct rds_incoming *inc, struct iov_iter *to); |
Santosh Shilimkar | f4f943c | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 374 | void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic, struct ib_wc *wc, |
| 375 | struct rds_ib_ack_state *state); |
Andy Grover | d521b63 | 2009-10-30 08:51:57 +0000 | [diff] [blame] | 376 | void rds_ib_recv_tasklet_fn(unsigned long data); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 377 | void rds_ib_recv_init_ring(struct rds_ib_connection *ic); |
| 378 | void rds_ib_recv_clear_ring(struct rds_ib_connection *ic); |
| 379 | void rds_ib_recv_init_ack(struct rds_ib_connection *ic); |
| 380 | void rds_ib_attempt_ack(struct rds_ib_connection *ic); |
| 381 | void rds_ib_ack_send_complete(struct rds_ib_connection *ic); |
| 382 | u64 rds_ib_piggyb_ack(struct rds_ib_connection *ic); |
Santosh Shilimkar | f4f943c | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 383 | void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq, int ack_required); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 384 | |
| 385 | /* ib_ring.c */ |
| 386 | void rds_ib_ring_init(struct rds_ib_work_ring *ring, u32 nr); |
| 387 | void rds_ib_ring_resize(struct rds_ib_work_ring *ring, u32 nr); |
| 388 | u32 rds_ib_ring_alloc(struct rds_ib_work_ring *ring, u32 val, u32 *pos); |
| 389 | void rds_ib_ring_free(struct rds_ib_work_ring *ring, u32 val); |
| 390 | void rds_ib_ring_unalloc(struct rds_ib_work_ring *ring, u32 val); |
| 391 | int rds_ib_ring_empty(struct rds_ib_work_ring *ring); |
| 392 | int rds_ib_ring_low(struct rds_ib_work_ring *ring); |
| 393 | u32 rds_ib_ring_oldest(struct rds_ib_work_ring *ring); |
| 394 | u32 rds_ib_ring_completed(struct rds_ib_work_ring *ring, u32 wr_id, u32 oldest); |
| 395 | extern wait_queue_head_t rds_ib_ring_empty_wait; |
| 396 | |
| 397 | /* ib_send.c */ |
Sowmini Varadhan | 226f7a7 | 2016-06-30 16:11:10 -0700 | [diff] [blame] | 398 | void rds_ib_xmit_path_complete(struct rds_conn_path *cp); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 399 | int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm, |
| 400 | unsigned int hdr_off, unsigned int sg, unsigned int off); |
Santosh Shilimkar | 0c28c04 | 2015-09-06 02:18:51 -0400 | [diff] [blame] | 401 | void rds_ib_send_cqe_handler(struct rds_ib_connection *ic, struct ib_wc *wc); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 402 | void rds_ib_send_init_ring(struct rds_ib_connection *ic); |
| 403 | void rds_ib_send_clear_ring(struct rds_ib_connection *ic); |
Andy Grover | f8b3aaf | 2010-03-01 14:11:53 -0800 | [diff] [blame] | 404 | int rds_ib_xmit_rdma(struct rds_connection *conn, struct rm_rdma_op *op); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 405 | void rds_ib_send_add_credits(struct rds_connection *conn, unsigned int credits); |
| 406 | void rds_ib_advertise_credits(struct rds_connection *conn, unsigned int posted); |
| 407 | int rds_ib_send_grab_credits(struct rds_ib_connection *ic, u32 wanted, |
Steve Wise | 7b70d03 | 2009-04-09 14:09:39 +0000 | [diff] [blame] | 408 | u32 *adv_credits, int need_posted, int max_posted); |
Andy Grover | ff3d7d3 | 2010-03-01 14:03:09 -0800 | [diff] [blame] | 409 | int rds_ib_xmit_atomic(struct rds_connection *conn, struct rm_atomic_op *op); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 410 | |
| 411 | /* ib_stats.c */ |
| 412 | DECLARE_PER_CPU(struct rds_ib_statistics, rds_ib_stats); |
| 413 | #define rds_ib_stats_inc(member) rds_stats_inc_which(rds_ib_stats, member) |
Santosh Shilimkar | 09b2b8f | 2016-07-09 17:14:02 -0700 | [diff] [blame^] | 414 | #define rds_ib_stats_add(member, count) \ |
| 415 | rds_stats_add_which(rds_ib_stats, member, count) |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 416 | unsigned int rds_ib_stats_info_copy(struct rds_info_iterator *iter, |
| 417 | unsigned int avail); |
| 418 | |
| 419 | /* ib_sysctl.c */ |
Zach Brown | ef87b7e | 2010-07-09 12:26:20 -0700 | [diff] [blame] | 420 | int rds_ib_sysctl_init(void); |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 421 | void rds_ib_sysctl_exit(void); |
| 422 | extern unsigned long rds_ib_sysctl_max_send_wr; |
| 423 | extern unsigned long rds_ib_sysctl_max_recv_wr; |
| 424 | extern unsigned long rds_ib_sysctl_max_unsig_wrs; |
| 425 | extern unsigned long rds_ib_sysctl_max_unsig_bytes; |
| 426 | extern unsigned long rds_ib_sysctl_max_recv_allocation; |
| 427 | extern unsigned int rds_ib_sysctl_flow_control; |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 428 | |
Andy Grover | ec16227 | 2009-02-24 15:30:30 +0000 | [diff] [blame] | 429 | #endif |