PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/TNETW_Driver/Ctrl/Cmd_Queue/CmdQueue.h

http://github.com/CyanogenMod/cm-kernel
C Header | 157 lines | 77 code | 20 blank | 60 comment | 8 complexity | 6634bce846da74b637c3f94064314ced MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.0
  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
  5. **| All rights reserved. |**
  6. **| |**
  7. **| Redistribution and use in source and binary forms, with or without |**
  8. **| modification, are permitted provided that the following conditions |**
  9. **| are met: |**
  10. **| |**
  11. **| * Redistributions of source code must retain the above copyright |**
  12. **| notice, this list of conditions and the following disclaimer. |**
  13. **| * Redistributions in binary form must reproduce the above copyright |**
  14. **| notice, this list of conditions and the following disclaimer in |**
  15. **| the documentation and/or other materials provided with the |**
  16. **| distribution. |**
  17. **| * Neither the name Texas Instruments nor the names of its |**
  18. **| contributors may be used to endorse or promote products derived |**
  19. **| from this software without specific prior written permission. |**
  20. **| |**
  21. **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |**
  22. **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |**
  23. **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
  24. **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |**
  25. **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
  26. **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |**
  27. **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
  28. **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
  29. **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |**
  30. **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
  31. **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |**
  32. **| |**
  33. **+-----------------------------------------------------------------------+**
  34. ****************************************************************************/
  35. /*********************************************************************************/
  36. /* */
  37. /* MODULE: CmdQueue.h */
  38. /* PURPOSE: CmdQueue internal H file */
  39. /* */
  40. /**********************************************************************************/
  41. #ifndef _CMDQUEUE_H_
  42. #define _CMDQUEUE_H_
  43. #include "whalCommon.h"
  44. #include "whalHwDefs.h"
  45. /*****************************************************************************
  46. ** Defines **
  47. *****************************************************************************/
  48. #define CMDQUEUE_QUEUE_DEPTH 50
  49. #define CMDQUEUE_HISTORY_DEPTH 5
  50. #define CMDQUEUE_INFO_ELEM_HEADER_LEN 4
  51. #define CMDQUEUE_CONVERT_RC(rc) \
  52. if((rc == TNETWIF_OK)||(rc == TNETWIF_COMPLETE)||(rc == TNETWIF_PENDING)||(rc == OK)) \
  53. return OK; \
  54. else \
  55. return NOK \
  56. #define CHECK_ERROR_FLAG(flag) \
  57. if(flag == TRUE) \
  58. return OK; \
  59. /*****************************************************************************
  60. ** Enums **
  61. *****************************************************************************/
  62. typedef enum
  63. {
  64. CMDQUEUE_EVENT_RUN,
  65. CMDQUEUE_EVENT_SEND_CMPLT,
  66. CMDQUEUE_EVENT_RESULT_RECEIVED,
  67. CMDQUEUE_EVENT_NUM,
  68. } CmdQueue_SMEvents_e;
  69. typedef enum
  70. {
  71. CMDQUEUE_STATE_IDLE,
  72. CMDQUEUE_STATE_SEND_CMD_v,
  73. CMDQUEUE_STATE_WAIT_SEND_CMPLT,
  74. CMDQUEUE_STATE_INTERROGATE_v,
  75. CMDQUEUE_STATE_WAIT_RESULT,
  76. CMDQUEUE_STATE_FINISH_v,
  77. CMDQUEUE_STATE_NUM,
  78. } CmdQueue_SMStates_e;
  79. /*****************************************************************************
  80. ** Structures **
  81. *****************************************************************************/
  82. /* CmdQueue Node */
  83. typedef struct
  84. {
  85. Command_e cmdType; /* Command Type Config/interrogat ... */
  86. UINT32 paramsLen;
  87. void* CB_Func;
  88. TI_HANDLE CB_Arg;
  89. UINT8 paramsBuf[MAX_CMD_PARAMS]; /* param for config */
  90. UINT8* interrogateParamsBuf; /* A returned value Buffer */
  91. }CmdQueue_CmdNode_T;
  92. /* Saved CallBack Node In case of Recovery*/
  93. typedef struct
  94. {
  95. void* CB_Func;
  96. TI_HANDLE CB_Arg;
  97. UINT8* interrogateParamsBuf; /* A returned value Buffer */
  98. }CmdQueue_RecoveryNode_T;
  99. /* MailBox Queue */
  100. typedef struct _CmdQueue_T
  101. {
  102. /* handles */
  103. TI_HANDLE hOs;
  104. TI_HANDLE hReport;
  105. TI_HANDLE hCmdMBox;
  106. /* SM */
  107. CmdQueue_SMStates_e State;
  108. CmdQueue_GenericCB_t CmdCompleteGenericCB_Func;
  109. TI_HANDLE CmdCompleteGenericCB_Arg;
  110. CmdQueue_CB_t FailureCB;
  111. TI_HANDLE FailureCbHandle;
  112. /* queues */
  113. CmdQueue_CmdNode_T CmdQueue[CMDQUEUE_QUEUE_DEPTH];
  114. CmdQueue_RecoveryNode_T RecoveryQueue[CMDQUEUE_QUEUE_DEPTH];
  115. /* CmdQueue indexes & counters */
  116. int Head;
  117. int Tail;
  118. int NumberOfCommandInQueue;
  119. int MaxNumberOfCommandInQueue;
  120. int NumberOfRecoveryNodes;
  121. #ifdef TI_DBG
  122. UINT32 CmdSendCounter;
  123. UINT32 CmdCompltCounter;
  124. #endif
  125. int SM_RC;
  126. /* error handling */
  127. int ErrorFlag;
  128. }CmdQueue_T;
  129. /*****************************************************************************
  130. ** Internal functions definitions **
  131. *****************************************************************************/
  132. int CmdQueue_SM(CmdQueue_T* pCmdQueue,CmdQueue_SMEvents_e event);
  133. int CmdQueue_Push(CmdQueue_T *pCmdQueue, Command_e cmdType,
  134. UINT8* pParamsBuf, UINT32 paramsLen,
  135. void *CB_Func, TI_HANDLE CB_Arg, UINT8* pCB_Buf);
  136. void CmdQueue_PrintQueue(CmdQueue_T *pCmdQueue);
  137. #endif