mac_mcps_purge.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**
  2. * Copyright (c) 2016 - 2020 Nordic Semiconductor ASA and Luxoft Global Operations Gmbh.
  3. *
  4. * All Rights Reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. *
  10. * 1. Redistributions of source code must retain the above copyright notice, this
  11. * list of conditions and the following disclaimer.
  12. *
  13. * 2. Redistributions in binary form, except as embedded into a Nordic
  14. * Semiconductor ASA integrated circuit in a product or a software update for
  15. * such product, must reproduce the above copyright notice, this list of
  16. * conditions and the following disclaimer in the documentation and/or other
  17. * materials provided with the distribution.
  18. *
  19. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  20. * contributors may be used to endorse or promote products derived from this
  21. * software without specific prior written permission.
  22. *
  23. * 4. This software, with or without modification, must only be used with a
  24. * Nordic Semiconductor ASA integrated circuit.
  25. *
  26. * 5. Any software provided in binary form under this license must not be reverse
  27. * engineered, decompiled, modified and/or disassembled.
  28. *
  29. *
  30. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  31. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  32. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  33. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  34. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  35. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  36. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  38. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  39. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. *
  41. */
  42. #ifndef MAC_MCPS_PURGE_H_INCLUDED
  43. #define MAC_MCPS_PURGE_H_INCLUDED
  44. #if (CONFIG_PURGE_ENABLED == 1)
  45. #include <stdint.h>
  46. #include "mac_common.h"
  47. #include "mac_task_scheduler.h"
  48. /** @file
  49. * The MAC Purge module declares the MAC Purge routines and necessary types
  50. * according to the MAC specification.
  51. *
  52. * @defgroup mac_purge MAC MCPS Purge API
  53. * @ingroup mac_15_4
  54. * @{
  55. * @brief Module to declare MAC MCPS Purge API.
  56. * @details The MAC MCPS Purge module declares the MAC Purge routines and necessary types according to
  57. * the MAC specification. More specifically, MAC purge request mcps_purge_req(), and the
  58. * confirmation callback typedef is declared as mcps_purge_conf_cb_t. An additional primitive
  59. * not covered by the standard is declared. This is mpcs_purge() which is a synchronous version
  60. * of mcps_purge_req().
  61. */
  62. /**
  63. * @brief MCPS-PURGE.confirm.
  64. *
  65. * @details The MCPS-PURGE.confirm primitive allows the MAC sublayer to notify the next higher layer
  66. * of the success of its request to purge an MSDU from the transaction queue.
  67. *
  68. * In accordance with IEEE Std 802.15.4-2006, section 7.1.1.5.
  69. */
  70. typedef struct
  71. {
  72. /** The handle of the MSDU to be purged from the transaction queue. */
  73. uint8_t msdu_handle;
  74. /** The status of the request to be purged an MSDU from the transaction queue. */
  75. mac_status_t status;
  76. } mcps_purge_conf_t;
  77. /**
  78. * @brief MCPS-PURGE.request.
  79. *
  80. * @details The MCPS-PURGE.request primitive allows the next higher layer
  81. * to purge an MSDU from the transaction queue.
  82. *
  83. * In accordance with IEEE Std 802.15.4-2006, section 7.1.1.4.
  84. */
  85. typedef struct
  86. {
  87. /** Do not edit this field. */
  88. mac_abstract_req_t service;
  89. /** Confirmation to this request. */
  90. mcps_purge_conf_t confirm;
  91. /** The handle of the MSDU to be purged from the transaction queue. */
  92. uint8_t msdu_handle;
  93. } mcps_purge_req_t;
  94. /**
  95. * @brief Confirmation function.
  96. *
  97. * @details The MCPS-PURGE.confirm primitive is generated by the MAC sublayer
  98. * entity in response to an MCPS-PURGE.request primitive. The MCPS-PURGE.confirm
  99. * primitive returns a status of either SUCCESS, indicating that the purge request
  100. * was successful, or INVALID_HANDLE, indicating an error.
  101. * The status values are fully described in 7.1.1.4.3.
  102. *
  103. * @param Pointer to confirmation primitive.
  104. */
  105. typedef void (* mcps_purge_conf_cb_t)(mcps_purge_conf_t *);
  106. /**
  107. * @brief MCPS-PURGE.request service.
  108. *
  109. * @details The MCPS-PURGE.request primitive is generated by the next higher layer
  110. * whenever an MSDU is to be purged from the transaction queue.
  111. * After request completion, user callback will be issued with
  112. * valid data stored in structure mcps_purge_conf_t.
  113. *
  114. * @param req Pointer to MCPS-PURGE request structure.
  115. * @param conf_cb Pointer to the confirmation function (user callback).
  116. *
  117. * In accordance with IEEE Std 802.15.4-2006, section 7.1.1.4.
  118. */
  119. void mcps_purge_req(mcps_purge_req_t * req, mcps_purge_conf_cb_t conf_cb);
  120. /**
  121. * @brief Performs MCPS-PURGE.request directly (without request - confirm approach).
  122. *
  123. * @details Optional. Not covered by the standard.
  124. *
  125. * The MCPS-PURGE.request primitive is generated by the next higher layer
  126. * whenever an MSDU is to be purged from the transaction queue.
  127. *
  128. * @param req Pointer to MCPS-PURGE request structure.
  129. *
  130. * @return Result of the purge procedure.
  131. */
  132. mac_status_t mcps_purge(mcps_purge_req_t * req);
  133. /** @} */
  134. #endif // (CONFIG_PURGE_ENABLED == 1)
  135. #endif // MAC_MCPS_PURGE_H_INCLUDED