ib_fmr_pool.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2004 Topspin Corporation. All rights reserved.
  3. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
  4. *
  5. * This software is available to you under a choice of one of two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * provided with the distribution.
  23. *
  24. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  25. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. *
  33. * $Id: ib_fmr_pool.h 2730 2005-06-28 16:43:03Z sean.hefty $
  34. */
  35. #if !defined(IB_FMR_POOL_H)
  36. #define IB_FMR_POOL_H
  37. #include <rdma/ib_verbs.h>
  38. struct ib_fmr_pool;
  39. /**
  40. * struct ib_fmr_pool_param - Parameters for creating FMR pool
  41. * @max_pages_per_fmr:Maximum number of pages per map request.
  42. * @page_shift: Log2 of sizeof "pages" mapped by this fmr
  43. * @access:Access flags for FMRs in pool.
  44. * @pool_size:Number of FMRs to allocate for pool.
  45. * @dirty_watermark:Flush is triggered when @dirty_watermark dirty
  46. * FMRs are present.
  47. * @flush_function:Callback called when unmapped FMRs are flushed and
  48. * more FMRs are possibly available for mapping
  49. * @flush_arg:Context passed to user's flush function.
  50. * @cache:If set, FMRs may be reused after unmapping for identical map
  51. * requests.
  52. */
  53. struct ib_fmr_pool_param {
  54. int max_pages_per_fmr;
  55. int page_shift;
  56. enum ib_access_flags access;
  57. int pool_size;
  58. int dirty_watermark;
  59. void (*flush_function)(struct ib_fmr_pool *pool,
  60. void * arg);
  61. void *flush_arg;
  62. unsigned cache:1;
  63. };
  64. struct ib_pool_fmr {
  65. struct ib_fmr *fmr;
  66. struct ib_fmr_pool *pool;
  67. struct list_head list;
  68. struct hlist_node cache_node;
  69. int ref_count;
  70. int remap_count;
  71. u64 io_virtual_address;
  72. int page_list_len;
  73. u64 page_list[0];
  74. };
  75. struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
  76. struct ib_fmr_pool_param *params);
  77. void ib_destroy_fmr_pool(struct ib_fmr_pool *pool);
  78. int ib_flush_fmr_pool(struct ib_fmr_pool *pool);
  79. struct ib_pool_fmr *ib_fmr_pool_map_phys(struct ib_fmr_pool *pool_handle,
  80. u64 *page_list,
  81. int list_len,
  82. u64 *io_virtual_address);
  83. int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr);
  84. #endif /* IB_FMR_POOL_H */