2 ** $Id: @(#) p2p_nic.c@@
6 \brief Wi-Fi Direct Functions that provide operation in NIC's (Network Interface Card) point of view.
8 This file includes functions which unite multiple hal(Hardware) operations
9 and also take the responsibility of Software Resource Management in order
10 to keep the synchronization with Hardware Manipulation.
17 /*******************************************************************************
18 * C O M P I L E R F L A G S
19 ********************************************************************************
22 /*******************************************************************************
23 * E X T E R N A L R E F E R E N C E S
24 ********************************************************************************
29 /*******************************************************************************
31 ********************************************************************************
34 /*******************************************************************************
36 ********************************************************************************
39 /*******************************************************************************
41 ********************************************************************************
44 /*******************************************************************************
45 * P R I V A T E D A T A
46 ********************************************************************************
49 /*******************************************************************************
51 ********************************************************************************
54 /*******************************************************************************
55 * F U N C T I O N D E C L A R A T I O N S
56 ********************************************************************************
59 /*******************************************************************************
61 ********************************************************************************
65 /*----------------------------------------------------------------------------*/
67 * @brief When Probe Rsp & Beacon frame is received and decide a P2P device,
68 * this function will be invoked to buffer scan result
70 * @param prAdapter Pointer to the Adapter structure.
71 * @param prEventScanResult Pointer of EVENT_SCAN_RESULT_T.
75 /*----------------------------------------------------------------------------*/
78 IN P_ADAPTER_T prAdapter,
79 IN P_EVENT_P2P_DEV_DISCOVER_RESULT_T prP2pResult,
80 IN PUINT_8 pucRxIEBuf,
81 IN UINT_16 u2RxIELength
84 P_P2P_INFO_T prP2pInfo = (P_P2P_INFO_T)NULL;
85 P_EVENT_P2P_DEV_DISCOVER_RESULT_T prTargetResult = (P_EVENT_P2P_DEV_DISCOVER_RESULT_T)NULL;
87 BOOLEAN bUpdate = FALSE;
89 PUINT_8 pucIeBuf = (PUINT_8)NULL;
90 UINT_16 u2IELength = 0;
91 UINT_8 zeroMac[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
95 prP2pInfo = prAdapter->prP2pInfo;
97 for (u4Idx = 0; u4Idx < prP2pInfo->u4DeviceNum; u4Idx++) {
98 prTargetResult = &prP2pInfo->arP2pDiscoverResult[u4Idx];
100 if (EQUAL_MAC_ADDR(prTargetResult->aucDeviceAddr, prP2pResult->aucDeviceAddr)) {
103 /* Backup OLD buffer result. */
104 pucIeBuf = prTargetResult->pucIeBuf;
105 u2IELength = prTargetResult->u2IELength;
107 /* Update Device Info. */
109 kalMemZero(prTargetResult, sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T));
112 kalMemCopy(prTargetResult,
114 sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T));
116 /* See if new IE length is longer or not. */
117 if ((u2RxIELength > u2IELength) && (u2IELength != 0)) {
118 /* Buffer is not enough. */
119 u2RxIELength = u2IELength;
121 else if ((u2IELength == 0) && (u2RxIELength != 0)) {
123 ASSERT(pucIeBuf == NULL);
124 pucIeBuf = prP2pInfo->pucCurrIePtr;
126 if (((UINT_32)prP2pInfo->pucCurrIePtr + (UINT_32)u2RxIELength) >
127 (UINT_32)&prP2pInfo->aucCommIePool[CFG_MAX_COMMON_IE_BUF_LEN]) {
128 /* Common Buffer is no enough. */
129 u2RxIELength = (UINT_16)((UINT_32)&prP2pInfo->aucCommIePool[CFG_MAX_COMMON_IE_BUF_LEN] - (UINT_32)prP2pInfo->pucCurrIePtr);
132 /* Step to next buffer address. */
133 prP2pInfo->pucCurrIePtr = (PUINT_8)((UINT_32)prP2pInfo->pucCurrIePtr + (UINT_32)u2RxIELength);
136 /* Restore buffer pointer. */
137 prTargetResult->pucIeBuf = pucIeBuf;
140 /* If new received IE is availabe.
141 * Replace the old one & update new IE length.
143 kalMemCopy(pucIeBuf, pucRxIEBuf, u2RxIELength);
144 prTargetResult->u2IELength = u2RxIELength;
147 /* There is no new IE information, keep the old one. */
148 prTargetResult->u2IELength = u2IELength;
154 /* We would flush the whole scan result after each scan request is issued.
155 * If P2P device is too many, it may over the scan list.
157 if ((u4Idx < CFG_MAX_NUM_BSS_LIST) && (UNEQUAL_MAC_ADDR(zeroMac, prP2pResult->aucDeviceAddr))) { /* whsu:XXX */
158 prTargetResult = &prP2pInfo->arP2pDiscoverResult[u4Idx];
161 kalMemZero(prTargetResult, sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T));
164 kalMemCopy(prTargetResult,
166 sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T));
168 //printk("DVC FND %d " MACSTR", " MACSTR "\n", prP2pInfo->u4DeviceNum, MAC2STR(prP2pResult->aucDeviceAddr), MAC2STR(prTargetResult->aucDeviceAddr));
171 prTargetResult->pucIeBuf = prP2pInfo->pucCurrIePtr;
173 if (((UINT_32)prP2pInfo->pucCurrIePtr + (UINT_32)u2RxIELength) >
174 (UINT_32)&prP2pInfo->aucCommIePool[CFG_MAX_COMMON_IE_BUF_LEN]) {
175 /* Common Buffer is no enough. */
176 u2IELength = (UINT_16)((UINT_32)&prP2pInfo->aucCommIePool[CFG_MAX_COMMON_IE_BUF_LEN] - (UINT_32)prP2pInfo->pucCurrIePtr);
179 u2IELength = u2RxIELength;
182 prP2pInfo->pucCurrIePtr = (PUINT_8)((UINT_32)prP2pInfo->pucCurrIePtr + (UINT_32)u2IELength);
184 kalMemCopy((PVOID)prTargetResult->pucIeBuf, (PVOID)pucRxIEBuf, (UINT_32)u2IELength);
185 prTargetResult->u2IELength = u2IELength;
188 prTargetResult->pucIeBuf = NULL;
189 prTargetResult->u2IELength = 0;
192 prP2pInfo->u4DeviceNum++;
196 // TODO: Fixme to replace an old one. (?)
200 } /* nicRxAddP2pDevice */