1f931551bSRalph Campbell /* 21dd173b0SMike Marciniszyn * Copyright (c) 2012, 2013 Intel Corporation. All rights reserved. 31fb9fed6SMike Marciniszyn * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved. 4f931551bSRalph Campbell * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 5f931551bSRalph Campbell * 6f931551bSRalph Campbell * This software is available to you under a choice of one of two 7f931551bSRalph Campbell * licenses. You may choose to be licensed under the terms of the GNU 8f931551bSRalph Campbell * General Public License (GPL) Version 2, available from the file 9f931551bSRalph Campbell * COPYING in the main directory of this source tree, or the 10f931551bSRalph Campbell * OpenIB.org BSD license below: 11f931551bSRalph Campbell * 12f931551bSRalph Campbell * Redistribution and use in source and binary forms, with or 13f931551bSRalph Campbell * without modification, are permitted provided that the following 14f931551bSRalph Campbell * conditions are met: 15f931551bSRalph Campbell * 16f931551bSRalph Campbell * - Redistributions of source code must retain the above 17f931551bSRalph Campbell * copyright notice, this list of conditions and the following 18f931551bSRalph Campbell * disclaimer. 19f931551bSRalph Campbell * 20f931551bSRalph Campbell * - Redistributions in binary form must reproduce the above 21f931551bSRalph Campbell * copyright notice, this list of conditions and the following 22f931551bSRalph Campbell * disclaimer in the documentation and/or other materials 23f931551bSRalph Campbell * provided with the distribution. 24f931551bSRalph Campbell * 25f931551bSRalph Campbell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26f931551bSRalph Campbell * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27f931551bSRalph Campbell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28f931551bSRalph Campbell * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29f931551bSRalph Campbell * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30f931551bSRalph Campbell * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31f931551bSRalph Campbell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32f931551bSRalph Campbell * SOFTWARE. 33f931551bSRalph Campbell */ 34f931551bSRalph Campbell 35f931551bSRalph Campbell #ifndef QIB_VERBS_H 36f931551bSRalph Campbell #define QIB_VERBS_H 37f931551bSRalph Campbell 38f931551bSRalph Campbell #include <linux/types.h> 39f931551bSRalph Campbell #include <linux/spinlock.h> 40f931551bSRalph Campbell #include <linux/kernel.h> 41f931551bSRalph Campbell #include <linux/interrupt.h> 42f931551bSRalph Campbell #include <linux/kref.h> 43f931551bSRalph Campbell #include <linux/workqueue.h> 4485caafe3SMike Marciniszyn #include <linux/kthread.h> 456a82649fSMike Marciniszyn #include <linux/completion.h> 46f931551bSRalph Campbell #include <rdma/ib_pack.h> 47f931551bSRalph Campbell #include <rdma/ib_user_verbs.h> 48f931551bSRalph Campbell 49f931551bSRalph Campbell struct qib_ctxtdata; 50f931551bSRalph Campbell struct qib_pportdata; 51f931551bSRalph Campbell struct qib_devdata; 52f931551bSRalph Campbell struct qib_verbs_txreq; 53f931551bSRalph Campbell 54f931551bSRalph Campbell #define QIB_MAX_RDMA_ATOMIC 16 55f931551bSRalph Campbell #define QIB_GUIDS_PER_PORT 5 56f931551bSRalph Campbell 57f931551bSRalph Campbell #define QPN_MAX (1 << 24) 58f931551bSRalph Campbell #define QPNMAP_ENTRIES (QPN_MAX / PAGE_SIZE / BITS_PER_BYTE) 59f931551bSRalph Campbell 60f931551bSRalph Campbell /* 61f931551bSRalph Campbell * Increment this value if any changes that break userspace ABI 62f931551bSRalph Campbell * compatibility are made. 63f931551bSRalph Campbell */ 64f931551bSRalph Campbell #define QIB_UVERBS_ABI_VERSION 2 65f931551bSRalph Campbell 66f931551bSRalph Campbell /* 67f931551bSRalph Campbell * Define an ib_cq_notify value that is not valid so we know when CQ 68f931551bSRalph Campbell * notifications are armed. 69f931551bSRalph Campbell */ 70f931551bSRalph Campbell #define IB_CQ_NONE (IB_CQ_NEXT_COMP + 1) 71f931551bSRalph Campbell 72f931551bSRalph Campbell #define IB_SEQ_NAK (3 << 29) 73f931551bSRalph Campbell 74f931551bSRalph Campbell /* AETH NAK opcode values */ 75f931551bSRalph Campbell #define IB_RNR_NAK 0x20 76f931551bSRalph Campbell #define IB_NAK_PSN_ERROR 0x60 77f931551bSRalph Campbell #define IB_NAK_INVALID_REQUEST 0x61 78f931551bSRalph Campbell #define IB_NAK_REMOTE_ACCESS_ERROR 0x62 79f931551bSRalph Campbell #define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63 80f931551bSRalph Campbell #define IB_NAK_INVALID_RD_REQUEST 0x64 81f931551bSRalph Campbell 82f931551bSRalph Campbell /* Flags for checking QP state (see ib_qib_state_ops[]) */ 83f931551bSRalph Campbell #define QIB_POST_SEND_OK 0x01 84f931551bSRalph Campbell #define QIB_POST_RECV_OK 0x02 85f931551bSRalph Campbell #define QIB_PROCESS_RECV_OK 0x04 86f931551bSRalph Campbell #define QIB_PROCESS_SEND_OK 0x08 87f931551bSRalph Campbell #define QIB_PROCESS_NEXT_SEND_OK 0x10 88f931551bSRalph Campbell #define QIB_FLUSH_SEND 0x20 89f931551bSRalph Campbell #define QIB_FLUSH_RECV 0x40 90f931551bSRalph Campbell #define QIB_PROCESS_OR_FLUSH_SEND \ 91f931551bSRalph Campbell (QIB_PROCESS_SEND_OK | QIB_FLUSH_SEND) 92f931551bSRalph Campbell 93f931551bSRalph Campbell /* IB Performance Manager status values */ 94f931551bSRalph Campbell #define IB_PMA_SAMPLE_STATUS_DONE 0x00 95f931551bSRalph Campbell #define IB_PMA_SAMPLE_STATUS_STARTED 0x01 96f931551bSRalph Campbell #define IB_PMA_SAMPLE_STATUS_RUNNING 0x02 97f931551bSRalph Campbell 98f931551bSRalph Campbell /* Mandatory IB performance counter select values. */ 99f931551bSRalph Campbell #define IB_PMA_PORT_XMIT_DATA cpu_to_be16(0x0001) 100f931551bSRalph Campbell #define IB_PMA_PORT_RCV_DATA cpu_to_be16(0x0002) 101f931551bSRalph Campbell #define IB_PMA_PORT_XMIT_PKTS cpu_to_be16(0x0003) 102f931551bSRalph Campbell #define IB_PMA_PORT_RCV_PKTS cpu_to_be16(0x0004) 103f931551bSRalph Campbell #define IB_PMA_PORT_XMIT_WAIT cpu_to_be16(0x0005) 104f931551bSRalph Campbell 105f931551bSRalph Campbell #define QIB_VENDOR_IPG cpu_to_be16(0xFFA0) 106f931551bSRalph Campbell 107f931551bSRalph Campbell #define IB_BTH_REQ_ACK (1 << 31) 108f931551bSRalph Campbell #define IB_BTH_SOLICITED (1 << 23) 109f931551bSRalph Campbell #define IB_BTH_MIG_REQ (1 << 22) 110f931551bSRalph Campbell 111f931551bSRalph Campbell /* XXX Should be defined in ib_verbs.h enum ib_port_cap_flags */ 112f931551bSRalph Campbell #define IB_PORT_OTHER_LOCAL_CHANGES_SUP (1 << 26) 113f931551bSRalph Campbell 114f931551bSRalph Campbell #define IB_GRH_VERSION 6 115f931551bSRalph Campbell #define IB_GRH_VERSION_MASK 0xF 116f931551bSRalph Campbell #define IB_GRH_VERSION_SHIFT 28 117f931551bSRalph Campbell #define IB_GRH_TCLASS_MASK 0xFF 118f931551bSRalph Campbell #define IB_GRH_TCLASS_SHIFT 20 119f931551bSRalph Campbell #define IB_GRH_FLOW_MASK 0xFFFFF 120f931551bSRalph Campbell #define IB_GRH_FLOW_SHIFT 0 121f931551bSRalph Campbell #define IB_GRH_NEXT_HDR 0x1B 122f931551bSRalph Campbell 123f931551bSRalph Campbell #define IB_DEFAULT_GID_PREFIX cpu_to_be64(0xfe80000000000000ULL) 124f931551bSRalph Campbell 125f931551bSRalph Campbell /* Values for set/get portinfo VLCap OperationalVLs */ 126f931551bSRalph Campbell #define IB_VL_VL0 1 127f931551bSRalph Campbell #define IB_VL_VL0_1 2 128f931551bSRalph Campbell #define IB_VL_VL0_3 3 129f931551bSRalph Campbell #define IB_VL_VL0_7 4 130f931551bSRalph Campbell #define IB_VL_VL0_14 5 131f931551bSRalph Campbell 132f931551bSRalph Campbell static inline int qib_num_vls(int vls) 133f931551bSRalph Campbell { 134f931551bSRalph Campbell switch (vls) { 135f931551bSRalph Campbell default: 136f931551bSRalph Campbell case IB_VL_VL0: 137f931551bSRalph Campbell return 1; 138f931551bSRalph Campbell case IB_VL_VL0_1: 139f931551bSRalph Campbell return 2; 140f931551bSRalph Campbell case IB_VL_VL0_3: 141f931551bSRalph Campbell return 4; 142f931551bSRalph Campbell case IB_VL_VL0_7: 143f931551bSRalph Campbell return 8; 144f931551bSRalph Campbell case IB_VL_VL0_14: 145f931551bSRalph Campbell return 15; 146f931551bSRalph Campbell } 147f931551bSRalph Campbell } 148f931551bSRalph Campbell 149f931551bSRalph Campbell struct ib_reth { 150f931551bSRalph Campbell __be64 vaddr; 151f931551bSRalph Campbell __be32 rkey; 152f931551bSRalph Campbell __be32 length; 15378a58864SMike Marciniszyn } __packed; 154f931551bSRalph Campbell 155f931551bSRalph Campbell struct ib_atomic_eth { 156f931551bSRalph Campbell __be32 vaddr[2]; /* unaligned so access as 2 32-bit words */ 157f931551bSRalph Campbell __be32 rkey; 158f931551bSRalph Campbell __be64 swap_data; 159f931551bSRalph Campbell __be64 compare_data; 16078a58864SMike Marciniszyn } __packed; 161f931551bSRalph Campbell 162f931551bSRalph Campbell struct qib_other_headers { 163f931551bSRalph Campbell __be32 bth[3]; 164f931551bSRalph Campbell union { 165f931551bSRalph Campbell struct { 166f931551bSRalph Campbell __be32 deth[2]; 167f931551bSRalph Campbell __be32 imm_data; 168f931551bSRalph Campbell } ud; 169f931551bSRalph Campbell struct { 170f931551bSRalph Campbell struct ib_reth reth; 171f931551bSRalph Campbell __be32 imm_data; 172f931551bSRalph Campbell } rc; 173f931551bSRalph Campbell struct { 174f931551bSRalph Campbell __be32 aeth; 175f931551bSRalph Campbell __be32 atomic_ack_eth[2]; 176f931551bSRalph Campbell } at; 177f931551bSRalph Campbell __be32 imm_data; 178f931551bSRalph Campbell __be32 aeth; 179f931551bSRalph Campbell struct ib_atomic_eth atomic_eth; 180f931551bSRalph Campbell } u; 18178a58864SMike Marciniszyn } __packed; 182f931551bSRalph Campbell 183f931551bSRalph Campbell /* 184f931551bSRalph Campbell * Note that UD packets with a GRH header are 8+40+12+8 = 68 bytes 185f931551bSRalph Campbell * long (72 w/ imm_data). Only the first 56 bytes of the IB header 186f931551bSRalph Campbell * will be in the eager header buffer. The remaining 12 or 16 bytes 187f931551bSRalph Campbell * are in the data buffer. 188f931551bSRalph Campbell */ 189f931551bSRalph Campbell struct qib_ib_header { 190f931551bSRalph Campbell __be16 lrh[4]; 191f931551bSRalph Campbell union { 192f931551bSRalph Campbell struct { 193f931551bSRalph Campbell struct ib_grh grh; 194f931551bSRalph Campbell struct qib_other_headers oth; 195f931551bSRalph Campbell } l; 196f931551bSRalph Campbell struct qib_other_headers oth; 197f931551bSRalph Campbell } u; 19878a58864SMike Marciniszyn } __packed; 199f931551bSRalph Campbell 200f931551bSRalph Campbell struct qib_pio_header { 201f931551bSRalph Campbell __le32 pbc[2]; 202f931551bSRalph Campbell struct qib_ib_header hdr; 20378a58864SMike Marciniszyn } __packed; 204f931551bSRalph Campbell 205f931551bSRalph Campbell /* 206f931551bSRalph Campbell * There is one struct qib_mcast for each multicast GID. 207f931551bSRalph Campbell * All attached QPs are then stored as a list of 208f931551bSRalph Campbell * struct qib_mcast_qp. 209f931551bSRalph Campbell */ 210f931551bSRalph Campbell struct qib_mcast_qp { 211f931551bSRalph Campbell struct list_head list; 212f931551bSRalph Campbell struct qib_qp *qp; 213f931551bSRalph Campbell }; 214f931551bSRalph Campbell 215f931551bSRalph Campbell struct qib_mcast { 216f931551bSRalph Campbell struct rb_node rb_node; 217f931551bSRalph Campbell union ib_gid mgid; 218f931551bSRalph Campbell struct list_head qp_list; 219f931551bSRalph Campbell wait_queue_head_t wait; 220f931551bSRalph Campbell atomic_t refcount; 221f931551bSRalph Campbell int n_attached; 222f931551bSRalph Campbell }; 223f931551bSRalph Campbell 224f931551bSRalph Campbell /* Protection domain */ 225f931551bSRalph Campbell struct qib_pd { 226f931551bSRalph Campbell struct ib_pd ibpd; 227f931551bSRalph Campbell int user; /* non-zero if created from user space */ 228f931551bSRalph Campbell }; 229f931551bSRalph Campbell 230f931551bSRalph Campbell /* Address Handle */ 231f931551bSRalph Campbell struct qib_ah { 232f931551bSRalph Campbell struct ib_ah ibah; 233f931551bSRalph Campbell struct ib_ah_attr attr; 234f931551bSRalph Campbell atomic_t refcount; 235f931551bSRalph Campbell }; 236f931551bSRalph Campbell 237f931551bSRalph Campbell /* 238f931551bSRalph Campbell * This structure is used by qib_mmap() to validate an offset 239f931551bSRalph Campbell * when an mmap() request is made. The vm_area_struct then uses 240f931551bSRalph Campbell * this as its vm_private_data. 241f931551bSRalph Campbell */ 242f931551bSRalph Campbell struct qib_mmap_info { 243f931551bSRalph Campbell struct list_head pending_mmaps; 244f931551bSRalph Campbell struct ib_ucontext *context; 245f931551bSRalph Campbell void *obj; 246f931551bSRalph Campbell __u64 offset; 247f931551bSRalph Campbell struct kref ref; 248f931551bSRalph Campbell unsigned size; 249f931551bSRalph Campbell }; 250f931551bSRalph Campbell 251f931551bSRalph Campbell /* 252f931551bSRalph Campbell * This structure is used to contain the head pointer, tail pointer, 253f931551bSRalph Campbell * and completion queue entries as a single memory allocation so 254f931551bSRalph Campbell * it can be mmap'ed into user space. 255f931551bSRalph Campbell */ 256f931551bSRalph Campbell struct qib_cq_wc { 257f931551bSRalph Campbell u32 head; /* index of next entry to fill */ 258f931551bSRalph Campbell u32 tail; /* index of next ib_poll_cq() entry */ 259f931551bSRalph Campbell union { 260f931551bSRalph Campbell /* these are actually size ibcq.cqe + 1 */ 261f931551bSRalph Campbell struct ib_uverbs_wc uqueue[0]; 262f931551bSRalph Campbell struct ib_wc kqueue[0]; 263f931551bSRalph Campbell }; 264f931551bSRalph Campbell }; 265f931551bSRalph Campbell 266f931551bSRalph Campbell /* 267f931551bSRalph Campbell * The completion queue structure. 268f931551bSRalph Campbell */ 269f931551bSRalph Campbell struct qib_cq { 270f931551bSRalph Campbell struct ib_cq ibcq; 27185caafe3SMike Marciniszyn struct kthread_work comptask; 27285caafe3SMike Marciniszyn struct qib_devdata *dd; 273f931551bSRalph Campbell spinlock_t lock; /* protect changes in this struct */ 274f931551bSRalph Campbell u8 notify; 275f931551bSRalph Campbell u8 triggered; 276f931551bSRalph Campbell struct qib_cq_wc *queue; 277f931551bSRalph Campbell struct qib_mmap_info *ip; 278f931551bSRalph Campbell }; 279f931551bSRalph Campbell 280f931551bSRalph Campbell /* 281f931551bSRalph Campbell * A segment is a linear region of low physical memory. 282f931551bSRalph Campbell * XXX Maybe we should use phys addr here and kmap()/kunmap(). 283f931551bSRalph Campbell * Used by the verbs layer. 284f931551bSRalph Campbell */ 285f931551bSRalph Campbell struct qib_seg { 286f931551bSRalph Campbell void *vaddr; 287f931551bSRalph Campbell size_t length; 288f931551bSRalph Campbell }; 289f931551bSRalph Campbell 290f931551bSRalph Campbell /* The number of qib_segs that fit in a page. */ 291f931551bSRalph Campbell #define QIB_SEGSZ (PAGE_SIZE / sizeof(struct qib_seg)) 292f931551bSRalph Campbell 293f931551bSRalph Campbell struct qib_segarray { 294f931551bSRalph Campbell struct qib_seg segs[QIB_SEGSZ]; 295f931551bSRalph Campbell }; 296f931551bSRalph Campbell 297f931551bSRalph Campbell struct qib_mregion { 298f931551bSRalph Campbell struct ib_pd *pd; /* shares refcnt of ibmr.pd */ 299f931551bSRalph Campbell u64 user_base; /* User's address for this region */ 300f931551bSRalph Campbell u64 iova; /* IB start address of this region */ 301f931551bSRalph Campbell size_t length; 302f931551bSRalph Campbell u32 lkey; 303f931551bSRalph Campbell u32 offset; /* offset (bytes) to start of region */ 304f931551bSRalph Campbell int access_flags; 305f931551bSRalph Campbell u32 max_segs; /* number of qib_segs in all the arrays */ 306f931551bSRalph Campbell u32 mapsz; /* size of the map array */ 3072a600f14SMike Marciniszyn u8 page_shift; /* 0 - non unform/non powerof2 sizes */ 3086a82649fSMike Marciniszyn u8 lkey_published; /* in global table */ 3096a82649fSMike Marciniszyn struct completion comp; /* complete when refcount goes to zero */ 3108aac4cc3SMike Marciniszyn struct rcu_head list; 311f931551bSRalph Campbell atomic_t refcount; 312f931551bSRalph Campbell struct qib_segarray *map[0]; /* the segments */ 313f931551bSRalph Campbell }; 314f931551bSRalph Campbell 315f931551bSRalph Campbell /* 316f931551bSRalph Campbell * These keep track of the copy progress within a memory region. 317f931551bSRalph Campbell * Used by the verbs layer. 318f931551bSRalph Campbell */ 319f931551bSRalph Campbell struct qib_sge { 320f931551bSRalph Campbell struct qib_mregion *mr; 321f931551bSRalph Campbell void *vaddr; /* kernel virtual address of segment */ 322f931551bSRalph Campbell u32 sge_length; /* length of the SGE */ 323f931551bSRalph Campbell u32 length; /* remaining length of the segment */ 324f931551bSRalph Campbell u16 m; /* current index: mr->map[m] */ 325f931551bSRalph Campbell u16 n; /* current index: mr->map[m]->segs[n] */ 326f931551bSRalph Campbell }; 327f931551bSRalph Campbell 328f931551bSRalph Campbell /* Memory region */ 329f931551bSRalph Campbell struct qib_mr { 330f931551bSRalph Campbell struct ib_mr ibmr; 331f931551bSRalph Campbell struct ib_umem *umem; 332f931551bSRalph Campbell struct qib_mregion mr; /* must be last */ 333f931551bSRalph Campbell }; 334f931551bSRalph Campbell 335f931551bSRalph Campbell /* 336f931551bSRalph Campbell * Send work request queue entry. 337f931551bSRalph Campbell * The size of the sg_list is determined when the QP is created and stored 338f931551bSRalph Campbell * in qp->s_max_sge. 339f931551bSRalph Campbell */ 340f931551bSRalph Campbell struct qib_swqe { 341f931551bSRalph Campbell struct ib_send_wr wr; /* don't use wr.sg_list */ 342f931551bSRalph Campbell u32 psn; /* first packet sequence number */ 343f931551bSRalph Campbell u32 lpsn; /* last packet sequence number */ 344f931551bSRalph Campbell u32 ssn; /* send sequence number */ 345f931551bSRalph Campbell u32 length; /* total length of data in sg_list */ 346f931551bSRalph Campbell struct qib_sge sg_list[0]; 347f931551bSRalph Campbell }; 348f931551bSRalph Campbell 349f931551bSRalph Campbell /* 350f931551bSRalph Campbell * Receive work request queue entry. 351f931551bSRalph Campbell * The size of the sg_list is determined when the QP (or SRQ) is created 352f931551bSRalph Campbell * and stored in qp->r_rq.max_sge (or srq->rq.max_sge). 353f931551bSRalph Campbell */ 354f931551bSRalph Campbell struct qib_rwqe { 355f931551bSRalph Campbell u64 wr_id; 356f931551bSRalph Campbell u8 num_sge; 357f931551bSRalph Campbell struct ib_sge sg_list[0]; 358f931551bSRalph Campbell }; 359f931551bSRalph Campbell 360f931551bSRalph Campbell /* 361f931551bSRalph Campbell * This structure is used to contain the head pointer, tail pointer, 362f931551bSRalph Campbell * and receive work queue entries as a single memory allocation so 363f931551bSRalph Campbell * it can be mmap'ed into user space. 364f931551bSRalph Campbell * Note that the wq array elements are variable size so you can't 365f931551bSRalph Campbell * just index into the array to get the N'th element; 366f931551bSRalph Campbell * use get_rwqe_ptr() instead. 367f931551bSRalph Campbell */ 368f931551bSRalph Campbell struct qib_rwq { 369f931551bSRalph Campbell u32 head; /* new work requests posted to the head */ 370f931551bSRalph Campbell u32 tail; /* receives pull requests from here. */ 371f931551bSRalph Campbell struct qib_rwqe wq[0]; 372f931551bSRalph Campbell }; 373f931551bSRalph Campbell 374f931551bSRalph Campbell struct qib_rq { 375f931551bSRalph Campbell struct qib_rwq *wq; 376f931551bSRalph Campbell u32 size; /* size of RWQE array */ 377f931551bSRalph Campbell u8 max_sge; 3781c94283dSMike Marciniszyn spinlock_t lock /* protect changes in this struct */ 3791c94283dSMike Marciniszyn ____cacheline_aligned_in_smp; 380f931551bSRalph Campbell }; 381f931551bSRalph Campbell 382f931551bSRalph Campbell struct qib_srq { 383f931551bSRalph Campbell struct ib_srq ibsrq; 384f931551bSRalph Campbell struct qib_rq rq; 385f931551bSRalph Campbell struct qib_mmap_info *ip; 386f931551bSRalph Campbell /* send signal when number of RWQEs < limit */ 387f931551bSRalph Campbell u32 limit; 388f931551bSRalph Campbell }; 389f931551bSRalph Campbell 390f931551bSRalph Campbell struct qib_sge_state { 391f931551bSRalph Campbell struct qib_sge *sg_list; /* next SGE to be used if any */ 392f931551bSRalph Campbell struct qib_sge sge; /* progress state for the current SGE */ 393f931551bSRalph Campbell u32 total_len; 394f931551bSRalph Campbell u8 num_sge; 395f931551bSRalph Campbell }; 396f931551bSRalph Campbell 397f931551bSRalph Campbell /* 398f931551bSRalph Campbell * This structure holds the information that the send tasklet needs 399f931551bSRalph Campbell * to send a RDMA read response or atomic operation. 400f931551bSRalph Campbell */ 401f931551bSRalph Campbell struct qib_ack_entry { 402f931551bSRalph Campbell u8 opcode; 403f931551bSRalph Campbell u8 sent; 404f931551bSRalph Campbell u32 psn; 405f931551bSRalph Campbell u32 lpsn; 406f931551bSRalph Campbell union { 407f931551bSRalph Campbell struct qib_sge rdma_sge; 408f931551bSRalph Campbell u64 atomic_data; 409f931551bSRalph Campbell }; 410f931551bSRalph Campbell }; 411f931551bSRalph Campbell 412f931551bSRalph Campbell /* 413f931551bSRalph Campbell * Variables prefixed with s_ are for the requester (sender). 414f931551bSRalph Campbell * Variables prefixed with r_ are for the responder (receiver). 415f931551bSRalph Campbell * Variables prefixed with ack_ are for responder replies. 416f931551bSRalph Campbell * 417f931551bSRalph Campbell * Common variables are protected by both r_rq.lock and s_lock in that order 418f931551bSRalph Campbell * which only happens in modify_qp() or changing the QP 'state'. 419f931551bSRalph Campbell */ 420f931551bSRalph Campbell struct qib_qp { 421f931551bSRalph Campbell struct ib_qp ibqp; 4221c94283dSMike Marciniszyn /* read mostly fields above and below */ 423f931551bSRalph Campbell struct ib_ah_attr remote_ah_attr; 424f931551bSRalph Campbell struct ib_ah_attr alt_ah_attr; 4251fb9fed6SMike Marciniszyn struct qib_qp __rcu *next; /* link list for QPN hash table */ 4261c94283dSMike Marciniszyn struct qib_swqe *s_wq; /* send work queue */ 427f931551bSRalph Campbell struct qib_mmap_info *ip; 4281c94283dSMike Marciniszyn struct qib_ib_header *s_hdr; /* next packet header to send */ 4291c94283dSMike Marciniszyn unsigned long timeout_jiffies; /* computed from timeout */ 4301c94283dSMike Marciniszyn 4311c94283dSMike Marciniszyn enum ib_mtu path_mtu; 4321c94283dSMike Marciniszyn u32 remote_qpn; 4331c94283dSMike Marciniszyn u32 pmtu; /* decoded from path_mtu */ 4341c94283dSMike Marciniszyn u32 qkey; /* QKEY for this QP (for UD or RD) */ 4351c94283dSMike Marciniszyn u32 s_size; /* send work queue size */ 4361c94283dSMike Marciniszyn u32 s_rnr_timeout; /* number of milliseconds for RNR timeout */ 4371c94283dSMike Marciniszyn 4381c94283dSMike Marciniszyn u8 state; /* QP state */ 4391c94283dSMike Marciniszyn u8 qp_access_flags; 4401c94283dSMike Marciniszyn u8 alt_timeout; /* Alternate path timeout for this QP */ 4411c94283dSMike Marciniszyn u8 timeout; /* Timeout for this QP */ 4421c94283dSMike Marciniszyn u8 s_srate; 4431c94283dSMike Marciniszyn u8 s_mig_state; 4441c94283dSMike Marciniszyn u8 port_num; 4451c94283dSMike Marciniszyn u8 s_pkey_index; /* PKEY index to use */ 4461c94283dSMike Marciniszyn u8 s_alt_pkey_index; /* Alternate path PKEY index to use */ 4471c94283dSMike Marciniszyn u8 r_max_rd_atomic; /* max number of RDMA read/atomic to receive */ 4481c94283dSMike Marciniszyn u8 s_max_rd_atomic; /* max number of RDMA read/atomic to send */ 4491c94283dSMike Marciniszyn u8 s_retry_cnt; /* number of times to retry */ 4501c94283dSMike Marciniszyn u8 s_rnr_retry_cnt; 4511c94283dSMike Marciniszyn u8 r_min_rnr_timer; /* retry timeout value for RNR NAKs */ 4521c94283dSMike Marciniszyn u8 s_max_sge; /* size of s_wq->sg_list */ 4531c94283dSMike Marciniszyn u8 s_draining; 4541c94283dSMike Marciniszyn 4551c94283dSMike Marciniszyn /* start of read/write fields */ 4561c94283dSMike Marciniszyn 4571c94283dSMike Marciniszyn atomic_t refcount ____cacheline_aligned_in_smp; 4581c94283dSMike Marciniszyn wait_queue_head_t wait; 4591c94283dSMike Marciniszyn 4601c94283dSMike Marciniszyn 4611c94283dSMike Marciniszyn struct qib_ack_entry s_ack_queue[QIB_MAX_RDMA_ATOMIC + 1] 4621c94283dSMike Marciniszyn ____cacheline_aligned_in_smp; 463f931551bSRalph Campbell struct qib_sge_state s_rdma_read_sge; 4641c94283dSMike Marciniszyn 4651c94283dSMike Marciniszyn spinlock_t r_lock ____cacheline_aligned_in_smp; /* used for APM */ 4661c94283dSMike Marciniszyn unsigned long r_aflags; 4671c94283dSMike Marciniszyn u64 r_wr_id; /* ID for current receive WQE */ 4681c94283dSMike Marciniszyn u32 r_ack_psn; /* PSN for next ACK or atomic ACK */ 4691c94283dSMike Marciniszyn u32 r_len; /* total length of r_sge */ 4701c94283dSMike Marciniszyn u32 r_rcv_len; /* receive data len processed */ 4711c94283dSMike Marciniszyn u32 r_psn; /* expected rcv packet sequence number */ 4721c94283dSMike Marciniszyn u32 r_msn; /* message sequence number */ 4731c94283dSMike Marciniszyn 4741c94283dSMike Marciniszyn u8 r_state; /* opcode of last packet received */ 4751c94283dSMike Marciniszyn u8 r_flags; 4761c94283dSMike Marciniszyn u8 r_head_ack_queue; /* index into s_ack_queue[] */ 4771c94283dSMike Marciniszyn 4781c94283dSMike Marciniszyn struct list_head rspwait; /* link for waititing to respond */ 4791c94283dSMike Marciniszyn 480f931551bSRalph Campbell struct qib_sge_state r_sge; /* current receive data */ 4811c94283dSMike Marciniszyn struct qib_rq r_rq; /* receive work queue */ 4821c94283dSMike Marciniszyn 4831c94283dSMike Marciniszyn spinlock_t s_lock ____cacheline_aligned_in_smp; 4841c94283dSMike Marciniszyn struct qib_sge_state *s_cur_sge; 485f931551bSRalph Campbell u32 s_flags; 4861c94283dSMike Marciniszyn struct qib_verbs_txreq *s_tx; 4871c94283dSMike Marciniszyn struct qib_swqe *s_wqe; 4881c94283dSMike Marciniszyn struct qib_sge_state s_sge; /* current send request data */ 4891c94283dSMike Marciniszyn struct qib_mregion *s_rdma_mr; 4901c94283dSMike Marciniszyn atomic_t s_dma_busy; 491f931551bSRalph Campbell u32 s_cur_size; /* size of send packet in bytes */ 492f931551bSRalph Campbell u32 s_len; /* total length of s_sge */ 493f931551bSRalph Campbell u32 s_rdma_read_len; /* total length of s_rdma_read_sge */ 494f931551bSRalph Campbell u32 s_next_psn; /* PSN for next request */ 495f931551bSRalph Campbell u32 s_last_psn; /* last response PSN processed */ 496f931551bSRalph Campbell u32 s_sending_psn; /* lowest PSN that is being sent */ 497f931551bSRalph Campbell u32 s_sending_hpsn; /* highest PSN that is being sent */ 498f931551bSRalph Campbell u32 s_psn; /* current packet sequence number */ 499f931551bSRalph Campbell u32 s_ack_rdma_psn; /* PSN for sending RDMA read responses */ 500f931551bSRalph Campbell u32 s_ack_psn; /* PSN for acking sends and RDMA writes */ 501f931551bSRalph Campbell u32 s_head; /* new entries added here */ 502f931551bSRalph Campbell u32 s_tail; /* next entry to process */ 503f931551bSRalph Campbell u32 s_cur; /* current work queue entry */ 504f931551bSRalph Campbell u32 s_acked; /* last un-ACK'ed entry */ 505f931551bSRalph Campbell u32 s_last; /* last completed entry */ 506f931551bSRalph Campbell u32 s_ssn; /* SSN of tail entry */ 507f931551bSRalph Campbell u32 s_lsn; /* limit sequence number (credit) */ 5081c94283dSMike Marciniszyn u16 s_hdrwords; /* size of s_hdr in 32 bit words */ 5091c94283dSMike Marciniszyn u16 s_rdma_ack_cnt; 5101c94283dSMike Marciniszyn u8 s_state; /* opcode of last packet sent */ 5111c94283dSMike Marciniszyn u8 s_ack_state; /* opcode of packet to ACK */ 5121c94283dSMike Marciniszyn u8 s_nak_state; /* non-zero if NAK is pending */ 5131c94283dSMike Marciniszyn u8 r_nak_state; /* non-zero if NAK is pending */ 5141c94283dSMike Marciniszyn u8 s_retry; /* requester retry counter */ 5151c94283dSMike Marciniszyn u8 s_rnr_retry; /* requester RNR retry counter */ 5161c94283dSMike Marciniszyn u8 s_num_rd_atomic; /* number of RDMA read/atomic pending */ 5171c94283dSMike Marciniszyn u8 s_tail_ack_queue; /* index into s_ack_queue[] */ 5181c94283dSMike Marciniszyn 5191c94283dSMike Marciniszyn struct qib_sge_state s_ack_rdma_sge; 5201c94283dSMike Marciniszyn struct timer_list s_timer; 5211c94283dSMike Marciniszyn struct list_head iowait; /* link for wait PIO buf */ 5221c94283dSMike Marciniszyn 5231c94283dSMike Marciniszyn struct work_struct s_work; 5241c94283dSMike Marciniszyn 5251c94283dSMike Marciniszyn wait_queue_head_t wait_dma; 5261c94283dSMike Marciniszyn 5271c94283dSMike Marciniszyn struct qib_sge r_sg_list[0] /* verified SGEs */ 5281c94283dSMike Marciniszyn ____cacheline_aligned_in_smp; 529f931551bSRalph Campbell }; 530f931551bSRalph Campbell 531f931551bSRalph Campbell /* 532f931551bSRalph Campbell * Atomic bit definitions for r_aflags. 533f931551bSRalph Campbell */ 534f931551bSRalph Campbell #define QIB_R_WRID_VALID 0 535f931551bSRalph Campbell #define QIB_R_REWIND_SGE 1 536f931551bSRalph Campbell 537f931551bSRalph Campbell /* 538f931551bSRalph Campbell * Bit definitions for r_flags. 539f931551bSRalph Campbell */ 540f931551bSRalph Campbell #define QIB_R_REUSE_SGE 0x01 541f931551bSRalph Campbell #define QIB_R_RDMAR_SEQ 0x02 542f931551bSRalph Campbell #define QIB_R_RSP_NAK 0x04 543f931551bSRalph Campbell #define QIB_R_RSP_SEND 0x08 544f931551bSRalph Campbell #define QIB_R_COMM_EST 0x10 545f931551bSRalph Campbell 546f931551bSRalph Campbell /* 547f931551bSRalph Campbell * Bit definitions for s_flags. 548f931551bSRalph Campbell * 549f931551bSRalph Campbell * QIB_S_SIGNAL_REQ_WR - set if QP send WRs contain completion signaled 550f931551bSRalph Campbell * QIB_S_BUSY - send tasklet is processing the QP 551f931551bSRalph Campbell * QIB_S_TIMER - the RC retry timer is active 552f931551bSRalph Campbell * QIB_S_ACK_PENDING - an ACK is waiting to be sent after RDMA read/atomics 553f931551bSRalph Campbell * QIB_S_WAIT_FENCE - waiting for all prior RDMA read or atomic SWQEs 554f931551bSRalph Campbell * before processing the next SWQE 555f931551bSRalph Campbell * QIB_S_WAIT_RDMAR - waiting for a RDMA read or atomic SWQE to complete 556f931551bSRalph Campbell * before processing the next SWQE 557f931551bSRalph Campbell * QIB_S_WAIT_RNR - waiting for RNR timeout 558f931551bSRalph Campbell * QIB_S_WAIT_SSN_CREDIT - waiting for RC credits to process next SWQE 559f931551bSRalph Campbell * QIB_S_WAIT_DMA - waiting for send DMA queue to drain before generating 560f931551bSRalph Campbell * next send completion entry not via send DMA 561f931551bSRalph Campbell * QIB_S_WAIT_PIO - waiting for a send buffer to be available 562f931551bSRalph Campbell * QIB_S_WAIT_TX - waiting for a struct qib_verbs_txreq to be available 563f931551bSRalph Campbell * QIB_S_WAIT_DMA_DESC - waiting for DMA descriptors to be available 564f931551bSRalph Campbell * QIB_S_WAIT_KMEM - waiting for kernel memory to be available 565f931551bSRalph Campbell * QIB_S_WAIT_PSN - waiting for a packet to exit the send DMA queue 566f931551bSRalph Campbell * QIB_S_WAIT_ACK - waiting for an ACK packet before sending more requests 567f931551bSRalph Campbell * QIB_S_SEND_ONE - send one packet, request ACK, then wait for ACK 568f931551bSRalph Campbell */ 569f931551bSRalph Campbell #define QIB_S_SIGNAL_REQ_WR 0x0001 570f931551bSRalph Campbell #define QIB_S_BUSY 0x0002 571f931551bSRalph Campbell #define QIB_S_TIMER 0x0004 572f931551bSRalph Campbell #define QIB_S_RESP_PENDING 0x0008 573f931551bSRalph Campbell #define QIB_S_ACK_PENDING 0x0010 574f931551bSRalph Campbell #define QIB_S_WAIT_FENCE 0x0020 575f931551bSRalph Campbell #define QIB_S_WAIT_RDMAR 0x0040 576f931551bSRalph Campbell #define QIB_S_WAIT_RNR 0x0080 577f931551bSRalph Campbell #define QIB_S_WAIT_SSN_CREDIT 0x0100 578f931551bSRalph Campbell #define QIB_S_WAIT_DMA 0x0200 579f931551bSRalph Campbell #define QIB_S_WAIT_PIO 0x0400 580f931551bSRalph Campbell #define QIB_S_WAIT_TX 0x0800 581f931551bSRalph Campbell #define QIB_S_WAIT_DMA_DESC 0x1000 582f931551bSRalph Campbell #define QIB_S_WAIT_KMEM 0x2000 583f931551bSRalph Campbell #define QIB_S_WAIT_PSN 0x4000 584f931551bSRalph Campbell #define QIB_S_WAIT_ACK 0x8000 585f931551bSRalph Campbell #define QIB_S_SEND_ONE 0x10000 586f931551bSRalph Campbell #define QIB_S_UNLIMITED_CREDIT 0x20000 587f931551bSRalph Campbell 588f931551bSRalph Campbell /* 589f931551bSRalph Campbell * Wait flags that would prevent any packet type from being sent. 590f931551bSRalph Campbell */ 591f931551bSRalph Campbell #define QIB_S_ANY_WAIT_IO (QIB_S_WAIT_PIO | QIB_S_WAIT_TX | \ 592f931551bSRalph Campbell QIB_S_WAIT_DMA_DESC | QIB_S_WAIT_KMEM) 593f931551bSRalph Campbell 594f931551bSRalph Campbell /* 595f931551bSRalph Campbell * Wait flags that would prevent send work requests from making progress. 596f931551bSRalph Campbell */ 597f931551bSRalph Campbell #define QIB_S_ANY_WAIT_SEND (QIB_S_WAIT_FENCE | QIB_S_WAIT_RDMAR | \ 598f931551bSRalph Campbell QIB_S_WAIT_RNR | QIB_S_WAIT_SSN_CREDIT | QIB_S_WAIT_DMA | \ 599f931551bSRalph Campbell QIB_S_WAIT_PSN | QIB_S_WAIT_ACK) 600f931551bSRalph Campbell 601f931551bSRalph Campbell #define QIB_S_ANY_WAIT (QIB_S_ANY_WAIT_IO | QIB_S_ANY_WAIT_SEND) 602f931551bSRalph Campbell 603f931551bSRalph Campbell #define QIB_PSN_CREDIT 16 604f931551bSRalph Campbell 605f931551bSRalph Campbell /* 606f931551bSRalph Campbell * Since struct qib_swqe is not a fixed size, we can't simply index into 607f931551bSRalph Campbell * struct qib_qp.s_wq. This function does the array index computation. 608f931551bSRalph Campbell */ 609f931551bSRalph Campbell static inline struct qib_swqe *get_swqe_ptr(struct qib_qp *qp, 610f931551bSRalph Campbell unsigned n) 611f931551bSRalph Campbell { 612f931551bSRalph Campbell return (struct qib_swqe *)((char *)qp->s_wq + 613f931551bSRalph Campbell (sizeof(struct qib_swqe) + 614f931551bSRalph Campbell qp->s_max_sge * 615f931551bSRalph Campbell sizeof(struct qib_sge)) * n); 616f931551bSRalph Campbell } 617f931551bSRalph Campbell 618f931551bSRalph Campbell /* 619f931551bSRalph Campbell * Since struct qib_rwqe is not a fixed size, we can't simply index into 620f931551bSRalph Campbell * struct qib_rwq.wq. This function does the array index computation. 621f931551bSRalph Campbell */ 622f931551bSRalph Campbell static inline struct qib_rwqe *get_rwqe_ptr(struct qib_rq *rq, unsigned n) 623f931551bSRalph Campbell { 624f931551bSRalph Campbell return (struct qib_rwqe *) 625f931551bSRalph Campbell ((char *) rq->wq->wq + 626f931551bSRalph Campbell (sizeof(struct qib_rwqe) + 627f931551bSRalph Campbell rq->max_sge * sizeof(struct ib_sge)) * n); 628f931551bSRalph Campbell } 629f931551bSRalph Campbell 630f931551bSRalph Campbell /* 631f931551bSRalph Campbell * QPN-map pages start out as NULL, they get allocated upon 632f931551bSRalph Campbell * first use and are never deallocated. This way, 633f931551bSRalph Campbell * large bitmaps are not allocated unless large numbers of QPs are used. 634f931551bSRalph Campbell */ 635f931551bSRalph Campbell struct qpn_map { 636f931551bSRalph Campbell void *page; 637f931551bSRalph Campbell }; 638f931551bSRalph Campbell 639f931551bSRalph Campbell struct qib_qpn_table { 640f931551bSRalph Campbell spinlock_t lock; /* protect changes in this struct */ 641f931551bSRalph Campbell unsigned flags; /* flags for QP0/1 allocated for each port */ 642f931551bSRalph Campbell u32 last; /* last QP number allocated */ 643f931551bSRalph Campbell u32 nmaps; /* size of the map table */ 644f931551bSRalph Campbell u16 limit; 645f931551bSRalph Campbell u16 mask; 646f931551bSRalph Campbell /* bit map of free QP numbers other than 0/1 */ 647f931551bSRalph Campbell struct qpn_map map[QPNMAP_ENTRIES]; 648f931551bSRalph Campbell }; 649f931551bSRalph Campbell 650f931551bSRalph Campbell struct qib_lkey_table { 651f931551bSRalph Campbell spinlock_t lock; /* protect changes in this struct */ 652f931551bSRalph Campbell u32 next; /* next unused index (speeds search) */ 653f931551bSRalph Campbell u32 gen; /* generation count */ 654f931551bSRalph Campbell u32 max; /* size of the table */ 6557e230177SMike Marciniszyn struct qib_mregion __rcu **table; 656f931551bSRalph Campbell }; 657f931551bSRalph Campbell 658f931551bSRalph Campbell struct qib_opcode_stats { 659f931551bSRalph Campbell u64 n_packets; /* number of packets */ 660f931551bSRalph Campbell u64 n_bytes; /* total number of bytes */ 661f931551bSRalph Campbell }; 662f931551bSRalph Campbell 663ddb88765SMike Marciniszyn struct qib_opcode_stats_perctx { 664ddb88765SMike Marciniszyn struct qib_opcode_stats stats[128]; 665ddb88765SMike Marciniszyn }; 666ddb88765SMike Marciniszyn 6677d7632adSMike Marciniszyn struct qib_pma_counters { 6687d7632adSMike Marciniszyn u64 n_unicast_xmit; /* total unicast packets sent */ 6697d7632adSMike Marciniszyn u64 n_unicast_rcv; /* total unicast packets received */ 6707d7632adSMike Marciniszyn u64 n_multicast_xmit; /* total multicast packets sent */ 6717d7632adSMike Marciniszyn u64 n_multicast_rcv; /* total multicast packets received */ 6727d7632adSMike Marciniszyn }; 6737d7632adSMike Marciniszyn 674f931551bSRalph Campbell struct qib_ibport { 6751fb9fed6SMike Marciniszyn struct qib_qp __rcu *qp0; 6761fb9fed6SMike Marciniszyn struct qib_qp __rcu *qp1; 677f931551bSRalph Campbell struct ib_mad_agent *send_agent; /* agent for SMI (traps) */ 678f931551bSRalph Campbell struct qib_ah *sm_ah; 679f931551bSRalph Campbell struct qib_ah *smi_ah; 680f931551bSRalph Campbell struct rb_root mcast_tree; 681f931551bSRalph Campbell spinlock_t lock; /* protect changes in this struct */ 682f931551bSRalph Campbell 683f931551bSRalph Campbell /* non-zero when timer is set */ 684f931551bSRalph Campbell unsigned long mkey_lease_timeout; 685f931551bSRalph Campbell unsigned long trap_timeout; 686f931551bSRalph Campbell __be64 gid_prefix; /* in network order */ 687f931551bSRalph Campbell __be64 mkey; 688f931551bSRalph Campbell __be64 guids[QIB_GUIDS_PER_PORT - 1]; /* writable GUIDs */ 689f931551bSRalph Campbell u64 tid; /* TID for traps */ 6907d7632adSMike Marciniszyn struct qib_pma_counters __percpu *pmastats; 6917d7632adSMike Marciniszyn u64 z_unicast_xmit; /* starting count for PMA */ 6927d7632adSMike Marciniszyn u64 z_unicast_rcv; /* starting count for PMA */ 6937d7632adSMike Marciniszyn u64 z_multicast_xmit; /* starting count for PMA */ 6947d7632adSMike Marciniszyn u64 z_multicast_rcv; /* starting count for PMA */ 695f931551bSRalph Campbell u64 z_symbol_error_counter; /* starting count for PMA */ 696f931551bSRalph Campbell u64 z_link_error_recovery_counter; /* starting count for PMA */ 697f931551bSRalph Campbell u64 z_link_downed_counter; /* starting count for PMA */ 698f931551bSRalph Campbell u64 z_port_rcv_errors; /* starting count for PMA */ 699f931551bSRalph Campbell u64 z_port_rcv_remphys_errors; /* starting count for PMA */ 700f931551bSRalph Campbell u64 z_port_xmit_discards; /* starting count for PMA */ 701f931551bSRalph Campbell u64 z_port_xmit_data; /* starting count for PMA */ 702f931551bSRalph Campbell u64 z_port_rcv_data; /* starting count for PMA */ 703f931551bSRalph Campbell u64 z_port_xmit_packets; /* starting count for PMA */ 704f931551bSRalph Campbell u64 z_port_rcv_packets; /* starting count for PMA */ 705f931551bSRalph Campbell u32 z_local_link_integrity_errors; /* starting count for PMA */ 706f931551bSRalph Campbell u32 z_excessive_buffer_overrun_errors; /* starting count for PMA */ 707f931551bSRalph Campbell u32 z_vl15_dropped; /* starting count for PMA */ 708f931551bSRalph Campbell u32 n_rc_resends; 709f931551bSRalph Campbell u32 n_rc_acks; 710f931551bSRalph Campbell u32 n_rc_qacks; 711f931551bSRalph Campbell u32 n_rc_delayed_comp; 712f931551bSRalph Campbell u32 n_seq_naks; 713f931551bSRalph Campbell u32 n_rdma_seq; 714f931551bSRalph Campbell u32 n_rnr_naks; 715f931551bSRalph Campbell u32 n_other_naks; 716f931551bSRalph Campbell u32 n_loop_pkts; 717f931551bSRalph Campbell u32 n_pkt_drops; 718f931551bSRalph Campbell u32 n_vl15_dropped; 719f931551bSRalph Campbell u32 n_rc_timeouts; 720f931551bSRalph Campbell u32 n_dmawait; 721f931551bSRalph Campbell u32 n_unaligned; 722f931551bSRalph Campbell u32 n_rc_dupreq; 723f931551bSRalph Campbell u32 n_rc_seqnak; 724f931551bSRalph Campbell u32 port_cap_flags; 725f931551bSRalph Campbell u32 pma_sample_start; 726f931551bSRalph Campbell u32 pma_sample_interval; 727f931551bSRalph Campbell __be16 pma_counter_select[5]; 728f931551bSRalph Campbell u16 pma_tag; 729f931551bSRalph Campbell u16 pkey_violations; 730f931551bSRalph Campbell u16 qkey_violations; 731f931551bSRalph Campbell u16 mkey_violations; 732f931551bSRalph Campbell u16 mkey_lease_period; 733f931551bSRalph Campbell u16 sm_lid; 734f931551bSRalph Campbell u16 repress_traps; 735f931551bSRalph Campbell u8 sm_sl; 736f931551bSRalph Campbell u8 mkeyprot; 737f931551bSRalph Campbell u8 subnet_timeout; 738f931551bSRalph Campbell u8 vl_high_limit; 739f931551bSRalph Campbell u8 sl_to_vl[16]; 740f931551bSRalph Campbell 741f931551bSRalph Campbell }; 742f931551bSRalph Campbell 743551ace12SMike Marciniszyn 744f931551bSRalph Campbell struct qib_ibdev { 745f931551bSRalph Campbell struct ib_device ibdev; 746f931551bSRalph Campbell struct list_head pending_mmaps; 747f931551bSRalph Campbell spinlock_t mmap_offset_lock; /* protect mmap_offset */ 748f931551bSRalph Campbell u32 mmap_offset; 7497e230177SMike Marciniszyn struct qib_mregion __rcu *dma_mr; 750f931551bSRalph Campbell 751f931551bSRalph Campbell /* QP numbers are shared by all IB ports */ 752f931551bSRalph Campbell struct qib_qpn_table qpn_table; 753f931551bSRalph Campbell struct qib_lkey_table lk_table; 754f931551bSRalph Campbell struct list_head piowait; /* list for wait PIO buf */ 755f931551bSRalph Campbell struct list_head dmawait; /* list for wait DMA */ 756f931551bSRalph Campbell struct list_head txwait; /* list for wait qib_verbs_txreq */ 757f931551bSRalph Campbell struct list_head memwait; /* list for wait kernel memory */ 758f931551bSRalph Campbell struct list_head txreq_free; 759f931551bSRalph Campbell struct timer_list mem_timer; 7601fb9fed6SMike Marciniszyn struct qib_qp __rcu **qp_table; 761f931551bSRalph Campbell struct qib_pio_header *pio_hdrs; 762f931551bSRalph Campbell dma_addr_t pio_hdrs_phys; 763f931551bSRalph Campbell /* list of QPs waiting for RNR timer */ 764f931551bSRalph Campbell spinlock_t pending_lock; /* protect wait lists, PMA counters, etc. */ 765af061a64SMike Marciniszyn u32 qp_table_size; /* size of the hash table */ 766af061a64SMike Marciniszyn u32 qp_rnd; /* random bytes for hash */ 767f931551bSRalph Campbell spinlock_t qpt_lock; 768f931551bSRalph Campbell 769f931551bSRalph Campbell u32 n_piowait; 770f931551bSRalph Campbell u32 n_txwait; 771f931551bSRalph Campbell 772f931551bSRalph Campbell u32 n_pds_allocated; /* number of PDs allocated for device */ 773f931551bSRalph Campbell spinlock_t n_pds_lock; 774f931551bSRalph Campbell u32 n_ahs_allocated; /* number of AHs allocated for device */ 775f931551bSRalph Campbell spinlock_t n_ahs_lock; 776f931551bSRalph Campbell u32 n_cqs_allocated; /* number of CQs allocated for device */ 777f931551bSRalph Campbell spinlock_t n_cqs_lock; 778f931551bSRalph Campbell u32 n_qps_allocated; /* number of QPs allocated for device */ 779f931551bSRalph Campbell spinlock_t n_qps_lock; 780f931551bSRalph Campbell u32 n_srqs_allocated; /* number of SRQs allocated for device */ 781f931551bSRalph Campbell spinlock_t n_srqs_lock; 782f931551bSRalph Campbell u32 n_mcast_grps_allocated; /* number of mcast groups allocated */ 783f931551bSRalph Campbell spinlock_t n_mcast_grps_lock; 784ddb88765SMike Marciniszyn #ifdef CONFIG_DEBUG_FS 785ddb88765SMike Marciniszyn /* per HCA debugfs */ 786ddb88765SMike Marciniszyn struct dentry *qib_ibdev_dbg; 787ddb88765SMike Marciniszyn #endif 788f931551bSRalph Campbell }; 789f931551bSRalph Campbell 790f931551bSRalph Campbell struct qib_verbs_counters { 791f931551bSRalph Campbell u64 symbol_error_counter; 792f931551bSRalph Campbell u64 link_error_recovery_counter; 793f931551bSRalph Campbell u64 link_downed_counter; 794f931551bSRalph Campbell u64 port_rcv_errors; 795f931551bSRalph Campbell u64 port_rcv_remphys_errors; 796f931551bSRalph Campbell u64 port_xmit_discards; 797f931551bSRalph Campbell u64 port_xmit_data; 798f931551bSRalph Campbell u64 port_rcv_data; 799f931551bSRalph Campbell u64 port_xmit_packets; 800f931551bSRalph Campbell u64 port_rcv_packets; 801f931551bSRalph Campbell u32 local_link_integrity_errors; 802f931551bSRalph Campbell u32 excessive_buffer_overrun_errors; 803f931551bSRalph Campbell u32 vl15_dropped; 804f931551bSRalph Campbell }; 805f931551bSRalph Campbell 806f931551bSRalph Campbell static inline struct qib_mr *to_imr(struct ib_mr *ibmr) 807f931551bSRalph Campbell { 808f931551bSRalph Campbell return container_of(ibmr, struct qib_mr, ibmr); 809f931551bSRalph Campbell } 810f931551bSRalph Campbell 811f931551bSRalph Campbell static inline struct qib_pd *to_ipd(struct ib_pd *ibpd) 812f931551bSRalph Campbell { 813f931551bSRalph Campbell return container_of(ibpd, struct qib_pd, ibpd); 814f931551bSRalph Campbell } 815f931551bSRalph Campbell 816f931551bSRalph Campbell static inline struct qib_ah *to_iah(struct ib_ah *ibah) 817f931551bSRalph Campbell { 818f931551bSRalph Campbell return container_of(ibah, struct qib_ah, ibah); 819f931551bSRalph Campbell } 820f931551bSRalph Campbell 821f931551bSRalph Campbell static inline struct qib_cq *to_icq(struct ib_cq *ibcq) 822f931551bSRalph Campbell { 823f931551bSRalph Campbell return container_of(ibcq, struct qib_cq, ibcq); 824f931551bSRalph Campbell } 825f931551bSRalph Campbell 826f931551bSRalph Campbell static inline struct qib_srq *to_isrq(struct ib_srq *ibsrq) 827f931551bSRalph Campbell { 828f931551bSRalph Campbell return container_of(ibsrq, struct qib_srq, ibsrq); 829f931551bSRalph Campbell } 830f931551bSRalph Campbell 831f931551bSRalph Campbell static inline struct qib_qp *to_iqp(struct ib_qp *ibqp) 832f931551bSRalph Campbell { 833f931551bSRalph Campbell return container_of(ibqp, struct qib_qp, ibqp); 834f931551bSRalph Campbell } 835f931551bSRalph Campbell 836f931551bSRalph Campbell static inline struct qib_ibdev *to_idev(struct ib_device *ibdev) 837f931551bSRalph Campbell { 838f931551bSRalph Campbell return container_of(ibdev, struct qib_ibdev, ibdev); 839f931551bSRalph Campbell } 840f931551bSRalph Campbell 841f931551bSRalph Campbell /* 842f931551bSRalph Campbell * Send if not busy or waiting for I/O and either 843f931551bSRalph Campbell * a RC response is pending or we can process send work requests. 844f931551bSRalph Campbell */ 845f931551bSRalph Campbell static inline int qib_send_ok(struct qib_qp *qp) 846f931551bSRalph Campbell { 847f931551bSRalph Campbell return !(qp->s_flags & (QIB_S_BUSY | QIB_S_ANY_WAIT_IO)) && 848f931551bSRalph Campbell (qp->s_hdrwords || (qp->s_flags & QIB_S_RESP_PENDING) || 849f931551bSRalph Campbell !(qp->s_flags & QIB_S_ANY_WAIT_SEND)); 850f931551bSRalph Campbell } 851f931551bSRalph Campbell 852f931551bSRalph Campbell /* 853f931551bSRalph Campbell * This must be called with s_lock held. 854f931551bSRalph Campbell */ 855551ace12SMike Marciniszyn void qib_schedule_send(struct qib_qp *qp); 856f931551bSRalph Campbell 857f931551bSRalph Campbell static inline int qib_pkey_ok(u16 pkey1, u16 pkey2) 858f931551bSRalph Campbell { 859f931551bSRalph Campbell u16 p1 = pkey1 & 0x7FFF; 860f931551bSRalph Campbell u16 p2 = pkey2 & 0x7FFF; 861f931551bSRalph Campbell 862f931551bSRalph Campbell /* 863f931551bSRalph Campbell * Low 15 bits must be non-zero and match, and 864f931551bSRalph Campbell * one of the two must be a full member. 865f931551bSRalph Campbell */ 866f931551bSRalph Campbell return p1 && p1 == p2 && ((__s16)pkey1 < 0 || (__s16)pkey2 < 0); 867f931551bSRalph Campbell } 868f931551bSRalph Campbell 869f931551bSRalph Campbell void qib_bad_pqkey(struct qib_ibport *ibp, __be16 trap_num, u32 key, u32 sl, 870f931551bSRalph Campbell u32 qp1, u32 qp2, __be16 lid1, __be16 lid2); 871f931551bSRalph Campbell void qib_cap_mask_chg(struct qib_ibport *ibp); 872f931551bSRalph Campbell void qib_sys_guid_chg(struct qib_ibport *ibp); 873f931551bSRalph Campbell void qib_node_desc_chg(struct qib_ibport *ibp); 874f931551bSRalph Campbell int qib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num, 875a97e2d86SIra Weiny const struct ib_wc *in_wc, const struct ib_grh *in_grh, 8764cd7c947SIra Weiny const struct ib_mad_hdr *in, size_t in_mad_size, 8774cd7c947SIra Weiny struct ib_mad_hdr *out, size_t *out_mad_size, 8784cd7c947SIra Weiny u16 *out_mad_pkey_index); 879f931551bSRalph Campbell int qib_create_agents(struct qib_ibdev *dev); 880f931551bSRalph Campbell void qib_free_agents(struct qib_ibdev *dev); 881f931551bSRalph Campbell 882f931551bSRalph Campbell /* 883f931551bSRalph Campbell * Compare the lower 24 bits of the two values. 884f931551bSRalph Campbell * Returns an integer <, ==, or > than zero. 885f931551bSRalph Campbell */ 886f931551bSRalph Campbell static inline int qib_cmp24(u32 a, u32 b) 887f931551bSRalph Campbell { 888f931551bSRalph Campbell return (((int) a) - ((int) b)) << 8; 889f931551bSRalph Campbell } 890f931551bSRalph Campbell 891f931551bSRalph Campbell struct qib_mcast *qib_mcast_find(struct qib_ibport *ibp, union ib_gid *mgid); 892f931551bSRalph Campbell 893f931551bSRalph Campbell int qib_snapshot_counters(struct qib_pportdata *ppd, u64 *swords, 894f931551bSRalph Campbell u64 *rwords, u64 *spkts, u64 *rpkts, 895f931551bSRalph Campbell u64 *xmit_wait); 896f931551bSRalph Campbell 897f931551bSRalph Campbell int qib_get_counters(struct qib_pportdata *ppd, 898f931551bSRalph Campbell struct qib_verbs_counters *cntrs); 899f931551bSRalph Campbell 900f931551bSRalph Campbell int qib_multicast_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); 901f931551bSRalph Campbell 902f931551bSRalph Campbell int qib_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid); 903f931551bSRalph Campbell 904f931551bSRalph Campbell int qib_mcast_tree_empty(struct qib_ibport *ibp); 905f931551bSRalph Campbell 906f931551bSRalph Campbell __be32 qib_compute_aeth(struct qib_qp *qp); 907f931551bSRalph Campbell 908f931551bSRalph Campbell struct qib_qp *qib_lookup_qpn(struct qib_ibport *ibp, u32 qpn); 909f931551bSRalph Campbell 910f931551bSRalph Campbell struct ib_qp *qib_create_qp(struct ib_pd *ibpd, 911f931551bSRalph Campbell struct ib_qp_init_attr *init_attr, 912f931551bSRalph Campbell struct ib_udata *udata); 913f931551bSRalph Campbell 914f931551bSRalph Campbell int qib_destroy_qp(struct ib_qp *ibqp); 915f931551bSRalph Campbell 916f931551bSRalph Campbell int qib_error_qp(struct qib_qp *qp, enum ib_wc_status err); 917f931551bSRalph Campbell 918f931551bSRalph Campbell int qib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 919f931551bSRalph Campbell int attr_mask, struct ib_udata *udata); 920f931551bSRalph Campbell 921f931551bSRalph Campbell int qib_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 922f931551bSRalph Campbell int attr_mask, struct ib_qp_init_attr *init_attr); 923f931551bSRalph Campbell 924f931551bSRalph Campbell unsigned qib_free_all_qps(struct qib_devdata *dd); 925f931551bSRalph Campbell 926f931551bSRalph Campbell void qib_init_qpn_table(struct qib_devdata *dd, struct qib_qpn_table *qpt); 927f931551bSRalph Campbell 928f931551bSRalph Campbell void qib_free_qpn_table(struct qib_qpn_table *qpt); 929f931551bSRalph Campbell 9301dd173b0SMike Marciniszyn #ifdef CONFIG_DEBUG_FS 9311dd173b0SMike Marciniszyn 9321dd173b0SMike Marciniszyn struct qib_qp_iter; 9331dd173b0SMike Marciniszyn 9341dd173b0SMike Marciniszyn struct qib_qp_iter *qib_qp_iter_init(struct qib_ibdev *dev); 9351dd173b0SMike Marciniszyn 9361dd173b0SMike Marciniszyn int qib_qp_iter_next(struct qib_qp_iter *iter); 9371dd173b0SMike Marciniszyn 9381dd173b0SMike Marciniszyn void qib_qp_iter_print(struct seq_file *s, struct qib_qp_iter *iter); 9391dd173b0SMike Marciniszyn 9401dd173b0SMike Marciniszyn #endif 9411dd173b0SMike Marciniszyn 942f931551bSRalph Campbell void qib_get_credit(struct qib_qp *qp, u32 aeth); 943f931551bSRalph Campbell 944f931551bSRalph Campbell unsigned qib_pkt_delay(u32 plen, u8 snd_mult, u8 rcv_mult); 945f931551bSRalph Campbell 946f931551bSRalph Campbell void qib_verbs_sdma_desc_avail(struct qib_pportdata *ppd, unsigned avail); 947f931551bSRalph Campbell 948f931551bSRalph Campbell void qib_put_txreq(struct qib_verbs_txreq *tx); 949f931551bSRalph Campbell 950f931551bSRalph Campbell int qib_verbs_send(struct qib_qp *qp, struct qib_ib_header *hdr, 951f931551bSRalph Campbell u32 hdrwords, struct qib_sge_state *ss, u32 len); 952f931551bSRalph Campbell 953f931551bSRalph Campbell void qib_copy_sge(struct qib_sge_state *ss, void *data, u32 length, 954f931551bSRalph Campbell int release); 955f931551bSRalph Campbell 956f931551bSRalph Campbell void qib_skip_sge(struct qib_sge_state *ss, u32 length, int release); 957f931551bSRalph Campbell 958f931551bSRalph Campbell void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr, 959f931551bSRalph Campbell int has_grh, void *data, u32 tlen, struct qib_qp *qp); 960f931551bSRalph Campbell 961f931551bSRalph Campbell void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr, 962f931551bSRalph Campbell int has_grh, void *data, u32 tlen, struct qib_qp *qp); 963f931551bSRalph Campbell 964f931551bSRalph Campbell int qib_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr); 965f931551bSRalph Campbell 9661fb9fed6SMike Marciniszyn struct ib_ah *qib_create_qp0_ah(struct qib_ibport *ibp, u16 dlid); 9671fb9fed6SMike Marciniszyn 968f931551bSRalph Campbell void qib_rc_rnr_retry(unsigned long arg); 969f931551bSRalph Campbell 970f931551bSRalph Campbell void qib_rc_send_complete(struct qib_qp *qp, struct qib_ib_header *hdr); 971f931551bSRalph Campbell 972f931551bSRalph Campbell void qib_rc_error(struct qib_qp *qp, enum ib_wc_status err); 973f931551bSRalph Campbell 974f931551bSRalph Campbell int qib_post_ud_send(struct qib_qp *qp, struct ib_send_wr *wr); 975f931551bSRalph Campbell 976f931551bSRalph Campbell void qib_ud_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr, 977f931551bSRalph Campbell int has_grh, void *data, u32 tlen, struct qib_qp *qp); 978f931551bSRalph Campbell 9796a82649fSMike Marciniszyn int qib_alloc_lkey(struct qib_mregion *mr, int dma_region); 980f931551bSRalph Campbell 9816a82649fSMike Marciniszyn void qib_free_lkey(struct qib_mregion *mr); 982f931551bSRalph Campbell 983f931551bSRalph Campbell int qib_lkey_ok(struct qib_lkey_table *rkt, struct qib_pd *pd, 984f931551bSRalph Campbell struct qib_sge *isge, struct ib_sge *sge, int acc); 985f931551bSRalph Campbell 986f931551bSRalph Campbell int qib_rkey_ok(struct qib_qp *qp, struct qib_sge *sge, 987f931551bSRalph Campbell u32 len, u64 vaddr, u32 rkey, int acc); 988f931551bSRalph Campbell 989f931551bSRalph Campbell int qib_post_srq_receive(struct ib_srq *ibsrq, struct ib_recv_wr *wr, 990f931551bSRalph Campbell struct ib_recv_wr **bad_wr); 991f931551bSRalph Campbell 992f931551bSRalph Campbell struct ib_srq *qib_create_srq(struct ib_pd *ibpd, 993f931551bSRalph Campbell struct ib_srq_init_attr *srq_init_attr, 994f931551bSRalph Campbell struct ib_udata *udata); 995f931551bSRalph Campbell 996f931551bSRalph Campbell int qib_modify_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr, 997f931551bSRalph Campbell enum ib_srq_attr_mask attr_mask, 998f931551bSRalph Campbell struct ib_udata *udata); 999f931551bSRalph Campbell 1000f931551bSRalph Campbell int qib_query_srq(struct ib_srq *ibsrq, struct ib_srq_attr *attr); 1001f931551bSRalph Campbell 1002f931551bSRalph Campbell int qib_destroy_srq(struct ib_srq *ibsrq); 1003f931551bSRalph Campbell 100485caafe3SMike Marciniszyn int qib_cq_init(struct qib_devdata *dd); 100585caafe3SMike Marciniszyn 100685caafe3SMike Marciniszyn void qib_cq_exit(struct qib_devdata *dd); 100785caafe3SMike Marciniszyn 1008f931551bSRalph Campbell void qib_cq_enter(struct qib_cq *cq, struct ib_wc *entry, int sig); 1009f931551bSRalph Campbell 1010f931551bSRalph Campbell int qib_poll_cq(struct ib_cq *ibcq, int num_entries, struct ib_wc *entry); 1011f931551bSRalph Campbell 1012bcf4c1eaSMatan Barak struct ib_cq *qib_create_cq(struct ib_device *ibdev, 1013bcf4c1eaSMatan Barak const struct ib_cq_init_attr *attr, 1014bcf4c1eaSMatan Barak struct ib_ucontext *context, 1015f931551bSRalph Campbell struct ib_udata *udata); 1016f931551bSRalph Campbell 1017f931551bSRalph Campbell int qib_destroy_cq(struct ib_cq *ibcq); 1018f931551bSRalph Campbell 1019f931551bSRalph Campbell int qib_req_notify_cq(struct ib_cq *ibcq, enum ib_cq_notify_flags notify_flags); 1020f931551bSRalph Campbell 1021f931551bSRalph Campbell int qib_resize_cq(struct ib_cq *ibcq, int cqe, struct ib_udata *udata); 1022f931551bSRalph Campbell 1023f931551bSRalph Campbell struct ib_mr *qib_get_dma_mr(struct ib_pd *pd, int acc); 1024f931551bSRalph Campbell 1025f931551bSRalph Campbell struct ib_mr *qib_reg_phys_mr(struct ib_pd *pd, 1026f931551bSRalph Campbell struct ib_phys_buf *buffer_list, 1027f931551bSRalph Campbell int num_phys_buf, int acc, u64 *iova_start); 1028f931551bSRalph Campbell 1029f931551bSRalph Campbell struct ib_mr *qib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, 1030f931551bSRalph Campbell u64 virt_addr, int mr_access_flags, 1031f931551bSRalph Campbell struct ib_udata *udata); 1032f931551bSRalph Campbell 1033f931551bSRalph Campbell int qib_dereg_mr(struct ib_mr *ibmr); 1034f931551bSRalph Campbell 1035f931551bSRalph Campbell struct ib_mr *qib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len); 1036f931551bSRalph Campbell 1037f931551bSRalph Campbell struct ib_fast_reg_page_list *qib_alloc_fast_reg_page_list( 1038f931551bSRalph Campbell struct ib_device *ibdev, int page_list_len); 1039f931551bSRalph Campbell 1040f931551bSRalph Campbell void qib_free_fast_reg_page_list(struct ib_fast_reg_page_list *pl); 1041f931551bSRalph Campbell 1042f931551bSRalph Campbell int qib_fast_reg_mr(struct qib_qp *qp, struct ib_send_wr *wr); 1043f931551bSRalph Campbell 1044f931551bSRalph Campbell struct ib_fmr *qib_alloc_fmr(struct ib_pd *pd, int mr_access_flags, 1045f931551bSRalph Campbell struct ib_fmr_attr *fmr_attr); 1046f931551bSRalph Campbell 1047f931551bSRalph Campbell int qib_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, 1048f931551bSRalph Campbell int list_len, u64 iova); 1049f931551bSRalph Campbell 1050f931551bSRalph Campbell int qib_unmap_fmr(struct list_head *fmr_list); 1051f931551bSRalph Campbell 1052f931551bSRalph Campbell int qib_dealloc_fmr(struct ib_fmr *ibfmr); 1053f931551bSRalph Campbell 10546a82649fSMike Marciniszyn static inline void qib_get_mr(struct qib_mregion *mr) 10556a82649fSMike Marciniszyn { 10566a82649fSMike Marciniszyn atomic_inc(&mr->refcount); 10576a82649fSMike Marciniszyn } 10586a82649fSMike Marciniszyn 10598aac4cc3SMike Marciniszyn void mr_rcu_callback(struct rcu_head *list); 10608aac4cc3SMike Marciniszyn 10616a82649fSMike Marciniszyn static inline void qib_put_mr(struct qib_mregion *mr) 10626a82649fSMike Marciniszyn { 10636a82649fSMike Marciniszyn if (unlikely(atomic_dec_and_test(&mr->refcount))) 10648aac4cc3SMike Marciniszyn call_rcu(&mr->list, mr_rcu_callback); 10656a82649fSMike Marciniszyn } 10666a82649fSMike Marciniszyn 10676a82649fSMike Marciniszyn static inline void qib_put_ss(struct qib_sge_state *ss) 10686a82649fSMike Marciniszyn { 10696a82649fSMike Marciniszyn while (ss->num_sge) { 10706a82649fSMike Marciniszyn qib_put_mr(ss->sge.mr); 10716a82649fSMike Marciniszyn if (--ss->num_sge) 10726a82649fSMike Marciniszyn ss->sge = *ss->sg_list++; 10736a82649fSMike Marciniszyn } 10746a82649fSMike Marciniszyn } 10756a82649fSMike Marciniszyn 10766a82649fSMike Marciniszyn 1077f931551bSRalph Campbell void qib_release_mmap_info(struct kref *ref); 1078f931551bSRalph Campbell 1079f931551bSRalph Campbell struct qib_mmap_info *qib_create_mmap_info(struct qib_ibdev *dev, u32 size, 1080f931551bSRalph Campbell struct ib_ucontext *context, 1081f931551bSRalph Campbell void *obj); 1082f931551bSRalph Campbell 1083f931551bSRalph Campbell void qib_update_mmap_info(struct qib_ibdev *dev, struct qib_mmap_info *ip, 1084f931551bSRalph Campbell u32 size, void *obj); 1085f931551bSRalph Campbell 1086f931551bSRalph Campbell int qib_mmap(struct ib_ucontext *context, struct vm_area_struct *vma); 1087f931551bSRalph Campbell 1088f931551bSRalph Campbell int qib_get_rwqe(struct qib_qp *qp, int wr_id_only); 1089f931551bSRalph Campbell 1090f931551bSRalph Campbell void qib_migrate_qp(struct qib_qp *qp); 1091f931551bSRalph Campbell 1092f931551bSRalph Campbell int qib_ruc_check_hdr(struct qib_ibport *ibp, struct qib_ib_header *hdr, 1093f931551bSRalph Campbell int has_grh, struct qib_qp *qp, u32 bth0); 1094f931551bSRalph Campbell 1095f931551bSRalph Campbell u32 qib_make_grh(struct qib_ibport *ibp, struct ib_grh *hdr, 1096f931551bSRalph Campbell struct ib_global_route *grh, u32 hwords, u32 nwords); 1097f931551bSRalph Campbell 1098f931551bSRalph Campbell void qib_make_ruc_header(struct qib_qp *qp, struct qib_other_headers *ohdr, 1099f931551bSRalph Campbell u32 bth0, u32 bth2); 1100f931551bSRalph Campbell 1101f931551bSRalph Campbell void qib_do_send(struct work_struct *work); 1102f931551bSRalph Campbell 1103f931551bSRalph Campbell void qib_send_complete(struct qib_qp *qp, struct qib_swqe *wqe, 1104f931551bSRalph Campbell enum ib_wc_status status); 1105f931551bSRalph Campbell 1106f931551bSRalph Campbell void qib_send_rc_ack(struct qib_qp *qp); 1107f931551bSRalph Campbell 1108f931551bSRalph Campbell int qib_make_rc_req(struct qib_qp *qp); 1109f931551bSRalph Campbell 1110f931551bSRalph Campbell int qib_make_uc_req(struct qib_qp *qp); 1111f931551bSRalph Campbell 1112f931551bSRalph Campbell int qib_make_ud_req(struct qib_qp *qp); 1113f931551bSRalph Campbell 1114f931551bSRalph Campbell int qib_register_ib_device(struct qib_devdata *); 1115f931551bSRalph Campbell 1116f931551bSRalph Campbell void qib_unregister_ib_device(struct qib_devdata *); 1117f931551bSRalph Campbell 1118f931551bSRalph Campbell void qib_ib_rcv(struct qib_ctxtdata *, void *, void *, u32); 1119f931551bSRalph Campbell 1120f931551bSRalph Campbell void qib_ib_piobufavail(struct qib_devdata *); 1121f931551bSRalph Campbell 1122f931551bSRalph Campbell unsigned qib_get_npkeys(struct qib_devdata *); 1123f931551bSRalph Campbell 1124f931551bSRalph Campbell unsigned qib_get_pkey(struct qib_ibport *, unsigned); 1125f931551bSRalph Campbell 1126f931551bSRalph Campbell extern const enum ib_wc_opcode ib_qib_wc_opcode[]; 1127f931551bSRalph Campbell 1128f931551bSRalph Campbell /* 1129f931551bSRalph Campbell * Below HCA-independent IB PhysPortState values, returned 1130f931551bSRalph Campbell * by the f_ibphys_portstate() routine. 1131f931551bSRalph Campbell */ 1132f931551bSRalph Campbell #define IB_PHYSPORTSTATE_SLEEP 1 1133f931551bSRalph Campbell #define IB_PHYSPORTSTATE_POLL 2 1134f931551bSRalph Campbell #define IB_PHYSPORTSTATE_DISABLED 3 1135f931551bSRalph Campbell #define IB_PHYSPORTSTATE_CFG_TRAIN 4 1136f931551bSRalph Campbell #define IB_PHYSPORTSTATE_LINKUP 5 1137f931551bSRalph Campbell #define IB_PHYSPORTSTATE_LINK_ERR_RECOVER 6 1138f931551bSRalph Campbell #define IB_PHYSPORTSTATE_CFG_DEBOUNCE 8 1139f931551bSRalph Campbell #define IB_PHYSPORTSTATE_CFG_IDLE 0xB 1140f931551bSRalph Campbell #define IB_PHYSPORTSTATE_RECOVERY_RETRAIN 0xC 1141f931551bSRalph Campbell #define IB_PHYSPORTSTATE_RECOVERY_WAITRMT 0xE 1142f931551bSRalph Campbell #define IB_PHYSPORTSTATE_RECOVERY_IDLE 0xF 1143f931551bSRalph Campbell #define IB_PHYSPORTSTATE_CFG_ENH 0x10 1144f931551bSRalph Campbell #define IB_PHYSPORTSTATE_CFG_WAIT_ENH 0x13 1145f931551bSRalph Campbell 1146f931551bSRalph Campbell extern const int ib_qib_state_ops[]; 1147f931551bSRalph Campbell 1148f931551bSRalph Campbell extern __be64 ib_qib_sys_image_guid; /* in network order */ 1149f931551bSRalph Campbell 1150f931551bSRalph Campbell extern unsigned int ib_qib_lkey_table_size; 1151f931551bSRalph Campbell 1152f931551bSRalph Campbell extern unsigned int ib_qib_max_cqes; 1153f931551bSRalph Campbell 1154f931551bSRalph Campbell extern unsigned int ib_qib_max_cqs; 1155f931551bSRalph Campbell 1156f931551bSRalph Campbell extern unsigned int ib_qib_max_qp_wrs; 1157f931551bSRalph Campbell 1158f931551bSRalph Campbell extern unsigned int ib_qib_max_qps; 1159f931551bSRalph Campbell 1160f931551bSRalph Campbell extern unsigned int ib_qib_max_sges; 1161f931551bSRalph Campbell 1162f931551bSRalph Campbell extern unsigned int ib_qib_max_mcast_grps; 1163f931551bSRalph Campbell 1164f931551bSRalph Campbell extern unsigned int ib_qib_max_mcast_qp_attached; 1165f931551bSRalph Campbell 1166f931551bSRalph Campbell extern unsigned int ib_qib_max_srqs; 1167f931551bSRalph Campbell 1168f931551bSRalph Campbell extern unsigned int ib_qib_max_srq_sges; 1169f931551bSRalph Campbell 1170f931551bSRalph Campbell extern unsigned int ib_qib_max_srq_wrs; 1171f931551bSRalph Campbell 1172f931551bSRalph Campbell extern const u32 ib_qib_rnr_table[]; 1173f931551bSRalph Campbell 1174f931551bSRalph Campbell extern struct ib_dma_mapping_ops qib_dma_mapping_ops; 1175f931551bSRalph Campbell 1176f931551bSRalph Campbell #endif /* QIB_VERBS_H */ 1177