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

/drivers/net/wireless/tiwlan1251/pform/common/src/osClsfr.c

http://github.com/CyanogenMod/cm-kernel
C | 144 lines | 54 code | 26 blank | 64 comment | 11 complexity | 6ed9ec74bab648617f0474f8f35f52fc 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. * file osClsfr.c
  37. */
  38. #include "osAdapter.h"
  39. #include "srcApi.h"
  40. #define ETHERNET_HEADER_SIZE 14
  41. /************************************************************************
  42. * os_txClassifier *
  43. ************************************************************************
  44. DESCRIPTION: the function demonstrate qos classification from UDP port
  45. number.
  46. INPUT: pData - void pointer to Msdu.
  47. OUTPUT:
  48. RETURN: OK on success, NOK otherwise
  49. ************************************************************************/
  50. TI_STATUS os_txClassifier(mem_MSDU_T *pMsdu,UINT8 *pQosClassifierTable)
  51. {
  52. UINT8 i;
  53. UINT8 *pUdpHeader;
  54. UINT8 *pIpHeader;
  55. UINT8 ipHeaderLen;
  56. UINT16 dstPortNum;
  57. UINT32 ipAddr;
  58. NWIF_CLSFR_ENTRY *pCt;
  59. pCt = (NWIF_CLSFR_ENTRY *)pQosClassifierTable;
  60. /*pEthHeader = (EthernetHeader_t*)(memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr));*/
  61. pIpHeader = (UINT8 *)(memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr)) + ETHERNET_HEADER_SIZE;
  62. ipHeaderLen = ((*(unsigned char*)pIpHeader & 0x0f) * 4);
  63. pUdpHeader = pIpHeader + ipHeaderLen;
  64. dstPortNum = *((UINT16 *)(pUdpHeader + 2));
  65. ipAddr = *((UINT32 *)(pIpHeader + 16));
  66. dstPortNum = ((dstPortNum >> 8) | (dstPortNum << 8));
  67. pMsdu->qosTag = 0;
  68. for(i = 0; i < NWIF_MAX_QOS_CONNS; i++ )
  69. {
  70. if ((pCt[i].ip == ipAddr) && (pCt[i].port == dstPortNum) )
  71. {
  72. pMsdu->qosTag = (UINT8)pCt[i].pri;
  73. /*printk(KERN_ALERT "Found classifier match for ip=0x%x, port=%d, prio=%d \n",ipAddr, dstPortNum, pCt[i].pri);*/
  74. break;
  75. }
  76. }
  77. return OK;
  78. }
  79. /************************************************************************
  80. * os_txSetClassifier *
  81. ************************************************************************
  82. DESCRIPTION: the function demonstrate setting qos classification table.
  83. INPUT: pData - void pointer to Msdu.
  84. OUTPUT:
  85. RETURN: OK on success, NOK otherwise
  86. ************************************************************************/
  87. TI_STATUS osSend_ConfigTxClassifier(PTIWLN_ADAPTER_T pAdapter,UINT32 bufferLength, UINT8 *pQosClassifierBuffer)
  88. {
  89. NWIF_CLSFR_ENTRY *pSrc, *pDest;
  90. UINT8 clsfrIndex;
  91. UINT8 NumOfEntries;
  92. if(bufferLength > NWIF_MAX_QOS_CONNS * sizeof(NWIF_CLSFR_ENTRY))
  93. {
  94. return NOK;
  95. }
  96. if((pAdapter == NULL) || (pQosClassifierBuffer == NULL))
  97. {
  98. return NOK;
  99. }
  100. pDest = (NWIF_CLSFR_ENTRY *)(pAdapter->qosClassifierTable);
  101. pSrc = (NWIF_CLSFR_ENTRY *)pQosClassifierBuffer;
  102. NumOfEntries = bufferLength / sizeof(NWIF_CLSFR_ENTRY);
  103. for(clsfrIndex = 0; clsfrIndex <NumOfEntries ; clsfrIndex++)
  104. {
  105. pDest[clsfrIndex].ip = pSrc[clsfrIndex].ip;
  106. pDest[clsfrIndex].port = pSrc[clsfrIndex].port;
  107. pDest[clsfrIndex].pri = pSrc[clsfrIndex].pri;
  108. }
  109. return OK;
  110. }