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 <sunyue5@motorola.com>
Reviewed-on: https://gerrit.mot.com/2243470
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Xianglong Liao <liaoxl@motorola.com>
Reviewed-by: Bin Liu <liubin7@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
sunyue5 2022-04-14 13:39:18 +08:00 • committed by panyq6
commit b813573e22

View file

@ -72,6 +72,11 @@
#include <wlan_crypto_global_api.h>
#include "cdp_txrx_host_stats.h"
// IKSWS-90973 BEGIN
#include <linux/fdtable.h>
#include <linux/signal.h>
// 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)