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"
22 void MLMEResetTxRx(struct wbsoft_priv * adapter)
26 // Reset the interface between MDS and MLME
27 for (i = 0; i < MAX_NUM_TX_MMPDU; i++)
28 adapter->sMlmeFrame.TxMMPDUInUse[i] = false;
29 for (i = 0; i < MAX_NUM_RX_MMPDU; i++)
30 adapter->sMlmeFrame.SaveRxBufSlotInUse[i] = false;
32 adapter->sMlmeFrame.wNumRxMMPDUInMLME = 0;
33 adapter->sMlmeFrame.wNumRxMMPDUDiscarded = 0;
34 adapter->sMlmeFrame.wNumRxMMPDU = 0;
35 adapter->sMlmeFrame.wNumTxMMPDUDiscarded = 0;
36 adapter->sMlmeFrame.wNumTxMMPDU = 0;
37 adapter->sLocalPara.boCCAbusy = false;
38 adapter->sLocalPara.iPowerSaveMode = PWR_ACTIVE; // Power active
41 //=============================================================================
43 // MLMEGetMMPDUBuffer()
46 // Return the pointer to an available data buffer with
47 // the size MAX_MMPDU_SIZE for a MMPDU.
50 // adapter - pointer to the miniport adapter context.
53 // NULL : No available data buffer available
54 // Otherwise: Pointer to the data buffer
55 //=============================================================================
57 /* FIXME: Should this just be replaced with kmalloc() and kfree()? */
58 u8 *MLMEGetMMPDUBuffer(struct wbsoft_priv * adapter)
63 for (i = 0; i< MAX_NUM_TX_MMPDU; i++) {
64 if (adapter->sMlmeFrame.TxMMPDUInUse[i] == false)
67 if (i >= MAX_NUM_TX_MMPDU) return NULL;
69 returnVal = (u8 *)&(adapter->sMlmeFrame.TxMMPDU[i]);
70 adapter->sMlmeFrame.TxMMPDUInUse[i] = true;
75 //=============================================================================
76 u8 MLMESendFrame(struct wbsoft_priv * adapter, u8 *pMMPDU, u16 len, u8 DataType)
77 /* DataType : FRAME_TYPE_802_11_MANAGEMENT, FRAME_TYPE_802_11_MANAGEMENT_CHALLENGE,
78 FRAME_TYPE_802_11_DATA */
80 if (adapter->sMlmeFrame.IsInUsed != PACKET_FREE_TO_USE) {
81 adapter->sMlmeFrame.wNumTxMMPDUDiscarded++;
84 adapter->sMlmeFrame.IsInUsed = PACKET_COME_FROM_MLME;
86 // Keep information for sending
87 adapter->sMlmeFrame.pMMPDU = pMMPDU;
88 adapter->sMlmeFrame.DataType = DataType;
89 // len must be the last setting due to QUERY_SIZE_SECOND of Mds
90 adapter->sMlmeFrame.len = len;
91 adapter->sMlmeFrame.wNumTxMMPDU++;
93 // H/W will enter power save by set the register. S/W don't send null frame
94 //with PWRMgt bit enbled to enter power save now.
96 // Transmit NDIS packet
101 void MLME_GetNextPacket(struct wbsoft_priv *adapter, PDESCRIPTOR desc)
103 desc->InternalUsed = desc->buffer_start_index + desc->buffer_number;
104 desc->InternalUsed %= MAX_DESCRIPTOR_BUFFER_INDEX;
105 desc->buffer_address[desc->InternalUsed] = adapter->sMlmeFrame.pMMPDU;
106 desc->buffer_size[desc->InternalUsed] = adapter->sMlmeFrame.len;
107 desc->buffer_total_size += adapter->sMlmeFrame.len;
108 desc->buffer_number++;
109 desc->Type = adapter->sMlmeFrame.DataType;
112 void MLMEfreeMMPDUBuffer(struct wbsoft_priv * adapter, s8 *pData)
116 // Reclaim the data buffer
117 for (i = 0; i < MAX_NUM_TX_MMPDU; i++) {
118 if (pData == (s8 *)&(adapter->sMlmeFrame.TxMMPDU[i]))
121 if (adapter->sMlmeFrame.TxMMPDUInUse[i])
122 adapter->sMlmeFrame.TxMMPDUInUse[i] = false;
125 // PD43 Add debug code here???
130 MLME_SendComplete(struct wbsoft_priv * adapter, u8 PacketID, unsigned char SendOK)
132 MLME_TXCALLBACK TxCallback;
134 // Reclaim the data buffer
135 adapter->sMlmeFrame.len = 0;
136 MLMEfreeMMPDUBuffer( adapter, adapter->sMlmeFrame.pMMPDU );
139 TxCallback.bResult = MLME_SUCCESS;
142 adapter->sMlmeFrame.IsInUsed = PACKET_FREE_TO_USE;