Browse Source

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
Mohit Khanna 8 years ago
parent
commit
200e660f21
1 changed files with 6 additions and 1 deletions
  1. 6 1
      hif/src/hif_napi.c

+ 6 - 1
hif/src/hif_napi.c

@@ -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 */