1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
//============================================================================
// Module Name:
// MLMETxRx.C
//
// Description:
// The interface between MDS (MAC Data Service) and MLME.
//
// Revision History:
// --------------------------------------------------------------------------
// 200209 UN20 Jennifer Xu
// Initial Release
// 20021108 PD43 Austin Liu
// 20030117 PD43 Austin Liu
// Deleted MLMEReturnPacket and MLMEProcThread()
//
// Copyright (c) 1996-2002 Winbond Electronics Corp. All Rights Reserved.
//============================================================================
#include "os_common.h"
void MLMEResetTxRx(PWB32_ADAPTER Adapter)
{
s32 i;
// Reset the interface between MDS and MLME
for (i = 0; i < MAX_NUM_TX_MMPDU; i++)
Adapter->sMlmeFrame.TxMMPDUInUse[i] = FALSE;
for (i = 0; i < MAX_NUM_RX_MMPDU; i++)
Adapter->sMlmeFrame.SaveRxBufSlotInUse[i] = FALSE;
Adapter->sMlmeFrame.wNumRxMMPDUInMLME = 0;
Adapter->sMlmeFrame.wNumRxMMPDUDiscarded = 0;
Adapter->sMlmeFrame.wNumRxMMPDU = 0;
Adapter->sMlmeFrame.wNumTxMMPDUDiscarded = 0;
Adapter->sMlmeFrame.wNumTxMMPDU = 0;
Adapter->sLocalPara.boCCAbusy = FALSE;
Adapter->sLocalPara.iPowerSaveMode = PWR_ACTIVE; // Power active
}
//=============================================================================
// Function:
// MLMEGetMMPDUBuffer()
//
// Description:
// Return the pointer to an available data buffer with
// the size MAX_MMPDU_SIZE for a MMPDU.
//
// Arguments:
// Adapter - pointer to the miniport adapter context.
//
// Return value:
// NULL : No available data buffer available
// Otherwise: Pointer to the data buffer
//=============================================================================
/* FIXME: Should this just be replaced with kmalloc() and kfree()? */
u8 *MLMEGetMMPDUBuffer(PWB32_ADAPTER Adapter)
{
s32 i;
u8 *returnVal;
for (i = 0; i< MAX_NUM_TX_MMPDU; i++) {
if (Adapter->sMlmeFrame.TxMMPDUInUse[i] == FALSE)
break;
}
if (i >= MAX_NUM_TX_MMPDU) return NULL;
returnVal = (u8 *)&(Adapter->sMlmeFrame.TxMMPDU[i]);
Adapter->sMlmeFrame.TxMMPDUInUse[i] = TRUE;
return returnVal;
}
//=============================================================================
u8 MLMESendFrame(PWB32_ADAPTER Adapter, u8 *pMMPDU, u16 len, u8 DataType)
/* DataType : FRAME_TYPE_802_11_MANAGEMENT, FRAME_TYPE_802_11_MANAGEMENT_CHALLENGE,
FRAME_TYPE_802_11_DATA */
{
if (Adapter->sMlmeFrame.IsInUsed != PACKET_FREE_TO_USE) {
Adapter->sMlmeFrame.wNumTxMMPDUDiscarded++;
return FALSE;
}
Adapter->sMlmeFrame.IsInUsed = PACKET_COME_FROM_MLME;
// Keep information for sending
Adapter->sMlmeFrame.pMMPDU = pMMPDU;
Adapter->sMlmeFrame.DataType = DataType;
// len must be the last setting due to QUERY_SIZE_SECOND of Mds
Adapter->sMlmeFrame.len = len;
Adapter->sMlmeFrame.wNumTxMMPDU++;
// H/W will enter power save by set the register. S/W don't send null frame
//with PWRMgt bit enbled to enter power save now.
// Transmit NDIS packet
Mds_Tx(Adapter);
return TRUE;
}
void
MLME_GetNextPacket(PADAPTER Adapter, PDESCRIPTOR pDes)
{
#define DESCRIPTOR_ADD_BUFFER( _D, _A, _S ) \
{\
_D->InternalUsed = _D->buffer_start_index + _D->buffer_number; \
_D->InternalUsed %= MAX_DESCRIPTOR_BUFFER_INDEX; \
_D->buffer_address[ _D->InternalUsed ] = _A; \
_D->buffer_size[ _D->InternalUsed ] = _S; \
_D->buffer_total_size += _S; \
_D->buffer_number++;\
}
DESCRIPTOR_ADD_BUFFER( pDes, Adapter->sMlmeFrame.pMMPDU, Adapter->sMlmeFrame.len );
pDes->Type = Adapter->sMlmeFrame.DataType;
}
void MLMEfreeMMPDUBuffer(PWB32_ADAPTER Adapter, PCHAR pData)
{
int i;
// Reclaim the data buffer
for (i = 0; i < MAX_NUM_TX_MMPDU; i++) {
if (pData == (PCHAR)&(Adapter->sMlmeFrame.TxMMPDU[i]))
break;
}
if (Adapter->sMlmeFrame.TxMMPDUInUse[i])
Adapter->sMlmeFrame.TxMMPDUInUse[i] = FALSE;
else {
// Something wrong
// PD43 Add debug code here???
}
}
void
MLME_SendComplete(PADAPTER Adapter, u8 PacketID, unsigned char SendOK)
{
MLME_TXCALLBACK TxCallback;
// Reclaim the data buffer
Adapter->sMlmeFrame.len = 0;
MLMEfreeMMPDUBuffer( Adapter, Adapter->sMlmeFrame.pMMPDU );
TxCallback.bResult = MLME_SUCCESS;
// Return resource
Adapter->sMlmeFrame.IsInUsed = PACKET_FREE_TO_USE;
}
|