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(struct wb35_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(struct wb35_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(struct wb35_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(struct wb35_adapter * 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(struct wb35_adapter * adapter, s8 *pData)
{
int i;
// Reclaim the data buffer
for (i = 0; i < MAX_NUM_TX_MMPDU; i++) {
if (pData == (s8 *)&(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(struct wb35_adapter * 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;
}
|