summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHouston Hoffman <hhoffman@codeaurora.org>2016-11-15 10:42:27 -0800
committerqcabuildsw <qcabuildsw@localhost>2016-11-28 14:09:36 -0800
commit83e956719a0b3e549e3d3ed211b73f3170bb76bb (patch)
treeb42208731564c8c92e33bd8e0780d1b19c8bfc74
parent0cc9b711b8776e4fd3c35e096a994167196d6e38 (diff)
qcacmn: Remove cds from napi hot_plug_notifier functionality
Instead of using cds to get the hif context in the notifier callback rely on the context_of semantics to traverse back to the hif context. Change-Id: I7d57f9dcf8c09836c34ce16a4acaa8c3bc1624b9 CRs-Fixed: 1092842
-rw-r--r--hif/inc/hif.h2
-rw-r--r--hif/inc/hif_napi.h16
-rw-r--r--hif/src/hif_napi.c55
3 files changed, 38 insertions, 35 deletions
diff --git a/hif/inc/hif.h b/hif/inc/hif.h
index d5d9634bd72d..8b50a179a336 100644
--- a/hif/inc/hif.h
+++ b/hif/inc/hif.h
@@ -183,7 +183,6 @@ struct qca_napi_cpu {
*
* A variable of this type will be stored in hif module context.
*/
-
struct qca_napi_data {
spinlock_t lock;
uint32_t state;
@@ -195,6 +194,7 @@ struct qca_napi_data {
struct qca_napi_cpu napi_cpu[NR_CPUS];
int lilcl_head, bigcl_head;
enum qca_napi_tput_state napi_mode;
+ struct notifier_block hnc_cpu_notifier;
};
/**
diff --git a/hif/inc/hif_napi.h b/hif/inc/hif_napi.h
index 8d34dd34a233..c0f7b90ac4ff 100644
--- a/hif/inc/hif_napi.h
+++ b/hif/inc/hif_napi.h
@@ -171,19 +171,21 @@ static inline void hif_napi_update_yield_stats(struct CE_state *ce_state,
*/
/* fw-declare to make compiler happy */
struct qca_napi_data;
-static inline int hif_napi_cpu_init(void *ctx) { return 0; }
-static inline int hif_napi_cpu_deinit(void *ctx) { return 0; }
+static inline int hif_napi_cpu_init(struct hif_opaque_softc *hif)
+{ return 0; }
+
+static inline int hif_napi_cpu_deinit(struct hif_opaque_softc *hif)
+{ return 0; }
+
static inline int hif_napi_serialize(struct hif_opaque_softc *hif, int is_on)
-{
- return -EPERM;
-}
+{ return -EPERM; }
#else /* HELIUMPLUS - NAPI CPU symbols are valid */
/*
* prototype signatures
*/
-int hif_napi_cpu_init(void *);
-int hif_napi_cpu_deinit(void *);
+int hif_napi_cpu_init(struct hif_opaque_softc *hif);
+int hif_napi_cpu_deinit(struct hif_opaque_softc *hif);
int hif_napi_cpu_migrate(struct qca_napi_data *napid, int cpu, int action);
int hif_napi_cpu_blacklist(bool is_on);
diff --git a/hif/src/hif_napi.c b/hif/src/hif_napi.c
index 8a627b291f36..ffec13f5ce2a 100644
--- a/hif/src/hif_napi.c
+++ b/hif/src/hif_napi.c
@@ -46,7 +46,6 @@
#include <linux/pm.h>
/* Driver headers */
-#include <cds_api.h>
#include <hif_napi.h>
#include <hif_debug.h>
#include <hif_io32.h>
@@ -125,7 +124,7 @@ int hif_napi_create(struct hif_opaque_softc *hif_ctx,
napid->state |= HIF_NAPI_INITED;
- rc = hif_napi_cpu_init(napid);
+ rc = hif_napi_cpu_init(hif_ctx);
if (rc != 0) {
HIF_ERROR("NAPI_initialization failed,. %d", rc);
goto hnc_err;
@@ -261,7 +260,7 @@ int hif_napi_destroy(struct hif_opaque_softc *hif_ctx,
* set the whole structure to uninitialized state
*/
if (napid->ce_map == 0) {
- rc = hif_napi_cpu_deinit(napid);
+ rc = hif_napi_cpu_deinit(hif_ctx);
/* caller is tolerant to receiving !=0 rc */
memset(napid,
@@ -1033,14 +1032,9 @@ static int hnc_cpu_notify_cb(struct notifier_block *nb,
NAPI_DEBUG("-->%s(act=%ld, cpu=%ld)", __func__, action, cpu);
- hif = (struct hif_opaque_softc *)cds_get_context(QDF_MODULE_ID_HIF);
- if (qdf_likely(hif != NULL))
- napid = hif_napi_get_all(hif);
- if (qdf_unlikely(napid == NULL)) {
- NAPI_DEBUG("%s: hif/napid NULL (%p/%p)",
- __func__, hif, napid);
- goto lab_hnc_notify;
- }
+ napid = qdf_container_of(nb, struct qca_napi_data, hnc_cpu_notifier);
+ hif = &qdf_container_of(napid, struct hif_softc, napi_data)->osc;
+
switch (action) {
case CPU_ONLINE:
napid->napi_cpu[cpu].state = QCA_NAPI_CPU_UP;
@@ -1074,14 +1068,19 @@ static int hnc_cpu_notify_cb(struct notifier_block *nb,
NAPI_DEBUG("%s: ignored. action: %ld", __func__, action);
break;
} /* switch */
-lab_hnc_notify:
NAPI_DEBUG("<--%s [%d]", __func__, rc);
return rc;
}
/**
* hnc_hotplug_hook() - installs a hotplug notifier
+ * @hif_sc: hif_sc context
* @register: !0 => register , =0 => deregister
+ *
+ * Because the callback relies on the data layout of
+ * struct hif_softc & its napi_data member, this callback
+ * registration requires that the hif_softc is passed in.
+ *
* Note that this is different from the cpu notifier used by
* rx_thread (cds_schedule.c).
* We may consider combining these modifiers in the future.
@@ -1089,19 +1088,21 @@ lab_hnc_notify:
* Return: 0: success
* <0: error
*/
-static struct notifier_block hnc_cpu_notifier = {
- .notifier_call = hnc_cpu_notify_cb,
-};
-static int hnc_hotplug_hook(int install)
+static int hnc_hotplug_hook(struct hif_softc *hif_sc, int install)
{
int rc = 0;
NAPI_DEBUG("-->%s(%d)", __func__, install);
- if (install)
- rc = register_hotcpu_notifier(&hnc_cpu_notifier);
- else
- unregister_hotcpu_notifier(&hnc_cpu_notifier);
+ if (install) {
+ hif_sc->napi_data.hnc_cpu_notifier.notifier_call
+ = hnc_cpu_notify_cb;
+ rc = register_hotcpu_notifier(
+ &hif_sc->napi_data.hnc_cpu_notifier);
+ } else {
+ unregister_hotcpu_notifier(
+ &hif_sc->napi_data.hnc_cpu_notifier);
+ }
NAPI_DEBUG("<--%s()[%d]", __func__, rc);
return rc;
@@ -1148,11 +1149,11 @@ static int hnc_tput_hook(int install)
* Return: 0: OK
* <0: error code
*/
-int hif_napi_cpu_init(void *ctx)
+int hif_napi_cpu_init(struct hif_opaque_softc *hif)
{
int rc = 0;
int i;
- struct qca_napi_data *napid = (struct qca_napi_data *)ctx;
+ struct qca_napi_data *napid = &HIF_GET_SOFTC(hif)->napi_data;
struct qca_napi_cpu *cpus = napid->napi_cpu;
NAPI_DEBUG("--> ");
@@ -1185,7 +1186,7 @@ int hif_napi_cpu_init(void *ctx)
goto lab_err_topology;
/* install hotplug notifier */
- rc = hnc_hotplug_hook(1);
+ rc = hnc_hotplug_hook(HIF_GET_SOFTC(hif), 1);
if (0 != rc)
goto lab_err_hotplug;
@@ -1196,7 +1197,7 @@ int hif_napi_cpu_init(void *ctx)
lab_err_hotplug:
hnc_tput_hook(0);
- hnc_hotplug_hook(0);
+ hnc_hotplug_hook(HIF_GET_SOFTC(hif), 0);
lab_err_topology:
memset(napid->napi_cpu, 0, sizeof(struct qca_napi_cpu) * NR_CPUS);
lab_rss_init:
@@ -1212,10 +1213,10 @@ lab_rss_init:
* - clears cpu topology table
* Return: 0: OK
*/
-int hif_napi_cpu_deinit(void *ctx)
+int hif_napi_cpu_deinit(struct hif_opaque_softc *hif)
{
int rc = 0;
- struct qca_napi_data *napid = (struct qca_napi_data *)ctx;
+ struct qca_napi_data *napid = &HIF_GET_SOFTC(hif)->napi_data;
NAPI_DEBUG("-->%s(...)", __func__);
@@ -1223,7 +1224,7 @@ int hif_napi_cpu_deinit(void *ctx)
rc = hnc_tput_hook(0);
/* uninstall hotplug notifier */
- rc = hnc_hotplug_hook(0);
+ rc = hnc_hotplug_hook(HIF_GET_SOFTC(hif), 0);
/* clear the topology table */
memset(napid->napi_cpu, 0, sizeof(struct qca_napi_cpu) * NR_CPUS);