]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/crypto/isa-l/isa-l_crypto/aes/xts_128_enc_perf.c
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / crypto / isa-l / isa-l_crypto / aes / xts_128_enc_perf.c
index 1fce1665c2d18688e8338e2c7f3a0ec288226062..166e46652a0cac1bf2d50aef85627453a2f40de6 100644 (file)
@@ -2,7 +2,7 @@
   Copyright(c) 2011-2016 Intel Corporation All rights reserved.
 
   Redistribution and use in source and binary forms, with or without
-  modification, are permitted provided that the following conditions 
+  modification, are permitted provided that the following conditions
   are met:
     * Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
 #include <stdlib.h>            // for rand
 #include <string.h>            // for memcmp
 #include "aes_xts.h"
+#include "aes_keyexp.h"
 #include "test.h"
 
 //#define CACHED_TEST
 #ifdef CACHED_TEST
 // Cached test, loop many times over small dataset
 # define TEST_LEN     8*1024
-# define TEST_LOOPS   400000
+# define TEST_LOOPS   3000000
 # define TEST_TYPE_STR "_warm"
 #else
 // Uncached test.  Pull from large mem base.
 #  define GT_L3_CACHE  32*1024*1024    /* some number > last level cache */
 #  define TEST_LEN     (2 * GT_L3_CACHE)
-#  define TEST_LOOPS   50
+#  define TEST_LOOPS   400
 #  define TEST_TYPE_STR "_cold"
 #endif
 
@@ -69,6 +70,8 @@ int main(void)
 
        unsigned char key1[16], key2[16], tinit[16];
        unsigned char *pt, *ct;
+       uint8_t expkey1_enc[16 * 11], expkey2_enc[16 * 11];
+       uint8_t expkey1_dec[16 * 11], null_key[16 * 11];
 
        printf("aes_xts_128_enc_perf:\n");
 
@@ -80,6 +83,8 @@ int main(void)
                return -1;
        }
 
+       /* Encode perf test */
+
        mk_rand_data(key1, key2, tinit, pt, TEST_LEN);
        XTS_AES_128_enc(key2, key1, tinit, TEST_LEN, pt, ct);
 
@@ -93,7 +98,25 @@ int main(void)
 
        perf_stop(&stop);
 
-       printf("aes_xts_128_enc" TEST_TYPE_STR ": ");
+       printf("aes_xts_128_enc" TEST_TYPE_STR ":              ");
+       perf_print(stop, start, (long long)TEST_LEN * i);
+
+       /* Expanded keys perf test */
+
+       aes_keyexp_128(key1, expkey1_enc, expkey1_dec);
+       aes_keyexp_128(key2, expkey2_enc, null_key);
+       XTS_AES_128_enc_expanded_key(expkey2_enc, expkey1_enc, tinit, TEST_LEN, pt, ct);
+
+       perf_start(&start);
+
+       for (i = 0; i < TEST_LOOPS; i++) {
+               XTS_AES_128_enc_expanded_key(expkey2_enc, expkey1_enc, tinit, TEST_LEN, pt,
+                                            ct);
+       }
+
+       perf_stop(&stop);
+
+       printf("aes_xts_128_enc_expanded_key" TEST_TYPE_STR ": ");
        perf_print(stop, start, (long long)TEST_LEN * i);
 
        return 0;