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_pke_replay_stats.h"
6 #include "adf_common_drv.h"
7 #include "icp_qat_fw_init_admin.h"
8 #include <sys/sbuf.h>
9 #include <sys/sysctl.h>
10
11 #define PKE_REPLAY_DBG_FILE "pke_replay_stats"
12 #define LINE \
13 "+-----------------------------------------------------------------+\n"
14 #define BANNER \
15 "| PKE Replay Statistics for Qat Device |\n"
16
17 static int qat_pke_replay_counters_show(SYSCTL_HANDLER_ARGS)
18 {
19 struct sbuf sb;
20 struct adf_accel_dev *accel_dev = arg1;
21 int ret = 0;
22 u64 suc_counter = 0;
23 u64 unsuc_counter = 0;
24
25 sbuf_new_for_sysctl(&sb, NULL, 256, req);
26
27 sbuf_printf(&sb, "\n");
28 sbuf_printf(&sb, LINE);
29
30 ret = adf_get_fw_pke_stats(accel_dev, &suc_counter, &unsuc_counter);
31 if (ret)
32 return ret;
33
34 sbuf_printf(
35 &sb,
36 "| Successful Replays: %40llu |\n| Unsuccessful Replays: %40llu |\n",
37 (unsigned long long)suc_counter,
38 (unsigned long long)unsuc_counter);
39
40 sbuf_finish(&sb);
41 SYSCTL_OUT(req, sbuf_data(&sb), sbuf_len(&sb));
42 sbuf_delete(&sb);
43
44 return 0;
45 }
46
47 /**
48 * adf_pke_replay_counters_add_c4xxx() - Create debugfs entry for
49 * acceleration device Freq counters.
50 * @accel_dev: Pointer to acceleration device.
51 *
52 * Return: 0 on success, error code otherwise.
53 */
54 int
55 adf_pke_replay_counters_add_c4xxx(struct adf_accel_dev *accel_dev)
56 {
57 struct sysctl_ctx_list *qat_sysctl_ctx = NULL;
58 struct sysctl_oid *qat_sysctl_tree = NULL;
59 struct sysctl_oid *pke_rep_file = NULL;
60
61 qat_sysctl_ctx =
62 device_get_sysctl_ctx(accel_dev->accel_pci_dev.pci_dev);
63 qat_sysctl_tree =
64 device_get_sysctl_tree(accel_dev->accel_pci_dev.pci_dev);
65
66 pke_rep_file = SYSCTL_ADD_PROC(qat_sysctl_ctx,
67 SYSCTL_CHILDREN(qat_sysctl_tree),
68 OID_AUTO,
69 PKE_REPLAY_DBG_FILE,
70 CTLTYPE_STRING | CTLFLAG_RD,
71 accel_dev,
72 0,
73 qat_pke_replay_counters_show,
74 "A",
75 "QAT PKE Replay Statistics");
76 accel_dev->pke_replay_dbgfile = pke_rep_file;
77 if (!accel_dev->pke_replay_dbgfile) {
78 device_printf(
79 GET_DEV(accel_dev),
80 "Failed to create qat pke replay debugfs entry.\n");
81 return ENOENT;
82 }
83 return 0;
84 }
85
86 /**
87 * adf_pke_replay_counters_remove_c4xxx() - Remove debugfs entry for
88 * acceleration device Freq counters.
89 * @accel_dev: Pointer to acceleration device.
90 *
91 * Return: void
92 */
93 void
94 adf_pke_replay_counters_remove_c4xxx(struct adf_accel_dev *accel_dev)
95 {
96 if (accel_dev->pke_replay_dbgfile) {
97 remove_oid(accel_dev, accel_dev->pke_replay_dbgfile);
98 accel_dev->pke_replay_dbgfile = NULL;
99 }
100 }
Cache object: 7f319b2286819aa1ebc19843552b1fa8
|