Avoid beyond bounds copy while caching ACL
[zen-stable.git] / drivers / staging / bcm / hostmibs.c
blob101c4e31249e02f8381d289c946df3972524bb95
1 /*
2 * File Name: hostmibs.c
4 * Author: Beceem Communications Pvt. Ltd
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 */
10 #include "headers.h"
12 INT ProcessGetHostMibs(PMINI_ADAPTER Adapter, S_MIBS_HOST_STATS_MIBS *pstHostMibs)
14 S_SERVICEFLOW_ENTRY *pstServiceFlowEntry = NULL;
15 S_PHS_RULE *pstPhsRule = NULL;
16 S_CLASSIFIER_TABLE *pstClassifierTable = NULL;
17 S_CLASSIFIER_ENTRY *pstClassifierRule = NULL;
18 PPHS_DEVICE_EXTENSION pDeviceExtension = (PPHS_DEVICE_EXTENSION) &Adapter->stBCMPhsContext;
20 UINT nClassifierIndex = 0, nPhsTableIndex = 0, nSfIndex = 0, uiIndex = 0;
22 if (pDeviceExtension == NULL) {
23 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, HOST_MIBS, DBG_LVL_ALL, "Invalid Device Extension\n");
24 return STATUS_FAILURE;
27 /* Copy the classifier Table */
28 for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; nClassifierIndex++) {
29 if (Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE)
30 memcpy((PVOID) & pstHostMibs->
31 astClassifierTable[nClassifierIndex],
32 (PVOID) & Adapter->
33 astClassifierTable[nClassifierIndex],
34 sizeof(S_MIBS_CLASSIFIER_RULE));
37 /* Copy the SF Table */
38 for (nSfIndex = 0; nSfIndex < NO_OF_QUEUES; nSfIndex++) {
39 if (Adapter->PackInfo[nSfIndex].bValid) {
40 memcpy((PVOID) & pstHostMibs->astSFtable[nSfIndex],
41 (PVOID) & Adapter->PackInfo[nSfIndex],
42 sizeof(S_MIBS_SERVICEFLOW_TABLE));
43 } else {
44 /* If index in not valid,
45 * don't process this for the PHS table.
46 * Go For the next entry.
48 continue;
51 /* Retrieve the SFID Entry Index for requested Service Flow */
52 if (PHS_INVALID_TABLE_INDEX ==
53 GetServiceFlowEntry(pDeviceExtension->
54 pstServiceFlowPhsRulesTable,
55 Adapter->PackInfo[nSfIndex].
56 usVCID_Value, &pstServiceFlowEntry))
58 continue;
60 pstClassifierTable = pstServiceFlowEntry->pstClassifierTable;
62 for (uiIndex = 0; uiIndex < MAX_PHSRULE_PER_SF; uiIndex++) {
63 pstClassifierRule = &pstClassifierTable->stActivePhsRulesList[uiIndex];
65 if (pstClassifierRule->bUsed) {
66 pstPhsRule = pstClassifierRule->pstPhsRule;
68 pstHostMibs->astPhsRulesTable[nPhsTableIndex].
69 ulSFID = Adapter->PackInfo[nSfIndex].ulSFID;
71 memcpy(&pstHostMibs->
72 astPhsRulesTable[nPhsTableIndex].u8PHSI,
73 &pstPhsRule->u8PHSI, sizeof(S_PHS_RULE));
74 nPhsTableIndex++;
82 /* Copy other Host Statistics parameters */
83 pstHostMibs->stHostInfo.GoodTransmits = Adapter->dev->stats.tx_packets;
84 pstHostMibs->stHostInfo.GoodReceives = Adapter->dev->stats.rx_packets;
85 pstHostMibs->stHostInfo.CurrNumFreeDesc = atomic_read(&Adapter->CurrNumFreeTxDesc);
86 pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize;
87 pstHostMibs->stHostInfo.rtPSBucketSize = Adapter->rtPSBucketSize;
88 pstHostMibs->stHostInfo.TimerActive = Adapter->TimerActive;
89 pstHostMibs->stHostInfo.u32TotalDSD = Adapter->u32TotalDSD;
91 memcpy(pstHostMibs->stHostInfo.aTxPktSizeHist, Adapter->aTxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES);
92 memcpy(pstHostMibs->stHostInfo.aRxPktSizeHist, Adapter->aRxPktSizeHist, sizeof(UINT32) * MIBS_MAX_HIST_ENTRIES);
94 return STATUS_SUCCESS;
97 VOID GetDroppedAppCntrlPktMibs(S_MIBS_HOST_STATS_MIBS *pstHostMibs, const PPER_TARANG_DATA pTarang)
99 memcpy(&(pstHostMibs->stDroppedAppCntrlMsgs),
100 &(pTarang->stDroppedAppCntrlMsgs),
101 sizeof(S_MIBS_DROPPED_APP_CNTRL_MESSAGES));
104 VOID CopyMIBSExtendedSFParameters(PMINI_ADAPTER Adapter, CServiceFlowParamSI *psfLocalSet, UINT uiSearchRuleIndex)
106 S_MIBS_EXTSERVICEFLOW_PARAMETERS *t = &Adapter->PackInfo[uiSearchRuleIndex].stMibsExtServiceFlowTable;
108 t->wmanIfSfid = psfLocalSet->u32SFID;
109 t->wmanIfCmnCpsMaxSustainedRate = psfLocalSet->u32MaxSustainedTrafficRate;
110 t->wmanIfCmnCpsMaxTrafficBurst = psfLocalSet->u32MaxTrafficBurst;
111 t->wmanIfCmnCpsMinReservedRate = psfLocalSet->u32MinReservedTrafficRate;
112 t->wmanIfCmnCpsToleratedJitter = psfLocalSet->u32ToleratedJitter;
113 t->wmanIfCmnCpsMaxLatency = psfLocalSet->u32MaximumLatency;
114 t->wmanIfCmnCpsFixedVsVariableSduInd = psfLocalSet->u8FixedLengthVSVariableLengthSDUIndicator;
115 t->wmanIfCmnCpsFixedVsVariableSduInd = ntohl(t->wmanIfCmnCpsFixedVsVariableSduInd);
116 t->wmanIfCmnCpsSduSize = psfLocalSet->u8SDUSize;
117 t->wmanIfCmnCpsSduSize = ntohl(t->wmanIfCmnCpsSduSize);
118 t->wmanIfCmnCpsSfSchedulingType = psfLocalSet->u8ServiceFlowSchedulingType;
119 t->wmanIfCmnCpsSfSchedulingType = ntohl(t->wmanIfCmnCpsSfSchedulingType);
120 t->wmanIfCmnCpsArqEnable = psfLocalSet->u8ARQEnable;
121 t->wmanIfCmnCpsArqEnable = ntohl(t->wmanIfCmnCpsArqEnable);
122 t->wmanIfCmnCpsArqWindowSize = ntohs(psfLocalSet->u16ARQWindowSize);
123 t->wmanIfCmnCpsArqWindowSize = ntohl(t->wmanIfCmnCpsArqWindowSize);
124 t->wmanIfCmnCpsArqBlockLifetime = ntohs(psfLocalSet->u16ARQBlockLifeTime);
125 t->wmanIfCmnCpsArqBlockLifetime = ntohl(t->wmanIfCmnCpsArqBlockLifetime);
126 t->wmanIfCmnCpsArqSyncLossTimeout = ntohs(psfLocalSet->u16ARQSyncLossTimeOut);
127 t->wmanIfCmnCpsArqSyncLossTimeout = ntohl(t->wmanIfCmnCpsArqSyncLossTimeout);
128 t->wmanIfCmnCpsArqDeliverInOrder = psfLocalSet->u8ARQDeliverInOrder;
129 t->wmanIfCmnCpsArqDeliverInOrder = ntohl(t->wmanIfCmnCpsArqDeliverInOrder);
130 t->wmanIfCmnCpsArqRxPurgeTimeout = ntohs(psfLocalSet->u16ARQRxPurgeTimeOut);
131 t->wmanIfCmnCpsArqRxPurgeTimeout = ntohl(t->wmanIfCmnCpsArqRxPurgeTimeout);
132 t->wmanIfCmnCpsArqBlockSize = ntohs(psfLocalSet->u16ARQBlockSize);
133 t->wmanIfCmnCpsArqBlockSize = ntohl(t->wmanIfCmnCpsArqBlockSize);
134 t->wmanIfCmnCpsReqTxPolicy = psfLocalSet->u8RequesttransmissionPolicy;
135 t->wmanIfCmnCpsReqTxPolicy = ntohl(t->wmanIfCmnCpsReqTxPolicy);
136 t->wmanIfCmnSfCsSpecification = psfLocalSet->u8CSSpecification;
137 t->wmanIfCmnSfCsSpecification = ntohl(t->wmanIfCmnSfCsSpecification);
138 t->wmanIfCmnCpsTargetSaid = ntohs(psfLocalSet->u16TargetSAID);
139 t->wmanIfCmnCpsTargetSaid = ntohl(t->wmanIfCmnCpsTargetSaid);