summaryrefslogtreecommitdiffstats
path: root/cpukit/libblock/include/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-06-12 09:46:09 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-06-12 10:12:40 +0200
commit9f527308d7248d1ec1d63f0911757bb5faa7ea10 (patch)
tree27943302132f4b86a1ea3c6089407b45d23c66cb /cpukit/libblock/include/rtems
parentlibblock: Remove const qualifier (diff)
downloadrtems-9f527308d7248d1ec1d63f0911757bb5faa7ea10.tar.bz2
libblock: Add block device statistics
Diffstat (limited to 'cpukit/libblock/include/rtems')
-rw-r--r--cpukit/libblock/include/rtems/bdbuf.h13
-rw-r--r--cpukit/libblock/include/rtems/blkdev.h35
-rw-r--r--cpukit/libblock/include/rtems/diskdevs.h67
3 files changed, 115 insertions, 0 deletions
diff --git a/cpukit/libblock/include/rtems/bdbuf.h b/cpukit/libblock/include/rtems/bdbuf.h
index f63c1c548c..6c6eb76a42 100644
--- a/cpukit/libblock/include/rtems/bdbuf.h
+++ b/cpukit/libblock/include/rtems/bdbuf.h
@@ -662,6 +662,19 @@ rtems_bdbuf_purge_dev (rtems_disk_device *dd);
rtems_status_code
rtems_bdbuf_set_block_size (rtems_disk_device *dd, uint32_t block_size);
+/**
+ * @brief Returns the block device statistics.
+ */
+void
+rtems_bdbuf_get_device_stats (const rtems_disk_device *dd,
+ rtems_blkdev_stats *stats);
+
+/**
+ * @brief Resets the block device statistics.
+ */
+void
+rtems_bdbuf_reset_device_stats (rtems_disk_device *dd);
+
/** @} */
#ifdef __cplusplus
diff --git a/cpukit/libblock/include/rtems/blkdev.h b/cpukit/libblock/include/rtems/blkdev.h
index 7c2787204a..ccc8981c35 100644
--- a/cpukit/libblock/include/rtems/blkdev.h
+++ b/cpukit/libblock/include/rtems/blkdev.h
@@ -16,7 +16,9 @@
#include <rtems.h>
#include <rtems/diskdevs.h>
+#include <rtems/bspIo.h>
#include <sys/ioctl.h>
+#include <stdio.h>
#ifdef __cplusplus
extern "C" {
@@ -161,6 +163,8 @@ typedef struct rtems_blkdev_request {
#define RTEMS_BLKIO_CAPABILITIES _IO('B', 8)
#define RTEMS_BLKIO_GETDISKDEV _IOR('B', 9, rtems_disk_device *)
#define RTEMS_BLKIO_PURGEDEV _IO('B', 10)
+#define RTEMS_BLKIO_GETDEVSTATS _IOR('B', 11, rtems_blkdev_stats *)
+#define RTEMS_BLKIO_RESETDEVSTATS _IO('B', 12)
/** @} */
@@ -208,6 +212,19 @@ static inline int rtems_disk_fd_purge(int fd)
return ioctl(fd, RTEMS_BLKIO_PURGEDEV);
}
+static inline int rtems_disk_fd_get_device_stats(
+ int fd,
+ rtems_blkdev_stats *stats
+)
+{
+ return ioctl(fd, RTEMS_BLKIO_GETDEVSTATS, stats);
+}
+
+static inline int rtems_disk_fd_reset_device_stats(int fd)
+{
+ return ioctl(fd, RTEMS_BLKIO_RESETDEVSTATS);
+}
+
/**
* Only consecutive multi-sector buffer requests are supported.
*
@@ -361,6 +378,24 @@ rtems_status_code rtems_blkdev_create_partition(
rtems_blkdev_bnum block_count
);
+/**
+ * @brief Prints the block device statistics.
+ */
+void rtems_blkdev_print_stats(
+ const rtems_blkdev_stats *stats,
+ rtems_printk_plugin_t print,
+ void *print_arg
+);
+
+/**
+ * @brief Block device statistics command.
+ */
+void rtems_blkstats(
+ FILE *output,
+ const char *device,
+ bool reset
+);
+
/** @} */
#ifdef __cplusplus
diff --git a/cpukit/libblock/include/rtems/diskdevs.h b/cpukit/libblock/include/rtems/diskdevs.h
index 6e6be5e9b7..3a9967ecb2 100644
--- a/cpukit/libblock/include/rtems/diskdevs.h
+++ b/cpukit/libblock/include/rtems/diskdevs.h
@@ -87,6 +87,68 @@ typedef struct {
} rtems_blkdev_read_ahead;
/**
+ * @brief Block device statistics.
+ *
+ * Integer overflows in the statistic counters may happen.
+ */
+typedef struct {
+ /**
+ * @brief Read hit count.
+ *
+ * A read hit occurs in the rtems_bdbuf_read() function in case the block is
+ * in the cached or modified state.
+ */
+ uint32_t read_hits;
+
+ /**
+ * @brief Read miss count.
+ *
+ * A read miss occurs in the rtems_bdbuf_read() function in case the block is
+ * in the empty state and a read transfer must be initiated to read the data
+ * from the device.
+ */
+ uint32_t read_misses;
+
+ /**
+ * @brief Read-ahead transfer count.
+ *
+ * Each read-ahead transfer may read multiple blocks.
+ */
+ uint32_t read_ahead_transfers;
+
+ /**
+ * @brief Count of blocks transfered from the device.
+ */
+ uint32_t read_blocks;
+
+ /**
+ * @brief Read error count.
+ *
+ * Error count of transfers issued by the read or read-ahead requests.
+ */
+ uint32_t read_errors;
+
+ /**
+ * @brief Write transfer count.
+ *
+ * Each write transfer may write multiple blocks.
+ */
+ uint32_t write_transfers;
+
+ /**
+ * @brief Count of blocks transfered to the device.
+ */
+ uint32_t write_blocks;
+
+ /**
+ * @brief Write error count.
+ *
+ * Error count of transfers issued by write requests.
+ */
+ uint32_t write_errors;
+} rtems_blkdev_stats;
+
+/**
* @brief Description of a disk device (logical and physical disks).
*
* An array of pointer tables to rtems_disk_device structures is maintained.
@@ -202,6 +264,11 @@ struct rtems_disk_device {
bool deleted;
/**
+ * @brief Device statistics for this disk.
+ */
+ rtems_blkdev_stats stats;
+
+ /**
* @brief Read-ahead control for this disk.
*/
rtems_blkdev_read_ahead read_ahead;