From b813573e2217e0a924d3fe62b8af2d6aa308dca1 Mon Sep 17 00:00:00 2001 From: sunyue5 Date: Thu, 14 Apr 2022 13:39:18 +0800 Subject: [PATCH] Print the process which is receiving data Print the process name can easily help us to know which APP is waking up the system, so that we can make some power consumption improvment for this APP Change-Id: Ib45ac56a0ed4d090eea7b5bd8ba5ecefd2b9ce2f Signed-off-by: sunyue5 Reviewed-on: https://gerrit.mot.com/2243470 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Xianglong Liao Reviewed-by: Bin Liu Submit-Approved: Jira Key --- core/wma/src/wma_features.c | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/core/wma/src/wma_features.c b/core/wma/src/wma_features.c index 03a51f01fbd4..e598ab8fafd6 100644 --- a/core/wma/src/wma_features.c +++ b/core/wma/src/wma_features.c @@ -72,6 +72,11 @@ #include #include "cdp_txrx_host_stats.h" +// IKSWS-90973 BEGIN +#include +#include +// IKSWS-90973 END + /** * WMA_SET_VDEV_IE_SOURCE_HOST - Flag to identify the source of VDEV SET IE * command. The value is 0x0 for the VDEV SET IE WMI commands from mobile @@ -2032,6 +2037,76 @@ wma_wow_get_pkt_proto_subtype(uint8_t *data, uint32_t len) } } +// IKSWS-90973 BEGIN, print the process that causing the wow wakeup +static int wow_check_task = 0; +module_param(wow_check_task, int, 0644); +MODULE_PARM_DESC(wow_check_task, "Check wow wakeup process"); + +static void check_task(uint16_t dport) +{ + struct task_struct *p = NULL; + struct file *file = NULL; + struct files_struct *files = NULL; + struct socket *sock = NULL; + struct sock *sk = NULL; + struct inet_sock *inet = NULL; + struct fdtable *fdt = NULL; + int i = 0, err = 0; + + for_each_process(p) + { + files = p->files; + if (files != NULL) { + spin_lock(&files->file_lock); + for (i = 0; i < NR_OPEN_DEFAULT; i++) + { + file = rcu_dereference(files->fd_array[i]); + if (file != NULL) { + sock = sock_from_file(file, &err); + if (sock) { + sk = sock->sk; + if (!sk) + continue; + if (sk->sk_family == AF_INET || sk->sk_family == AF_INET6) { + inet = inet_sk(sock->sk); + if(inet->inet_sport == dport) { + wma_info("task pid[%d], comm[%s], inet_sport[%u], inet_dport[%u]", + p->pid, p->comm, qdf_cpu_to_be16(inet->inet_sport), qdf_cpu_to_be16(inet->inet_dport)); + spin_unlock(&files->file_lock); + return; + } + } + } + } + } + fdt = files_fdtable(files); + for (i = 0; i < fdt->max_fds; i++) { + file = rcu_dereference_check_fdtable(files, fdt->fd[i]); + if (!file) + continue; + sock = sock_from_file(file, &err); + if (sock) { + sk = sock->sk; + if (!sk) + continue; + if (sk->sk_family == AF_INET || sk->sk_family == AF_INET6) { + inet = inet_sk(sock->sk); + if(inet->inet_sport == dport) { + wma_info("task pid[%d], comm[%s], inet_sport[%u], inet_dport[%u]", + p->pid, p->comm, qdf_cpu_to_be16(inet->inet_sport), qdf_cpu_to_be16(inet->inet_dport)); + spin_unlock(&files->file_lock); + return; + } + } + } + } + spin_unlock(&files->file_lock); + } + } + wma_info("No process have the dport[%u]", qdf_cpu_to_be16(dport)); +} +// IKSWS-90973 END + static void wma_log_pkt_eapol(uint8_t *data, uint32_t length) { uint16_t pkt_len, key_len; @@ -2106,6 +2181,10 @@ static void wma_log_pkt_ipv4(uint8_t *data, uint32_t length) qdf_cpu_to_be16(pkt_len), qdf_cpu_to_be16(src_port), qdf_cpu_to_be16(dst_port)); + // IKSWS-90973 BEGIN + if (wow_check_task) + check_task(dst_port); + // IKSWS-90973 END } static void wma_log_pkt_ipv6(uint8_t *data, uint32_t length) @@ -2137,6 +2216,10 @@ static void wma_log_pkt_ipv6(uint8_t *data, uint32_t length) qdf_cpu_to_be16(pkt_len), qdf_cpu_to_be16(src_port), qdf_cpu_to_be16(dst_port)); + // IKSWS-90973 BEGIN + if (wow_check_task) + check_task(dst_port); + // IKSWS-90973 END } static void wma_log_pkt_tcpv4(uint8_t *data, uint32_t length)