Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 1 | /* |
Mike Marciniszyn | 1dd173b | 2013-06-15 17:07:14 -0400 | [diff] [blame] | 2 | * Copyright (c) 2012, 2013 Intel Corporation. All rights reserved. |
Mike Marciniszyn | 1fb9fed | 2012-07-16 17:11:06 +0000 | [diff] [blame] | 3 | * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved. |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 4 | * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. |
| 5 | * |
| 6 | * This software is available to you under a choice of one of two |
| 7 | * licenses. You may choose to be licensed under the terms of the GNU |
| 8 | * General Public License (GPL) Version 2, available from the file |
| 9 | * COPYING in the main directory of this source tree, or the |
| 10 | * OpenIB.org BSD license below: |
| 11 | * |
| 12 | * Redistribution and use in source and binary forms, with or |
| 13 | * without modification, are permitted provided that the following |
| 14 | * conditions are met: |
| 15 | * |
| 16 | * - Redistributions of source code must retain the above |
| 17 | * copyright notice, this list of conditions and the following |
| 18 | * disclaimer. |
| 19 | * |
| 20 | * - Redistributions in binary form must reproduce the above |
| 21 | * copyright notice, this list of conditions and the following |
| 22 | * disclaimer in the documentation and/or other materials |
| 23 | * provided with the distribution. |
| 24 | * |
| 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 29 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 30 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 31 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 32 | * SOFTWARE. |
| 33 | */ |
| 34 | |
| 35 | #ifndef QIB_VERBS_H |
| 36 | #define QIB_VERBS_H |
| 37 | |
| 38 | #include <linux/types.h> |
| 39 | #include <linux/spinlock.h> |
| 40 | #include <linux/kernel.h> |
| 41 | #include <linux/interrupt.h> |
| 42 | #include <linux/kref.h> |
| 43 | #include <linux/workqueue.h> |
Mike Marciniszyn | 85caafe | 2013-06-04 15:05:37 -0400 | [diff] [blame] | 44 | #include <linux/kthread.h> |
Mike Marciniszyn | 6a82649 | 2012-06-27 18:33:12 -0400 | [diff] [blame] | 45 | #include <linux/completion.h> |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 46 | #include <rdma/ib_pack.h> |
| 47 | #include <rdma/ib_user_verbs.h> |
Dennis Dalessandro | 2dc05ab | 2016-01-22 12:44:29 -0800 | [diff] [blame] | 48 | #include <rdma/rdma_vt.h> |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 49 | |
| 50 | struct qib_ctxtdata; |
| 51 | struct qib_pportdata; |
| 52 | struct qib_devdata; |
| 53 | struct qib_verbs_txreq; |
| 54 | |
| 55 | #define QIB_MAX_RDMA_ATOMIC 16 |
| 56 | #define QIB_GUIDS_PER_PORT 5 |
| 57 | |
| 58 | #define QPN_MAX (1 << 24) |
| 59 | #define QPNMAP_ENTRIES (QPN_MAX / PAGE_SIZE / BITS_PER_BYTE) |
| 60 | |
| 61 | /* |
| 62 | * Increment this value if any changes that break userspace ABI |
| 63 | * compatibility are made. |
| 64 | */ |
| 65 | #define QIB_UVERBS_ABI_VERSION 2 |
| 66 | |
| 67 | /* |
| 68 | * Define an ib_cq_notify value that is not valid so we know when CQ |
| 69 | * notifications are armed. |
| 70 | */ |
| 71 | #define IB_CQ_NONE (IB_CQ_NEXT_COMP + 1) |
| 72 | |
| 73 | #define IB_SEQ_NAK (3 << 29) |
| 74 | |
| 75 | /* AETH NAK opcode values */ |
| 76 | #define IB_RNR_NAK 0x20 |
| 77 | #define IB_NAK_PSN_ERROR 0x60 |
| 78 | #define IB_NAK_INVALID_REQUEST 0x61 |
| 79 | #define IB_NAK_REMOTE_ACCESS_ERROR 0x62 |
| 80 | #define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63 |
| 81 | #define IB_NAK_INVALID_RD_REQUEST 0x64 |
| 82 | |
| 83 | /* Flags for checking QP state (see ib_qib_state_ops[]) */ |
| 84 | #define QIB_POST_SEND_OK 0x01 |
| 85 | #define QIB_POST_RECV_OK 0x02 |
| 86 | #define QIB_PROCESS_RECV_OK 0x04 |
| 87 | #define QIB_PROCESS_SEND_OK 0x08 |
| 88 | #define QIB_PROCESS_NEXT_SEND_OK 0x10 |
| 89 | #define QIB_FLUSH_SEND 0x20 |
| 90 | #define QIB_FLUSH_RECV 0x40 |
| 91 | #define QIB_PROCESS_OR_FLUSH_SEND \ |
| 92 | (QIB_PROCESS_SEND_OK | QIB_FLUSH_SEND) |
| 93 | |
| 94 | /* IB Performance Manager status values */ |
| 95 | #define IB_PMA_SAMPLE_STATUS_DONE 0x00 |
| 96 | #define IB_PMA_SAMPLE_STATUS_STARTED 0x01 |
| 97 | #define IB_PMA_SAMPLE_STATUS_RUNNING 0x02 |
| 98 | |
| 99 | /* Mandatory IB performance counter select values. */ |
| 100 | #define IB_PMA_PORT_XMIT_DATA cpu_to_be16(0x0001) |
| 101 | #define IB_PMA_PORT_RCV_DATA cpu_to_be16(0x0002) |
| 102 | #define IB_PMA_PORT_XMIT_PKTS cpu_to_be16(0x0003) |
| 103 | #define IB_PMA_PORT_RCV_PKTS cpu_to_be16(0x0004) |
| 104 | #define IB_PMA_PORT_XMIT_WAIT cpu_to_be16(0x0005) |
| 105 | |
| 106 | #define QIB_VENDOR_IPG cpu_to_be16(0xFFA0) |
| 107 | |
| 108 | #define IB_BTH_REQ_ACK (1 << 31) |
| 109 | #define IB_BTH_SOLICITED (1 << 23) |
| 110 | #define IB_BTH_MIG_REQ (1 << 22) |
| 111 | |
| 112 | /* XXX Should be defined in ib_verbs.h enum ib_port_cap_flags */ |
| 113 | #define IB_PORT_OTHER_LOCAL_CHANGES_SUP (1 << 26) |
| 114 | |
| 115 | #define IB_GRH_VERSION 6 |
| 116 | #define IB_GRH_VERSION_MASK 0xF |
| 117 | #define IB_GRH_VERSION_SHIFT 28 |
| 118 | #define IB_GRH_TCLASS_MASK 0xFF |
| 119 | #define IB_GRH_TCLASS_SHIFT 20 |
| 120 | #define IB_GRH_FLOW_MASK 0xFFFFF |
| 121 | #define IB_GRH_FLOW_SHIFT 0 |
| 122 | #define IB_GRH_NEXT_HDR 0x1B |
| 123 | |
| 124 | #define IB_DEFAULT_GID_PREFIX cpu_to_be64(0xfe80000000000000ULL) |
| 125 | |
| 126 | /* Values for set/get portinfo VLCap OperationalVLs */ |
| 127 | #define IB_VL_VL0 1 |
| 128 | #define IB_VL_VL0_1 2 |
| 129 | #define IB_VL_VL0_3 3 |
| 130 | #define IB_VL_VL0_7 4 |
| 131 | #define IB_VL_VL0_14 5 |
| 132 | |
| 133 | static inline int qib_num_vls(int vls) |
| 134 | { |
| 135 | switch (vls) { |
| 136 | default: |
| 137 | case IB_VL_VL0: |
| 138 | return 1; |
| 139 | case IB_VL_VL0_1: |
| 140 | return 2; |
| 141 | case IB_VL_VL0_3: |
| 142 | return 4; |
| 143 | case IB_VL_VL0_7: |
| 144 | return 8; |
| 145 | case IB_VL_VL0_14: |
| 146 | return 15; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | struct ib_reth { |
| 151 | __be64 vaddr; |
| 152 | __be32 rkey; |
| 153 | __be32 length; |
Mike Marciniszyn | 78a5886 | 2013-10-24 11:40:37 -0400 | [diff] [blame] | 154 | } __packed; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 155 | |
| 156 | struct ib_atomic_eth { |
| 157 | __be32 vaddr[2]; /* unaligned so access as 2 32-bit words */ |
| 158 | __be32 rkey; |
| 159 | __be64 swap_data; |
| 160 | __be64 compare_data; |
Mike Marciniszyn | 78a5886 | 2013-10-24 11:40:37 -0400 | [diff] [blame] | 161 | } __packed; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 162 | |
| 163 | struct qib_other_headers { |
| 164 | __be32 bth[3]; |
| 165 | union { |
| 166 | struct { |
| 167 | __be32 deth[2]; |
| 168 | __be32 imm_data; |
| 169 | } ud; |
| 170 | struct { |
| 171 | struct ib_reth reth; |
| 172 | __be32 imm_data; |
| 173 | } rc; |
| 174 | struct { |
| 175 | __be32 aeth; |
| 176 | __be32 atomic_ack_eth[2]; |
| 177 | } at; |
| 178 | __be32 imm_data; |
| 179 | __be32 aeth; |
| 180 | struct ib_atomic_eth atomic_eth; |
| 181 | } u; |
Mike Marciniszyn | 78a5886 | 2013-10-24 11:40:37 -0400 | [diff] [blame] | 182 | } __packed; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 183 | |
| 184 | /* |
| 185 | * Note that UD packets with a GRH header are 8+40+12+8 = 68 bytes |
| 186 | * long (72 w/ imm_data). Only the first 56 bytes of the IB header |
| 187 | * will be in the eager header buffer. The remaining 12 or 16 bytes |
| 188 | * are in the data buffer. |
| 189 | */ |
| 190 | struct qib_ib_header { |
| 191 | __be16 lrh[4]; |
| 192 | union { |
| 193 | struct { |
| 194 | struct ib_grh grh; |
| 195 | struct qib_other_headers oth; |
| 196 | } l; |
| 197 | struct qib_other_headers oth; |
| 198 | } u; |
Mike Marciniszyn | 78a5886 | 2013-10-24 11:40:37 -0400 | [diff] [blame] | 199 | } __packed; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 200 | |
| 201 | struct qib_pio_header { |
| 202 | __le32 pbc[2]; |
| 203 | struct qib_ib_header hdr; |
Mike Marciniszyn | 78a5886 | 2013-10-24 11:40:37 -0400 | [diff] [blame] | 204 | } __packed; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 205 | |
| 206 | /* |
| 207 | * There is one struct qib_mcast for each multicast GID. |
| 208 | * All attached QPs are then stored as a list of |
| 209 | * struct qib_mcast_qp. |
| 210 | */ |
| 211 | struct qib_mcast_qp { |
| 212 | struct list_head list; |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 213 | struct rvt_qp *qp; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 214 | }; |
| 215 | |
| 216 | struct qib_mcast { |
| 217 | struct rb_node rb_node; |
| 218 | union ib_gid mgid; |
| 219 | struct list_head qp_list; |
| 220 | wait_queue_head_t wait; |
| 221 | atomic_t refcount; |
| 222 | int n_attached; |
| 223 | }; |
| 224 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 225 | /* Address Handle */ |
| 226 | struct qib_ah { |
| 227 | struct ib_ah ibah; |
| 228 | struct ib_ah_attr attr; |
| 229 | atomic_t refcount; |
| 230 | }; |
| 231 | |
| 232 | /* |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 233 | * This structure is used to contain the head pointer, tail pointer, |
| 234 | * and completion queue entries as a single memory allocation so |
| 235 | * it can be mmap'ed into user space. |
| 236 | */ |
| 237 | struct qib_cq_wc { |
| 238 | u32 head; /* index of next entry to fill */ |
| 239 | u32 tail; /* index of next ib_poll_cq() entry */ |
| 240 | union { |
| 241 | /* these are actually size ibcq.cqe + 1 */ |
| 242 | struct ib_uverbs_wc uqueue[0]; |
| 243 | struct ib_wc kqueue[0]; |
| 244 | }; |
| 245 | }; |
| 246 | |
| 247 | /* |
| 248 | * The completion queue structure. |
| 249 | */ |
| 250 | struct qib_cq { |
| 251 | struct ib_cq ibcq; |
Mike Marciniszyn | 85caafe | 2013-06-04 15:05:37 -0400 | [diff] [blame] | 252 | struct kthread_work comptask; |
| 253 | struct qib_devdata *dd; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 254 | spinlock_t lock; /* protect changes in this struct */ |
| 255 | u8 notify; |
| 256 | u8 triggered; |
| 257 | struct qib_cq_wc *queue; |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 258 | struct rvt_mmap_info *ip; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 259 | }; |
| 260 | |
| 261 | struct qib_srq { |
| 262 | struct ib_srq ibsrq; |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 263 | struct rvt_rq rq; |
| 264 | struct rvt_mmap_info *ip; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 265 | /* send signal when number of RWQEs < limit */ |
| 266 | u32 limit; |
| 267 | }; |
| 268 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 269 | /* |
Dennis Dalessandro | ffc2690 | 2016-01-22 12:45:11 -0800 | [diff] [blame] | 270 | * qib specific data structure that will be hidden from rvt after the queue pair |
| 271 | * is made common. |
| 272 | */ |
Dennis Dalessandro | ffc2690 | 2016-01-22 12:45:11 -0800 | [diff] [blame] | 273 | struct qib_qp_priv { |
| 274 | struct qib_ib_header *s_hdr; /* next packet header to send */ |
| 275 | struct list_head iowait; /* link for wait PIO buf */ |
| 276 | atomic_t s_dma_busy; |
| 277 | struct qib_verbs_txreq *s_tx; |
| 278 | struct work_struct s_work; |
| 279 | wait_queue_head_t wait_dma; |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 280 | struct rvt_qp *owner; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | /* |
| 284 | * Atomic bit definitions for r_aflags. |
| 285 | */ |
| 286 | #define QIB_R_WRID_VALID 0 |
| 287 | #define QIB_R_REWIND_SGE 1 |
| 288 | |
| 289 | /* |
| 290 | * Bit definitions for r_flags. |
| 291 | */ |
| 292 | #define QIB_R_REUSE_SGE 0x01 |
| 293 | #define QIB_R_RDMAR_SEQ 0x02 |
| 294 | #define QIB_R_RSP_NAK 0x04 |
| 295 | #define QIB_R_RSP_SEND 0x08 |
| 296 | #define QIB_R_COMM_EST 0x10 |
| 297 | |
| 298 | /* |
| 299 | * Bit definitions for s_flags. |
| 300 | * |
| 301 | * QIB_S_SIGNAL_REQ_WR - set if QP send WRs contain completion signaled |
| 302 | * QIB_S_BUSY - send tasklet is processing the QP |
| 303 | * QIB_S_TIMER - the RC retry timer is active |
| 304 | * QIB_S_ACK_PENDING - an ACK is waiting to be sent after RDMA read/atomics |
| 305 | * QIB_S_WAIT_FENCE - waiting for all prior RDMA read or atomic SWQEs |
| 306 | * before processing the next SWQE |
| 307 | * QIB_S_WAIT_RDMAR - waiting for a RDMA read or atomic SWQE to complete |
| 308 | * before processing the next SWQE |
| 309 | * QIB_S_WAIT_RNR - waiting for RNR timeout |
| 310 | * QIB_S_WAIT_SSN_CREDIT - waiting for RC credits to process next SWQE |
| 311 | * QIB_S_WAIT_DMA - waiting for send DMA queue to drain before generating |
| 312 | * next send completion entry not via send DMA |
| 313 | * QIB_S_WAIT_PIO - waiting for a send buffer to be available |
| 314 | * QIB_S_WAIT_TX - waiting for a struct qib_verbs_txreq to be available |
| 315 | * QIB_S_WAIT_DMA_DESC - waiting for DMA descriptors to be available |
| 316 | * QIB_S_WAIT_KMEM - waiting for kernel memory to be available |
| 317 | * QIB_S_WAIT_PSN - waiting for a packet to exit the send DMA queue |
| 318 | * QIB_S_WAIT_ACK - waiting for an ACK packet before sending more requests |
| 319 | * QIB_S_SEND_ONE - send one packet, request ACK, then wait for ACK |
| 320 | */ |
| 321 | #define QIB_S_SIGNAL_REQ_WR 0x0001 |
| 322 | #define QIB_S_BUSY 0x0002 |
| 323 | #define QIB_S_TIMER 0x0004 |
| 324 | #define QIB_S_RESP_PENDING 0x0008 |
| 325 | #define QIB_S_ACK_PENDING 0x0010 |
| 326 | #define QIB_S_WAIT_FENCE 0x0020 |
| 327 | #define QIB_S_WAIT_RDMAR 0x0040 |
| 328 | #define QIB_S_WAIT_RNR 0x0080 |
| 329 | #define QIB_S_WAIT_SSN_CREDIT 0x0100 |
| 330 | #define QIB_S_WAIT_DMA 0x0200 |
| 331 | #define QIB_S_WAIT_PIO 0x0400 |
| 332 | #define QIB_S_WAIT_TX 0x0800 |
| 333 | #define QIB_S_WAIT_DMA_DESC 0x1000 |
| 334 | #define QIB_S_WAIT_KMEM 0x2000 |
| 335 | #define QIB_S_WAIT_PSN 0x4000 |
| 336 | #define QIB_S_WAIT_ACK 0x8000 |
| 337 | #define QIB_S_SEND_ONE 0x10000 |
| 338 | #define QIB_S_UNLIMITED_CREDIT 0x20000 |
| 339 | |
| 340 | /* |
| 341 | * Wait flags that would prevent any packet type from being sent. |
| 342 | */ |
| 343 | #define QIB_S_ANY_WAIT_IO (QIB_S_WAIT_PIO | QIB_S_WAIT_TX | \ |
| 344 | QIB_S_WAIT_DMA_DESC | QIB_S_WAIT_KMEM) |
| 345 | |
| 346 | /* |
| 347 | * Wait flags that would prevent send work requests from making progress. |
| 348 | */ |
| 349 | #define QIB_S_ANY_WAIT_SEND (QIB_S_WAIT_FENCE | QIB_S_WAIT_RDMAR | \ |
| 350 | QIB_S_WAIT_RNR | QIB_S_WAIT_SSN_CREDIT | QIB_S_WAIT_DMA | \ |
| 351 | QIB_S_WAIT_PSN | QIB_S_WAIT_ACK) |
| 352 | |
| 353 | #define QIB_S_ANY_WAIT (QIB_S_ANY_WAIT_IO | QIB_S_ANY_WAIT_SEND) |
| 354 | |
| 355 | #define QIB_PSN_CREDIT 16 |
| 356 | |
| 357 | /* |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 358 | * Since struct rvt_swqe is not a fixed size, we can't simply index into |
| 359 | * struct rvt_qp.s_wq. This function does the array index computation. |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 360 | */ |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 361 | static inline struct rvt_swqe *get_swqe_ptr(struct rvt_qp *qp, |
| 362 | unsigned n) |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 363 | { |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 364 | return (struct rvt_swqe *)((char *)qp->s_wq + |
| 365 | (sizeof(struct rvt_swqe) + |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 366 | qp->s_max_sge * |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 367 | sizeof(struct rvt_sge)) * n); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | /* |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 371 | * Since struct rvt_rwqe is not a fixed size, we can't simply index into |
| 372 | * struct rvt_rwq.wq. This function does the array index computation. |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 373 | */ |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 374 | static inline struct rvt_rwqe *get_rwqe_ptr(struct rvt_rq *rq, unsigned n) |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 375 | { |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 376 | return (struct rvt_rwqe *) |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 377 | ((char *) rq->wq->wq + |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 378 | (sizeof(struct rvt_rwqe) + |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 379 | rq->max_sge * sizeof(struct ib_sge)) * n); |
| 380 | } |
| 381 | |
| 382 | /* |
| 383 | * QPN-map pages start out as NULL, they get allocated upon |
| 384 | * first use and are never deallocated. This way, |
| 385 | * large bitmaps are not allocated unless large numbers of QPs are used. |
| 386 | */ |
| 387 | struct qpn_map { |
| 388 | void *page; |
| 389 | }; |
| 390 | |
| 391 | struct qib_qpn_table { |
| 392 | spinlock_t lock; /* protect changes in this struct */ |
| 393 | unsigned flags; /* flags for QP0/1 allocated for each port */ |
| 394 | u32 last; /* last QP number allocated */ |
| 395 | u32 nmaps; /* size of the map table */ |
| 396 | u16 limit; |
| 397 | u16 mask; |
| 398 | /* bit map of free QP numbers other than 0/1 */ |
| 399 | struct qpn_map map[QPNMAP_ENTRIES]; |
| 400 | }; |
| 401 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 402 | struct qib_opcode_stats { |
| 403 | u64 n_packets; /* number of packets */ |
| 404 | u64 n_bytes; /* total number of bytes */ |
| 405 | }; |
| 406 | |
Mike Marciniszyn | ddb8876 | 2013-06-15 17:07:03 -0400 | [diff] [blame] | 407 | struct qib_opcode_stats_perctx { |
| 408 | struct qib_opcode_stats stats[128]; |
| 409 | }; |
| 410 | |
Mike Marciniszyn | 7d7632a | 2014-03-07 08:40:55 -0500 | [diff] [blame] | 411 | struct qib_pma_counters { |
| 412 | u64 n_unicast_xmit; /* total unicast packets sent */ |
| 413 | u64 n_unicast_rcv; /* total unicast packets received */ |
| 414 | u64 n_multicast_xmit; /* total multicast packets sent */ |
| 415 | u64 n_multicast_rcv; /* total multicast packets received */ |
| 416 | }; |
| 417 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 418 | struct qib_ibport { |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 419 | struct rvt_qp __rcu *qp0; |
| 420 | struct rvt_qp __rcu *qp1; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 421 | struct ib_mad_agent *send_agent; /* agent for SMI (traps) */ |
| 422 | struct qib_ah *sm_ah; |
| 423 | struct qib_ah *smi_ah; |
| 424 | struct rb_root mcast_tree; |
| 425 | spinlock_t lock; /* protect changes in this struct */ |
| 426 | |
| 427 | /* non-zero when timer is set */ |
| 428 | unsigned long mkey_lease_timeout; |
| 429 | unsigned long trap_timeout; |
| 430 | __be64 gid_prefix; /* in network order */ |
| 431 | __be64 mkey; |
| 432 | __be64 guids[QIB_GUIDS_PER_PORT - 1]; /* writable GUIDs */ |
| 433 | u64 tid; /* TID for traps */ |
Mike Marciniszyn | 7d7632a | 2014-03-07 08:40:55 -0500 | [diff] [blame] | 434 | struct qib_pma_counters __percpu *pmastats; |
| 435 | u64 z_unicast_xmit; /* starting count for PMA */ |
| 436 | u64 z_unicast_rcv; /* starting count for PMA */ |
| 437 | u64 z_multicast_xmit; /* starting count for PMA */ |
| 438 | u64 z_multicast_rcv; /* starting count for PMA */ |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 439 | u64 z_symbol_error_counter; /* starting count for PMA */ |
| 440 | u64 z_link_error_recovery_counter; /* starting count for PMA */ |
| 441 | u64 z_link_downed_counter; /* starting count for PMA */ |
| 442 | u64 z_port_rcv_errors; /* starting count for PMA */ |
| 443 | u64 z_port_rcv_remphys_errors; /* starting count for PMA */ |
| 444 | u64 z_port_xmit_discards; /* starting count for PMA */ |
| 445 | u64 z_port_xmit_data; /* starting count for PMA */ |
| 446 | u64 z_port_rcv_data; /* starting count for PMA */ |
| 447 | u64 z_port_xmit_packets; /* starting count for PMA */ |
| 448 | u64 z_port_rcv_packets; /* starting count for PMA */ |
| 449 | u32 z_local_link_integrity_errors; /* starting count for PMA */ |
| 450 | u32 z_excessive_buffer_overrun_errors; /* starting count for PMA */ |
| 451 | u32 z_vl15_dropped; /* starting count for PMA */ |
| 452 | u32 n_rc_resends; |
| 453 | u32 n_rc_acks; |
| 454 | u32 n_rc_qacks; |
| 455 | u32 n_rc_delayed_comp; |
| 456 | u32 n_seq_naks; |
| 457 | u32 n_rdma_seq; |
| 458 | u32 n_rnr_naks; |
| 459 | u32 n_other_naks; |
| 460 | u32 n_loop_pkts; |
| 461 | u32 n_pkt_drops; |
| 462 | u32 n_vl15_dropped; |
| 463 | u32 n_rc_timeouts; |
| 464 | u32 n_dmawait; |
| 465 | u32 n_unaligned; |
| 466 | u32 n_rc_dupreq; |
| 467 | u32 n_rc_seqnak; |
| 468 | u32 port_cap_flags; |
| 469 | u32 pma_sample_start; |
| 470 | u32 pma_sample_interval; |
| 471 | __be16 pma_counter_select[5]; |
| 472 | u16 pma_tag; |
| 473 | u16 pkey_violations; |
| 474 | u16 qkey_violations; |
| 475 | u16 mkey_violations; |
| 476 | u16 mkey_lease_period; |
| 477 | u16 sm_lid; |
| 478 | u16 repress_traps; |
| 479 | u8 sm_sl; |
| 480 | u8 mkeyprot; |
| 481 | u8 subnet_timeout; |
| 482 | u8 vl_high_limit; |
| 483 | u8 sl_to_vl[16]; |
| 484 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 485 | }; |
| 486 | |
Mike Marciniszyn | 551ace1 | 2012-07-19 13:03:56 +0000 | [diff] [blame] | 487 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 488 | struct qib_ibdev { |
Dennis Dalessandro | 2dc05ab | 2016-01-22 12:44:29 -0800 | [diff] [blame] | 489 | struct rvt_dev_info rdi; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 490 | struct list_head pending_mmaps; |
| 491 | spinlock_t mmap_offset_lock; /* protect mmap_offset */ |
| 492 | u32 mmap_offset; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 493 | |
| 494 | /* QP numbers are shared by all IB ports */ |
| 495 | struct qib_qpn_table qpn_table; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 496 | struct list_head piowait; /* list for wait PIO buf */ |
| 497 | struct list_head dmawait; /* list for wait DMA */ |
| 498 | struct list_head txwait; /* list for wait qib_verbs_txreq */ |
| 499 | struct list_head memwait; /* list for wait kernel memory */ |
| 500 | struct list_head txreq_free; |
| 501 | struct timer_list mem_timer; |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 502 | struct rvt_qp __rcu **qp_table; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 503 | struct qib_pio_header *pio_hdrs; |
| 504 | dma_addr_t pio_hdrs_phys; |
| 505 | /* list of QPs waiting for RNR timer */ |
| 506 | spinlock_t pending_lock; /* protect wait lists, PMA counters, etc. */ |
Mike Marciniszyn | af061a6 | 2011-09-23 13:16:44 -0400 | [diff] [blame] | 507 | u32 qp_table_size; /* size of the hash table */ |
| 508 | u32 qp_rnd; /* random bytes for hash */ |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 509 | spinlock_t qpt_lock; |
| 510 | |
| 511 | u32 n_piowait; |
| 512 | u32 n_txwait; |
| 513 | |
| 514 | u32 n_pds_allocated; /* number of PDs allocated for device */ |
| 515 | spinlock_t n_pds_lock; |
| 516 | u32 n_ahs_allocated; /* number of AHs allocated for device */ |
| 517 | spinlock_t n_ahs_lock; |
| 518 | u32 n_cqs_allocated; /* number of CQs allocated for device */ |
| 519 | spinlock_t n_cqs_lock; |
| 520 | u32 n_qps_allocated; /* number of QPs allocated for device */ |
| 521 | spinlock_t n_qps_lock; |
| 522 | u32 n_srqs_allocated; /* number of SRQs allocated for device */ |
| 523 | spinlock_t n_srqs_lock; |
| 524 | u32 n_mcast_grps_allocated; /* number of mcast groups allocated */ |
| 525 | spinlock_t n_mcast_grps_lock; |
Mike Marciniszyn | ddb8876 | 2013-06-15 17:07:03 -0400 | [diff] [blame] | 526 | #ifdef CONFIG_DEBUG_FS |
| 527 | /* per HCA debugfs */ |
| 528 | struct dentry *qib_ibdev_dbg; |
| 529 | #endif |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 530 | }; |
| 531 | |
| 532 | struct qib_verbs_counters { |
| 533 | u64 symbol_error_counter; |
| 534 | u64 link_error_recovery_counter; |
| 535 | u64 link_downed_counter; |
| 536 | u64 port_rcv_errors; |
| 537 | u64 port_rcv_remphys_errors; |
| 538 | u64 port_xmit_discards; |
| 539 | u64 port_xmit_data; |
| 540 | u64 port_rcv_data; |
| 541 | u64 port_xmit_packets; |
| 542 | u64 port_rcv_packets; |
| 543 | u32 local_link_integrity_errors; |
| 544 | u32 excessive_buffer_overrun_errors; |
| 545 | u32 vl15_dropped; |
| 546 | }; |
| 547 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 548 | static inline struct qib_ah *to_iah(struct ib_ah *ibah) |
| 549 | { |
| 550 | return container_of(ibah, struct qib_ah, ibah); |
| 551 | } |
| 552 | |
| 553 | static inline struct qib_cq *to_icq(struct ib_cq *ibcq) |
| 554 | { |
| 555 | return container_of(ibcq, struct qib_cq, ibcq); |
| 556 | } |
| 557 | |
| 558 | static inline struct qib_srq *to_isrq(struct ib_srq *ibsrq) |
| 559 | { |
| 560 | return container_of(ibsrq, struct qib_srq, ibsrq); |
| 561 | } |
| 562 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 563 | static inline struct rvt_qp *to_iqp(struct ib_qp *ibqp) |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 564 | { |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 565 | return container_of(ibqp, struct rvt_qp, ibqp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | static inline struct qib_ibdev *to_idev(struct ib_device *ibdev) |
| 569 | { |
Dennis Dalessandro | 2dc05ab | 2016-01-22 12:44:29 -0800 | [diff] [blame] | 570 | struct rvt_dev_info *rdi; |
| 571 | |
| 572 | rdi = container_of(ibdev, struct rvt_dev_info, ibdev); |
| 573 | return container_of(rdi, struct qib_ibdev, rdi); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | /* |
| 577 | * Send if not busy or waiting for I/O and either |
| 578 | * a RC response is pending or we can process send work requests. |
| 579 | */ |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 580 | static inline int qib_send_ok(struct rvt_qp *qp) |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 581 | { |
| 582 | return !(qp->s_flags & (QIB_S_BUSY | QIB_S_ANY_WAIT_IO)) && |
| 583 | (qp->s_hdrwords || (qp->s_flags & QIB_S_RESP_PENDING) || |
| 584 | !(qp->s_flags & QIB_S_ANY_WAIT_SEND)); |
| 585 | } |
| 586 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 587 | /* |
| 588 | * This must be called with s_lock held. |
| 589 | */ |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 590 | void qib_schedule_send(struct rvt_qp *qp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 591 | |
| 592 | static inline int qib_pkey_ok(u16 pkey1, u16 pkey2) |
| 593 | { |
| 594 | u16 p1 = pkey1 & 0x7FFF; |
| 595 | u16 p2 = pkey2 & 0x7FFF; |
| 596 | |
| 597 | /* |
| 598 | * Low 15 bits must be non-zero and match, and |
| 599 | * one of the two must be a full member. |
| 600 | */ |
| 601 | return p1 && p1 == p2 && ((__s16)pkey1 < 0 || (__s16)pkey2 < 0); |
| 602 | } |
| 603 | |
| 604 | void qib_bad_pqkey(struct qib_ibport *ibp, __be16 trap_num, u32 key, u32 sl, |
| 605 | u32 qp1, u32 qp2, __be16 lid1, __be16 lid2); |
| 606 | void qib_cap_mask_chg(struct qib_ibport *ibp); |
| 607 | void qib_sys_guid_chg(struct qib_ibport *ibp); |
| 608 | void qib_node_desc_chg(struct qib_ibport *ibp); |
| 609 | int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, |
Ira Weiny | a97e2d8 | 2015-05-31 17:15:30 -0400 | [diff] [blame] | 610 | const struct ib_wc *in_wc, const struct ib_grh *in_grh, |
Ira Weiny | 4cd7c94 | 2015-06-06 14:38:31 -0400 | [diff] [blame] | 611 | const struct ib_mad_hdr *in, size_t in_mad_size, |
| 612 | struct ib_mad_hdr *out, size_t *out_mad_size, |
| 613 | u16 *out_mad_pkey_index); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 614 | int qib_create_agents(struct qib_ibdev *dev); |
| 615 | void qib_free_agents(struct qib_ibdev *dev); |
| 616 | |
| 617 | /* |
| 618 | * Compare the lower 24 bits of the two values. |
| 619 | * Returns an integer <, ==, or > than zero. |
| 620 | */ |
| 621 | static inline int qib_cmp24(u32 a, u32 b) |
| 622 | { |
| 623 | return (((int) a) - ((int) b)) << 8; |
| 624 | } |
| 625 | |
| 626 | struct qib_mcast *qib_mcast_find(struct qib_ibport *ibp, union ib_gid *mgid); |
| 627 | |
| 628 | int qib_snapshot_counters(struct qib_pportdata *ppd, u64 *swords, |
| 629 | u64 *rwords, u64 *spkts, u64 *rpkts, |
| 630 | u64 *xmit_wait); |
| 631 | |
| 632 | int qib_get_counters(struct qib_pportdata *ppd, |
| 633 | struct qib_verbs_counters *cntrs); |
| 634 | |
| 635 | int qib_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); |
| 636 | |
| 637 | int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); |
| 638 | |
| 639 | int qib_mcast_tree_empty(struct qib_ibport *ibp); |
| 640 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 641 | __be32 qib_compute_aeth(struct rvt_qp *qp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 642 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 643 | struct rvt_qp *qib_lookup_qpn(struct qib_ibport *ibp, u32 qpn); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 644 | |
| 645 | struct ib_qp *qib_create_qp(struct ib_pd *ibpd, |
| 646 | struct ib_qp_init_attr *init_attr, |
| 647 | struct ib_udata *udata); |
| 648 | |
| 649 | int qib_destroy_qp(struct ib_qp *ibqp); |
| 650 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 651 | int qib_error_qp(struct rvt_qp *qp, enum ib_wc_status err); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 652 | |
| 653 | int qib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, |
| 654 | int attr_mask, struct ib_udata *udata); |
| 655 | |
| 656 | int qib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, |
| 657 | int attr_mask, struct ib_qp_init_attr *init_attr); |
| 658 | |
| 659 | unsigned qib_free_all_qps(struct qib_devdata *dd); |
| 660 | |
| 661 | void qib_init_qpn_table(struct qib_devdata *dd, struct qib_qpn_table *qpt); |
| 662 | |
| 663 | void qib_free_qpn_table(struct qib_qpn_table *qpt); |
| 664 | |
Mike Marciniszyn | 1dd173b | 2013-06-15 17:07:14 -0400 | [diff] [blame] | 665 | #ifdef CONFIG_DEBUG_FS |
| 666 | |
| 667 | struct qib_qp_iter; |
| 668 | |
| 669 | struct qib_qp_iter *qib_qp_iter_init(struct qib_ibdev *dev); |
| 670 | |
| 671 | int qib_qp_iter_next(struct qib_qp_iter *iter); |
| 672 | |
| 673 | void qib_qp_iter_print(struct seq_file *s, struct qib_qp_iter *iter); |
| 674 | |
| 675 | #endif |
| 676 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 677 | void qib_get_credit(struct rvt_qp *qp, u32 aeth); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 678 | |
| 679 | unsigned qib_pkt_delay(u32 plen, u8 snd_mult, u8 rcv_mult); |
| 680 | |
| 681 | void qib_verbs_sdma_desc_avail(struct qib_pportdata *ppd, unsigned avail); |
| 682 | |
| 683 | void qib_put_txreq(struct qib_verbs_txreq *tx); |
| 684 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 685 | int qib_verbs_send(struct rvt_qp *qp, struct qib_ib_header *hdr, |
| 686 | u32 hdrwords, struct rvt_sge_state *ss, u32 len); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 687 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 688 | void qib_copy_sge(struct rvt_sge_state *ss, void *data, u32 length, |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 689 | int release); |
| 690 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 691 | void qib_skip_sge(struct rvt_sge_state *ss, u32 length, int release); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 692 | |
| 693 | void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr, |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 694 | int has_grh, void *data, u32 tlen, struct rvt_qp *qp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 695 | |
| 696 | void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr, |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 697 | int has_grh, void *data, u32 tlen, struct rvt_qp *qp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 698 | |
| 699 | int qib_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr); |
| 700 | |
Mike Marciniszyn | 1fb9fed | 2012-07-16 17:11:06 +0000 | [diff] [blame] | 701 | struct ib_ah *qib_create_qp0_ah(struct qib_ibport *ibp, u16 dlid); |
| 702 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 703 | void qib_rc_rnr_retry(unsigned long arg); |
| 704 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 705 | void qib_rc_send_complete(struct rvt_qp *qp, struct qib_ib_header *hdr); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 706 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 707 | void qib_rc_error(struct rvt_qp *qp, enum ib_wc_status err); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 708 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 709 | int qib_post_ud_send(struct rvt_qp *qp, struct ib_send_wr *wr); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 710 | |
| 711 | void qib_ud_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr, |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 712 | int has_grh, void *data, u32 tlen, struct rvt_qp *qp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 713 | |
| 714 | int qib_post_srq_receive(struct ib_srq *ibsrq, struct ib_recv_wr *wr, |
| 715 | struct ib_recv_wr **bad_wr); |
| 716 | |
| 717 | struct ib_srq *qib_create_srq(struct ib_pd *ibpd, |
| 718 | struct ib_srq_init_attr *srq_init_attr, |
| 719 | struct ib_udata *udata); |
| 720 | |
| 721 | int qib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, |
| 722 | enum ib_srq_attr_mask attr_mask, |
| 723 | struct ib_udata *udata); |
| 724 | |
| 725 | int qib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr); |
| 726 | |
| 727 | int qib_destroy_srq(struct ib_srq *ibsrq); |
| 728 | |
Mike Marciniszyn | 85caafe | 2013-06-04 15:05:37 -0400 | [diff] [blame] | 729 | int qib_cq_init(struct qib_devdata *dd); |
| 730 | |
| 731 | void qib_cq_exit(struct qib_devdata *dd); |
| 732 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 733 | void qib_cq_enter(struct qib_cq *cq, struct ib_wc *entry, int sig); |
| 734 | |
| 735 | int qib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry); |
| 736 | |
Matan Barak | bcf4c1e | 2015-06-11 16:35:20 +0300 | [diff] [blame] | 737 | struct ib_cq *qib_create_cq(struct ib_device *ibdev, |
| 738 | const struct ib_cq_init_attr *attr, |
| 739 | struct ib_ucontext *context, |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 740 | struct ib_udata *udata); |
| 741 | |
| 742 | int qib_destroy_cq(struct ib_cq *ibcq); |
| 743 | |
| 744 | int qib_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags notify_flags); |
| 745 | |
| 746 | int qib_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata); |
| 747 | |
Mike Marciniszyn | 8aac4cc | 2012-06-27 18:33:19 -0400 | [diff] [blame] | 748 | void mr_rcu_callback(struct rcu_head *list); |
| 749 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 750 | static inline void qib_put_ss(struct rvt_sge_state *ss) |
Mike Marciniszyn | 6a82649 | 2012-06-27 18:33:12 -0400 | [diff] [blame] | 751 | { |
| 752 | while (ss->num_sge) { |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 753 | rvt_put_mr(ss->sge.mr); |
Mike Marciniszyn | 6a82649 | 2012-06-27 18:33:12 -0400 | [diff] [blame] | 754 | if (--ss->num_sge) |
| 755 | ss->sge = *ss->sg_list++; |
| 756 | } |
| 757 | } |
| 758 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 759 | void qib_release_mmap_info(struct kref *ref); |
| 760 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 761 | struct rvt_mmap_info *qib_create_mmap_info(struct qib_ibdev *dev, u32 size, |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 762 | struct ib_ucontext *context, |
| 763 | void *obj); |
| 764 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 765 | void qib_update_mmap_info(struct qib_ibdev *dev, struct rvt_mmap_info *ip, |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 766 | u32 size, void *obj); |
| 767 | |
| 768 | int qib_mmap(struct ib_ucontext *context, struct vm_area_struct *vma); |
| 769 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 770 | int qib_get_rwqe(struct rvt_qp *qp, int wr_id_only); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 771 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 772 | void qib_migrate_qp(struct rvt_qp *qp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 773 | |
| 774 | int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr, |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 775 | int has_grh, struct rvt_qp *qp, u32 bth0); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 776 | |
| 777 | u32 qib_make_grh(struct qib_ibport *ibp, struct ib_grh *hdr, |
| 778 | struct ib_global_route *grh, u32 hwords, u32 nwords); |
| 779 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 780 | void qib_make_ruc_header(struct rvt_qp *qp, struct qib_other_headers *ohdr, |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 781 | u32 bth0, u32 bth2); |
| 782 | |
| 783 | void qib_do_send(struct work_struct *work); |
| 784 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 785 | void qib_send_complete(struct rvt_qp *qp, struct rvt_swqe *wqe, |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 786 | enum ib_wc_status status); |
| 787 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 788 | void qib_send_rc_ack(struct rvt_qp *qp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 789 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 790 | int qib_make_rc_req(struct rvt_qp *qp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 791 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 792 | int qib_make_uc_req(struct rvt_qp *qp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 793 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 794 | int qib_make_ud_req(struct rvt_qp *qp); |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 795 | |
| 796 | int qib_register_ib_device(struct qib_devdata *); |
| 797 | |
| 798 | void qib_unregister_ib_device(struct qib_devdata *); |
| 799 | |
| 800 | void qib_ib_rcv(struct qib_ctxtdata *, void *, void *, u32); |
| 801 | |
| 802 | void qib_ib_piobufavail(struct qib_devdata *); |
| 803 | |
| 804 | unsigned qib_get_npkeys(struct qib_devdata *); |
| 805 | |
| 806 | unsigned qib_get_pkey(struct qib_ibport *, unsigned); |
| 807 | |
| 808 | extern const enum ib_wc_opcode ib_qib_wc_opcode[]; |
| 809 | |
| 810 | /* |
| 811 | * Below HCA-independent IB PhysPortState values, returned |
| 812 | * by the f_ibphys_portstate() routine. |
| 813 | */ |
| 814 | #define IB_PHYSPORTSTATE_SLEEP 1 |
| 815 | #define IB_PHYSPORTSTATE_POLL 2 |
| 816 | #define IB_PHYSPORTSTATE_DISABLED 3 |
| 817 | #define IB_PHYSPORTSTATE_CFG_TRAIN 4 |
| 818 | #define IB_PHYSPORTSTATE_LINKUP 5 |
| 819 | #define IB_PHYSPORTSTATE_LINK_ERR_RECOVER 6 |
| 820 | #define IB_PHYSPORTSTATE_CFG_DEBOUNCE 8 |
| 821 | #define IB_PHYSPORTSTATE_CFG_IDLE 0xB |
| 822 | #define IB_PHYSPORTSTATE_RECOVERY_RETRAIN 0xC |
| 823 | #define IB_PHYSPORTSTATE_RECOVERY_WAITRMT 0xE |
| 824 | #define IB_PHYSPORTSTATE_RECOVERY_IDLE 0xF |
| 825 | #define IB_PHYSPORTSTATE_CFG_ENH 0x10 |
| 826 | #define IB_PHYSPORTSTATE_CFG_WAIT_ENH 0x13 |
| 827 | |
| 828 | extern const int ib_qib_state_ops[]; |
| 829 | |
| 830 | extern __be64 ib_qib_sys_image_guid; /* in network order */ |
| 831 | |
Dennis Dalessandro | 7c2e11f | 2016-01-22 12:45:59 -0800 | [diff] [blame^] | 832 | extern unsigned int ib_rvt_lkey_table_size; |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 833 | |
| 834 | extern unsigned int ib_qib_max_cqes; |
| 835 | |
| 836 | extern unsigned int ib_qib_max_cqs; |
| 837 | |
| 838 | extern unsigned int ib_qib_max_qp_wrs; |
| 839 | |
| 840 | extern unsigned int ib_qib_max_qps; |
| 841 | |
| 842 | extern unsigned int ib_qib_max_sges; |
| 843 | |
| 844 | extern unsigned int ib_qib_max_mcast_grps; |
| 845 | |
| 846 | extern unsigned int ib_qib_max_mcast_qp_attached; |
| 847 | |
| 848 | extern unsigned int ib_qib_max_srqs; |
| 849 | |
| 850 | extern unsigned int ib_qib_max_srq_sges; |
| 851 | |
| 852 | extern unsigned int ib_qib_max_srq_wrs; |
| 853 | |
| 854 | extern const u32 ib_qib_rnr_table[]; |
| 855 | |
Ralph Campbell | f931551 | 2010-05-23 21:44:54 -0700 | [diff] [blame] | 856 | #endif /* QIB_VERBS_H */ |