i40iw_pble.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*******************************************************************************
  2. *
  3. * Copyright (c) 2015-2016 Intel Corporation. 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. * OpenFabrics.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. *******************************************************************************/
  34. #ifndef I40IW_PBLE_H
  35. #define I40IW_PBLE_H
  36. #define POOL_SHIFT 6
  37. #define PBLE_PER_PAGE 512
  38. #define I40IW_HMC_PAGED_BP_SHIFT 12
  39. #define PBLE_512_SHIFT 9
  40. enum i40iw_pble_level {
  41. I40IW_LEVEL_0 = 0,
  42. I40IW_LEVEL_1 = 1,
  43. I40IW_LEVEL_2 = 2
  44. };
  45. enum i40iw_alloc_type {
  46. I40IW_NO_ALLOC = 0,
  47. I40IW_DMA_COHERENT = 1,
  48. I40IW_VMALLOC = 2
  49. };
  50. struct i40iw_pble_info {
  51. unsigned long addr;
  52. u32 idx;
  53. u32 cnt;
  54. };
  55. struct i40iw_pble_level2 {
  56. struct i40iw_pble_info root;
  57. struct i40iw_pble_info *leaf;
  58. u32 leaf_cnt;
  59. };
  60. struct i40iw_pble_alloc {
  61. u32 total_cnt;
  62. enum i40iw_pble_level level;
  63. union {
  64. struct i40iw_pble_info level1;
  65. struct i40iw_pble_level2 level2;
  66. };
  67. };
  68. struct sd_pd_idx {
  69. u32 sd_idx;
  70. u32 pd_idx;
  71. u32 rel_pd_idx;
  72. };
  73. struct i40iw_add_page_info {
  74. struct i40iw_chunk *chunk;
  75. struct i40iw_hmc_sd_entry *sd_entry;
  76. struct i40iw_hmc_info *hmc_info;
  77. struct sd_pd_idx idx;
  78. u32 pages;
  79. };
  80. struct i40iw_chunk {
  81. struct list_head list;
  82. u32 size;
  83. void *vaddr;
  84. u64 fpm_addr;
  85. u32 pg_cnt;
  86. dma_addr_t *dmaaddrs;
  87. enum i40iw_alloc_type type;
  88. };
  89. struct i40iw_pble_pool {
  90. struct gen_pool *pool;
  91. struct list_head clist;
  92. u32 total_pble_alloc;
  93. u32 free_pble_cnt;
  94. u32 pool_shift;
  95. };
  96. struct i40iw_hmc_pble_rsrc {
  97. u32 unallocated_pble;
  98. u64 fpm_base_addr;
  99. u64 next_fpm_addr;
  100. struct i40iw_pble_pool pinfo;
  101. u32 stats_direct_sds;
  102. u32 stats_paged_sds;
  103. u64 stats_alloc_ok;
  104. u64 stats_alloc_fail;
  105. u64 stats_alloc_freed;
  106. u64 stats_lvl1;
  107. u64 stats_lvl2;
  108. };
  109. void i40iw_destroy_pble_pool(struct i40iw_sc_dev *dev, struct i40iw_hmc_pble_rsrc *pble_rsrc);
  110. enum i40iw_status_code i40iw_hmc_init_pble(struct i40iw_sc_dev *dev,
  111. struct i40iw_hmc_pble_rsrc *pble_rsrc);
  112. void i40iw_free_pble(struct i40iw_hmc_pble_rsrc *pble_rsrc, struct i40iw_pble_alloc *palloc);
  113. enum i40iw_status_code i40iw_get_pble(struct i40iw_sc_dev *dev,
  114. struct i40iw_hmc_pble_rsrc *pble_rsrc,
  115. struct i40iw_pble_alloc *palloc,
  116. u32 pble_cnt);
  117. #endif