qcacmn: correct napi bucket calculation

NAPI bucket calculation was resulting in bucket number which was out of
bounds for the number of buckets.
Calculate bucket index correctly and check for out of bound
condition.

CRs-Fixed: 1091483
Change-Id: Ieb81b2eeec546a6128c6b878db4c65ccb8b62bda
This commit is contained in:
Mohit Khanna
2016-11-17 12:25:49 -08:00
committed by Sandeep Puligilla
parent 9ee4b9e84a
commit 200e660f21

View File

@@ -758,7 +758,12 @@ int hif_napi_poll(struct hif_opaque_softc *hif_ctx, struct napi_struct *napi,
*/
if (rc)
normalized++;
bucket = (normalized / QCA_NAPI_DEF_SCALE);
bucket = normalized / (QCA_NAPI_BUDGET / QCA_NAPI_NUM_BUCKETS);
if (bucket >= QCA_NAPI_NUM_BUCKETS) {
bucket = QCA_NAPI_NUM_BUCKETS - 1;
HIF_ERROR("Bad bucket#(%d) > QCA_NAPI_NUM_BUCKETS(%d)",
bucket, QCA_NAPI_NUM_BUCKETS);
}
napi_info->stats[cpu].napi_budget_uses[bucket]++;
/* if ce_per engine reports 0, then poll should be terminated */