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