1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /* Copyright(c) 2007-2022 Intel Corporation */
3 /* $FreeBSD$ */
4 #include "adf_c4xxx_hw_data.h"
5 #include "adf_c4xxx_misc_error_stats.h"
6 #include "adf_common_drv.h"
7 #include "adf_cfg_common.h"
8 #include <sys/sbuf.h>
9 #include <sys/sysctl.h>
10
11 #define MISC_ERROR_DBG_FILE "misc_error_stats"
12 #define LINE \
13 "+-----------------------------------------------------------------+\n"
14 #define BANNER \
15 "| Miscellaneous Error Statistics for Qat Device |\n"
16
17 static void *misc_counter;
18
19 struct adf_dev_miscellaneous_stats {
20 u64 misc_counter;
21 };
22
23 static int qat_misc_error_show(SYSCTL_HANDLER_ARGS)
24 {
25 struct sbuf sb;
26
27 sbuf_new_for_sysctl(&sb, NULL, 256, req);
28 sbuf_printf(&sb, "\n");
29 sbuf_printf(&sb, LINE);
30 sbuf_printf(&sb,
31 "| Miscellaneous Error: %40llu |\n",
32 (unsigned long long)((struct adf_dev_miscellaneous_stats *)
33 misc_counter)
34 ->misc_counter);
35
36 sbuf_finish(&sb);
37 SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb));
38 sbuf_delete(&sb);
39
40 return 0;
41 }
42
43 /**
44 * adf_misc_error_add_c4xxx() - Create debugfs entry for
45 * acceleration device Freq counters.
46 * @accel_dev: Pointer to acceleration device.
47 *
48 * Return: 0 on success, error code otherwise.
49 */
50 int
51 adf_misc_error_add_c4xxx(struct adf_accel_dev *accel_dev)
52 {
53 struct sysctl_ctx_list *qat_sysctl_ctx = NULL;
54 struct sysctl_oid *qat_sysctl_tree = NULL;
55 struct sysctl_oid *misc_er_file = NULL;
56
57 qat_sysctl_ctx =
58 device_get_sysctl_ctx(accel_dev->accel_pci_dev.pci_dev);
59 qat_sysctl_tree =
60 device_get_sysctl_tree(accel_dev->accel_pci_dev.pci_dev);
61
62 misc_er_file = SYSCTL_ADD_PROC(qat_sysctl_ctx,
63 SYSCTL_CHILDREN(qat_sysctl_tree),
64 OID_AUTO,
65 MISC_ERROR_DBG_FILE,
66 CTLTYPE_STRING | CTLFLAG_RD,
67 accel_dev,
68 0,
69 qat_misc_error_show,
70 "A",
71 "QAT Miscellaneous Error Statistics");
72 accel_dev->misc_error_dbgfile = misc_er_file;
73 if (!accel_dev->misc_error_dbgfile) {
74 device_printf(
75 GET_DEV(accel_dev),
76 "Failed to create qat miscellaneous error debugfs entry.\n");
77 return ENOENT;
78 }
79
80 misc_counter = kmalloc(PAGE_SIZE, GFP_KERNEL);
81 if (!misc_counter)
82 return ENOMEM;
83
84 memset(misc_counter, 0, PAGE_SIZE);
85
86 return 0;
87 }
88
89 /**
90 * adf_misc_error_remove_c4xxx() - Remove debugfs entry for
91 * acceleration device misc error counter.
92 * @accel_dev: Pointer to acceleration device.
93 *
94 * Return: void
95 */
96 void
97 adf_misc_error_remove_c4xxx(struct adf_accel_dev *accel_dev)
98 {
99 if (accel_dev->misc_error_dbgfile) {
100 remove_oid(accel_dev, accel_dev->misc_error_dbgfile);
101 accel_dev->misc_error_dbgfile = NULL;
102 }
103
104 kfree(misc_counter);
105 misc_counter = NULL;
106 }
Cache object: b0d7e9dd6e5ad2cf4d0e893339cab316
|