ipath_verbs.h
来自「linux 内核源代码」· C头文件 代码 · 共 864 行 · 第 1/2 页
H
864 行
/* * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */#ifndef IPATH_VERBS_H#define IPATH_VERBS_H#include <linux/types.h>#include <linux/spinlock.h>#include <linux/kernel.h>#include <linux/interrupt.h>#include <linux/kref.h>#include <rdma/ib_pack.h>#include <rdma/ib_user_verbs.h>#include "ipath_kernel.h"#define IPATH_MAX_RDMA_ATOMIC 4#define QPN_MAX (1 << 24)#define QPNMAP_ENTRIES (QPN_MAX / PAGE_SIZE / BITS_PER_BYTE)/* * Increment this value if any changes that break userspace ABI * compatibility are made. */#define IPATH_UVERBS_ABI_VERSION 2/* * Define an ib_cq_notify value that is not valid so we know when CQ * notifications are armed. */#define IB_CQ_NONE (IB_CQ_NEXT_COMP + 1)/* AETH NAK opcode values */#define IB_RNR_NAK 0x20#define IB_NAK_PSN_ERROR 0x60#define IB_NAK_INVALID_REQUEST 0x61#define IB_NAK_REMOTE_ACCESS_ERROR 0x62#define IB_NAK_REMOTE_OPERATIONAL_ERROR 0x63#define IB_NAK_INVALID_RD_REQUEST 0x64/* Flags for checking QP state (see ib_ipath_state_ops[]) */#define IPATH_POST_SEND_OK 0x01#define IPATH_POST_RECV_OK 0x02#define IPATH_PROCESS_RECV_OK 0x04#define IPATH_PROCESS_SEND_OK 0x08/* IB Performance Manager status values */#define IB_PMA_SAMPLE_STATUS_DONE 0x00#define IB_PMA_SAMPLE_STATUS_STARTED 0x01#define IB_PMA_SAMPLE_STATUS_RUNNING 0x02/* Mandatory IB performance counter select values. */#define IB_PMA_PORT_XMIT_DATA __constant_htons(0x0001)#define IB_PMA_PORT_RCV_DATA __constant_htons(0x0002)#define IB_PMA_PORT_XMIT_PKTS __constant_htons(0x0003)#define IB_PMA_PORT_RCV_PKTS __constant_htons(0x0004)#define IB_PMA_PORT_XMIT_WAIT __constant_htons(0x0005)struct ib_reth { __be64 vaddr; __be32 rkey; __be32 length;} __attribute__ ((packed));struct ib_atomic_eth { __be32 vaddr[2]; /* unaligned so access as 2 32-bit words */ __be32 rkey; __be64 swap_data; __be64 compare_data;} __attribute__ ((packed));struct ipath_other_headers { __be32 bth[3]; union { struct { __be32 deth[2]; __be32 imm_data; } ud; struct { struct ib_reth reth; __be32 imm_data; } rc; struct { __be32 aeth; __be32 atomic_ack_eth[2]; } at; __be32 imm_data; __be32 aeth; struct ib_atomic_eth atomic_eth; } u;} __attribute__ ((packed));/* * Note that UD packets with a GRH header are 8+40+12+8 = 68 bytes * long (72 w/ imm_data). Only the first 56 bytes of the IB header * will be in the eager header buffer. The remaining 12 or 16 bytes * are in the data buffer. */struct ipath_ib_header { __be16 lrh[4]; union { struct { struct ib_grh grh; struct ipath_other_headers oth; } l; struct ipath_other_headers oth; } u;} __attribute__ ((packed));/* * There is one struct ipath_mcast for each multicast GID. * All attached QPs are then stored as a list of * struct ipath_mcast_qp. */struct ipath_mcast_qp { struct list_head list; struct ipath_qp *qp;};struct ipath_mcast { struct rb_node rb_node; union ib_gid mgid; struct list_head qp_list; wait_queue_head_t wait; atomic_t refcount; int n_attached;};/* Protection domain */struct ipath_pd { struct ib_pd ibpd; int user; /* non-zero if created from user space */};/* Address Handle */struct ipath_ah { struct ib_ah ibah; struct ib_ah_attr attr;};/* * This structure is used by ipath_mmap() to validate an offset * when an mmap() request is made. The vm_area_struct then uses * this as its vm_private_data. */struct ipath_mmap_info { struct list_head pending_mmaps; struct ib_ucontext *context; void *obj; __u64 offset; struct kref ref; unsigned size;};/* * This structure is used to contain the head pointer, tail pointer, * and completion queue entries as a single memory allocation so * it can be mmap'ed into user space. */struct ipath_cq_wc { u32 head; /* index of next entry to fill */ u32 tail; /* index of next ib_poll_cq() entry */ union { /* these are actually size ibcq.cqe + 1 */ struct ib_uverbs_wc uqueue[0]; struct ib_wc kqueue[0]; };};/* * The completion queue structure. */struct ipath_cq { struct ib_cq ibcq; struct tasklet_struct comptask; spinlock_t lock; u8 notify; u8 triggered; struct ipath_cq_wc *queue; struct ipath_mmap_info *ip;};/* * A segment is a linear region of low physical memory. * XXX Maybe we should use phys addr here and kmap()/kunmap(). * Used by the verbs layer. */struct ipath_seg { void *vaddr; size_t length;};/* The number of ipath_segs that fit in a page. */#define IPATH_SEGSZ (PAGE_SIZE / sizeof (struct ipath_seg))struct ipath_segarray { struct ipath_seg segs[IPATH_SEGSZ];};struct ipath_mregion { struct ib_pd *pd; /* shares refcnt of ibmr.pd */ u64 user_base; /* User's address for this region */ u64 iova; /* IB start address of this region */ size_t length; u32 lkey; u32 offset; /* offset (bytes) to start of region */ int access_flags; u32 max_segs; /* number of ipath_segs in all the arrays */ u32 mapsz; /* size of the map array */ struct ipath_segarray *map[0]; /* the segments */};/* * These keep track of the copy progress within a memory region. * Used by the verbs layer. */struct ipath_sge { struct ipath_mregion *mr; void *vaddr; /* kernel virtual address of segment */ u32 sge_length; /* length of the SGE */ u32 length; /* remaining length of the segment */ u16 m; /* current index: mr->map[m] */ u16 n; /* current index: mr->map[m]->segs[n] */};/* Memory region */struct ipath_mr { struct ib_mr ibmr; struct ib_umem *umem; struct ipath_mregion mr; /* must be last */};/* * Send work request queue entry. * The size of the sg_list is determined when the QP is created and stored * in qp->s_max_sge. */struct ipath_swqe { struct ib_send_wr wr; /* don't use wr.sg_list */ u32 psn; /* first packet sequence number */ u32 lpsn; /* last packet sequence number */ u32 ssn; /* send sequence number */ u32 length; /* total length of data in sg_list */ struct ipath_sge sg_list[0];};/* * Receive work request queue entry. * The size of the sg_list is determined when the QP (or SRQ) is created * and stored in qp->r_rq.max_sge (or srq->rq.max_sge). */struct ipath_rwqe { u64 wr_id; u8 num_sge; struct ib_sge sg_list[0];};/* * This structure is used to contain the head pointer, tail pointer, * and receive work queue entries as a single memory allocation so * it can be mmap'ed into user space. * Note that the wq array elements are variable size so you can't * just index into the array to get the N'th element; * use get_rwqe_ptr() instead. */struct ipath_rwq { u32 head; /* new work requests posted to the head */ u32 tail; /* receives pull requests from here. */ struct ipath_rwqe wq[0];};struct ipath_rq { struct ipath_rwq *wq; spinlock_t lock; u32 size; /* size of RWQE array */ u8 max_sge;};struct ipath_srq { struct ib_srq ibsrq; struct ipath_rq rq; struct ipath_mmap_info *ip; /* send signal when number of RWQEs < limit */ u32 limit;};struct ipath_sge_state { struct ipath_sge *sg_list; /* next SGE to be used if any */ struct ipath_sge sge; /* progress state for the current SGE */ u8 num_sge;};/* * This structure holds the information that the send tasklet needs * to send a RDMA read response or atomic operation. */struct ipath_ack_entry { u8 opcode; u8 sent; u32 psn; union { struct ipath_sge_state rdma_sge; u64 atomic_data; };};/* * Variables prefixed with s_ are for the requester (sender). * Variables prefixed with r_ are for the responder (receiver). * Variables prefixed with ack_ are for responder replies. * * Common variables are protected by both r_rq.lock and s_lock in that order * which only happens in modify_qp() or changing the QP 'state'. */struct ipath_qp { struct ib_qp ibqp; struct ipath_qp *next; /* link list for QPN hash table */ struct ipath_qp *timer_next; /* link list for ipath_ib_timer() */ struct list_head piowait; /* link for wait PIO buf */ struct list_head timerwait; /* link for waiting for timeouts */ struct ib_ah_attr remote_ah_attr; struct ipath_ib_header s_hdr; /* next packet header to send */ atomic_t refcount; wait_queue_head_t wait; struct tasklet_struct s_task; struct ipath_mmap_info *ip; struct ipath_sge_state *s_cur_sge; struct ipath_sge_state s_sge; /* current send request data */ struct ipath_ack_entry s_ack_queue[IPATH_MAX_RDMA_ATOMIC + 1]; struct ipath_sge_state s_ack_rdma_sge; struct ipath_sge_state s_rdma_read_sge; struct ipath_sge_state r_sge; /* current receive data */ spinlock_t s_lock; unsigned long s_busy; u32 s_hdrwords; /* size of s_hdr in 32 bit words */ u32 s_cur_size; /* size of send packet in bytes */ u32 s_len; /* total length of s_sge */ u32 s_rdma_read_len; /* total length of s_rdma_read_sge */ u32 s_next_psn; /* PSN for next request */ u32 s_last_psn; /* last response PSN processed */ u32 s_psn; /* current packet sequence number */ u32 s_ack_rdma_psn; /* PSN for sending RDMA read responses */ u32 s_ack_psn; /* PSN for acking sends and RDMA writes */ u32 s_rnr_timeout; /* number of milliseconds for RNR timeout */ u32 r_ack_psn; /* PSN for next ACK or atomic ACK */ u64 r_wr_id; /* ID for current receive WQE */ u32 r_len; /* total length of r_sge */ u32 r_rcv_len; /* receive data len processed */ u32 r_psn; /* expected rcv packet sequence number */ u32 r_msn; /* message sequence number */ u8 state; /* QP state */ u8 s_state; /* opcode of last packet sent */ u8 s_ack_state; /* opcode of packet to ACK */ u8 s_nak_state; /* non-zero if NAK is pending */ u8 r_state; /* opcode of last packet received */ u8 r_nak_state; /* non-zero if NAK is pending */ u8 r_min_rnr_timer; /* retry timeout value for RNR NAKs */ u8 r_reuse_sge; /* for UC receive errors */ u8 r_sge_inx; /* current index into sg_list */ u8 r_wrid_valid; /* r_wrid set but CQ entry not yet made */ u8 r_max_rd_atomic; /* max number of RDMA read/atomic to receive */ u8 r_head_ack_queue; /* index into s_ack_queue[] */ u8 qp_access_flags; u8 s_max_sge; /* size of s_wq->sg_list */ u8 s_retry_cnt; /* number of times to retry */ u8 s_rnr_retry_cnt; u8 s_retry; /* requester retry counter */ u8 s_rnr_retry; /* requester RNR retry counter */ u8 s_wait_credit; /* limit number of unacked packets sent */ u8 s_pkey_index; /* PKEY index to use */ u8 s_max_rd_atomic; /* max number of RDMA read/atomic to send */ u8 s_num_rd_atomic; /* number of RDMA read/atomic pending */ u8 s_tail_ack_queue; /* index into s_ack_queue[] */ u8 s_flags; u8 timeout; /* Timeout for this QP */ enum ib_mtu path_mtu; u32 remote_qpn; u32 qkey; /* QKEY for this QP (for UD or RD) */ u32 s_size; /* send work queue size */ u32 s_head; /* new entries added here */ u32 s_tail; /* next entry to process */ u32 s_cur; /* current work queue entry */ u32 s_last; /* last un-ACK'ed entry */ u32 s_ssn; /* SSN of tail entry */ u32 s_lsn; /* limit sequence number (credit) */ struct ipath_swqe *s_wq; /* send work queue */ struct ipath_swqe *s_wqe; struct ipath_rq r_rq; /* receive work queue */ struct ipath_sge r_sg_list[0]; /* verified SGEs */};/* Bit definition for s_busy. */#define IPATH_S_BUSY 0/* * Bit definitions for s_flags. */#define IPATH_S_SIGNAL_REQ_WR 0x01#define IPATH_S_FENCE_PENDING 0x02#define IPATH_S_RDMAR_PENDING 0x04#define IPATH_S_ACK_PENDING 0x08
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?