Staging: rt2860: remove dead BLOCK_NET_IF code
[linux-2.6] / drivers / staging / rt2870 / common / netif_block.c
1 /*
2  *************************************************************************
3  * Ralink Tech Inc.
4  * 5F., No.36, Taiyuan St., Jhubei City,
5  * Hsinchu County 302,
6  * Taiwan, R.O.C.
7  *
8  * (c) Copyright 2002-2007, Ralink Technology, Inc.
9  *
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  *************************************************************************
26  */
27
28 #include "../rt_config.h"
29 #include "netif_block.h"
30
31 static NETIF_ENTRY freeNetIfEntryPool[FREE_NETIF_POOL_SIZE];
32 static LIST_HEADER freeNetIfEntryList;
33
34 void initblockQueueTab(
35         IN PRTMP_ADAPTER pAd)
36 {
37         int i;
38
39         initList(&freeNetIfEntryList);
40         for (i = 0; i < FREE_NETIF_POOL_SIZE; i++)
41                 insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)&freeNetIfEntryPool[i]);
42
43         for (i=0; i < NUM_OF_TX_RING; i++)
44                 initList(&pAd->blockQueueTab[i].NetIfList);
45
46         return;
47 }
48
49 BOOLEAN blockNetIf(
50         IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry,
51         IN PNET_DEV pNetDev)
52 {
53         PNETIF_ENTRY pNetIfEntry = NULL;
54
55         if ((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(&freeNetIfEntryList)) != NULL)
56         {
57                 netif_stop_queue(pNetDev);
58                 pNetIfEntry->pNetDev = pNetDev;
59                 insertTailList(&pBlockQueueEntry->NetIfList, (PLIST_ENTRY)pNetIfEntry);
60
61                 pBlockQueueEntry->SwTxQueueBlockFlag = TRUE;
62                 DBGPRINT(RT_DEBUG_TRACE, ("netif_stop_queue(%s)\n", pNetDev->name));
63         }
64         else
65                 return FALSE;
66
67         return TRUE;
68 }
69
70 VOID releaseNetIf(
71         IN PBLOCK_QUEUE_ENTRY pBlockQueueEntry)
72 {
73         PNETIF_ENTRY pNetIfEntry = NULL;
74         PLIST_HEADER pNetIfList = &pBlockQueueEntry->NetIfList;
75
76         while((pNetIfEntry = (PNETIF_ENTRY)removeHeadList(pNetIfList)) !=  NULL)
77         {
78                 PNET_DEV pNetDev = pNetIfEntry->pNetDev;
79                 netif_wake_queue(pNetDev);
80                 insertTailList(&freeNetIfEntryList, (PLIST_ENTRY)pNetIfEntry);
81
82                 DBGPRINT(RT_DEBUG_TRACE, ("netif_wake_queue(%s)\n", pNetDev->name));
83         }
84         pBlockQueueEntry->SwTxQueueBlockFlag = FALSE;
85         return;
86 }
87
88
89 VOID StopNetIfQueue(
90         IN PRTMP_ADAPTER pAd,
91         IN UCHAR QueIdx,
92         IN PNDIS_PACKET pPacket)
93 {
94         PNET_DEV NetDev = NULL;
95         UCHAR IfIdx = 0;
96         BOOLEAN valid = FALSE;
97
98         {
99 #ifdef MBSS_SUPPORT
100                 if (pAd->OpMode == OPMODE_AP)
101                 {
102                         IfIdx = (RTMP_GET_PACKET_NET_DEVICE(pPacket) - MIN_NET_DEVICE_FOR_MBSSID) % MAX_MBSSID_NUM;
103                         NetDev = pAd->ApCfg.MBSSID[IfIdx].MSSIDDev;
104                 }
105                 else
106                 {
107                         IfIdx = MAIN_MBSSID;
108                         NetDev = pAd->net_dev;
109                 }
110 #else
111                 IfIdx = MAIN_MBSSID;
112                 NetDev = pAd->net_dev;
113 #endif
114         }
115
116         // WMM support 4 software queues.
117         // One software queue full doesn't mean device have no capbility to transmit packet.
118         // So disable block Net-If queue function while WMM enable.
119 #ifdef CONFIG_STA_SUPPORT
120         IF_DEV_CONFIG_OPMODE_ON_STA(pAd)
121                 valid = (pAd->CommonCfg.bWmmCapable == TRUE) ? FALSE : TRUE;
122 #endif // CONFIG_STA_SUPPORT //
123
124         if (valid)
125                 blockNetIf(&pAd->blockQueueTab[QueIdx], NetDev);
126         return;
127 }
128