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
This commit is contained in:
Houston Hoffman
2016-11-15 10:42:27 -08:00
committed by qcabuildsw
parent 60af6759fb
commit fec8ed1234
3 changed files with 38 additions and 35 deletions

View File

@@ -241,7 +241,6 @@ struct qca_napi_cpu {
* *
* A variable of this type will be stored in hif module context. * A variable of this type will be stored in hif module context.
*/ */
struct qca_napi_data { struct qca_napi_data {
spinlock_t lock; spinlock_t lock;
uint32_t state; uint32_t state;
@@ -253,6 +252,7 @@ struct qca_napi_data {
struct qca_napi_cpu napi_cpu[NR_CPUS]; struct qca_napi_cpu napi_cpu[NR_CPUS];
int lilcl_head, bigcl_head; int lilcl_head, bigcl_head;
enum qca_napi_tput_state napi_mode; enum qca_napi_tput_state napi_mode;
struct notifier_block hnc_cpu_notifier;
}; };
/** /**

View File

@@ -157,19 +157,21 @@ int hif_napi_poll(struct hif_opaque_softc *hif_ctx,
*/ */
/* fw-declare to make compiler happy */ /* fw-declare to make compiler happy */
struct qca_napi_data; struct qca_napi_data;
static inline int hif_napi_cpu_init(void *ctx) { return 0; } static inline int hif_napi_cpu_init(struct hif_opaque_softc *hif)
static inline int hif_napi_cpu_deinit(void *ctx) { return 0; } { 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) 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 */ #else /* HELIUMPLUS - NAPI CPU symbols are valid */
/* /*
* prototype signatures * prototype signatures
*/ */
int hif_napi_cpu_init(void *); int hif_napi_cpu_init(struct hif_opaque_softc *hif);
int hif_napi_cpu_deinit(void *); 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_migrate(struct qca_napi_data *napid, int cpu, int action);
int hif_napi_cpu_blacklist(bool is_on); int hif_napi_cpu_blacklist(bool is_on);

View File

@@ -46,7 +46,6 @@
#include <linux/pm.h> #include <linux/pm.h>
/* Driver headers */ /* Driver headers */
#include <cds_api.h>
#include <hif_napi.h> #include <hif_napi.h>
#include <hif_debug.h> #include <hif_debug.h>
#include <hif_io32.h> #include <hif_io32.h>
@@ -125,7 +124,7 @@ int hif_napi_create(struct hif_opaque_softc *hif_ctx,
napid->state |= HIF_NAPI_INITED; napid->state |= HIF_NAPI_INITED;
rc = hif_napi_cpu_init(napid); rc = hif_napi_cpu_init(hif_ctx);
if (rc != 0) { if (rc != 0) {
HIF_ERROR("NAPI_initialization failed,. %d", rc); HIF_ERROR("NAPI_initialization failed,. %d", rc);
goto hnc_err; goto hnc_err;
@@ -261,7 +260,7 @@ int hif_napi_destroy(struct hif_opaque_softc *hif_ctx,
* set the whole structure to uninitialized state * set the whole structure to uninitialized state
*/ */
if (napid->ce_map == 0) { 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 */ /* caller is tolerant to receiving !=0 rc */
memset(napid, memset(napid,
@@ -966,14 +965,9 @@ static int hnc_cpu_notify_cb(struct notifier_block *nb,
NAPI_DEBUG("-->%s(act=%ld, cpu=%ld)", __func__, action, cpu); NAPI_DEBUG("-->%s(act=%ld, cpu=%ld)", __func__, action, cpu);
hif = (struct hif_opaque_softc *)cds_get_context(QDF_MODULE_ID_HIF); napid = qdf_container_of(nb, struct qca_napi_data, hnc_cpu_notifier);
if (qdf_likely(hif != NULL)) hif = &qdf_container_of(napid, struct hif_softc, napi_data)->osc;
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;
}
switch (action) { switch (action) {
case CPU_ONLINE: case CPU_ONLINE:
napid->napi_cpu[cpu].state = QCA_NAPI_CPU_UP; napid->napi_cpu[cpu].state = QCA_NAPI_CPU_UP;
@@ -1007,14 +1001,19 @@ static int hnc_cpu_notify_cb(struct notifier_block *nb,
NAPI_DEBUG("%s: ignored. action: %ld", __func__, action); NAPI_DEBUG("%s: ignored. action: %ld", __func__, action);
break; break;
} /* switch */ } /* switch */
lab_hnc_notify:
NAPI_DEBUG("<--%s [%d]", __func__, rc); NAPI_DEBUG("<--%s [%d]", __func__, rc);
return rc; return rc;
} }
/** /**
* hnc_hotplug_hook() - installs a hotplug notifier * hnc_hotplug_hook() - installs a hotplug notifier
* @hif_sc: hif_sc context
* @register: !0 => register , =0 => deregister * @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 * Note that this is different from the cpu notifier used by
* rx_thread (cds_schedule.c). * rx_thread (cds_schedule.c).
* We may consider combining these modifiers in the future. * We may consider combining these modifiers in the future.
@@ -1022,19 +1021,21 @@ lab_hnc_notify:
* Return: 0: success * Return: 0: success
* <0: error * <0: error
*/ */
static struct notifier_block hnc_cpu_notifier = { static int hnc_hotplug_hook(struct hif_softc *hif_sc, int install)
.notifier_call = hnc_cpu_notify_cb,
};
static int hnc_hotplug_hook(int install)
{ {
int rc = 0; int rc = 0;
NAPI_DEBUG("-->%s(%d)", __func__, install); NAPI_DEBUG("-->%s(%d)", __func__, install);
if (install) if (install) {
rc = register_hotcpu_notifier(&hnc_cpu_notifier); hif_sc->napi_data.hnc_cpu_notifier.notifier_call
else = hnc_cpu_notify_cb;
unregister_hotcpu_notifier(&hnc_cpu_notifier); 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); NAPI_DEBUG("<--%s()[%d]", __func__, rc);
return rc; return rc;
@@ -1081,11 +1082,11 @@ static int hnc_tput_hook(int install)
* Return: 0: OK * Return: 0: OK
* <0: error code * <0: error code
*/ */
int hif_napi_cpu_init(void *ctx) int hif_napi_cpu_init(struct hif_opaque_softc *hif)
{ {
int rc = 0; int rc = 0;
int i; 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; struct qca_napi_cpu *cpus = napid->napi_cpu;
NAPI_DEBUG("--> "); NAPI_DEBUG("--> ");
@@ -1118,7 +1119,7 @@ int hif_napi_cpu_init(void *ctx)
goto lab_err_topology; goto lab_err_topology;
/* install hotplug notifier */ /* install hotplug notifier */
rc = hnc_hotplug_hook(1); rc = hnc_hotplug_hook(HIF_GET_SOFTC(hif), 1);
if (0 != rc) if (0 != rc)
goto lab_err_hotplug; goto lab_err_hotplug;
@@ -1129,7 +1130,7 @@ int hif_napi_cpu_init(void *ctx)
lab_err_hotplug: lab_err_hotplug:
hnc_tput_hook(0); hnc_tput_hook(0);
hnc_hotplug_hook(0); hnc_hotplug_hook(HIF_GET_SOFTC(hif), 0);
lab_err_topology: lab_err_topology:
memset(napid->napi_cpu, 0, sizeof(struct qca_napi_cpu) * NR_CPUS); memset(napid->napi_cpu, 0, sizeof(struct qca_napi_cpu) * NR_CPUS);
lab_rss_init: lab_rss_init:
@@ -1145,10 +1146,10 @@ lab_rss_init:
* - clears cpu topology table * - clears cpu topology table
* Return: 0: OK * Return: 0: OK
*/ */
int hif_napi_cpu_deinit(void *ctx) int hif_napi_cpu_deinit(struct hif_opaque_softc *hif)
{ {
int rc = 0; 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__); NAPI_DEBUG("-->%s(...)", __func__);
@@ -1156,7 +1157,7 @@ int hif_napi_cpu_deinit(void *ctx)
rc = hnc_tput_hook(0); rc = hnc_tput_hook(0);
/* uninstall hotplug notifier */ /* uninstall hotplug notifier */
rc = hnc_hotplug_hook(0); rc = hnc_hotplug_hook(HIF_GET_SOFTC(hif), 0);
/* clear the topology table */ /* clear the topology table */
memset(napid->napi_cpu, 0, sizeof(struct qca_napi_cpu) * NR_CPUS); memset(napid->napi_cpu, 0, sizeof(struct qca_napi_cpu) * NR_CPUS);