rdma.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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_free_mr(struct rds_sock *rs, char __user *optval, int optlen);
  54. void rds_rdma_drop_keys(struct rds_sock *rs);
  55. int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
  56. struct cmsghdr *cmsg);
  57. int rds_cmsg_rdma_dest(struct rds_sock *rs, struct rds_message *rm,
  58. struct cmsghdr *cmsg);
  59. int rds_cmsg_rdma_args(struct rds_sock *rs, struct rds_message *rm,
  60. struct cmsghdr *cmsg);
  61. int rds_cmsg_rdma_map(struct rds_sock *rs, struct rds_message *rm,
  62. struct cmsghdr *cmsg);
  63. void rds_rdma_free_op(struct rds_rdma_op *ro);
  64. void rds_rdma_send_complete(struct rds_message *rm, int);
  65. extern void __rds_put_mr_final(struct rds_mr *mr);
  66. static inline void rds_mr_put(struct rds_mr *mr)
  67. {
  68. if (atomic_dec_and_test(&mr->r_refcount))
  69. __rds_put_mr_final(mr);
  70. }
  71. #endif