]>
Commit | Line | Data |
---|---|---|
cf637391 TC |
1 | /* |
2 | * CDDL HEADER START | |
3 | * | |
4 | * The contents of this file are subject to the terms of the | |
5 | * Common Development and Distribution License (the "License"). | |
6 | * You may not use this file except in compliance with the License. | |
7 | * | |
8 | * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
9 | * or http://www.opensolaris.org/os/licensing. | |
10 | * See the License for the specific language governing permissions | |
11 | * and limitations under the License. | |
12 | * | |
13 | * When distributing Covered Code, include this CDDL HEADER in each | |
14 | * file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
15 | * If applicable, add the following below this CDDL HEADER, with the | |
16 | * fields enclosed by brackets "[]" replaced with your own identifying | |
17 | * information: Portions Copyright [yyyy] [name of copyright owner] | |
18 | * | |
19 | * CDDL HEADER END | |
20 | */ | |
21 | ||
22 | #if defined(_KERNEL) && defined(HAVE_QAT) | |
23 | #include <sys/zfs_context.h> | |
24 | #include "qat.h" | |
25 | ||
26 | qat_stats_t qat_stats = { | |
27 | { "comp_requests", KSTAT_DATA_UINT64 }, | |
28 | { "comp_total_in_bytes", KSTAT_DATA_UINT64 }, | |
29 | { "comp_total_out_bytes", KSTAT_DATA_UINT64 }, | |
30 | { "decomp_requests", KSTAT_DATA_UINT64 }, | |
31 | { "decomp_total_in_bytes", KSTAT_DATA_UINT64 }, | |
32 | { "decomp_total_out_bytes", KSTAT_DATA_UINT64 }, | |
33 | { "dc_fails", KSTAT_DATA_UINT64 }, | |
34 | { "encrypt_requests", KSTAT_DATA_UINT64 }, | |
35 | { "encrypt_total_in_bytes", KSTAT_DATA_UINT64 }, | |
36 | { "encrypt_total_out_bytes", KSTAT_DATA_UINT64 }, | |
37 | { "decrypt_requests", KSTAT_DATA_UINT64 }, | |
38 | { "decrypt_total_in_bytes", KSTAT_DATA_UINT64 }, | |
39 | { "decrypt_total_out_bytes", KSTAT_DATA_UINT64 }, | |
40 | { "crypt_fails", KSTAT_DATA_UINT64 }, | |
41 | }; | |
42 | ||
43 | static kstat_t *qat_ksp = NULL; | |
44 | int zfs_qat_disable = 0; | |
45 | ||
46 | CpaStatus | |
47 | qat_mem_alloc_contig(void **pp_mem_addr, Cpa32U size_bytes) | |
48 | { | |
49 | *pp_mem_addr = kmalloc(size_bytes, GFP_KERNEL); | |
50 | if (*pp_mem_addr == NULL) | |
51 | return (CPA_STATUS_RESOURCE); | |
52 | return (CPA_STATUS_SUCCESS); | |
53 | } | |
54 | ||
55 | void | |
56 | qat_mem_free_contig(void **pp_mem_addr) | |
57 | { | |
58 | if (*pp_mem_addr != NULL) { | |
59 | kfree(*pp_mem_addr); | |
60 | *pp_mem_addr = NULL; | |
61 | } | |
62 | } | |
63 | ||
64 | int | |
65 | qat_init(void) | |
66 | { | |
67 | int ret; | |
68 | ||
69 | ret = qat_dc_init(); | |
70 | if (ret != 0) | |
71 | return (ret); | |
72 | ||
73 | ret = qat_crypt_init(); | |
74 | if (ret != 0) { | |
75 | qat_dc_fini(); | |
76 | return (ret); | |
77 | } | |
78 | ||
79 | qat_ksp = kstat_create("zfs", 0, "qat", "misc", | |
80 | KSTAT_TYPE_NAMED, sizeof (qat_stats) / sizeof (kstat_named_t), | |
81 | KSTAT_FLAG_VIRTUAL); | |
82 | if (qat_ksp != NULL) { | |
83 | qat_ksp->ks_data = &qat_stats; | |
84 | kstat_install(qat_ksp); | |
85 | } | |
86 | ||
87 | return (0); | |
88 | } | |
89 | ||
90 | void | |
91 | qat_fini(void) | |
92 | { | |
93 | if (qat_ksp != NULL) { | |
94 | kstat_delete(qat_ksp); | |
95 | qat_ksp = NULL; | |
96 | } | |
97 | ||
98 | qat_crypt_fini(); | |
99 | qat_dc_fini(); | |
100 | } | |
101 | ||
102 | #endif |