1 /* 2 * This file contains definitions imported from the OFED rds header rdma.h. 3 * Oracle elects to have and use the contents of rdma.h under and 4 * governed by the OpenIB.org BSD license. 5 */ 6 7 /* 8 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 9 */ 10 11 #ifndef _RDSV3_RDMA_H 12 #define _RDSV3_RDMA_H 13 14 #include <sys/rds.h> 15 #include <sys/uio.h> 16 17 #include <sys/ib/clients/rdsv3/rdsv3.h> 18 19 struct rdsv3_mr { 20 /* for AVL tree */ 21 avl_node_t r_rb_node; 22 atomic_t r_refcount; 23 uint32_t r_key; 24 25 /* A copy of the creation flags */ 26 unsigned int r_use_once:1; 27 unsigned int r_invalidate:1; 28 unsigned int r_write:1; 29 30 /* 31 * This is for RDS_MR_DEAD. 32 * It would be nice & consistent to make this part of the above 33 * bit field here, but we need to use test_and_set_bit. 34 */ 35 unsigned long r_state; 36 /* back pointer to the socket that owns us */ 37 struct rdsv3_sock *r_sock; 38 struct rdsv3_transport *r_trans; 39 void *r_trans_private; 40 }; 41 42 /* Flags for mr->r_state */ 43 #define RDSV3_MR_DEAD 0 44 45 struct rdsv3_rdma_sg { 46 ddi_umem_cookie_t umem_cookie; 47 struct rds_iovec iovec; 48 ibt_send_wr_t swr; 49 ibt_mi_hdl_t mihdl; 50 ibt_hca_hdl_t hca_hdl; 51 }; 52 53 struct rdsv3_rdma_op { 54 uint32_t r_key; 55 uint64_t r_remote_addr; 56 unsigned int r_write:1; 57 unsigned int r_fence:1; 58 unsigned int r_notify:1; 59 unsigned int r_recverr:1; 60 unsigned int r_mapped:1; 61 struct rdsv3_notifier *r_notifier; 62 unsigned int r_bytes; 63 unsigned int r_nents; 64 unsigned int r_count; 65 struct rdsv3_scatterlist *r_sg; 66 struct rdsv3_rdma_sg r_rdma_sg[1]; 67 }; 68 69 static inline rds_rdma_cookie_t 70 rdsv3_rdma_make_cookie(uint32_t r_key, uint32_t offset) 71 { 72 return (r_key | (((uint64_t)offset) << 32)); 73 } 74 75 static inline uint32_t 76 rdsv3_rdma_cookie_key(rds_rdma_cookie_t cookie) 77 { 78 return ((uint32_t)cookie); 79 } 80 81 static inline uint32_t 82 rdsv3_rdma_cookie_offset(rds_rdma_cookie_t cookie) 83 { 84 return (cookie >> 32); 85 } 86 87 int rdsv3_get_mr(struct rdsv3_sock *rs, const void *optval, int optlen); 88 int rdsv3_get_mr_for_dest(struct rdsv3_sock *rs, const void *optval, 89 int optlen); 90 int rdsv3_free_mr(struct rdsv3_sock *rs, const void *optval, int optlen); 91 void rdsv3_rdma_drop_keys(struct rdsv3_sock *rs); 92 int rdsv3_cmsg_rdma_args(struct rdsv3_sock *rs, struct rdsv3_message *rm, 93 struct cmsghdr *cmsg); 94 int rdsv3_cmsg_rdma_dest(struct rdsv3_sock *rs, struct rdsv3_message *rm, 95 struct cmsghdr *cmsg); 96 int rdsv3_cmsg_rdma_map(struct rdsv3_sock *rs, struct rdsv3_message *rm, 97 struct cmsghdr *cmsg); 98 void rdsv3_rdma_free_op(struct rdsv3_rdma_op *ro); 99 void rdsv3_rdma_send_complete(struct rdsv3_message *rm, int); 100 101 extern void __rdsv3_put_mr_final(struct rdsv3_mr *mr); 102 static inline void rdsv3_mr_put(struct rdsv3_mr *mr) 103 { 104 if (atomic_dec_and_test(&mr->r_refcount)) 105 __rdsv3_put_mr_final(mr); 106 } 107 108 #endif /* _RDSV3_RDMA_H */ 109