]> git.proxmox.com Git - ceph.git/blob - ceph/src/compressor/QatAccel.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / compressor / QatAccel.h
1 /*
2 * Ceph - scalable distributed file system
3 *
4 * Copyright (C) 2018 Intel Corporation
5 *
6 * Author: Qiaowei Ren <qiaowei.ren@intel.com>
7 *
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
12 *
13 */
14
15 #ifndef CEPH_QATACCEL_H
16 #define CEPH_QATACCEL_H
17
18 #include <condition_variable>
19 #include <memory>
20 #include <mutex>
21 #include <optional>
22 #include <vector>
23
24 #include "include/buffer.h"
25
26 extern "C" struct QzSession_S; // typedef struct QzSession_S QzSession_T;
27
28 struct QzSessionDeleter {
29 void operator() (struct QzSession_S *session);
30 };
31
32 class QatAccel {
33 public:
34 using session_ptr = std::unique_ptr<struct QzSession_S, QzSessionDeleter>;
35 QatAccel();
36 ~QatAccel();
37
38 bool init(const std::string &alg);
39
40 int compress(const bufferlist &in, bufferlist &out, std::optional<int32_t> &compressor_message);
41 int decompress(const bufferlist &in, bufferlist &out, std::optional<int32_t> compressor_message);
42 int decompress(bufferlist::const_iterator &p, size_t compressed_len, bufferlist &dst, std::optional<int32_t> compressor_message);
43
44 private:
45 // get a session from the pool or create a new one. returns null if session init fails
46 session_ptr get_session();
47
48 friend struct cached_session_t;
49 std::vector<session_ptr> sessions;
50 std::mutex mutex;
51 std::string alg_name;
52 };
53
54 #endif