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