Advertisement
debil228

Untitled

Nov 5th, 2019
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.48 KB | None | 0 0
  1. /*--------------------------------------------------------------------*/
  2. /* Static function prototypes */
  3. /*--------------------------------------------------------------------*/
  4. static void proc_dnld_rsp(tpAniSirGlobal, uint16_t, uint32_t *);
  5. static void proc_get_req(tpAniSirGlobal, uint16_t, uint32_t *);
  6.  
  7. static uint8_t check_param(tpAniSirGlobal, uint16_t, uint32_t, uint32_t,
  8. uint32_t *);
  9. /*--------------------------------------------------------------------*/
  10. /* Module global variables */
  11. /*--------------------------------------------------------------------*/
  12.  
  13. /* CFG function table */
  14. void (*g_cfg_func[])(tpAniSirGlobal, uint16_t, uint32_t *) = {
  15. proc_dnld_rsp, proc_get_req
  16. };
  17.  
  18. /**---------------------------------------------------------------------
  19. * cfg_process_mb_msg()
  20. *
  21. ***FUNCTION:
  22. * CFG mailbox message processing function.
  23. *
  24. ***LOGIC:
  25. *
  26. ***ASSUMPTIONS:
  27. * None.
  28. *
  29. ***NOTE:
  30. *
  31. * @param pMsg Message pointer
  32. *
  33. * @return None.
  34. *
  35. */
  36. void cfg_process_mb_msg(tpAniSirGlobal pMac, tSirMbMsg *pMsg)
  37. {
  38. uint16_t index;
  39. uint16_t len;
  40. uint32_t *pParam;
  41.  
  42. /* Use type[7:0] as index to function table */
  43. index = CFG_GET_FUNC_INDX(pMsg->type);
  44.  
  45. if (index >= QDF_ARRAY_SIZE(g_cfg_func)) {
  46. qdf_mem_free(pMsg);
  47. return;
  48. }
  49. len = pMsg->msgLen - WNI_CFG_MB_HDR_LEN;
  50. pParam = ((uint32_t *) pMsg) + 1;
  51.  
  52. /* Call processing function */
  53. g_cfg_func[index] (pMac, len, pParam);
  54.  
  55. /* Free up buffer */
  56. qdf_mem_free(pMsg);
  57.  
  58. } /*** end cfg_process_mb_msg() ***/
  59.  
  60. /**---------------------------------------------------------------------
  61. * proc_dnld_rsp()
  62. *
  63. * FUNCTION:
  64. * This function processes CFG_DNLD_RSP message from host.
  65. *
  66. * LOGIC:
  67. *
  68. * ASSUMPTIONS:
  69. *
  70. * NOTE:
  71. *
  72. * @param length: message length
  73. * @param pParam: parameter list pointer
  74. *
  75. * @return None
  76. *
  77. */
  78. static void proc_dnld_rsp(tpAniSirGlobal pMac, uint16_t length, uint32_t *pParam)
  79. {
  80. int32_t i;
  81.  
  82. uint32_t expLen, retVal, bufStart, bufEnd;
  83. uint32_t *pSrc, *pDst, *pDstEnd;
  84. uint32_t strSize, j;
  85. uint8_t pStr[CFG_MAX_STR_LEN];
  86. tpCfgBinHdr pHdr;
  87. tSirMsgQ mmhMsg;
  88.  
  89. /* First Dword must contain the AP or STA magic dword */
  90. pe_debug("CFG size: %d bytes MAGIC dword is: 0x%x",
  91. length, sir_read_u32_n((uint8_t *) pParam));
  92.  
  93. /* if the string is not correct, return failure */
  94. if (*pParam == CFG_STA_MAGIC_DWORD) {
  95. }
  96.  
  97. else {
  98. pe_warn("Invalid magic dword: 0x%x",
  99. sir_read_u32_n((uint8_t *) pParam));
  100. retVal = WNI_CFG_INVALID_LEN;
  101. goto end;
  102. }
  103.  
  104. pParam++;
  105. length -= 4;
  106.  
  107. /* Parse the Cfg header */
  108. pHdr = (tpCfgBinHdr) pParam;
  109. pParam += (sizeof(tCfgBinHdr) >> 2);
  110. pe_debug("CFG hdr totParams: %d intParams: %d strBufSize: %d/%d",
  111. pHdr->controlSize, pHdr->iBufSize, pHdr->sBufSize,
  112. pMac->cfg.gCfgMaxSBufSize);
  113.  
  114. expLen =
  115. ((CFG_PARAM_MAX_NUM + 3 * pMac->cfg.gCfgMaxIBufSize) << 2) +
  116. pHdr->sBufSize + sizeof(tCfgBinHdr);
  117.  
  118. if (length != expLen) {
  119. pe_warn("<CFG> DNLD_RSP invalid length: %d (exp: %d)", length,
  120. expLen);
  121. retVal = WNI_CFG_INVALID_LEN;
  122. goto end;
  123. }
  124.  
  125. if (pHdr->controlSize != CFG_PARAM_MAX_NUM) {
  126. pe_warn("<CFG> Total parameter count mismatch");
  127. retVal = WNI_CFG_INVALID_LEN;
  128. goto end;
  129. }
  130.  
  131. if (pHdr->iBufSize != pMac->cfg.gCfgMaxIBufSize) {
  132. pe_warn("<CFG> Integer parameter count mismatch");
  133. retVal = WNI_CFG_INVALID_LEN;
  134. goto end;
  135. }
  136. /* Copy control array */
  137. pDst = (uint32_t *) pMac->cfg.gCfgEntry;
  138. pDstEnd = pDst + CFG_PARAM_MAX_NUM;
  139. pSrc = pParam;
  140. while (pDst < pDstEnd) {
  141. *pDst++ = *pSrc++;
  142. }
  143. /* Copy default values */
  144. pDst = pMac->cfg.gCfgIBuf;
  145. pDstEnd = pDst + pMac->cfg.gCfgMaxIBufSize;
  146. while (pDst < pDstEnd) {
  147. *pDst++ = *pSrc++;
  148. }
  149.  
  150. /* Copy min values */
  151. pDst = pMac->cfg.gCfgIBufMin;
  152. pDstEnd = pDst + pMac->cfg.gCfgMaxIBufSize;
  153. while (pDst < pDstEnd) {
  154. *pDst++ = *pSrc++;
  155. }
  156.  
  157. /* Copy max values */
  158. pDst = pMac->cfg.gCfgIBufMax;
  159. pDstEnd = pDst + pMac->cfg.gCfgMaxIBufSize;
  160. while (pDst < pDstEnd) {
  161. *pDst++ = *pSrc++;
  162. }
  163.  
  164. for (i = 0; i < pMac->cfg.gCfgMaxIBufSize; i++)
  165. if (pMac->cfg.gCfgIBuf[i] < pMac->cfg.gCfgIBufMin[i] ||
  166. pMac->cfg.gCfgIBuf[i] > pMac->cfg.gCfgIBufMax[i]) {
  167. pe_debug("cfg id: %d Invalid def value: %d min: %d max: %d",
  168. i, pMac->cfg.gCfgIBuf[i],
  169. pMac->cfg.gCfgIBufMin[i],
  170. pMac->cfg.gCfgIBufMax[i]);
  171. }
  172. /* Calculate max string buffer lengths for all string parameters */
  173. bufEnd = pMac->cfg.gCfgMaxSBufSize;
  174. for (i = CFG_PARAM_MAX_NUM - 1; i >= 0; i--) {
  175. if ((pMac->cfg.gCfgEntry[i].control & CFG_CTL_INT) != 0)
  176. continue;
  177.  
  178. if ((pMac->cfg.gCfgEntry[i].control & CFG_CTL_VALID) == 0)
  179. continue;
  180.  
  181. bufStart = pMac->cfg.gCfgEntry[i].control & CFG_BUF_INDX_MASK;
  182. pMac->cfg.gCfgSBuf[bufStart] =
  183. (uint8_t) (bufEnd - bufStart - 2);
  184.  
  185. pe_debug("id: %d max: %d bufStart: %d bufEnd: %d", i,
  186. pMac->cfg.gCfgSBuf[bufStart], bufStart, bufEnd);
  187. bufEnd = bufStart;
  188. }
  189.  
  190. /* Initialize string defaults */
  191. strSize = pHdr->sBufSize;
  192. while (strSize) {
  193. uint32_t paramId, paramLen, paramLenCeil4;
  194.  
  195. if (strSize < 4) {
  196. pe_warn("parsing str defaults, rem: %d bytes",
  197. strSize);
  198. retVal = WNI_CFG_INVALID_LEN;
  199. goto end;
  200. }
  201. paramId = *pSrc >> 16;
  202. paramLen = *pSrc & 0xff;
  203. pSrc++;
  204. strSize -= 4;
  205.  
  206. paramLenCeil4 = ((paramLen + 3) >> 2);
  207. if (strSize < paramLenCeil4 << 2) {
  208. pe_warn("parsing str defaults, rem: %d bytes",
  209. strSize);
  210. pe_warn("param id: %d len: %d bytes",
  211. paramId, paramLen);
  212. retVal = WNI_CFG_INVALID_LEN;
  213. goto end;
  214. }
  215. for (j = 0; j < paramLenCeil4; j++) {
  216. pStr[4 * j] = (uint8_t) (*pSrc >> 24) & 0xff;
  217. pStr[4 * j + 1] = (uint8_t) (*pSrc >> 16) & 0xff;
  218. pStr[4 * j + 2] = (uint8_t) (*pSrc >> 8) & 0xff;
  219. pStr[4 * j + 3] = (uint8_t) (*pSrc) & 0xff;
  220.  
  221. pSrc++;
  222. strSize -= 4;
  223. }
  224.  
  225. pe_debug("set str id: %d len: %d", paramId, paramLen);
  226.  
  227. if (cfg_set_str(pMac, (uint16_t) paramId, pStr, paramLen) !=
  228. eSIR_SUCCESS) {
  229. pe_warn("setting str default param %d len %d",
  230. paramId, paramLen);
  231. retVal = WNI_CFG_INVALID_LEN;
  232. goto end;
  233. }
  234. }
  235.  
  236. /* Set status to READY */
  237. pMac->cfg.gCfgStatus = CFG_SUCCESS;
  238. retVal = WNI_CFG_SUCCESS;
  239. pe_debug("<CFG> Completed successfully");
  240.  
  241. end:
  242.  
  243. if (retVal != WNI_CFG_SUCCESS)
  244. pMac->cfg.gCfgStatus = CFG_FAILURE;
  245.  
  246. /* Send response message to host */
  247. pMac->cfg.gParamList[WNI_CFG_DNLD_CNF_RES] = retVal;
  248. cfg_send_host_msg(pMac, WNI_CFG_DNLD_CNF, WNI_CFG_DNLD_CNF_LEN,
  249. WNI_CFG_DNLD_CNF_NUM, pMac->cfg.gParamList, 0, 0);
  250.  
  251. /* notify WMA that the config has downloaded */
  252. mmhMsg.type = SIR_CFG_DOWNLOAD_COMPLETE_IND;
  253. mmhMsg.bodyptr = NULL;
  254. mmhMsg.bodyval = 0;
  255.  
  256. MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, mmhMsg.type));
  257. if (wma_post_ctrl_msg(pMac, &mmhMsg) != eSIR_SUCCESS) {
  258. pe_err("WMAPostMsgApi failed!");
  259. }
  260.  
  261. } /*** end procDnldRsp() ***/
  262.  
  263. /**---------------------------------------------------------------------
  264. * proc_get_req()
  265. *
  266. * FUNCTION:
  267. * This function processes CFG_GET_REQ message from host.
  268. *
  269. * LOGIC:
  270. *
  271. * ASSUMPTIONS:
  272. *
  273. * NOTE:
  274. * For every parameter ID specified on the list, CFG will send a separate
  275. * CFG_GET_RSP back to host.
  276. *
  277. * @param length: message length
  278. * @param pParam: parameter list pointer
  279. *
  280. * @return None
  281. *
  282. */
  283. static void proc_get_req(tpAniSirGlobal pMac, uint16_t length, uint32_t *pParam)
  284. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement