From ec01bbcfbe1f9ddbf19ce6c677cef3ccd7648138 Mon Sep 17 00:00:00 2001 From: Venkata Sharath Chandra Manchala Date: Thu, 25 Apr 2019 13:31:34 -0700 Subject: [PATCH] qcacmn: Copy HTC Packet data Make a local copy of HTC buffer before giving it to Firmware through CE Change-Id: Ib11ee7f0d7cd7b055768c0fe10627b81383257f3 CRs-Fixed: 2434881 --- hif/src/ce/ce_internal.h | 17 ++++++++++---- hif/src/ce/ce_main.c | 48 +++++++++++++++++++++++++++++++--------- hif/src/ce/ce_service.c | 24 ++++++++++++-------- hif/src/hif_main.h | 4 ++-- 4 files changed, 67 insertions(+), 26 deletions(-) diff --git a/hif/src/ce/ce_internal.h b/hif/src/ce/ce_internal.h index ef954c59a059..ca62f31ca3e2 100644 --- a/hif/src/ce/ce_internal.h +++ b/hif/src/ce/ce_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 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 @@ -542,15 +542,24 @@ struct hif_ce_desc_event { void *memory; #ifdef HIF_CE_DEBUG_DATA_BUF uint8_t *data; - ssize_t actual_data_len; -#endif + size_t actual_data_len; +#endif /* HIF_CE_DEBUG_DATA_BUF */ }; +#endif /*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/ #ifdef HIF_CE_DEBUG_DATA_BUF QDF_STATUS alloc_mem_ce_debug_hist_data(struct hif_softc *scn, uint32_t ce_id); void free_mem_ce_debug_hist_data(struct hif_softc *scn, uint32_t ce_id); +#else +static inline +QDF_STATUS alloc_mem_ce_debug_hist_data(struct hif_softc *scn, uint32_t ce_id) +{ + return QDF_STATUS_SUCCESS; +} + +static inline +void free_mem_ce_debug_hist_data(struct hif_softc *scn, uint32_t ce_id) { } #endif /*HIF_CE_DEBUG_DATA_BUF*/ -#endif/*#if defined(HIF_CONFIG_SLUB_DEBUG_ON)||defined(HIF_CE_DEBUG_DATA_BUF)*/ #ifdef HIF_CONFIG_SLUB_DEBUG_ON /** diff --git a/hif/src/ce/ce_main.c b/hif/src/ce/ce_main.c index d0415885fe53..6fd3ff79ab68 100644 --- a/hif/src/ce/ce_main.c +++ b/hif/src/ce/ce_main.c @@ -1238,6 +1238,7 @@ QDF_STATUS alloc_mem_ce_debug_hist_data(struct hif_softc *scn, uint32_t ce_id) if (!hist_ev) return QDF_STATUS_E_NOMEM; + scn->hif_ce_desc_hist.data_enable[ce_id] = true; for (index = 0; index < HIF_CE_HISTORY_MAX; index++) { event = &hist_ev[index]; event->data = @@ -1278,24 +1279,31 @@ void free_mem_ce_debug_hist_data(struct hif_softc *scn, uint32_t ce_id) } #endif /* HIF_CE_DEBUG_DATA_BUF */ -#if defined(HIF_CONFIG_SLUB_DEBUG_ON) /* MCL */ +#if defined(CONFIG_MCL) +#if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF) struct hif_ce_desc_event hif_ce_desc_history[CE_COUNT_MAX][HIF_CE_HISTORY_MAX]; /** * alloc_mem_ce_debug_history() - Allocate CE descriptor history * @scn: hif scn handle * @ce_id: Copy Engine Id - * + * @src_nentries: source ce ring entries * Return: QDF_STATUS */ static QDF_STATUS -alloc_mem_ce_debug_history(struct hif_softc *scn, unsigned int ce_id) +alloc_mem_ce_debug_history(struct hif_softc *scn, unsigned int ce_id, + uint32_t src_nentries) { struct ce_desc_hist *ce_hist = &scn->hif_ce_desc_hist; ce_hist->hist_ev[ce_id] = hif_ce_desc_history[ce_id]; ce_hist->enable[ce_id] = 1; + if (src_nentries) + alloc_mem_ce_debug_hist_data(scn, ce_id); + else + ce_hist->data_enable[ce_id] = false; + return QDF_STATUS_SUCCESS; } @@ -1312,12 +1320,28 @@ static void free_mem_ce_debug_history(struct hif_softc *scn, unsigned int ce_id) ce_hist->enable[ce_id] = 0; ce_hist->hist_ev[ce_id] = NULL; + if (ce_hist->data_enable[ce_id]) { + ce_hist->data_enable[ce_id] = false; + free_mem_ce_debug_hist_data(scn, ce_id); + } +} +#else +static inline QDF_STATUS +alloc_mem_ce_debug_history(struct hif_softc *scn, unsigned int CE_id, + uint32_t src_nentries) +{ + return QDF_STATUS_SUCCESS; } -#elif defined(HIF_CE_DEBUG_DATA_BUF) /* WIN */ +static inline void +free_mem_ce_debug_history(struct hif_softc *scn, unsigned int CE_id) { } +#endif /* (HIF_CONFIG_SLUB_DEBUG_ON) || (HIF_CE_DEBUG_DATA_BUF) */ +#elif defined(CONFIG_WIN) +#if defined(HIF_CE_DEBUG_DATA_BUF) static QDF_STATUS -alloc_mem_ce_debug_history(struct hif_softc *scn, unsigned int CE_id) +alloc_mem_ce_debug_history(struct hif_softc *scn, unsigned int CE_id, + uint32_t src_nentries) { scn->hif_ce_desc_hist.hist_ev[CE_id] = (struct hif_ce_desc_event *) qdf_mem_malloc(HIF_CE_HISTORY_MAX * sizeof(struct hif_ce_desc_event)); @@ -1339,8 +1363,8 @@ static void free_mem_ce_debug_history(struct hif_softc *scn, unsigned int CE_id) if (!hist_ev) return; - if (ce_hist->data_enable[CE_id] == 1) { - ce_hist->data_enable[CE_id] = 0; + if (ce_hist->data_enable[CE_id]) { + ce_hist->data_enable[CE_id] = false; free_mem_ce_debug_hist_data(scn, CE_id); } @@ -1349,17 +1373,19 @@ static void free_mem_ce_debug_history(struct hif_softc *scn, unsigned int CE_id) ce_hist->hist_ev[CE_id] = NULL; } -#else /* Disabled */ +#else static inline QDF_STATUS -alloc_mem_ce_debug_history(struct hif_softc *scn, unsigned int CE_id) +alloc_mem_ce_debug_history(struct hif_softc *scn, unsigned int CE_id, + uint32_t src_nentries) { return QDF_STATUS_SUCCESS; } static inline void free_mem_ce_debug_history(struct hif_softc *scn, unsigned int CE_id) { } -#endif +#endif /* HIF_CE_DEBUG_DATA_BUF */ +#endif /* CONFIG_MCL */ #if defined(HIF_CONFIG_SLUB_DEBUG_ON) || defined(HIF_CE_DEBUG_DATA_BUF) /** @@ -1606,7 +1632,7 @@ struct CE_handle *ce_init(struct hif_softc *scn, ce_mark_datapath(CE_state); scn->ce_id_to_state[CE_id] = CE_state; - alloc_mem_ce_debug_history(scn, CE_id); + alloc_mem_ce_debug_history(scn, CE_id, attr->src_nentries); return (struct CE_handle *)CE_state; diff --git a/hif/src/ce/ce_service.c b/hif/src/ce/ce_service.c index eef48cca131f..6dadc181d2a8 100644 --- a/hif/src/ce/ce_service.c +++ b/hif/src/ce/ce_service.c @@ -123,12 +123,15 @@ static int get_next_record_index(qdf_atomic_t *table_index, int array_size) * @len: length of the data * Return: */ -static void hif_ce_desc_data_record(struct hif_ce_desc_event *event, int len) +static inline +void hif_ce_desc_data_record(struct hif_ce_desc_event *event, int len) { uint8_t *data = NULL; - if (!event->data) + if (!event->data) { + hif_err("No memory allocated"); return; + } if (event->memory && len > 0) data = qdf_nbuf_data((qdf_nbuf_t)event->memory); @@ -143,7 +146,12 @@ static void hif_ce_desc_data_record(struct hif_ce_desc_event *event, int len) event->actual_data_len = len; } } -#endif +#else +static inline +void hif_ce_desc_data_record(struct hif_ce_desc_event *event, int len) +{ +} +#endif /* HIF_CE_DEBUG_DATA_BUF */ /** * hif_record_ce_desc_event() - record ce descriptor events @@ -197,10 +205,8 @@ void hif_record_ce_desc_event(struct hif_softc *scn, int ce_id, event->memory = memory; event->index = index; -#ifdef HIF_CE_DEBUG_DATA_BUF if (ce_hist->data_enable[ce_id]) hif_ce_desc_data_record(event, len); -#endif } qdf_export_symbol(hif_record_ce_desc_event); @@ -1575,7 +1581,7 @@ ssize_t hif_dump_desc_event(struct hif_softc *scn, char *buf) ce_event_type_to_str(event->type), event->index, event->memory); #ifdef HIF_CE_DEBUG_DATA_BUF - len += snprintf(buf + len, PAGE_SIZE - len, ", Data len=%d", + len += snprintf(buf + len, PAGE_SIZE - len, ", Data len=%lu", event->actual_data_len); #endif @@ -1692,18 +1698,18 @@ ssize_t hif_ce_en_desc_hist(struct hif_softc *scn, const char *buf, size_t size) qdf_mutex_acquire(&ce_hist->ce_dbg_datamem_lock[ce_id]); if (cfg == 1) { if (ce_hist->data_enable[ce_id] == 1) { - qdf_print("\nAlready Enabled"); + qdf_debug("Already Enabled"); } else { if (alloc_mem_ce_debug_hist_data(scn, ce_id) == QDF_STATUS_E_NOMEM){ ce_hist->data_enable[ce_id] = 0; - qdf_print("%s:Memory Alloc failed"); + qdf_err("%s:Memory Alloc failed", __func__); } else ce_hist->data_enable[ce_id] = 1; } } else if (cfg == 0) { if (ce_hist->data_enable[ce_id] == 0) { - qdf_print("\nAlready Disabled"); + qdf_debug("Already Disabled"); } else { ce_hist->data_enable[ce_id] = 0; free_mem_ce_debug_hist_data(scn, ce_id); diff --git a/hif/src/hif_main.h b/hif/src/hif_main.h index 99bd2957797b..bd7cf8b5e42d 100644 --- a/hif/src/hif_main.h +++ b/hif/src/hif_main.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2019 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 @@ -129,7 +129,7 @@ struct hif_ce_stats { struct ce_desc_hist { qdf_atomic_t history_index[CE_COUNT_MAX]; uint32_t enable[CE_COUNT_MAX]; - uint32_t data_enable[CE_COUNT_MAX]; + bool data_enable[CE_COUNT_MAX]; qdf_mutex_t ce_dbg_datamem_lock[CE_COUNT_MAX]; uint32_t hist_index; uint32_t hist_id;