added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / drivers / staging / rt2870 / common / netif_block.c
blobd3f7d087e7f06d876ae9629acc0e81518139211d
1 /*
2 *************************************************************************
3 * Ralink Tech Inc.
4 * 5F., No.36, Taiyuan St., Jhubei City,
5 * Hsinchu County 302,
6 * Taiwan, R.O.C.
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24 * *
25 *************************************************************************
28 #include "../rt_config.h"
29 #include "netif_block.h"
31 static NETIF_ENTRY freeNetIfEntryPool[FREE_NETIF_POOL_SIZE];
32 static LIST_HEADER freeNetIfEntryList;
34 void initblockQueueTab(
35 IN PRTMP_ADAPTER pAd)
37 int i;
39 initList(&freeNetIfEntryList);
40 for (i = 0; i < FREE_NETIF_POOL_SIZE; i++)
41 insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)&freeNetIfEntryPool[i]);
43 for (i=0; i < NUM_OF_TX_RING; i++)
44 initList(&pAd->blockQueueTab[i].NetIfList);
46 return;
49 BOOLEAN blockNetIf(
50 IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry,
51 IN PNET_DEV pNetDev)
53 PNETIF_ENTRY pNetIfEntry = NULL;
55 if ((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(&freeNetIfEntryList)) != NULL)
57 netif_stop_queue(pNetDev);
58 pNetIfEntry->pNetDev = pNetDev;
59 insertTailList(&pBlockQueueEntry->NetIfList, (PLIST_ENTRY)pNetIfEntry);
61 pBlockQueueEntry->SwTxQueueBlockFlag = TRUE;
62 DBGPRINT(RT_DEBUG_TRACE, ("netif_stop_queue(%s)\n", pNetDev->name));
64 else
65 return FALSE;
67 return TRUE;
70 VOID releaseNetIf(
71 IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry)
73 PNETIF_ENTRY pNetIfEntry = NULL;
74 PLIST_HEADER pNetIfList = &pBlockQueueEntry->NetIfList;
76 while((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(pNetIfList)) != NULL)
78 PNET_DEV pNetDev = pNetIfEntry->pNetDev;
79 netif_wake_queue(pNetDev);
80 insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)pNetIfEntry);
82 DBGPRINT(RT_DEBUG_TRACE, ("netif_wake_queue(%s)\n", pNetDev->name));
84 pBlockQueueEntry->SwTxQueueBlockFlag = FALSE;
85 return;
89 VOID StopNetIfQueue(
90 IN PRTMP_ADAPTER pAd,
91 IN UCHAR QueIdx,
92 IN PNDIS_PACKET pPacket)
94 PNET_DEV NetDev = NULL;
95 UCHAR IfIdx = 0;
96 BOOLEAN valid = FALSE;
98 #ifdef APCLI_SUPPORT
99 if (RTMP_GET_PACKET_NET_DEVICE(pPacket) >= MIN_NET_DEVICE_FOR_APCLI)
101 IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_APCLI) % MAX_APCLI_NUM;
102 NetDev = pAd->ApCfg.ApCliTab[IfIdx].dev;
104 else
105 #endif // APCLI_SUPPORT //
106 #ifdef WDS_SUPPORT
107 if (RTMP_GET_PACKET_NET_DEVICE(pPacket) >= MIN_NET_DEVICE_FOR_WDS)
109 IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_WDS) % MAX_WDS_ENTRY;
110 NetDev = pAd->WdsTab.WdsEntry[IfIdx].dev;
112 else
113 #endif // WDS_SUPPORT //
115 #ifdef MBSS_SUPPORT
116 if (pAd->OpMode == OPMODE_AP)
118 IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_MBSSID) % MAX_MBSSID_NUM;
119 NetDev = pAd->ApCfg.MBSSID[IfIdx].MSSIDDev;
121 else
123 IfIdx = MAIN_MBSSID;
124 NetDev = pAd->net_dev;
126 #else
127 IfIdx = MAIN_MBSSID;
128 NetDev = pAd->net_dev;
129 #endif
132 // WMM support 4 software queues.
133 // One software queue full doesn't mean device have no capbility to transmit packet.
134 // So disable block Net-If queue function while WMM enable.
135 #ifdef CONFIG_STA_SUPPORT
136 IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
137 valid = (pAd->CommonCfg.bWmmCapable == TRUE) ? FALSE : TRUE;
138 #endif // CONFIG_STA_SUPPORT //
140 if (valid)
141 blockNetIf(&pAd->blockQueueTab[QueIdx], NetDev);
142 return;