qcacmn: Add qdf debugfs API to detect buffer overflow

Add API to query qdf debugfs buffer overflow.
Add support to dump log in different block sizes.

Change-Id: I3d5b63ef2f9b0eeb4df20dbb93a76f10ed10f556
CRs-Fixed: 2307897
This commit is contained in:
Karthik Kantamneni
2018-09-03 15:01:10 +05:30
committed by nshrivas
parent e6feafc106
commit d07cfa4b67
2 changed files with 29 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017 The Linux Foundation. All rights reserved. * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
* *
* Permission to use, copy, modify, and/or distribute this software for * Permission to use, copy, modify, and/or distribute this software for
* any purpose with or without fee is hereby granted, provided that the * any purpose with or without fee is hereby granted, provided that the
@@ -111,10 +111,21 @@ void qdf_debugfs_printf(qdf_debugfs_file_t file, const char *f, ...);
* @file: debugfs file handle passed in fops->show() function. * @file: debugfs file handle passed in fops->show() function.
* @buf: data * @buf: data
* @len: data length * @len: data length
* @rowsize: row size in bytes to dump
* @groupsize: group size in bytes to dump
* *
*/ */
void qdf_debugfs_hexdump(qdf_debugfs_file_t file, const uint8_t *buf, void qdf_debugfs_hexdump(qdf_debugfs_file_t file, const uint8_t *buf,
qdf_size_t len); qdf_size_t len, int rowsize, int groupsize);
/**
* qdf_debugfs_overflow() - check overflow occurrence in debugfs buffer
* @file: debugfs file handle passed in fops->show() function.
*
* Return: 1 on overflow occurrence else 0
*
*/
bool qdf_debugfs_overflow(qdf_debugfs_file_t file);
/** /**
* qdf_debugfs_write() - write data into debugfs file * qdf_debugfs_write() - write data into debugfs file
@@ -260,10 +271,16 @@ static inline void qdf_debugfs_printf(qdf_debugfs_file_t file, const char *f,
} }
static inline void qdf_debugfs_hexdump(qdf_debugfs_file_t file, static inline void qdf_debugfs_hexdump(qdf_debugfs_file_t file,
const uint8_t *buf, qdf_size_t len) const uint8_t *buf, qdf_size_t len,
int rowsize, int groupsize)
{ {
} }
static inline bool qdf_debugfs_overflow(qdf_debugfs_file_t file)
{
return 0;
}
static inline void qdf_debugfs_write(qdf_debugfs_file_t file, static inline void qdf_debugfs_write(qdf_debugfs_file_t file,
const uint8_t *buf, qdf_size_t len) const uint8_t *buf, qdf_size_t len)
{ {

View File

@@ -170,18 +170,17 @@ void qdf_debugfs_printf(qdf_debugfs_file_t file, const char *f, ...)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
void qdf_debugfs_hexdump(qdf_debugfs_file_t file, const uint8_t *buf, void qdf_debugfs_hexdump(qdf_debugfs_file_t file, const uint8_t *buf,
qdf_size_t len) qdf_size_t len, int rowsize, int groupsize)
{ {
seq_hex_dump(file, "", DUMP_PREFIX_OFFSET, 16, 4, buf, len, false); seq_hex_dump(file, "", DUMP_PREFIX_OFFSET, rowsize, groupsize, buf, len,
false);
} }
#else #else
void qdf_debugfs_hexdump(qdf_debugfs_file_t file, const uint8_t *buf, void qdf_debugfs_hexdump(qdf_debugfs_file_t file, const uint8_t *buf,
qdf_size_t len) qdf_size_t len, int rowsize, int groupsize)
{ {
const size_t rowsize = 16;
const size_t groupsize = 4;
char *dst; char *dst;
size_t dstlen, readlen; size_t dstlen, readlen;
int prefix = 0; int prefix = 0;
@@ -206,6 +205,11 @@ void qdf_debugfs_hexdump(qdf_debugfs_file_t file, const uint8_t *buf,
#endif #endif
bool qdf_debugfs_overflow(qdf_debugfs_file_t file)
{
return seq_has_overflowed(file);
}
void qdf_debugfs_write(qdf_debugfs_file_t file, const uint8_t *buf, void qdf_debugfs_write(qdf_debugfs_file_t file, const uint8_t *buf,
qdf_size_t len) qdf_size_t len)
{ {