qdf_list.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * DOC: qdf_list.h
  28. * QCA driver framework (QDF) list APIs
  29. * Definitions for QDF Linked Lists API
  30. *
  31. * Lists are implemented as a doubly linked list. An item in a list can
  32. * be of any type as long as the datatype contains a field of type
  33. * qdf_link_t.
  34. *
  35. * In general, a list is a doubly linked list of items with a pointer
  36. * to the front of the list and a pointer to the end of the list. The
  37. * list items contain a forward and back link.
  38. *
  39. * QDF linked list APIs are NOT thread safe so make sure to use appropriate
  40. * locking mechanisms to assure operations on the list are thread safe.
  41. */
  42. #if !defined(__QDF_LIST_H)
  43. #define __QDF_LIST_H
  44. /* Include Files */
  45. #include <qdf_types.h>
  46. #include <qdf_status.h>
  47. #include <i_qdf_list.h>
  48. #include <qdf_trace.h>
  49. typedef __qdf_list_node_t qdf_list_node_t;
  50. typedef __qdf_list_t qdf_list_t;
  51. /* Function declarations */
  52. QDF_STATUS qdf_list_insert_front(qdf_list_t *list, qdf_list_node_t *node);
  53. QDF_STATUS qdf_list_insert_back_size(qdf_list_t *list, qdf_list_node_t *node,
  54. uint32_t *size);
  55. QDF_STATUS qdf_list_remove_front(qdf_list_t *list, qdf_list_node_t **node1);
  56. QDF_STATUS qdf_list_peek_next(qdf_list_t *list, qdf_list_node_t *node,
  57. qdf_list_node_t **node1);
  58. /**
  59. * qdf_list_create() - Create qdf list and initialize list head
  60. * @list: object of list
  61. * @max_size: max size of the list
  62. *
  63. * Return: none
  64. */
  65. static inline void qdf_list_create(__qdf_list_t *list, uint32_t max_size)
  66. {
  67. __qdf_list_create(list, max_size);
  68. }
  69. /**
  70. * qdf_init_list_head() - initialize list head
  71. * @list_head: pointer to list head
  72. *
  73. * Return: none
  74. */
  75. static inline void qdf_init_list_head(__qdf_list_node_t *list_head)
  76. {
  77. __qdf_init_list_head(list_head);
  78. }
  79. /**
  80. * qdf_list_destroy() - Destroy the list
  81. * @list: object of list
  82. * Return: none
  83. */
  84. static inline void qdf_list_destroy(qdf_list_t *list)
  85. {
  86. if (list->count != 0) {
  87. QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR,
  88. "%s: list length not equal to zero", __func__);
  89. QDF_ASSERT(0);
  90. }
  91. }
  92. /**
  93. * qdf_list_size() - gives the size of the list
  94. * @list: object of list
  95. * @size: size of the list
  96. * Return: uint32_t
  97. */
  98. static inline uint32_t qdf_list_size(qdf_list_t *list)
  99. {
  100. return list->count;
  101. }
  102. QDF_STATUS qdf_list_insert_back(qdf_list_t *list, qdf_list_node_t *node);
  103. QDF_STATUS qdf_list_remove_back(qdf_list_t *list, qdf_list_node_t **node1);
  104. QDF_STATUS qdf_list_peek_front(qdf_list_t *list, qdf_list_node_t **node1);
  105. QDF_STATUS qdf_list_remove_node(qdf_list_t *list,
  106. qdf_list_node_t *node_to_remove);
  107. bool qdf_list_empty(qdf_list_t *list);
  108. #endif /* __QDF_LIST_H */