#ifndef _C2_WR_H_
#define _C2_WR_H_
#ifdef CCDEBUG
#define CCWR_MAGIC 0xb07700b0
#endif
#define C2_QP_NO_ATTR_CHANGE 0xFFFFFFFF
/* Maximum allowed size in bytes of private_data exchange
* on connect.
*/
#define C2_MAX_PRIVATE_DATA_SIZE 200
/*
* These types are shared among the adapter, host, and CCIL consumer.
*/
enum c2_cq_notification_type {
C2_CQ_NOTIFICATION_TYPE_NONE = 1,
C2_CQ_NOTIFICATION_TYPE_NEXT,
C2_CQ_NOTIFICATION_TYPE_NEXT_SE
};
enum c2_setconfig_cmd {
C2_CFG_ADD_ADDR = 1,
C2_CFG_DEL_ADDR = 2,
C2_CFG_ADD_ROUTE = 3,
C2_CFG_DEL_ROUTE = 4
};
enum c2_getconfig_cmd {
C2_GETCONFIG_ROUTES = 1,
C2_GETCONFIG_ADDRS
};
/*
* CCIL Work Request Identifiers
*/
enum c2wr_ids {
CCWR_RNIC_OPEN = 1,
CCWR_RNIC_QUERY,
CCWR_RNIC_SETCONFIG,
CCWR_RNIC_GETCONFIG,
CCWR_RNIC_CLOSE,
CCWR_CQ_CREATE,
CCWR_CQ_QUERY,
CCWR_CQ_MODIFY,
CCWR_CQ_DESTROY,
CCWR_QP_CONNECT,
CCWR_PD_ALLOC,
CCWR_PD_DEALLOC,
CCWR_SRQ_CREATE,
CCWR_SRQ_QUERY,
CCWR_SRQ_MODIFY,
CCWR_SRQ_DESTROY,
CCWR_QP_CREATE,
CCWR_QP_QUERY,
CCWR_QP_MODIFY,
CCWR_QP_DESTROY,
CCWR_NSMR_STAG_ALLOC,
CCWR_NSMR_REGISTER,
CCWR_NSMR_PBL,
CCWR_STAG_DEALLOC,
CCWR_NSMR_REREGISTER,
CCWR_SMR_REGISTER,
CCWR_MR_QUERY,
CCWR_MW_ALLOC,
CCWR_MW_QUERY,
CCWR_EP_CREATE,
CCWR_EP_GETOPT,
CCWR_EP_SETOPT,
CCWR_EP_DESTROY,
CCWR_EP_BIND,
CCWR_EP_CONNECT,
CCWR_EP_LISTEN,
CCWR_EP_SHUTDOWN,
CCWR_EP_LISTEN_CREATE,
CCWR_EP_LISTEN_DESTROY,
CCWR_EP_QUERY,
CCWR_CR_ACCEPT,
CCWR_CR_REJECT,
CCWR_CONSOLE,
CCWR_TERM,
CCWR_FLASH_INIT,
CCWR_FLASH,
CCWR_BUF_ALLOC,
CCWR_BUF_FREE,
CCWR_FLASH_WRITE,
CCWR_INIT, /* WARNING: Don't move this ever again! */
/* Add new IDs here */
/*
* WARNING: CCWR_LAST must always be the last verbs id defined!
* All the preceding IDs are fixed, and must not change.
* You can add new IDs, but must not remove or reorder
* any IDs. If you do, YOU will ruin any hope of
* compatibility between versions.
*/
CCWR_LAST,
/*
* Start over at 1 so that arrays indexed by user wr id's
* begin at 1. This is OK since the verbs and user wr id's
* are always used on disjoint sets of queues.
*/
/*
* The order of the CCWR_SEND_XX verbs must
* match the order of the RDMA_OPs
*/
CCWR_SEND = 1,
CCWR_SEND_INV,
CCWR_SEND_SE,
CCWR_SEND_SE_INV,
CCWR_RDMA_WRITE,
CCWR_RDMA_READ,
CCWR_RDMA_READ_INV,
CCWR_MW_BIND,
CCWR_NSMR_FASTREG,
CCWR_STAG_INVALIDATE,
CCWR_RECV,
CCWR_NOP,
CCWR_UNIMPL,
/* WARNING: This must always be the last user wr id defined! */
};
#define RDMA_SEND_OPCODE_FROM_WR_ID(x) (x+2)
/*
* SQ/RQ Work Request Types
*/
enum c2_wr_type {
C2_WR_TYPE_SEND = CCWR_SEND,
C2_WR_TYPE_SEND_SE = CCWR_SEND_SE,
C2_WR_TYPE_SEND_INV = CCWR_SEND_INV,
C2_WR_TYPE_SEND_SE_INV = CCWR_SEND_SE_INV,
C2_WR_TYPE_RDMA_WRITE = CCWR_RDMA_WRITE,
C2_WR_TYPE_RDMA_READ = CCWR_RDMA_READ,
C2_WR_TYPE_RDMA_READ_INV_STAG = CCWR_RDMA_READ_INV,
C2_WR_TYPE_BIND_MW = CCWR_MW_BIND,
C2_WR_TYPE_FASTREG_NSMR = CCWR_NSMR_FASTREG,
C2_WR_TYPE_INV_STAG = CCWR_STAG_INVALIDATE,
C2_WR_TYPE_RECV = CCWR_RECV,
C2_WR_TYPE_NOP = CCWR_NOP,
};
struct c2_netaddr {
__be32 ip_addr;
__be32 netmask;
u32 mtu;
};
struct c2_route {
u32 ip_addr; /* 0 indicates the default route */
u32 netmask; /* netmask associated with dst */
u32 flags;
union {
u32 ipaddr; /* address of the nexthop interface */
u8 enaddr[6];
} nexthop;
};
/*
* A Scatter Gather Entry.
*/
struct c2_data_addr {
__be32 stag;
__be32 length;
__be64 to;
};
/*
* MR and MW flags used by the consumer, RI, and RNIC.
*/
enum c2_mm_flags {
MEM_REMOTE = 0x0001, /* allow mw binds with remote access. */
MEM_VA_BASED = 0x0002, /* Not Zero-based */
MEM_PBL_COMPLETE = 0x0004, /* PBL array is complete in this msg */
MEM_LOCAL_READ = 0x0008, /* allow local reads */
MEM_LOCAL_WRITE = 0x0010, /* allow local writes */
MEM_REMOTE_READ = 0x0020, /* allow remote reads */
MEM_REMOTE_WRITE = 0x0040, /* allow remote writes */
MEM_WINDOW_BIND = 0x0080, /* binds allowed */
MEM_SHARED = 0x0100, /* set if MR is shared */
MEM_STAG_VALID = 0x0200 /* set if STAG is in valid state */
};
/*
* CCIL API ACF flags defined in terms of the low level mem flags.
* This minimizes translation needed in the user API
*/
enum c2_acf {
C2_ACF_LOCAL_READ = MEM_LOCAL_READ,
C2_ACF_LOCAL_WRITE = MEM_LOCAL_WRITE,
C2_ACF_REMOTE_READ = MEM_REMOTE_READ,
C2_ACF_REMOTE_WRITE = MEM_REMOTE_WRITE,
C2_ACF_WINDOW_BIND = MEM_WINDOW_BIND
};
/*
* Image types of objects written to flash
*/
#define C2_FLASH_IMG_BITFILE 1
#define C2_FLASH_IMG_OPTION_ROM 2
#define C2_FLASH_IMG_VPD 3
/*
* to fix bug 1815 we define the max size allowable of the
* terminate message (per the IETF spec).Refer to the IETF
* protocol specification, section 12.1.6, page 64)
* The message is prefixed by 20 types of DDP info.
*
* Then the message has 6 bytes for the terminate control
* and DDP segment length info plus a DDP header (either
* 14 or 18 byts) plus 28 bytes for the RDMA header.
* Thus the max size in:
* 20 + (6 + 18 + 28) = 72
*/
#define C2_MAX_TERMINATE_MESSAGE_SIZE (72)
/*
* Build String Length. It must be the same as C2_BUILD_STR_LEN in ccil_api.h
*/
#define WR_BUILD_STR_LEN 64
/*
* WARNING: All of these structs need to align any 64bit types on
* 64 bit boundaries! 64bit types include u64 and u64.
*/
/*
* Clustercore Work Request Header. Be sensitive to field layout
* and alignment.
*/
struct c2wr_hdr {
/* wqe_count is part of the cqe. It is put here so the
* adapter can write to it while the wr is pending without
* clobbering part of the wr. This word need not be dma'd
* from the host to adapter by libccil, but we copy it anyway
* to make the memcpy to the adapter better aligned.
*/
__be32 wqe_count;
/* Put these fields next so that later 32- and 64-bit
* quantities are naturally aligned.
*/
u8 id;
u8 result; /* adapter -> host */
u8 sge_count; /* host -> adapter */
u8 flags; /* host -> adapter */
u64 context;
#ifdef CCMSGMAGIC
u32 magic;
u32 pad;
#endif
} __attribute__((packed));
/*
*------------------------ RNIC ------------------------
*/
/*
* WR_RNIC_OPEN
*/
/*
* Flags for the RNIC WRs
*/
enum c2_rnic_flags {
RNIC_IRD_STATIC = 0x0001,
RNIC_ORD_STATIC = 0x0002,
RNIC_QP_STATIC = 0x0004,
RNIC_SRQ_SUPPORTED = 0x0008,
RNIC_PBL_BLOCK_MODE = 0x0010,
RNIC_SRQ_MODEL_ARRIVAL = 0x0020,
RNIC_CQ_OVF_DETECTED = 0x0040,
RNIC_PRIV_MODE = 0x0080
};
struct c2wr_rnic_open_req {
struct c2wr_hdr hdr;
u64 user_context;
__be16 flags; /* See enum c2_rnic_flags */
__be16 port_num;
} __attribute__((packed));
struct c2wr_rnic_open_rep {
struct c2wr_hdr hdr;
u32 rnic_handle;
} __attribute__((packed));
union c2wr_rnic_open {
struct c2wr_rnic_open_req req;
struct c2wr_rnic_open_rep rep;
} __attribute__((packed));
struct c2wr_rnic_query_req {
struct c2wr_hdr hdr;
u32 rnic_handle;
} __attribute__((packed));
/*
* WR_RNIC_QUERY
*/
struct c2wr_rnic_query_rep {
struct c2wr_hdr hdr;
u64 user_context;
__be32 vendor_id;
__be32 part_number;
__be32 hw_version;
__be32 fw_ver_major;
__be32 fw_ver_minor;
__be32 fw_ver_patch;
char fw_ver_build_str[WR_BUILD_STR_LEN];
__be32 max_qps;
__be32 max_qp_depth;
u32 max_srq_depth;
u32 max_send_sgl_depth;
u32 max_rdma_sgl_depth;
__be32 max_cqs;
__be32 max_cq_depth;
u32 max_cq_event_handlers;
__be32 max_mrs;
u32 max_pbl_depth;
__be32 max_pds;
__be32 max_global_ird;
u32 max_global_ord;
__be32 max_qp_ird;
__be32 max_qp_ord;
u32 flags;
__be32 max_mws;
u32 pbe_range_low;
u32 pbe_range_high;
u32 max_srqs;
u32 page_size;
} __attribute__((packed));
union c2wr_rnic_query {
struct c2wr_rnic_query_req req;
struct c2wr_rnic_query_rep rep;
} __attribute__((packed));
/*
* WR_RNIC_GETCONFIG
*/
struct c2wr_rnic_getconfig_req {
struct c2wr_hdr hdr;
u32 rnic_handle;
u32 option; /* see c2_getconfig_cmd_t */
u64 reply_buf;
u32 reply_buf_len;
} __attribute__((packed)) ;
struct c2wr_rnic_g