i_wbuff.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * Copyright (c) 2018 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /**
  20. * DOC: i_wbuff.h
  21. * wbuff private
  22. */
  23. #ifndef _I_WBUFF_H
  24. #define _I_WBUFF_H
  25. #include <qdf_nbuf.h>
  26. #include <wbuff.h>
  27. #define WBUFF_MODULE_ID_SHIFT 4
  28. #define WBUFF_MODULE_ID_BITMASK 0xF0
  29. #define WBUFF_POOL_ID_SHIFT 1
  30. #define WBUFF_POOL_ID_BITMASK 0xE
  31. /**
  32. * struct wbuff_handle - wbuff handle to the registered module
  33. * @id: the identifier for the registered module.
  34. */
  35. struct wbuff_handle {
  36. uint8_t id;
  37. };
  38. /**
  39. * struct wbuff_pool - structure representing wbuff pool
  40. * @initialized: To identify whether pool is initialized
  41. * @pool: nbuf pool
  42. * @buffer_size: size of the buffer in this @pool
  43. * @pool_id: pool identifier
  44. * @alloc_success: Successful allocations for this pool
  45. * @alloc_fail: Failed allocations for this pool
  46. * @mem_alloc: Memory allocated for this pool
  47. */
  48. struct wbuff_pool {
  49. bool initialized;
  50. qdf_nbuf_t pool;
  51. uint16_t buffer_size;
  52. uint8_t pool_id;
  53. uint64_t alloc_success;
  54. uint64_t alloc_fail;
  55. uint64_t mem_alloc;
  56. };
  57. /**
  58. * struct wbuff_module - allocation holder for wbuff registered module
  59. * @registered: To identify whether module is registered
  60. * @pending_returns: Number of buffers pending to be returned to
  61. * wbuff by the module
  62. * @lock: Lock for accessing per module buffer pools
  63. * @handle: wbuff handle for the registered module
  64. * @reserve: nbuf headroom to start with
  65. * @align: alignment for the nbuf
  66. * @wbuff_pool: pools for all available buffers for the module
  67. */
  68. struct wbuff_module {
  69. bool registered;
  70. uint16_t pending_returns;
  71. qdf_spinlock_t lock;
  72. struct wbuff_handle handle;
  73. int reserve;
  74. int align;
  75. struct wbuff_pool wbuff_pool[WBUFF_MAX_POOLS];
  76. };
  77. /**
  78. * struct wbuff_holder - allocation holder for wbuff
  79. * @initialized: to identified whether module is initialized
  80. * @mod: list of modules
  81. * @pf_cache: Reference to page frag cache, used for nbuf allocations
  82. * @wbuff_debugfs_dir: wbuff debugfs root directory
  83. * @wbuff_stats_dentry: wbuff debugfs stats file
  84. */
  85. struct wbuff_holder {
  86. bool initialized;
  87. struct wbuff_module mod[WBUFF_MAX_MODULES];
  88. qdf_frag_cache_t pf_cache;
  89. struct dentry *wbuff_debugfs_dir;
  90. struct dentry *wbuff_stats_dentry;
  91. };
  92. #endif /* _WBUFF_H */