10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57387SRobert.Gordon@Sun.COM * Common Development and Distribution License (the "License"). 67387SRobert.Gordon@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12553SKaren.Rochford@Sun.COM * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 257387SRobert.Gordon@Sun.COM /* 267387SRobert.Gordon@Sun.COM * Copyright (c) 2007, The Ohio State University. All rights reserved. 277387SRobert.Gordon@Sun.COM * 287387SRobert.Gordon@Sun.COM * Portions of this source code is developed by the team members of 297387SRobert.Gordon@Sun.COM * The Ohio State University's Network-Based Computing Laboratory (NBCL), 307387SRobert.Gordon@Sun.COM * headed by Professor Dhabaleswar K. (DK) Panda. 317387SRobert.Gordon@Sun.COM * 327387SRobert.Gordon@Sun.COM * Acknowledgements to contributions from developors: 337387SRobert.Gordon@Sun.COM * Ranjit Noronha: noronha@cse.ohio-state.edu 347387SRobert.Gordon@Sun.COM * Lei Chai : chail@cse.ohio-state.edu 357387SRobert.Gordon@Sun.COM * Weikuan Yu : yuw@cse.ohio-state.edu 367387SRobert.Gordon@Sun.COM * 377387SRobert.Gordon@Sun.COM */ 387387SRobert.Gordon@Sun.COM 390Sstevel@tonic-gate #ifndef _RPC_RPC_RDMA_H 400Sstevel@tonic-gate #define _RPC_RPC_RDMA_H 410Sstevel@tonic-gate 420Sstevel@tonic-gate #include <rpc/rpc.h> 430Sstevel@tonic-gate #include <rpc/rpc_sztypes.h> 440Sstevel@tonic-gate #include <sys/sunddi.h> 450Sstevel@tonic-gate #include <sys/sunldi.h> 460Sstevel@tonic-gate 470Sstevel@tonic-gate #ifdef __cplusplus 480Sstevel@tonic-gate extern "C" { 490Sstevel@tonic-gate #endif 500Sstevel@tonic-gate 517387SRobert.Gordon@Sun.COM #define RPCRDMA_VERS 1 /* Version of the RPC over RDMA protocol */ 520Sstevel@tonic-gate #define RDMATF_VERS 1 /* Version of the API used by RPC for RDMA */ 530Sstevel@tonic-gate #define RDMATF_VERS_1 1 /* Current version of RDMATF */ 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* 560Sstevel@tonic-gate * The size of an RPC call or reply message 570Sstevel@tonic-gate */ 587387SRobert.Gordon@Sun.COM #define RPC_MSG_SZ 1024 597387SRobert.Gordon@Sun.COM 607387SRobert.Gordon@Sun.COM /* 617387SRobert.Gordon@Sun.COM * RDMA chunk size 627387SRobert.Gordon@Sun.COM */ 637387SRobert.Gordon@Sun.COM #define RDMA_MINCHUNK 1024 640Sstevel@tonic-gate 650Sstevel@tonic-gate /* 660Sstevel@tonic-gate * Storage for a chunk list 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate #define RPC_CL_SZ 1024 690Sstevel@tonic-gate 700Sstevel@tonic-gate /* 710Sstevel@tonic-gate * Chunk size 720Sstevel@tonic-gate */ 730Sstevel@tonic-gate #define MINCHUNK 1024 740Sstevel@tonic-gate 750Sstevel@tonic-gate /* 760Sstevel@tonic-gate * Size of receive buffer 770Sstevel@tonic-gate */ 780Sstevel@tonic-gate #define RPC_BUF_SIZE 2048 790Sstevel@tonic-gate 800Sstevel@tonic-gate #define NOWAIT 0 /* don't wait for operation of complete */ 810Sstevel@tonic-gate #define WAIT 1 /* wait and ensure that operation is complete */ 820Sstevel@tonic-gate 830Sstevel@tonic-gate /* 840Sstevel@tonic-gate * RDMA xdr buffer control and other control flags. Add new flags here, 850Sstevel@tonic-gate * set them in private structure for xdr over RDMA in xdr_rdma.c 860Sstevel@tonic-gate */ 877387SRobert.Gordon@Sun.COM #define XDR_RDMA_CHUNK 0x1 887387SRobert.Gordon@Sun.COM #define XDR_RDMA_WLIST_REG 0x2 897387SRobert.Gordon@Sun.COM #define XDR_RDMA_RLIST_REG 0x4 907387SRobert.Gordon@Sun.COM 917387SRobert.Gordon@Sun.COM #define LONG_REPLY_LEN 65536 927387SRobert.Gordon@Sun.COM #define WCL_BUF_LEN 32768 937387SRobert.Gordon@Sun.COM #define RCL_BUF_LEN 32768 947387SRobert.Gordon@Sun.COM 957387SRobert.Gordon@Sun.COM 967387SRobert.Gordon@Sun.COM #define RDMA_BUFS_RQST 34 /* Num bufs requested by client */ 977387SRobert.Gordon@Sun.COM #define RDMA_BUFS_GRANT 32 /* Num bufs granted by server */ 987387SRobert.Gordon@Sun.COM 997387SRobert.Gordon@Sun.COM struct xdr_ops *xdrrdma_xops(void); 1007387SRobert.Gordon@Sun.COM 1017387SRobert.Gordon@Sun.COM /* 1027387SRobert.Gordon@Sun.COM * Credit Control Structures. 1037387SRobert.Gordon@Sun.COM */ 1047387SRobert.Gordon@Sun.COM typedef enum rdma_cc_type { 1057387SRobert.Gordon@Sun.COM RDMA_CC_CLNT, /* CONN is for a client */ 1067387SRobert.Gordon@Sun.COM RDMA_CC_SRV /* CONN is for a server */ 1077387SRobert.Gordon@Sun.COM } rdma_cc_type_t; 1087387SRobert.Gordon@Sun.COM 1097387SRobert.Gordon@Sun.COM /* 1107387SRobert.Gordon@Sun.COM * Client side credit control data structure. 1117387SRobert.Gordon@Sun.COM */ 1127387SRobert.Gordon@Sun.COM typedef struct rdma_clnt_cred_ctrl { 1137387SRobert.Gordon@Sun.COM uint32_t clnt_cc_granted_ops; 1147387SRobert.Gordon@Sun.COM uint32_t clnt_cc_in_flight_ops; 1157387SRobert.Gordon@Sun.COM kcondvar_t clnt_cc_cv; 1167387SRobert.Gordon@Sun.COM } rdma_clnt_cred_ctrl_t; 1177387SRobert.Gordon@Sun.COM 1187387SRobert.Gordon@Sun.COM /* 1197387SRobert.Gordon@Sun.COM * Server side credit control data structure. 1207387SRobert.Gordon@Sun.COM */ 1217387SRobert.Gordon@Sun.COM typedef struct rdma_srv_cred_ctrl { 1227387SRobert.Gordon@Sun.COM uint32_t srv_cc_buffers_granted; 1237387SRobert.Gordon@Sun.COM uint32_t srv_cc_cur_buffers_used; 1247387SRobert.Gordon@Sun.COM uint32_t srv_cc_posted; 1257387SRobert.Gordon@Sun.COM uint32_t srv_cc_max_buf_size; /* to be determined by CCP */ 1267387SRobert.Gordon@Sun.COM uint32_t srv_cc_cur_buf_size; /* to be determined by CCP */ 1277387SRobert.Gordon@Sun.COM } rdma_srv_cred_ctrl_t; 1287387SRobert.Gordon@Sun.COM 1297387SRobert.Gordon@Sun.COM typedef enum { 1307387SRobert.Gordon@Sun.COM RPCCALL_WLIST, 1317387SRobert.Gordon@Sun.COM RPCCALL_WCHUNK, 1327387SRobert.Gordon@Sun.COM RPCCALL_NOWRITE 1337387SRobert.Gordon@Sun.COM }rpccall_write_t; 1347387SRobert.Gordon@Sun.COM 1357387SRobert.Gordon@Sun.COM typedef enum { 1369348SSiddheshwar.Mahesh@Sun.COM CLIST_REG_SOURCE = 1, 1377387SRobert.Gordon@Sun.COM CLIST_REG_DST 1387387SRobert.Gordon@Sun.COM } clist_dstsrc; 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate /* 1410Sstevel@tonic-gate * Return codes from RDMA operations 1420Sstevel@tonic-gate */ 1430Sstevel@tonic-gate typedef enum { 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate RDMA_SUCCESS = 0, /* successful operation */ 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate RDMA_INVAL = 1, /* invalid parameter */ 1480Sstevel@tonic-gate RDMA_TIMEDOUT = 2, /* operation timed out */ 1490Sstevel@tonic-gate RDMA_INTR = 3, /* operation interrupted */ 1500Sstevel@tonic-gate RDMA_NORESOURCE = 4, /* insufficient resource */ 1510Sstevel@tonic-gate /* 1520Sstevel@tonic-gate * connection errors 1530Sstevel@tonic-gate */ 1540Sstevel@tonic-gate RDMA_REJECT = 5, /* connection req rejected */ 1550Sstevel@tonic-gate RDMA_NOLISTENER = 6, /* no listener on server */ 1560Sstevel@tonic-gate RDMA_UNREACHABLE = 7, /* host unreachable */ 1570Sstevel@tonic-gate RDMA_CONNLOST = 8, /* connection lost */ 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate RDMA_XPRTFAILED = 9, /* RDMA transport failed */ 1600Sstevel@tonic-gate RDMA_PROTECTERR = 10, /* memory protection error */ 1610Sstevel@tonic-gate RDMA_OVERRUN = 11, /* transport overrun */ 1620Sstevel@tonic-gate RDMA_RECVQEMPTY = 12, /* incoming pkt dropped, recv q empty */ 1630Sstevel@tonic-gate RDMA_PROTFAILED = 13, /* RDMA protocol failed */ 1640Sstevel@tonic-gate RDMA_NOTSUPP = 14, /* requested feature not supported */ 1650Sstevel@tonic-gate RDMA_REMOTERR = 15, /* error at remote end */ 1660Sstevel@tonic-gate /* 1670Sstevel@tonic-gate * RDMATF errors 1680Sstevel@tonic-gate */ 1690Sstevel@tonic-gate RDMA_BADVERS = 16, /* mismatch RDMATF versions */ 1700Sstevel@tonic-gate RDMA_REG_EXIST = 17, /* RDMATF registration already exists */ 1718695SRajkumar.Sivaprakasam@Sun.COM RDMA_HCA_ATTACH = 18, 1728695SRajkumar.Sivaprakasam@Sun.COM RDMA_HCA_DETACH = 19, 1730Sstevel@tonic-gate 1740Sstevel@tonic-gate /* 1750Sstevel@tonic-gate * fallback error 1760Sstevel@tonic-gate */ 1778695SRajkumar.Sivaprakasam@Sun.COM RDMA_FAILED = 20 /* generic error */ 1780Sstevel@tonic-gate } rdma_stat; 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate /* 1810Sstevel@tonic-gate * Memory region context. This is an RDMA provider generated 1820Sstevel@tonic-gate * handle for a registered arbitrary size contiguous virtual 1830Sstevel@tonic-gate * memory. The RDMA Interface Adapter needs this for local or 1840Sstevel@tonic-gate * remote memory access. 1850Sstevel@tonic-gate * 1860Sstevel@tonic-gate * The mrc_rmr field holds the remote memory region context 1870Sstevel@tonic-gate * which is sent over-the-wire to provide the remote host 1880Sstevel@tonic-gate * with RDMA access to the memory region. 1890Sstevel@tonic-gate */ 1900Sstevel@tonic-gate struct mrc { 1910Sstevel@tonic-gate uint32_t mrc_rmr; /* Remote MR context, sent OTW */ 1920Sstevel@tonic-gate union { 1930Sstevel@tonic-gate struct mr { 1940Sstevel@tonic-gate uint32_t lmr; /* Local MR context */ 1950Sstevel@tonic-gate uint64_t linfo; /* Local memory info */ 1960Sstevel@tonic-gate } mr; 1970Sstevel@tonic-gate } lhdl; 1980Sstevel@tonic-gate }; 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate #define mrc_lmr lhdl.mr.lmr 2010Sstevel@tonic-gate #define mrc_linfo lhdl.mr.linfo 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate /* 2047387SRobert.Gordon@Sun.COM * Memory management for the RDMA buffers 2057387SRobert.Gordon@Sun.COM */ 2067387SRobert.Gordon@Sun.COM /* 2077387SRobert.Gordon@Sun.COM * RDMA buffer types 2087387SRobert.Gordon@Sun.COM */ 2097387SRobert.Gordon@Sun.COM typedef enum { 2107387SRobert.Gordon@Sun.COM SEND_BUFFER, /* buf for send msg */ 2117387SRobert.Gordon@Sun.COM SEND_DESCRIPTOR, /* buf used for send msg descriptor in plugins only */ 2127387SRobert.Gordon@Sun.COM RECV_BUFFER, /* buf for recv msg */ 2137387SRobert.Gordon@Sun.COM RECV_DESCRIPTOR, /* buf used for recv msg descriptor in plugins only */ 2147387SRobert.Gordon@Sun.COM RDMA_LONG_BUFFER /* chunk buf used in RDMATF only and not in plugins */ 2157387SRobert.Gordon@Sun.COM } rdma_btype; 2167387SRobert.Gordon@Sun.COM 2177387SRobert.Gordon@Sun.COM /* 2187387SRobert.Gordon@Sun.COM * RDMA buffer information 2197387SRobert.Gordon@Sun.COM */ 2207387SRobert.Gordon@Sun.COM typedef struct rdma_buf { 2217387SRobert.Gordon@Sun.COM rdma_btype type; /* buffer type */ 2227387SRobert.Gordon@Sun.COM uint_t len; /* length of buffer */ 2237387SRobert.Gordon@Sun.COM caddr_t addr; /* buffer address */ 2247387SRobert.Gordon@Sun.COM struct mrc handle; /* buffer registration handle */ 2257387SRobert.Gordon@Sun.COM caddr_t rb_private; 2267387SRobert.Gordon@Sun.COM } rdma_buf_t; 2277387SRobert.Gordon@Sun.COM 2287387SRobert.Gordon@Sun.COM 2297387SRobert.Gordon@Sun.COM /* 2300Sstevel@tonic-gate * The XDR offset value is used by the XDR 2310Sstevel@tonic-gate * routine to identify the position in the 2320Sstevel@tonic-gate * RPC message where the opaque object would 2330Sstevel@tonic-gate * normally occur. Neither the data content 2340Sstevel@tonic-gate * of the chunk, nor its size field are included 2350Sstevel@tonic-gate * in the RPC message. The XDR offset is calculated 2360Sstevel@tonic-gate * as if the chunks were present. 2370Sstevel@tonic-gate * 2380Sstevel@tonic-gate * The remaining fields identify the chunk of data 2390Sstevel@tonic-gate * on the sender. The c_memhandle identifies a 2400Sstevel@tonic-gate * registered RDMA memory region and the c_addr 2410Sstevel@tonic-gate * and c_len fields identify the chunk within it. 2420Sstevel@tonic-gate */ 2430Sstevel@tonic-gate struct clist { 2440Sstevel@tonic-gate uint32 c_xdroff; /* XDR offset */ 2450Sstevel@tonic-gate uint32 c_len; /* Length */ 2469348SSiddheshwar.Mahesh@Sun.COM clist_dstsrc c_regtype; /* type of registration */ 2470Sstevel@tonic-gate struct mrc c_smemhandle; /* src memory handle */ 2480Sstevel@tonic-gate uint64 c_ssynchandle; /* src sync handle */ 2497387SRobert.Gordon@Sun.COM union { 2507387SRobert.Gordon@Sun.COM uint64 c_saddr; /* src address */ 2517387SRobert.Gordon@Sun.COM caddr_t c_saddr3; 2527387SRobert.Gordon@Sun.COM } w; 2530Sstevel@tonic-gate struct mrc c_dmemhandle; /* dst memory handle */ 2540Sstevel@tonic-gate uint64 c_dsynchandle; /* dst sync handle */ 2557387SRobert.Gordon@Sun.COM union { 2567387SRobert.Gordon@Sun.COM uint64 c_daddr; /* dst address */ 2577387SRobert.Gordon@Sun.COM caddr_t c_daddr3; 2587387SRobert.Gordon@Sun.COM } u; 2597387SRobert.Gordon@Sun.COM struct as *c_adspc; /* address space for saddr/daddr */ 2607387SRobert.Gordon@Sun.COM rdma_buf_t rb_longbuf; /* used for long requests/replies */ 2610Sstevel@tonic-gate struct clist *c_next; /* Next chunk */ 2620Sstevel@tonic-gate }; 2630Sstevel@tonic-gate 2640Sstevel@tonic-gate typedef struct clist clist; 2650Sstevel@tonic-gate 2667387SRobert.Gordon@Sun.COM /* 2677387SRobert.Gordon@Sun.COM * max 4M wlist xfer size 2687387SRobert.Gordon@Sun.COM * This is defined because the rfs3_tsize service requires 2697387SRobert.Gordon@Sun.COM * svc_req struct (which we don't have that in krecv). 2707387SRobert.Gordon@Sun.COM */ 2717387SRobert.Gordon@Sun.COM #define MAX_SVC_XFER_SIZE (4*1024*1024) 2727387SRobert.Gordon@Sun.COM 2730Sstevel@tonic-gate enum rdma_proc { 2740Sstevel@tonic-gate RDMA_MSG = 0, /* chunk list and RPC msg follow */ 2750Sstevel@tonic-gate RDMA_NOMSG = 1, /* only chunk list follows */ 2760Sstevel@tonic-gate RDMA_MSGP = 2, /* chunk list and RPC msg with padding follow */ 2770Sstevel@tonic-gate RDMA_DONE = 3 /* signal completion of chunk transfer */ 2780Sstevel@tonic-gate }; 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate /* 2810Sstevel@tonic-gate * Listener information for a service 2820Sstevel@tonic-gate */ 2830Sstevel@tonic-gate struct rdma_svc_data { 2840Sstevel@tonic-gate queue_t q; /* queue_t to place incoming pkts */ 2850Sstevel@tonic-gate int active; /* If active, after registeration startup */ 2860Sstevel@tonic-gate rdma_stat err_code; /* Error code from plugin layer */ 2870Sstevel@tonic-gate int32_t svcid; /* RDMA based service identifier */ 2880Sstevel@tonic-gate }; 2890Sstevel@tonic-gate 2900Sstevel@tonic-gate /* 2910Sstevel@tonic-gate * Per RDMA plugin module information. 2920Sstevel@tonic-gate * Will be populated by each plugin 2930Sstevel@tonic-gate * module during its initialization. 2940Sstevel@tonic-gate */ 2950Sstevel@tonic-gate typedef struct rdma_mod { 2960Sstevel@tonic-gate char *rdma_api; /* "kvipl", "ibtf", etc */ 2970Sstevel@tonic-gate uint_t rdma_version; /* RDMATF API version */ 2980Sstevel@tonic-gate int rdma_count; /* # of devices */ 2990Sstevel@tonic-gate struct rdmaops *rdma_ops; /* rdma op vector for api */ 3000Sstevel@tonic-gate } rdma_mod_t; 3010Sstevel@tonic-gate 3020Sstevel@tonic-gate /* 3030Sstevel@tonic-gate * Registry of RDMA plugins 3040Sstevel@tonic-gate */ 3050Sstevel@tonic-gate typedef struct rdma_registry { 3060Sstevel@tonic-gate rdma_mod_t *r_mod; /* plugin mod info */ 3078695SRajkumar.Sivaprakasam@Sun.COM uint32_t r_mod_state; 3080Sstevel@tonic-gate struct rdma_registry *r_next; /* next registered RDMA plugin */ 3090Sstevel@tonic-gate } rdma_registry_t; 3100Sstevel@tonic-gate 3110Sstevel@tonic-gate /* 3128695SRajkumar.Sivaprakasam@Sun.COM * RDMA MODULE state flags (r_mod_state). 3138695SRajkumar.Sivaprakasam@Sun.COM */ 3148695SRajkumar.Sivaprakasam@Sun.COM #define RDMA_MOD_ACTIVE 1 3158695SRajkumar.Sivaprakasam@Sun.COM #define RDMA_MOD_INACTIVE 0 3168695SRajkumar.Sivaprakasam@Sun.COM 3178695SRajkumar.Sivaprakasam@Sun.COM /* 3180Sstevel@tonic-gate * RDMA transport information 3190Sstevel@tonic-gate */ 3200Sstevel@tonic-gate typedef struct rdma_info { 3210Sstevel@tonic-gate uint_t addrlen; /* address length */ 3220Sstevel@tonic-gate uint_t mts; /* max transfer size */ 3230Sstevel@tonic-gate uint_t mtu; /* native mtu size of unlerlying network */ 3240Sstevel@tonic-gate } rdma_info_t; 3250Sstevel@tonic-gate 3267387SRobert.Gordon@Sun.COM typedef enum { 3277387SRobert.Gordon@Sun.COM C_IDLE = 0x00000001, 3287387SRobert.Gordon@Sun.COM C_CONN_PEND = 0x00000002, 3297387SRobert.Gordon@Sun.COM C_CONNECTED = 0x00000004, 3307387SRobert.Gordon@Sun.COM C_ERROR_CONN = 0x00000008, 3317387SRobert.Gordon@Sun.COM C_DISCONN_PEND = 0x00000010, 3327387SRobert.Gordon@Sun.COM C_REMOTE_DOWN = 0x00000020 3337387SRobert.Gordon@Sun.COM } conn_c_state; 3347387SRobert.Gordon@Sun.COM 3359723SSiddheshwar.Mahesh@Sun.COM /* c_flags */ 3369723SSiddheshwar.Mahesh@Sun.COM #define C_CLOSE_NOTNEEDED 0x00000001 /* just free the channel */ 3379723SSiddheshwar.Mahesh@Sun.COM #define C_CLOSE_PENDING 0x00000002 /* a close in progress */ 3389723SSiddheshwar.Mahesh@Sun.COM 3390Sstevel@tonic-gate /* 3400Sstevel@tonic-gate * RDMA Connection information 3410Sstevel@tonic-gate */ 3420Sstevel@tonic-gate typedef struct conn { 3430Sstevel@tonic-gate rdma_mod_t *c_rdmamod; /* RDMA transport info for conn */ 34410326SSiddheshwar.Mahesh@Sun.COM char *c_netid; /* tcp or tcp6 token */ 3450Sstevel@tonic-gate struct netbuf c_raddr; /* remote address */ 3460Sstevel@tonic-gate struct netbuf c_laddr; /* local address */ 347*12553SKaren.Rochford@Sun.COM struct netbuf c_addrmask; /* Address Mask */ 3480Sstevel@tonic-gate int c_ref; /* no. of clients of connection */ 3490Sstevel@tonic-gate struct conn *c_next; /* next in list of connections */ 3500Sstevel@tonic-gate struct conn *c_prev; /* prev in list of connections */ 3510Sstevel@tonic-gate caddr_t c_private; /* transport specific stuff */ 3527387SRobert.Gordon@Sun.COM conn_c_state c_state; /* state of connection */ 3539723SSiddheshwar.Mahesh@Sun.COM int c_flags; /* flags for connection management */ 3547387SRobert.Gordon@Sun.COM rdma_cc_type_t c_cc_type; /* client or server, for credit cntrl */ 3557387SRobert.Gordon@Sun.COM union { 3567387SRobert.Gordon@Sun.COM rdma_clnt_cred_ctrl_t c_clnt_cc; 3577387SRobert.Gordon@Sun.COM rdma_srv_cred_ctrl_t c_srv_cc; 3587387SRobert.Gordon@Sun.COM } rdma_conn_cred_ctrl_u; 3590Sstevel@tonic-gate kmutex_t c_lock; /* protect c_state and c_ref fields */ 3600Sstevel@tonic-gate kcondvar_t c_cv; /* to signal when pending is done */ 3619723SSiddheshwar.Mahesh@Sun.COM timeout_id_t c_timeout; /* timeout id for untimeout() */ 3629723SSiddheshwar.Mahesh@Sun.COM time_t c_last_used; /* last time any activity on the conn */ 3630Sstevel@tonic-gate } CONN; 3640Sstevel@tonic-gate 3650Sstevel@tonic-gate 3660Sstevel@tonic-gate /* 3670Sstevel@tonic-gate * Data transferred from plugin interrupt to svc_queuereq() 3680Sstevel@tonic-gate */ 3697387SRobert.Gordon@Sun.COM typedef struct rdma_recv_data { 3700Sstevel@tonic-gate CONN *conn; 3710Sstevel@tonic-gate int status; 3720Sstevel@tonic-gate rdma_buf_t rpcmsg; 3737387SRobert.Gordon@Sun.COM } rdma_recv_data_t; 3747387SRobert.Gordon@Sun.COM 3757387SRobert.Gordon@Sun.COM /* structure used to pass information for READ over rdma write */ 3767387SRobert.Gordon@Sun.COM typedef enum { 3777387SRobert.Gordon@Sun.COM RCI_WRITE_UIO_CHUNK = 1, 3787387SRobert.Gordon@Sun.COM RCI_WRITE_ADDR_CHUNK = 2, 3797387SRobert.Gordon@Sun.COM RCI_REPLY_CHUNK = 3 3807387SRobert.Gordon@Sun.COM } rci_type_t; 3817387SRobert.Gordon@Sun.COM 3827387SRobert.Gordon@Sun.COM typedef struct { 3837387SRobert.Gordon@Sun.COM rci_type_t rci_type; 3847387SRobert.Gordon@Sun.COM union { 3857387SRobert.Gordon@Sun.COM struct uio *rci_uiop; 3867387SRobert.Gordon@Sun.COM caddr_t rci_addr; 3877387SRobert.Gordon@Sun.COM } rci_a; 3887387SRobert.Gordon@Sun.COM uint32 rci_len; 3897387SRobert.Gordon@Sun.COM struct clist **rci_clpp; /* point to write chunk list in readargs */ 3907387SRobert.Gordon@Sun.COM } rdma_chunkinfo_t; 3917387SRobert.Gordon@Sun.COM 3927387SRobert.Gordon@Sun.COM typedef struct { 3937387SRobert.Gordon@Sun.COM uint_t rcil_len; 3947387SRobert.Gordon@Sun.COM uint_t rcil_len_alt; 3957387SRobert.Gordon@Sun.COM } rdma_chunkinfo_lengths_t; 3967387SRobert.Gordon@Sun.COM 3977387SRobert.Gordon@Sun.COM typedef struct { 3987387SRobert.Gordon@Sun.COM struct clist *rwci_wlist; 3997387SRobert.Gordon@Sun.COM CONN *rwci_conn; 4007387SRobert.Gordon@Sun.COM } rdma_wlist_conn_info_t; 4010Sstevel@tonic-gate 4020Sstevel@tonic-gate /* 4030Sstevel@tonic-gate * Operations vector for RDMA transports. 4040Sstevel@tonic-gate */ 4050Sstevel@tonic-gate typedef struct rdmaops { 4060Sstevel@tonic-gate /* Network */ 4070Sstevel@tonic-gate rdma_stat (*rdma_reachable)(int addr_type, struct netbuf *, 4080Sstevel@tonic-gate void **handle); 4090Sstevel@tonic-gate /* Connection */ 4109733SFaramarz.Jalalian@Sun.COM rdma_stat (*rdma_get_conn)(struct netbuf *, struct netbuf *, 4119733SFaramarz.Jalalian@Sun.COM int addr_type, void *, CONN **); 4120Sstevel@tonic-gate rdma_stat (*rdma_rel_conn)(CONN *); 4130Sstevel@tonic-gate /* Server side listner start and stop routines */ 4140Sstevel@tonic-gate void (*rdma_svc_listen)(struct rdma_svc_data *); 4150Sstevel@tonic-gate void (*rdma_svc_stop)(struct rdma_svc_data *); 4160Sstevel@tonic-gate /* Memory */ 4177387SRobert.Gordon@Sun.COM rdma_stat (*rdma_regmem)(CONN *, caddr_t, caddr_t, 4187387SRobert.Gordon@Sun.COM uint_t, struct mrc *); 4190Sstevel@tonic-gate rdma_stat (*rdma_deregmem)(CONN *, caddr_t, struct mrc); 4207387SRobert.Gordon@Sun.COM rdma_stat (*rdma_regmemsync)(CONN *, caddr_t, caddr_t, uint_t, 4217387SRobert.Gordon@Sun.COM struct mrc *, void **, void *); 4220Sstevel@tonic-gate rdma_stat (*rdma_deregmemsync)(CONN *, caddr_t, struct mrc, 4237387SRobert.Gordon@Sun.COM void *, void *); 4240Sstevel@tonic-gate rdma_stat (*rdma_syncmem)(CONN *, void *, caddr_t, int, int); 4250Sstevel@tonic-gate /* Buffer */ 4260Sstevel@tonic-gate rdma_stat (*rdma_buf_alloc)(CONN *, rdma_buf_t *); 4270Sstevel@tonic-gate void (*rdma_buf_free)(CONN *, rdma_buf_t *); 4280Sstevel@tonic-gate /* Transfer */ 4290Sstevel@tonic-gate rdma_stat (*rdma_send)(CONN *, clist *, uint32_t); 4300Sstevel@tonic-gate rdma_stat (*rdma_send_resp)(CONN *, clist *, uint32_t); 4310Sstevel@tonic-gate rdma_stat (*rdma_clnt_recvbuf)(CONN *, clist *, uint32_t); 4327387SRobert.Gordon@Sun.COM rdma_stat (*rdma_clnt_recvbuf_remove)(CONN *, uint32_t); 4330Sstevel@tonic-gate rdma_stat (*rdma_svc_recvbuf)(CONN *, clist *); 4340Sstevel@tonic-gate rdma_stat (*rdma_recv)(CONN *, clist **, uint32_t); 4350Sstevel@tonic-gate /* RDMA */ 4360Sstevel@tonic-gate rdma_stat (*rdma_read)(CONN *, clist *, int); 4370Sstevel@tonic-gate rdma_stat (*rdma_write)(CONN *, clist *, int); 4380Sstevel@tonic-gate /* INFO */ 4390Sstevel@tonic-gate rdma_stat (*rdma_getinfo)(rdma_info_t *info); 4400Sstevel@tonic-gate } rdmaops_t; 4410Sstevel@tonic-gate 4428695SRajkumar.Sivaprakasam@Sun.COM typedef struct rdma_svc_wait { 4438695SRajkumar.Sivaprakasam@Sun.COM kmutex_t svc_lock; 4448695SRajkumar.Sivaprakasam@Sun.COM kcondvar_t svc_cv; 4458695SRajkumar.Sivaprakasam@Sun.COM rdma_stat svc_stat; 4468695SRajkumar.Sivaprakasam@Sun.COM } rdma_svc_wait_t; 4478695SRajkumar.Sivaprakasam@Sun.COM 4488695SRajkumar.Sivaprakasam@Sun.COM extern rdma_svc_wait_t rdma_wait; 4498695SRajkumar.Sivaprakasam@Sun.COM 4500Sstevel@tonic-gate /* 4510Sstevel@tonic-gate * RDMA operations. 4520Sstevel@tonic-gate */ 4530Sstevel@tonic-gate #define RDMA_REACHABLE(rdma_ops, addr_type, addr, handle) \ 4540Sstevel@tonic-gate (*(rdma_ops)->rdma_reachable)(addr_type, addr, handle) 4550Sstevel@tonic-gate 4569733SFaramarz.Jalalian@Sun.COM #define RDMA_GET_CONN(rdma_ops, saddr, daddr, addr_type, handle, conn) \ 4579733SFaramarz.Jalalian@Sun.COM (*(rdma_ops)->rdma_get_conn)(saddr, daddr, addr_type, handle, conn) 4580Sstevel@tonic-gate 4590Sstevel@tonic-gate #define RDMA_REL_CONN(conn) \ 4600Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_rel_conn)(conn) 4610Sstevel@tonic-gate 4627387SRobert.Gordon@Sun.COM #define RDMA_REGMEM(conn, adsp, buff, len, handle) \ 4637387SRobert.Gordon@Sun.COM (*(conn)->c_rdmamod->rdma_ops->rdma_regmem)(conn, adsp, \ 4647387SRobert.Gordon@Sun.COM buff, len, handle) 4650Sstevel@tonic-gate 4660Sstevel@tonic-gate #define RDMA_DEREGMEM(conn, buff, handle) \ 4670Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_deregmem)(conn, buff, handle) 4680Sstevel@tonic-gate 4697387SRobert.Gordon@Sun.COM #define RDMA_REGMEMSYNC(conn, adsp, buff, len, handle, synchandle, lrc) \ 4707387SRobert.Gordon@Sun.COM (*(conn)->c_rdmamod->rdma_ops->rdma_regmemsync)(conn, adsp, buff, \ 4717387SRobert.Gordon@Sun.COM len, handle, synchandle, lrc) 4720Sstevel@tonic-gate 4737387SRobert.Gordon@Sun.COM #define RDMA_DEREGMEMSYNC(conn, buff, handle, synchandle, lrc) \ 4747387SRobert.Gordon@Sun.COM (*(conn)->c_rdmamod->rdma_ops->rdma_deregmemsync)(conn, buff, \ 4757387SRobert.Gordon@Sun.COM handle, synchandle, lrc) 4760Sstevel@tonic-gate 4770Sstevel@tonic-gate #define RDMA_SYNCMEM(conn, handle, buff, len, direction) \ 4780Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_syncmem)(conn, handle, \ 4790Sstevel@tonic-gate buff, len, direction) 4800Sstevel@tonic-gate 4810Sstevel@tonic-gate #define RDMA_BUF_ALLOC(conn, rbuf) \ 4820Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_buf_alloc)(conn, rbuf) 4830Sstevel@tonic-gate 4840Sstevel@tonic-gate #define RDMA_BUF_FREE(conn, rbuf) \ 4850Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_buf_free)(conn, rbuf) 4860Sstevel@tonic-gate 4870Sstevel@tonic-gate #define RDMA_SEND(conn, sendlist, xid) \ 4880Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_send)(conn, sendlist, xid) 4890Sstevel@tonic-gate 4900Sstevel@tonic-gate #define RDMA_SEND_RESP(conn, sendlist, xid) \ 4910Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_send_resp)(conn, sendlist, xid) 4920Sstevel@tonic-gate 4930Sstevel@tonic-gate #define RDMA_CLNT_RECVBUF(conn, cl, xid) \ 4940Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_clnt_recvbuf)(conn, cl, xid) 4950Sstevel@tonic-gate 4967387SRobert.Gordon@Sun.COM #define RDMA_CLNT_RECVBUF_REMOVE(conn, xid) \ 4977387SRobert.Gordon@Sun.COM (*(conn)->c_rdmamod->rdma_ops->rdma_clnt_recvbuf_remove)(conn, xid) 4987387SRobert.Gordon@Sun.COM 4990Sstevel@tonic-gate #define RDMA_SVC_RECVBUF(conn, cl) \ 5000Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_svc_recvbuf)(conn, cl) 5010Sstevel@tonic-gate 5020Sstevel@tonic-gate #define RDMA_RECV(conn, recvlist, xid) \ 5030Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_recv)(conn, recvlist, xid) 5040Sstevel@tonic-gate 5050Sstevel@tonic-gate #define RDMA_READ(conn, cl, wait) \ 5060Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_read)(conn, cl, wait) 5070Sstevel@tonic-gate 5080Sstevel@tonic-gate #define RDMA_WRITE(conn, cl, wait) \ 5090Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_write)(conn, cl, wait) 5100Sstevel@tonic-gate 5110Sstevel@tonic-gate #define RDMA_GETINFO(rdma_mod, info) \ 5120Sstevel@tonic-gate (*(rdma_mod)->rdma_ops->rdma_getinfo)(info) 5130Sstevel@tonic-gate 5140Sstevel@tonic-gate #ifdef _KERNEL 5150Sstevel@tonic-gate extern rdma_registry_t *rdma_mod_head; 5160Sstevel@tonic-gate extern krwlock_t rdma_lock; /* protects rdma_mod_head list */ 5170Sstevel@tonic-gate extern int rdma_modloaded; /* flag for loading RDMA plugins */ 5180Sstevel@tonic-gate extern int rdma_dev_available; /* rdma device is loaded or not */ 5190Sstevel@tonic-gate extern kmutex_t rdma_modload_lock; /* protects rdma_modloaded flag */ 5200Sstevel@tonic-gate extern uint_t rdma_minchunk; 5210Sstevel@tonic-gate extern ldi_ident_t rpcmod_li; /* needed by layed driver framework */ 5220Sstevel@tonic-gate 5230Sstevel@tonic-gate /* 5240Sstevel@tonic-gate * General RDMA routines 5250Sstevel@tonic-gate */ 5267387SRobert.Gordon@Sun.COM extern struct clist *clist_alloc(void); 5277387SRobert.Gordon@Sun.COM extern void clist_add(struct clist **, uint32_t, int, 5287387SRobert.Gordon@Sun.COM struct mrc *, caddr_t, struct mrc *, caddr_t); 5297387SRobert.Gordon@Sun.COM extern void clist_free(struct clist *); 5309348SSiddheshwar.Mahesh@Sun.COM extern uint32_t clist_len(struct clist *); 5319348SSiddheshwar.Mahesh@Sun.COM extern void clist_zero_len(struct clist *); 5327387SRobert.Gordon@Sun.COM extern rdma_stat clist_register(CONN *conn, struct clist *cl, clist_dstsrc); 5339348SSiddheshwar.Mahesh@Sun.COM extern rdma_stat clist_deregister(CONN *conn, struct clist *cl); 5347387SRobert.Gordon@Sun.COM extern rdma_stat clist_syncmem(CONN *conn, struct clist *cl, clist_dstsrc); 5357387SRobert.Gordon@Sun.COM extern rdma_stat rdma_clnt_postrecv(CONN *conn, uint32_t xid); 5367387SRobert.Gordon@Sun.COM extern rdma_stat rdma_clnt_postrecv_remove(CONN *conn, uint32_t xid); 5377387SRobert.Gordon@Sun.COM extern rdma_stat rdma_svc_postrecv(CONN *conn); 5380Sstevel@tonic-gate extern rdma_stat rdma_register_mod(rdma_mod_t *mod); 5390Sstevel@tonic-gate extern rdma_stat rdma_unregister_mod(rdma_mod_t *mod); 5407387SRobert.Gordon@Sun.COM extern rdma_stat rdma_buf_alloc(CONN *, rdma_buf_t *); 5417387SRobert.Gordon@Sun.COM extern void rdma_buf_free(CONN *, rdma_buf_t *); 5420Sstevel@tonic-gate extern int rdma_modload(); 5437387SRobert.Gordon@Sun.COM extern bool_t rdma_get_wchunk(struct svc_req *, iovec_t *, struct clist *); 5448695SRajkumar.Sivaprakasam@Sun.COM extern rdma_stat rdma_kwait(void); 5459348SSiddheshwar.Mahesh@Sun.COM extern int rdma_setup_read_chunks(struct clist *, uint32_t, int *); 5460Sstevel@tonic-gate 5470Sstevel@tonic-gate /* 5480Sstevel@tonic-gate * RDMA XDR 5490Sstevel@tonic-gate */ 5500Sstevel@tonic-gate extern void xdrrdma_create(XDR *, caddr_t, uint_t, int, struct clist *, 5510Sstevel@tonic-gate enum xdr_op, CONN *); 5520Sstevel@tonic-gate extern void xdrrdma_destroy(XDR *); 5537387SRobert.Gordon@Sun.COM 5540Sstevel@tonic-gate extern uint_t xdrrdma_getpos(XDR *); 5550Sstevel@tonic-gate extern bool_t xdrrdma_setpos(XDR *, uint_t); 5560Sstevel@tonic-gate extern bool_t xdr_clist(XDR *, clist *); 5570Sstevel@tonic-gate extern bool_t xdr_do_clist(XDR *, clist **); 5580Sstevel@tonic-gate extern uint_t xdr_getbufsize(XDR *); 5597387SRobert.Gordon@Sun.COM extern unsigned int xdrrdma_sizeof(xdrproc_t, void *, int, uint_t *, uint_t *); 5607387SRobert.Gordon@Sun.COM extern unsigned int xdrrdma_authsize(AUTH *, struct cred *, int); 5617387SRobert.Gordon@Sun.COM 5627387SRobert.Gordon@Sun.COM extern void xdrrdma_store_wlist(XDR *, struct clist *); 5637387SRobert.Gordon@Sun.COM extern struct clist *xdrrdma_wclist(XDR *); 5647387SRobert.Gordon@Sun.COM extern bool_t xdr_decode_reply_wchunk(XDR *, struct clist **); 5657387SRobert.Gordon@Sun.COM extern bool_t xdr_decode_wlist(XDR *xdrs, struct clist **, bool_t *); 5667387SRobert.Gordon@Sun.COM extern bool_t xdr_decode_wlist_svc(XDR *xdrs, struct clist **, bool_t *, 5677387SRobert.Gordon@Sun.COM uint32_t *, CONN *); 5687387SRobert.Gordon@Sun.COM extern bool_t xdr_encode_rlist_svc(XDR *, clist *); 5697387SRobert.Gordon@Sun.COM extern bool_t xdr_encode_wlist(XDR *, clist *); 5707387SRobert.Gordon@Sun.COM extern bool_t xdr_encode_reply_wchunk(XDR *, struct clist *, 5717387SRobert.Gordon@Sun.COM uint32_t seg_array_len); 5727387SRobert.Gordon@Sun.COM bool_t xdrrdma_getrdmablk(XDR *, struct clist **, uint_t *, 5737387SRobert.Gordon@Sun.COM CONN **conn, const uint_t); 5749348SSiddheshwar.Mahesh@Sun.COM bool_t xdrrdma_read_from_client(struct clist *, CONN **, uint_t); 5759348SSiddheshwar.Mahesh@Sun.COM bool_t xdrrdma_send_read_data(XDR *, uint_t, struct clist *); 5767387SRobert.Gordon@Sun.COM bool_t xdrrdma_free_clist(CONN *, struct clist *); 5770Sstevel@tonic-gate #endif /* _KERNEL */ 5780Sstevel@tonic-gate 5790Sstevel@tonic-gate #ifdef __cplusplus 5800Sstevel@tonic-gate } 5810Sstevel@tonic-gate #endif 5820Sstevel@tonic-gate 5830Sstevel@tonic-gate #endif /* _RPC_RPC_RDMA_H */ 584