1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) Nelson Integration, LLC 2016
4 * Author: Eric Nelson<eric@nelint.com>
13 static int blkc_show(struct cmd_tbl
*cmdtp
, int flag
,
14 int argc
, char *const argv
[])
16 struct block_cache_stats stats
;
17 blkcache_stats(&stats
);
22 "max blocks/entry: %u\n"
23 "max cache entries: %u\n",
24 stats
.hits
, stats
.misses
, stats
.entries
,
25 stats
.max_blocks_per_entry
, stats
.max_entries
);
29 static int blkc_configure(struct cmd_tbl
*cmdtp
, int flag
,
30 int argc
, char *const argv
[])
32 unsigned blocks_per_entry
, max_entries
;
36 blocks_per_entry
= simple_strtoul(argv
[1], 0, 0);
37 max_entries
= simple_strtoul(argv
[2], 0, 0);
38 blkcache_configure(blocks_per_entry
, max_entries
);
39 printf("changed to max of %u entries of %u blocks each\n",
40 max_entries
, blocks_per_entry
);
44 static struct cmd_tbl cmd_blkc_sub
[] = {
45 U_BOOT_CMD_MKENT(show
, 0, 0, blkc_show
, "", ""),
46 U_BOOT_CMD_MKENT(configure
, 3, 0, blkc_configure
, "", ""),
49 static int do_blkcache(struct cmd_tbl
*cmdtp
, int flag
,
50 int argc
, char *const argv
[])
57 /* Strip off leading argument */
61 c
= find_cmd_tbl(argv
[0], &cmd_blkc_sub
[0], ARRAY_SIZE(cmd_blkc_sub
));
66 return c
->cmd(cmdtp
, flag
, argc
, argv
);
70 blkcache
, 4, 0, do_blkcache
,
71 "block cache diagnostics and control",
72 "show - show and reset statistics\n"
73 "blkcache configure <blocks> <entries> "
74 "- set max blocks per entry and max cache entries\n"