1 //============================================================================
6 // The interface between MDS (MAC Data Service) and MLME.
9 // --------------------------------------------------------------------------
10 // 200209 UN20 Jennifer Xu
12 // 20021108 PD43 Austin Liu
13 // 20030117 PD43 Austin Liu
14 // Deleted MLMEReturnPacket and MLMEProcThread()
16 // Copyright (c) 1996-2002 Winbond Electronics Corp. All Rights Reserved.
17 //============================================================================
18 #include "os_common.h"
20 void MLMEResetTxRx(PWB32_ADAPTER Adapter)
24 // Reset the interface between MDS and MLME
25 for (i = 0; i < MAX_NUM_TX_MMPDU; i++)
26 Adapter->sMlmeFrame.TxMMPDUInUse[i] = FALSE;
27 for (i = 0; i < MAX_NUM_RX_MMPDU; i++)
28 Adapter->sMlmeFrame.SaveRxBufSlotInUse[i] = FALSE;
30 Adapter->sMlmeFrame.wNumRxMMPDUInMLME = 0;
31 Adapter->sMlmeFrame.wNumRxMMPDUDiscarded = 0;
32 Adapter->sMlmeFrame.wNumRxMMPDU = 0;
33 Adapter->sMlmeFrame.wNumTxMMPDUDiscarded = 0;
34 Adapter->sMlmeFrame.wNumTxMMPDU = 0;
35 Adapter->sLocalPara.boCCAbusy = FALSE;
36 Adapter->sLocalPara.iPowerSaveMode = PWR_ACTIVE; // Power active
39 //=============================================================================
41 // MLMEGetMMPDUBuffer()
44 // Return the pointer to an available data buffer with
45 // the size MAX_MMPDU_SIZE for a MMPDU.
48 // Adapter - pointer to the miniport adapter context.
51 // NULL : No available data buffer available
52 // Otherwise: Pointer to the data buffer
53 //=============================================================================
55 /* FIXME: Should this just be replaced with kmalloc() and kfree()? */
56 u8 *MLMEGetMMPDUBuffer(PWB32_ADAPTER Adapter)
61 for (i = 0; i< MAX_NUM_TX_MMPDU; i++) {
62 if (Adapter->sMlmeFrame.TxMMPDUInUse[i] == FALSE)
65 if (i >= MAX_NUM_TX_MMPDU) return NULL;
67 returnVal = (u8 *)&(Adapter->sMlmeFrame.TxMMPDU[i]);
68 Adapter->sMlmeFrame.TxMMPDUInUse[i] = TRUE;
73 //=============================================================================
74 u8 MLMESendFrame(PWB32_ADAPTER Adapter, u8 *pMMPDU, u16 len, u8 DataType)
75 /* DataType : FRAME_TYPE_802_11_MANAGEMENT, FRAME_TYPE_802_11_MANAGEMENT_CHALLENGE,
76 FRAME_TYPE_802_11_DATA */
78 if (Adapter->sMlmeFrame.IsInUsed != PACKET_FREE_TO_USE) {
79 Adapter->sMlmeFrame.wNumTxMMPDUDiscarded++;
82 Adapter->sMlmeFrame.IsInUsed = PACKET_COME_FROM_MLME;
84 // Keep information for sending
85 Adapter->sMlmeFrame.pMMPDU = pMMPDU;
86 Adapter->sMlmeFrame.DataType = DataType;
87 // len must be the last setting due to QUERY_SIZE_SECOND of Mds
88 Adapter->sMlmeFrame.len = len;
89 Adapter->sMlmeFrame.wNumTxMMPDU++;
91 // H/W will enter power save by set the register. S/W don't send null frame
92 //with PWRMgt bit enbled to enter power save now.
94 // Transmit NDIS packet
100 MLME_GetNextPacket(PADAPTER Adapter, PDESCRIPTOR pDes)
102 #define DESCRIPTOR_ADD_BUFFER( _D, _A, _S ) \
104 _D->InternalUsed = _D->buffer_start_index + _D->buffer_number; \
105 _D->InternalUsed %= MAX_DESCRIPTOR_BUFFER_INDEX; \
106 _D->buffer_address[ _D->InternalUsed ] = _A; \
107 _D->buffer_size[ _D->InternalUsed ] = _S; \
108 _D->buffer_total_size += _S; \
109 _D->buffer_number++;\
112 DESCRIPTOR_ADD_BUFFER( pDes, Adapter->sMlmeFrame.pMMPDU, Adapter->sMlmeFrame.len );
113 pDes->Type = Adapter->sMlmeFrame.DataType;
116 void MLMEfreeMMPDUBuffer(PWB32_ADAPTER Adapter, s8 *pData)
120 // Reclaim the data buffer
121 for (i = 0; i < MAX_NUM_TX_MMPDU; i++) {
122 if (pData == (s8 *)&(Adapter->sMlmeFrame.TxMMPDU[i]))
125 if (Adapter->sMlmeFrame.TxMMPDUInUse[i])
126 Adapter->sMlmeFrame.TxMMPDUInUse[i] = FALSE;
129 // PD43 Add debug code here???
134 MLME_SendComplete(PADAPTER Adapter, u8 PacketID, unsigned char SendOK)
136 MLME_TXCALLBACK TxCallback;
138 // Reclaim the data buffer
139 Adapter->sMlmeFrame.len = 0;
140 MLMEfreeMMPDUBuffer( Adapter, Adapter->sMlmeFrame.pMMPDU );
143 TxCallback.bResult = MLME_SUCCESS;
146 Adapter->sMlmeFrame.IsInUsed = PACKET_FREE_TO_USE;