qcacmn: Enable wbuff support for WMI

Register WMI with wbuff for pre-allocation of
skbs. Register at wmi_unified_attach() and
de-register at wmi wmi_unified_detach().

Change-Id: I9d6df1a8480324dd2a258de12672669a8fbe8940
CRs-Fixed: 2313935
This commit is contained in:
Rakshith Suresh Patkar
2018-09-12 16:51:30 +05:30
committed by nshrivas
parent a1860003dd
commit 1f18454889
3 changed files with 76 additions and 13 deletions

View File

@@ -30,6 +30,7 @@
#include <wmi_unified.h>
#endif
#include "qdf_atomic.h"
#include <wbuff.h>
#ifdef CONVERGED_P2P_ENABLE
#include <wlan_p2p_public_struct.h>
@@ -1795,6 +1796,7 @@ struct wmi_host_abi_version {
struct wmi_unified {
void *scn_handle; /* handle to device */
osdev_t osdev; /* handle to use OS-independent services */
struct wbuff_mod_handle *wbuff_handle; /* handle to wbuff */
qdf_atomic_t pending_cmds;
HTC_ENDPOINT_ID wmi_endpoint_id;
uint16_t max_msg_len;

View File

@@ -352,6 +352,16 @@ typedef PREPACK struct {
#define WMI_MIN_HEAD_ROOM 64
/* WBUFF pool sizes for WMI */
/* Allocation of size 256 bytes */
#define WMI_WBUFF_POOL_0_SIZE 128
/* Allocation of size 512 bytes */
#define WMI_WBUFF_POOL_1_SIZE 16
/* Allocation of size 1024 bytes */
#define WMI_WBUFF_POOL_2_SIZE 8
/* Allocation of size 2048 bytes */
#define WMI_WBUFF_POOL_3_SIZE 8
#ifdef WMI_INTERFACE_EVENT_LOGGING
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0))
/* TODO Cleanup this backported function */
@@ -1462,10 +1472,13 @@ wmi_buf_alloc_debug(wmi_unified_t wmi_handle, uint32_t len, uint8_t *file_name,
return NULL;
}
wmi_buf = qdf_nbuf_alloc_debug(NULL,
roundup(len + WMI_MIN_HEAD_ROOM, 4),
WMI_MIN_HEAD_ROOM, 4, false, file_name,
line_num);
wmi_buf = wbuff_buff_get(wmi_handle->wbuff_handle, len);
if (!wmi_buf)
wmi_buf = qdf_nbuf_alloc_debug(NULL,
roundup(len + WMI_MIN_HEAD_ROOM,
4),
WMI_MIN_HEAD_ROOM, 4, false,
file_name, line_num);
if (!wmi_buf)
return NULL;
@@ -1484,7 +1497,9 @@ qdf_export_symbol(wmi_buf_alloc_debug);
void wmi_buf_free(wmi_buf_t net_buf)
{
qdf_nbuf_free(net_buf);
net_buf = wbuff_buff_put(net_buf);
if (net_buf)
qdf_nbuf_free(net_buf);
}
qdf_export_symbol(wmi_buf_free);
#else
@@ -1499,8 +1514,12 @@ wmi_buf_t wmi_buf_alloc_fl(wmi_unified_t wmi_handle, uint32_t len,
return NULL;
}
wmi_buf = qdf_nbuf_alloc_fl(NULL, roundup(len + WMI_MIN_HEAD_ROOM, 4),
WMI_MIN_HEAD_ROOM, 4, false, func, line);
wmi_buf = wbuff_buff_get(wmi_handle->wbuff_handle, len);
if (!wmi_buf)
wmi_buf = qdf_nbuf_alloc_fl(NULL, roundup(len +
WMI_MIN_HEAD_ROOM, 4), WMI_MIN_HEAD_ROOM, 4,
false, func, line);
if (!wmi_buf)
return NULL;
@@ -1517,7 +1536,9 @@ qdf_export_symbol(wmi_buf_alloc_fl);
void wmi_buf_free(wmi_buf_t net_buf)
{
qdf_nbuf_free(net_buf);
net_buf = wbuff_buff_put(net_buf);
if (net_buf)
qdf_nbuf_free(net_buf);
}
qdf_export_symbol(wmi_buf_free);
#endif
@@ -2392,6 +2413,41 @@ void wmi_unified_register_module(enum wmi_target_type target_type,
}
qdf_export_symbol(wmi_unified_register_module);
/**
* wmi_wbuff_register() - register wmi with wbuff
* @wmi_handle: handle to wmi
*
* @Return: void
*/
static void wmi_wbuff_register(struct wmi_unified *wmi_handle)
{
struct wbuff_alloc_request wbuff_alloc[4];
wbuff_alloc[0].slot = WBUFF_POOL_0;
wbuff_alloc[0].size = WMI_WBUFF_POOL_0_SIZE;
wbuff_alloc[1].slot = WBUFF_POOL_1;
wbuff_alloc[1].size = WMI_WBUFF_POOL_1_SIZE;
wbuff_alloc[2].slot = WBUFF_POOL_2;
wbuff_alloc[2].size = WMI_WBUFF_POOL_2_SIZE;
wbuff_alloc[3].slot = WBUFF_POOL_3;
wbuff_alloc[3].size = WMI_WBUFF_POOL_3_SIZE;
wmi_handle->wbuff_handle = wbuff_module_register(wbuff_alloc, 4,
WMI_MIN_HEAD_ROOM, 4);
}
/**
* wmi_wbuff_deregister() - deregister wmi with wbuff
* @wmi_handle: handle to wmi
*
* @Return: void
*/
static inline void wmi_wbuff_deregister(struct wmi_unified *wmi_handle)
{
wbuff_module_deregister(wmi_handle->wbuff_handle);
wmi_handle->wbuff_handle = NULL;
}
/**
* wmi_unified_attach() - attach for unified WMI
* @scn_handle: handle to SCN
@@ -2478,6 +2534,8 @@ void *wmi_unified_attach(void *scn_handle,
if (wmi_ext_dbgfs_init(wmi_handle) != QDF_STATUS_SUCCESS)
WMI_LOGE("failed to initialize wmi extended debugfs");
wmi_wbuff_register(wmi_handle);
return wmi_handle;
error:
@@ -2500,7 +2558,10 @@ void wmi_unified_detach(struct wmi_unified *wmi_handle)
struct wmi_soc *soc;
uint8_t i;
wmi_wbuff_deregister(wmi_handle);
wmi_ext_dbgfs_deinit(wmi_handle);
soc = wmi_handle->soc;
for (i = 0; i < WMI_MAX_RADIOS; i++) {
if (soc->wmi_pdev[i]) {
@@ -2621,7 +2682,7 @@ static void wmi_htc_tx_complete(void *ctx, HTC_PACKET *htc_pkt)
buf_ptr = (u_int8_t *) wmi_buf_data(wmi_cmd_buf);
len = qdf_nbuf_len(wmi_cmd_buf);
qdf_mem_zero(buf_ptr, len);
qdf_nbuf_free(wmi_cmd_buf);
wmi_buf_free(wmi_cmd_buf);
qdf_mem_free(htc_pkt);
qdf_atomic_dec(&wmi_handle->pending_cmds);
}

View File

@@ -975,7 +975,7 @@ QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
__func__);
qdf_nbuf_free(buf);
wmi_buf_free(buf);
return QDF_STATUS_E_FAILURE;
}
WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
@@ -1022,7 +1022,7 @@ QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
__func__);
qdf_nbuf_free(buf);
wmi_buf_free(buf);
return QDF_STATUS_E_FAILURE;
}
WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
@@ -14324,7 +14324,7 @@ QDF_STATUS send_enable_enhance_multicast_offload_tlv(
status = wmi_unified_cmd_send(wmi_handle, buf,
sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
if (status != QDF_STATUS_SUCCESS) {
qdf_nbuf_free(buf);
wmi_buf_free(buf);
WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
__func__);
}
@@ -15373,7 +15373,7 @@ QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
WMI_FWTEST_CMDID)) {
WMI_LOGP("%s: failed to send fw test command", __func__);
qdf_nbuf_free(wmi_buf);
wmi_buf_free(wmi_buf);
return QDF_STATUS_E_FAILURE;
}