From ab99a27dc107fe2d829cabf9cf4c73b8273c4aee Mon Sep 17 00:00:00 2001 From: "Poddar, Siddarth" Date: Mon, 10 Apr 2017 12:53:26 +0530 Subject: [PATCH] qcacld-3.0: Add iwpriv pktlog command to clear pktlog buffer Implement iwpriv pktlog command to clear pktlog buffer. This command is effective only if pktlog disable is issued previously. This command needs one argument. Command to use this feature : iwpriv wlan0 pktlog 4 CRs-Fixed: 2031210 Change-Id: I19d695c30608ab8cde21ee251eee5c5d43d89751 --- core/hdd/src/wlan_hdd_cfg80211.c | 1 + core/hdd/src/wlan_hdd_main.c | 36 +++++++++++++++++++++++++++++++- core/mac/inc/sir_api.h | 2 ++ core/sme/src/common/sme_api.c | 1 + core/wma/src/wma_main.c | 3 +++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c index 038db8a156..d008e4df83 100644 --- a/core/hdd/src/wlan_hdd_cfg80211.c +++ b/core/hdd/src/wlan_hdd_cfg80211.c @@ -4918,6 +4918,7 @@ static int __wlan_hdd_cfg80211_wifi_logger_start(struct wiphy *wiphy, /* size is buff size which can be set using iwpriv command*/ start_log.size = 0; + start_log.is_pktlog_buff_clear = false; cds_set_ring_log_level(start_log.ring_id, start_log.verbose_level); diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 787c14ffbd..306c5638ff 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -7973,6 +7973,7 @@ static inline void hdd_release_rtnl_lock(void) { } /* MAX iwpriv command support */ #define PKTLOG_SET_BUFF_SIZE 3 +#define PKTLOG_CLEAR_BUFF 4 #define MAX_PKTLOG_SIZE 16 /** @@ -7993,6 +7994,7 @@ static int hdd_pktlog_set_buff_size(hdd_context_t *hdd_ctx, int set_value2) start_log.ini_triggered = cds_is_packet_log_enabled(); start_log.user_triggered = 1; start_log.size = set_value2; + start_log.is_pktlog_buff_clear = false; status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); if (!QDF_IS_STATUS_SUCCESS(status)) { @@ -8004,6 +8006,35 @@ static int hdd_pktlog_set_buff_size(hdd_context_t *hdd_ctx, int set_value2) return 0; } +/** + * hdd_pktlog_clear_buff() - clear pktlog buffer + * @hdd_ctx: hdd context + * + * Return: 0 for success or error. + */ +static int hdd_pktlog_clear_buff(hdd_context_t *hdd_ctx) +{ + struct sir_wifi_start_log start_log; + QDF_STATUS status; + + start_log.ring_id = RING_ID_PER_PACKET_STATS; + start_log.verbose_level = WLAN_LOG_LEVEL_OFF; + start_log.ini_triggered = cds_is_packet_log_enabled(); + start_log.user_triggered = 1; + start_log.size = 0; + start_log.is_pktlog_buff_clear = true; + + status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); + if (!QDF_IS_STATUS_SUCCESS(status)) { + hdd_err("sme_wifi_start_logger failed(err=%d)", status); + EXIT(); + return -EINVAL; + } + + return 0; +} + + /** * hdd_process_pktlog_command() - process pktlog command * @hdd_ctx: hdd context @@ -8029,7 +8060,7 @@ int hdd_process_pktlog_command(hdd_context_t *hdd_ctx, uint32_t set_value, hdd_debug("set pktlog %d, set size %d", set_value, set_value2); - if (set_value > PKTLOG_SET_BUFF_SIZE) { + if (set_value > PKTLOG_CLEAR_BUFF) { hdd_err("invalid pktlog value %d", set_value); return -EINVAL; } @@ -8043,6 +8074,8 @@ int hdd_process_pktlog_command(hdd_context_t *hdd_ctx, uint32_t set_value, return -EINVAL; } return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); + } else if (set_value == PKTLOG_CLEAR_BUFF) { + return hdd_pktlog_clear_buff(hdd_ctx); } /* @@ -8082,6 +8115,7 @@ int hdd_pktlog_enable_disable(hdd_context_t *hdd_ctx, bool enable, start_log.ini_triggered = cds_is_packet_log_enabled(); start_log.user_triggered = user_triggered; start_log.size = size; + start_log.is_pktlog_buff_clear = false; /* * Use "is_iwpriv_command" flag to distinguish iwpriv command from other * commands. Host uses this flag to decide whether to send pktlog diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h index 5aa9c5e7ed..b5c3ef283d 100644 --- a/core/mac/inc/sir_api.h +++ b/core/mac/inc/sir_api.h @@ -3238,6 +3238,7 @@ typedef struct { * @ini_triggered: triggered using ini * @user_triggered: triggered by user * @size: pktlog buffer size + * @is_pktlog_buff_clear: clear the pktlog buffer */ struct sir_wifi_start_log { uint32_t ring_id; @@ -3246,6 +3247,7 @@ struct sir_wifi_start_log { bool ini_triggered; uint8_t user_triggered; int size; + bool is_pktlog_buff_clear; }; diff --git a/core/sme/src/common/sme_api.c b/core/sme/src/common/sme_api.c index 1dd31735c0..fc14aa06a7 100644 --- a/core/sme/src/common/sme_api.c +++ b/core/sme/src/common/sme_api.c @@ -14215,6 +14215,7 @@ QDF_STATUS sme_wifi_start_logger(tHalHandle hal, req_msg->ini_triggered = start_log.ini_triggered; req_msg->user_triggered = start_log.user_triggered; req_msg->size = start_log.size; + req_msg->is_pktlog_buff_clear = start_log.is_pktlog_buff_clear; status = sme_acquire_global_lock(&mac->sme); if (status != QDF_STATUS_SUCCESS) { diff --git a/core/wma/src/wma_main.c b/core/wma/src/wma_main.c index f844fb227d..4d3b9db1a0 100644 --- a/core/wma/src/wma_main.c +++ b/core/wma/src/wma_main.c @@ -5963,6 +5963,9 @@ static void wma_set_wifi_start_packet_stats(void *wma_handle, if (start_log->size != 0) { pktlog_setsize(scn, start_log->size * MEGABYTE); return; + } else if (start_log->is_pktlog_buff_clear == true) { + pktlog_clearbuff(scn, start_log->is_pktlog_buff_clear); + return; } if (start_log->verbose_level == WLAN_LOG_LEVEL_ACTIVE) {