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 /*----------------------------------------------------------------------------*/
77 nicRxAddP2pDevice(IN P_ADAPTER_T prAdapter
,
78 IN P_EVENT_P2P_DEV_DISCOVER_RESULT_T prP2pResult
,
79 IN PUINT_8 pucRxIEBuf
, IN UINT_16 u2RxIELength
)
81 P_P2P_INFO_T prP2pInfo
= (P_P2P_INFO_T
) NULL
;
82 P_EVENT_P2P_DEV_DISCOVER_RESULT_T prTargetResult
= (P_EVENT_P2P_DEV_DISCOVER_RESULT_T
) NULL
;
84 BOOLEAN bUpdate
= FALSE
;
86 PUINT_8 pucIeBuf
= (PUINT_8
) NULL
;
87 UINT_16 u2IELength
= 0;
88 UINT_8 zeroMac
[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
92 prP2pInfo
= prAdapter
->prP2pInfo
;
94 for (u4Idx
= 0; u4Idx
< prP2pInfo
->u4DeviceNum
; u4Idx
++) {
95 prTargetResult
= &prP2pInfo
->arP2pDiscoverResult
[u4Idx
];
97 if (EQUAL_MAC_ADDR(prTargetResult
->aucDeviceAddr
, prP2pResult
->aucDeviceAddr
)) {
100 /* Backup OLD buffer result. */
101 pucIeBuf
= prTargetResult
->pucIeBuf
;
102 u2IELength
= prTargetResult
->u2IELength
;
104 /* Update Device Info. */
106 kalMemZero(prTargetResult
, sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T
));
109 kalMemCopy(prTargetResult
,
110 (PVOID
) prP2pResult
, sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T
));
112 /* See if new IE length is longer or not. */
113 if ((u2RxIELength
> u2IELength
) && (u2IELength
!= 0)) {
114 /* Buffer is not enough. */
115 u2RxIELength
= u2IELength
;
116 } else if ((u2IELength
== 0) && (u2RxIELength
!= 0)) {
118 ASSERT(pucIeBuf
== NULL
);
119 pucIeBuf
= prP2pInfo
->pucCurrIePtr
;
121 if (((UINT_32
) prP2pInfo
->pucCurrIePtr
+ (UINT_32
) u2RxIELength
) >
122 (UINT_32
) &prP2pInfo
->
123 aucCommIePool
[CFG_MAX_COMMON_IE_BUF_LEN
]) {
124 /* Common Buffer is no enough. */
126 (UINT_16
) ((UINT_32
) &prP2pInfo
->
127 aucCommIePool
[CFG_MAX_COMMON_IE_BUF_LEN
] -
128 (UINT_32
) prP2pInfo
->pucCurrIePtr
);
131 /* Step to next buffer address. */
132 prP2pInfo
->pucCurrIePtr
=
133 (PUINT_8
) ((UINT_32
) prP2pInfo
->pucCurrIePtr
+
134 (UINT_32
) u2RxIELength
);
137 /* Restore buffer pointer. */
138 prTargetResult
->pucIeBuf
= pucIeBuf
;
141 /* If new received IE is availabe.
142 * Replace the old one & update new IE length.
144 kalMemCopy(pucIeBuf
, pucRxIEBuf
, u2RxIELength
);
145 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
,
165 (PVOID
) prP2pResult
, sizeof(EVENT_P2P_DEV_DISCOVER_RESULT_T
));
167 /* printk("DVC FND %d " MACSTR", " MACSTR "\n", prP2pInfo->u4DeviceNum, MAC2STR(prP2pResult->aucDeviceAddr), MAC2STR(prTargetResult->aucDeviceAddr)); */
170 prTargetResult
->pucIeBuf
= prP2pInfo
->pucCurrIePtr
;
172 if (((UINT_32
) prP2pInfo
->pucCurrIePtr
+ (UINT_32
) u2RxIELength
) >
173 (UINT_32
) &prP2pInfo
->
174 aucCommIePool
[CFG_MAX_COMMON_IE_BUF_LEN
]) {
175 /* Common Buffer is no enough. */
177 (UINT_16
) ((UINT_32
) &prP2pInfo
->
178 aucCommIePool
[CFG_MAX_COMMON_IE_BUF_LEN
] -
179 (UINT_32
) prP2pInfo
->pucCurrIePtr
);
181 u2IELength
= u2RxIELength
;
184 prP2pInfo
->pucCurrIePtr
=
185 (PUINT_8
) ((UINT_32
) prP2pInfo
->pucCurrIePtr
+
186 (UINT_32
) u2IELength
);
188 kalMemCopy((PVOID
) prTargetResult
->pucIeBuf
, (PVOID
) pucRxIEBuf
,
189 (UINT_32
) u2IELength
);
190 prTargetResult
->u2IELength
= u2IELength
;
192 prTargetResult
->pucIeBuf
= NULL
;
193 prTargetResult
->u2IELength
= 0;
196 prP2pInfo
->u4DeviceNum
++;
199 /* TODO: Fixme to replace an old one. (?) */
203 } /* nicRxAddP2pDevice */