Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / crypto / isa-l / isal_crypto_plugin.h
1 /*
2  * Ceph - scalable distributed file system
3  *
4  * Copyright (C) 2016 Mirantis, Inc.
5  *
6  * Author: Adam Kupczyk <akupczyk@mirantis.com>
7  *
8  *  This library is free software; you can redistribute it and/or
9  *  modify it under the terms of the GNU Lesser General Public
10  *  License as published by the Free Software Foundation; either
11  *  version 2.1 of the License, or (at your option) any later version.
12  *
13  */
14
15 #ifndef ISAL_CRYPTO_PLUGIN_H
16 #define ISAL_CRYPTO_PLUGIN_H
17 // -----------------------------------------------------------------------------
18 #include "crypto/crypto_plugin.h"
19 #include "crypto/isa-l/isal_crypto_accel.h"
20 #include "arch/intel.h"
21 #include "arch/probe.h"
22 // -----------------------------------------------------------------------------
23
24
25 class ISALCryptoPlugin : public CryptoPlugin {
26
27   CryptoAccelRef cryptoaccel;
28 public:
29
30   explicit ISALCryptoPlugin(CephContext* cct) : CryptoPlugin(cct)
31   {}
32   ~ISALCryptoPlugin()
33   {}
34   virtual int factory(CryptoAccelRef *cs,
35                       ostream *ss)
36   {
37     if (cryptoaccel == nullptr)
38     {
39       ceph_arch_probe();
40       if (ceph_arch_intel_aesni && ceph_arch_intel_sse41) {
41         cryptoaccel = CryptoAccelRef(new ISALCryptoAccel);
42       }
43     }
44     *cs = cryptoaccel;
45     return 0;
46   }
47 };
48 #endif