From d07cfa4b67e060b53d9710f5797e107190f636ee Mon Sep 17 00:00:00 2001 From: Karthik Kantamneni Date: Mon, 3 Sep 2018 15:01:10 +0530 Subject: [PATCH] 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 --- qdf/inc/qdf_debugfs.h | 23 ++++++++++++++++++++--- qdf/linux/src/qdf_debugfs.c | 14 +++++++++----- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/qdf/inc/qdf_debugfs.h b/qdf/inc/qdf_debugfs.h index 99017e1b38aa..b4e965ccd8df 100644 --- a/qdf/inc/qdf_debugfs.h +++ b/qdf/inc/qdf_debugfs.h @@ -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 * 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. * @buf: data * @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, - 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 @@ -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, - 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, const uint8_t *buf, qdf_size_t len) { diff --git a/qdf/linux/src/qdf_debugfs.c b/qdf/linux/src/qdf_debugfs.c index 054a1ee12d3f..66664a96274c 100644 --- a/qdf/linux/src/qdf_debugfs.c +++ b/qdf/linux/src/qdf_debugfs.c @@ -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)) 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 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; size_t dstlen, readlen; int prefix = 0; @@ -206,6 +205,11 @@ void qdf_debugfs_hexdump(qdf_debugfs_file_t file, const uint8_t *buf, #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, qdf_size_t len) {