1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) Nelson Integration, LLC 2016
4 * Author: Eric Nelson<eric@nelint.com>
12 static int blkc_show(cmd_tbl_t *cmdtp, int flag,
13 int argc, char * const argv[])
15 struct block_cache_stats stats;
16 blkcache_stats(&stats);
21 "max blocks/entry: %u\n"
22 "max cache entries: %u\n",
23 stats.hits, stats.misses, stats.entries,
24 stats.max_blocks_per_entry, stats.max_entries);
28 static int blkc_configure(cmd_tbl_t *cmdtp, int flag,
29 int argc, char * const argv[])
31 unsigned blocks_per_entry, max_entries;
35 blocks_per_entry = simple_strtoul(argv[1], 0, 0);
36 max_entries = simple_strtoul(argv[2], 0, 0);
37 blkcache_configure(blocks_per_entry, max_entries);
38 printf("changed to max of %u entries of %u blocks each\n",
39 max_entries, blocks_per_entry);
43 static cmd_tbl_t cmd_blkc_sub[] = {
44 U_BOOT_CMD_MKENT(show, 0, 0, blkc_show, "", ""),
45 U_BOOT_CMD_MKENT(configure, 3, 0, blkc_configure, "", ""),
48 static __maybe_unused void blkc_reloc(void)
53 fixup_cmdtable(cmd_blkc_sub, ARRAY_SIZE(cmd_blkc_sub));
58 static int do_blkcache(cmd_tbl_t *cmdtp, int flag,
59 int argc, char * const argv[])
63 #ifdef CONFIG_NEEDS_MANUAL_RELOC
69 /* Strip off leading argument */
73 c = find_cmd_tbl(argv[0], &cmd_blkc_sub[0], ARRAY_SIZE(cmd_blkc_sub));
78 return c->cmd(cmdtp, flag, argc, argv);
82 blkcache, 4, 0, do_blkcache,
83 "block cache diagnostics and control",
84 "show - show and reset statistics\n"
85 "blkcache configure blocks entries\n"