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 5*7387SRobert.Gordon@Sun.COM * Common Development and Distribution License (the "License"). 6*7387SRobert.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*7387SRobert.Gordon@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 26*7387SRobert.Gordon@Sun.COM /* 27*7387SRobert.Gordon@Sun.COM * Copyright (c) 2007, The Ohio State University. All rights reserved. 28*7387SRobert.Gordon@Sun.COM * 29*7387SRobert.Gordon@Sun.COM * Portions of this source code is developed by the team members of 30*7387SRobert.Gordon@Sun.COM * The Ohio State University's Network-Based Computing Laboratory (NBCL), 31*7387SRobert.Gordon@Sun.COM * headed by Professor Dhabaleswar K. (DK) Panda. 32*7387SRobert.Gordon@Sun.COM * 33*7387SRobert.Gordon@Sun.COM * Acknowledgements to contributions from developors: 34*7387SRobert.Gordon@Sun.COM * Ranjit Noronha: noronha@cse.ohio-state.edu 35*7387SRobert.Gordon@Sun.COM * Lei Chai : chail@cse.ohio-state.edu 36*7387SRobert.Gordon@Sun.COM * Weikuan Yu : yuw@cse.ohio-state.edu 37*7387SRobert.Gordon@Sun.COM * 38*7387SRobert.Gordon@Sun.COM */ 39*7387SRobert.Gordon@Sun.COM 400Sstevel@tonic-gate #ifndef _RPC_RPC_RDMA_H 410Sstevel@tonic-gate #define _RPC_RPC_RDMA_H 420Sstevel@tonic-gate 430Sstevel@tonic-gate #include <rpc/rpc.h> 440Sstevel@tonic-gate #include <rpc/rpc_sztypes.h> 450Sstevel@tonic-gate #include <sys/sunddi.h> 460Sstevel@tonic-gate #include <sys/sunldi.h> 470Sstevel@tonic-gate 480Sstevel@tonic-gate #ifdef __cplusplus 490Sstevel@tonic-gate extern "C" { 500Sstevel@tonic-gate #endif 510Sstevel@tonic-gate 52*7387SRobert.Gordon@Sun.COM #define RPCRDMA_VERS 1 /* Version of the RPC over RDMA protocol */ 530Sstevel@tonic-gate #define RDMATF_VERS 1 /* Version of the API used by RPC for RDMA */ 540Sstevel@tonic-gate #define RDMATF_VERS_1 1 /* Current version of RDMATF */ 550Sstevel@tonic-gate 560Sstevel@tonic-gate /* 570Sstevel@tonic-gate * The size of an RPC call or reply message 580Sstevel@tonic-gate */ 59*7387SRobert.Gordon@Sun.COM #define RPC_MSG_SZ 1024 60*7387SRobert.Gordon@Sun.COM 61*7387SRobert.Gordon@Sun.COM /* 62*7387SRobert.Gordon@Sun.COM * RDMA chunk size 63*7387SRobert.Gordon@Sun.COM */ 64*7387SRobert.Gordon@Sun.COM #define RDMA_MINCHUNK 1024 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* 670Sstevel@tonic-gate * Storage for a chunk list 680Sstevel@tonic-gate */ 690Sstevel@tonic-gate #define RPC_CL_SZ 1024 700Sstevel@tonic-gate 710Sstevel@tonic-gate /* 720Sstevel@tonic-gate * Chunk size 730Sstevel@tonic-gate */ 740Sstevel@tonic-gate #define MINCHUNK 1024 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* 770Sstevel@tonic-gate * Size of receive buffer 780Sstevel@tonic-gate */ 790Sstevel@tonic-gate #define RPC_BUF_SIZE 2048 800Sstevel@tonic-gate 810Sstevel@tonic-gate #define NOWAIT 0 /* don't wait for operation of complete */ 820Sstevel@tonic-gate #define WAIT 1 /* wait and ensure that operation is complete */ 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * RDMA xdr buffer control and other control flags. Add new flags here, 860Sstevel@tonic-gate * set them in private structure for xdr over RDMA in xdr_rdma.c 870Sstevel@tonic-gate */ 88*7387SRobert.Gordon@Sun.COM #define XDR_RDMA_CHUNK 0x1 89*7387SRobert.Gordon@Sun.COM #define XDR_RDMA_WLIST_REG 0x2 90*7387SRobert.Gordon@Sun.COM #define XDR_RDMA_RLIST_REG 0x4 91*7387SRobert.Gordon@Sun.COM 92*7387SRobert.Gordon@Sun.COM #define LONG_REPLY_LEN 65536 93*7387SRobert.Gordon@Sun.COM #define WCL_BUF_LEN 32768 94*7387SRobert.Gordon@Sun.COM #define RCL_BUF_LEN 32768 95*7387SRobert.Gordon@Sun.COM 96*7387SRobert.Gordon@Sun.COM 97*7387SRobert.Gordon@Sun.COM #define RDMA_BUFS_RQST 34 /* Num bufs requested by client */ 98*7387SRobert.Gordon@Sun.COM #define RDMA_BUFS_GRANT 32 /* Num bufs granted by server */ 99*7387SRobert.Gordon@Sun.COM 100*7387SRobert.Gordon@Sun.COM struct xdr_ops *xdrrdma_xops(void); 101*7387SRobert.Gordon@Sun.COM 102*7387SRobert.Gordon@Sun.COM /* 103*7387SRobert.Gordon@Sun.COM * Credit Control Structures. 104*7387SRobert.Gordon@Sun.COM */ 105*7387SRobert.Gordon@Sun.COM typedef enum rdma_cc_type { 106*7387SRobert.Gordon@Sun.COM RDMA_CC_CLNT, /* CONN is for a client */ 107*7387SRobert.Gordon@Sun.COM RDMA_CC_SRV /* CONN is for a server */ 108*7387SRobert.Gordon@Sun.COM } rdma_cc_type_t; 109*7387SRobert.Gordon@Sun.COM 110*7387SRobert.Gordon@Sun.COM /* 111*7387SRobert.Gordon@Sun.COM * Client side credit control data structure. 112*7387SRobert.Gordon@Sun.COM */ 113*7387SRobert.Gordon@Sun.COM typedef struct rdma_clnt_cred_ctrl { 114*7387SRobert.Gordon@Sun.COM uint32_t clnt_cc_granted_ops; 115*7387SRobert.Gordon@Sun.COM uint32_t clnt_cc_in_flight_ops; 116*7387SRobert.Gordon@Sun.COM kcondvar_t clnt_cc_cv; 117*7387SRobert.Gordon@Sun.COM } rdma_clnt_cred_ctrl_t; 118*7387SRobert.Gordon@Sun.COM 119*7387SRobert.Gordon@Sun.COM /* 120*7387SRobert.Gordon@Sun.COM * Server side credit control data structure. 121*7387SRobert.Gordon@Sun.COM */ 122*7387SRobert.Gordon@Sun.COM typedef struct rdma_srv_cred_ctrl { 123*7387SRobert.Gordon@Sun.COM uint32_t srv_cc_buffers_granted; 124*7387SRobert.Gordon@Sun.COM uint32_t srv_cc_cur_buffers_used; 125*7387SRobert.Gordon@Sun.COM uint32_t srv_cc_posted; 126*7387SRobert.Gordon@Sun.COM uint32_t srv_cc_max_buf_size; /* to be determined by CCP */ 127*7387SRobert.Gordon@Sun.COM uint32_t srv_cc_cur_buf_size; /* to be determined by CCP */ 128*7387SRobert.Gordon@Sun.COM } rdma_srv_cred_ctrl_t; 129*7387SRobert.Gordon@Sun.COM 130*7387SRobert.Gordon@Sun.COM typedef enum { 131*7387SRobert.Gordon@Sun.COM RPCCALL_WLIST, 132*7387SRobert.Gordon@Sun.COM RPCCALL_WCHUNK, 133*7387SRobert.Gordon@Sun.COM RPCCALL_NOWRITE 134*7387SRobert.Gordon@Sun.COM }rpccall_write_t; 135*7387SRobert.Gordon@Sun.COM 136*7387SRobert.Gordon@Sun.COM typedef enum { 137*7387SRobert.Gordon@Sun.COM CLIST_REG_SOURCE, 138*7387SRobert.Gordon@Sun.COM CLIST_REG_DST 139*7387SRobert.Gordon@Sun.COM } clist_dstsrc; 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate /* 1420Sstevel@tonic-gate * Return codes from RDMA operations 1430Sstevel@tonic-gate */ 1440Sstevel@tonic-gate typedef enum { 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate RDMA_SUCCESS = 0, /* successful operation */ 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate RDMA_INVAL = 1, /* invalid parameter */ 1490Sstevel@tonic-gate RDMA_TIMEDOUT = 2, /* operation timed out */ 1500Sstevel@tonic-gate RDMA_INTR = 3, /* operation interrupted */ 1510Sstevel@tonic-gate RDMA_NORESOURCE = 4, /* insufficient resource */ 1520Sstevel@tonic-gate /* 1530Sstevel@tonic-gate * connection errors 1540Sstevel@tonic-gate */ 1550Sstevel@tonic-gate RDMA_REJECT = 5, /* connection req rejected */ 1560Sstevel@tonic-gate RDMA_NOLISTENER = 6, /* no listener on server */ 1570Sstevel@tonic-gate RDMA_UNREACHABLE = 7, /* host unreachable */ 1580Sstevel@tonic-gate RDMA_CONNLOST = 8, /* connection lost */ 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate RDMA_XPRTFAILED = 9, /* RDMA transport failed */ 1610Sstevel@tonic-gate RDMA_PROTECTERR = 10, /* memory protection error */ 1620Sstevel@tonic-gate RDMA_OVERRUN = 11, /* transport overrun */ 1630Sstevel@tonic-gate RDMA_RECVQEMPTY = 12, /* incoming pkt dropped, recv q empty */ 1640Sstevel@tonic-gate RDMA_PROTFAILED = 13, /* RDMA protocol failed */ 1650Sstevel@tonic-gate RDMA_NOTSUPP = 14, /* requested feature not supported */ 1660Sstevel@tonic-gate RDMA_REMOTERR = 15, /* error at remote end */ 1670Sstevel@tonic-gate /* 1680Sstevel@tonic-gate * RDMATF errors 1690Sstevel@tonic-gate */ 1700Sstevel@tonic-gate RDMA_BADVERS = 16, /* mismatch RDMATF versions */ 1710Sstevel@tonic-gate RDMA_REG_EXIST = 17, /* RDMATF registration already exists */ 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate /* 1740Sstevel@tonic-gate * fallback error 1750Sstevel@tonic-gate */ 1760Sstevel@tonic-gate RDMA_FAILED = 18 /* generic error */ 1770Sstevel@tonic-gate } rdma_stat; 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate /* 1800Sstevel@tonic-gate * Memory region context. This is an RDMA provider generated 1810Sstevel@tonic-gate * handle for a registered arbitrary size contiguous virtual 1820Sstevel@tonic-gate * memory. The RDMA Interface Adapter needs this for local or 1830Sstevel@tonic-gate * remote memory access. 1840Sstevel@tonic-gate * 1850Sstevel@tonic-gate * The mrc_rmr field holds the remote memory region context 1860Sstevel@tonic-gate * which is sent over-the-wire to provide the remote host 1870Sstevel@tonic-gate * with RDMA access to the memory region. 1880Sstevel@tonic-gate */ 1890Sstevel@tonic-gate struct mrc { 1900Sstevel@tonic-gate uint32_t mrc_rmr; /* Remote MR context, sent OTW */ 1910Sstevel@tonic-gate union { 1920Sstevel@tonic-gate struct mr { 1930Sstevel@tonic-gate uint32_t lmr; /* Local MR context */ 1940Sstevel@tonic-gate uint64_t linfo; /* Local memory info */ 1950Sstevel@tonic-gate } mr; 1960Sstevel@tonic-gate } lhdl; 1970Sstevel@tonic-gate }; 1980Sstevel@tonic-gate 1990Sstevel@tonic-gate #define mrc_lmr lhdl.mr.lmr 2000Sstevel@tonic-gate #define mrc_linfo lhdl.mr.linfo 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate /* 203*7387SRobert.Gordon@Sun.COM * Memory management for the RDMA buffers 204*7387SRobert.Gordon@Sun.COM */ 205*7387SRobert.Gordon@Sun.COM /* 206*7387SRobert.Gordon@Sun.COM * RDMA buffer types 207*7387SRobert.Gordon@Sun.COM */ 208*7387SRobert.Gordon@Sun.COM typedef enum { 209*7387SRobert.Gordon@Sun.COM SEND_BUFFER, /* buf for send msg */ 210*7387SRobert.Gordon@Sun.COM SEND_DESCRIPTOR, /* buf used for send msg descriptor in plugins only */ 211*7387SRobert.Gordon@Sun.COM RECV_BUFFER, /* buf for recv msg */ 212*7387SRobert.Gordon@Sun.COM RECV_DESCRIPTOR, /* buf used for recv msg descriptor in plugins only */ 213*7387SRobert.Gordon@Sun.COM RDMA_LONG_BUFFER /* chunk buf used in RDMATF only and not in plugins */ 214*7387SRobert.Gordon@Sun.COM } rdma_btype; 215*7387SRobert.Gordon@Sun.COM 216*7387SRobert.Gordon@Sun.COM /* 217*7387SRobert.Gordon@Sun.COM * RDMA buffer information 218*7387SRobert.Gordon@Sun.COM */ 219*7387SRobert.Gordon@Sun.COM typedef struct rdma_buf { 220*7387SRobert.Gordon@Sun.COM rdma_btype type; /* buffer type */ 221*7387SRobert.Gordon@Sun.COM uint_t len; /* length of buffer */ 222*7387SRobert.Gordon@Sun.COM caddr_t addr; /* buffer address */ 223*7387SRobert.Gordon@Sun.COM struct mrc handle; /* buffer registration handle */ 224*7387SRobert.Gordon@Sun.COM caddr_t rb_private; 225*7387SRobert.Gordon@Sun.COM } rdma_buf_t; 226*7387SRobert.Gordon@Sun.COM 227*7387SRobert.Gordon@Sun.COM 228*7387SRobert.Gordon@Sun.COM /* 2290Sstevel@tonic-gate * The XDR offset value is used by the XDR 2300Sstevel@tonic-gate * routine to identify the position in the 2310Sstevel@tonic-gate * RPC message where the opaque object would 2320Sstevel@tonic-gate * normally occur. Neither the data content 2330Sstevel@tonic-gate * of the chunk, nor its size field are included 2340Sstevel@tonic-gate * in the RPC message. The XDR offset is calculated 2350Sstevel@tonic-gate * as if the chunks were present. 2360Sstevel@tonic-gate * 2370Sstevel@tonic-gate * The remaining fields identify the chunk of data 2380Sstevel@tonic-gate * on the sender. The c_memhandle identifies a 2390Sstevel@tonic-gate * registered RDMA memory region and the c_addr 2400Sstevel@tonic-gate * and c_len fields identify the chunk within it. 2410Sstevel@tonic-gate */ 2420Sstevel@tonic-gate struct clist { 2430Sstevel@tonic-gate uint32 c_xdroff; /* XDR offset */ 2440Sstevel@tonic-gate uint32 c_len; /* Length */ 2450Sstevel@tonic-gate struct mrc c_smemhandle; /* src memory handle */ 2460Sstevel@tonic-gate uint64 c_ssynchandle; /* src sync handle */ 247*7387SRobert.Gordon@Sun.COM union { 248*7387SRobert.Gordon@Sun.COM uint64 c_saddr; /* src address */ 249*7387SRobert.Gordon@Sun.COM caddr_t c_saddr3; 250*7387SRobert.Gordon@Sun.COM } w; 2510Sstevel@tonic-gate struct mrc c_dmemhandle; /* dst memory handle */ 2520Sstevel@tonic-gate uint64 c_dsynchandle; /* dst sync handle */ 253*7387SRobert.Gordon@Sun.COM union { 254*7387SRobert.Gordon@Sun.COM uint64 c_daddr; /* dst address */ 255*7387SRobert.Gordon@Sun.COM caddr_t c_daddr3; 256*7387SRobert.Gordon@Sun.COM } u; 257*7387SRobert.Gordon@Sun.COM struct as *c_adspc; /* address space for saddr/daddr */ 258*7387SRobert.Gordon@Sun.COM rdma_buf_t rb_longbuf; /* used for long requests/replies */ 2590Sstevel@tonic-gate struct clist *c_next; /* Next chunk */ 2600Sstevel@tonic-gate }; 2610Sstevel@tonic-gate 2620Sstevel@tonic-gate typedef struct clist clist; 2630Sstevel@tonic-gate 264*7387SRobert.Gordon@Sun.COM /* 265*7387SRobert.Gordon@Sun.COM * max 4M wlist xfer size 266*7387SRobert.Gordon@Sun.COM * This is defined because the rfs3_tsize service requires 267*7387SRobert.Gordon@Sun.COM * svc_req struct (which we don't have that in krecv). 268*7387SRobert.Gordon@Sun.COM */ 269*7387SRobert.Gordon@Sun.COM #define MAX_SVC_XFER_SIZE (4*1024*1024) 270*7387SRobert.Gordon@Sun.COM 2710Sstevel@tonic-gate enum rdma_proc { 2720Sstevel@tonic-gate RDMA_MSG = 0, /* chunk list and RPC msg follow */ 2730Sstevel@tonic-gate RDMA_NOMSG = 1, /* only chunk list follows */ 2740Sstevel@tonic-gate RDMA_MSGP = 2, /* chunk list and RPC msg with padding follow */ 2750Sstevel@tonic-gate RDMA_DONE = 3 /* signal completion of chunk transfer */ 2760Sstevel@tonic-gate }; 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate /* 2790Sstevel@tonic-gate * Listener information for a service 2800Sstevel@tonic-gate */ 2810Sstevel@tonic-gate struct rdma_svc_data { 2820Sstevel@tonic-gate queue_t q; /* queue_t to place incoming pkts */ 2830Sstevel@tonic-gate int active; /* If active, after registeration startup */ 2840Sstevel@tonic-gate rdma_stat err_code; /* Error code from plugin layer */ 2850Sstevel@tonic-gate int32_t svcid; /* RDMA based service identifier */ 2860Sstevel@tonic-gate }; 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate /* 2890Sstevel@tonic-gate * Per RDMA plugin module information. 2900Sstevel@tonic-gate * Will be populated by each plugin 2910Sstevel@tonic-gate * module during its initialization. 2920Sstevel@tonic-gate */ 2930Sstevel@tonic-gate typedef struct rdma_mod { 2940Sstevel@tonic-gate char *rdma_api; /* "kvipl", "ibtf", etc */ 2950Sstevel@tonic-gate uint_t rdma_version; /* RDMATF API version */ 2960Sstevel@tonic-gate int rdma_count; /* # of devices */ 2970Sstevel@tonic-gate struct rdmaops *rdma_ops; /* rdma op vector for api */ 2980Sstevel@tonic-gate } rdma_mod_t; 2990Sstevel@tonic-gate 3000Sstevel@tonic-gate /* 3010Sstevel@tonic-gate * Registry of RDMA plugins 3020Sstevel@tonic-gate */ 3030Sstevel@tonic-gate typedef struct rdma_registry { 3040Sstevel@tonic-gate rdma_mod_t *r_mod; /* plugin mod info */ 3050Sstevel@tonic-gate struct rdma_registry *r_next; /* next registered RDMA plugin */ 3060Sstevel@tonic-gate } rdma_registry_t; 3070Sstevel@tonic-gate 3080Sstevel@tonic-gate /* 3090Sstevel@tonic-gate * RDMA transport information 3100Sstevel@tonic-gate */ 3110Sstevel@tonic-gate typedef struct rdma_info { 3120Sstevel@tonic-gate uint_t addrlen; /* address length */ 3130Sstevel@tonic-gate uint_t mts; /* max transfer size */ 3140Sstevel@tonic-gate uint_t mtu; /* native mtu size of unlerlying network */ 3150Sstevel@tonic-gate } rdma_info_t; 3160Sstevel@tonic-gate 317*7387SRobert.Gordon@Sun.COM typedef enum { 318*7387SRobert.Gordon@Sun.COM C_IDLE = 0x00000001, 319*7387SRobert.Gordon@Sun.COM C_CONN_PEND = 0x00000002, 320*7387SRobert.Gordon@Sun.COM C_CONNECTED = 0x00000004, 321*7387SRobert.Gordon@Sun.COM C_ERROR_CONN = 0x00000008, 322*7387SRobert.Gordon@Sun.COM C_DISCONN_PEND = 0x00000010, 323*7387SRobert.Gordon@Sun.COM C_REMOTE_DOWN = 0x00000020 324*7387SRobert.Gordon@Sun.COM } conn_c_state; 325*7387SRobert.Gordon@Sun.COM 3260Sstevel@tonic-gate /* 3270Sstevel@tonic-gate * RDMA Connection information 3280Sstevel@tonic-gate */ 3290Sstevel@tonic-gate typedef struct conn { 3300Sstevel@tonic-gate rdma_mod_t *c_rdmamod; /* RDMA transport info for conn */ 3310Sstevel@tonic-gate struct netbuf c_raddr; /* remote address */ 3320Sstevel@tonic-gate struct netbuf c_laddr; /* local address */ 3330Sstevel@tonic-gate int c_ref; /* no. of clients of connection */ 3340Sstevel@tonic-gate struct conn *c_next; /* next in list of connections */ 3350Sstevel@tonic-gate struct conn *c_prev; /* prev in list of connections */ 3360Sstevel@tonic-gate caddr_t c_private; /* transport specific stuff */ 337*7387SRobert.Gordon@Sun.COM conn_c_state c_state; /* state of connection */ 338*7387SRobert.Gordon@Sun.COM rdma_cc_type_t c_cc_type; /* client or server, for credit cntrl */ 339*7387SRobert.Gordon@Sun.COM union { 340*7387SRobert.Gordon@Sun.COM rdma_clnt_cred_ctrl_t c_clnt_cc; 341*7387SRobert.Gordon@Sun.COM rdma_srv_cred_ctrl_t c_srv_cc; 342*7387SRobert.Gordon@Sun.COM } rdma_conn_cred_ctrl_u; 3430Sstevel@tonic-gate kmutex_t c_lock; /* protect c_state and c_ref fields */ 3440Sstevel@tonic-gate kcondvar_t c_cv; /* to signal when pending is done */ 3450Sstevel@tonic-gate } CONN; 3460Sstevel@tonic-gate 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate /* 3490Sstevel@tonic-gate * Data transferred from plugin interrupt to svc_queuereq() 3500Sstevel@tonic-gate */ 351*7387SRobert.Gordon@Sun.COM typedef struct rdma_recv_data { 3520Sstevel@tonic-gate CONN *conn; 3530Sstevel@tonic-gate int status; 3540Sstevel@tonic-gate rdma_buf_t rpcmsg; 355*7387SRobert.Gordon@Sun.COM } rdma_recv_data_t; 356*7387SRobert.Gordon@Sun.COM 357*7387SRobert.Gordon@Sun.COM /* structure used to pass information for READ over rdma write */ 358*7387SRobert.Gordon@Sun.COM typedef enum { 359*7387SRobert.Gordon@Sun.COM RCI_WRITE_UIO_CHUNK = 1, 360*7387SRobert.Gordon@Sun.COM RCI_WRITE_ADDR_CHUNK = 2, 361*7387SRobert.Gordon@Sun.COM RCI_REPLY_CHUNK = 3 362*7387SRobert.Gordon@Sun.COM } rci_type_t; 363*7387SRobert.Gordon@Sun.COM 364*7387SRobert.Gordon@Sun.COM typedef struct { 365*7387SRobert.Gordon@Sun.COM rci_type_t rci_type; 366*7387SRobert.Gordon@Sun.COM union { 367*7387SRobert.Gordon@Sun.COM struct uio *rci_uiop; 368*7387SRobert.Gordon@Sun.COM caddr_t rci_addr; 369*7387SRobert.Gordon@Sun.COM } rci_a; 370*7387SRobert.Gordon@Sun.COM uint32 rci_len; 371*7387SRobert.Gordon@Sun.COM struct clist **rci_clpp; /* point to write chunk list in readargs */ 372*7387SRobert.Gordon@Sun.COM } rdma_chunkinfo_t; 373*7387SRobert.Gordon@Sun.COM 374*7387SRobert.Gordon@Sun.COM typedef struct { 375*7387SRobert.Gordon@Sun.COM uint_t rcil_len; 376*7387SRobert.Gordon@Sun.COM uint_t rcil_len_alt; 377*7387SRobert.Gordon@Sun.COM } rdma_chunkinfo_lengths_t; 378*7387SRobert.Gordon@Sun.COM 379*7387SRobert.Gordon@Sun.COM typedef struct { 380*7387SRobert.Gordon@Sun.COM struct clist *rwci_wlist; 381*7387SRobert.Gordon@Sun.COM CONN *rwci_conn; 382*7387SRobert.Gordon@Sun.COM } rdma_wlist_conn_info_t; 3830Sstevel@tonic-gate 3840Sstevel@tonic-gate /* 3850Sstevel@tonic-gate * Operations vector for RDMA transports. 3860Sstevel@tonic-gate */ 3870Sstevel@tonic-gate typedef struct rdmaops { 3880Sstevel@tonic-gate /* Network */ 3890Sstevel@tonic-gate rdma_stat (*rdma_reachable)(int addr_type, struct netbuf *, 3900Sstevel@tonic-gate void **handle); 3910Sstevel@tonic-gate /* Connection */ 3920Sstevel@tonic-gate rdma_stat (*rdma_get_conn)(struct netbuf *, int addr_type, 3930Sstevel@tonic-gate void *, CONN **); 3940Sstevel@tonic-gate rdma_stat (*rdma_rel_conn)(CONN *); 3950Sstevel@tonic-gate /* Server side listner start and stop routines */ 3960Sstevel@tonic-gate void (*rdma_svc_listen)(struct rdma_svc_data *); 3970Sstevel@tonic-gate void (*rdma_svc_stop)(struct rdma_svc_data *); 3980Sstevel@tonic-gate /* Memory */ 399*7387SRobert.Gordon@Sun.COM rdma_stat (*rdma_regmem)(CONN *, caddr_t, caddr_t, 400*7387SRobert.Gordon@Sun.COM uint_t, struct mrc *); 4010Sstevel@tonic-gate rdma_stat (*rdma_deregmem)(CONN *, caddr_t, struct mrc); 402*7387SRobert.Gordon@Sun.COM rdma_stat (*rdma_regmemsync)(CONN *, caddr_t, caddr_t, uint_t, 403*7387SRobert.Gordon@Sun.COM struct mrc *, void **, void *); 4040Sstevel@tonic-gate rdma_stat (*rdma_deregmemsync)(CONN *, caddr_t, struct mrc, 405*7387SRobert.Gordon@Sun.COM void *, void *); 4060Sstevel@tonic-gate rdma_stat (*rdma_syncmem)(CONN *, void *, caddr_t, int, int); 4070Sstevel@tonic-gate /* Buffer */ 4080Sstevel@tonic-gate rdma_stat (*rdma_buf_alloc)(CONN *, rdma_buf_t *); 4090Sstevel@tonic-gate void (*rdma_buf_free)(CONN *, rdma_buf_t *); 4100Sstevel@tonic-gate /* Transfer */ 4110Sstevel@tonic-gate rdma_stat (*rdma_send)(CONN *, clist *, uint32_t); 4120Sstevel@tonic-gate rdma_stat (*rdma_send_resp)(CONN *, clist *, uint32_t); 4130Sstevel@tonic-gate rdma_stat (*rdma_clnt_recvbuf)(CONN *, clist *, uint32_t); 414*7387SRobert.Gordon@Sun.COM rdma_stat (*rdma_clnt_recvbuf_remove)(CONN *, uint32_t); 4150Sstevel@tonic-gate rdma_stat (*rdma_svc_recvbuf)(CONN *, clist *); 4160Sstevel@tonic-gate rdma_stat (*rdma_recv)(CONN *, clist **, uint32_t); 4170Sstevel@tonic-gate /* RDMA */ 4180Sstevel@tonic-gate rdma_stat (*rdma_read)(CONN *, clist *, int); 4190Sstevel@tonic-gate rdma_stat (*rdma_write)(CONN *, clist *, int); 4200Sstevel@tonic-gate /* INFO */ 4210Sstevel@tonic-gate rdma_stat (*rdma_getinfo)(rdma_info_t *info); 4220Sstevel@tonic-gate } rdmaops_t; 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate /* 4250Sstevel@tonic-gate * RDMA operations. 4260Sstevel@tonic-gate */ 4270Sstevel@tonic-gate #define RDMA_REACHABLE(rdma_ops, addr_type, addr, handle) \ 4280Sstevel@tonic-gate (*(rdma_ops)->rdma_reachable)(addr_type, addr, handle) 4290Sstevel@tonic-gate 4300Sstevel@tonic-gate #define RDMA_GET_CONN(rdma_ops, addr, addr_type, handle, conn) \ 4310Sstevel@tonic-gate (*(rdma_ops)->rdma_get_conn)(addr, addr_type, handle, conn) 4320Sstevel@tonic-gate 4330Sstevel@tonic-gate #define RDMA_REL_CONN(conn) \ 4340Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_rel_conn)(conn) 4350Sstevel@tonic-gate 436*7387SRobert.Gordon@Sun.COM #define RDMA_REGMEM(conn, adsp, buff, len, handle) \ 437*7387SRobert.Gordon@Sun.COM (*(conn)->c_rdmamod->rdma_ops->rdma_regmem)(conn, adsp, \ 438*7387SRobert.Gordon@Sun.COM buff, len, handle) 4390Sstevel@tonic-gate 4400Sstevel@tonic-gate #define RDMA_DEREGMEM(conn, buff, handle) \ 4410Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_deregmem)(conn, buff, handle) 4420Sstevel@tonic-gate 443*7387SRobert.Gordon@Sun.COM #define RDMA_REGMEMSYNC(conn, adsp, buff, len, handle, synchandle, lrc) \ 444*7387SRobert.Gordon@Sun.COM (*(conn)->c_rdmamod->rdma_ops->rdma_regmemsync)(conn, adsp, buff, \ 445*7387SRobert.Gordon@Sun.COM len, handle, synchandle, lrc) 4460Sstevel@tonic-gate 447*7387SRobert.Gordon@Sun.COM #define RDMA_DEREGMEMSYNC(conn, buff, handle, synchandle, lrc) \ 448*7387SRobert.Gordon@Sun.COM (*(conn)->c_rdmamod->rdma_ops->rdma_deregmemsync)(conn, buff, \ 449*7387SRobert.Gordon@Sun.COM handle, synchandle, lrc) 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate #define RDMA_SYNCMEM(conn, handle, buff, len, direction) \ 4520Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_syncmem)(conn, handle, \ 4530Sstevel@tonic-gate buff, len, direction) 4540Sstevel@tonic-gate 4550Sstevel@tonic-gate #define RDMA_BUF_ALLOC(conn, rbuf) \ 4560Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_buf_alloc)(conn, rbuf) 4570Sstevel@tonic-gate 4580Sstevel@tonic-gate #define RDMA_BUF_FREE(conn, rbuf) \ 4590Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_buf_free)(conn, rbuf) 4600Sstevel@tonic-gate 4610Sstevel@tonic-gate #define RDMA_SEND(conn, sendlist, xid) \ 4620Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_send)(conn, sendlist, xid) 4630Sstevel@tonic-gate 4640Sstevel@tonic-gate #define RDMA_SEND_RESP(conn, sendlist, xid) \ 4650Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_send_resp)(conn, sendlist, xid) 4660Sstevel@tonic-gate 4670Sstevel@tonic-gate #define RDMA_CLNT_RECVBUF(conn, cl, xid) \ 4680Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_clnt_recvbuf)(conn, cl, xid) 4690Sstevel@tonic-gate 470*7387SRobert.Gordon@Sun.COM #define RDMA_CLNT_RECVBUF_REMOVE(conn, xid) \ 471*7387SRobert.Gordon@Sun.COM (*(conn)->c_rdmamod->rdma_ops->rdma_clnt_recvbuf_remove)(conn, xid) 472*7387SRobert.Gordon@Sun.COM 4730Sstevel@tonic-gate #define RDMA_SVC_RECVBUF(conn, cl) \ 4740Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_svc_recvbuf)(conn, cl) 4750Sstevel@tonic-gate 4760Sstevel@tonic-gate #define RDMA_RECV(conn, recvlist, xid) \ 4770Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_recv)(conn, recvlist, xid) 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate #define RDMA_READ(conn, cl, wait) \ 4800Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_read)(conn, cl, wait) 4810Sstevel@tonic-gate 4820Sstevel@tonic-gate #define RDMA_WRITE(conn, cl, wait) \ 4830Sstevel@tonic-gate (*(conn)->c_rdmamod->rdma_ops->rdma_write)(conn, cl, wait) 4840Sstevel@tonic-gate 4850Sstevel@tonic-gate #define RDMA_GETINFO(rdma_mod, info) \ 4860Sstevel@tonic-gate (*(rdma_mod)->rdma_ops->rdma_getinfo)(info) 4870Sstevel@tonic-gate 4880Sstevel@tonic-gate #ifdef _KERNEL 4890Sstevel@tonic-gate extern rdma_registry_t *rdma_mod_head; 4900Sstevel@tonic-gate extern krwlock_t rdma_lock; /* protects rdma_mod_head list */ 4910Sstevel@tonic-gate extern int rdma_modloaded; /* flag for loading RDMA plugins */ 4920Sstevel@tonic-gate extern int rdma_dev_available; /* rdma device is loaded or not */ 4930Sstevel@tonic-gate extern kmutex_t rdma_modload_lock; /* protects rdma_modloaded flag */ 4940Sstevel@tonic-gate extern uint_t rdma_minchunk; 4950Sstevel@tonic-gate extern ldi_ident_t rpcmod_li; /* needed by layed driver framework */ 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate /* 4980Sstevel@tonic-gate * General RDMA routines 4990Sstevel@tonic-gate */ 500*7387SRobert.Gordon@Sun.COM extern struct clist *clist_alloc(void); 501*7387SRobert.Gordon@Sun.COM extern void clist_add(struct clist **, uint32_t, int, 502*7387SRobert.Gordon@Sun.COM struct mrc *, caddr_t, struct mrc *, caddr_t); 503*7387SRobert.Gordon@Sun.COM extern void clist_free(struct clist *); 504*7387SRobert.Gordon@Sun.COM extern rdma_stat clist_register(CONN *conn, struct clist *cl, clist_dstsrc); 505*7387SRobert.Gordon@Sun.COM extern rdma_stat clist_deregister(CONN *conn, struct clist *cl, clist_dstsrc); 506*7387SRobert.Gordon@Sun.COM extern rdma_stat clist_syncmem(CONN *conn, struct clist *cl, clist_dstsrc); 507*7387SRobert.Gordon@Sun.COM extern rdma_stat rdma_clnt_postrecv(CONN *conn, uint32_t xid); 508*7387SRobert.Gordon@Sun.COM extern rdma_stat rdma_clnt_postrecv_remove(CONN *conn, uint32_t xid); 509*7387SRobert.Gordon@Sun.COM extern rdma_stat rdma_svc_postrecv(CONN *conn); 5100Sstevel@tonic-gate extern rdma_stat rdma_register_mod(rdma_mod_t *mod); 5110Sstevel@tonic-gate extern rdma_stat rdma_unregister_mod(rdma_mod_t *mod); 512*7387SRobert.Gordon@Sun.COM extern rdma_stat rdma_buf_alloc(CONN *, rdma_buf_t *); 513*7387SRobert.Gordon@Sun.COM extern void rdma_buf_free(CONN *, rdma_buf_t *); 5140Sstevel@tonic-gate extern int rdma_modload(); 515*7387SRobert.Gordon@Sun.COM extern bool_t rdma_get_wchunk(struct svc_req *, iovec_t *, struct clist *); 5160Sstevel@tonic-gate 5170Sstevel@tonic-gate /* 5180Sstevel@tonic-gate * RDMA XDR 5190Sstevel@tonic-gate */ 5200Sstevel@tonic-gate extern void xdrrdma_create(XDR *, caddr_t, uint_t, int, struct clist *, 5210Sstevel@tonic-gate enum xdr_op, CONN *); 5220Sstevel@tonic-gate extern void xdrrdma_destroy(XDR *); 523*7387SRobert.Gordon@Sun.COM 5240Sstevel@tonic-gate extern uint_t xdrrdma_getpos(XDR *); 5250Sstevel@tonic-gate extern bool_t xdrrdma_setpos(XDR *, uint_t); 5260Sstevel@tonic-gate extern bool_t xdr_clist(XDR *, clist *); 5270Sstevel@tonic-gate extern bool_t xdr_do_clist(XDR *, clist **); 5280Sstevel@tonic-gate extern uint_t xdr_getbufsize(XDR *); 529*7387SRobert.Gordon@Sun.COM extern unsigned int xdrrdma_sizeof(xdrproc_t, void *, int, uint_t *, uint_t *); 530*7387SRobert.Gordon@Sun.COM extern unsigned int xdrrdma_authsize(AUTH *, struct cred *, int); 531*7387SRobert.Gordon@Sun.COM 532*7387SRobert.Gordon@Sun.COM extern void xdrrdma_store_wlist(XDR *, struct clist *); 533*7387SRobert.Gordon@Sun.COM extern struct clist *xdrrdma_wclist(XDR *); 534*7387SRobert.Gordon@Sun.COM extern bool_t xdr_decode_reply_wchunk(XDR *, struct clist **); 535*7387SRobert.Gordon@Sun.COM extern bool_t xdr_decode_wlist(XDR *xdrs, struct clist **, bool_t *); 536*7387SRobert.Gordon@Sun.COM extern bool_t xdr_decode_wlist_svc(XDR *xdrs, struct clist **, bool_t *, 537*7387SRobert.Gordon@Sun.COM uint32_t *, CONN *); 538*7387SRobert.Gordon@Sun.COM extern bool_t xdr_encode_rlist_svc(XDR *, clist *); 539*7387SRobert.Gordon@Sun.COM extern bool_t xdr_encode_wlist(XDR *, clist *); 540*7387SRobert.Gordon@Sun.COM extern bool_t xdr_encode_reply_wchunk(XDR *, struct clist *, 541*7387SRobert.Gordon@Sun.COM uint32_t seg_array_len); 542*7387SRobert.Gordon@Sun.COM bool_t xdrrdma_getrdmablk(XDR *, struct clist **, uint_t *, 543*7387SRobert.Gordon@Sun.COM CONN **conn, const uint_t); 544*7387SRobert.Gordon@Sun.COM bool_t xdrrdma_read_from_client(struct clist **, CONN **, uint_t); 545*7387SRobert.Gordon@Sun.COM bool_t xdrrdma_send_read_data(XDR *, struct clist *); 546*7387SRobert.Gordon@Sun.COM bool_t xdrrdma_free_clist(CONN *, struct clist *); 5470Sstevel@tonic-gate #endif /* _KERNEL */ 5480Sstevel@tonic-gate 5490Sstevel@tonic-gate #ifdef __cplusplus 5500Sstevel@tonic-gate } 5510Sstevel@tonic-gate #endif 5520Sstevel@tonic-gate 5530Sstevel@tonic-gate #endif /* _RPC_RPC_RDMA_H */ 554