qcacmn: Refactor HIF to use Single HIF Context

Remove unwanted pointers to various HIF data structures.
Use single HIF Context and dynamically typecast to required
HIF data structures.

Change-Id: I1e2f39455a23826d1eaa9785aa9f1bc3854a9cb2
CRs-Fixed: 967765
This commit is contained in:
Komal Seelam
2016-02-22 20:44:25 +05:30
parent 43301de999
commit 02cf2f8509
13 changed files with 155 additions and 204 deletions

View File

@@ -223,12 +223,6 @@ struct ol_softc {
/* status of target init */ /* status of target init */
WLAN_INIT_STATUS wlan_init_status; WLAN_INIT_STATUS wlan_init_status;
/* Handles for Lower Layers : filled in at init time */
hif_handle_t hif_hdl;
#ifdef HIF_PCI
struct hif_pci_softc *hif_sc;
#endif
#ifdef WLAN_FEATURE_FASTPATH #ifdef WLAN_FEATURE_FASTPATH
int fastpath_mode_on; /* Duplicating this for data path efficiency */ int fastpath_mode_on; /* Duplicating this for data path efficiency */
#endif /* WLAN_FEATURE_FASTPATH */ #endif /* WLAN_FEATURE_FASTPATH */

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013-2015 The Linux Foundation. All rights reserved. * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
* *
* Previously licensed under the ISC license by Qualcomm Atheros, Inc. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
* *
@@ -29,6 +29,8 @@
#define __COPY_ENGINE_API_H__ #define __COPY_ENGINE_API_H__
#include "ce_main.h" #include "ce_main.h"
#include "hif_main.h"
/* TBDXXX: Use int return values for consistency with Target */ /* TBDXXX: Use int return values for consistency with Target */
/* TBDXXX: Perhaps merge Host/Target-->common */ /* TBDXXX: Perhaps merge Host/Target-->common */
@@ -463,8 +465,9 @@ static inline void ce_pkt_error_count_incr(
struct HIF_CE_state *_hif_state, struct HIF_CE_state *_hif_state,
enum ol_ath_hif_pkt_ecodes _hif_ecode) enum ol_ath_hif_pkt_ecodes _hif_ecode)
{ {
struct ol_softc *scn = HIF_GET_SOFTC(_hif_state);
if (_hif_ecode == HIF_PIPE_NO_RESOURCE) if (_hif_ecode == HIF_PIPE_NO_RESOURCE)
(_hif_state->scn->pkt_stats.hif_pipe_no_resrc_count) (scn->pkt_stats.hif_pipe_no_resrc_count)
+= 1; += 1;
} }

View File

@@ -88,7 +88,7 @@ void hif_bmi_send_done(struct CE_handle *copyeng, void *ce_context,
{ {
struct BMI_transaction *transaction = struct BMI_transaction *transaction =
(struct BMI_transaction *)transfer_context; (struct BMI_transaction *)transfer_context;
struct ol_softc *scn = transaction->hif_state->scn; struct ol_softc *scn = HIF_GET_SOFTC(transaction->hif_state);
#ifdef BMI_RSP_POLLING #ifdef BMI_RSP_POLLING
/* /*
@@ -124,7 +124,7 @@ void hif_bmi_recv_data(struct CE_handle *copyeng, void *ce_context,
{ {
struct BMI_transaction *transaction = struct BMI_transaction *transaction =
(struct BMI_transaction *)transfer_context; (struct BMI_transaction *)transfer_context;
struct ol_softc *scn = transaction->hif_state->scn; struct ol_softc *scn = HIF_GET_SOFTC(transaction->hif_state);
transaction->bmi_response_length = nbytes; transaction->bmi_response_length = nbytes;
transaction->bmi_transaction_flags |= BMI_RESP_RECV_DONE; transaction->bmi_transaction_flags |= BMI_RESP_RECV_DONE;
@@ -137,13 +137,14 @@ void hif_bmi_recv_data(struct CE_handle *copyeng, void *ce_context,
} }
#endif #endif
CDF_STATUS hif_exchange_bmi_msg(struct ol_softc *scn, CDF_STATUS hif_exchange_bmi_msg(struct ol_softc *hif_ctx,
uint8_t *bmi_request, uint8_t *bmi_request,
uint32_t request_length, uint32_t request_length,
uint8_t *bmi_response, uint8_t *bmi_response,
uint32_t *bmi_response_lengthp, uint32_t TimeoutMS) uint32_t *bmi_response_lengthp, uint32_t TimeoutMS)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
struct HIF_CE_pipe_info *send_pipe_info = struct HIF_CE_pipe_info *send_pipe_info =
&(hif_state->pipe_info[BMI_CE_NUM_TO_TARG]); &(hif_state->pipe_info[BMI_CE_NUM_TO_TARG]);
struct CE_handle *ce_send_hdl = send_pipe_info->ce_hdl; struct CE_handle *ce_send_hdl = send_pipe_info->ce_hdl;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015 The Linux Foundation. All rights reserved. * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
* *
* Previously licensed under the ISC license by Qualcomm Atheros, Inc. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
* *
@@ -51,9 +51,10 @@
#include "epping_main.h" #include "epping_main.h"
#include "cds_concurrency.h" #include "cds_concurrency.h"
void hif_dump_target_memory(struct ol_softc *scn, void *ramdump_base, void hif_dump_target_memory(struct ol_softc *hif_ctx, void *ramdump_base,
uint32_t address, uint32_t size) uint32_t address, uint32_t size)
{ {
struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
uint32_t loc = address; uint32_t loc = address;
uint32_t val = 0; uint32_t val = 0;
uint32_t j = 0; uint32_t j = 0;
@@ -95,10 +96,11 @@ void hif_dump_target_memory(struct ol_softc *scn, void *ramdump_base,
*/ */
CDF_STATUS CDF_STATUS
hif_diag_read_mem(struct ol_softc *scn, uint32_t address, uint8_t *data, hif_diag_read_mem(struct ol_softc *hif_ctx, uint32_t address, uint8_t *data,
int nbytes) int nbytes)
{ {
struct HIF_CE_state *hif_state; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
CDF_STATUS status = CDF_STATUS_SUCCESS; CDF_STATUS status = CDF_STATUS_SUCCESS;
cdf_dma_addr_t buf; cdf_dma_addr_t buf;
unsigned int completed_nbytes, orig_nbytes, remaining_bytes; unsigned int completed_nbytes, orig_nbytes, remaining_bytes;
@@ -115,8 +117,6 @@ hif_diag_read_mem(struct ol_softc *scn, uint32_t address, uint8_t *data,
unsigned int toeplitz_hash_result; unsigned int toeplitz_hash_result;
unsigned int user_flags = 0; unsigned int user_flags = 0;
hif_state = (struct HIF_CE_state *)scn->hif_hdl;
transaction_id = (mux_id & MUX_ID_MASK) | transaction_id = (mux_id & MUX_ID_MASK) |
(transaction_id & TRANSACTION_ID_MASK); (transaction_id & TRANSACTION_ID_MASK);
#ifdef QCA_WIFI_3_0 #ifdef QCA_WIFI_3_0
@@ -260,12 +260,11 @@ done:
} }
/* Read 4-byte aligned data from Target memory or register */ /* Read 4-byte aligned data from Target memory or register */
CDF_STATUS hif_diag_read_access(struct ol_softc *scn, CDF_STATUS hif_diag_read_access(struct ol_softc *hif_ctx,
uint32_t address, uint32_t *data) uint32_t address, uint32_t *data)
{ {
struct HIF_CE_state *hif_state; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
hif_state = (struct HIF_CE_state *)scn->hif_hdl;
if (address >= DRAM_BASE_ADDRESS) { if (address >= DRAM_BASE_ADDRESS) {
/* Assume range doesn't cross this boundary */ /* Assume range doesn't cross this boundary */
return hif_diag_read_mem(scn, address, (uint8_t *) data, return hif_diag_read_mem(scn, address, (uint8_t *) data,
@@ -279,10 +278,11 @@ CDF_STATUS hif_diag_read_access(struct ol_softc *scn,
} }
} }
CDF_STATUS hif_diag_write_mem(struct ol_softc *scn, CDF_STATUS hif_diag_write_mem(struct ol_softc *hif_ctx,
uint32_t address, uint8_t *data, int nbytes) uint32_t address, uint8_t *data, int nbytes)
{ {
struct HIF_CE_state *hif_state; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
CDF_STATUS status = CDF_STATUS_SUCCESS; CDF_STATUS status = CDF_STATUS_SUCCESS;
cdf_dma_addr_t buf; cdf_dma_addr_t buf;
unsigned int completed_nbytes, orig_nbytes, remaining_bytes; unsigned int completed_nbytes, orig_nbytes, remaining_bytes;
@@ -299,7 +299,6 @@ CDF_STATUS hif_diag_write_mem(struct ol_softc *scn,
unsigned int toeplitz_hash_result; unsigned int toeplitz_hash_result;
unsigned int user_flags = 0; unsigned int user_flags = 0;
hif_state = (struct HIF_CE_state *)scn->hif_hdl;
ce_diag = hif_state->ce_diag; ce_diag = hif_state->ce_diag;
transaction_id = (mux_id & MUX_ID_MASK) | transaction_id = (mux_id & MUX_ID_MASK) |
(transaction_id & TRANSACTION_ID_MASK); (transaction_id & TRANSACTION_ID_MASK);
@@ -433,12 +432,11 @@ done:
} }
/* Write 4B data to Target memory or register */ /* Write 4B data to Target memory or register */
CDF_STATUS CDF_STATUS hif_diag_write_access(struct ol_softc *hif_ctx, uint32_t address,
hif_diag_write_access(struct ol_softc *scn, uint32_t address, uint32_t data) uint32_t data)
{ {
struct HIF_CE_state *hif_state; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
hif_state = (struct HIF_CE_state *)scn->hif_hdl;
if (address >= DRAM_BASE_ADDRESS) { if (address >= DRAM_BASE_ADDRESS) {
/* Assume range doesn't cross this boundary */ /* Assume range doesn't cross this boundary */
uint32_t data_buf = data; uint32_t data_buf = data;

View File

@@ -539,9 +539,9 @@ void ce_fini(struct CE_handle *copyeng)
cdf_mem_free(CE_state); cdf_mem_free(CE_state);
} }
void hif_detach_htc(struct ol_softc *scn) void hif_detach_htc(struct ol_softc *hif_ctx)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
cdf_mem_zero(&hif_state->msg_callbacks_pending, cdf_mem_zero(&hif_state->msg_callbacks_pending,
sizeof(hif_state->msg_callbacks_pending)); sizeof(hif_state->msg_callbacks_pending));
@@ -551,11 +551,12 @@ void hif_detach_htc(struct ol_softc *scn)
/* Send the first nbytes bytes of the buffer */ /* Send the first nbytes bytes of the buffer */
CDF_STATUS CDF_STATUS
hif_send_head(struct ol_softc *scn, hif_send_head(struct ol_softc *hif_ctx,
uint8_t pipe, unsigned int transfer_id, unsigned int nbytes, uint8_t pipe, unsigned int transfer_id, unsigned int nbytes,
cdf_nbuf_t nbuf, unsigned int data_attr) cdf_nbuf_t nbuf, unsigned int data_attr)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]); struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]);
struct CE_handle *ce_hdl = pipe_info->ce_hdl; struct CE_handle *ce_hdl = pipe_info->ce_hdl;
int bytes = nbytes, nfrags = 0; int bytes = nbytes, nfrags = 0;
@@ -659,9 +660,9 @@ void hif_send_complete_check(struct ol_softc *scn, uint8_t pipe, int force)
#endif #endif
} }
uint16_t hif_get_free_queue_number(struct ol_softc *scn, uint8_t pipe) uint16_t hif_get_free_queue_number(struct ol_softc *hif_ctx, uint8_t pipe)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]); struct HIF_CE_pipe_info *pipe_info = &(hif_state->pipe_info[pipe]);
uint16_t rv; uint16_t rv;
@@ -682,6 +683,7 @@ hif_pci_ce_send_done(struct CE_handle *copyeng, void *ce_context,
struct HIF_CE_pipe_info *pipe_info = struct HIF_CE_pipe_info *pipe_info =
(struct HIF_CE_pipe_info *)ce_context; (struct HIF_CE_pipe_info *)ce_context;
struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state; struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state;
struct ol_softc *scn = HIF_GET_SOFTC(hif_state);
unsigned int sw_idx = sw_index, hw_idx = hw_index; unsigned int sw_idx = sw_index, hw_idx = hw_index;
struct hif_msg_callbacks *msg_callbacks = struct hif_msg_callbacks *msg_callbacks =
&hif_state->msg_callbacks_current; &hif_state->msg_callbacks_current;
@@ -692,7 +694,7 @@ hif_pci_ce_send_done(struct CE_handle *copyeng, void *ce_context,
* when last fragment is complteted. * when last fragment is complteted.
*/ */
if (transfer_context != CE_SENDLIST_ITEM_CTXT) { if (transfer_context != CE_SENDLIST_ITEM_CTXT) {
if (hif_state->scn->target_status if (scn->target_status
== OL_TRGET_STATUS_RESET) == OL_TRGET_STATUS_RESET)
cdf_nbuf_free(transfer_context); cdf_nbuf_free(transfer_context);
else else
@@ -750,19 +752,20 @@ hif_pci_ce_recv_data(struct CE_handle *copyeng, void *ce_context,
(struct HIF_CE_pipe_info *)ce_context; (struct HIF_CE_pipe_info *)ce_context;
struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state; struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state;
struct CE_state *ce_state = (struct CE_state *) copyeng; struct CE_state *ce_state = (struct CE_state *) copyeng;
struct ol_softc *scn = hif_state->scn; struct ol_softc *scn = HIF_GET_SOFTC(hif_state);
struct hif_pci_softc *hif_sc = HIF_GET_PCI_SOFTC(hif_state);
struct hif_msg_callbacks *msg_callbacks = struct hif_msg_callbacks *msg_callbacks =
&hif_state->msg_callbacks_current; &hif_state->msg_callbacks_current;
do { do {
hif_pm_runtime_mark_last_busy(scn->hif_sc->dev); hif_pm_runtime_mark_last_busy(hif_sc->dev);
cdf_nbuf_unmap_single(scn->cdf_dev, cdf_nbuf_unmap_single(scn->cdf_dev,
(cdf_nbuf_t) transfer_context, (cdf_nbuf_t) transfer_context,
CDF_DMA_FROM_DEVICE); CDF_DMA_FROM_DEVICE);
atomic_inc(&pipe_info->recv_bufs_needed); atomic_inc(&pipe_info->recv_bufs_needed);
hif_post_recv_buffers_for_pipe(pipe_info); hif_post_recv_buffers_for_pipe(pipe_info);
if (hif_state->scn->target_status == OL_TRGET_STATUS_RESET) if (scn->target_status == OL_TRGET_STATUS_RESET)
cdf_nbuf_free(transfer_context); cdf_nbuf_free(transfer_context);
else else
hif_ce_do_recv(msg_callbacks, transfer_context, hif_ce_do_recv(msg_callbacks, transfer_context,
@@ -785,10 +788,10 @@ hif_pci_ce_recv_data(struct CE_handle *copyeng, void *ce_context,
/* TBDXXX: Set CE High Watermark; invoke txResourceAvailHandler in response */ /* TBDXXX: Set CE High Watermark; invoke txResourceAvailHandler in response */
void void
hif_post_init(struct ol_softc *scn, void *unused, hif_post_init(struct ol_softc *hif_ctx, void *unused,
struct hif_msg_callbacks *callbacks) struct hif_msg_callbacks *callbacks)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
#ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG #ifdef CONFIG_ATH_PCIE_ACCESS_DEBUG
spin_lock_init(&pcie_access_log_lock); spin_lock_init(&pcie_access_log_lock);
@@ -803,7 +806,7 @@ int hif_completion_thread_startup(struct HIF_CE_state *hif_state)
{ {
struct CE_handle *ce_diag = hif_state->ce_diag; struct CE_handle *ce_diag = hif_state->ce_diag;
int pipe_num; int pipe_num;
struct ol_softc *scn = hif_state->scn; struct ol_softc *scn = HIF_GET_SOFTC(hif_state);
struct hif_msg_callbacks *hif_msg_callbacks = struct hif_msg_callbacks *hif_msg_callbacks =
&hif_state->msg_callbacks_current; &hif_state->msg_callbacks_current;
@@ -865,7 +868,7 @@ int hif_completion_thread_startup(struct HIF_CE_state *hif_state)
*/ */
static void hif_msg_callbacks_install(struct ol_softc *scn) static void hif_msg_callbacks_install(struct ol_softc *scn)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
cdf_mem_copy(&hif_state->msg_callbacks_current, cdf_mem_copy(&hif_state->msg_callbacks_current,
&hif_state->msg_callbacks_pending, &hif_state->msg_callbacks_pending,
@@ -891,14 +894,9 @@ hif_get_default_pipe(struct ol_softc *scn, uint8_t *ULPipe, uint8_t *DLPipe)
*/ */
void hif_dump_pipe_debug_count(struct ol_softc *scn) void hif_dump_pipe_debug_count(struct ol_softc *scn)
{ {
struct HIF_CE_state *hif_state; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
int pipe_num; int pipe_num;
if (scn == NULL) {
HIF_ERROR("%s scn is NULL", __func__);
return;
}
hif_state = (struct HIF_CE_state *)scn->hif_hdl;
if (hif_state == NULL) { if (hif_state == NULL) {
HIF_ERROR("%s hif_state is NULL", __func__); HIF_ERROR("%s hif_state is NULL", __func__);
return; return;
@@ -925,8 +923,7 @@ static int hif_post_recv_buffers_for_pipe(struct HIF_CE_pipe_info *pipe_info)
{ {
struct CE_handle *ce_hdl; struct CE_handle *ce_hdl;
cdf_size_t buf_sz; cdf_size_t buf_sz;
struct HIF_CE_state *hif_state = pipe_info->HIF_CE_state; struct ol_softc *scn = HIF_GET_SOFTC(pipe_info->HIF_CE_state);
struct ol_softc *scn = hif_state->scn;
CDF_STATUS ret; CDF_STATUS ret;
uint32_t bufs_posted = 0; uint32_t bufs_posted = 0;
@@ -1031,7 +1028,7 @@ static int hif_post_recv_buffers_for_pipe(struct HIF_CE_pipe_info *pipe_info)
*/ */
static int hif_post_recv_buffers(struct ol_softc *scn) static int hif_post_recv_buffers(struct ol_softc *scn)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
int pipe_num, rv = 0; int pipe_num, rv = 0;
A_TARGET_ACCESS_LIKELY(scn); A_TARGET_ACCESS_LIKELY(scn);
@@ -1051,9 +1048,10 @@ done:
return rv; return rv;
} }
CDF_STATUS hif_start(struct ol_softc *scn) CDF_STATUS hif_start(struct ol_softc *hif_ctx)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
hif_msg_callbacks_install(scn); hif_msg_callbacks_install(scn);
@@ -1132,7 +1130,7 @@ void hif_recv_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info)
return; return;
} }
scn = hif_state->scn; scn = HIF_GET_SOFTC(hif_state);
ce_hdl = pipe_info->ce_hdl; ce_hdl = pipe_info->ce_hdl;
if (scn->cdf_dev == NULL) { if (scn->cdf_dev == NULL) {
@@ -1151,6 +1149,7 @@ void hif_send_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info)
{ {
struct CE_handle *ce_hdl; struct CE_handle *ce_hdl;
struct HIF_CE_state *hif_state; struct HIF_CE_state *hif_state;
struct ol_softc *scn;
cdf_nbuf_t netbuf; cdf_nbuf_t netbuf;
void *per_CE_context; void *per_CE_context;
cdf_dma_addr_t CE_data; cdf_dma_addr_t CE_data;
@@ -1170,6 +1169,8 @@ void hif_send_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info)
return; return;
} }
scn = HIF_GET_SOFTC(hif_state);
ce_hdl = pipe_info->ce_hdl; ce_hdl = pipe_info->ce_hdl;
while (ce_cancel_send_next while (ce_cancel_send_next
@@ -1185,7 +1186,7 @@ void hif_send_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info)
* by checking whether it's the endpoint * by checking whether it's the endpoint
* which they are queued in. * which they are queued in.
*/ */
if (id == hif_state->scn->htc_endpoint) if (id == scn->htc_endpoint)
return; return;
/* Indicate the completion to higer /* Indicate the completion to higer
* layer to free the buffer */ * layer to free the buffer */
@@ -1208,8 +1209,9 @@ void hif_send_buffer_cleanup_on_pipe(struct HIF_CE_pipe_info *pipe_info)
void hif_buffer_cleanup(struct HIF_CE_state *hif_state) void hif_buffer_cleanup(struct HIF_CE_state *hif_state)
{ {
int pipe_num; int pipe_num;
struct ol_softc *scn = HIF_GET_SOFTC(hif_state);
for (pipe_num = 0; pipe_num < hif_state->scn->ce_count; pipe_num++) { for (pipe_num = 0; pipe_num < scn->ce_count; pipe_num++) {
struct HIF_CE_pipe_info *pipe_info; struct HIF_CE_pipe_info *pipe_info;
pipe_info = &hif_state->pipe_info[pipe_num]; pipe_info = &hif_state->pipe_info[pipe_num];
@@ -1218,15 +1220,17 @@ void hif_buffer_cleanup(struct HIF_CE_state *hif_state)
} }
} }
void hif_flush_surprise_remove(struct ol_softc *scn) void hif_flush_surprise_remove(struct ol_softc *hif_ctx)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct ol_softc *scn = hif_ctx;
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
hif_buffer_cleanup(hif_state); hif_buffer_cleanup(hif_state);
} }
void hif_stop(struct ol_softc *scn) void hif_stop(struct ol_softc *hif_ctx)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
int pipe_num; int pipe_num;
scn->hif_init_done = false; scn->hif_init_done = false;
@@ -1503,7 +1507,7 @@ void hif_wake_target_cpu(struct ol_softc *scn)
static void hif_sleep_entry(void *arg) static void hif_sleep_entry(void *arg)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)arg; struct HIF_CE_state *hif_state = (struct HIF_CE_state *)arg;
struct ol_softc *scn = hif_state->scn; struct ol_softc *scn = HIF_GET_SOFTC(hif_state);
uint32_t idle_ms; uint32_t idle_ms;
if (scn->recovery) if (scn->recovery)
return; return;
@@ -1880,8 +1884,6 @@ int hif_config_ce(hif_handle_t hif_hdl)
return CDF_STATUS_NOT_INITIALIZED; return CDF_STATUS_NOT_INITIALIZED;
} }
hif_state->scn = scn;
scn->hif_hdl = hif_state;
scn->mem = soc_info.v_addr; scn->mem = soc_info.v_addr;
scn->mem_pa = soc_info.p_addr; scn->mem_pa = soc_info.p_addr;
tgt_info->soc_version = soc_info.version; tgt_info->soc_version = soc_info.version;
@@ -2011,7 +2013,6 @@ err:
hif_state->sleep_timer_init = false; hif_state->sleep_timer_init = false;
} }
scn->hif_hdl = NULL;
athdiag_procfs_remove(); athdiag_procfs_remove();
scn->athdiag_procfs_inited = false; scn->athdiag_procfs_inited = false;
HIF_TRACE("%s: X, ret = %d\n", __func__, rv); HIF_TRACE("%s: X, ret = %d\n", __func__, rv);
@@ -2037,12 +2038,13 @@ err:
* *
* Return: None * Return: None
*/ */
void hif_ipa_get_ce_resource(struct ol_softc *scn, void hif_ipa_get_ce_resource(struct ol_softc *hif_ctx,
cdf_dma_addr_t *ce_sr_base_paddr, cdf_dma_addr_t *ce_sr_base_paddr,
uint32_t *ce_sr_ring_size, uint32_t *ce_sr_ring_size,
cdf_dma_addr_t *ce_reg_paddr) cdf_dma_addr_t *ce_reg_paddr)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
struct HIF_CE_pipe_info *pipe_info = struct HIF_CE_pipe_info *pipe_info =
&(hif_state->pipe_info[HIF_PCI_IPA_UC_ASSIGNED_CE]); &(hif_state->pipe_info[HIF_PCI_IPA_UC_ASSIGNED_CE]);
struct CE_handle *ce_hdl = pipe_info->ce_hdl; struct CE_handle *ce_hdl = pipe_info->ce_hdl;

View File

@@ -109,7 +109,6 @@ struct ce_tasklet_entry {
struct HIF_CE_state { struct HIF_CE_state {
struct ol_softc ol_sc; struct ol_softc ol_sc;
struct ol_softc *scn;
bool started; bool started;
struct ce_tasklet_entry tasklets[CE_COUNT_MAX]; struct ce_tasklet_entry tasklets[CE_COUNT_MAX];
cdf_spinlock_t keep_awake_lock; cdf_spinlock_t keep_awake_lock;

View File

@@ -101,7 +101,8 @@ static void reschedule_ce_tasklet_work_handler(struct work_struct *work)
HIF_ERROR("%s: tasklet scn is null", __func__); HIF_ERROR("%s: tasklet scn is null", __func__);
return; return;
} }
hif_ce_state = (struct HIF_CE_state *)scn->hif_hdl;
hif_ce_state = HIF_GET_CE_STATE(scn);
if (scn->hif_init_done == false) { if (scn->hif_init_done == false) {
HIF_ERROR("%s: wlan driver is unloaded", __func__); HIF_ERROR("%s: wlan driver is unloaded", __func__);
@@ -193,7 +194,7 @@ static void ce_tasklet(unsigned long data)
struct ce_tasklet_entry *tasklet_entry = struct ce_tasklet_entry *tasklet_entry =
(struct ce_tasklet_entry *)data; (struct ce_tasklet_entry *)data;
struct HIF_CE_state *hif_ce_state = tasklet_entry->hif_ce_state; struct HIF_CE_state *hif_ce_state = tasklet_entry->hif_ce_state;
struct ol_softc *scn = hif_ce_state->scn; struct ol_softc *scn = HIF_GET_SOFTC(hif_ce_state);
struct CE_state *CE_state = scn->ce_id_to_state[tasklet_entry->ce_id]; struct CE_state *CE_state = scn->ce_id_to_state[tasklet_entry->ce_id];
hif_record_ce_desc_event(tasklet_entry->ce_id, HIF_CE_TASKLET_ENTRY, hif_record_ce_desc_event(tasklet_entry->ce_id, HIF_CE_TASKLET_ENTRY,
@@ -262,7 +263,7 @@ void ce_tasklet_init(struct HIF_CE_state *hif_ce_state, uint32_t mask)
void ce_tasklet_kill(struct HIF_CE_state *hif_ce_state) void ce_tasklet_kill(struct HIF_CE_state *hif_ce_state)
{ {
int i; int i;
struct ol_softc *scn = hif_ce_state->scn; struct ol_softc *scn = HIF_GET_SOFTC(hif_ce_state);
for (i = 0; i < CE_COUNT_MAX; i++) for (i = 0; i < CE_COUNT_MAX; i++)
if (hif_ce_state->tasklets[i].inited) { if (hif_ce_state->tasklets[i].inited) {
@@ -282,7 +283,7 @@ static irqreturn_t ce_irq_handler(int irq, void *context)
{ {
struct ce_tasklet_entry *tasklet_entry = context; struct ce_tasklet_entry *tasklet_entry = context;
struct HIF_CE_state *hif_ce_state = tasklet_entry->hif_ce_state; struct HIF_CE_state *hif_ce_state = tasklet_entry->hif_ce_state;
struct ol_softc *scn = hif_ce_state->scn; struct ol_softc *scn = HIF_GET_SOFTC(hif_ce_state);
uint32_t host_status; uint32_t host_status;
int ce_id = icnss_get_ce_id(irq); int ce_id = icnss_get_ce_id(irq);
@@ -397,7 +398,7 @@ CDF_STATUS ce_register_irq(struct HIF_CE_state *hif_ce_state, uint32_t mask)
#ifndef HIF_PCI #ifndef HIF_PCI
/* move to hif_configure_irq */ /* move to hif_configure_irq */
ce_enable_irq_in_group_reg(hif_ce_state->scn, done_mask); ce_enable_irq_in_group_reg(HIF_GET_SOFTC(hif_ce_state), done_mask);
#endif #endif
return CDF_STATUS_SUCCESS; return CDF_STATUS_SUCCESS;

View File

@@ -112,15 +112,7 @@ void hif_dump(struct ol_softc *scn, uint8_t cmd_id, bool start)
*/ */
void hif_shut_down_device(struct ol_softc *scn) void hif_shut_down_device(struct ol_softc *scn)
{ {
if (scn && scn->hif_hdl) { hif_stop(scn);
struct HIF_CE_state *hif_state =
(struct HIF_CE_state *)scn->hif_hdl;
hif_stop(scn);
cdf_mem_free(hif_state);
scn->hif_hdl = NULL;
}
} }
@@ -217,7 +209,7 @@ static inline void hif_fw_event_handler(struct HIF_CE_state *hif_state)
irqreturn_t hif_fw_interrupt_handler(int irq, void *arg) irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
{ {
struct ol_softc *scn = arg; struct ol_softc *scn = arg;
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
uint32_t fw_indicator_address, fw_indicator; uint32_t fw_indicator_address, fw_indicator;
A_TARGET_ACCESS_BEGIN_RET(scn); A_TARGET_ACCESS_BEGIN_RET(scn);
@@ -262,8 +254,9 @@ irqreturn_t hif_fw_interrupt_handler(int irq, void *arg)
* *
* Return: void * * Return: void *
*/ */
void *hif_get_targetdef(struct ol_softc *scn) void *hif_get_targetdef(struct ol_softc *hif_ctx)
{ {
struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
return scn->targetdef; return scn->targetdef;
} }
@@ -548,10 +541,6 @@ void hif_close(void *hif_ctx)
scn->athdiag_procfs_inited = false; scn->athdiag_procfs_inited = false;
} }
if (scn->hif_hdl) {
cdf_mem_free(scn->hif_hdl);
scn->hif_hdl = NULL;
}
hif_bus_close(scn); hif_bus_close(scn);
cds_free_context(cds_get_global_context(), cds_free_context(cds_get_global_context(),
CDF_MODULE_ID_HIF, hif_ctx); CDF_MODULE_ID_HIF, hif_ctx);
@@ -606,7 +595,7 @@ CDF_STATUS hif_enable(void *hif_ctx, struct device *dev,
*/ */
#ifdef HIF_PCI #ifdef HIF_PCI
status = hif_configure_irq(scn->hif_sc); status = hif_configure_irq(hif_ctx);
if (status < 0) { if (status < 0) {
HIF_ERROR("%s: ERROR - configure_IRQ_and_CE failed, status = %d", HIF_ERROR("%s: ERROR - configure_IRQ_and_CE failed, status = %d",
__func__, status); __func__, status);
@@ -702,13 +691,9 @@ static void hif_crash_shutdown_dump_bus_register(void *hif_ctx)
*/ */
void hif_crash_shutdown(void *hif_ctx) void hif_crash_shutdown(void *hif_ctx)
{ {
struct ol_softc *scn = hif_ctx; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct HIF_CE_state *hif_state; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(hif_ctx);
if (!scn)
return;
hif_state = (struct HIF_CE_state *)scn->hif_hdl;
if (!hif_state) if (!hif_state)
return; return;

View File

@@ -57,9 +57,6 @@
*/ */
#define TARGID_TO_PCI_ADDR(targid) (*((A_target_id_t *)(targid))) #define TARGID_TO_PCI_ADDR(targid) (*((A_target_id_t *)(targid)))
A_target_id_t hif_get_target_id(struct ol_softc *scn);
bool hif_target_forced_awake(struct ol_softc *scn);
#ifdef QCA_WIFI_3_0 #ifdef QCA_WIFI_3_0
#define DISABLE_L1SS_STATES 1 #define DISABLE_L1SS_STATES 1
#endif #endif
@@ -101,9 +98,14 @@ bool hif_target_forced_awake(struct ol_softc *scn);
#define QCA6180_DEVICE_ID (0x041) #define QCA6180_DEVICE_ID (0x041)
#endif #endif
#define HIF_GET_PCI_SOFTC(scn) ((struct hif_pci_softc *)scn)
#define HIF_GET_CE_STATE(scn) ((struct HIF_CE_state *)scn)
#define HIF_GET_SOFTC(scn) ((struct ol_softc *)scn)
A_target_id_t hif_get_target_id(struct ol_softc *scn); A_target_id_t hif_get_target_id(struct ol_softc *scn);
void hif_dump_pipe_debug_count(struct ol_softc *scn); void hif_dump_pipe_debug_count(struct ol_softc *scn);
bool hif_target_forced_awake(struct ol_softc *scn);
bool hif_max_num_receives_reached(unsigned int count); bool hif_max_num_receives_reached(unsigned int count);
int hif_config_ce(hif_handle_t hif_hdl); int hif_config_ce(hif_handle_t hif_hdl);
int athdiag_procfs_init(void *scn); int athdiag_procfs_init(void *scn);

View File

@@ -30,7 +30,7 @@
#ifdef HIF_PCI #ifdef HIF_PCI
#include "hif.h" #include "hif_main.h"
#include "regtable.h" #include "regtable.h"
#include "ce_reg.h" #include "ce_reg.h"
#include "cdf_atomic.h" #include "cdf_atomic.h"
@@ -256,7 +256,7 @@ irqreturn_t hif_fw_interrupt_handler(int irq, void *arg);
static inline void ce_irq_enable(struct ol_softc *scn, int ce_id) static inline void ce_irq_enable(struct ol_softc *scn, int ce_id)
{ {
uint32_t tmp = 1 << ce_id; uint32_t tmp = 1 << ce_id;
struct hif_pci_softc *sc = scn->hif_sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
cdf_spin_lock_irqsave(&sc->irq_lock); cdf_spin_lock_irqsave(&sc->irq_lock);
scn->ce_irq_summary &= ~tmp; scn->ce_irq_summary &= ~tmp;

View File

@@ -123,7 +123,7 @@ static inline void hif_pci_route_adrastea_interrupt(struct hif_pci_softc *sc)
#else #else
void hif_pci_route_adrastea_interrupt(struct hif_pci_softc *sc) void hif_pci_route_adrastea_interrupt(struct hif_pci_softc *sc)
{ {
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
unsigned int target_enable0, target_enable1; unsigned int target_enable0, target_enable1;
unsigned int target_cause0, target_cause1; unsigned int target_cause0, target_cause1;
@@ -146,8 +146,8 @@ void hif_pci_route_adrastea_interrupt(struct hif_pci_softc *sc)
static irqreturn_t hif_pci_interrupt_handler(int irq, void *arg) static irqreturn_t hif_pci_interrupt_handler(int irq, void *arg)
{ {
struct hif_pci_softc *sc = (struct hif_pci_softc *)arg; struct hif_pci_softc *sc = (struct hif_pci_softc *)arg;
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(arg);
volatile int tmp; volatile int tmp;
uint16_t val; uint16_t val;
uint32_t bar0; uint32_t bar0;
@@ -278,7 +278,7 @@ static irqreturn_t hif_pci_msi_fw_handler(int irq, void *arg)
{ {
struct hif_pci_softc *sc = (struct hif_pci_softc *)arg; struct hif_pci_softc *sc = (struct hif_pci_softc *)arg;
(irqreturn_t) hif_fw_interrupt_handler(sc->irq_event, sc->ol_sc); (irqreturn_t) hif_fw_interrupt_handler(sc->irq_event, arg);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
@@ -302,7 +302,7 @@ bool hif_pci_targ_is_present(struct ol_softc *scn, void *__iomem *mem)
#if CONFIG_ATH_PCIE_MAX_PERF == 0 #if CONFIG_ATH_PCIE_MAX_PERF == 0
void hif_pci_cancel_deferred_target_sleep(struct ol_softc *scn) void hif_pci_cancel_deferred_target_sleep(struct ol_softc *scn)
{ {
struct HIF_CE_state *hif_state = (struct HIF_CE_state *)scn->hif_hdl; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
A_target_id_t pci_addr = scn->mem; A_target_id_t pci_addr = scn->mem;
cdf_spin_lock_irqsave(&hif_state->keep_awake_lock); cdf_spin_lock_irqsave(&hif_state->keep_awake_lock);
@@ -342,7 +342,7 @@ static void hif_pci_device_reset(struct hif_pci_softc *sc)
void __iomem *mem = sc->mem; void __iomem *mem = sc->mem;
int i; int i;
uint32_t val; uint32_t val;
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
if (!scn->hostdef) if (!scn->hostdef)
return; return;
@@ -415,7 +415,7 @@ void hif_pci_device_warm_reset(struct hif_pci_softc *sc)
int i; int i;
uint32_t val; uint32_t val;
uint32_t fw_indicator; uint32_t fw_indicator;
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
/* NB: Don't check resetok here. This form of reset is /* NB: Don't check resetok here. This form of reset is
* integral to correct operation. */ * integral to correct operation. */
@@ -531,9 +531,10 @@ void hif_pci_device_warm_reset(struct hif_pci_softc *sc)
} }
#ifndef QCA_WIFI_3_0 #ifndef QCA_WIFI_3_0
int hif_check_fw_reg(struct ol_softc *scn) int hif_check_fw_reg(struct ol_softc *hif_ctx)
{ {
struct hif_pci_softc *sc = scn->hif_sc; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
void __iomem *mem = sc->mem; void __iomem *mem = sc->mem;
uint32_t val; uint32_t val;
@@ -550,12 +551,13 @@ int hif_check_fw_reg(struct ol_softc *scn)
} }
#endif #endif
int hif_check_soc_status(struct ol_softc *scn) int hif_check_soc_status(struct ol_softc *hif_ctx)
{ {
struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
uint16_t device_id; uint16_t device_id;
uint32_t val; uint32_t val;
uint16_t timeout_count = 0; uint16_t timeout_count = 0;
struct hif_pci_softc *sc = scn->hif_sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
/* Check device ID from PCIe configuration space for link status */ /* Check device ID from PCIe configuration space for link status */
pci_read_config_word(sc->pdev, PCI_DEVICE_ID, &device_id); pci_read_config_word(sc->pdev, PCI_DEVICE_ID, &device_id);
@@ -617,7 +619,7 @@ int hif_check_soc_status(struct ol_softc *scn)
*/ */
static void hif_dump_pci_registers(struct ol_softc *scn) static void hif_dump_pci_registers(struct ol_softc *scn)
{ {
struct hif_pci_softc *sc = scn->hif_sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
void __iomem *mem = sc->mem; void __iomem *mem = sc->mem;
uint32_t val, i, j; uint32_t val, i, j;
uint32_t wrapper_idx[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; uint32_t wrapper_idx[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
@@ -769,7 +771,6 @@ int hif_dump_registers(struct ol_softc *scn)
*/ */
static irqreturn_t ce_per_engine_handler(int irq, void *arg) static irqreturn_t ce_per_engine_handler(int irq, void *arg)
{ {
struct hif_pci_softc *sc = (struct hif_pci_softc *)arg;
int CE_id = irq - MSI_ASSIGN_CE_INITIAL; int CE_id = irq - MSI_ASSIGN_CE_INITIAL;
/* /*
@@ -781,7 +782,7 @@ static irqreturn_t ce_per_engine_handler(int irq, void *arg)
* used by firmware. * used by firmware.
*/ */
ce_per_engine_service(sc->ol_sc, CE_id); ce_per_engine_service(arg, CE_id);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
@@ -792,7 +793,7 @@ static irqreturn_t ce_per_engine_handler(int irq, void *arg)
static void reschedule_tasklet_work_handler(void *arg) static void reschedule_tasklet_work_handler(void *arg)
{ {
struct hif_pci_softc *sc = arg; struct hif_pci_softc *sc = arg;
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
if (!scn) { if (!scn) {
HIF_ERROR("%s: ol_softc is NULL", __func__); HIF_ERROR("%s: ol_softc is NULL", __func__);
@@ -827,7 +828,7 @@ static void hif_init_reschedule_tasklet_work(struct hif_pci_softc *sc) { }
static void wlan_tasklet(unsigned long data) static void wlan_tasklet(unsigned long data)
{ {
struct hif_pci_softc *sc = (struct hif_pci_softc *)data; struct hif_pci_softc *sc = (struct hif_pci_softc *)data;
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
if (scn->hif_init_done == false) if (scn->hif_init_done == false)
goto end; goto end;
@@ -837,7 +838,7 @@ static void wlan_tasklet(unsigned long data)
if (!ADRASTEA_BU) { if (!ADRASTEA_BU) {
(irqreturn_t) hif_fw_interrupt_handler(sc->irq_event, scn); (irqreturn_t) hif_fw_interrupt_handler(sc->irq_event, scn);
if (sc->ol_sc->target_status == OL_TRGET_STATUS_RESET) if (scn->target_status == OL_TRGET_STATUS_RESET)
goto end; goto end;
} }
@@ -1042,9 +1043,7 @@ static void hif_pm_runtime_lock_timeout_fn(unsigned long data);
*/ */
static void hif_pm_runtime_start(struct hif_pci_softc *sc) static void hif_pm_runtime_start(struct hif_pci_softc *sc)
{ {
struct ol_softc *ol_sc; struct ol_softc *ol_sc = HIF_GET_SOFTC(sc);
ol_sc = sc->ol_sc;
if (!ol_sc->enable_runtime_pm) { if (!ol_sc->enable_runtime_pm) {
HIF_INFO("%s: RUNTIME PM is disabled in ini\n", __func__); HIF_INFO("%s: RUNTIME PM is disabled in ini\n", __func__);
@@ -1078,7 +1077,7 @@ static void hif_pm_runtime_start(struct hif_pci_softc *sc)
*/ */
static void hif_pm_runtime_stop(struct hif_pci_softc *sc) static void hif_pm_runtime_stop(struct hif_pci_softc *sc)
{ {
struct ol_softc *ol_sc = sc->ol_sc; struct ol_softc *ol_sc = HIF_GET_PCI_SOFTC(sc);
if (!ol_sc->enable_runtime_pm) if (!ol_sc->enable_runtime_pm)
return; return;
@@ -1148,15 +1147,13 @@ static void hif_pm_runtime_stop(struct hif_pci_softc *sc) {}
*/ */
void hif_enable_power_management(void *hif_ctx) void hif_enable_power_management(void *hif_ctx)
{ {
struct hif_pci_softc *pci_ctx; struct hif_pci_softc *pci_ctx = HIF_GET_PCI_SOFTC(hif_ctx);
if (hif_ctx == NULL) { if (pci_ctx == NULL) {
HIF_ERROR("%s, hif_ctx null", __func__); HIF_ERROR("%s, hif_ctx null", __func__);
return; return;
} }
pci_ctx = ((struct ol_softc *)hif_ctx)->hif_sc;
hif_pm_runtime_start(pci_ctx); hif_pm_runtime_start(pci_ctx);
} }
@@ -1170,15 +1167,13 @@ void hif_enable_power_management(void *hif_ctx)
*/ */
void hif_disable_power_management(void *hif_ctx) void hif_disable_power_management(void *hif_ctx)
{ {
struct hif_pci_softc *pci_ctx; struct hif_pci_softc *pci_ctx = HIF_GET_PCI_SOFTC(hif_ctx);
if (hif_ctx == NULL) { if (pci_ctx == NULL) {
HIF_ERROR("%s, hif_ctx null", __func__); HIF_ERROR("%s, hif_ctx null", __func__);
return; return;
} }
pci_ctx = ((struct ol_softc *)hif_ctx)->hif_sc;
hif_pm_runtime_stop(pci_ctx); hif_pm_runtime_stop(pci_ctx);
} }
@@ -1202,10 +1197,8 @@ int hif_bus_get_context_size(void)
*/ */
CDF_STATUS hif_bus_open(struct ol_softc *ol_sc, enum ath_hal_bus_type bus_type) CDF_STATUS hif_bus_open(struct ol_softc *ol_sc, enum ath_hal_bus_type bus_type)
{ {
struct hif_pci_softc *sc = (struct hif_pci_softc *)ol_sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(ol_sc);
ol_sc->hif_sc = (void *)sc;
sc->ol_sc = ol_sc;
ol_sc->bus_type = bus_type; ol_sc->bus_type = bus_type;
hif_pm_runtime_open(sc); hif_pm_runtime_open(sc);
@@ -1221,18 +1214,9 @@ CDF_STATUS hif_bus_open(struct ol_softc *ol_sc, enum ath_hal_bus_type bus_type)
*/ */
void hif_bus_close(struct ol_softc *ol_sc) void hif_bus_close(struct ol_softc *ol_sc)
{ {
struct hif_pci_softc *sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(ol_sc);
if (ol_sc == NULL) {
HIF_ERROR("%s: ol_softc is NULL", __func__);
return;
}
sc = ol_sc->hif_sc;
if (sc == NULL)
return;
hif_pm_runtime_close(sc); hif_pm_runtime_close(sc);
ol_sc->hif_sc = NULL;
} }
#define BAR_NUM 0 #define BAR_NUM 0
@@ -1244,7 +1228,7 @@ int hif_enable_pci(struct hif_pci_softc *sc,
void __iomem *mem; void __iomem *mem;
int ret = 0; int ret = 0;
uint16_t device_id; uint16_t device_id;
struct ol_softc *ol_sc = sc->ol_sc; struct ol_softc *ol_sc = HIF_GET_SOFTC(sc);
pci_read_config_word(pdev,PCI_DEVICE_ID,&device_id); pci_read_config_word(pdev,PCI_DEVICE_ID,&device_id);
if(device_id != id->device) { if(device_id != id->device) {
@@ -1340,12 +1324,7 @@ err_region:
void hif_disable_pci(struct hif_pci_softc *sc) void hif_disable_pci(struct hif_pci_softc *sc)
{ {
struct ol_softc *ol_sc; struct ol_softc *ol_sc = HIF_GET_SOFTC(sc);
if (!sc)
return;
ol_sc = sc->ol_sc;
if (ol_sc == NULL) { if (ol_sc == NULL) {
HIF_ERROR("%s: ol_sc = NULL", __func__); HIF_ERROR("%s: ol_sc = NULL", __func__);
return; return;
@@ -1367,7 +1346,7 @@ int hif_pci_probe_tgt_wakeup(struct hif_pci_softc *sc)
#ifndef QCA_WIFI_3_0 #ifndef QCA_WIFI_3_0
uint32_t fw_indicator; uint32_t fw_indicator;
#endif #endif
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
/* /*
* Verify that the Target was started cleanly.* * Verify that the Target was started cleanly.*
* The case where this is most likely is with an AUX-powered * The case where this is most likely is with an AUX-powered
@@ -1431,23 +1410,23 @@ static void wlan_tasklet_msi(unsigned long data)
{ {
struct hif_tasklet_entry *entry = (struct hif_tasklet_entry *)data; struct hif_tasklet_entry *entry = (struct hif_tasklet_entry *)data;
struct hif_pci_softc *sc = (struct hif_pci_softc *) entry->hif_handler; struct hif_pci_softc *sc = (struct hif_pci_softc *) entry->hif_handler;
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
if (sc->ol_sc->hif_init_done == false) if (scn->hif_init_done == false)
goto irq_handled; goto irq_handled;
if (cdf_atomic_read(&sc->ol_sc->link_suspended)) if (cdf_atomic_read(&scn->link_suspended))
goto irq_handled; goto irq_handled;
cdf_atomic_inc(&scn->active_tasklet_cnt); cdf_atomic_inc(&scn->active_tasklet_cnt);
if (entry->id == HIF_MAX_TASKLET_NUM) { if (entry->id == HIF_MAX_TASKLET_NUM) {
/* the last tasklet is for fw IRQ */ /* the last tasklet is for fw IRQ */
(irqreturn_t)hif_fw_interrupt_handler(sc->irq_event, sc->ol_sc); (irqreturn_t)hif_fw_interrupt_handler(sc->irq_event, scn);
if (sc->ol_sc->target_status == OL_TRGET_STATUS_RESET) if (scn->target_status == OL_TRGET_STATUS_RESET)
goto irq_handled; goto irq_handled;
} else if (entry->id < sc->ol_sc->ce_count) { } else if (entry->id < scn->ce_count) {
ce_per_engine_service(sc->ol_sc, entry->id); ce_per_engine_service(scn, entry->id);
} else { } else {
HIF_ERROR("%s: ERROR - invalid CE_id = %d", HIF_ERROR("%s: ERROR - invalid CE_id = %d",
__func__, entry->id); __func__, entry->id);
@@ -1464,7 +1443,7 @@ int hif_configure_msi(struct hif_pci_softc *sc)
int ret = 0; int ret = 0;
int num_msi_desired; int num_msi_desired;
int rv = -1; int rv = -1;
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
HIF_TRACE("%s: E", __func__); HIF_TRACE("%s: E", __func__);
@@ -1580,7 +1559,7 @@ if (sc->num_msi_intrs >= 1)
static int hif_pci_configure_legacy_irq(struct hif_pci_softc *sc) static int hif_pci_configure_legacy_irq(struct hif_pci_softc *sc)
{ {
int ret = 0; int ret = 0;
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
HIF_TRACE("%s: E", __func__); HIF_TRACE("%s: E", __func__);
@@ -1618,7 +1597,8 @@ end:
void hif_nointrs(struct ol_softc *scn) void hif_nointrs(struct ol_softc *scn)
{ {
int i; int i;
struct hif_pci_softc *sc = scn->hif_sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
if (scn->request_irq_done == false) if (scn->request_irq_done == false)
return; return;
@@ -1632,7 +1612,7 @@ void hif_nointrs(struct ol_softc *scn)
/* Legacy PCI line interrupt */ /* Legacy PCI line interrupt */
free_irq(sc->pdev->irq, sc); free_irq(sc->pdev->irq, sc);
} }
ce_unregister_irq(scn->hif_hdl, 0xfff); ce_unregister_irq(hif_state, 0xfff);
scn->request_irq_done = false; scn->request_irq_done = false;
} }
@@ -1658,7 +1638,7 @@ void hif_disable_bus(void *bdev)
if (!sc) if (!sc)
return; return;
scn = sc->ol_sc; scn = HIF_GET_SOFTC(sc);
if (ADRASTEA_BU) { if (ADRASTEA_BU) {
hif_write32_mb(sc->mem + PCIE_INTR_ENABLE_ADDRESS, 0); hif_write32_mb(sc->mem + PCIE_INTR_ENABLE_ADDRESS, 0);
@@ -1832,20 +1812,16 @@ static int hif_bus_resume_link_up(struct ol_softc *scn)
static int hif_bus_suspend_link_down(struct ol_softc *scn) static int hif_bus_suspend_link_down(struct ol_softc *scn)
{ {
struct pci_dev *pdev; struct pci_dev *pdev;
struct HIF_CE_state *hif_state; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
int status = 0; int status = 0;
if (!scn)
return -EFAULT;
pdev = scn->aps_osdev.bdev;
hif_state = (struct HIF_CE_state *)scn->hif_hdl;
if (!hif_state) { if (!hif_state) {
HIF_ERROR("%s: hif_state is null", __func__); HIF_ERROR("%s: hif_state is null", __func__);
return -EFAULT; return -EFAULT;
} }
pdev = scn->aps_osdev.bdev;
disable_irq(pdev->irq); disable_irq(pdev->irq);
status = hif_drain_tasklets(scn); status = hif_drain_tasklets(scn);
@@ -2186,13 +2162,13 @@ static void hif_free_msi_ctx(struct ol_softc *scn)
void hif_disable_isr(void *ol_sc) void hif_disable_isr(void *ol_sc)
{ {
struct ol_softc *scn = (struct ol_softc *)ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(ol_sc);
struct hif_pci_softc *sc = scn->hif_sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
hif_nointrs(ol_sc); hif_nointrs(ol_sc);
hif_free_msi_ctx(scn); hif_free_msi_ctx(scn);
/* Cancel the pending tasklet */ /* Cancel the pending tasklet */
ce_tasklet_kill(scn->hif_hdl); ce_tasklet_kill(ol_sc);
tasklet_kill(&sc->intr_tq); tasklet_kill(&sc->intr_tq);
cdf_atomic_set(&scn->active_tasklet_cnt, 0); cdf_atomic_set(&scn->active_tasklet_cnt, 0);
} }
@@ -2200,8 +2176,8 @@ void hif_disable_isr(void *ol_sc)
/* Function to reset SoC */ /* Function to reset SoC */
void hif_reset_soc(void *ol_sc) void hif_reset_soc(void *ol_sc)
{ {
struct ol_softc *scn = (struct ol_softc *)ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(ol_sc);
struct hif_pci_softc *sc = scn->hif_sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(ol_sc);
struct hif_target_info *tgt_info = hif_get_target_info_handle(scn); struct hif_target_info *tgt_info = hif_get_target_info_handle(scn);
#if defined(CPU_WARM_RESET_WAR) #if defined(CPU_WARM_RESET_WAR)
@@ -2220,8 +2196,8 @@ void hif_reset_soc(void *ol_sc)
void hif_disable_aspm(void *hif_ctx) void hif_disable_aspm(void *hif_ctx)
{ {
struct ol_softc *scn = hif_ctx; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct hif_pci_softc *sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_ctx);
if (NULL == scn) { if (NULL == scn) {
HIF_ERROR("%s: Could not disable ASPM scn is null", HIF_ERROR("%s: Could not disable ASPM scn is null",
@@ -2229,8 +2205,6 @@ void hif_disable_aspm(void *hif_ctx)
return; return;
} }
sc = scn->hif_sc;
/* Disable ASPM when pkt log is enabled */ /* Disable ASPM when pkt log is enabled */
pci_read_config_dword(sc->pdev, 0x80, &sc->lcr_val); pci_read_config_dword(sc->pdev, 0x80, &sc->lcr_val);
pci_write_config_dword(sc->pdev, 0x80, (sc->lcr_val & 0xffffff00)); pci_write_config_dword(sc->pdev, 0x80, (sc->lcr_val & 0xffffff00));
@@ -2245,15 +2219,14 @@ void hif_disable_aspm(void *hif_ctx)
*/ */
void hif_enable_power_gating(void *hif_ctx) void hif_enable_power_gating(void *hif_ctx)
{ {
struct ol_softc *scn = hif_ctx; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct hif_pci_softc *sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_ctx);
if (NULL == scn) { if (NULL == scn) {
HIF_ERROR("%s: Could not disable ASPM scn is null", HIF_ERROR("%s: Could not disable ASPM scn is null",
__func__); __func__);
return; return;
} }
sc = scn->hif_sc;
/* Re-enable ASPM after firmware/OTP download is complete */ /* Re-enable ASPM after firmware/OTP download is complete */
pci_write_config_dword(sc->pdev, 0x80, sc->lcr_val); pci_write_config_dword(sc->pdev, 0x80, sc->lcr_val);
@@ -2310,10 +2283,10 @@ int
hif_target_sleep_state_adjust(struct ol_softc *scn, hif_target_sleep_state_adjust(struct ol_softc *scn,
bool sleep_ok, bool wait_for_it) bool sleep_ok, bool wait_for_it)
{ {
struct HIF_CE_state *hif_state = scn->hif_hdl; struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
A_target_id_t pci_addr = scn->mem; A_target_id_t pci_addr = scn->mem;
static int max_delay; static int max_delay;
struct hif_pci_softc *sc = scn->hif_sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(scn);
static int debug; static int debug;
struct hif_config_info *cfg = hif_get_ini_handle(scn); struct hif_config_info *cfg = hif_get_ini_handle(scn);
@@ -2625,7 +2598,7 @@ void war_pci_write32(char *addr, uint32_t offset, uint32_t value)
int hif_configure_irq(struct hif_pci_softc *sc) int hif_configure_irq(struct hif_pci_softc *sc)
{ {
int ret = 0; int ret = 0;
struct ol_softc *scn = sc->ol_sc; struct ol_softc *scn = HIF_GET_SOFTC(sc);
HIF_TRACE("%s: E", __func__); HIF_TRACE("%s: E", __func__);
@@ -2676,7 +2649,7 @@ void hif_target_sync(struct ol_softc *scn)
int fw_ind = 0; int fw_ind = 0;
HIF_TRACE("%s: Loop checking FW signal", __func__); HIF_TRACE("%s: Loop checking FW signal", __func__);
while (1) { while (1) {
fw_ind = hif_read32_mb(scn->hif_sc->mem + fw_ind = hif_read32_mb(scn->mem +
FW_INDICATOR_ADDRESS); FW_INDICATOR_ADDRESS);
if (fw_ind & FW_IND_INITIALIZED) if (fw_ind & FW_IND_INITIALIZED)
break; break;
@@ -2718,7 +2691,7 @@ CDF_STATUS hif_enable_bus(struct ol_softc *ol_sc,
{ {
int ret = 0; int ret = 0;
uint32_t hif_type, target_type; uint32_t hif_type, target_type;
struct hif_pci_softc *sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(ol_sc);
uint16_t revision_id; uint16_t revision_id;
uint32_t lcr_val; uint32_t lcr_val;
int probe_again = 0; int probe_again = 0;
@@ -2733,7 +2706,6 @@ CDF_STATUS hif_enable_bus(struct ol_softc *ol_sc,
HIF_ERROR("%s: hif_ctx is NULL", __func__); HIF_ERROR("%s: hif_ctx is NULL", __func__);
return CDF_STATUS_E_NOMEM; return CDF_STATUS_E_NOMEM;
} }
sc = ol_sc->hif_sc;
ol_sc->aps_osdev.bdev = pdev; ol_sc->aps_osdev.bdev = pdev;
sc->pdev = pdev; sc->pdev = pdev;
@@ -2772,8 +2744,8 @@ again:
HIF_TRACE("%s: hif_type = 0x%x, target_type = 0x%x", HIF_TRACE("%s: hif_type = 0x%x, target_type = 0x%x",
__func__, hif_type, target_type); __func__, hif_type, target_type);
hif_register_tbl_attach(sc->ol_sc, hif_type); hif_register_tbl_attach(ol_sc, hif_type);
target_register_tbl_attach(sc->ol_sc, target_type); target_register_tbl_attach(ol_sc, target_type);
ret = hif_pci_probe_tgt_wakeup(sc); ret = hif_pci_probe_tgt_wakeup(sc);
if (ret < 0) { if (ret < 0) {
@@ -2858,13 +2830,9 @@ int hif_get_target_type(struct ol_softc *ol_sc, struct device *dev,
void hif_pm_runtime_get_noresume(void *hif_ctx) void hif_pm_runtime_get_noresume(void *hif_ctx)
{ {
struct ol_softc *scn = hif_ctx; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct hif_pci_softc *sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_ctx);
if (NULL == scn)
return;
sc = scn->hif_sc;
if (NULL == sc) if (NULL == sc)
return; return;
@@ -2887,8 +2855,8 @@ void hif_pm_runtime_get_noresume(void *hif_ctx)
*/ */
int hif_pm_runtime_get(void *hif_ctx) int hif_pm_runtime_get(void *hif_ctx)
{ {
struct ol_softc *scn = hif_ctx; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct hif_pci_softc *sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_ctx);
int ret; int ret;
int pm_state; int pm_state;
@@ -2897,7 +2865,6 @@ int hif_pm_runtime_get(void *hif_ctx)
__func__); __func__);
return -EFAULT; return -EFAULT;
} }
sc = scn->hif_sc;
pm_state = cdf_atomic_read(&sc->pm_state); pm_state = cdf_atomic_read(&sc->pm_state);
@@ -2944,8 +2911,8 @@ int hif_pm_runtime_get(void *hif_ctx)
*/ */
int hif_pm_runtime_put(void *hif_ctx) int hif_pm_runtime_put(void *hif_ctx)
{ {
struct ol_softc *scn = (struct ol_softc *)hif_ctx; struct ol_softc *scn = HIF_GET_SOFTC(hif_ctx);
struct hif_pci_softc *sc; struct hif_pci_softc *sc = HIF_GET_PCI_SOFTC(hif_ctx);
int pm_state, usage_count; int pm_state, usage_count;
unsigned long flags; unsigned long flags;
char *error = NULL; char *error = NULL;
@@ -2955,8 +2922,6 @@ int hif_pm_runtime_put(void *hif_ctx)
__func__); __func__);
return -EFAULT; return -EFAULT;
} }
sc = scn->hif_sc;
usage_count = atomic_read(&sc->dev->power.usage_count); usage_count = atomic_read(&sc->dev->power.usage_count);
if (usage_count == 1) { if (usage_count == 1) {

View File

@@ -117,7 +117,6 @@ struct hif_pci_softc {
struct device *dev; struct device *dev;
struct pci_dev *pdev; struct pci_dev *pdev;
struct ol_softc *ol_sc;
int num_msi_intrs; /* number of MSI interrupts granted */ int num_msi_intrs; /* number of MSI interrupts granted */
/* 0 --> using legacy PCI line interrupts */ /* 0 --> using legacy PCI line interrupts */
struct tasklet_struct intr_tq; /* tasklet */ struct tasklet_struct intr_tq; /* tasklet */

View File

@@ -94,9 +94,10 @@ void hif_reset_soc(void *hif_ctx)
void hif_disable_isr(void *hif_ctx) void hif_disable_isr(void *hif_ctx)
{ {
struct ol_softc *scn = (struct ol_softc *)hif_ctx; struct ol_softc *scn = (struct ol_softc *)hif_ctx;
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
hif_nointrs(scn); hif_nointrs(scn);
ce_tasklet_kill(scn->hif_hdl); ce_tasklet_kill(scn);
cdf_atomic_set(&scn->active_tasklet_cnt, 0); cdf_atomic_set(&scn->active_tasklet_cnt, 0);
} }
@@ -316,8 +317,9 @@ void hif_disable_bus(void *bdev)
*/ */
void hif_nointrs(struct ol_softc *scn) void hif_nointrs(struct ol_softc *scn)
{ {
struct HIF_CE_state *hif_state = HIF_GET_CE_STATE(scn);
if (scn->request_irq_done) { if (scn->request_irq_done) {
ce_unregister_irq(scn->hif_hdl, 0xfff); ce_unregister_irq(hif_state, 0xfff);
scn->request_irq_done = false; scn->request_irq_done = false;
} }
} }