summaryrefslogtreecommitdiff
path: root/hif
diff options
context:
space:
mode:
authorchenguo <chenguo@codeaurora.org>2017-11-08 16:33:25 +0800
committersnandini <snandini@codeaurora.org>2017-11-27 22:40:17 -0800
commitf254886c3dd596a9ad28d990b07011da61b87ca1 (patch)
tree7e1218d17da2b76fa04fb2e942fc6a1e60862ce2 /hif
parent98b30de85218a2f2808b9e22b77bba1e86aa6591 (diff)
downloadqca-wfi-host-cmn-f254886c3dd596a9ad28d990b07011da61b87ca1.tar.gz
qcacmn: Mapping between NAPI budget and internal budget
There is a scale factor mapping between NAPI budget and internal budget. Add logic for this dynamic translation. CRs-Fixed: 2140049 Change-Id: Iac03bd431ab7a416a87e488b14bc8b5c1bb7869f
Diffstat (limited to 'hif')
-rw-r--r--hif/inc/hif.h18
-rw-r--r--hif/src/hif_exec.c35
-rw-r--r--hif/src/hif_exec.h1
3 files changed, 40 insertions, 14 deletions
diff --git a/hif/inc/hif.h b/hif/inc/hif.h
index f55f21b31..24192e345 100644
--- a/hif/inc/hif.h
+++ b/hif/inc/hif.h
@@ -167,16 +167,20 @@ struct CE_state;
#ifndef NAPI_YIELD_BUDGET_BASED
#ifdef HIF_CONFIG_SLUB_DEBUG_ON
-#define QCA_NAPI_BUDGET 64
-#define QCA_NAPI_DEF_SCALE 2
+#define QCA_NAPI_DEF_SCALE_BIN_SHIFT 1
#else /* PERF build */
-#define QCA_NAPI_BUDGET 64
-#define QCA_NAPI_DEF_SCALE 16
+#ifdef CONFIG_WIN
+#define QCA_NAPI_DEF_SCALE_BIN_SHIFT 1
+#else
+#define QCA_NAPI_DEF_SCALE_BIN_SHIFT 4
+#endif /* CONFIG_WIN */
#endif /* SLUB_DEBUG_ON */
-#else /* NAPI_YIELD_BUDGET_BASED */
+#else /* NAPI_YIELD_BUDGET_BASED */
+#define QCA_NAPI_DEF_SCALE_BIN_SHIFT 2
+#endif /* NAPI_YIELD_BUDGET_BASED */
#define QCA_NAPI_BUDGET 64
-#define QCA_NAPI_DEF_SCALE 4
-#endif
+#define QCA_NAPI_DEF_SCALE \
+ (1 << QCA_NAPI_DEF_SCALE_BIN_SHIFT)
#define HIF_NAPI_MAX_RECEIVES (QCA_NAPI_BUDGET * QCA_NAPI_DEF_SCALE)
/* NOTE: "napi->scale" can be changed,
diff --git a/hif/src/hif_exec.c b/hif/src/hif_exec.c
index 15d8f60e3..748c3c8a6 100644
--- a/hif/src/hif_exec.c
+++ b/hif/src/hif_exec.c
@@ -20,6 +20,15 @@
#include <ce_main.h>
#include <hif_irq_affinity.h>
+/* mapping NAPI budget 0 to internal budget 0
+ * NAPI budget 1 to internal budget [1,scaler -1]
+ * NAPI budget 2 to internal budget [scaler, 2 * scaler - 1], etc
+ */
+#define NAPI_BUDGET_TO_INTERNAL_BUDGET(n, s) \
+ (((n) << (s)) - 1)
+#define INTERNAL_BUDGET_TO_NAPI_BUDGET(n, s) \
+ (((n) >> (s)) + 1)
+
static struct hif_exec_context *hif_exec_tasklet_create(void);
/**
@@ -102,11 +111,16 @@ static int hif_exec_poll(struct napi_struct *napi, int budget)
struct hif_exec_context *hif_ext_group = &exec_ctx->exec_ctx;
struct hif_softc *scn = HIF_GET_SOFTC(hif_ext_group->hif);
int work_done;
+ int normalized_budget = 0;
+ int shift = hif_ext_group->scale_bin_shift;
int cpu = smp_processor_id();
- work_done = hif_ext_group->handler(hif_ext_group->context, budget);
+ if (budget)
+ normalized_budget = NAPI_BUDGET_TO_INTERNAL_BUDGET(budget, shift);
+ work_done = hif_ext_group->handler(hif_ext_group->context,
+ normalized_budget);
- if (work_done < budget) {
+ if (work_done < normalized_budget) {
napi_complete(napi);
qdf_atomic_dec(&scn->active_grp_tasklet_cnt);
hif_ext_group->irq_enable(hif_ext_group);
@@ -114,12 +128,16 @@ static int hif_exec_poll(struct napi_struct *napi, int budget)
} else {
/* if the ext_group supports time based yield, claim full work
* done anyways */
- work_done = budget;
+ work_done = normalized_budget;
}
hif_ext_group->stats[cpu].napi_polls++;
hif_ext_group->stats[cpu].napi_workdone += work_done;
+ /* map internal budget to NAPI budget */
+ if (work_done)
+ work_done = INTERNAL_BUDGET_TO_NAPI_BUDGET(work_done, shift);
+
return work_done;
}
@@ -163,8 +181,10 @@ struct hif_execution_ops napi_sched_ops = {
#ifdef FEATURE_NAPI
/**
* hif_exec_napi_create() - allocate and initialize a napi exec context
+ * @scale: a binary shift factor to map NAPI budget from\to internal
+ * budget
*/
-static struct hif_exec_context *hif_exec_napi_create(uint32_t budget)
+static struct hif_exec_context *hif_exec_napi_create(uint32_t scale)
{
struct hif_napi_exec_context *ctx;
@@ -174,15 +194,16 @@ static struct hif_exec_context *hif_exec_napi_create(uint32_t budget)
ctx->exec_ctx.sched_ops = &napi_sched_ops;
ctx->exec_ctx.inited = true;
+ ctx->exec_ctx.scale_bin_shift = scale;
init_dummy_netdev(&(ctx->netdev));
netif_napi_add(&(ctx->netdev), &(ctx->napi), hif_exec_poll,
- budget);
+ QCA_NAPI_BUDGET);
napi_enable(&ctx->napi);
return &ctx->exec_ctx;
}
#else
-static struct hif_exec_context *hif_exec_napi_create(uint32_t budget)
+static struct hif_exec_context *hif_exec_napi_create(uint32_t scale)
{
HIF_WARN("%s: FEATURE_NAPI not defined, making tasklet");
return hif_exec_tasklet_create();
@@ -396,7 +417,7 @@ struct hif_exec_context *hif_exec_create(enum hif_exec_type type,
switch (type) {
case HIF_EXEC_NAPI_TYPE:
- return hif_exec_napi_create(QCA_NAPI_BUDGET * scale);
+ return hif_exec_napi_create(scale);
case HIF_EXEC_TASKLET_TYPE:
return hif_exec_tasklet_create();
diff --git a/hif/src/hif_exec.h b/hif/src/hif_exec.h
index a3e7ea175..b15e2bbc7 100644
--- a/hif/src/hif_exec.h
+++ b/hif/src/hif_exec.h
@@ -56,6 +56,7 @@ struct hif_exec_context {
uint32_t irq[HIF_MAX_GRP_IRQ];
uint32_t os_irq[HIF_MAX_GRP_IRQ];
uint32_t grp_id;
+ uint32_t scale_bin_shift;
const char *context_name;
void *context;
ext_intr_handler handler;