physical_ops.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (c) 2015 Oracle. All rights reserved.
  3. * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
  4. */
  5. /* No-op chunk preparation. All client memory is pre-registered.
  6. * Sometimes referred to as ALLPHYSICAL mode.
  7. *
  8. * Physical registration is simple because all client memory is
  9. * pre-registered and never deregistered. This mode is good for
  10. * adapter bring up, but is considered not safe: the server is
  11. * trusted not to abuse its access to client memory not involved
  12. * in RDMA I/O.
  13. */
  14. #include "xprt_rdma.h"
  15. #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
  16. # define RPCDBG_FACILITY RPCDBG_TRANS
  17. #endif
  18. static int
  19. physical_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
  20. struct rpcrdma_create_data_internal *cdata)
  21. {
  22. return 0;
  23. }
  24. /* PHYSICAL memory registration conveys one page per chunk segment.
  25. */
  26. static size_t
  27. physical_op_maxpages(struct rpcrdma_xprt *r_xprt)
  28. {
  29. return min_t(unsigned int, RPCRDMA_MAX_DATA_SEGS,
  30. rpcrdma_max_segments(r_xprt));
  31. }
  32. static int
  33. physical_op_init(struct rpcrdma_xprt *r_xprt)
  34. {
  35. return 0;
  36. }
  37. /* The client's physical memory is already exposed for
  38. * remote access via RDMA READ or RDMA WRITE.
  39. */
  40. static int
  41. physical_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
  42. int nsegs, bool writing)
  43. {
  44. struct rpcrdma_ia *ia = &r_xprt->rx_ia;
  45. rpcrdma_map_one(ia->ri_id->device, seg,
  46. rpcrdma_data_dir(writing));
  47. seg->mr_rkey = ia->ri_bind_mem->rkey;
  48. seg->mr_base = seg->mr_dma;
  49. seg->mr_nsegs = 1;
  50. return 1;
  51. }
  52. /* Unmap a memory region, but leave it registered.
  53. */
  54. static int
  55. physical_op_unmap(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg)
  56. {
  57. struct rpcrdma_ia *ia = &r_xprt->rx_ia;
  58. read_lock(&ia->ri_qplock);
  59. rpcrdma_unmap_one(ia->ri_id->device, seg);
  60. read_unlock(&ia->ri_qplock);
  61. return 1;
  62. }
  63. static void
  64. physical_op_reset(struct rpcrdma_xprt *r_xprt)
  65. {
  66. }
  67. static void
  68. physical_op_destroy(struct rpcrdma_buffer *buf)
  69. {
  70. }
  71. const struct rpcrdma_memreg_ops rpcrdma_physical_memreg_ops = {
  72. .ro_map = physical_op_map,
  73. .ro_unmap = physical_op_unmap,
  74. .ro_open = physical_op_open,
  75. .ro_maxpages = physical_op_maxpages,
  76. .ro_init = physical_op_init,
  77. .ro_reset = physical_op_reset,
  78. .ro_destroy = physical_op_destroy,
  79. .ro_displayname = "physical",
  80. };