rdma.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef _RDS_RDMA_H
  2. #define _RDS_RDMA_H
  3. #include <linux/rbtree.h>
  4. #include <linux/spinlock.h>
  5. #include <linux/scatterlist.h>
  6. #include "rds.h"
  7. struct rds_mr {
  8. struct rb_node r_rb_node;
  9. atomic_t r_refcount;
  10. u32 r_key;
  11. /* A copy of the creation flags */
  12. unsigned int r_use_once:1;
  13. unsigned int r_invalidate:1;
  14. unsigned int r_write:1;
  15. /* This is for RDS_MR_DEAD.
  16. * It would be nice & consistent to make this part of the above
  17. * bit field here, but we need to use test_and_set_bit.
  18. */
  19. unsigned long r_state;
  20. struct rds_sock *r_sock; /* back pointer to the socket that owns us */
  21. struct rds_transport *r_trans;
  22. void *r_trans_private;
  23. };
  24. /* Flags for mr->r_state */
  25. #define RDS_MR_DEAD 0
  26. struct rds_rdma_op {
  27. u32 r_key;
  28. u64 r_remote_addr;
  29. unsigned int r_write:1;
  30. unsigned int r_fence:1;
  31. unsigned int r_notify:1;
  32. unsigned int r_recverr:1;
  33. unsigned int r_mapped:1;
  34. struct rds_notifier *r_notifier;
  35. unsigned int r_bytes;
  36. unsigned int r_nents;
  37. unsigned int r_count;
  38. struct scatterlist r_sg[0];
  39. };
  40. static inline rds_rdma_cookie_t rds_rdma_make_cookie(u32 r_key, u32 offset)
  41. {
  42. return r_key | (((u64) offset) << 32);
  43. }
  44. static inline u32 rds_rdma_cookie_key(rds_rdma_cookie_t cookie)
  45. {
  46. return cookie;
  47. }
  48. static inline u32 rds_rdma_cookie_offset(rds_rdma_cookie_t cookie)
  49. {
  50. return cookie >> 32;
  51. }
  52. int rds_get_mr(struct rds_sock *rs, char __user *optval, int optlen);
  53. int rds_get_mr_for_dest(struct rds_sock *rs, char __user *optval, int optlen);
  54. int rds_free_mr(struct rds_sock *rs, char __user *optval, int optlen);
  55. void rds_rdma_drop_keys(struct rds_sock *rs);
  56. int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
  57. struct cmsghdr *cmsg);
  58. int rds_cmsg_rdma_dest(struct rds_sock *rs, struct rds_message *rm,
  59. struct cmsghdr *cmsg);
  60. int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
  61. struct cmsghdr *cmsg);
  62. int rds_cmsg_rdma_map(struct rds_sock *rs, struct rds_message *rm,
  63. struct cmsghdr *cmsg);
  64. void rds_rdma_free_op(struct rds_rdma_op *ro);
  65. void rds_rdma_send_complete(struct rds_message *rm, int);
  66. extern void __rds_put_mr_final(struct rds_mr *mr);
  67. static inline void rds_mr_put(struct rds_mr *mr)
  68. {
  69. if (atomic_dec_and_test(&mr->r_refcount))
  70. __rds_put_mr_final(mr);
  71. }
  72. #endif