Path: blob/master/drivers/infiniband/hw/amso1100/c2_wr.h
15112 views
/*1* Copyright (c) 2005 Ammasso, Inc. All rights reserved.2* Copyright (c) 2005 Open Grid Computing, Inc. All rights reserved.3*4* This software is available to you under a choice of one of two5* licenses. You may choose to be licensed under the terms of the GNU6* General Public License (GPL) Version 2, available from the file7* COPYING in the main directory of this source tree, or the8* OpenIB.org BSD license below:9*10* Redistribution and use in source and binary forms, with or11* without modification, are permitted provided that the following12* conditions are met:13*14* - Redistributions of source code must retain the above15* copyright notice, this list of conditions and the following16* disclaimer.17*18* - Redistributions in binary form must reproduce the above19* copyright notice, this list of conditions and the following20* disclaimer in the documentation and/or other materials21* provided with the distribution.22*23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,24* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF25* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND26* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS27* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN28* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN29* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE30* SOFTWARE.31*/32#ifndef _C2_WR_H_33#define _C2_WR_H_3435#ifdef CCDEBUG36#define CCWR_MAGIC 0xb07700b037#endif3839#define C2_QP_NO_ATTR_CHANGE 0xFFFFFFFF4041/* Maximum allowed size in bytes of private_data exchange42* on connect.43*/44#define C2_MAX_PRIVATE_DATA_SIZE 2004546/*47* These types are shared among the adapter, host, and CCIL consumer.48*/49enum c2_cq_notification_type {50C2_CQ_NOTIFICATION_TYPE_NONE = 1,51C2_CQ_NOTIFICATION_TYPE_NEXT,52C2_CQ_NOTIFICATION_TYPE_NEXT_SE53};5455enum c2_setconfig_cmd {56C2_CFG_ADD_ADDR = 1,57C2_CFG_DEL_ADDR = 2,58C2_CFG_ADD_ROUTE = 3,59C2_CFG_DEL_ROUTE = 460};6162enum c2_getconfig_cmd {63C2_GETCONFIG_ROUTES = 1,64C2_GETCONFIG_ADDRS65};6667/*68* CCIL Work Request Identifiers69*/70enum c2wr_ids {71CCWR_RNIC_OPEN = 1,72CCWR_RNIC_QUERY,73CCWR_RNIC_SETCONFIG,74CCWR_RNIC_GETCONFIG,75CCWR_RNIC_CLOSE,76CCWR_CQ_CREATE,77CCWR_CQ_QUERY,78CCWR_CQ_MODIFY,79CCWR_CQ_DESTROY,80CCWR_QP_CONNECT,81CCWR_PD_ALLOC,82CCWR_PD_DEALLOC,83CCWR_SRQ_CREATE,84CCWR_SRQ_QUERY,85CCWR_SRQ_MODIFY,86CCWR_SRQ_DESTROY,87CCWR_QP_CREATE,88CCWR_QP_QUERY,89CCWR_QP_MODIFY,90CCWR_QP_DESTROY,91CCWR_NSMR_STAG_ALLOC,92CCWR_NSMR_REGISTER,93CCWR_NSMR_PBL,94CCWR_STAG_DEALLOC,95CCWR_NSMR_REREGISTER,96CCWR_SMR_REGISTER,97CCWR_MR_QUERY,98CCWR_MW_ALLOC,99CCWR_MW_QUERY,100CCWR_EP_CREATE,101CCWR_EP_GETOPT,102CCWR_EP_SETOPT,103CCWR_EP_DESTROY,104CCWR_EP_BIND,105CCWR_EP_CONNECT,106CCWR_EP_LISTEN,107CCWR_EP_SHUTDOWN,108CCWR_EP_LISTEN_CREATE,109CCWR_EP_LISTEN_DESTROY,110CCWR_EP_QUERY,111CCWR_CR_ACCEPT,112CCWR_CR_REJECT,113CCWR_CONSOLE,114CCWR_TERM,115CCWR_FLASH_INIT,116CCWR_FLASH,117CCWR_BUF_ALLOC,118CCWR_BUF_FREE,119CCWR_FLASH_WRITE,120CCWR_INIT, /* WARNING: Don't move this ever again! */121122123124/* Add new IDs here */125126127128/*129* WARNING: CCWR_LAST must always be the last verbs id defined!130* All the preceding IDs are fixed, and must not change.131* You can add new IDs, but must not remove or reorder132* any IDs. If you do, YOU will ruin any hope of133* compatibility between versions.134*/135CCWR_LAST,136137/*138* Start over at 1 so that arrays indexed by user wr id's139* begin at 1. This is OK since the verbs and user wr id's140* are always used on disjoint sets of queues.141*/142/*143* The order of the CCWR_SEND_XX verbs must144* match the order of the RDMA_OPs145*/146CCWR_SEND = 1,147CCWR_SEND_INV,148CCWR_SEND_SE,149CCWR_SEND_SE_INV,150CCWR_RDMA_WRITE,151CCWR_RDMA_READ,152CCWR_RDMA_READ_INV,153CCWR_MW_BIND,154CCWR_NSMR_FASTREG,155CCWR_STAG_INVALIDATE,156CCWR_RECV,157CCWR_NOP,158CCWR_UNIMPL,159/* WARNING: This must always be the last user wr id defined! */160};161#define RDMA_SEND_OPCODE_FROM_WR_ID(x) (x+2)162163/*164* SQ/RQ Work Request Types165*/166enum c2_wr_type {167C2_WR_TYPE_SEND = CCWR_SEND,168C2_WR_TYPE_SEND_SE = CCWR_SEND_SE,169C2_WR_TYPE_SEND_INV = CCWR_SEND_INV,170C2_WR_TYPE_SEND_SE_INV = CCWR_SEND_SE_INV,171C2_WR_TYPE_RDMA_WRITE = CCWR_RDMA_WRITE,172C2_WR_TYPE_RDMA_READ = CCWR_RDMA_READ,173C2_WR_TYPE_RDMA_READ_INV_STAG = CCWR_RDMA_READ_INV,174C2_WR_TYPE_BIND_MW = CCWR_MW_BIND,175C2_WR_TYPE_FASTREG_NSMR = CCWR_NSMR_FASTREG,176C2_WR_TYPE_INV_STAG = CCWR_STAG_INVALIDATE,177C2_WR_TYPE_RECV = CCWR_RECV,178C2_WR_TYPE_NOP = CCWR_NOP,179};180181struct c2_netaddr {182__be32 ip_addr;183__be32 netmask;184u32 mtu;185};186187struct c2_route {188u32 ip_addr; /* 0 indicates the default route */189u32 netmask; /* netmask associated with dst */190u32 flags;191union {192u32 ipaddr; /* address of the nexthop interface */193u8 enaddr[6];194} nexthop;195};196197/*198* A Scatter Gather Entry.199*/200struct c2_data_addr {201__be32 stag;202__be32 length;203__be64 to;204};205206/*207* MR and MW flags used by the consumer, RI, and RNIC.208*/209enum c2_mm_flags {210MEM_REMOTE = 0x0001, /* allow mw binds with remote access. */211MEM_VA_BASED = 0x0002, /* Not Zero-based */212MEM_PBL_COMPLETE = 0x0004, /* PBL array is complete in this msg */213MEM_LOCAL_READ = 0x0008, /* allow local reads */214MEM_LOCAL_WRITE = 0x0010, /* allow local writes */215MEM_REMOTE_READ = 0x0020, /* allow remote reads */216MEM_REMOTE_WRITE = 0x0040, /* allow remote writes */217MEM_WINDOW_BIND = 0x0080, /* binds allowed */218MEM_SHARED = 0x0100, /* set if MR is shared */219MEM_STAG_VALID = 0x0200 /* set if STAG is in valid state */220};221222/*223* CCIL API ACF flags defined in terms of the low level mem flags.224* This minimizes translation needed in the user API225*/226enum c2_acf {227C2_ACF_LOCAL_READ = MEM_LOCAL_READ,228C2_ACF_LOCAL_WRITE = MEM_LOCAL_WRITE,229C2_ACF_REMOTE_READ = MEM_REMOTE_READ,230C2_ACF_REMOTE_WRITE = MEM_REMOTE_WRITE,231C2_ACF_WINDOW_BIND = MEM_WINDOW_BIND232};233234/*235* Image types of objects written to flash236*/237#define C2_FLASH_IMG_BITFILE 1238#define C2_FLASH_IMG_OPTION_ROM 2239#define C2_FLASH_IMG_VPD 3240241/*242* to fix bug 1815 we define the max size allowable of the243* terminate message (per the IETF spec).Refer to the IETF244* protocol specification, section 12.1.6, page 64)245* The message is prefixed by 20 types of DDP info.246*247* Then the message has 6 bytes for the terminate control248* and DDP segment length info plus a DDP header (either249* 14 or 18 byts) plus 28 bytes for the RDMA header.250* Thus the max size in:251* 20 + (6 + 18 + 28) = 72252*/253#define C2_MAX_TERMINATE_MESSAGE_SIZE (72)254255/*256* Build String Length. It must be the same as C2_BUILD_STR_LEN in ccil_api.h257*/258#define WR_BUILD_STR_LEN 64259260/*261* WARNING: All of these structs need to align any 64bit types on262* 64 bit boundaries! 64bit types include u64 and u64.263*/264265/*266* Clustercore Work Request Header. Be sensitive to field layout267* and alignment.268*/269struct c2wr_hdr {270/* wqe_count is part of the cqe. It is put here so the271* adapter can write to it while the wr is pending without272* clobbering part of the wr. This word need not be dma'd273* from the host to adapter by libccil, but we copy it anyway274* to make the memcpy to the adapter better aligned.275*/276__be32 wqe_count;277278/* Put these fields next so that later 32- and 64-bit279* quantities are naturally aligned.280*/281u8 id;282u8 result; /* adapter -> host */283u8 sge_count; /* host -> adapter */284u8 flags; /* host -> adapter */285286u64 context;287#ifdef CCMSGMAGIC288u32 magic;289u32 pad;290#endif291} __attribute__((packed));292293/*294*------------------------ RNIC ------------------------295*/296297/*298* WR_RNIC_OPEN299*/300301/*302* Flags for the RNIC WRs303*/304enum c2_rnic_flags {305RNIC_IRD_STATIC = 0x0001,306RNIC_ORD_STATIC = 0x0002,307RNIC_QP_STATIC = 0x0004,308RNIC_SRQ_SUPPORTED = 0x0008,309RNIC_PBL_BLOCK_MODE = 0x0010,310RNIC_SRQ_MODEL_ARRIVAL = 0x0020,311RNIC_CQ_OVF_DETECTED = 0x0040,312RNIC_PRIV_MODE = 0x0080313};314315struct c2wr_rnic_open_req {316struct c2wr_hdr hdr;317u64 user_context;318__be16 flags; /* See enum c2_rnic_flags */319__be16 port_num;320} __attribute__((packed));321322struct c2wr_rnic_open_rep {323struct c2wr_hdr hdr;324u32 rnic_handle;325} __attribute__((packed));326327union c2wr_rnic_open {328struct c2wr_rnic_open_req req;329struct c2wr_rnic_open_rep rep;330} __attribute__((packed));331332struct c2wr_rnic_query_req {333struct c2wr_hdr hdr;334u32 rnic_handle;335} __attribute__((packed));336337/*338* WR_RNIC_QUERY339*/340struct c2wr_rnic_query_rep {341struct c2wr_hdr hdr;342u64 user_context;343__be32 vendor_id;344__be32 part_number;345__be32 hw_version;346__be32 fw_ver_major;347__be32 fw_ver_minor;348__be32 fw_ver_patch;349char fw_ver_build_str[WR_BUILD_STR_LEN];350__be32 max_qps;351__be32 max_qp_depth;352u32 max_srq_depth;353u32 max_send_sgl_depth;354u32 max_rdma_sgl_depth;355__be32 max_cqs;356__be32 max_cq_depth;357u32 max_cq_event_handlers;358__be32 max_mrs;359u32 max_pbl_depth;360__be32 max_pds;361__be32 max_global_ird;362u32 max_global_ord;363__be32 max_qp_ird;364__be32 max_qp_ord;365u32 flags;366__be32 max_mws;367u32 pbe_range_low;368u32 pbe_range_high;369u32 max_srqs;370u32 page_size;371} __attribute__((packed));372373union c2wr_rnic_query {374struct c2wr_rnic_query_req req;375struct c2wr_rnic_query_rep rep;376} __attribute__((packed));377378/*379* WR_RNIC_GETCONFIG380*/381382struct c2wr_rnic_getconfig_req {383struct c2wr_hdr hdr;384u32 rnic_handle;385u32 option; /* see c2_getconfig_cmd_t */386u64 reply_buf;387u32 reply_buf_len;388} __attribute__((packed)) ;389390struct c2wr_rnic_getconfig_rep {391struct c2wr_hdr hdr;392u32 option; /* see c2_getconfig_cmd_t */393u32 count_len; /* length of the number of addresses configured */394} __attribute__((packed)) ;395396union c2wr_rnic_getconfig {397struct c2wr_rnic_getconfig_req req;398struct c2wr_rnic_getconfig_rep rep;399} __attribute__((packed)) ;400401/*402* WR_RNIC_SETCONFIG403*/404struct c2wr_rnic_setconfig_req {405struct c2wr_hdr hdr;406u32 rnic_handle;407__be32 option; /* See c2_setconfig_cmd_t */408/* variable data and pad. See c2_netaddr and c2_route */409u8 data[0];410} __attribute__((packed)) ;411412struct c2wr_rnic_setconfig_rep {413struct c2wr_hdr hdr;414} __attribute__((packed)) ;415416union c2wr_rnic_setconfig {417struct c2wr_rnic_setconfig_req req;418struct c2wr_rnic_setconfig_rep rep;419} __attribute__((packed)) ;420421/*422* WR_RNIC_CLOSE423*/424struct c2wr_rnic_close_req {425struct c2wr_hdr hdr;426u32 rnic_handle;427} __attribute__((packed)) ;428429struct c2wr_rnic_close_rep {430struct c2wr_hdr hdr;431} __attribute__((packed)) ;432433union c2wr_rnic_close {434struct c2wr_rnic_close_req req;435struct c2wr_rnic_close_rep rep;436} __attribute__((packed)) ;437438/*439*------------------------ CQ ------------------------440*/441struct c2wr_cq_create_req {442struct c2wr_hdr hdr;443__be64 shared_ht;444u64 user_context;445__be64 msg_pool;446u32 rnic_handle;447__be32 msg_size;448__be32 depth;449} __attribute__((packed)) ;450451struct c2wr_cq_create_rep {452struct c2wr_hdr hdr;453__be32 mq_index;454__be32 adapter_shared;455u32 cq_handle;456} __attribute__((packed)) ;457458union c2wr_cq_create {459struct c2wr_cq_create_req req;460struct c2wr_cq_create_rep rep;461} __attribute__((packed)) ;462463struct c2wr_cq_modify_req {464struct c2wr_hdr hdr;465u32 rnic_handle;466u32 cq_handle;467u32 new_depth;468u64 new_msg_pool;469} __attribute__((packed)) ;470471struct c2wr_cq_modify_rep {472struct c2wr_hdr hdr;473} __attribute__((packed)) ;474475union c2wr_cq_modify {476struct c2wr_cq_modify_req req;477struct c2wr_cq_modify_rep rep;478} __attribute__((packed)) ;479480struct c2wr_cq_destroy_req {481struct c2wr_hdr hdr;482u32 rnic_handle;483u32 cq_handle;484} __attribute__((packed)) ;485486struct c2wr_cq_destroy_rep {487struct c2wr_hdr hdr;488} __attribute__((packed)) ;489490union c2wr_cq_destroy {491struct c2wr_cq_destroy_req req;492struct c2wr_cq_destroy_rep rep;493} __attribute__((packed)) ;494495/*496*------------------------ PD ------------------------497*/498struct c2wr_pd_alloc_req {499struct c2wr_hdr hdr;500u32 rnic_handle;501u32 pd_id;502} __attribute__((packed)) ;503504struct c2wr_pd_alloc_rep {505struct c2wr_hdr hdr;506} __attribute__((packed)) ;507508union c2wr_pd_alloc {509struct c2wr_pd_alloc_req req;510struct c2wr_pd_alloc_rep rep;511} __attribute__((packed)) ;512513struct c2wr_pd_dealloc_req {514struct c2wr_hdr hdr;515u32 rnic_handle;516u32 pd_id;517} __attribute__((packed)) ;518519struct c2wr_pd_dealloc_rep {520struct c2wr_hdr hdr;521} __attribute__((packed)) ;522523union c2wr_pd_dealloc {524struct c2wr_pd_dealloc_req req;525struct c2wr_pd_dealloc_rep rep;526} __attribute__((packed)) ;527528/*529*------------------------ SRQ ------------------------530*/531struct c2wr_srq_create_req {532struct c2wr_hdr hdr;533u64 shared_ht;534u64 user_context;535u32 rnic_handle;536u32 srq_depth;537u32 srq_limit;538u32 sgl_depth;539u32 pd_id;540} __attribute__((packed)) ;541542struct c2wr_srq_create_rep {543struct c2wr_hdr hdr;544u32 srq_depth;545u32 sgl_depth;546u32 msg_size;547u32 mq_index;548u32 mq_start;549u32 srq_handle;550} __attribute__((packed)) ;551552union c2wr_srq_create {553struct c2wr_srq_create_req req;554struct c2wr_srq_create_rep rep;555} __attribute__((packed)) ;556557struct c2wr_srq_destroy_req {558struct c2wr_hdr hdr;559u32 rnic_handle;560u32 srq_handle;561} __attribute__((packed)) ;562563struct c2wr_srq_destroy_rep {564struct c2wr_hdr hdr;565} __attribute__((packed)) ;566567union c2wr_srq_destroy {568struct c2wr_srq_destroy_req req;569struct c2wr_srq_destroy_rep rep;570} __attribute__((packed)) ;571572/*573*------------------------ QP ------------------------574*/575enum c2wr_qp_flags {576QP_RDMA_READ = 0x00000001, /* RDMA read enabled? */577QP_RDMA_WRITE = 0x00000002, /* RDMA write enabled? */578QP_MW_BIND = 0x00000004, /* MWs enabled */579QP_ZERO_STAG = 0x00000008, /* enabled? */580QP_REMOTE_TERMINATION = 0x00000010, /* remote end terminated */581QP_RDMA_READ_RESPONSE = 0x00000020 /* Remote RDMA read */582/* enabled? */583};584585struct c2wr_qp_create_req {586struct c2wr_hdr hdr;587__be64 shared_sq_ht;588__be64 shared_rq_ht;589u64 user_context;590u32 rnic_handle;591u32 sq_cq_handle;592u32 rq_cq_handle;593__be32 sq_depth;594__be32 rq_depth;595u32 srq_handle;596u32 srq_limit;597__be32 flags; /* see enum c2wr_qp_flags */598__be32 send_sgl_depth;599__be32 recv_sgl_depth;600__be32 rdma_write_sgl_depth;601__be32 ord;602__be32 ird;603u32 pd_id;604} __attribute__((packed)) ;605606struct c2wr_qp_create_rep {607struct c2wr_hdr hdr;608__be32 sq_depth;609__be32 rq_depth;610u32 send_sgl_depth;611u32 recv_sgl_depth;612u32 rdma_write_sgl_depth;613u32 ord;614u32 ird;615__be32 sq_msg_size;616__be32 sq_mq_index;617__be32 sq_mq_start;618__be32 rq_msg_size;619__be32 rq_mq_index;620__be32 rq_mq_start;621u32 qp_handle;622} __attribute__((packed)) ;623624union c2wr_qp_create {625struct c2wr_qp_create_req req;626struct c2wr_qp_create_rep rep;627} __attribute__((packed)) ;628629struct c2wr_qp_query_req {630struct c2wr_hdr hdr;631u32 rnic_handle;632u32 qp_handle;633} __attribute__((packed)) ;634635struct c2wr_qp_query_rep {636struct c2wr_hdr hdr;637u64 user_context;638u32 rnic_handle;639u32 sq_depth;640u32 rq_depth;641u32 send_sgl_depth;642u32 rdma_write_sgl_depth;643u32 recv_sgl_depth;644u32 ord;645u32 ird;646u16 qp_state;647u16 flags; /* see c2wr_qp_flags_t */648u32 qp_id;649u32 local_addr;650u32 remote_addr;651u16 local_port;652u16 remote_port;653u32 terminate_msg_length; /* 0 if not present */654u8 data[0];655/* Terminate Message in-line here. */656} __attribute__((packed)) ;657658union c2wr_qp_query {659struct c2wr_qp_query_req req;660struct c2wr_qp_query_rep rep;661} __attribute__((packed)) ;662663struct c2wr_qp_modify_req {664struct c2wr_hdr hdr;665u64 stream_msg;666u32 stream_msg_length;667u32 rnic_handle;668u32 qp_handle;669__be32 next_qp_state;670__be32 ord;671__be32 ird;672__be32 sq_depth;673__be32 rq_depth;674u32 llp_ep_handle;675} __attribute__((packed)) ;676677struct c2wr_qp_modify_rep {678struct c2wr_hdr hdr;679u32 ord;680u32 ird;681u32 sq_depth;682u32 rq_depth;683u32 sq_msg_size;684u32 sq_mq_index;685u32 sq_mq_start;686u32 rq_msg_size;687u32 rq_mq_index;688u32 rq_mq_start;689} __attribute__((packed)) ;690691union c2wr_qp_modify {692struct c2wr_qp_modify_req req;693struct c2wr_qp_modify_rep rep;694} __attribute__((packed)) ;695696struct c2wr_qp_destroy_req {697struct c2wr_hdr hdr;698u32 rnic_handle;699u32 qp_handle;700} __attribute__((packed)) ;701702struct c2wr_qp_destroy_rep {703struct c2wr_hdr hdr;704} __attribute__((packed)) ;705706union c2wr_qp_destroy {707struct c2wr_qp_destroy_req req;708struct c2wr_qp_destroy_rep rep;709} __attribute__((packed)) ;710711/*712* The CCWR_QP_CONNECT msg is posted on the verbs request queue. It can713* only be posted when a QP is in IDLE state. After the connect request is714* submitted to the LLP, the adapter moves the QP to CONNECT_PENDING state.715* No synchronous reply from adapter to this WR. The results of716* connection are passed back in an async event CCAE_ACTIVE_CONNECT_RESULTS717* See c2wr_ae_active_connect_results_t718*/719struct c2wr_qp_connect_req {720struct c2wr_hdr hdr;721u32 rnic_handle;722u32 qp_handle;723__be32 remote_addr;724__be16 remote_port;725u16 pad;726__be32 private_data_length;727u8 private_data[0]; /* Private data in-line. */728} __attribute__((packed)) ;729730struct c2wr_qp_connect {731struct c2wr_qp_connect_req req;732/* no synchronous reply. */733} __attribute__((packed)) ;734735736/*737*------------------------ MM ------------------------738*/739740struct c2wr_nsmr_stag_alloc_req {741struct c2wr_hdr hdr;742u32 rnic_handle;743u32 pbl_depth;744u32 pd_id;745u32 flags;746} __attribute__((packed)) ;747748struct c2wr_nsmr_stag_alloc_rep {749struct c2wr_hdr hdr;750u32 pbl_depth;751u32 stag_index;752} __attribute__((packed)) ;753754union c2wr_nsmr_stag_alloc {755struct c2wr_nsmr_stag_alloc_req req;756struct c2wr_nsmr_stag_alloc_rep rep;757} __attribute__((packed)) ;758759struct c2wr_nsmr_register_req {760struct c2wr_hdr hdr;761__be64 va;762u32 rnic_handle;763__be16 flags;764u8 stag_key;765u8 pad;766u32 pd_id;767__be32 pbl_depth;768__be32 pbe_size;769__be32 fbo;770__be32 length;771__be32 addrs_length;772/* array of paddrs (must be aligned on a 64bit boundary) */773__be64 paddrs[0];774} __attribute__((packed)) ;775776struct c2wr_nsmr_register_rep {777struct c2wr_hdr hdr;778u32 pbl_depth;779__be32 stag_index;780} __attribute__((packed)) ;781782union c2wr_nsmr_register {783struct c2wr_nsmr_register_req req;784struct c2wr_nsmr_register_rep rep;785} __attribute__((packed)) ;786787struct c2wr_nsmr_pbl_req {788struct c2wr_hdr hdr;789u32 rnic_handle;790__be32 flags;791__be32 stag_index;792__be32 addrs_length;793/* array of paddrs (must be aligned on a 64bit boundary) */794__be64 paddrs[0];795} __attribute__((packed)) ;796797struct c2wr_nsmr_pbl_rep {798struct c2wr_hdr hdr;799} __attribute__((packed)) ;800801union c2wr_nsmr_pbl {802struct c2wr_nsmr_pbl_req req;803struct c2wr_nsmr_pbl_rep rep;804} __attribute__((packed)) ;805806struct c2wr_mr_query_req {807struct c2wr_hdr hdr;808u32 rnic_handle;809u32 stag_index;810} __attribute__((packed)) ;811812struct c2wr_mr_query_rep {813struct c2wr_hdr hdr;814u8 stag_key;815u8 pad[3];816u32 pd_id;817u32 flags;818u32 pbl_depth;819} __attribute__((packed)) ;820821union c2wr_mr_query {822struct c2wr_mr_query_req req;823struct c2wr_mr_query_rep rep;824} __attribute__((packed)) ;825826struct c2wr_mw_query_req {827struct c2wr_hdr hdr;828u32 rnic_handle;829u32 stag_index;830} __attribute__((packed)) ;831832struct c2wr_mw_query_rep {833struct c2wr_hdr hdr;834u8 stag_key;835u8 pad[3];836u32 pd_id;837u32 flags;838} __attribute__((packed)) ;839840union c2wr_mw_query {841struct c2wr_mw_query_req req;842struct c2wr_mw_query_rep rep;843} __attribute__((packed)) ;844845846struct c2wr_stag_dealloc_req {847struct c2wr_hdr hdr;848u32 rnic_handle;849__be32 stag_index;850} __attribute__((packed)) ;851852struct c2wr_stag_dealloc_rep {853struct c2wr_hdr hdr;854} __attribute__((packed)) ;855856union c2wr_stag_dealloc {857struct c2wr_stag_dealloc_req req;858struct c2wr_stag_dealloc_rep rep;859} __attribute__((packed)) ;860861struct c2wr_nsmr_reregister_req {862struct c2wr_hdr hdr;863u64 va;864u32 rnic_handle;865u16 flags;866u8 stag_key;867u8 pad;868u32 stag_index;869u32 pd_id;870u32 pbl_depth;871u32 pbe_size;872u32 fbo;873u32 length;874u32 addrs_length;875u32 pad1;876/* array of paddrs (must be aligned on a 64bit boundary) */877u64 paddrs[0];878} __attribute__((packed)) ;879880struct c2wr_nsmr_reregister_rep {881struct c2wr_hdr hdr;882u32 pbl_depth;883u32 stag_index;884} __attribute__((packed)) ;885886union c2wr_nsmr_reregister {887struct c2wr_nsmr_reregister_req req;888struct c2wr_nsmr_reregister_rep rep;889} __attribute__((packed)) ;890891struct c2wr_smr_register_req {892struct c2wr_hdr hdr;893u64 va;894u32 rnic_handle;895u16 flags;896u8 stag_key;897u8 pad;898u32 stag_index;899u32 pd_id;900} __attribute__((packed)) ;901902struct c2wr_smr_register_rep {903struct c2wr_hdr hdr;904u32 stag_index;905} __attribute__((packed)) ;906907union c2wr_smr_register {908struct c2wr_smr_register_req req;909struct c2wr_smr_register_rep rep;910} __attribute__((packed)) ;911912struct c2wr_mw_alloc_req {913struct c2wr_hdr hdr;914u32 rnic_handle;915u32 pd_id;916} __attribute__((packed)) ;917918struct c2wr_mw_alloc_rep {919struct c2wr_hdr hdr;920u32 stag_index;921} __attribute__((packed)) ;922923union c2wr_mw_alloc {924struct c2wr_mw_alloc_req req;925struct c2wr_mw_alloc_rep rep;926} __attribute__((packed)) ;927928/*929*------------------------ WRs -----------------------930*/931932struct c2wr_user_hdr {933struct c2wr_hdr hdr; /* Has status and WR Type */934} __attribute__((packed)) ;935936enum c2_qp_state {937C2_QP_STATE_IDLE = 0x01,938C2_QP_STATE_CONNECTING = 0x02,939C2_QP_STATE_RTS = 0x04,940C2_QP_STATE_CLOSING = 0x08,941C2_QP_STATE_TERMINATE = 0x10,942C2_QP_STATE_ERROR = 0x20,943};944945/* Completion queue entry. */946struct c2wr_ce {947struct c2wr_hdr hdr; /* Has status and WR Type */948u64 qp_user_context; /* c2_user_qp_t * */949u32 qp_state; /* Current QP State */950u32 handle; /* QPID or EP Handle */951__be32 bytes_rcvd; /* valid for RECV WCs */952u32 stag;953} __attribute__((packed)) ;954955956/*957* Flags used for all post-sq WRs. These must fit in the flags958* field of the struct c2wr_hdr (eight bits).959*/960enum {961SQ_SIGNALED = 0x01,962SQ_READ_FENCE = 0x02,963SQ_FENCE = 0x04,964};965966/*967* Common fields for all post-sq WRs. Namely the standard header and a968* secondary header with fields common to all post-sq WRs.969*/970struct c2_sq_hdr {971struct c2wr_user_hdr user_hdr;972} __attribute__((packed));973974/*975* Same as above but for post-rq WRs.976*/977struct c2_rq_hdr {978struct c2wr_user_hdr user_hdr;979} __attribute__((packed));980981/*982* use the same struct for all sends.983*/984struct c2wr_send_req {985struct c2_sq_hdr sq_hdr;986__be32 sge_len;987__be32 remote_stag;988u8 data[0]; /* SGE array */989} __attribute__((packed));990991union c2wr_send {992struct c2wr_send_req req;993struct c2wr_ce rep;994} __attribute__((packed));995996struct c2wr_rdma_write_req {997struct c2_sq_hdr sq_hdr;998__be64 remote_to;999__be32 remote_stag;1000__be32 sge_len;1001u8 data[0]; /* SGE array */1002} __attribute__((packed));10031004union c2wr_rdma_write {1005struct c2wr_rdma_write_req req;1006struct c2wr_ce rep;1007} __attribute__((packed));10081009struct c2wr_rdma_read_req {1010struct c2_sq_hdr sq_hdr;1011__be64 local_to;1012__be64 remote_to;1013__be32 local_stag;1014__be32 remote_stag;1015__be32 length;1016} __attribute__((packed));10171018union c2wr_rdma_read {1019struct c2wr_rdma_read_req req;1020struct c2wr_ce rep;1021} __attribute__((packed));10221023struct c2wr_mw_bind_req {1024struct c2_sq_hdr sq_hdr;1025u64 va;1026u8 stag_key;1027u8 pad[3];1028u32 mw_stag_index;1029u32 mr_stag_index;1030u32 length;1031u32 flags;1032} __attribute__((packed));10331034union c2wr_mw_bind {1035struct c2wr_mw_bind_req req;1036struct c2wr_ce rep;1037} __attribute__((packed));10381039struct c2wr_nsmr_fastreg_req {1040struct c2_sq_hdr sq_hdr;1041u64 va;1042u8 stag_key;1043u8 pad[3];1044u32 stag_index;1045u32 pbe_size;1046u32 fbo;1047u32 length;1048u32 addrs_length;1049/* array of paddrs (must be aligned on a 64bit boundary) */1050u64 paddrs[0];1051} __attribute__((packed));10521053union c2wr_nsmr_fastreg {1054struct c2wr_nsmr_fastreg_req req;1055struct c2wr_ce rep;1056} __attribute__((packed));10571058struct c2wr_stag_invalidate_req {1059struct c2_sq_hdr sq_hdr;1060u8 stag_key;1061u8 pad[3];1062u32 stag_index;1063} __attribute__((packed));10641065union c2wr_stag_invalidate {1066struct c2wr_stag_invalidate_req req;1067struct c2wr_ce rep;1068} __attribute__((packed));10691070union c2wr_sqwr {1071struct c2_sq_hdr sq_hdr;1072struct c2wr_send_req send;1073struct c2wr_send_req send_se;1074struct c2wr_send_req send_inv;1075struct c2wr_send_req send_se_inv;1076struct c2wr_rdma_write_req rdma_write;1077struct c2wr_rdma_read_req rdma_read;1078struct c2wr_mw_bind_req mw_bind;1079struct c2wr_nsmr_fastreg_req nsmr_fastreg;1080struct c2wr_stag_invalidate_req stag_inv;1081} __attribute__((packed));108210831084/*1085* RQ WRs1086*/1087struct c2wr_rqwr {1088struct c2_rq_hdr rq_hdr;1089u8 data[0]; /* array of SGEs */1090} __attribute__((packed));10911092union c2wr_recv {1093struct c2wr_rqwr req;1094struct c2wr_ce rep;1095} __attribute__((packed));10961097/*1098* All AEs start with this header. Most AEs only need to convey the1099* information in the header. Some, like LLP connection events, need1100* more info. The union typdef c2wr_ae_t has all the possible AEs.1101*1102* hdr.context is the user_context from the rnic_open WR. NULL If this1103* is not affiliated with an rnic1104*1105* hdr.id is the AE identifier (eg; CCAE_REMOTE_SHUTDOWN,1106* CCAE_LLP_CLOSE_COMPLETE)1107*1108* resource_type is one of: C2_RES_IND_QP, C2_RES_IND_CQ, C2_RES_IND_SRQ1109*1110* user_context is the context passed down when the host created the resource.1111*/1112struct c2wr_ae_hdr {1113struct c2wr_hdr hdr;1114u64 user_context; /* user context for this res. */1115__be32 resource_type; /* see enum c2_resource_indicator */1116__be32 resource; /* handle for resource */1117__be32 qp_state; /* current QP State */1118} __attribute__((packed));11191120/*1121* After submitting the CCAE_ACTIVE_CONNECT_RESULTS message on the AEQ,1122* the adapter moves the QP into RTS state1123*/1124struct c2wr_ae_active_connect_results {1125struct c2wr_ae_hdr ae_hdr;1126__be32 laddr;1127__be32 raddr;1128__be16 lport;1129__be16 rport;1130__be32 private_data_length;1131u8 private_data[0]; /* data is in-line in the msg. */1132} __attribute__((packed));11331134/*1135* When connections are established by the stack (and the private data1136* MPA frame is received), the adapter will generate an event to the host.1137* The details of the connection, any private data, and the new connection1138* request handle is passed up via the CCAE_CONNECTION_REQUEST msg on the1139* AE queue:1140*/1141struct c2wr_ae_connection_request {1142struct c2wr_ae_hdr ae_hdr;1143u32 cr_handle; /* connreq handle (sock ptr) */1144__be32 laddr;1145__be32 raddr;1146__be16 lport;1147__be16 rport;1148__be32 private_data_length;1149u8 private_data[0]; /* data is in-line in the msg. */1150} __attribute__((packed));11511152union c2wr_ae {1153struct c2wr_ae_hdr ae_generic;1154struct c2wr_ae_active_connect_results ae_active_connect_results;1155struct c2wr_ae_connection_request ae_connection_request;1156} __attribute__((packed));11571158struct c2wr_init_req {1159struct c2wr_hdr hdr;1160__be64 hint_count;1161__be64 q0_host_shared;1162__be64 q1_host_shared;1163__be64 q1_host_msg_pool;1164__be64 q2_host_shared;1165__be64 q2_host_msg_pool;1166} __attribute__((packed));11671168struct c2wr_init_rep {1169struct c2wr_hdr hdr;1170} __attribute__((packed));11711172union c2wr_init {1173struct c2wr_init_req req;1174struct c2wr_init_rep rep;1175} __attribute__((packed));11761177/*1178* For upgrading flash.1179*/11801181struct c2wr_flash_init_req {1182struct c2wr_hdr hdr;1183u32 rnic_handle;1184} __attribute__((packed));11851186struct c2wr_flash_init_rep {1187struct c2wr_hdr hdr;1188u32 adapter_flash_buf_offset;1189u32 adapter_flash_len;1190} __attribute__((packed));11911192union c2wr_flash_init {1193struct c2wr_flash_init_req req;1194struct c2wr_flash_init_rep rep;1195} __attribute__((packed));11961197struct c2wr_flash_req {1198struct c2wr_hdr hdr;1199u32 rnic_handle;1200u32 len;1201} __attribute__((packed));12021203struct c2wr_flash_rep {1204struct c2wr_hdr hdr;1205u32 status;1206} __attribute__((packed));12071208union c2wr_flash {1209struct c2wr_flash_req req;1210struct c2wr_flash_rep rep;1211} __attribute__((packed));12121213struct c2wr_buf_alloc_req {1214struct c2wr_hdr hdr;1215u32 rnic_handle;1216u32 size;1217} __attribute__((packed));12181219struct c2wr_buf_alloc_rep {1220struct c2wr_hdr hdr;1221u32 offset; /* 0 if mem not available */1222u32 size; /* 0 if mem not available */1223} __attribute__((packed));12241225union c2wr_buf_alloc {1226struct c2wr_buf_alloc_req req;1227struct c2wr_buf_alloc_rep rep;1228} __attribute__((packed));12291230struct c2wr_buf_free_req {1231struct c2wr_hdr hdr;1232u32 rnic_handle;1233u32 offset; /* Must match value from alloc */1234u32 size; /* Must match value from alloc */1235} __attribute__((packed));12361237struct c2wr_buf_free_rep {1238struct c2wr_hdr hdr;1239} __attribute__((packed));12401241union c2wr_buf_free {1242struct c2wr_buf_free_req req;1243struct c2wr_ce rep;1244} __attribute__((packed));12451246struct c2wr_flash_write_req {1247struct c2wr_hdr hdr;1248u32 rnic_handle;1249u32 offset;1250u32 size;1251u32 type;1252u32 flags;1253} __attribute__((packed));12541255struct c2wr_flash_write_rep {1256struct c2wr_hdr hdr;1257u32 status;1258} __attribute__((packed));12591260union c2wr_flash_write {1261struct c2wr_flash_write_req req;1262struct c2wr_flash_write_rep rep;1263} __attribute__((packed));12641265/*1266* Messages for LLP connection setup.1267*/12681269/*1270* Listen Request. This allocates a listening endpoint to allow passive1271* connection setup. Newly established LLP connections are passed up1272* via an AE. See c2wr_ae_connection_request_t1273*/1274struct c2wr_ep_listen_create_req {1275struct c2wr_hdr hdr;1276u64 user_context; /* returned in AEs. */1277u32 rnic_handle;1278__be32 local_addr; /* local addr, or 0 */1279__be16 local_port; /* 0 means "pick one" */1280u16 pad;1281__be32 backlog; /* tradional tcp listen bl */1282} __attribute__((packed));12831284struct c2wr_ep_listen_create_rep {1285struct c2wr_hdr hdr;1286u32 ep_handle; /* handle to new listening ep */1287u16 local_port; /* resulting port... */1288u16 pad;1289} __attribute__((packed));12901291union c2wr_ep_listen_create {1292struct c2wr_ep_listen_create_req req;1293struct c2wr_ep_listen_create_rep rep;1294} __attribute__((packed));12951296struct c2wr_ep_listen_destroy_req {1297struct c2wr_hdr hdr;1298u32 rnic_handle;1299u32 ep_handle;1300} __attribute__((packed));13011302struct c2wr_ep_listen_destroy_rep {1303struct c2wr_hdr hdr;1304} __attribute__((packed));13051306union c2wr_ep_listen_destroy {1307struct c2wr_ep_listen_destroy_req req;1308struct c2wr_ep_listen_destroy_rep rep;1309} __attribute__((packed));13101311struct c2wr_ep_query_req {1312struct c2wr_hdr hdr;1313u32 rnic_handle;1314u32 ep_handle;1315} __attribute__((packed));13161317struct c2wr_ep_query_rep {1318struct c2wr_hdr hdr;1319u32 rnic_handle;1320u32 local_addr;1321u32 remote_addr;1322u16 local_port;1323u16 remote_port;1324} __attribute__((packed));13251326union c2wr_ep_query {1327struct c2wr_ep_query_req req;1328struct c2wr_ep_query_rep rep;1329} __attribute__((packed));133013311332/*1333* The host passes this down to indicate acceptance of a pending iWARP1334* connection. The cr_handle was obtained from the CONNECTION_REQUEST1335* AE passed up by the adapter. See c2wr_ae_connection_request_t.1336*/1337struct c2wr_cr_accept_req {1338struct c2wr_hdr hdr;1339u32 rnic_handle;1340u32 qp_handle; /* QP to bind to this LLP conn */1341u32 ep_handle; /* LLP handle to accept */1342__be32 private_data_length;1343u8 private_data[0]; /* data in-line in msg. */1344} __attribute__((packed));13451346/*1347* adapter sends reply when private data is successfully submitted to1348* the LLP.1349*/1350struct c2wr_cr_accept_rep {1351struct c2wr_hdr hdr;1352} __attribute__((packed));13531354union c2wr_cr_accept {1355struct c2wr_cr_accept_req req;1356struct c2wr_cr_accept_rep rep;1357} __attribute__((packed));13581359/*1360* The host sends this down if a given iWARP connection request was1361* rejected by the consumer. The cr_handle was obtained from a1362* previous c2wr_ae_connection_request_t AE sent by the adapter.1363*/1364struct c2wr_cr_reject_req {1365struct c2wr_hdr hdr;1366u32 rnic_handle;1367u32 ep_handle; /* LLP handle to reject */1368} __attribute__((packed));13691370/*1371* Dunno if this is needed, but we'll add it for now. The adapter will1372* send the reject_reply after the LLP endpoint has been destroyed.1373*/1374struct c2wr_cr_reject_rep {1375struct c2wr_hdr hdr;1376} __attribute__((packed));13771378union c2wr_cr_reject {1379struct c2wr_cr_reject_req req;1380struct c2wr_cr_reject_rep rep;1381} __attribute__((packed));13821383/*1384* console command. Used to implement a debug console over the verbs1385* request and reply queues.1386*/13871388/*1389* Console request message. It contains:1390* - message hdr with id = CCWR_CONSOLE1391* - the physaddr/len of host memory to be used for the reply.1392* - the command string. eg: "netstat -s" or "zoneinfo"1393*/1394struct c2wr_console_req {1395struct c2wr_hdr hdr; /* id = CCWR_CONSOLE */1396u64 reply_buf; /* pinned host buf for reply */1397u32 reply_buf_len; /* length of reply buffer */1398u8 command[0]; /* NUL terminated ascii string */1399/* containing the command req */1400} __attribute__((packed));14011402/*1403* flags used in the console reply.1404*/1405enum c2_console_flags {1406CONS_REPLY_TRUNCATED = 0x00000001 /* reply was truncated */1407} __attribute__((packed));14081409/*1410* Console reply message.1411* hdr.result contains the c2_status_t error if the reply was _not_ generated,1412* or C2_OK if the reply was generated.1413*/1414struct c2wr_console_rep {1415struct c2wr_hdr hdr; /* id = CCWR_CONSOLE */1416u32 flags;1417} __attribute__((packed));14181419union c2wr_console {1420struct c2wr_console_req req;1421struct c2wr_console_rep rep;1422} __attribute__((packed));142314241425/*1426* Giant union with all WRs. Makes life easier...1427*/1428union c2wr {1429struct c2wr_hdr hdr;1430struct c2wr_user_hdr user_hdr;1431union c2wr_rnic_open rnic_open;1432union c2wr_rnic_query rnic_query;1433union c2wr_rnic_getconfig rnic_getconfig;1434union c2wr_rnic_setconfig rnic_setconfig;1435union c2wr_rnic_close rnic_close;1436union c2wr_cq_create cq_create;1437union c2wr_cq_modify cq_modify;1438union c2wr_cq_destroy cq_destroy;1439union c2wr_pd_alloc pd_alloc;1440union c2wr_pd_dealloc pd_dealloc;1441union c2wr_srq_create srq_create;1442union c2wr_srq_destroy srq_destroy;1443union c2wr_qp_create qp_create;1444union c2wr_qp_query qp_query;1445union c2wr_qp_modify qp_modify;1446union c2wr_qp_destroy qp_destroy;1447struct c2wr_qp_connect qp_connect;1448union c2wr_nsmr_stag_alloc nsmr_stag_alloc;1449union c2wr_nsmr_register nsmr_register;1450union c2wr_nsmr_pbl nsmr_pbl;1451union c2wr_mr_query mr_query;1452union c2wr_mw_query mw_query;1453union c2wr_stag_dealloc stag_dealloc;1454union c2wr_sqwr sqwr;1455struct c2wr_rqwr rqwr;1456struct c2wr_ce ce;1457union c2wr_ae ae;1458union c2wr_init init;1459union c2wr_ep_listen_create ep_listen_create;1460union c2wr_ep_listen_destroy ep_listen_destroy;1461union c2wr_cr_accept cr_accept;1462union c2wr_cr_reject cr_reject;1463union c2wr_console console;1464union c2wr_flash_init flash_init;1465union c2wr_flash flash;1466union c2wr_buf_alloc buf_alloc;1467union c2wr_buf_free buf_free;1468union c2wr_flash_write flash_write;1469} __attribute__((packed));147014711472/*1473* Accessors for the wr fields that are packed together tightly to1474* reduce the wr message size. The wr arguments are void* so that1475* either a struct c2wr*, a struct c2wr_hdr*, or a pointer to any of the types1476* in the struct c2wr union can be passed in.1477*/1478static __inline__ u8 c2_wr_get_id(void *wr)1479{1480return ((struct c2wr_hdr *) wr)->id;1481}1482static __inline__ void c2_wr_set_id(void *wr, u8 id)1483{1484((struct c2wr_hdr *) wr)->id = id;1485}1486static __inline__ u8 c2_wr_get_result(void *wr)1487{1488return ((struct c2wr_hdr *) wr)->result;1489}1490static __inline__ void c2_wr_set_result(void *wr, u8 result)1491{1492((struct c2wr_hdr *) wr)->result = result;1493}1494static __inline__ u8 c2_wr_get_flags(void *wr)1495{1496return ((struct c2wr_hdr *) wr)->flags;1497}1498static __inline__ void c2_wr_set_flags(void *wr, u8 flags)1499{1500((struct c2wr_hdr *) wr)->flags = flags;1501}1502static __inline__ u8 c2_wr_get_sge_count(void *wr)1503{1504return ((struct c2wr_hdr *) wr)->sge_count;1505}1506static __inline__ void c2_wr_set_sge_count(void *wr, u8 sge_count)1507{1508((struct c2wr_hdr *) wr)->sge_count = sge_count;1509}1510static __inline__ __be32 c2_wr_get_wqe_count(void *wr)1511{1512return ((struct c2wr_hdr *) wr)->wqe_count;1513}1514static __inline__ void c2_wr_set_wqe_count(void *wr, u32 wqe_count)1515{1516((struct c2wr_hdr *) wr)->wqe_count = wqe_count;1517}15181519#endif /* _C2_WR_H_ */152015211522