qcacmn: remove fw headers in init_deinit component

Avoid direct fw headers usage in init_deinit component since
can have functional impacts. The inclusion is done at wmi level 
to fix the inconsistency of code. 

Change-Id: I73cc1aac500cec041de81750b9c7654d21344e6c
CRs-Fixed: 2505399
This commit is contained in:
Neha Bisht
2019-12-11 14:13:22 +05:30
committed by nshrivas
parent 294f63373d
commit 5f25cbe8f2
7 changed files with 190 additions and 146 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
* Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the
@@ -30,7 +30,6 @@
#include <wlan_tgt_def_config.h>
#include <wlan_reg_ucfg_api.h>
#include <init_cmd_api.h>
#include <wlan_defs.h>
#include <target_if_scan.h>
#include <target_if_reg.h>
@@ -182,98 +181,6 @@ static QDF_STATUS init_deinit_alloc_host_mem(struct wlan_objmgr_psoc *psoc,
return QDF_STATUS_SUCCESS;
}
/**
* init_deinit_alloc_num_units() - allocates num units requested by FW.
* @psoc: PSOC object
* @tgt_hdl: Target PSOC info
* @mem_reqs: pointer to mem req
* @num_units: Number
* @i: FW priority
* @idx: Index
*
* API to allocate num units of host memory requested by FW
*
* Return: QDF_STATUS_SUCCESS on successful allocation
* QDF_STATUS_E_FAILURE on failure
*/
static QDF_STATUS init_deinit_alloc_num_units(struct wlan_objmgr_psoc *psoc,
struct target_psoc_info *tgt_hdl,
host_mem_req *mem_reqs, uint16_t fw_prio,
uint16_t idx)
{
struct tgt_info *info;
uint32_t num_units;
QDF_STATUS status;
if (!tgt_hdl || !mem_reqs) {
target_if_err("Invalid parameters, tgt_hdl: %pK, mem_reqs: %pK",
tgt_hdl, mem_reqs);
return QDF_STATUS_E_INVAL;
}
info = (&tgt_hdl->info);
if (((fw_prio == FW_MEM_HIGH_PRIORITY) &&
(mem_reqs[idx].num_unit_info &
HOST_CONTIGUOUS_MEM_CHUNK_REQUIRED)) ||
((fw_prio == FW_MEM_LOW_PRIORITY) &&
(!(mem_reqs[idx].num_unit_info &
HOST_CONTIGUOUS_MEM_CHUNK_REQUIRED)))) {
/* First allocate the memory that requires contiguous memory */
num_units = mem_reqs[idx].num_units;
if (mem_reqs[idx].num_unit_info) {
if (mem_reqs[idx].num_unit_info &
NUM_UNITS_IS_NUM_PEERS) {
/*
* number of units allocated is equal to number
* of peers, 1 extra for self peer on target.
* this needs to be fixed, host and target can
* get out of sync
*/
num_units = info->wlan_res_cfg.num_peers + 1;
}
if (mem_reqs[idx].num_unit_info &
NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
/*
* Requesting allocation of memory using
* num_active_peers in qcache. if qcache is
* disabled in host, then it should allocate
* memory for num_peers instead of
* num_active_peers.
*/
if (info->wlan_res_cfg.num_active_peers)
num_units =
info->wlan_res_cfg.num_active_peers + 1;
else
num_units =
info->wlan_res_cfg.num_peers + 1;
}
}
target_if_debug("idx %d req %d num_units %d num_unit_info %d unit size %d actual units %d",
idx, mem_reqs[idx].req_id,
mem_reqs[idx].num_units,
mem_reqs[idx].num_unit_info,
mem_reqs[idx].unit_size, num_units);
status = init_deinit_alloc_host_mem(psoc, tgt_hdl,
mem_reqs[idx].req_id, num_units,
mem_reqs[idx].unit_size,
mem_reqs[idx].num_unit_info);
if (status == QDF_STATUS_E_FAILURE) {
target_if_err(
"psoc:(%pK) num_mem_chunk exceeds supp number",
psoc);
return QDF_STATUS_E_FAILURE;
} else if (status == QDF_STATUS_E_NOMEM) {
target_if_err("soc:(%pK) mem alloc failure", psoc);
return QDF_STATUS_E_NOMEM;
}
}
return QDF_STATUS_SUCCESS;
}
QDF_STATUS init_deinit_free_num_units(struct wlan_objmgr_psoc *psoc,
struct target_psoc_info *tgt_hdl)
{
@@ -300,12 +207,12 @@ QDF_STATUS init_deinit_free_num_units(struct wlan_objmgr_psoc *psoc,
info = (&tgt_hdl->info);
for (idx = 0; idx < info->num_mem_chunks; idx++) {
qdf_mem_free_consistent(
qdf_dev, qdf_dev->dev,
info->mem_chunks[idx].len,
info->mem_chunks[idx].vaddr,
info->mem_chunks[idx].paddr,
qdf_get_dma_mem_context(
(&(info->mem_chunks[idx])), memctx));
qdf_dev, qdf_dev->dev,
info->mem_chunks[idx].len,
info->mem_chunks[idx].vaddr,
info->mem_chunks[idx].paddr,
qdf_get_dma_mem_context(
(&info->mem_chunks[idx]), memctx));
info->mem_chunks[idx].vaddr = NULL;
info->mem_chunks[idx].paddr = 0;
@@ -319,11 +226,11 @@ QDF_STATUS init_deinit_free_num_units(struct wlan_objmgr_psoc *psoc,
}
QDF_STATUS init_deinit_handle_host_mem_req(
struct wlan_objmgr_psoc *psoc,
struct target_psoc_info *tgt_hdl, uint8_t *event)
struct wlan_objmgr_psoc *psoc,
struct target_psoc_info *tgt_hdl, uint8_t *event)
{
uint8_t num_mem_reqs;
host_mem_req *mem_reqs;
uint32_t num_mem_reqs;
host_mem_req mem_reqs;
uint32_t i;
uint32_t idx;
QDF_STATUS status = QDF_STATUS_SUCCESS;
@@ -338,21 +245,38 @@ QDF_STATUS init_deinit_handle_host_mem_req(
wmi_handle = target_psoc_get_wmi_hdl(tgt_hdl);
info = (&tgt_hdl->info);
mem_reqs = wmi_extract_host_mem_req_from_service_ready(
wmi_handle, event, &num_mem_reqs);
num_mem_reqs = wmi_extract_num_mem_reqs_from_service_ready(
wmi_handle, event);
if (!num_mem_reqs)
return QDF_STATUS_SUCCESS;
if (num_mem_reqs > MAX_MEM_CHUNKS) {
target_if_err_rl("num_mem_reqs:%u is out of bounds",
num_mem_reqs);
num_mem_reqs);
return QDF_STATUS_E_FAILURE;
}
for (i = 0; i < FW_PRIORITY_MAX; i++) {
for (i = 0; i < WMI_FW_PRIORITY_MAX; i++) {
for (idx = 0; idx < num_mem_reqs; idx++) {
status = init_deinit_alloc_num_units(psoc, tgt_hdl,
mem_reqs, i, idx);
status = wmi_extract_host_mem_req_from_service_ready(
wmi_handle, event, &mem_reqs,
info->wlan_res_cfg.num_active_peers,
info->wlan_res_cfg.num_peers, i, idx);
if (mem_reqs.tgt_num_units) {
status = init_deinit_alloc_host_mem(
psoc,
tgt_hdl,
mem_reqs.req_id,
mem_reqs.tgt_num_units,
mem_reqs.unit_size,
mem_reqs.num_unit_info);
if (status == QDF_STATUS_E_FAILURE) {
target_if_err("num_mem_chunk exceeds supp number");
} else if (status == QDF_STATUS_E_NOMEM) {
target_if_err("mem alloc failure");
}
}
if (status != QDF_STATUS_SUCCESS)
return status;
}