Merge branch 'bugfixes' of git://git.linux-nfs.org/projects/trondmy/nfs-2.6
[pandora-kernel.git] / drivers / staging / bcm / hostmibs.c
1
2 /*
3  * File Name: hostmibs.c
4  *
5  * Author: Beceem Communications Pvt. Ltd
6  *
7  * Abstract: This file contains the routines to copy the statistics used by
8  * the driver to the Host MIBS structure and giving the same to Application.
9  *
10  */
11 #include "headers.h"
12
13 INT  ProcessGetHostMibs(PMINI_ADAPTER Adapter,
14                                                   PVOID ioBuffer,
15                                                   ULONG inputBufferLength)
16 {
17
18         S_MIBS_HOST_STATS_MIBS *pstHostMibs         = NULL;
19         S_SERVICEFLOW_ENTRY    *pstServiceFlowEntry = NULL;
20         S_PHS_RULE             *pstPhsRule          = NULL;
21         S_CLASSIFIER_TABLE     *pstClassifierTable  = NULL;
22         S_CLASSIFIER_ENTRY     *pstClassifierRule   = NULL;
23         PPHS_DEVICE_EXTENSION  pDeviceExtension     = (PPHS_DEVICE_EXTENSION)&Adapter->stBCMPhsContext;
24
25         UINT nClassifierIndex = 0, nPhsTableIndex = 0,nSfIndex = 0, uiIndex = 0;
26
27         if(pDeviceExtension == NULL)
28         {
29                 BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, HOST_MIBS, DBG_LVL_ALL, "Invalid Device Extension\n");
30                 return STATUS_FAILURE;
31         }
32
33         if(ioBuffer == NULL)
34         {
35                 return -EINVAL;
36         }
37         memset(ioBuffer,0,sizeof(S_MIBS_HOST_STATS_MIBS));
38
39         pstHostMibs = (S_MIBS_HOST_STATS_MIBS *)ioBuffer;
40
41
42         //Copy the classifier Table
43         for(nClassifierIndex=0; nClassifierIndex < MAX_CLASSIFIERS;
44                         nClassifierIndex++)
45         {
46                 if(Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE)
47                         memcpy((PVOID)&pstHostMibs->astClassifierTable[nClassifierIndex],
48                                 (PVOID)&Adapter->astClassifierTable[nClassifierIndex],
49                                 sizeof(S_MIBS_CLASSIFIER_RULE));
50         }
51
52   //Copy the SF Table
53         for(nSfIndex=0; nSfIndex < NO_OF_QUEUES ; nSfIndex++)
54         {
55         if(Adapter->PackInfo[nSfIndex].bValid)
56         {
57                         OsalMemMove((PVOID)&pstHostMibs->astSFtable[nSfIndex],(PVOID)&Adapter->PackInfo[nSfIndex],sizeof(S_MIBS_SERVICEFLOW_TABLE));
58         }
59         else
60         {
61                 //if index in not valid, don't process this for the PHS table. Go For the next entry.
62                 continue ;
63         }
64
65                 //Retrieve the SFID Entry Index for requested Service Flow
66                 if(PHS_INVALID_TABLE_INDEX == GetServiceFlowEntry(pDeviceExtension->pstServiceFlowPhsRulesTable,
67                                                   Adapter->PackInfo[nSfIndex].usVCID_Value ,&pstServiceFlowEntry))
68                 {
69
70                 continue;
71                 }
72
73                 pstClassifierTable = pstServiceFlowEntry->pstClassifierTable;
74
75
76                 for(uiIndex = 0; uiIndex < MAX_PHSRULE_PER_SF; uiIndex++)
77                 {
78                         pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[uiIndex];
79
80                 if(pstClassifierRule->bUsed)
81                 {
82                         pstPhsRule = pstClassifierRule->pstPhsRule;
83
84                         pstHostMibs->astPhsRulesTable[nPhsTableIndex].ulSFID = Adapter->PackInfo[nSfIndex].ulSFID;
85
86                         OsalMemMove(&pstHostMibs->astPhsRulesTable[nPhsTableIndex].u8PHSI,
87                                                 &pstPhsRule->u8PHSI,
88                                                 sizeof(S_PHS_RULE));
89                                 nPhsTableIndex++;
90
91                         }
92
93                 }
94
95         }
96
97
98
99         //copy other Host Statistics parameters
100         pstHostMibs->stHostInfo.GoodTransmits =
101                                 atomic_read(&Adapter->TxTotalPacketCount);
102         pstHostMibs->stHostInfo.GoodReceives =
103                                 atomic_read(&Adapter->GoodRxPktCount);
104         pstHostMibs->stHostInfo.CurrNumFreeDesc =
105                         atomic_read(&Adapter->CurrNumFreeTxDesc);
106         pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize;
107         pstHostMibs->stHostInfo.rtPSBucketSize = Adapter->rtPSBucketSize;
108         pstHostMibs->stHostInfo.TimerActive = Adapter->TimerActive;
109         pstHostMibs->stHostInfo.u32TotalDSD = Adapter->u32TotalDSD;
110
111         memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist,Adapter->aTxPktSizeHist,sizeof(UINT32)*MIBS_MAX_HIST_ENTRIES);
112         memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist,Adapter->aRxPktSizeHist,sizeof(UINT32)*MIBS_MAX_HIST_ENTRIES);
113
114         return STATUS_SUCCESS;
115 }
116
117
118 INT GetDroppedAppCntrlPktMibs(PVOID ioBuffer, PPER_TARANG_DATA pTarang)
119 {
120         S_MIBS_HOST_STATS_MIBS *pstHostMibs = (S_MIBS_HOST_STATS_MIBS *)ioBuffer;
121
122         memcpy((PVOID)&(pstHostMibs->stDroppedAppCntrlMsgs),(PVOID)&(pTarang->stDroppedAppCntrlMsgs),sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES));
123
124         return STATUS_SUCCESS ;
125 }
126
127
128 VOID CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter,
129                 CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex)
130 {
131         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfSfid = psfLocalSet->u32SFID;
132         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsMaxSustainedRate = psfLocalSet->u32MaxSustainedTrafficRate;
133         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsMaxTrafficBurst = psfLocalSet->u32MaxTrafficBurst;
134         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsMinReservedRate = psfLocalSet->u32MinReservedTrafficRate;
135         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsToleratedJitter = psfLocalSet->u32ToleratedJitter;
136         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsMaxLatency = psfLocalSet->u32MaximumLatency;
137         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsFixedVsVariableSduInd = psfLocalSet->u8FixedLengthVSVariableLengthSDUIndicator;
138         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsFixedVsVariableSduInd = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsFixedVsVariableSduInd);
139         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSduSize = psfLocalSet->u8SDUSize;
140         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSduSize = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSduSize);
141         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSfSchedulingType = psfLocalSet->u8ServiceFlowSchedulingType;
142         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSfSchedulingType = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsSfSchedulingType);
143         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqEnable = psfLocalSet->u8ARQEnable;
144         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqEnable = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqEnable);
145         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqWindowSize = ntohs(psfLocalSet->u16ARQWindowSize);
146         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqWindowSize = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqWindowSize);
147         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockLifetime = ntohs(psfLocalSet->u16ARQBlockLifeTime);
148         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockLifetime = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockLifetime);
149         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqSyncLossTimeout = ntohs(psfLocalSet->u16ARQSyncLossTimeOut);
150         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqSyncLossTimeout = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqSyncLossTimeout);
151         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqDeliverInOrder = psfLocalSet->u8ARQDeliverInOrder;
152         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqDeliverInOrder = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqDeliverInOrder);
153         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqRxPurgeTimeout = ntohs(psfLocalSet->u16ARQRxPurgeTimeOut);
154         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqRxPurgeTimeout = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqRxPurgeTimeout);
155         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockSize = ntohs(psfLocalSet->u16ARQBlockSize);
156         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockSize = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsArqBlockSize);
157         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsReqTxPolicy = psfLocalSet->u8RequesttransmissionPolicy;
158         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsReqTxPolicy = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsReqTxPolicy);
159         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnSfCsSpecification = psfLocalSet->u8CSSpecification;
160         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnSfCsSpecification = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnSfCsSpecification);
161         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsTargetSaid = ntohs(psfLocalSet->u16TargetSAID);
162         Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsTargetSaid = ntohl(Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable.wmanIfCmnCpsTargetSaid);
163
164 }